WwMenuBar Function
Creates a menu bar.
note | WwMenuBar can only occur once per layout widget on Windows. |
Usage
menubar = WwMenuBar(parent, items)
Input Parameters
parent — The widget ID of the parent widget.
items — An unnamed structure containing the menu bar items. For more information, see "Creating and Handling Menus" in the PV‑WAVE Application Developer’s Guide.
Returned Value
menubar — The widget ID of the menu bar widget.
Keywords
HelpJustify — If nonzero, positions the last menu item (usually the Help menu) at the far right of the menu bar.
Layout_name — Specifies the name of the RowColumn widget which is part of the resource specification. (Default: menubar.)
Menus — Returns an array of menu pane widget IDs in the order in which the menus were created. A menu pane is a special menu widget that serves as a container for a menu item. Menu pane widget IDs can be used in the WwMenuItem function to add, modify, or delete menu items.
Position — (UNIX) If the menu bar widget is to be placed in a bulletin board layout, use this keyword to specify the x, y coordinates of the menu bar widget within the bulletin board.
Spacing — Specifies the amount of space in pixels between child widgets.
Color/Font Keywords
For Unix:
Background — Specifies the background color name.
Font — Specifies the name of the font used for text.
Foreground — Specifies the foreground color name.
For Windows:
MSFont — Adds support for Windows fonts.
Attachment Keywords
Bottom — If a widget ID is specified (for example, Bottom=wid), then the bottom of the menu bar widget 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 widget 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 widget 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 widget 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 widget is attached to the left side of the specified widget. If no widget ID is specified (for example, /Right), then the menu bar widget’s right side 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 widget 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 widget is attached to the top of the parent widget.
Get/Set Value
getvalue — Gets the button label or icon pixmap ID for the selected menu button. Or, if the button is a toggle, determines if the button is selected or unselected (selected = 1, unselected = 0).
setvalue — Sets the button label or icon pixmap ID for the selected menu button. Or, if the button is a toggle, selects or unselects the toggle button (select = 1, unselect = 0).
Callback Parameters
Any menu bar callback procedure must have the following two parameters:
wid — Widget ID of the selected menu item.
index — Index of the selected menu item (1 – n).
Example 1
First, this example creates a menu bar with three menus: Fonts, Size, and Icons. The unnamed structure menus contains all of the information used to create the menus.
Enter the callback procedure into a file, and compile the procedure with the .RUN command. Then, enter the widget commands at the WAVE> prompt (or enter them in a command file and run them with the @ command). To dismiss the menu bar, select the appropriate function (such as Close) from the window manager menu.
Callback Procedure
PRO MenuCB, wid, index
PRINT, 'Menu Item', index, 'selected.'
value = WwGetValue(wid)
PRINT, value
END
Widget Commands
top = WwInit('ww_ex29', 'Examples', layout)
menus={,callback:'MenuCB', $
menubutton:'Fonts', $
menu:{,callback:'MenuCB', $
menubutton:'Adobe', $
menu:{,callback:'MenuCB', $
toggle:'Normal', $
toggle:'Bold', $
toggle:'Italic'}, $
button:'Helvetica', $
button:'Courier'}, $
menubutton:'Size', $
menu:{,callback:'MenuCB', $
button:'8', $
button:'10', $
button:'12'}, $
menubutton:'Icons', $
menu:{,callback:'MenuCB', title:'Help', $
icon:getenv('WAVE_DIR')+ '/xres/wxbm_btn_help_search.', $
icon:getenv('WAVE_DIR')+ '/xres/wxbm_btn_help_toc.', $
icon:getenv('WAVE_DIR')+ '/xres/wxbm_btn_help_topics.', $
separator:1, $
icon:getenv('WAVE_DIR')+ '/xres/wxbm_btn_help_quit.'}}
bar=WwMenuBar(layout, menus)
status=WwSetValue(top, /Display)
WwLoop
Example 2
The following example demonstrates WwGetValue with the WwMenuBar function. WwGetValue returns a string array containing the button label ID for the selected menu button. The callback routine MenuCB prints the value returned by WwGetValue whenever the user makes a menu bar selection.
Enter the callback procedure and the main procedure into a file, and compile it with the .RUN command. To run the example, enter wwgetvalue_ex at the WAVE> prompt. To dismiss the widget, select the appropriate function (such as Close) from the window manager menu of the command window.
PRO MenuCB, wid, index
value = WwGetValue(wid)
print, value
END
PRO wwgetvalue_ex
top = WwInit('ww_ex26', 'wwgetvalue_ex', layout)
items = {, callback:'MenuCB', $
menubutton:'Menu a', menu:{,callback:'MenuCB', $
button:'a0',button:'a1'}, $
menubutton:'Menu b', menu:{,callback:'MenuCB', $
button:'b0',button:'b1'} }
menubar = WwMenuBar(layout, items)
status = WwSetValue(top, /Display)
WwLoop
END
See Also
For detailed information on GUI development, refer to the PV‑WAVE Application Developer’s Guide.
For more information about how to write an application program based on PV‑WAVE Widgets, refer to Using Wave Widgets in the PV‑WAVE Application Developer’s Guide.
For additional information on the color and font keywords, see "Setting Colors and Fonts" in the PV‑WAVE Application Developer’s Guide.
For additional information on attachment keywords, see "Form Layout: Attachments" in the PV‑WAVE Application Developer’s Guide.
For information on Get and Set values, see "Setting and Getting Widget Values" in the PV‑WAVE Application Developer’s Guide.
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.