Reference Guide > W Routines > WoColorWheel Function
  

WoColorWheel Function
Creates a color wheel that can be used to modify a single color in the current color table.
Usage
wid = WoColorWheel(tool_name, color_index, value_changed_cb)
Parameters
tool_name — A string containing the unique name of a VDA Tool.
color_index — The index of the color to display in the color wheel.
value_changed_cb — A string containing the name of a callback procedure to call when the color value changes.
Keywords
None.
Returned Value
wid — The widget ID of the color wheel.
Callback Parameters
The “value changed” callback must have the following two parameters:
tool_name — A string containing the unique name of a VDA Tool.
color_index — The index of the color displayed in the color wheel.
Discussion
The color wheel modifies the current color table directly. WoColorWheel is used by the WzColorEdit VDA Tool.
Example
This is the callback that is called when the color wheel value is changed.
PRO ValueChangedCB, tool_name, color_index
   print, 'Value changed: ', tool_name, color_index
END
This callback is called when the Color Wheel or Quit button is pressed. If Color Wheel is pressed, a color wheel appears for the selected color index. If the Quit button is pressed, the shell is destroyed.
PRO ButtonCB, wid, which
   DECLARE FUNC, TmGetAttribute
   DECLARE FUNC, WoColorWheel
   ; Get the tool name from user data.
   tool_name = WwGetValue (wid, /Userdata)
   CASE which OF
   1: BEGIN ; Color Wheel
      ; Get the selected color index.
      color_om = TmGetAttribute (tool_name, 'TM', 'COLOR_OM')
      index = WwGetValue (color_om) - 1
      ; Display the color wheel.
      wheel = WoColorWheel (tool_name, index, 'ValueChangedCB')
      END
   2: BEGIN ; Quit
      top = TmGetTop (tool_name)
      status = WwSetValue (top, /Close)
      END
   ENDCASE
END
This program demonstrates the WoColorWheel function. It creates a simple tool that allows the user to display the color wheel for any of the first 10 colors in the current color table.
PRO WoColorWheel_test
   DECLARE FUNC, TmGetUniqueToolName
   DECLARE FUNC, TmSetAttribute
   ; Initialize the tool manager.
   TmInit
   ; Get a new unique tool name.
   tool_name = TmGetUniqueToolName ('WoColorWheel_test')
   ; Initialize the top-level shell, and register the tool.
   top = WwInit ('WoColorWheel_test', 'wocolorwheel_test', $
      layout, 'WoDestroyCB', 	Userdata = tool_name, $ 
      /Vertical, title = tool_name)
         TmRegister, tool_name, top
   ; Create the color option menu and the button box.
   color_menu = {, callback: 'TmNoOpCB', $
      button: '0', button: '1', button: '2', $
      button: '3', button: '4', button: '5', $
      button: '6', button: '7', button: '8', $
      button: '9', button: '10'}
   color_om = WwOptionMenu (layout, 'Color Index', color_menu)
   button_wid = WwButtonBox (layout, ['Color Wheel...', $
      'Quit'], 'ButtonCB', buttons = buttons)
   ; Save the attribute information needed for the callbacks.
   status = TmSetAttribute (tool_name, 'TM', 'COLOR_OM', $
      color_om)
   FOR i=0L, (N_ELEMENTS(buttons) - 1) DO BEGIN
      status = WwSetValue (buttons(i), Userdata =    tool_name)
   ENDFOR
   ; Display the tool.
   status = WwSetValue (top, /Display)
   WwLoop, /NoBlock
END

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