Next: , Previous: , Up: Classes   [Index]


ANSIYesNoBoxPane

ANSIYesNoBoxPane Class

An ANSIYesNoBoxPane object presents the user with a dialog that contains a text message and waits for the user’s ‘Yes’ or ‘No’ response.

Here is an example of opening an ANSIYesNoBoxPane object using standard input and output (e.g., when displaying the pane on a xterm).

int main () {
  ANSIYesNoBoxPane new messageBox;
  String new answer;

  messageBox withText "Do you want to quit?";
  answer = messageBox show 10, 10;
  messageBox cleanup;
  printf ("You answered, \"%s\"\n", answer);
}

Here is an example of opening an ANSIYesNoBoxPane object in a serial terminal (for a Linux serial device). For other systems, change the ‘/dev/ttyS1’ argument to the device node that connects to the serial terminal. It’s necessary to adjust the arguments to setTty to match the terminal’s settings.

int main () {
  ANSIYesNoBoxPane new messageBox;
  String new answer;

  messageBox paneStream openOn "/dev/ttyS1";  /* Linux serial device. */
  messageBox paneStream setTty 9600, 1, 'n', 8;
 
  messageBox noBorder;  /* Not all terminals support line drawing characters. */

  messageBox withText "Are you sure you want to quit?";
  answer = messageBox show 10, 10;
  messageBox cleanup;
  printf ("You answered, \"%s\"\n", answer);
}

As with any dialog widget, pressing Esc or Return closes the ANSIYesNoBoxPane object. The Tab key selects between the “Yes” and “No” buttons, as do the Y and N keys,

Instance Variables

button1

The ANSIButtonPane widget that controls the ‘Yes’ response.

button2

The ANSIButtonPane widget that controls the ‘No’ response. (ANSIYesNoBoxPane class)

messageText

A String object that contains the text displayed in the pane.

Instance Methods

cleanup (void)

Delete the widget’s data before exiting.

getFocusWidgetText (void)

Return the text associated with the button that has the input focus.

handleInput (void)

Wait for the user’s input and return the response from the widget.

new (newPaneName

Create a new ANSIYesNoBox object with the name given as an argument. If the argument list contains more than one name, create ANSIYesNoBoxPane objects for each argument.


ANSIYesNoBoxPane new yesnobox1, yesnobox2;

nextFocus (void)

Set the input focus to the next button widget.

noBorder (void)
withBorder (void)

Set or unset the border for the main pane and the button labels. These methods are equivalent to the following expressions.


  /* To display borders. */
  yesnoBox border = 1;
  yesnoBox button1 border = 1;
  yesnoBox button2 border = 1;

  /* To hide the borders. */
  yesnoBox border = 0;
  yesnoBox button1 border = 0;
  yesnoBox button2 border = 0;

Note that not all terninals support line drawing characters.

noBorder (void)
withBorder (void)

Set or unset the shadow for the main pane and the buttons. The methods are a shortcut for these statements.


  /* To display shadows. */
  yesnoBox shadow = 1;
  yesnoBox button1 shadow = 1;
  yesnoBox button2 shadow = 1;

  /* To hide the shadows. */
  yesnoBox shadow = 0;
  yesnoBox button1 shadow = 0;
  yesnoBox button2 shadow = 0;

show (int x_origin, int y_origin)

Display the ANSIYesNoBoxPane object at x_origin, y_origin. If displayed over another pane, the origin is relative to the parent pane’s origin. If displayed independently, the origin is relative the the upper left-hand corner of the terminal.

withText (char *text)

Defines the text that is to appear within the pane. This method adjust’s the pane’s size to fit the text.


Next: , Previous: , Up: Classes   [Index]