WgCtTool Procedure
Creates a simple widget that can be used interactively to modify a PV‑WAVE color table.
Usage
WgCtTool
Keywords
Cmap — The index of the color table to load when the widget is created; a positive integer in the range (0–18).
Parent — The widget or shell ID of the parent widget (long). If parent is not specified, WgCtTool runs on its own (i.e., in its own event loop).
Position — A two-element vector specifying the x- and y-coordinates of the upper-left corner of the CtTool window (long integer). The elements of the vector are [x, y], where x (horizontal) and y (vertical) are specified in pixels. These coordinates are measured from the upper-left corner of the screen.
Shell — The ID of the newly created widget. If the procedure fails, zero (0) is returned.
Title — A string containing the title that appears in the header of the window. Default value is “Color Table Tool”.
Color/Font Keywords
For additional information on the color and font keywords, see the PV‑WAVE Application Developer’s Guide.
Background — Specifies the background color name.
Basecolor — Specifies the base color.
Font — Specifies the name of the font used for text.
Foreground — Specifies the foreground color name.
Discussion
The WgCtTool window (Figure 19-5: WgGtTool Window) allows you to interactively modify system color tables by stretching, rotating, and reversing them.
In some ways, the WgCtTool window is similar to the WgCeditTool window, in that it provides easy ways to interactively modify color tables. For example, with a single click, you can reverse the color table using the WgCtTool window. But if you need to edit individual colors in the color table, or save your changes for future use, then use the WgCeditTool window, instead.
 
Figure 19-5: WgGtTool Window
 
The Colors Common Block
This procedure modifies the PV‑WAVE internal color table, as well as the color table variables in the COLORS common block.
Most color table procedures maintain the current color table in a common block called Colors, defined as follows:
COMMON Colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
The variables are integer vectors of length equal to the number of color indices. Your program can access these variables by declaring the common block. The modifications you make to the color table by interacting with the CtTool widget are stored in r_curr, g_curr, and b_curr.
Contents of the Window
The CtTool window has three main parts — the color bar area, the control area, and the system color table list.
CtTool Color Bar Area
The built-in color bar lets you display the colors of the current color table and “rotate” them. To rotate the color table using the color bar, press and drag the left mouse button to the left or to the right in the color bar. As you “slide” colors into different color table indices, the colors that “scroll off” the end of the color table are added to the opposite end.
CtTool Control Area
Use the following controls to operate the CtTool window:
*Stretch Bottom — Select the lower limit for the stretched color table.
*Stretch Top — Select the upper limit for the stretched color table.
*Undo — Discard color table modifications you have made using the CtTool window, and return to the color table that CtTool was using when it was first created.
*Reverse — Swap the color table (as currently defined), end for end.
*Dismiss — Destroy the CtTool window and erase it from the screen.
The CtTool window uses the STRETCH procedure to linearly expand a range of color table indices. The Stretch Bottom number is used for the first parameter to the STRETCH command, and the Stretch Top number is subtracted from the number of colors available in the color table to determine the second parameter to the STRETCH command. For more information about the STRETCH command, refer the description for STRETCH.
System Color Table List
This area lists the 19 system color tables that are provided as part of PV‑WAVE. Use the left mouse button to select one. The color table you select from the list will immediately be displayed in the color bar area.
Because system color tables are “read-only”, no system color table will be permanently altered by any changes made with the CtTool. For this reason, the changes can be overwritten by any other PV‑WAVE routine writing to the Colors common block.
 
note
To save color table changes for later use, you can use another utility widget, WgCeditTool.
Event Handling
You can use the CtTool widget in one of the following two ways:
*From the WAVE> prompt — Enter the procedure name at the WAVE> prompt to display the CtTool widget. The CtTool widget handles its own event loop by calling WwLoop.
*Stand-alone widget in its own window created by another application — The CtTool widget has its own Main window, but the application (not the CtTool widget) handles the event loop by calling WwLoop.
The output parameter shell can be returned only if you also supply the input parameter parent.
Example
Enter the commands shown below into a file, and compile the procedure with the .RUN command. If the variable parent is defined, WgCtTool is created as a child of parent; otherwise, WgCtTool runs on its own (i.e., in its own event loop).
When you are finished interacting with the WgCtTool window, close it by clicking the Dismiss button.
PRO Sample_wgcttool, parent, tool_shell
   ; Create WgCtTool as a child of "parent". The window of
   ; the newly created widget is returned via the optional
   ; output parameter "tool_shell".
   IF N_ELEMENTS(parent) NE 0 THEN BEGIN
      WgCtTool, Parent=parent, Shell=tool_shell
   ENDIF ELSE BEGIN
      ; Create WgCtTool and display it as its own Main window. 
      ; In other words, the WgCtTool window runs on its own
      ; (i.e., in its own event loop).
      WgCtTool
   ENDELSE
END
See Also
For more information about color table indices and color systems, refer to the PV‑WAVE User’s Guide.
For more information about writing application programs based on PV‑WAVE Widgets or the Widget Toolbox, refer to the PV‑WAVE Application Developer’s Guide.