18.10.2014 Views

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

314 A Text user <strong>in</strong>terface<br />

A dialog w<strong>in</strong>dow is <strong>in</strong>herited from a W<strong>in</strong>dow and as well as all the API calls of a W<strong>in</strong>dow has the follow<strong>in</strong>g<br />

additional API call:<br />

Note Function / procedure<br />

1 procedure Framework ( The:<strong>in</strong> out Dialog;<br />

Abs_X, Abs_Y:<strong>in</strong> Positive;<br />

Max_X: <strong>in</strong> Positive;<br />

Name:<strong>in</strong> Str<strong>in</strong>g; Cb:<strong>in</strong> P_Cbf );<br />

Note:<br />

1 Sets the absolute position of the w<strong>in</strong>dow on the screen. The size of the w<strong>in</strong>dow is set with max_x. The<br />

call-back function cb will be called after the user has constructed a message <strong>in</strong> the dialog box . This is<br />

<strong>in</strong>itiated by the user enter<strong>in</strong>g the Enter character (return key). When the Enter character is received<br />

the Dialog w<strong>in</strong>dow calls the call-back function with a str<strong>in</strong>g parameter conta<strong>in</strong><strong>in</strong>g the user’s entered<br />

text. The signature of the call-back function is:<br />

function Cb(Mes:<strong>in</strong> Str<strong>in</strong>g) return Str<strong>in</strong>g<br />

where mes is the message typed by the user.<br />

22.2.4 User <strong>in</strong>teraction with the TUI<br />

A user of an application program that is built us<strong>in</strong>g the TUI API has the follow<strong>in</strong>g switch characters def<strong>in</strong>ed:<br />

Switch character<br />

TAB<br />

ESC<br />

^E<br />

Description<br />

Swaps the focus for user <strong>in</strong>put to another w<strong>in</strong>dow on<br />

the VDU screen. The active w<strong>in</strong>dow is <strong>in</strong>dicated by a #<br />

<strong>in</strong> the top left hand corner.<br />

Activates the menu system.<br />

The menu system is described <strong>in</strong> detail <strong>in</strong> Section 22.4.<br />

Term<strong>in</strong>ates the TUI session. All w<strong>in</strong>dows will be closed<br />

and the user returned to the environment which <strong>in</strong>itiated<br />

the program.<br />

A switch character is used to activate a specific w<strong>in</strong>dow on the system or cause a global effect.<br />

22.2.5 Classes used<br />

The TUI API is conta<strong>in</strong>ed <strong>in</strong> the follow<strong>in</strong>g classes:<br />

API for Conta<strong>in</strong>ed <strong>in</strong> the package Notes<br />

A w<strong>in</strong>dow Class_W<strong>in</strong>dow -<br />

A dialog box Class_Dialog Plus the API <strong>in</strong>herited from a<br />

W<strong>in</strong>dow.<br />

A Menu bar Class_Menu Plus the API <strong>in</strong>herited from a<br />

W<strong>in</strong>dow.<br />

A Menu Title Class_Menu_Title Plus the API <strong>in</strong>herited from a<br />

Menu<br />

The TUI set up Class_Input_Manager Controls the <strong>in</strong>put sent to the<br />

TUI.<br />

22.3 An example program us<strong>in</strong>g the TUI<br />

A short program to illustrate the use of many of the API calls is shown below. This example program converts a<br />

distance <strong>in</strong> miles entered by the user <strong>in</strong>to kilometres. The package Pack_Program conta<strong>in</strong>s the procedure Ma<strong>in</strong><br />

that implements this program.<br />

© M A Smith - May not be reproduced without permission

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!