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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

22.2 API for TUI<br />

The API (Application Program Interface) for the TUI consists of a set of function and procedure calls. These are<br />

implemented as methods <strong>in</strong> the classes used to form the complete TUI <strong>in</strong>terface. These w<strong>in</strong>dow classes form an<br />

<strong>in</strong>heritance hierarchy illustrated <strong>in</strong> Figure 22.1.<br />

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

Menu<br />

Dialog<br />

Title_Menu<br />

Figure 22.1 W<strong>in</strong>dow hierarchy.<br />

The API calls for a W<strong>in</strong>dow are <strong>in</strong>herited to form the base API calls for a Menu and Dialog. Likewise, the<br />

base API calls for a Title_Menu are <strong>in</strong>herited from a Menu.<br />

22.2.1 To set up and close down the TUI<br />

The follow<strong>in</strong>g procedures are responsible for sett<strong>in</strong>g up and clos<strong>in</strong>g down the TUI system. These API calls are<br />

<strong>in</strong>dependent of any w<strong>in</strong>dow and thus do not require as a parameter an actual <strong>in</strong>stance of a w<strong>in</strong>dow. These methods<br />

are class methods of the class Input_manager.<br />

function / procedure<br />

W<strong>in</strong>dow_Prolog;<br />

W<strong>in</strong>dow_Start;<br />

W<strong>in</strong>dow_Epilog;<br />

Note<br />

Set up the environment for the TUI. This must be called<br />

outside the block <strong>in</strong> which w<strong>in</strong>dows are elaborated.<br />

After <strong>in</strong>itializ<strong>in</strong>g any program-generated w<strong>in</strong>dows, start the<br />

application by allow<strong>in</strong>g a user to <strong>in</strong>teract with the program.<br />

Close down the w<strong>in</strong>dow system. This must be called<br />

outside the block <strong>in</strong> which the w<strong>in</strong>dows are elaborated.<br />

For example, the structure of a program us<strong>in</strong>g the TUI is:<br />

procedure Ma<strong>in</strong> is<br />

beg<strong>in</strong><br />

W<strong>in</strong>dow_Prologue;<br />

declare<br />

beg<strong>in</strong><br />

W<strong>in</strong>dow_Start;<br />

end;<br />

W<strong>in</strong>dow_Epilog;<br />

end Ma<strong>in</strong>;<br />

-- Set-up w<strong>in</strong>dow system<br />

-- Declaration of w<strong>in</strong>dows used <strong>in</strong><br />

-- the program<br />

-- Initialization of w<strong>in</strong>dows<br />

-- used <strong>in</strong> program<br />

-- Start the user <strong>in</strong>teraction<br />

-- Close w<strong>in</strong>dow system<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!