VkEZ(3x)
VkEZ - A simple "widget wrapper" package to make using Motif easier
As shipped in IRIX 6.5.19. Unchanged since IRIX 6.5.
NAME VkEZ - A simple "widget wrapper" package to make using Motif easier HEADER FILE #include <Vk/VkEZ.h> PUBLIC PROTOCOL SUMMARY General interface EZ(Widget w) Operators = += -= << String int foreground= background= x= y= width= height= Description VkEZ is a simple mechanism for performing many common operations on Motif widgets in a consistent way, without knowing the details of the Motif API required to perform them. NOTE: VkEZ trades ease of use for programming efficiency. While it is faster to use VkEZ in many cases, the resulting operations can easily cost far more than the equivalent Motif operations. VkEZ is best used for demos and quick prototypes. SGI does not recommend VkEZ for production code. The VkEZ mechanism works by wrapping a widget temporarily in a C++ class that supports various operators. It also makes assumptions about what is interesting about any given widget. For example, if one assigns an integer to a Motif Scale widget, it will move the scale's slider. Assigning the same integer to a XmLabel widget will display the value in the label. To wrap a widget, simply type: EZ(widget) VkEZ supports two kinds of operators that can be applied to wrapped widgets. General operators, which are applied directly to the object. For example: EZ(widget) = "a label"; Operators applied to an attribute (resource) supported by the widget. For example: EZ(widget).foreground = "red"; The following descriptions of each operator lists the widgets that support that operator and defines how the operator works on each widget. General Operators Operator: String() String() returns a character string from the widget. For example: char *s = EZ(text); strcpy(buffer, s); XtFree(s); The application should free the string with XtFree(). This example copies the contents of a text widget into buffer. The following list describes the behavior of this operator for each widget that supports it. XmLabel, XmLabelGadget, and subclasses Returns the current value of the XmNlabelString resource as a character string XmText, XmTextField Returns the contents of the text widget XmList Returns the text associated with the currently selected item Operator: int() int() returns an integer value from the widget. For example: int value = EZ(dial); This example assigns the current value of a dial widget to value. The following list describes the behavior of this operator for each widget that supports it. XmToggleButton and XmToggleButtonGadget Returns 1 if set, 0 if not set XmScrollBar, XmScale Returns the current position of the slider SgDial Returns the current position of the pointer XmText, XmTextField Returns the result of calling atoi(3C) on the current contents of the text widget XmList Returns the currently selected position Assignment Operators EZ& operator=(int); EZ& operator=(float); EZ& operator=(const char *); Assignment operators assign integer, floating point, and character values to a widget. For example: EZ(text) = 12345; This example displays the integer 12345 in a text field. The following list describes the behavior of the integer assignment operator for each widget that supports it. XmToggle, XmToggleButtonGadget If the specified value is zero, turns the toggle off; if the specified value is non-zero, turns the toggle on XmScrollBar, XmScale Sets the current slider position to the specified value SgDial Sets the current pointer position to the specified value XmLabel, XmLabelGadget, and subclasses (except toggle) Displays the specified value as the XmNlabelString resource XmText, XmTextField Displays the specified value as the XmNvalue resource XmList Sets the current position index to the specified value The following list describes the behavior of the floating point assignment operator for each widget that supports it. XmScrollBar, XmScale Sets the current slider position to the integer equivalent of the specified value (the floating point value is truncated) SgDial Sets the current pointer position to the integer equivalent of the specified value (the floating point value is truncated) XmLabel, XmLabelGadget and subclasses Displays the specified floating point value as the XmNlabelString resource XmText, XmTextField Displays the specified floating point value as the XmNvalue resource XmList Sets the current position index to the integer equivalent of the specified value (the floating point value is truncated) The following list describes the behavior of the character string assignment operator for each widget that supports it. XmScale Sets the title to the specified string XmLabel, XmLabelGadget, and subclasses Displays the specified string as the XmNlabelString resource XmText, XmTextField Displays the specified string as the XmNvalue resource XmList Treats the specified string as comma-separated list of items and sets the list widget to display the new items, removing old contents Append Operators EZ& operator+=(int); EZ& operator+=(float); EZ& operator+=(const char *); EZ& operator<<(int); EZ& operator<<(float); EZ& operator<<(const char *); Append operators append the right side expression to the current value of a widget. Logically, the += operators make more sense for numerical operations, while the << operators seem more suitable for strings, but they are actually equivalent and either can be used. The following list describes the behavior of the integer and floating point append operators for each widget that supports them. XmToggle, XmToggleButtonGadget Increments the current value of XmNset by the specified value, so EZ(toggle) += 0; does nothing, while EZ(toggle) +=1; sets toggle if it is not already set XmScale, XmScrollBar Increases the position of the slider by the specified value SgDial Increases the position of the pointer by the specified value XmLabel, XmLabelGadget, and subclasses Appends the specified value to the current XmNlabelString resource XmText, XmTextField Appends the specified value to the current XmNvalue resource XmList Increments the current position index by the specified value The following list describes the behavior of the character string append operator for each widget that supports it. XmLabel, XmLabelGadget and subclasses Appends the given string to the current value of the XmNlabelString resource XmScale Appends the give string to the current value of the XmNtitle resource XmText, XmTextField Appends the value to the XmNvalue resource XmList Treats the string as a comma-separated list of items and adds the items to the list widget's current contents Decrement Operator EZ& operator-=(int); The decrement operator decrements the current value associated with a widget. The following list describes the behavior of the decrement operator for each widget that supports it. XmToggle, XmToggleButtonGadget Decrements the current value of XmNset by the specified value, so EZ(toggle) -= 0; does nothing, while EZ(toggle) -= 1; unsets toggle if it is not already unset XmScale, XmScrollBar Decreases the position of the slider by the specified value SgDial Decreases the position of the pointer by the specified value XmList Decrements the current position index by the specified value Attributes The following are attributes that can be modified using VkEZ: Attributes supported by all widgets: border, width, height, x, y Attributes supported by all widgets that have setting support for Pixel or char *: background, foreground Attributes supported by XmLabel, XmLabelGadget and subclasses: label Attributes supported by XmScale, XmScrollBar, SgDial: value, minimum, maximum Each of these attributes can be retrieved or set. For example: int width = EZ(widget).width; EZ(widget).width = 20; EZ(widget).foreground = "red"; Pixel index = EZ(widget).background; SEE ALSO ViewKit Programmer's Guide The X Window System, DEC Press, Bob Sheifler and Jim Gettys The X Window System Toolkit, DEC Press, Paul Asente and Ralph Swick The OSF/Motif Programmers Reference, Prentice Hall, OSF