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.

352 TUI the implementation<br />

23.8.1 Implementation of the class Menu<br />

The implementation of the class is:<br />

with Pack_Constants;<br />

use Pack_Constants;<br />

package body Class_Menu is<br />

The procedure Set_Up populates the displayed menu w<strong>in</strong>dow with the names of the menu items.<br />

procedure Set_Up( The:<strong>in</strong> out Menu;<br />

Active:<strong>in</strong> Positive ) is<br />

Me: Menu_Item;<br />

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

Create( The, 1, 1, (1+Max_Menu)*Active+1, 3 );<br />

for I <strong>in</strong> 1 .. Active loop --Display menu names<br />

Get_Menu_Name( The, I, Me );<br />

Put( The, Me ); Put( The, "|" );<br />

null;<br />

end loop;<br />

Menu_Spot( The, C_Cursor ); --Mark current<br />

end Set_Up;<br />

In the procedure Framework the class type is described as Menu'Class. This is so that a run-time dispatch<br />

will be performed on <strong>in</strong>herited procedures or functions <strong>in</strong> any class derived from this class.<br />

procedure Framework( The:<strong>in</strong> out Menu'Class;<br />

M1:<strong>in</strong> Str<strong>in</strong>g:=""; W1:<strong>in</strong> P_Menu:=null; Cb1:<strong>in</strong> P_Cbf:=null;<br />

M2:<strong>in</strong> Str<strong>in</strong>g:=""; W2:<strong>in</strong> P_Menu:=null; Cb2:<strong>in</strong> P_Cbf:=null;<br />

M3:<strong>in</strong> Str<strong>in</strong>g:=""; W3:<strong>in</strong> P_Menu:=null; Cb3:<strong>in</strong> P_Cbf:=null;<br />

M4:<strong>in</strong> Str<strong>in</strong>g:=""; W4:<strong>in</strong> P_Menu:=null; Cb4:<strong>in</strong> P_Cbf:=null;<br />

M5:<strong>in</strong> Str<strong>in</strong>g:=""; W5:<strong>in</strong> P_Menu:=null; Cb5:<strong>in</strong> P_Cbf:=null;<br />

M6:<strong>in</strong> Str<strong>in</strong>g:=""; W6:<strong>in</strong> P_Menu:=null; Cb6:<strong>in</strong> P_Cbf:=null<br />

) is<br />

Spaces : Menu_Item := ( others => ' ' );<br />

Active : Menus_Index := 1;<br />

procedure Set_Up( Mi:<strong>in</strong> Str<strong>in</strong>g; Wi:<strong>in</strong> P_Menu;<br />

Cb:<strong>in</strong> P_Cbf; N:<strong>in</strong> Menus_Index ) is<br />

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

if Mi /= "" then Active := N; end if; --A menu item<br />

The.Menu_Set( N ) :=<br />

(" "&Mi&Spaces(1 .. Max_Menu-1-Mi'Length), Wi, Cb);<br />

end Set_Up;<br />

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

Set_Up( M1, W1, Cb1, 1 ); Set_Up( M2, W2, Cb2, 2 );<br />

Set_Up( M3, W3, Cb3, 3 ); Set_Up( M4, W4, Cb4, 4 );<br />

Set_Up( M5, W5, Cb5, 5 ); Set_Up( M6, W6, Cb6, 6 );<br />

The.Number := Active;<br />

Set_Up( The, Positive(Active) );<br />

end Framework;<br />

Note: The procedure set_up which is called from with<strong>in</strong> framework constructs the <strong>in</strong>ternal<br />

representation for the w<strong>in</strong>dow.<br />

The procedure menu_spot highlights the menu item selected.<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!