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.

344 TUI the implementation<br />

procedure Create( The:<strong>in</strong> out W<strong>in</strong>dow;<br />

Abs_X_Crd, Abs_Y_Crd: Positive;<br />

Max_X_Crd, Max_Y_Crd: Positive ) is<br />

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

if Max_X_Crd < 3 or else Max_X_Crd > W<strong>in</strong>dow_Max_X or else<br />

Max_Y_Crd < 3 or else Max_Y_Crd > W<strong>in</strong>dow_Max_Y or else<br />

Abs_X_Crd + Max_X_Crd - 1 > Vdt_Max_X or else<br />

Abs_Y_Crd + Max_Y_Crd - 1 > Vdt_Max_Y then<br />

W<strong>in</strong>dow_Fatal("Creation w<strong>in</strong>dow parameter error");<br />

end if;<br />

declare<br />

Top_Bottom: Str<strong>in</strong>g(1..Max_X_Crd) := (others => '-');<br />

Spaces : Str<strong>in</strong>g(2 .. Max_X_Crd-1) := (others => ' ');<br />

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

Top_Bottom(1) := '+'; Top_Bottom(Max_X_Crd) := '+';<br />

The.Max_X := Max_X_Crd - 2; --For border<br />

The.Max_Y := Max_Y_Crd - 2; --For border<br />

The.Abs_Y := Abs_Y_Crd; --Abs position screen<br />

The.Abs_X := Abs_X_Crd; --<br />

The.Pane(1)(1..Max_X_Crd) := Top_Bottom; --Clear / set up<br />

for Y <strong>in</strong> 2 .. Max_Y_Crd-1 loop<br />

The.Pane(Y)(1..Max_X_Crd):= '|'&Spaces&'|';<br />

end loop;<br />

The.Pane(Max_Y_Crd)(1..Max_X_Crd) := Top_Bottom;<br />

Position( The, 1, 1 );<br />

end;<br />

end Create;<br />

--Top left hand corner<br />

The user callable procedure framework def<strong>in</strong>es the position of the w<strong>in</strong>dow on the screen. This procedure<br />

uses create to do most of the <strong>in</strong>itialization of the w<strong>in</strong>dow.<br />

procedure Framework( The:<strong>in</strong> out W<strong>in</strong>dow;<br />

Abs_X_Crd, Abs_Y_Crd: Positive;<br />

Max_X_Crd, Max_Y_Crd: Positive;<br />

Cb:<strong>in</strong> P_Cbf := null ) is<br />

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

Create( The, Abs_X_Crd, Abs_Y_Crd, Max_X_Crd, Max_Y_Crd );<br />

Make_W<strong>in</strong>dow( The, Visible );<br />

if Cb /= null then<br />

Set_Call_Back( The, Cb );<br />

Register( The'Unchecked_Access, C_Switch );<br />

else<br />

Register( The'Unchecked_Access, C_No_Char );<br />

end if;<br />

end Framework;<br />

The call-back function is set by set_call_back and is called via call_call_back.<br />

procedure Set_Call_Back( The:<strong>in</strong> out W<strong>in</strong>dow; Cb:<strong>in</strong> P_Cbf ) is<br />

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

The.Call_Back := Cb;<br />

end Set_Call_Back;<br />

function Call_Call_Back( The:<strong>in</strong> W<strong>in</strong>dow;<br />

Str:<strong>in</strong> Str<strong>in</strong>g ) return Str<strong>in</strong>g is<br />

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

if The.Call_Back /= null then<br />

return The.Call_Back(Str);<br />

end if;<br />

return "No call back function";<br />

end;<br />

Note:<br />

The value returned by the call-back function is a str<strong>in</strong>g.<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!