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.

350 TUI the implementation<br />

#--------------------+<br />

|Dialog| Miles |<br />

|--------------------|<br />

|* |<br />

+--------------------+<br />

User <strong>in</strong>put sent to the dialog w<strong>in</strong>dow is processed by the procedure send_to. This stores characters <strong>in</strong> the<br />

str<strong>in</strong>g Dialog_Mes. When the user enters C_ACTION this causes a call to an application programmer written<br />

call-back function with the str<strong>in</strong>g Dialog_Mes as its parameter. The character C_ACTION is the normal Enter<br />

character on the keyboard.<br />

procedure Send_To( The:<strong>in</strong> out Dialog; Ch:<strong>in</strong> Character ) is<br />

Spaces : Str<strong>in</strong>g(1 .. About(W<strong>in</strong>dow(The),Top)) := (others => ' ');<br />

Res : Str<strong>in</strong>g(1..0);<br />

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

case Ch is<br />

when C_Where =><br />

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

when C_Action =><br />

Res := Call_Call_Back( The,<br />

The.Dialog_Mes(1..The.Dialog_Pos-1) )(1..0);<br />

The.Dialog_Pos := 1;<br />

The.Dialog_Mes := ( others => ' ' );<br />

Position( The, 1, 3 ); --Start<br />

Put( The, C_Cursor & Spaces ); --Clear<br />

Position( The, 2, 3 ); --Cursor<br />

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

--Cursor<br />

when C_Del =><br />

if The.Dialog_Pos > 1 then --Can delete<br />

The.Dialog_Pos := The.Dialog_Pos - 1; --Make avail.<br />

The.Dialog_Mes(The.Dialog_Pos):= ' '; --Remove<br />

Position( The, The.Dialog_Pos, 3 );<br />

Put( The, C_Cursor & " " ); --Overwrite<br />

Position( The, The.Dialog_Pos, 3 );<br />

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

--Cursor<br />

end if;<br />

when others =><br />

if The.Dialog_Pos

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

Saved successfully!

Ooh no, something went wrong!