Chapter 6 Wrapped Class Reference

6.2 User Interface

The class inheritance tree for the User Interface (XF) wrapped classes appears in Figure 6.5. As the legend shows, black boxes indicate classes and gray boxes indicate abstract classes. Documentation for all classes in this tree appears in this section.

Figure 6.5: User Interface Wrapped Classes Inheritance Tree

6.2.1 XFwidget - Abstract

XFwidget, the base class for all windowed widgets, defines all common attributes and activities.

Superclasses

Section 6.1.2, "Activity Manager - Abstract" page 116

Section 6.1.3, "Attribute Manager - Abstract" page 118

Methods

None

Attributes
Basic Widget Attributes
AttributeTypeDescriptionDefaultAccess
xintegerx-coord upper left outside corner of widget0CGS
yintegery-coord upper left outside corner of widget0CGS
widthintegerwidget width (in pixels), including border100CGS
heightintegerwidget height (in pixels), including border100CGS
borderWidth

(only on UNIX)

integerwidth of the border surrounding the widget0CGS
foreground

(only on UNIX)

stringforeground drawing color for the widgetplatformCGS
background

(limited on NT)

stringbackground drawing color for the widget (unavailable on NT for XFmessageDlg, XFhtml, XFcheckBox, XFradioButton, XFtext, XFselectList, XFtextField, XFfont nor any classes derived from XFmenuItem) platformCGS
borderColorstringcolor of the border surrounding the widgetplatformCGS
visiblebooleanStatus of the widget relative to the screen;

if set to TRUE, the widget is displayed.

TRUECGS
disabledbooleanDetermines if widget receives user input. When set to TRUE, widget is disabled and doesn't receive keyboard or mouse input.FALSECGS
systemLookbooleanSpecifies if widget should maintain the look of the platform. Setting this to TRUE may override other attributes on the widget.FALSECG

Basic Widget Activities
ActivityKeysDescription
MouseUpinteger x, y, button
boolean shift, control, modifier
mouse button released
MouseDownsamemouse button pressed
MouseDblClicksamemouse button double-clicked
MouseMovesamemouse moved
MouseDragsamemouse moved while button held down
Destroyednonewidget destroyed
Shownnonewidget displayed
Hiddennonewidget removed from display
Resizedinteger width, heightwidget resized
Movedinteger x, ywidget moved
FocusIn

(only on UNIX)

nonewidget gained input focus
FocusOut

(only on UNIX)

nonewidget lost input focus
Refreshinteger x, y,

integer width, height

widget redrawn
Helpnonehelp requested for widget
KeyPressedstring character, boolean shift,

boolean command, boolean modifier

key pressed in widget
KeyRepeatsamekey held down in widget
Activities

Example

None

6.2.2 XFcontainable - Abstract

The XFcontainable class is an abstract class that defines the interface and behavior of all containable widgets such as XFbuttons, XFtextFields, and so on. A widget is said to be "containable" if it can be placed as a child of another widget (the container).

Superclasses

Section 6.2.1, "XFwidget - Abstract" page 125

Methods

None

Attributes

None

Activities

None

Example

None

6.2.3 XFcontainer - Abstract

The XFcontainer class is an abstract class that defines the interface and behavior of all container widgets such as the XFtop. A widget is said to be a container if it can contain or hold other widgets as children.

Superclasses

Section 6.2.1, "XFwidget - Abstract" page 125

Methods

None

Attributes

None

Activities

None

Example

None

6.2.4 XFcontainableContainer - Abstract

The XFcontainableContainer class is an abstract class that defines the interface and behavior of all containable widgets which are also containers such as XFlayout and XFvisual.

Superclasses

Section 6.2.2, "XFcontainable - Abstract" page 128

Section 6.2.3, "XFcontainer - Abstract" page 128

Methods

None

Attributes

None

Activities

None

Example

None

6.2.5 XFtop

The XFtop class is a top-level widget, most commonly used as a container for other widgets. It defines the standard appearance for the primary windows of an application. XFtop defines two basic areas: a menu bar and a work area. The menu bar area is optional and is created only if there is a menu attached to the XFtop.

Superclasses

Section 6.2.3, "XFcontainer - Abstract" page 128

Methods

upon Construct

Default constructor.

Attributes
XFtop Attributes
AttributeTypeDescriptionDefaultAccess
titlestringcaption to be displayed in the widget's title bar"XFtop"CGS
windowStylelistSpecifies the style for the widget's decorations. This list should be composed of zero (0) or more of the following style names: "titleBar", "resizeControl", and "windowFrame".{"titleBar", "resizeControl", "windowFrame"}CG
menuBarhandledefines a handle to the XFmenu object associated with this XFtopNULLCGS

Activities
XFtop Activities
ActivityKeysDescription
ActivenonetopShell has been activated
DeactivenonetopShell has been deactivated
MenuCommandstring command,

list commandPath

a menu command was selected

Example

This code creates an instance of an anonymous class derived from XFtop and assigns appropriate values for some of the XFtop's attributes.

1 // In order to use XFtop as a container we use inheritance

2

3 anonymous : XFtop

4 {

5 // ... Some useful members here ...

6 // ... We can put other widgets here ...

7

8 } topShell { width = 200; height = 300; title = "ModuleName";};

6.2.6 XFlayout

The XFlayout class represents a widget that acts as a manager and container for other widgets. As a manager, it provides simple geometry management for children widgets and does not force positioning or sizes on them.

Superclasses

Section 6.2.4, "XFcontainableContainer - Abstract" page 129

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

Attributes

None

Activities

None

Example

1 // Create a class derived from XFlayout to contain to XFlabel objects

2 class Canvas : XFlayout

3 {

4 XFlabel screen

5 {

6 x=35; y=20; width=135; height=100; background="steelBlue";

7 label = ""; borderWidth = 5; borderColor = "darkOrchid";

8 };

9

10 XFlabel title

11 {

12 x = 50; y = 150; width = 100; height = 30; label = "Layout";

13 fontRequest = {"Helvetica", 14, {"bold"}, "roman"};

14 };

15 };

16

17 anonymous : XFtop

18 {

19 // Create an instance of the XFlayout derived class

20 Canvas layout {x=100; y=50; width=200; height=200; visible=FALSE;};

21

22 XFbutton controller

23 {

24 x = 100; y = 270; width = 70; height = 40; label = "Show";

25 recomputeSize = FALSE; background = "grey";

26 fontRequest = {"Helvetica", 14, {"bold"}, "roman"};

27 };

28

29 XFbutton quitButton

30 {

31 x = 230; y = 270; width = 70; height = 40; label = "Quit";

32 background = "grey";

33 fontRequest = {"Helvetica", 14, {"bold"}, "roman"};

34 };

35

36 // This method changes the visibility of the XFlayout when called

37 // Note that because the XFlayout contains another two objects,

38 // their visibility also changes

39 on ChangeVisibility

40 {

41 if ( layout.visible ) { controller.label = "Show"; }

42 else { controller.label = "Hide"; }

43 layout.visible = !layout.visible;

44 }

45

46 on Exit

47 {

48 "Exit" => theApp;

49 }

50

51 upon Construct

52 {

53 controller.Pressed = {"ChangeVisibility", self };

54 quitButton.Pressed = {"Exit", self };

55 }

56

57 } top {width = 400; height = 350; background = "grey";};

6.2.7 XFvisual

The XFvisual class provides a display surface for media objects. Since this class inherits from XFcontainableContainer, it can provide very simple geometry management of multiple widget children.

Superclasses

Section 6.2.4, "XFcontainableContainer - Abstract" page 129

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

Attributes

None

Activities

None

Example

1 anonymous : XFtop

2 {

3 // Create an XFvisual to display an image

4 XFvisual screen

5 {

6 x = 40; y = 20; width = 320; height = 200;

7 };

8

9 handle hPicture;

10 upon Construct

11 {

12 width = 300;

13 height = 200;

14 // Create the image to display

15 hPicture = new {"Construct", {"MEimage",

16 {"MAfile","dragon.gif"}}} => MMimage;

17

18 // Add the XFvisual object as the sink for this image

19 {"AddSink", &screen} => hPicture;

20 "Show" => hPicture;

21 ExitButton.Pressed = {"Quit", self };

22 }

23

24 XFbutton ExitButton

25 {

26 x = 150;

27 y = 240;

28 width = 100;

29 height = 60;

30 label = "Quit";

31 fontRequest = {"Helvetica", 18, {"bold"}, "roman"};

32 };

33

34 on Quit

35 {

36 "Exit" => theApp;

37 }

38

39 } topShell { width = 400; height = 320; title = "XFvisual example";};

6.2.8 XFhtml

This class provides a display surface for MMhtml objects.

Superclasses

Section 6.2.2, "XFcontainable - Abstract" page 128

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

on SetFont: string targetElementType, handle anXFfont

Sets the font for all elements of tag type targetElementType in this HTML display surface; currently, targetElementType can be "H1", "H2", "H3", "H4", "H5", "H6", "LISTING", "PLAIN", "ADDRESS", "FIXED", "ITALIC", "BOLD", and "NORMAL".

Attributes

None

Activities
XFhtml Activities
ActivityKeysDescription
AnchorPressedinteger element_id, string anchor_name, text, hrefA hyperlink anchor has been pressed and released. The anchor pressed is contained in anchor_name.
HTMLSubmitFormstring href, method,

integer attribute_count,

list attribute_names, attribute_values

An HTML submit button (for forms) has been pressed and released
ImageMapPressedstring image_src,
integer x, y, element_id, string anchor_name, href, text
An inlined HTML image map has been pressed and released. The key "image_src" is the URL of the inlined image. "x" and "y" are the coordinates of the user's mouse click within the image map. "element_id" is for future extension only. "anchor_name" is the name of the anchor for this image map. "href" is the URL of the object which contains the mapping information. "text" contains the hypertext associated with the anchor.

Example

The methods XFhtml and MMhtml work together (see Section 6.3.12, "MMhtml" page 195).

6.2.9 XFmessageDlg

The XFmessageDlg class defines a simple message dialog box, which is normally used to present transient messages. An XFmessageDlg consists of a message symbol, a message, and a number of push-buttons that are used to respond to the message and dismiss the dialog box.

Superclasses

Section 6.2.2, "XFcontainable - Abstract" page 128

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

on PostModal: return string

Posts dialog and forces the user to respond or dismiss the dialog.

Attributes
XFmessageDlg Attributes
AttributeTypeDescriptionDefaultAccess
titlestringtext to be displayed in the widget's title bar"XFmessageDlg"CGS
messagestringtext to be displayed in the dialog." "CGS
dialogIconstringSymbol to display along with the message: one of "error", "warning", "information", or "question"" "CGS
buttonSetstringSet of buttons to be displayed in the dialog box: one of: "ok", "okCancel", "yesNo", or "yesNoCancel""okCancel"CGS
defaultButtonstringThe default button for the dialog box: must be one of: "ok", "cancel", "yes", or "no". If the specified button is not part of the button set, this attribute is ignored."ok"CGS

Activities

None

Example

The following example illustrates the use of XFmessageDlg objects

1 anonymous : XFtop

2 {

3

4 // Create a message dialog to prevent the user from quitting

5 // without confirming

6 // Note that creating the QuitDialog object does NOT pop up the

7 // dialog box.

8 XFmessageDlg QuitDialog

9 {

10 title="Quit";

11 message="Do you really want to exit\nthis great application?";

12 dialogIcon="question";

13 buttonSet="yesNo";

14 defaultButton="no";

15 };

16

17 XFbutton ExitButton

18 {

19 x = 50;

20 y = 45;

21 width = 100;

22 height = 60;

23 label = "Quit";

24 font=new {"Create", "Helvetica", 18,{"bold"},"roman"}=> XFfont;

25 };

26

27 upon Construct

28 {

29 ExitButton.Pressed = {"Quit", self };

30 }

31

32 on Quit

33 {

34 // Post the dialog in modal mode. After returning from this call

35 // the dialog object still exists and can be posted again

36 string answer = {"PostModal"} => QuitDialog;

37 if ( answer == "yes" )

38 {

39 echo("Quitting...\n");

40 "Exit" => theApp;

41 }

42 }

43

44 } topShell { width = 200; height = 150; title = "Modal Messages";};

6.2.10 XFsimple - Abstract

The class XFsimple is an abstract class that defines the interface and behavior of simple widgets that cannot contain any other widgets.

Superclasses

Section 6.2.2, "XFcontainable - Abstract" page 128

Methods

None

Attributes

None

Activities

None

Example

None

6.2.11 XFfontable - Abstract

The XFfontable class is an abstract class that defines the interface and behavior of all other classes for which a font can be set. Some examples of such classes are the XFselectList, XFlabel, XFbutton, and XFtext.

Superclasses

Section 6.2.10, "XFsimple - Abstract" page 138

Attributes
XFfontable Attributes
AttributeTypeDescriptionDefaultAccess
fontRequestlistspecifies a request to use a certain font to display the text in the widget{}CGS
fonthandlereal font used to display the text in the widgetplatform dependentCGS

Activities

None

6.2.12 XFlabel

The XFlabel class represents a static text label. This, along with the XFbutton is one of the most widely used widgets in GUI-based applications. The XFlabel class defines the basic behavior and interface to render and manage static text by controlling its color, font, alignment, and other visual attributes.

Superclasses

Section 6.2.11, "XFfontable - Abstract" page 138

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

Attributes
XFlabel Attributes
AttributeTypeDescriptionDefaultAccess
labelstringtext to be displayed in widget"XFlabel"CGS
alignmentstringlabel alignment (language, left, center, or right)"center"CGS
marginTop

(only on UNIX)

integeramount of space between top of label text and top margin0CGS
marginBottom

(only on UNIX)

integeramount of space between bottom of label text and bottom margin0CGS
marginLeft

(only on UNIX)

integeramount of space between left of label text and left margin0CGS
marginRight

(only on UNIX)

integeramount of space between right of label text and right margin0CGS
recomputeSizebooleandetermines whether the widget resizes itself to accommodate its textTRUECGS

Activities

None

Example

The following example illustrates the use of XFlabel objects.

1 anonymous : XFtop

2 {

3 XFbutton ExitButton

4 {

5 x = 150;

6 y = 120;

7 width = 100; height = 60; label = "Quit";

8 fontRequest = {"Helvetica", 18, {"bold"}, "roman"};

9 };

10

11 // Create a label that will have the current time as its text

12 XFlabel timeLabel

13 {

14 width = 400;

15 height = 100;

16 background = "darkOrchid";

17 fontRequest = {"Helvetica", 48, {"bold"}, "roman"};

18 // Assign the currentTime to its label attribute

19 label = toString(localTime());

20 // Always be center aligned

21 alignment = "center";

22 // Do not change size after the label is set time by time

23 recomputeSize = FALSE;

24 };

25

26 // Create timer

27 PMclock timer; any timerKey;

28

29 upon Construct

30 {

31 ExitButton.Pressed = {"Quit", self };

32 // Subscribe for time notification every second

33 timerKey = {"Subscribe", 999, "Tick", {}, self} => timer;

34 }

35

36 on Tick : list cd, list ad return boolean

37 {

38 // Assign the current time to the label

39 timeLabel.label = toString(localTime());

40 return TRUE;

41 }

42

43 on Quit

44 {

45 // Remove timer notification

46 {"Unsubscribe", timerKey} => timer;

47 "Exit" => theApp;

48 }

49

50 } topShell { width = 400; height = 200; title = "TimeLabel";};

6.2.13 XFbutton

The XFbutton class represents a basic interface push-button. Push-buttons are one of the most widely-used widgets in GUI-based applications. XFbutton supports activities through which an application can perform an action in response to some user interaction. The appearance of an XFbutton changes to make it look either pressed in when selected or raised when unselected.

Superclasses

Section 6.2.12, "XFlabel" page 139

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

Attributes
XFbutton Attributes
AttributeTypeDescriptionDefaultAccess
showAsDefaultbooleanspecifies whether the button should be marked as the default buttonFALSECGS

Activities
XFbutton Activities
ActivityKeysDescription
Pressednonebutton pressed and released in widget

Example

The following code creates an instance of a class derived from XFtop which contains an XFbutton member. When the button is pressed, the application exits.

1 // Create an XFtop to be used as a module top-level widget

2 anonymous : XFtop

3 {

4 // Lets create a button member

5 XFbutton ExitButton

6 {

7 x = 50;

8 y = 20;

9 width = 100;

10 height = 60;

11 label = "Quit";

12 };

13 // ... Some other useful members here ...

14 // Constructor for the XFtop

15 upon Construct

16 {

17 // Use special XFbutton member Pressed to subscribe

18 // for the Pressed activity When the Pressed actity occurs

19 // send the message Quit to this XFtop (self)

20 ExitButton.Pressed = {"Quit", self };

21 }

22 // Quit Method

23 on Quit

24 {

25 echo("Quitting...\n");

26 "Exit" => theApp;

27 }

28

29 } topShell { width = 200; height = 300; title = "ModuleName";};

6.2.14 XFtoggleButton - Abstract

The XFtoggleButton class represents a button widget that is either set or unset. XFtoggleButtons are most commonly used in groups with either a one-of-many behavior, which means that only one button in the group can be set at a time, or an n-of-many behavior, which means that any number of buttons in the group can be set at one time. The XFtoggleButton class defines the common members, methods, and activities for two more specific classes: see "XFcheckBox" on page 143, and "XFradioButton" page 144.

Superclasses

Section 6.2.13, "XFbutton" page 141

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

on Toggle

Toggles the state of the XFtoggleButton object.

Attributes
XFtoggleButton Attributes
AttributeTypeDescriptionDefaultAccess
setbooleandetermines whether the XFtoggleButton object is set or notFALSECGS

Activities
XFtoggleButton Activities
ActivityKeysDescription
StateChangenonestate of the XFtoggleButton changed

Example

For a sample program using this class, see specific examples of ToggleButtons "XFcheckBox and XFradioButton" see "XFradioButton" on page 144.

6.2.15 XFcheckBox

The XFcheckBox class represents a kind of toggle button, a button that is either set or unset, to be used in groups with an n-of-many behavior (that is, any number of XFcheckBoxes in the same group may be set at one time.) It is important to note, however, that this behavior is not enforced by the widget itself, and the application should follow this interface guideline. An XFcheckBox consists of an indicator (a square on all platforms) and a label area. As its name suggests, the indicator tells whether a particular XFcheckBox is set or unset.

Superclasses

Section 6.2.14, "XFtoggleButton - Abstract" page 142

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

on Toggle

Toggles the state of the XFcheckBox object.

Attributes

None

Activities

None

Example

For a sample program using this class, see "XFcheckBox and XFradioButton" see "XFradioButton" on page 144.

6.2.16 XFradioButton

The XFradioButton class represents a kind of toggle button, a button that is either set or unset, to be used in groups with a one-of-many behavior (that is, only one XFradioButton in the same group can be set at a time.) It is important to note that this behavior is not enforced by the widget itself, and that the application should follow this interface guideline. An XFradioButton consists of an indicator (diamond or circle depending on the platform) and a label area. As its name suggests, the indicator tells whether a particular XFradioButton is set or unset.

Superclasses

Section 6.2.14, "XFtoggleButton - Abstract" page 142

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

on Toggle

Toggles the state of the XFradioButton object.

Attributes

None

Activities

None

Example

This example of the Toggle Buttons, XFcheckbox and XFradiobutton, also shows several uses of the XFfont class.

1 // This class defines a NRO for XFradioGroup activities

2 class RadioNro : Nro

3 {

4 upon Create: string act, handle cli, string mtd, any cd init

5 {

6 {"Create", act, cli, mtd, cd} => Nro

7 }

8 {

9 }

10 on HandleActivity: list keys, list values

11 {

12 {mMethod,mClientData,{"Lookup","Selection", keys, values}

13 =>self}

14 => mClient;

15 }

16 };

17 // This class implements the one-of-many behavior that groups of

18 // XFradioButtons should follow

19 class XFradioGroup : ActivityManager

20 {

21 handle mCurrent = NULL;

22 // Define the activity StateChange

23 list ActivityInfo = { {"StateChange",{"Selection"}} };

24

25 on AddRadioButton : handle hRadio

26 {

27 if (hRadio->set)

28 {

29 if (mCurrent == NULL)

30 {

31 mCurrent = hRadio;

32 }

33 else

34 {

35 echo("\n***ERROR:***\n");

36 echo("The" & mCurrent->label &

37 "XFradioButton is already set\n");

38 echo("Can't have two set XFradioButtons in the same group\n");

39 die("Aborting..");

40 }

41 }

42 // Subscribe with the new added XFradioButton to be

43 // notified when its state changes

44 {"Subscribe", new {"Create","StateChange", self,"Selection",

45 hRadio} => Nro } => hRadio;

46 }

47 on Selection : handle hRadio, list keys, list values

48 {

49 if (hRadio->set)

50 {

51 if (mCurrent != NULL)

52 {

53 if (mCurrent != hRadio)

54 {

55 mCurrent->set = FALSE;

56 }

57 }

58 mCurrent = hRadio;

59 // Notify all dependents that the group state has changed

60 {"TriggerNotification", "StateChange", {hRadio}} => self;

61 }

62 }

63 };

64 anonymous : XFtop

65 {

66 anonymous : XFlayout {

67 // Create group of XFradioButtons to handle a one-of-many behavior

68

69 XFradioGroup mGroupBox;

70

71 XFlabel BaudRateLabel

72 {

73 x=5; y=10; recomputeSize=FALSE; alignment="left"; width=160;

74 label="Baud Rate"; fontRequest={"Helvtica",14,{"bold"},"roman"};

75 };

76 // Create different XFradioButtons

77 XFradioButton baudRate1

78 {

79 recomputeSize = FALSE; x = 10; y = 30; width = 100; height = 30;

80 label="1200"; fontRequest={"Helvetica", 12, {"bold"}, "roman"};

81 };

82 XFradioButton baudRate2

83 {

84 recomputeSize = FALSE; x = 10; y = 60; width = 100; height = 30;

85 label="2400"; fontRequest={"Helvetica", 12, {"bold"}, "roman"};

86 };

87 XFradioButton baudRate3

88 {

89 recomputeSize = FALSE; x = 10; y = 90; width = 100; height = 30;

90 label="4800"; fontRequest={"Helvetica", 12,{"bold"},"roman"};

91 };

92 XFradioButton baudRate4

93 {

94 recomputeSize = FALSE; x = 10; y = 120; width = 100; height = 30;

95 label="9600"; fontRequest={"Helvetica",12,{"bold"},"roman"};

96 };

97

98 // Create two XFcheckBoxes

99 XFcheckBox parity

100 {

101 recomputeSize=FALSE; set = !set; x = 160; y=30; width=150;

102 height = 30; label = "Check Parity";

103 fontRequest = {"Helvetica", 12, {"bold"}, "roman"};

104 };

105

106 XFcheckBox carrier

107 {

108 recomputeSize = FALSE; x = 160; y = 60; width = 150;

109 height = 30; label = "Detect Carrier";

110 fontRequest = {"Helvetica", 12, {"bold"}, "roman"};

111 };

112 RadioNro {"Create", "StateChange", self, "GroupChange", {}}=>

113 groupNro;

114 upon Construct

115 {

116 // Add XFradioButtons to the group

117 {"AddRadioButton", &baudRate1} => mGroupBox;

118 {"AddRadioButton", &baudRate2} => mGroupBox;

119 {"AddRadioButton", &baudRate3} => mGroupBox;

120 {"AddRadioButton", &baudRate4} => mGroupBox;

121 // Subscribe for any changes in the group's state

122 {"Subscribe", &groupNro} => mGroupBox;

123 }

124 on Init

125 {

126 if (mGroupBox.mCurrent != NULL)

127 {

128 echo(mGroupBox.mCurrent->label + "\n");

129 }

130 }

131 on GroupChange : any cdata, handle hRadio

132 {

133 // Print out the label of the selected XFradioButton

134 echo(hRadio->label + "\n");

135 }

136 } layout { x = 10; y = 10; width = 300; height = 155; };

137

138 XFbutton ExitButton

139 {

140 x = 110;

141 y = 175;

142 width = 100;

143 height = 60;

144 label = "Quit";

145 font=new{"Create","Helvetica", 18, {"bold"},"roman"}=> XFfont;

146 Pressed = {"Exit", theApp};

147 };

148 } top {height=250; width=320; title="Communications Settings";};

6.2.17 XFselectList

The XFselectList class represents a widget that allows selection from a list of different choices. XFselectList displays a single column of text items or choices that can be selected in a variety of ways, using both the mouse and the keyboard.

Superclasses

Section 6.2.11, "XFfontable - Abstract" page 138

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

on AddItem: string anItem

Appends an item to the end of the list.

on InsertItem: string anItem, integer aPosition

Inserts an item at the specified position.

on GetItemPos: string anItem return integer

Returns the position of the first ocurrence of the specified item in the list. If the item is not in the list, the method returns 0 (zero).

on GetItemCount: return integer

Returns the number of items in the list.

on GetSelectedCount: return integer

Returns the number of selected items in the list.

on GetSelectedItems: return list

Returns a list of strings containing all selected items in the list. It returns an empty list if no items are selected.

on GetSelectedPos: return list

Returns a list of integers containing the positions of all selected items in the list. It returns an empty list if no items are selected.

on IsPosSelected: integer aPosition return boolean

Determines if the item at the specified position is selected. Returns TRUE if the item is selected, FALSE otherwise.

on SelectAtPos: list thePositions

Selects and highlights the items at the specified positions in the list.

on DeselectAtPos: integer aPosition

Deselects and unhighlights the item at the specified position in the list.

on RemoveItem: string anItem

Removes the first ocurrence of the specified item from the list.

on RemoveAllItems

Removes all items from the list.

on RemoveAtPos: integer aPosition

Removes the item at the specified position from the list.

Attributes
XFselectList members
AttributeTypeDescriptionDefaultAccess
selectionModestringThe mode in which the list should support selections. Possible values are: "single" and "multiple"."single"CGS
itemslistthe list of choices{}CGS

Activities
XFselectList activities
ActivityKeysDescription
SelectionnoneItem selected. This activity is also reported when an item is deselected in a multiple selection list.
ListActionstring item, integer itemPositionAction initiated on an item. This usually happens when the user double-clicks on an item or presses return or enter when an item is selected.

Example

The following code illustrates the use of XFselectList objects

1 anonymous : XFtop

2 {

3 XFbutton deleteButton

4 {

5 x = 285; y = 75; width = 100; height = 60;

6 label = "Delete"; background = "steelBlue";

7 fontRequest = {"Helvetica", 18, {"bold"}, "roman"};

8

9 XFbutton clearButton

10 {

11 x = 285; y = 195; width = 100; height = 60;

12 label = "Clear"; background = "steelBlue";

13 fontRequest = {"Helvetica", 18, {"bold"}, "roman"};

14 };

15

16 XFbutton exitButton

17 {

18 x = 285; y = 315; width = 100; height = 60;

19 label = "Quit"; background = "steelBlue";

20 fontRequest = {"Helvetica", 18, {"bold"}, "roman"};

21 };

22

23 XFlabel listTitle

24 {

25 x = 10; width = 250; height = 30;

26 label = "List of Items"; background = "steelBlue";

27 fontRequest = {"Helvetica", 14, {"bold", "italic"}, "roman"};

28 };

29

30 // Create a selectable list

31 XFselectList itemList

32 {

33 x = 10; y = 30; width = 250; height = 335; background = "grey";

34 fontRequest = {"Times", 12, {"bold"}, "roman"};

35 // Allow multiple selections

36 selectionMode = "multiple";

37 };

38

39 XFlabel textTitle

40 {

41 x = 10; y = 370; width = 250; height = 30;

42 label = "Add Item"; background = "steelBlue";

43 fontRequest = {"Helvetica", 14, {"bold"}, "roman"};

44 };

45

46 XFtextField addField

47 {

48 x = 10; y = 400; width = 250; height = 40; background = "grey";

49 fontRequest = {"Times", 14, {"bold"}, "roman"};

50 };

51

52 // Create a NRO for XFtextField's TextAccept activity

53 Nro {"Create", "TextAccepted", self, "Accept", {}} => AddNro;

54

55 upon Construct

56 {

57 exitButton.Pressed = {"Quit", self };

58 deleteButton.Pressed = {"Delete", self };

59 clearButton.Pressed = {"Clear", self };

60 // Subscribe for notification on XFtextField's TextAccept activity

61 {"Subscribe", &AddNro } => addField;

62 }

63

64 on Clear

65 {

66 // Clear the list

67 "RemoveAllItems" => itemList;

68 }

69

70 on Delete

71 {

72 // If there are any items selected, delete them

73 list selection = "GetSelectedItems" => itemList;

74 string item;

75 for item in selection

76 {

77 {"RemoveItem", item } => itemList;

78 }

79 }

80

81 on Accept : list clientData, list keys, list values

82 {

83 // If a text was entered in the textField, add it to the list of items

84 if (addField.text != "")

85 {

86 {"AddItem", addField.text } => itemList;

87 addField.text = "";

88 }

89 }

90

91 on Quit

92 {

93 "Exit" => theApp;

94 }

95

96 } topShell { width = 400; height = 450;

97 background = "steelBlue"; title = "Add List";};

6.2.18 XFtext

The XFtext class represents a multiple line text widget that allows text to be inserted, deleted, modified, and selected.

Superclasses

Section 6.2.11, "XFfontable - Abstract" page 138

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

on ScrollText: integer lines

If lines is positive it scrolls the text upward. If it is negative it scrolls the text downward.

Attributes
XFtext Attributes
AttributeTypeDescriptionDefaultAccess
textstringtext to be displayed" "CGS
cursorPositionintegerposition of cursor in text string0CGS
horizontalScrollBar

(only on UNIX)

booleandetermines whether the widget has a horizontal scrollBar or notTRUECGS
verticalScrollBar

(only on UNIX)

booleandetermines whether the widget has a vertical scrollBar or notTRUECGS
editablebooleandetermines whether the text is read-only or notTRUECGS
wordWrapbooleandetermines whether the widget should break lines automatically between words.FALSECGS

Activities
XFtext Activities
ActivityKeysDescription
TextChangenonetext in widget has been changed

Example

The following code illustrates the use of XFtext objects:

1 anonymous : XFtop

2 {

3 XFbutton ExitButton

4 {

5 x = 150;

6 y = 255;

7 width = 100;

8 height = 60;

9 label = "Quit";

10 fontRequest = {"Helvetica", 18, {"bold"}, "roman"}};

11 };

12

13 // Create an editable text widget

14 XFtext editor

15 {

16 y = 30;

17 width = 400;

18 height = 220;

19 background = "steelBlue";

20 // Break lines automatically

21 wordWrap = TRUE;

22 fontRequest = {"Times", 12, {"bold"}, "roman"};

23 };

24

25 XFlabel editorTitle

26 {

27 width = 400;

28 height = 30;

29 label = "Simple Text Editor";

30 background = "darkOrchid";

31 fontRequest = {"Helvetica", 14, {"bold", "italic"}, "roman"};

32 };

33

34 upon Construct

35 {

36 ExitButton.Pressed = {"Quit", self };

37 }

38

39 on Quit

40 {

41 "Exit" => theApp;

42 }

43

44 } topShell { width = 400; height = 320; title = "Text Editor";};

6.2.19 XFtextField

The XFtextField class represents a single-line text widget that allows text to be inserted, deleted, modified, and selected. As a single-line text editor, the XFtextField has a subset of the functionality of the XFtext widget.

Superclasses

Section 6.2.11, "XFfontable - Abstract" page 138

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

Attributes
XFtextField Attributes
AttributeTypeDescriptionDefaultAccess
textstringtext to be displayed" "CGS
cursorPositionintegerposition of cursor in text string0CGS
editablebooleandetermines whether the text is read-only or notTRUECGS

Activities
XFtextField Activities
ActivityKeysDescription
TextChangenonetext in widget has been changed
TextAcceptednonetext in widget has been accepted

Example

The following code illustrates the use of XFtextField objects

1 anonymous : XFtop

2 {

3 XFbutton ExitButton

4 {

5 x = 150;

6 y = 255;

7 width = 100;

8 height = 60;

9 label = "Quit";

10 font=new{"Create","Helvetica",18,{"bold"},"roman"}=> XFfont;

11 };

12

13 // Create the form with XFtextField and XFlabel objects

14

15 XFlabel nameLabel

16 {

17 x = 10; y = 10; width = 80; height = 30;

18 label = "Name :"; background = "steelBlue";

19 alignment = "language";

20 fontRequest = {"Helvetica", 14, {"bold"}, "roman"};

21 };

22

23 XFtextField name

24 {

25 x = 100; y = 10; width = 280; height = 40;

26 background = "steelBlue";

27 fontRequest = {"Times", 12, {"bold"}, "roman"};

28 };

29 XFlabel ssLabel

30 {

31 x = 10; y = 55; width = 200; height = 30;

32 label = "Social Security :";

33 alignment = "left";

34 background = "steelBlue";

35 fontRequest = {"Helvetica", 14, {"bold"}, "roman"};

36 };

37 XFtextField social

38 {

39 x = 220; y = 55; width = 160; height = 40;

40 background = "steelBlue";

41 fontRequest = {"Times", 12, {"bold"}, "roman"};

42 };

43 XFlabel emplName

44 {

45 x = 10; y = 100; width = 100; height = 30;

46 label = "Employer :"; background = "steelBlue";

47 alignment = "left";

48 fontRequest = {"Helvetica", 14, {"bold"}, "roman"};

49 };

50 XFtextField employer

51 {

52 x = 120; y = 100; width = 260; height = 40;

53 background = "steelBlue";

54 fontRequest = {"Times", 12, {"bold"}, "roman"};

55 };

56 XFlabel addName

57 {

58 x = 10; y = 145; width = 200; height = 30;

59 label = "Address :";

60 background = "steelBlue";

61 alignment = "left";

62 fontRequest = {"Helvetica", 14, {"bold"}, "roman"};

63 };

64 XFtext address

65 {

66 x = 120; y = 145; width = 260; height = 80;

67 background = "steelBlue";

68 fontRequest = {"Times", 12, {"bold"}, "roman"};

69 };

70 upon Construct

71 {

72 ExitButton.Pressed = {"Quit", self };

73 }

74 on Quit

75 {

76 "Exit" => theApp;

77 }

78 } topShell { width = 400; height = 320; background = "steelBlue";

79 title = "Form";};

6.2.20 XFscrollBar

The class XFscrollBar provides a widget to control the scrolling of the viewing area in other widgets. It allows users to view data that are too large to be displayed all at once, and is usually adjacent to the widget that contains the data for viewing.

Superclasses

Section 6.2.10, "XFsimple - Abstract" page 138

Methods

upon Construct

Default constructor.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

Attributes
XFscrollBar Attributes
AttributeTypeDescriptionDefaultAccess
minimumintegerthe minimum value of the slider0CGS
maximumintegerthe maximum value of the slider100CGS
positionintegerthe slider's position0CGS
incrementinteger amount the position changes due to the user's moving the thumb1 increment1CGS
pageIncrementintegeramount the position changes due to user's moving thumb 1 page increment.10CGS
orientationstringdirection the scrollbar is displayed. Values are "vertical" and "horizontal"."vertical"CG

Activities
XFscrollBar Activities
ActivityKeysDescription
Incrementinteger positionThumb's position incremented by one.
DecrementsameThumb's position decremented by one.
PageIncrementsameThumb's position incremented by one page.
PageDecrementsameThumb's position decremented by one page.
ThumbTracksameThe position of the thumb changes while being dragged.
ThumbPositionsameThumb has changed position.

Example

1 uses "nro.adl"@"StdLib";

2 class colorLabel: XFlabel

3 {

4 upon Create: string bg

5 {background=bg; label=bg; x=0; y=0 width=80; height=50;}

6 };

7 class Sequence : XFlayout

8 {

9 colorLabel {"Create", "darkOrchid"} => purple { x = 0; };

10 colorLabel {"Create", "lightBlue"} => lightBlue { x = 80; };

11 colorLabel {"Create", "plum"} => plum { x = 160;};

12 colorLabel {"Create", "orange"} => orange { x = 240;};

13 colorLabel {"Create", "red"} => red { x = 320;};

14 colorLabel {"Create", "yellow"} => yellow { x = 400;};

15 colorLabel {"Create", "green"} => green { x = 480;};

16 colorLabel {"Create", "royalBlue"} => royalBlue { x = 560;};

17 list colors={"darkOrchid","lightBlue","plum","orange",

18 "red","yellow","green","royalBlue"};

19 };

20 anonymous: XFtop

21 {

22 Sequence samples { x = 30; y = 195; width = 640; height = 50; };

23 // Create a horizontal scrollbar that acts as a slider

24 XFscrollBar slider

25 {

26 orientation = "horizontal";

27 x = 30; y = 245; width = 640; height = 30;

28 //Set the scroll range

29 minimum = 1; maximum = 8;

30 };

31 // Create a notification request object to subscribe for

32 // the XFscrollBar's ThumbPosition activity

33 vanillaNro {"Create","ThumbPosition",self,"ChangeColor", {}}

34 => colorNro;

35 XFlabel colorSample

36 {

37 label = ""; x = 60; y = 30; width = 580; height = 120;

38 borderWidth = 3;

39 };

40 XFbutton ExitButton

41 {

42 x = 300; y = 290; width = 100; height = 60;

43 label="Quit";

44 fontRequest={"Helvetica", 18, {"bold"}, "roman"};

45 };

46 on ChangeColor : list unused

47 {

48 // Whenever slider's thumb changes because of user input change

49 // labels background color to the appropriate color in sequence

50 colorSample.background = at(slider.position, samples.colors);

51 }

52 on Exit

53 {

54 "Exit" => theApp;

55 }

56 upon Construct

57 {

58 {"Subscribe", &colorNro } => slider;

59 // Initialize the color sample to the first in the sequence

60 {"ChangeColor", {}} => self;

61 ExitButton.Pressed = {"Exit", self };

62 }

63 } colors { width = 700; height = 360; title = "Color Sequence";};

6.2.21 XFmenuItem - Abstract

The class XFmenuItem is an abstract class that represents all the different kinds of items that can be placed in a menu such as XFmenuSeparators, XFmenuCommands, and XFmenus.

Superclasses

Section 6.1.2, "Activity Manager - Abstract" page 116

Section 6.1.3, "Attribute Manager - Abstract" page 118

Methods

None

Attributes

None

Activities

None

Example

For a sample program, see "XFmenu, XFmenuCommand, and XFmenuSeparator" ("XFmenuSeparator" page 162).

6.2.22 XFmenuLabeledItem - Abstract

The class XFmenuLabeledItem is an abstract class that represents labeled items that can be placed in a menu such as XFmenuCommands and XFmenus.

Superclasses

Section 6.2.21, "XFmenuItem - Abstract" page 159

Attributes
XFmenuLabeledItem Attributes
AttributeTypeDescriptionDefaultAccess
enabledbooleanDefines whether the menu item is enabled or notTRUECGS
labelstringtext to be displayed in the menu item label.Defined by subclassCGS
mnemonic

(only on UNIX)

stringDefines the key that can be used in conjunction with a modifier key to post a PullDownMenu. Platforms that support this attribute underline the character in the label string that matches the mnemonic. This attribute is ignored on the Mac platform" "CGS

6.2.23 XFmenu

The class XFmenu represents a logical menu that can be instantiated into a physical menu such as a menu bar, a pull-down menu or a pop-up menu, on demand. Applications typically create different menu systems by creating an instance (or instances) of this class and attaching them to other objects. For example, to create a menu bar, an application can create an XFmenu object (or objects) and attach it to an existing XFtop object.

Superclasses

Section 6.2.22, "XFmenuLabeledItem - Abstract" page 159

Methods

upon Construct

Default constructor.

upon ConstructTop

This constructor should be used when the XFmenu object to be created is the top-most menu.

upon Create: handle hContainer

Alternate constructor; hContainer is a handle to its container menu.

Attributes
XFmenu Attributes
AttributeTypeDescriptionDefaultAccess
tearOff

(only on UNIX)

booleanDefines whether the menu is a tear-off menu or not. This attribute works as a hint to the platforms that support this kind of menusFALSECGS

Activities

None

Example

For a sample program, see "XFmenu, XFmenuCommand, and XFmenuSeparator" ("XFmenuSeparator" page 162).

6.2.24 XFmenuCommand

The class XFmenuCommand represents menu items that initiate some command as they are selected.

Superclasses

Section 6.2.22, "XFmenuLabeledItem - Abstract" page 159

Methods

upon Construct

Default constructor.

upon Create: handle hContainer

Alternate constructor; hContainer is a handle to its container menu.

Attributes
XFmenuCommand Attributes
AttributeTypeDescriptionDefaultAccess
accelerator

(onlyon UNIX)

stringDefines the key that can be used in conjunction with the command key (Command or Ctrl) as a direct shortcut to invoke a menu item without popping up its menu pane. Platforms display a readable representation of this key sequence to the right of the item in the menu." "CGS

Activities

None

Example

For a sample program, see "XFmenu, XFmenuCommand, and XFmenuSeparator" ("XFmenuSeparator" page 162).

6.2.25 XFmenuSeparator

The class XFmenuSeparator represents a menu item that separates other items in a menu by drawing a horizontal line between them.

Superclasses

Section 6.2.21, "XFmenuItem - Abstract" page 159

Methods

None

Attributes

None

Activities

None

Example

1 // Create a subclass of XFmenu to include several menuItems

2 class XFtopMenu: XFmenu

3 {

4 upon Construct

5 init { "ConstructTop" => XFmenu }

6 {

7 }

8 };

9

10 anonymous: XFtop

11 {

12 // Create the logical menu structure

13 anonymous: XFtopMenu

14 {

15 anonymous: XFmenu

16 {

17 XFmenuCommand quit { label = "Quit"; accelerator = "Q"; };

18 } fileMenu { label = "File"; mnemonic = "F"; };

19 anonymous: XFmenu

20 {

21 XFmenuCommand add { label = "Add"; accelerator = "A"; };

22 XFmenuCommand reset { label = "Reset"; accelerator = "R"; };

23 XFmenuSeparator separator;

24 XFmenuCommand removeCmd { label="Remove"; accelerator="v"; };

25 } testMenu { label = "Test"; mnemonic = "T"; tearOff = TRUE;};

26 } mainMenu;

27

28 Nro {"Create","MenuCommand",self,"MenuCommand",{}}=> menuCmdNro;

29

30 on Init

31 {

32 // Attach the logical menu to an XFtop menuBar

33 menuBar = &mainMenu;

34 // Subscribe for any menuCommand in the physical XFtop's menu

35 {"Subscribe", &menuCmdNro} => self;

36 }

37

38 // This method gets called when a command is selected

39 on MenuCommand: any clientData, list keys, list values

40 {

41 string command = at(1,values);

42 // Call the command method

43 command ?=> self;

44 }

45

46 on Quit

47 {

48 "Exit" => theApp;

49 }

50

51 on Add

52 {

53 // Add was selected do something

54 echo("Add selected \n");

55 }

56

57 on Reset

58 {

59 // Reset was selected do something

60 echo("Reset selected \n");

61 }

62

63 on Remove

64 {

65 // Remove was selected do something

66 echo("Remove selected \n");

67 }

68

69 } top { width = 100; height = 100; };

6.2.26 XFfont

The XFfont class represent font objects that are commonly used with other XF classes such as XFlabel, XFtext and so on. This class provides constructors to create fonts from explicit information including the font name, size, style, and encoding.

Superclasses

None

Methods

upon Create: string fontName, integer size, list style, string encoding

FontName: the name of the font, such as 'helvetica, 'times, 'fixed, 'symbol, 'courier. Other generic font names are defined on the Macintosh platform and will soon be defined on the other platforms. These generic names are: "applicationFont", "textFont", "typewriterFont", and "systemFont". To ensure better font handling across the different platforms, system configurations, and languages, use of these generic names is recommended.

Size: size of the font.

Style: a list of types, which may contain any of: 'bold, 'italic, 'underline, 'underlineDouble, 'underlineDotted, 'superscript, 'subscript, 'outline, 'smallCaps.

Encoding: one of 'roman, 'japanese, 'arabic, 'hebrew, 'greek, 'symbol.

This special constructor creates a font object from the given information. AthenaMuse 2 attempts to find the best match for the font requested; the members described below can be examined to see exactly what font is being used.

Attributes
XFfont Attributes
AttributeTypeDescriptionDefaultAccess
fontNamestringcurrent font nameplatformG
sizeintegercurrent font sizeplatformG
stylelistlist of styles for current fontplatformG
encodingstringcurrent font encodingplatformG

Activities

None

Example

The following example shows several uses of the XFfont class.

1 uses "nro.adl"@"StdLib";

2

3 anonymous : XFtop

4 {

5 // Create different fonts to include in selection list

6 XFfont{"Create","Times",12,{},"roman"} => Times12;

7 XFfont{"Create","Times",14,{},"roman"} => Times14;

8 XFfont{"Create","Times",24,{},"roman"} => Times24;

9 XFfont{"Create","Times",14,{"bold"},"roman"} => TimesBold;

10 XFfont{"Create","Times",14,{"italic"},"roman"} => TimesItalic;

11 XFfont{"Create","Times",14,{"bold","italic"},"roman"}=>TimesBItalic;

12 XFfont{"Create","Helvetica", 12, {}, "roman"} => Helv12;

13 XFfont{"Create","Helvetica", 14, {}, "roman"} => Helv14;

14 XFfont{"Create","Helvetica", 24, {}, "roman"} => Helv24;

15 XFfont{"Create","Helvetica", 36, {}, "roman"} => Helv36;

16 XFfont{"Create","Helvetica", 14, {"bold"},"roman"} =>HelvBold;

17 XFfont{"Create","Helvetica", 14, {"italic"},"roman"}=>HelvItalic;

18 XFfont{"Create","Symbol",14,{}, "symbol"} => Symbol;

19

20 list fonts={&Times12, &Times14, &Times24, &TimesBold, &TimesItalic,

21 &TimesBItalic, &Helv12, &Helv14, &Helv24, &Helv36, &HelvBold,

22 &HelvItalic, &Symbol};

23

24 XFlabel fontSample

25 {

26 y = 230; width = 450; height = 100;

27 label = "The quick brown fox";

28 background = "steelBlue";

29 recomputeSize = FALSE;

30 };

31

32 XFselectList fontList

33 {

34 x = 75; y = 15;

35 width = 300;

36 height = 200;

37 items = {"Times 12", "Times 14", "Times 24", "Times Bold",

38 "Times Italic", "Times Bold & Italic",

39 "Helvetica 12","Helvetica 14","Helvetica 24","Helvetica 36",

40 "Helvetica Bold","Helvetica Italic", "Symbol font"};

41 // Setting the fontRequest attribute creates an XFfont object

42 // that is then assigned to the font attribute

43 fontRequest = {"Helvetica", 12, {"bold"}, "roman"};

44 };

45

46 XFbutton ExitButton

47 {

48 x = 175;

49 y = 355;

50 width = 100;

51 height = 60;

52 label = "Quit";

53 //Set the button's font to be Helvetica, 18 points, and bold.

54 //Create the font dynamically and then assign it to

55 //the font attribute which expects a font handle.

56 font=new {"Create", "Helvetica",18, {"bold"},"roman"}=>XFfont;

57 };

58

59 // Create a notification request object for the

60 // XFselectList's Selection activity

61 vanillaNro {"Create","Selection", self "ChangeFont",{}}=>FontNro;

62

63 upon Construct

64 {

65 ExitButton.Pressed = {"Quit", self };

66 {"Subscribe", &FontNro } => fontList;

67 }

68

69 on ChangeFont : list clientData

70 {

71 string item;

72 integer position = 1;

73 list selection = "GetSelectedItems" => fontList;

74 if (!isEmpty(selection))

75 {

76 position = {"GetItemPos", at(1,selection) } => fontList;

77 fontSample.font = at(position, fonts);

78 }

79 }

80

81 on Quit

82 {

83 echo("Quitting...\n");

84 "Exit" => theApp;

85 }

86

87 } topShell { width = 450; height = 450;

88 background = "steelBlue"; title = "Fonts";};

6.2.27 XGPainter

The XGpainter interface provides a simple set of operations and represents the necessary state to perform 2D drawing. Many of the methods described use lists as the representation for points with the idea that it can be used for both 2D and 3D graphics. For instance if we were to draw a line from (1,2) to (10,10) we would make a call similar to:

{"DrawLine", {1,2}, {10,10} } => myPainter;

Superclasses

Section 6.2.11, "XFfontable - Abstract" page 138

Methods

upon Construct

Default constructor. This should set the members into a useful default.

upon Create: handle hParent

Alternate constructor; hParent is a handle to its container widget.

on ClearDrawingArea

Clears (erases) the entire drawing area.

on DrawPoint: list point

Draws the given point with the current penWidth and color.

on DrawPoints: list points

Draws the given points with the current penWidth and color.

on DrawLine: list point1, list point2

Draws a line from point1 to point2 with the current penWidth and color.

on DrawPolyLine: list points

Draws a line segment from the first point to the second point, then from the second point to the third, and so on.

on DrawRectangle: list origin, integer width, integer height

Draws the outline of a rectangle with the current penWidth and color.

on FillRectangle: list origin, integer width, integer height

Fills the specified rectangle with the current color.

on DrawEllipse: list origin, integer width, integer height

Draws the outline of an ellipse specified by its bounding rectangle with the current penWidth and color.

on FillEllipse: list origin, integer width, integer height

Fills the ellipse specified by its bounding rectangle with the current color.

on DrawPolygon: list points

Draw the outline of the polygon specified by the list of points, using the current penWidth and color.

on FillPolygon: list points

Fills the specified polygon with the current color.

on DrawCircle: list center, integer radius

Draws the outline of the specified circle using the current penWidth and color.

on Fill Circle: list center, integer radius

Fills the specified circle of the given center and radius with the current color.

on DrawText: list startPos, string text

Draws the specified text starting at startPos using the current font.

Attributes
XGpainter Attributes
AttributeTypeDescriptionAccess
drawingAreahandlecurrent drawing area.

This is a handle to an XFvisual object.

CSG
penWidthintegercurrent width of the pen used to drawCSG
fontRequestlistfont requested to be used for text operationsCSG
fonthandlecurrent font used for text operationsCSG
colorhandleThis is the current color to be used in graphic operations. This is a handle to an MMcolor object. Specifies the raster operation or logical function to be used. Logical functions control how the source pixel values generated by a graphics request are combined with the destination pixel values already present on the screen. These operations are: copy, and, or, and xor.CSG

Activities

None

Example

This example using the XGpainter creates a class called Polygon. The anonymous instance derived from XFtop after the Polygon class definition then uses the Polygon class to create a filled square (in black) and a unfilled triangle in yellow.

1 XGpainter painter;

2

3 // Class for a Polygon

4 class Polygon

5 {

6 global XGpainter painter;

7

8 list points = {}; //list of vertices in form { {x1,y1}, {x2,y2} ...}

9 integer lineWidth=1; // width of drawing line

10 handle colorHandle; // handle to MMcolor object

11 string drawColor='black; // default color

12 handle drawParent; // parent widget to draw on

13 boolean fill=FALSE; // indicator for filled Polygon

14

15 // Constructor has parent widget for Polygon as argument

16 upon Construct: handle p

17 {

18 drawParent = p;

19 colorHandle= new {'CreateName, drawColor} => MMcolor;

20

21 }

22

23 // Destructor deletes the allocated MMcolor object

24 on Destroy

25 {

26 delete colorHandle;

27 }

28

29 // Method to reset the drawing color

30 on Set_drawColor: string color

31 {

32 delete colorHandle;

33 drawColor=color;

34 colorHandle = new {'CreateName, drawColor} => MMcolor;

35 painter.color = colorHandle;

36 }

37

38 // Method that draws the Polygon

39 on Draw

40 {

41

42 list fullPoints = points;

43

44 painter.drawingArea = drawParent;

45 painter.penWidth = lineWidth;

46 painter.color = colorHandle;

47

48 if(fill) {

49 {'FillPolygon, points} => painter;

50 }

51 else {

52 fullPoints << first(points);

53 {'DrawPolygon, fullPoints} => painter;

54 }

55 }

56

57 }; /* end of class Polygon */

58

59 // Anonymous instance derived from XFtop that uses Polygon class

60 anonymous:XFtop {

61

62 XFvisual vis {x=30; y=30; height=200; width=400;};

63 // drawing surface

64 Polygon {'Construct, &vis} => triangle

65 {points={{100,100}, {100,200}, {200,100}};

66 drawColor='Green; lineWidth=4;};

67 Polygon {'Construct, &vis} => filledSquare

68 {points={{10,10}, {100,10}, {100,100}, {10,100}};

69 drawColor='Black; fill=TRUE;};

70

71 XFbutton quitButton {x=250; y=30; label="Quit";};

72 // The following NRO is used to Subscribe for refresh events on XFvisual

73 Nro {'Create, 'Refresh, self, 'RedrawRefresh, NULL} => redrawNro;

74

75 upon Construct

76 {

77 {'Subscribe, &redrawNro} => vis;

78 quitButton.Pressed = {'Exit, theApp};

79 'Draw => filledSquare;

80 'Draw => triangle;

81 }

82 // This method handles refresh on the XFvisual by redrawing Polygons

83 on RedrawRefresh: any cd, list names, list vals

84 {

85 'Draw => filledSquare;

86 'Draw => triangle;

87 }

88

89 } myTop {x=100; y=100; height=300; width=500;};

Figure 6.5: - User Interface Wrapped Classes Inheritance Tree
6.2.1 - XFwidget - Abstract
Superclasses
Methods
Attributes
Activities
Example
6.2.2 - XFcontainable - Abstract
Superclasses
Methods
Attributes
Activities
Example
6.2.3 - XFcontainer - Abstract
Superclasses
Methods
Attributes
Activities
Example
6.2.4 - XFcontainableContainer - Abstract
Superclasses
Methods
Attributes
Activities
Example
6.2.5 - XFtop
Superclasses
Methods
Attributes
Activities
Example
6.2.6 - XFlayout
Superclasses
Methods
Attributes
Activities
Example
6.2.7 - XFvisual
Superclasses
Methods
Attributes
Activities
Example
6.2.8 - XFhtml
Superclasses
Methods
Attributes
Activities
Example
6.2.9 - XFmessageDlg
Superclasses
Methods
Attributes
Activities
Example
6.2.10 - XFsimple - Abstract
Superclasses
Methods
Attributes
Activities
Example
6.2.11 - XFfontable - Abstract
Superclasses
Attributes
Activities
6.2.12 - XFlabel
Superclasses
Methods
Attributes
Activities
Example
6.2.13 - XFbutton
Superclasses
Methods
Attributes
Activities
Example
6.2.14 - XFtoggleButton - Abstract
Superclasses
Methods
Attributes
Activities
Example
6.2.15 - XFcheckBox
Superclasses
Methods
Attributes
Activities
Example
6.2.16 - XFradioButton
Superclasses
Methods
Attributes
Activities
Example
6.2.17 - XFselectList
Superclasses
Methods
Attributes
Activities
Example
6.2.18 - XFtext
Superclasses
Methods
Attributes
Activities
Example
6.2.19 - XFtextField
Superclasses
Methods
Attributes
Activities
Example
6.2.20 - XFscrollBar
Superclasses
Methods
Attributes
Activities
Example
6.2.21 - XFmenuItem - Abstract
Superclasses
Methods
Attributes
Activities
Example
6.2.22 - XFmenuLabeledItem - Abstract
Superclasses
Attributes
6.2.23 - XFmenu
Superclasses
Methods
Attributes
Activities
Example
6.2.24 - XFmenuCommand
Superclasses
Methods
Attributes
Activities
Example
6.2.25 - XFmenuSeparator
Superclasses
Methods
Attributes
Activities
Example
6.2.26 - XFfont
Superclasses
Methods
Attributes
Activities
Example
6.2.27 - XGPainter
Superclasses
Methods
Attributes
Activities
Example

AM2 Documentation - 19 NOV 1996

Generated with Harlequin WebMaker