Reference Guide > W Routines > WoMenuBar Function
  

WoMenuBar Function
Create a menu bar for a VDA Tool.
Usage
bar = WoMenuBar(parent, toolname[,menus])
Input Parameters
parent — (long) Specifies the parent widget ID of the menu bar.
toolname — (string) Specifies the unique name of the VDA Tool to which the menu bar is to be attached.
menus — (optional) Specifies an unnamed structure containing menu definitions. This parameter is only needed if you do not wish to use the standard graphics menu bar (i.e., when the Graphics keyword is not specified).
Returned Value
bar — The widget ID of the menu bar.
Keywords
Graphics — If nonzero, specifies that the standard menu for graphics VDA Tools should be used.
Attachment Keywords
Bottom — If a widget ID is specified (for example, Bottom=wid), then the bottom of the menu bar is attached to the top of the specified widget. If no widget ID is specified (for example, /Bottom), then the bottom of the menu bar is attached to the bottom of the parent widget.
Left — If a widget ID is specified (for example, Left=wid), then the left side of the menu bar is attached to the right side of the specified widget. If no widget ID is specified (for example, /Left), then the left side of the menu bar is attached to the left side of the parent widget.
Right — If a widget ID is specified (for example, Right=wid), then the right side of the menu bar is attached to the left side of the specified widget. If no widget ID is specified (for example, /Right), then the right side of the menu bar is attached to the right side of the parent widget.
Top — If a widget ID is specified (for example, Top=wid), then the top of the menu bar is attached to the bottom of the specified widget. If no widget ID is specified (for example, /Top), then the top of the menu bar is attached to the top of the parent widget.
Discussion
If the Graphics keyword is specified, a predefined set of standard menus is provided automatically. These predefined menus are equipped with functional callbacks. If you choose to use the predefined set of menus in your application, you do not need to modify the underlying structure of the menus or the callbacks. Both the predefined callbacks and the underlying menu structures are defined in the following files in the vdatools subdirectory of the Standard Library:
wographicsmenus.pro — Uses unnamed structures to define the menus and callbacks for the menus.
wographicsmenuscb.pro — Contains the callback routines for each menu.
If you do not choose to use the standard menu bar, then you can use these files as templates for creating a customized menu bar. Use the optional menu parameter to specify the name of the unnamed structure containing the new menu definitions. The structure definition can be added to the VDA Tool program with an @include statement or included in the VDA Tool program itself.
For a customized menu bar, you will also have to write and include appropriate callback procedures in your application.
 
note
For information on how to use the functions on the standard menu bar, run one of the graphical VDA Tools, such as WzPlot, and read about the menu bar in online help.
Example 1
In this example, the Graphics keyword is used to place a standard menu bar in a VDA Tool.
bar = WoMenuBar(layout, tool_name, /Graphics, /Top, /Left, $
   /Right)
Example 2
This example shows a portion of the resource file for the WzPreview VDA Tool. The resources shown are used by the menus of this VDA Tool. These menus differ from the standard menu bar. The menu bar structure is then defined.
wzpreview.ad - resources for the WzPreview menus
!
! Menus and menu items
!
! Edit items
!
*WzPreview*EditDefineHeader.labelString: Define Header...
*WzPreview*EditDefineHeader.mnemonic: H
*WzPreview*EditDefineHeader.acceleratorText: Ctrl+H
*WzPreview*EditDefineHeader.accelerator: Ctrl<Key>H
 
*WzPreview*EditDefineRecord.labelString: Define Record...
*WzPreview*EditDefineRecord.mnemonic: R
*WzPreview*EditDefineRecord.acceleratorText: Ctrl+R
*WzPreview*EditDefineRecord.accelerator: Ctrl<Key>R
 
*WzPreview*EditDefineField.labelString: Define Field...
*WzPreview*EditDefineField.mnemonic: F
*WzPreview*EditDefineField.acceleratorText: Ctrl+F
*WzPreview*EditDefineField.accelerator: Ctrl<Key>F
 
*WzPreview*EditSelectArea.labelString: Select Area
*WzPreview*EditSelectArea.mnemonic: S
*WzPreview*EditClear.labelString: Clear
*WzPreview*EditClear.mnemonic: C
*WzPreview*EditClear.acceleratorText: Ctrl+X
*WzPreview*EditClear.accelerator: Ctrl<Key>X
 
*WzPreview*EditClearAll.labelString: Clear All
*WzPreview*EditClearAll.mnemonic: A
*WzPreview*EditClearAll.acceleratorText: Ctrl+A
*WzPreview*EditClearAll.accelerator: Ctrl<Key>A
!
! Attributes items
!
*WzPreview*AttributesSetup.labelString: Setup...
*WzPreview*AttributesSetup.mnemonic: S
*WzPreview*AttributesVariable.labelString: Variable
*WzPreview*AttributesVariable.mnemonic: r
 
*WzPreview*AttributesVariable*NoVariable.labelString: 
   No variables
 
*WzPreview*AttributesFixedFormat.labelString: Fixed Format...
*WzPreview*AttributesFixedFormat.mnemonic: x
 
*WzPreview*AttributesFreeFormat.labelString: Free Format...
*WzPreview*AttributesFreeFormat.mnemonic: r
; Define the WzPreview menu bar structure (in the wzpreview.pro
; procedure).
wzpreview_menus = {, $
   NAME: ['FileMenu','FileMenu'], $
   MENUBUTTON: '', $
   MENU: {,CALLBACK: 'WoGMBFileOpenCB', $
      NAME: 'FileOpen', $
      BUTTON: '', $
      CALLBACK: 'WzPreviewFileSaveCB', $
      NAME: 'FileSave', $
      BUTTON: '', $
      CALLBACK: 'WzPreviewFileSaveAsCB', $
      NAME: 'FileSaveAs', $
      BUTTON: '', $
      CALLBACK: 'WoGMBFileSaveTemplateAsCB', $
      NAME: 'FileSaveTemplateAs', $
      BUTTON: '', $
      SEPARATOR: 1, $
      CALLBACK: 'WoGMBFileExportVariableCB', $
      NAME: 'FileExportVariable', $
      BUTTON: '', $
      SEPARATOR: 1, $
      NAME: 'FileGenerateCode', $
      CALLBACK: 'WoGMBFileGenerateCodeCB', $
      BUTTON: '', $
      SEPARATOR: 1, $
      CALLBACK: 'WoGMBFileCloseCB', $
      NAME: 'FileClose', $
      BUTTON: '' $
   }, $
   NAME: ['EditMenu', 'EditMenu'],$
   MENUBUTTON: '',$
   MENU:{,$
      CALLBACK: 'WzPreviewEditCB', $
      NAME: 'EditDefineHeader',$
      BUTTON: '',$
      NAME: 'EditDefineRecord',$
      BUTTON: '',$
      NAME: 'EditDefineField',$
      BUTTON: '',$
      SEPARATOR: 1, $
      NAME: 'EditSelectArea',$
      BUTTON: '',$
      SEPARATOR: 1, $
      NAME: 'EditClear',$
      BUTTON: '',$
      NAME: 'EditClearAll',$
      BUTTON: '' $
   }, $
   NAME: ['AttributesMenu', 'AttributesMenu'],$
   MENUBUTTON: '',$
   MENU:{, $
      CALLBACK: 'WzPreviewSetupCB', $
      NAME: 'AttributesSetup', $
      BUTTON: '', $
      NAME: ['AttributesVariable', 'AttributesVariable'], $
      MENUBUTTON: '', $
      MENU:{, $
      CALLBACK: 'WzPreviewAttributesVarCB', $
      NAME: 'NoVariables', $
      BUTTON: '' $
   }, $
   SEPARATOR: 1, $
   CALLBACK:'WzPreviewFormatCB',$
   NAME: 'AttributesFixedFormat',$
   TOGGLE:'',$
   NAME: 'AttributesFreeFormat',$
   TOGGLE:''$
   }, $
   NAME: ['WindowMenu', 'WindowMenu'],$
   MENUBUTTON: '',$
   MENU:{,CALLBACK:'WoGMBWindowCB',$
         NAME: 'Window_1',$
         BUTTON: '' $
   }, $
   CALLBACK: 'WoGMBHelpCB', $
   NAME: ['HelpMenu', 'HelpMenu'],$
   MENUBUTTON: '',$
   MENU:{,CALLBACK: 'WoGMBHelpOnWindowCB',$
      NAME: 'HelpOnWindow',$
      BUTTON: '', $
      CALLBACK: 'WoGMBHelpIndexCB',$
      NAME: 'HelpIndex',$
      BUTTON: '', $
      CALLBACK: 'WoGMBHelpOnHelpCB',$
      NAME: 'HelpOnHelp',$
      BUTTON: '', $
      SEPARATOR: 1, $
      CALLBACK: 'WoGMBHelpOnVersionCB',$
      NAME: 'HelpOnVersion',$
      BUTTON: '' $
   } $
}
; Use the structure with customized menus, but include the
; Graphics keyword to include callbacks for graphics menu items.
bar = WoMenuBar(layout, tool_name, wzpreview_menus, $
   /Graphics, /Top, /Left, /Right)
; If no filename or a bad file was specified, make all the
; filename-dependent menu items insensitive.
IF STRLEN(file) EQ 0 THEN BEGIN
   panes = [1, $     ; File menu
   1, $
   1, $
   1, $
   1, $
   2, $     ; Edit menu
   2, $
   2, $
   2, $
   2, $
   2 $
]
   items = [2, $     ; Save
   3, $     ; Save As...
   4, $     ; Save Template As...
   6, $     ; Export Variable(s)
   8, $     ; Generate Code
   1, $     ; Select Header
   2, $     ; Select Record
   3, $     ; Select Field
   5, $     ; Select Area
   7, $     ; Clear
   8 $      ; Clear All
]
   WoMenuBarSetSensitivity, tool_name, panes, items, 0
ENDIF
See Also
WoMenuBarSetSensitivity

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.