WoAddButtons Procedure
Adds a bank of buttons to a button bar.
Usage
WoAddButtons, toolname, buttons
Input Parameters
toolname — (string) Specifies the unique name of the VDA Tool to which the button bar is attached.
buttons — An unnamed structure containing the button definitions.
Keywords
Measure — Specifies the number of columns of buttons (for a vertical box) or rows (for a horizontal box).
Radio — If nonzero, the buttons have a “one of many” behavior.
Sensitive — Specifies an array of initial sensitivity settings for the buttons. A value of 0 makes the button insensitive; 1 makes the button sensitive. (Default: All buttons are sensitive.)
Vertical — When nonzero, creates a vertically aligned column of buttons.
Discussion
An unnamed structure has the following general definition:
x = {, tag_name1: tag_def1, tag_namen: tag_defn}
The following tag names and tag definitions can be used in the unnamed structure used to define buttons:
LAYOUT_NAME: 'name' — Specifies the name of the row/column layout used to organize the buttons.
DESCRIPTOR: 'name' — Specifies the descriptor name for the button. A descriptor is a string used to identify a button. This string is also used as the button’s widget ID.
CALLBACK: 'name' — Specifies the name of the callback routine for the button.
STATUS_CALLBACK: 'name' — Specifies the name of the routine that prints the name of the button when the pointer passes over the button.
USERDATA: variable — Specifies a variable to pass to the callback when the button is pressed.
INSENSITIVE_PIXMAP: 'pathname' — Specifies the full pathname of the insensitive pixmap for the button.
PIXMAP: 'pathname' — Specifies the full pathname of the sensitive pixmap for the button.
For an example of an unnamed structure of button definitions, see the file wographicsbuttons.pro in:
<wavedir>/lib/vdatools
<wavedir>\lib\vdatools
Where <wavedir> is the main PV‑WAVE directory.
Example
The following code shows how to add custom buttons to the standard button bar. First, button callbacks are defined, and then a structure is created to define two buttons. Finally, WoAddButtonBar is used to add the buttons to the standard button bar, WoButtonBarSetSensitivity is used to set the sensitivity of one of the buttons, and WoButtonBarSet is used to press one of the buttons.
PRO Button0StatusCB, wid, tool_name, event
WoAddStatus, tool_name, 'MSG_Button0Status'
END
PRO Button1StatusCB, wid, tool_name, event
WoAddStatus, tool_name, 'MSG_Button0Status'
END
PRO Button0CB, wid, tool_name
print, 'Button 0 pressed in tool ' + tool_name
WoAddMessage, tool_name, 'MyTool_Button0', /Clear
END
PRO Button1CB, wid, tool_name
print, 'Button 1 pressed in tool ' + tool_name
WoAddMessage, tool_name, 'MyTool_Button0', /Clear
END
...
; Define the button bar structure.
pixmap_directory='~user/Pixmaps/'
MyButtons = $
{, $
LAYOUT_NAME: 'MyButtons', $
DESCRIPTOR: 'MyButton_0', $
CALLBACK: 'Button0CB', $
STATUS_CALLBACK: 'Button0StatusCB', $
INSENSITIVE_PIXMAP: pixmap_dir + 'button0x.pm', $
PIXMAP: pixmap_dir + 'button0.pm', $
DESCRIPTOR: 'MyButton_1', $
CALLBACK: 'Button1CB', $
STATUS_CALLBACK: 'Button1StatusCB', $
INSENSITIVE_PIXMAP: pixmap_dir + 'button1x.pm', $
PIXMAP: pixmap_dir + 'button1.pm' $
}
; Create the standard graphics button bar.
tb = WoButtonBar(layout , tool_name, Top=bar, /Graphics, $
/Left, /Right)
; Add the additional buttons.
WoAddButtons, tool_name, MyButtons
; Make the second button insensitive.
WoButtonBarSetSensitivity, tool_name, 'MyButton_1', 0
; Push the first button.
WoButtonBarSet, tool_name, 'MyButton_0', 1
...