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 AND 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:

  • GiDMenu::Create { menu_name_untranslated prepost {pos -1} {translationfunc _} }

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

  • menu_name_untranslated: text of the new menu (English).
  • prepost can have these values:

"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.

  • pos: optional, index where the new menu will be inserted (by default it is inserted before the 'Help' menu)
  • translationfunc: optional, must be _ for GiD strings (default), or = for problemtype strings

  • GiDMenu::Delete { menu_name_untranslated prepost {translationfunc _} }

Deletes a menu.

  • menu_name_untranslated: text of the menu to be deleted (English).
  • prepost can have these values:

"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.

  • translationfunc: optional, must be _ for GiD strings (default), or = for problemtype strings

  • GiDMenu::InsertOption { menu_name_untranslated option_name_untranslated position prepost command {acceler ""} {icon ""} {ins_repl "replace"} {translationfunc _} }

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).

  • menu_name_untranslated: text of the menu into which you wish to insert the new option (English), e.g "Utilities"
  • option_name_untranslated: name of the new option (English) you want to insert.

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.

  • position: position in the menu where the option is to be inserted. Note that positions start at 0, and separator lines also count.
  • prepost: this argument can have the following values:

"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.

  • command: is the command called when the menu option is selected.
  • acceler: optional, key accelerator, like "Control-s"
  • icon: optional, name of a 16x16 pixels icon to show in the menu
  • ins_repl: optional, if the argument is:
  • replace: (default) the new option replaces the option in the given position
  • insert: the new option is inserted before the given position.
  • insertafter: the new option is inserted after the given position.
  • translationfunc: optional, must be _ for GiD strings (default), or = for problemtype strings

  • GiDMenu::RemoveOption {menu_name_untranslated option_name_untranslated prepost {translationfunc _}}

Removes an option from a given menu.

  • menu_name_untranslated: name of the menu (English) which contains the option you want to remove. e.g "Utilities"
  • option_name_untranslated: name of the option (English) you want to remove. The option name, is a menu sublevels list, like [list "List" "Points"]
  • prepost: this argument can have the following values:

"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.

  • translationfunc: optional, must be _ for GiD strings (default), or = for problemtype strings

To remove separators, the option_name is --- , but you can append an index (starting from 0) to specify wich separator must be removed, if there are more than one.

e.g.

GiDMenu::RemoveOption "Geometry" [list "Create" "---2"] PRE

  • GiDMenu::ModifyOption { menu_name_untranslated option_name_untranslated prepost new_option_name {new_command -default-} {new_acceler -default-} {new_icon -default-} {translationfunc _} }

Edit an existent option from a given menu

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

  • GiDMenu::UpdateMenus {}

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

  • GiD_RegisterPluginAddedMenuProc and GiD_UnRegisterPluginAddedMenuProc

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.

  • GiD_RegisterExtensionProc and GiD_UnRegisterExtensionProc

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

Managing menus

Tcl menu functions

Menu Tcl functions