Managing menus

GiD offers you the opportunity to customize the pull-down menus. You can add new menus or to change the existing ones. If you are creating a problem type, these functions should be called from the InitGIDProject or InitGIDPostProcess functions (see TCL/TK EXTENSION ).

Note: Menus and option menus are identified by their names.

Note: It is not necessary to restore the menus when leaving the problem type, GiD does this automatically.

The Tcl functions are:

Creates a new menu. New menus are inserted between the Calculate and Help menus.

"PRE" to create the menu only in GiD Preprocess.

"POST" to create the menu only in GiD Postprocess.

"PREPOST" to create the menu in both Pre- and Postprocess.

Deletes a menu.

"PRE" to delete the menu only in GiD Preprocess.

"POST" to delete the menu only in GiD Postprocess.

"PREPOST" to delete the menu in both Pre- and Postprocess.

Creates a new option for a given menu in a given position (positions start at 0, the word 'end' can be used for the last one).

The option name, is a menu sublevels sublevels list, like [list "List" "Points"]

If you wish to insert a separator line in the menu, put "---" as the option_name.

"PRE" to insert the option into GiD Preprocess menus.

"POST" to insert the option into GiD Postprocess menus.

"PREPOST" to insert the option into both Pre- and Postprocess menus.

Removes an option from a given menu.

"PRE" to insert the option into GiD Preprocess menus.

"POST" to insert the option into GiD Postprocess menus.

"PREPOST" to insert the option into both Pre- and Postprocess menus.

Edit an existent option from a given menu

some parameters can be '-default-' to keep the current value for the command, accelerator, etc

Updates changes made on menus. This function must be called when all calls to create, delete or modify menus are made.

This commands can be used to specify a callback procedure name to be called to do some change to the original menus

GiD_RegisterPluginAddedMenuProc <procname>

GiD_UnRegisterPluginAddedMenuProc <procname>

The procedure prototype to be registered must not expect any parameter, something like this.

proc <procname> { } {

... do something ...

}

e.g. a plugin can modify a menu to add some entry, but this entry will be lost when GiD create again all menus, for example when starting a new model. Registering the procedure will be applied again when recreating menus.

This tcl command must be used to register a procedure that is able to handle when using 'drag and drop' of a file on the GiD window.

It is possible to specify the extension (or a list of extensions) of the files to be handled, the mode PRE or POST where it will be handled, and the name of the callback procedure to be called.

GiD_RegisterExtensionProc <list of extensions> <prepost> <procname>

GiD_UnRegisterExtensionProc <list of extensions> <prepost>

<extension> is the file extension, preceded by a dot

<prepost> could be PRE or POST

The procedure prototype to be registered must expect a single parameter, the dropped file name, something like this.

proc <procname> { filename } {

... do something ...

}

Example:

GiD_RegisterExtensionProc ".gif .png" PRE MyImageProcedure

EXAMPLE: creating and modifying menus

In this example we create a new menu called "New Menu" and we modify the GiD Help menu:

The code to make these changes would be:

GiDMenu::Create "New Menu" "PRE" -1 =

GiDMenu::InsertOption "New Menu" [list "Option 1"] 0 PRE "Command_1" "" "" replace =

GiDMenu::InsertOption "New Menu" [list "Option 2"] 1 PRE "Command_2" "" "" replace =

GiDMenu::InsertOption "New Menu" [list "---"] 2 PRE "" "" "" replace =

GiDMenu::InsertOption "New Menu" [list "Option 3"] 3 PRE "Command_3" "" "" replace =

GiDMenu::InsertOption "Help" [list "My Help"] 1 PRE "" "" "" insert _

GiDMenu::InsertOption "Help" [list "My Help" "My help 1"] 0 PRE "Command_help1" "" "" replace _

GiDMenu::InsertOption "Help" [list "My Help" "My help 2"] 1 PRE "Command_help2" "" "" replace _

GiDMenu::RemoveOption "Help" [list "Customization Help"] PRE _

GiDMenu::RemoveOption "Help" [list "What is new"] PRE _

GiDMenu::RemoveOption "Help" [list "FAQ"] PRE _

GiDMenu::UpdateMenus