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.

336 TUI the implementation<br />

Top<br />

Make the supplied w<strong>in</strong>dow the top w<strong>in</strong>dow. The<br />

top w<strong>in</strong>dow <strong>in</strong> the list is the focus for <strong>in</strong>put.<br />

F<strong>in</strong>d<br />

Search the controlled w<strong>in</strong>dows for a w<strong>in</strong>dow which<br />

has the supplied character as its switch character.<br />

Send_To_Top<br />

Send a character to the topmost w<strong>in</strong>dow<br />

Switch_To_Top<br />

Prepare the top w<strong>in</strong>dow as the focus of <strong>in</strong>put.<br />

Switch_Away_From_Top Prepare a w<strong>in</strong>dow to have the focus of <strong>in</strong>put<br />

removed from it.<br />

Write_To<br />

Write to supplied w<strong>in</strong>dow. Information has already<br />

been clipped to fit <strong>in</strong>to the w<strong>in</strong>dow.<br />

Hide_W<strong>in</strong><br />

Remove the w<strong>in</strong>dow from the screen.<br />

W<strong>in</strong>dow_Fatal<br />

Report a serious error <strong>in</strong> the TUI system.<br />

The <strong>Ada</strong> specification for this class is:<br />

with <strong>Ada</strong>.F<strong>in</strong>alization, Class_Root_W<strong>in</strong>dow;<br />

use <strong>Ada</strong>.F<strong>in</strong>alization, Class_Root_W<strong>in</strong>dow;<br />

package Class_W<strong>in</strong>dow_Control is<br />

type W<strong>in</strong>dow_Control is abstract tagged limited private;<br />

procedure Add_To_List(P_W:<strong>in</strong> P_Root_W<strong>in</strong>dow; Ch:<strong>in</strong> Character);<br />

procedure Remove_From_List( P_W:<strong>in</strong> P_Root_W<strong>in</strong>dow );<br />

procedure Top( P_W:<strong>in</strong> P_Root_W<strong>in</strong>dow );<br />

procedure F<strong>in</strong>d( P_W:out P_Root_W<strong>in</strong>dow; Ch:<strong>in</strong> Character );<br />

procedure Send_To_Top( Ch:<strong>in</strong> Character );<br />

procedure Switch_To_Top;<br />

procedure Switch_Away_From_Top;<br />

procedure Write_To( P_W:<strong>in</strong> P_Root_W<strong>in</strong>dow;<br />

X,Y:<strong>in</strong> Positive; Mes:<strong>in</strong> Str<strong>in</strong>g );<br />

procedure Hide_W<strong>in</strong>( P_W:<strong>in</strong> P_Root_W<strong>in</strong>dow );<br />

procedure W<strong>in</strong>dow_Fatal( Mes:<strong>in</strong> Str<strong>in</strong>g );<br />

private<br />

type W<strong>in</strong>dow_Control is<br />

abstract new Limited_Controlled with null record;<br />

Max_Items : constant := 10;<br />

type Active_W<strong>in</strong>dow is record --Active w<strong>in</strong>dow<br />

P_W : P_Root_W<strong>in</strong>dow; --W<strong>in</strong>dow<br />

A_Ch: Character;<br />

--Activate character<br />

end record;<br />

subtype W<strong>in</strong>dow_Index is Natural range 0 .. Max_Items;<br />

subtype W<strong>in</strong>dow_Range is W<strong>in</strong>dow_Index range 1 .. Max_Items;<br />

type W<strong>in</strong>dow_Array is array (W<strong>in</strong>dow_Range) of Active_W<strong>in</strong>dow;<br />

The_Last_W<strong>in</strong>: W<strong>in</strong>dow_Index := 0;<br />

The_W<strong>in</strong>dows : W<strong>in</strong>dow_Array;<br />

end Class_W<strong>in</strong>dow_Control;<br />

--Last active w<strong>in</strong>dow<br />

--All w<strong>in</strong>dows<br />

Note:<br />

As there is only one screen, the class W<strong>in</strong>dow_Control has all class methods.<br />

Associated with each w<strong>in</strong>dow is its switch character. When typed by a user this switch character activates the<br />

w<strong>in</strong>dow as the focus for <strong>in</strong>put.<br />

23.4.3 Implementation of the class Input_manager<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!