WoDialogStatus Procedure

Saves or restores the status of a dialog box by saving or restoring the state of its widgets as stored in the Tools Manager.

Usage

WoDialogStatus, toolname, status

Input Parameters

toolname — (string) Specifies the unique name of the VDA Tool with which the dialog is associated.

status — Specifies a structure containing the status information. The fields are:

WIDGET_ID — The widget ID of the widget to be saved or restored.

DEFAULT — The default value to use upon restoring the dialog if nothing is found in the Tools Manager. In other words, this is the first time the dialog is invoked.

ITEM — The Tools Manager item under which to save or restore the setting.

ATTRIBUTE — The Tools Manager attribute under which to save or restore the setting.

Keywords

Restore — If nonzero, restores the status of the dialog box.

Save — If nonzero, saves the status of the dialog box.

Verbose — If nonzero, prints messages indicating the status of WoDialogStatus. This keyword is useful for debugging.

Discussion

The WIDGET_ID, DEFAULT, and ITEM fields must occur before the ATTRIBUTE field in the structure status.

WoDialogStatus can be used to save and restore the status of any PV‑WAVE Widget that allows WwSetValue and WwGetValue calls.

Example

The following code is taken from wzpreview.pro. It shows how WoDialogStatus is used to set and restore dialog box values.

FUNCTION WzPreviewDialogCB, wid, index 
   DECLARE FUNC, TmGetAttribute 
   DECLARE FUNC, TmSetAttribute 
   ; Get userdata and extract the tool name from the structure. 
   setup_data = WwGetValue(wid, /Userdata) 
   tool_name = setup_data.tool_name 
   ; If OK or Apply was pressed, save the dialog. Let the 
   ; WoGenericDialog routine handle Cancel and Help.
   CASE index OF
   1: BEGIN ; OK
      WoDialogStatus, tool_name, setup_data.status, /Save
      RETURN, 0
      END
   2: BEGIN ; Apply
      WoDialogStatus, tool_name, setup_data.status, /Save
      RETURN, 0
      END
   3: BEGIN ; Cancel
      RETURN, 0
      END
   4: BEGIN ; Help
      RETURN, 0
      END
   ENDCASE
END
PRO WzPreviewFreeDialog, tool_name
   DECLARE FUNC, TmGetTop
   DECLARE FUNC, TmGetAttribute
   parent = TmGetTop(tool_name)
   ; Create the elements of the dialog.
   helpfile= TmGetAttribute(tool_name, 'TM_HELP', 'HELP_FILE')
   topic = TmGetMessage('wzpreview.ads', $
      'WzPreview_free_dialog_help')
   title = TmGetMessage('wzpreview.ads', $
      'WzPreview_free_title') + tool_name
   free_dialog = WoGenericDialog(parent, layout, $
      'WzPreviewDialogCB', Dialog_name = 'freeDialog', $
      Title=title, Buttons=buttons, Help=[topic, helpfile], $
      /Ok, /Apply, /Cancel)
   ; Create the elements of the dialog.
   separator_label = WwText(layout, Text='', /Label, $
      Name='separatorLabel', /Top, /Left) separator_radio = $
      WwRadioBox(layout, ['','','',''], /NOfMany, /Vertical, $
      /Form, Layout_name='separatorForm', $
      Name=['spaceToggle','commaToggle', 'tabToggle', $
      'otherToggle'], Toggles=separator_toggles, $
      Top=separator_label, /Left)
   other_text = WwText(separator_radio, Text='', $
      Top=separator_toggles(2), Left=separator_toggles(3)) 
   ; Create data structure needed in the dialog callback.
   status = {, $
      WIDGET_ID: separator_toggles(0), $
      DEFAULT: 1, $
      ITEM: 'TM', $
      ATTRIBUTE: 'SPACE_SEPARATOR', $
      WIDGET_ID: separator_toggles(1), $
      DEFAULT: 1, $
      ITEM: 'TM', $
      ATTRIBUTE: 'COMMA_SEPARATOR', $
      WIDGET_ID: separator_toggles(2), $
      DEFAULT: 1, $
      ITEM: 'TM', $
      ATTRIBUTE: 'TAB_SEPARATOR', $
      WIDGET_ID: separator_toggles(3), $
      DEFAULT: 0, $
      ITEM: 'TM', $
      ATTRIBUTE: 'OTHER_SEPARATOR', $
      WIDGET_ID: other_text, $
      DEFAULT: '', $
      ITEM: 'TM', $
      ATTRIBUTE: 'OTHER_SEPARATOR_TEXT' $
   }
   ; Use WoDialogStatus to restore values previously saved from
   ; this dialog. If this is first time this dialog is displayed
   ; the widgets are initialized from DEFAULT field values.
   WoDialogStatus, tool_name, status, /Restore
   ; Set the tool name and the above structure as the userdata on 
   ; the dialog buttons--we need the status structure to save the 
   ; dialog status in the dialogs callback.
   setup_data = {, tool_name: tool_name, status: status}
   ; Set the userdata for all the buttons on the dialog.
   FOR i=1L, N_ELEMENTS(buttons) DO $
      s = WwSetValue(buttons(i-1), Userdata=setup_data)
      ; Show the dialog.
      s = WwSetValue(free_dialog, /Show)
END

See Also

WoGenericDialog