VARKON Version 1.17 1999-05-07

### Creating your own user interface

The UNIX-version of VARKON is based on the X window system for its user interface. The Windows version of VARKON uses the 32-bit WIN32 API currently used in Windows95/98 and NT.

Basic elements of the interface are menus, toolbars, functionkeys, and windows. All these are defined in external textfiles called MDF. A standard setup is of course included in the system but creating your own interface is important if you want to develop a nice application.

Editing a MDF-file is a simple way of replacing standard menus for menus of your own but if you need more detailed control you can also use the MBS language to manually program a user dialogue. MBS includes a number of high level routines to create windows buttons, icons and edit fields and to manage events from these. Here's a simple example.....

    MACRO MODULE show_message(STRING message_text*132);

      INT main_id,button1_id,button2_id,event_id;

    BEGINMODULE

      main_id:=cre_win(vec(20,20),400,200,"APPLICATION MESSAGE");
      button1_id:=cre_button(main_id,vec(10,30),20,350,0,message_text);
      button2_id:=cre_button(main_id,vec(10,150),50,50,5,"Okey");
      show_win(main_id);

      loop: event_id:=wait_win(main_id);

      if event_id = button2_id then
        del_win(main_id);
        exit();
      else
        goto loop;
      endif;

    ENDMODULE

This simple MACRO program creates a window with a message and a button with the label Okey. When the user clicks his mouse in the Okey button the program kills the window and exits. Note that this program will run without changes (or recompilation) on any UNIX platform as well as the Windows 95/98 and NT platforms.

A MACRO module can also be used to create or update a DRAWING or GEOMETRY module! The following routines are used for this purpose...

add_mbs(routine_name,par1,par2....parn); ! Adds a statement to active module
parval:=getp_mbs(id,parnum); ! Gets the value of a parameter
updp_mbs(id,parnum,parval,mode); ! Changes a parameter and reevaluates
updpp_mbs(id,parnum,parval,mode); ! Same for part
del_mbs(id); ! Deletes statement
run_mbs(); ! Reevaluates entire module

VARKON Homepage | Index