All edm widgets share some common behavior. For example, they provide a widget property dialog box during creation and edit. They implement color buttons that link to a pallete or menu of colors. Widgets that display text implement a menu of available fonts. Most include the capibility to process macros (i.e. if the symbol foo=bar, they translate $(foo):pv into bar:pv). All must be able to serialize/deserialize themselves to/from offline storage. To enforce various norms and release the widget developer from the burden of extensive work, a number of helper classes have been provided to perform these common functions. Each class will be introduced in the following. Class usage details are given in Appendix A.
An object named actWin is available to each widget by inheritance. This object contains the window context and is used in various ways by a widget. References to this object will appear thoughout the remained of this document.
An object named appCtx is available as an attibute of actWin. Each widget may reference this object as actWin->appCtx. This object contains the application context and is used in various ways by a widget. References to this object will appear thoughout the remained of this document.
An object named ef is available to each widget by inheritance. This object is used to implement the propery diaglog box of a widget. Typical usage is shown functionally below.
// Other code must be written that will be called in response to the // event generated by the user pressing the OK, Apply, or Cancel button. // For this example, call these functions ok_hander, apply_handler, and // cancel_handler. // create the dialog ef.create(...); // the following ef.add... functions are used in various combinations ef.addTextField(...); ef.addOption(...); ef.addToggle(...); ef.addColorButton(...); ef.addFontMenu(...); // creation is complete ef.finished( ok_hander, apply_handler, cancel_handler, ... ); actWin->currentEf = &ef; // pop-up the dialog ef.popup(); // pop-down and destroy the dialog ef.popdown(); // add a button to the dialog that when pressed will popup another dialog ef.addEmbeddedEf( "Embedded Form", "... ", &efSubForm ); // pop-down but do not destroy an embedded dialog; the embedded // dialog will be destroyed with its parent efSubForm->popdownNoDestroy();
One set of helper objects are used with the entryFormClass to provide fields that may be null. For now, they will simply be listed by name.
class efInt - integer object that may have a null value class efDouble - double object that may have a null value
Another set of helper classes provides a color button form object and a font menu form object. The classes are listed below.
class colorButtonClass class fontMenuClass
This is a string object that edm widgets use to support macro expansion. Example usage is shown below.
// set string unexpanded value alarmPvExpStr.setRaw( bufAlarmPvName ); // get string unexpanded value into buf strncpy( buf, alarmPvExpStr.getRaw(), MAX ); // expand macros stat = alarmPvExpStr.expand1st( numMacros, macros, expansions ); // get string expanded value into buf (after macro substitution) strncpy( buf, alarmPvExpStr.getExpanded(), MAX );
An object named ci is available as an attibute of actWin. It is referenced as actWin->ci and is used whenever color related operations are performed. A few examples follow.
// prepare color for offline storage tag.loadW( "fgColor", actWin->ci, &fgColor ); // reference current colormap ef.create( actWin->top, actWin->ci.getColorMap(), ... ); // add color button to a propery box ef.addColorButton( "Fg", actWin->ci, &fgCb, &bufFgColor ); // set pvColor object to a particular color index fgColor.setColorIndex( color, actWin->ci );
An object named fi is available as an attibute of actWin. It is referenced as actWin->fi and is used whenever font related operations are performed. A few examples follow.
// load font actWin->fi->loadFontTag( fontTag ); // get X Window font struct fs = actWin->fi->getXFontStruct( fontTag ); // setup graphics context to use particular font actWin->drawGc.setFontTag( fontTag, actWin->fi ); // add font menu to a property box ef.addFontMenu( "Font", actWin->fi, &fm, fontTag );
An object named drawGc and one named executeGc are available as attibutes of actWin. A widget may reference these object as actWin->drawGc and actWin->executeGc. The drawGc object is used to draw in edit mode and the executeGc object is used to draw in execute mode. This class encapsulates the functionality of the window system graphics context. Example usage is shown below.
// save foreground color actWin->executeGc.saveFg(); // set style of line (solid or dash) actWin->executeGc.setLineStyle( lineStyle ); // set width of line actWin->executeGc.setLineWidth( lineWidth ); // set color of line actWin->executeGc.setFG( fillColor.getIndex(), &blink ); // draw filled polygon XFillPolygon( actWin->d, XtWindow(actWin->executeWidget), actWin->executeGc.normGC(), xpoints, n, Complex, CoordModeOrigin ); // restore default settings actWin->executeGc.restoreFg(); actWin->executeGc.setLineStyle( LineSolid ); actWin->executeGc.setLineWidth( 1 );
A class that works with process variable alarm and connection states. Several usage examples follow.
// make color sensitive to alarm state of pv lineColor.setAlarmSensitive(); // set color alarm state lineColor.setStatus( curStatus, curSeverity ); // set color connect state to "pv is connected" lineColor.setConnected(); // set color connect state to "pv is not connected" lineColor.setDisconnected(); // set graphics context fg to raw pixel color actWin->drawGc.setFG( lineColor.pixelColor() ); // set graphics context fg to alarm sensitive color and enable blinking // colors to be processed actWin->executeGc.setFG( lineColor.getIndex(), &blink ); // make color sensitive to connect state of pv lineColor.setConnectSensitive(); // prepare pvColorClass object for serialization tag.loadW( "lineColor", actWin->ci, &lineColor );
Class used to keep track of connected state of multiple process variables. Several usage examples follow.
// initialize
connection.init();
// max process variables will be 2
connection.setMaxPvs( 2 );
// keep track of one pv so far
connection.addPv();
// keep track of another pv (two, at this point)
connection.addPv();
// set pv connected
connection.setPvConnected( (void *) alarmPvConnection );
// set pv connected
connection.setPvConnected( (void *) visPvConnection );
// set pv disconnected
connection.setPvDisconnected( (void *) alarmPvConnection );
// set pv disconnected
connection.setPvDisconnected( (void *) visPvConnection );
if ( connection.pvsConnected() ) {
// all pvs are connected
}
else {
// at least one pv is disconnected
}Class to serialize/deserialize object to/from offline storage. Example usage follows.
// Serialize tag.init(); tag.loadW( "beginObjectProperties" ); tag.loadW( "major", &major ); tag.loadW( "minor", &minor ); tag.loadW( "release", &release ); tag.loadW( "x", &x ); tag.loadW( "y", &y ); tag.loadW( "w", &w ); tag.loadW( "h", &h ); tag.loadW( "fgColor", actWin->ci, &fgColor ); tag.loadW( "bgColor", actWin->ci, &bgColor ); tag.loadW( "endObjectProperties" ); tag.loadW( "" ); stat = tag.writeTags( f ); // Deserialize tag.init(); tag.loadR( "beginObjectProperties" ); tag.loadR( "major", &major ); tag.loadR( "minor", &minor ); tag.loadR( "release", &release ); tag.loadR( "x", &x ); tag.loadR( "y", &y ); tag.loadR( "w", &w ); tag.loadR( "h", &h ); tag.loadR( "fgColor", actWin->ci, &fgColor ); tag.loadR( "bgColor", actWin->ci, &bgColor ); tag.loadR( "endObjectProperties" ); stat = tag.readTags( f, "endObjectProperties" );
Class used in undo operation for widgets with complex internal details.
Another class used in undo operation for widgets with complex internal details.