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 _} }
...
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:
Code Block |
---|
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:
Code Block |
---|
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 |