CompBase Widget Metaclass


Overview

CompBase is a base widget class that handles hardcopy output for its subclasses, including
EditObject and EditTable. The CompBase widget class defines a set of functions for producing disk files containing CGM or PostScript representations of the graphical display of a widget and of its content. CompBase also handles the hardcopy output of the composition of multiple widgets. A composite image must be of multiple EditObject based widgets contained within a Composite widget such as a Motif Form or RowColumn widget.

In addition to hardcopy, CompBase provides a set of convenience functions to map user coordinates to and from device coordinates. The CompBase widget class is a metaclass and cannot be instantiated directly.


Inherited Resources and Behavior

The CompBase widget inherits behavior and resources from the Core, Composite and Manager classes.
The following resources are defined by the CompBase class:
NameTypeDefault
XmNfontPathchar *NULL
XmNwarningintXintWARNING_POST


XmNfontPath

Some subclasses of CompBase and some object classes such as Text or Symbol may require the use of scalable fonts, which are displayed using an outline font technology provided with the INT library. Resource XmNfontPath can be used to specify the path to the directory where the files containing the font outlines reside. Alternatively, you can use environment variable INT_FONT_PATH to specify this directory. If neither resource XmNfontPath nor environment variable INT_FONT_PATH is set, the current directory will be searched.

XmNwarning

Specifies the destination of warning messages that an INT widget might need to display. Use one of the following defined integer constants when specifying a value for this resource:

Resource ValueDescription
XintWARNING_NONENo message will be output.
XintWARNING_PRINTMessage will be written to stderr.
XintWARNING_POST (default)Message will be displayed in a dialog box.

You can combine destinations using a logical OR or an arithmetic + operation. For instance, specify XintWARNING_PRINT + XintWARNING_POST to have any warning message displayed on the screen and written to stderr.


Defined Functions

The following functions are defined for hardcopy output and coordinate system transformations. All of these functions can be applied to any widget instance of a class derived from the CompBase widget class (such as EditObject or EditTable). In addition, the composite hardcopy functions can be applied to any instance of a composite widget such as a widget instantiated from the Motif Form, or the Motif BulletinBoard widget classes.

Function NameDescription
XintCGMDrawBoxTo tell the CGM output whether or not to draw a box around a CGM plot.
XintCGMGetDimensionsGets the size in inches used by a widget.
XintCGMPixelToInchConverts a size specified in pixels to a size specified in inches.
XintCGMSetEdgeWidthModeSets the edge width mode for drawing primitives in the CGM display.
XintCGMSetLineWidthModeSets the line width mode for drawing primitives in the CGM display.
XintCGMSetVDCTypeSelects either real or integer output coordinates for CGM.
XintGetHardcopyGeometryInfoReturns geometry information that can be used to scale a hardcopy plot.
XintGetWidgetSizeReturns the size in pixels that a widget will occupy when output to hardcopy.
XintHorizontalPixelToUserPixel to User coordinates conversion in the horizontal direction.
XintHorizontalUserToPixelUser coordinates to Pixel conversion in the horizontal direction.
XintOutputCGMCreates a CGM file containing the graphic representation of a single widget or of all of the widgets that are children of a composite widget.
XintOutputMontageCGMCreates a CGM file containing a montage composed of several widgets.
XintOutputMontagePostscriptCreates a PostScript file containing a montage composed of several widgets.
XintOutputPostscriptCreates a PostScript file containing the graphic representation of a single widget or of all of the widgets that are children of a composite widget.
XintPostscriptGetCompressImageReturns the value of the flag controlling how PostScript images are output.
XintPostscriptGetDefaultsGets the PostScript page characteristics.
XintPostscriptSetBackgroundSets the background for PostScript output.
XintPostscriptSetCompressImageSets whether an 8 bit image is output in compressed mode or output as rgb values.
XintPostscriptSetDefaultsSets the PostScript page characteristics.
XintVerticalPixelToUserPixel to User coordinates conversion in the vertical direction.
XintVerticalUserToPixelUser coordinates to Pixel conversion in the vertical direction.


XintCGMDrawBox

This function sets a flag which tells the CGM output routines XintOutputCGM and XintOutputMontageCGM whether or not to draw a rectangular box around the plot.
     void XintCGMDrawBox (Boolean flag)
where flag is a Boolean variable that should be set to True to have the box drawn around the plot.

XintCGMGetDimensions

This function returns the dimensions (in inches) that a widget (or combination of widgets) will occupy when mapped to a plot. You usually call this function prior to calling a CGM hardcopy function so that you can specify the appropriate dimensions in the CGM hardcopy function call.
     void XintCGMGetDimensions (...)

WidgetwidgetThe ID of the widget to be output.
float *widthWidth in inches of the widget's extent.
float *heightHeight in inches of the widget's extent.


XintCGMPixelToInch

This function converts a size specification from pixels to inches. This function can be used to provide the plot size specification in inches required by function XintOutputMontageCGM.
     void XintCGMPixelToInch (...)

WidgetwidgetThe ID of the widget.
intpwidthWidth in pixels.
intpheightHeight in pixels.
float *widthReturns the width in inches.
float *heightReturns the height in inches.


XintCGMSetEdgeWidthMode

This function controls the mode for the edge width of filled polygons in the CGM output.
     void XintCGMSetEdgeWidthMode (...)

intmodeSpecify one of the values below.

The argument mode must be specified as one of the following:
Resource ValueDescription
XintCGM_WIDTH_MODE_ABSOLUTEThe edge width in the CGM display is the edge width of the primitive multiplied by the nominal line width of the target device, usually one pixel or device coordinate.
XintCGM_WIDTH_MODE_SCALED (default)The edge width in the CGM display is specified in the world coordinates of the plot.


XintCGMSetLineWidthMode

This function controls the mode for the line width of lines and polygons in the CGM output.
     void XintCGMSetLineWidthMode (...)

intmodeSpecify one of the values below.

The argument mode must be specified as one of the following:
Resource ValueDescription
XintCGM_WIDTH_MODE_ABSOLUTEThe line width in the CGM display is the line width of the primitive multiplied by the nominal line width of the target device, usually one pixel or device coordinate.
XintCGM_WIDTH_MODE_SCALED (default)The line width in the CGM display is specified in the world coordinates of the plot.


XintCGMSetVDCType

This function allows the application to globally select the type of CGM output file to be created. Output coordinate data can be either real, the default, or integer. The integer type is provided because some CGM previewers and rasterizers do not support the floating point format.
     void XintCGMSetVDCType (...)

inttypeSpecify one of the values below.

The argument type must be specified as one of the following defined constants:
Resource ValueDescription
XintCGM_VDC_TYPE_INTEGERThe coordinates are output in 16 bit integer format, as required by the CGM/PIP (Petroleum Industry Profile) specification.
XintCGM_VDC_TYPE_REALThe coordinates are output in fixed point floating format, as required by the CGM/PIP (Petroleum Industry Profile) specification. This is the default.


XintGetHardcopyGeometryInfo

This function returns geometry information that can be used to scale a hardcopy plot. It is only useful with the Grid widget.
     void XintGetHardcopyGeometryInfo (...)

WidgetwidgetThe ID of the Grid widget.
int *lmReturns the size of the left margin in pixels.
int *rmReturns the size of the right margin in pixels.
int *tmReturns the size of the top margin in pixels.
int *bmReturns the size of the bottom margin in pixels.
int *widthReturns the width of the plot (including margins) in pixels.
int *heightReturns the height of the plot (including margins) in pixels.

For example, to obtain a CGM plot with an internal plot size width of 20 inches, the plot width (required when calling function XintOutputCGM) can be calculated as follows:

    plot_width = 20. * width / (width - lm - rm); 

The same applies for the calculation of the plot height.


XintGetWidgetSize

This function returns the size in pixels that a widget will occupy when output to hardcopy. This function is primarily used in conjunction with functions XintOutputMontagePostscript or XintOutputMontageCGM to position the widgets to be output. The size returned by this function is equal to the widget size, except when the argument is a Motif ScrolledWindow widget, in which case it will return the full size of the child widget.
     void XintGetWidgetSize (...)

WidgetwidgetThe ID of the widget.
int *widthReturns the width in pixels.
int *heightReturns the height in pixels.


XintHorizontalPixelToUser

This function converts a pixel coordinate into the corresponding user coordinate using the default horizontal coordinate system of a widget whose class is derived from the XintCompBase widget class.
     Boolean XintHorizontalPixelToUser (...)

WidgetwidgetThe ID of the CompBase derived widget.
intpixelSpecifies the horizontal window coordinate.
float *userReturns the corresponding user coordinate.

The function returns False if pixel is outside the widget's window.


XintHorizontalUserToPixel

This function converts a user coordinate into the corresponding pixel coordinate using the default horizontal coordinate system of a widget whose class is derived from the XintCompBase widget class.
     Boolean XintHorizontalUserToPixel (...)

WidgetwidgetThe ID of the CompBase derived widget.
floatuserSpecifies the horizontal user coordinate.
int *pixelReturns the corresponding window coordinate.

The function returns False if user is outside the widget's window.


XintOutputCGM

Writes a color CGM description of a widget or of the contents of a container widget to a disk file. The geometry of the widgets inside a container widget is preserved. However, widgets contained in a Motif ScrolledWindow widget are expanded to their full size and the scrollbars are not displayed. Only widgets that are instances of INT CompBase, Scroll, or Motif ScrolledWindow, Label, Text or TextField, or one of their subclasses will be output.
     Boolean XintOutputCGM (...)

WidgetwidgetWidget for output.
char *filenameName of CGM file to be created.
floatplot_widthSpecifies the width in inches of the CGM plot to be generated.
floatplot_heightSpecifies the height in inches of the CGM plot to be generated.

In case of error, the function returns a warning message to the end-user (as controlled by resource XmNwarning) and returns False. Otherwise, it returns True.


XintOutputMontageCGM

Writes a color CGM file containing a montage of several widgets into a canvas. The canvas size and the widget positions inside the canvas are specified in pixel units. The convenience function XintGetWidgetSize can be used to obtain the size in pixels of each widget. The widgets in the list must be of a class derived from INT CompBase, Scroll, or Motif ScrolledWindow, Label, Text or TextField.
     Boolean XintOutputMontageCGM (...)

Data TypeArg NameDescription
widget *widget_listList of widgets to output.
int *xpos_listList of x coordinates for the widgets.
int *ypos_listList of y coordinates for the widgets.
intcountNumber of widgets to output.
char *filenameName of CGM file to be created.
intcanvas_widthWidth of canvas in pixels.
intcanvas_heightHeight of canvas in pixels.
floatwidthWidth of plot in inches.
floatheightHeight of plot in inches.

In case of error, the function displays a warning message (as controlled by resource XmNwarning) to the end user and returns False; otherwise, it returns True.


XintOutputMontagePostscript

Writes a color or monochrome PostScript file containing a montage of several widgets into a canvas. The canvas size and the widget positions inside the canvas are specified in pixel units. Convenience function XintGetWidgetSize can be used to obtain the size in pixels of each widget. The widgets in the list must be from a class derived from INT CompBase, Scroll, or Motif ScrolledWindow, Label, Text or TextField.
     Boolean XintOutputMontagePostscript (...)

Widget *widget_listList of widgets to output.
int *xpos_listList of x coordinates for the widgets.
int *ypos_listList of y coordinates for the widgets.
intcountNumber of widgets to output.
char *filenameName of PostScript file to be created.
intcanvas_widthWidth of canvas in pixels.
intcanvas_heightHeight of canvas in pixels.
floatscale_factorSpecify a real number greater than 0 (see below).
intcolor_modelSpecify XintMONOCHROME for monochrome output or XintCOLOR for color output.
intorientationSpecify one of the values below.

When the color_model argument is specified as XintCOLOR for a monochrome device, a grayscale display will be produced. Specification of XintMONOCHROME sets all lines and text to black. All fill areas will be grayscale.

The argument orientation must be specified as one of the following defined constants:
Resource ValueDescription
XintORIENTATION_PORTRAITImage will be oriented as on screen.
XintORIENTATION_LANDSCAPEImage will be rotated 90 degrees clockwise from the screen image.
XintORIENTATION_AUTOMATICImage will be oriented so that the longest dimension (height or width) will be along the longest dimension of the page.

The scale_factor argument in the function call specifies how the image inside the widget window will be scaled when output to the PostScript file. If you specify 1, then the image will be fitted to the page. If you specify a fractional number greater than 0 and less than 1, then the image will be scaled to that fraction of the page. If you specify a number greater than 1, then the image will be scaled by that number and multiple pages, as required by the amount of scaling, will be output to the PostScript file.

In case of error, the function displays a warning message to the end user (as controlled by resource XmNwarning) and returns False; otherwise, it returns True.


XintOutputPostscript

Writes a scaled monochrome or color PostScript description of an INT widget, or of all of the widgets inside of a container widget, to a disk file. When a container widget is specified, the geometry of the widgets inside the container widget is preserved. However, widgets contained in a Motif ScrolledWindow widget or an INT Scroll widget are expanded to their full size and the scrollbars are not displayed. Only widgets that are instances of INT CompBase, Scroll, or Motif ScrolledWindow, Label, LabelGadget, Text or TextField, or one of their subclasses will be output.
     Boolean XintOutputPostscript (...)

WidgetwidgetWidget for output.
char *filenameName of PostScript file to be created.
floatscale_factorSpecify a real number greater than 0 (see below).
intcolor_modelSpecify XintMONOCHROME for monochrome output or XintCOLOR for color output.
intorientationSpecify one of the values below.

When the color_model argument is specified as XintCOLOR for a monochrome device, a grayscale display will be produced. Specification of XintMONOCHROME sets all lines and text to black. All fill areas will be grayscale.

The argument orientation must be specified as one of the following defined constants:
Resource ValueDescription
XintORIENTATION_PORTRAITImage will be oriented as on screen.
XintORIENTATION_LANDSCAPEImage will be rotated 90 degrees clockwise from the screen image.
XintORIENTATION_AUTOMATICImage will be oriented so that the longest dimension (height or width) will be along the longest dimension of the page.

The scale_factor argument in the function call specifies how the image inside the widget window will be scaled when output to the PostScript file. If you specify 1, then the image will be fitted to the page. If you specify a fractional number greater than 0 and less than 1, then the image will be scaled to that fraction of the page. If you specify a number greater than 1, then the image will be scaled by that number and multiple pages, as required by the amount of scaling, will be output.

In case of error, the function displays a warning message to the end user (as controlled by resource XmNwarning) and returns False; otherwise, it returns True.


XintPostscriptGetCompressImage

Returns the compression mode used when generating a PostScript output file.

     int XintPostscriptGetCompressImage (void)

If value returned is True then compression mode is on. If value returned is False then compression mode is off and image is output as rgb values.


XintPostscriptGetDefaults

Gets the PostScript output page characteristics set by using the XintPostscriptSetDefaults function.
     void XintPostscriptGetDefaults (...)

int *resolutionReturns a pointer to an integer specifying the page resolution in dots per inch.
float *page_widthReturns a pointer to a floating point number specifying the page width in inches.
float *page_heightReturns a pointer to a floating point number specifying the page height in inches.


XintPostscriptSetBackground

Sets the background color for the PostScript output. By default, the PostScript output will not paint the background. Use this function if you want the plot background to be painted.
     void XintPostscriptSetBackground (Pixel fill_color)

where fill_color is a Pixel value. Set fill_color to XintNO_FILL to have no background painted.


XintPostscriptSetCompressImage

Sets the compression mode for 8 bit image output when generating a PostScript file.

 void XintPostscriptSetCompressImage (int flag)

When set to True, images are output in compressed mode (index into a color table). When set to False, images are output as rgb values. The compress mode generates smaller files (close to 3 times smaller), however, the printing takes much longer for large images compared to the case where the image is not compressed. The default flag is True.


XintPostscriptSetDefaults

Sets the PostScript output page characteristics used by XintOutputPostscript.
     void XintPostscriptSetDefaults (...)

intresolutationSpecifies the page resolution in dots per inch.
floatpage_widthSpecifies the page width in inches.
floatpage_heightSpecifies the page height in inches.


XintVerticalPixelToUser

This function converts a pixel coordinate into the corresponding user coordinate in the default vertical coordinate system of a widget whose class is derived from the XintCompBase widget class.
     Boolean XintVerticalPixelToUser (...)

WidgetwidgetThe ID of the CompBase widget.
intpixelSpecifies the pixel location in the vertical direction.
float *userReturns the user coordinate corresponding to argument pixel.

The function returns False if argument pixel is outside the widget's boundaries.


XintVerticalUserToPixel

This function converts a user coordinate into the corresponding pixel coordinate using the default vertical coordinate system of a widget whose class is derived from the XintCompBase widget class.
     Boolean XintVerticalUserToPixel (...)

WidgetwidgetThe ID of the CompBase widget.
floatuserSpecifies the user location in the vertical direction.
int *pixelReturns the pixel coordinate corresponding to argument user.

The function returns False if argument user is outside the widget's boundaries.