Skip to content

Type Converter Functions

To use the functions defined in this section, you should include the header file <X11/Xmu/Converters.h> and link against the libXmu library.

void XmuCvtFunctionToCallback(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);
void XmuCvtFunctionToCallback(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);

args

this argument is ignored

num_args

this argument is ignored

fromVal

the function to convert

toVal

the place to store the converted value

This function converts a callback procedure to a callback list containing that procedure, with NULL closure data. To use this converter, include the following in your widget's ClassInitialize procedure:

XtAddConverter(XtRCallProc, XtRCallback, XmuCvtFunctionToCallback, NULL, 0);
XtAddConverter(XtRCallProc, XtRCallback, XmuCvtFunctionToCallback, NULL, 0);

void XmuCvtStringToBackingStore(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);
void XmuCvtStringToBackingStore(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);

args

this argument is ignored

num_args

this argument must be a pointer to a Cardinal containing the value 0

fromVal

specifies the string to convert

toVal

returns the converted value

This function converts a string to a backing-store integer as defined in <X11/X.h>. The string "notUseful" converts to NotUseful, "whenMapped" converts to WhenMapped, and "always" converts to Always. The string "default" converts to the value Always + WhenMapped + NotUseful. The case of the string does not matter. To use this converter, include the following in your widget's ClassInitialize procedure:

XtAddConverter(XtRString, XtRBackingStore, XmuCvtStringToBackingStore, NULL, 0);
XtAddConverter(XtRString, XtRBackingStore, XmuCvtStringToBackingStore, NULL, 0);

void XmuCvtStringToBitmap(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);
void XmuCvtStringToBitmap(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);

args

the sole argument specifies the Screen on which to create the bitmap

num_args

must be the value 1

fromVal

specifies the string to convert

toVal

returns the converted value

This function creates a bitmap (a Pixmap of depth one) suitable for window manager icons. The string argument is the name of a file in standard bitmap file format. For the possible filename specifications, see XmuLocateBitmapFile. To use this converter, include the following in your widget's ClassInitialize procedure:

static XtConvertArgRec screenConvertArg[] = {
  {XtBaseOffset, (XtPointer)XtOffset(Widget, core.screen), sizeof(Screen *)}
};

XtAddConverter(XtRString, XtRBitmap, XmuCvtStringToBitmap,
		 screenConvertArg, XtNumber(screenConvertArg));
      

Boolean XmuCvtStringToColorCursor(Display *dpy, XrmValuePtr args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *data);
Boolean XmuCvtStringToColorCursor(Display *dpy, XrmValuePtr args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *data);

dpy

specifies the display to use for conversion warnings

args

specifies the required conversion arguments

num_args

specifies the number of required conversion arguments, which is 4

fromVal

specifies the string to convert

toVal

returns the converted value

data

this argument is ignored

This function converts a string to a Cursor with the foreground and background pixels specified by the conversion arguments. The string can either be a standard cursor name formed by removing the “XC_” prefix from any of the cursor defines listed in Appendix B of the Xlib Manual, a font name and glyph index in decimal of the form "FONT fontname index [[font] index]", or a bitmap filename acceptable to XmuLocateBitmapFile. To use this converter, include the following in the widget ClassInitialize procedure:

static XtConvertArgRec colorCursorConvertArgs[] = {
  {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
   sizeof(Screen *)},
  {XtResourceString, (XtPointer) XtNpointerColor, sizeof(Pixel)},
  {XtResourceString, (XtPointer) XtNpointerColorBackground, sizeof(Pixel)},
  {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.colormap),
   sizeof(Colormap)}
};


XtSetTypeConverter(XtRString, XtRColorCursor, XmuCvtStringToColorCursor,
		 colorCursorConvertArgs, XtNumber(colorCursorConvertArgs),
                 XtCacheByDisplay, NULL);
static XtConvertArgRec colorCursorConvertArgs[] = {
  {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
   sizeof(Screen *)},
  {XtResourceString, (XtPointer) XtNpointerColor, sizeof(Pixel)},
  {XtResourceString, (XtPointer) XtNpointerColorBackground, sizeof(Pixel)},
  {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.colormap),
   sizeof(Colormap)}
};


XtSetTypeConverter(XtRString, XtRColorCursor, XmuCvtStringToColorCursor,
		 colorCursorConvertArgs, XtNumber(colorCursorConvertArgs),
                 XtCacheByDisplay, NULL);

The widget must recognize XtNpointerColor and XtNpointerColorBackground as resources, or specify other appropriate foreground and background resources. The widget's Realize and SetValues methods must cause the converter to be invoked with the appropriate arguments when one of the foreground, background, or cursor resources has changed, or when the window is created, and must assign the cursor to the window of the widget.

void XmuCvtStringToCursor(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);
void XmuCvtStringToCursor(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);

args

specifies the required conversion argument, the screen

num_args

specifies the number of required conversion arguments, which is 1

fromVal

specifies the string to convert

toVal

returns the converted value

This function converts a string to a Cursor. The string can either be a standard cursor name formed by removing the “XC_” prefix from any of the cursor defines listed in Appendix B of the Xlib Manual, a font name and glyph index in decimal of the form "FONT fontname index [[font] index]", or a bitmap filename acceptable to XmuLocateBitmapFile. To use this converter, include the following in your widget's ClassInitialize procedure:

static XtConvertArgRec screenConvertArg[] = {
  {XtBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.screen), sizeof(Screen *)}
};

XtAddConverter(XtRString, XtRCursor, XmuCvtStringToCursor,
		 screenConvertArg, XtNumber(screenConvertArg));
      

void XmuCvtStringToGravity(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);
void XmuCvtStringToGravity(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);

args

this argument is ignored

num_args

this argument must be a pointer to a Cardinal containing the value 0

fromVal

specifies the string to convert

toVal

returns the converted value

This function converts a string to an XtGravity enumeration value. The string "forget" and a NULL value convert to ForgetGravity, "NorthWestGravity" converts to NorthWestGravity, the strings "NorthGravity" and "top" convert to NorthGravity, "NorthEastGravity" converts to NorthEastGravity, the strings "West" and "left" convert to WestGravity, "CenterGravity" converts to CenterGravity, "EastGravity" and "right" convert to EastGravity, "SouthWestGravity" converts to SouthWestGravity, "SouthGravity" and "bottom" convert to SouthGravity, "SouthEastGravity" converts to SouthEastGravity, "StaticGravity" converts to StaticGravity, and "UnmapGravity" converts to UnmapGravity. The case of the string does not matter. To use this converter, include the following in your widget's class initialize procedure:

XtAddConverter(XtRString, XtRGravity, XmuCvtStringToGravity, NULL, 0);
XtAddConverter(XtRString, XtRGravity, XmuCvtStringToGravity, NULL, 0);

void XmuCvtStringToJustify(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);
void XmuCvtStringToJustify(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);

args

this argument is ignored

num_args

this argument is ignored

fromVal

specifies the string to convert

toVal

returns the converted value

This function converts a string to an XtJustify enumeration value. The string "left" converts to XtJustifyLeft, "center" converts to XtJustifyCenter, and "right" converts to XtJustifyRight. The case of the string does not matter. To use this converter, include the following in your widget's ClassInitialize procedure:

XtAddConverter(XtRString, XtRJustify, XmuCvtStringToJustify, NULL, 0);
XtAddConverter(XtRString, XtRJustify, XmuCvtStringToJustify, NULL, 0);

void XmuCvtStringToLong(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);
void XmuCvtStringToLong(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);

args

this argument is ignored

num_args

this argument must be a pointer to a Cardinal containing 0

fromVal

specifies the string to convert

toVal

returns the converted value

This function converts a string to an integer of type long. It parses the string using sscanf with a format of "%ld". To use this converter, include the following in your widget's ClassInitialize procedure:

XtAddConverter(XtRString, XtRLong, XmuCvtStringToLong, NULL, 0);
XtAddConverter(XtRString, XtRLong, XmuCvtStringToLong, NULL, 0);

void XmuCvtStringToOrientation(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);
void XmuCvtStringToOrientation(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);

args

this argument is ignored

num_args

this argument is ignored

fromVal

specifies the string to convert

toVal

returns the converted value

This function converts a string to an XtOrientation enumeration value. The string "horizontal" converts to XtorientHorizontal and "vertical" converts to XtorientVertical. The case of the string does not matter. To use this converter, include the following in your widget's ClassInitialize procedure:

XtAddConverter(XtRString, XtROrientation, XmuCvtStringToOrientation, NULL, 0);
XtAddConverter(XtRString, XtROrientation, XmuCvtStringToOrientation, NULL, 0);

Boolean XmuCvtStringToShapeStyle(Display *dpy, XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *data);
Boolean XmuCvtStringToShapeStyle(Display *dpy, XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *data);

dpy

the display to use for conversion warnings

args

this argument is ignored

num_args

this argument is ignored

fromVal

the value to convert from

toVal

the place to store the converted value

data

this argument is ignored

This function converts a string to an integer shape style. The string "rectangle" converts to XmuShapeRectangle, "oval" converts to XmuShapeOval, "ellipse" converts to XmuShapeEllipse, and "roundedRectangle" converts to XmuShapeRoundedRectangle. The case of the string does not matter. To use this converter, include the following in your widget's ClassInitialize procedure:

XtSetTypeConverter(XtRString, XtRShapeStyle, XmuCvtStringToShapeStyle,
		     NULL, 0, XtCacheNone, NULL);
XtSetTypeConverter(XtRString, XtRShapeStyle, XmuCvtStringToShapeStyle,
		     NULL, 0, XtCacheNone, NULL);

Boolean XmuReshapeWidget(Widget w, int shape_style, int corner_width, int corner_height);
Boolean XmuReshapeWidget(Widget w, int shape_style, int corner_width, int corner_height);

w

specifies the widget to reshape

shape_style

specifies the new shape

corner_width

specifies the width of the rounded rectangle corner

corner_height

specified the height of the rounded rectangle corner

This function reshapes the specified widget, using the Shape extension, to a rectangle, oval, ellipse, or rounded rectangle, as specified by shape_style ( XmuShapeRectangle, XmuShapeOval, XmuShapeEllipse, and XmuShapeRoundedRectangle, respectively). The shape is bounded by the outside edges of the rectangular extents of the widget. If the shape is a rounded rectangle, corner_width and corner_height specify the size of the bounding box that the corners are drawn inside of (see XmuFillRoundedRectangle); otherwise, corner_width and corner_height are ignored. The origin of the widget within its parent remains unchanged.

void XmuCvtStringToWidget(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);
void XmuCvtStringToWidget(XrmValue *args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal);

args

the sole argument is the parent Widget

num_args

this argument must be 1

fromVal

specifies the string to convert

toVal

returns the converted value

This function converts a string to an immediate child widget of the parent widget passed as an argument. Note that this converter only works for child widgets that have already been created; there is no lazy evaluation. The string is first compared against the names of the normal and popup children, and if a match is found the corresponding child is returned. If no match is found, the string is compared against the classes of the normal and popup children, and if a match is found the corresponding child is returned. The case of the string is significant. To use this converter, include the following in your widget's ClassInitialize procedure:

static XtConvertArgRec parentCvtArg[] = {
  {XtBaseOffset, (XtPointer)XtOffset(Widget, core.parent), sizeof(Widget)},
};

XtAddConverter(XtRString, XtRWidget, XmuCvtStringToWidget,
		 parentCvtArg, XtNumber(parentCvtArg));
      

Boolean XmuNewCvtStringToWidget(Display *dpy, XrmValuePtr args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *data);
Boolean XmuNewCvtStringToWidget(Display *dpy, XrmValuePtr args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *data);

dpy

the display to use for conversion warnings

args

the sole argument is the parent Widget

num_args

this argument must be a pointer to a Cardinal containing the value 1

fromVal

specifies the string to convert

toVal

returns the converted value

data

this argument is ignored

This converter is identical in functionality to XmuCvtStringToWidget, except that it is a new-style converter, allowing the specification of a cache type at the time of registration. Most widgets will not cache the conversion results, as the application may dynamically create and destroy widgets, which would cause cached values to become illegal. To use this converter, include the following in the widget's class initialize procedure:

static XtConvertArgRec parentCvtArg[] = {
  {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.parent),
   sizeof(Widget)}
};

XtSetTypeConverter(XtRString, XtRWidget, XmuNewCvtStringToWidget,
		   parentCvtArg, XtNumber(parentCvtArg), XtCacheNone, NULL);
static XtConvertArgRec parentCvtArg[] = {
  {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.parent),
   sizeof(Widget)}
};

XtSetTypeConverter(XtRString, XtRWidget, XmuNewCvtStringToWidget,
		   parentCvtArg, XtNumber(parentCvtArg), XtCacheNone, NULL);