1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| Program EX021A; Uses Objects, Views, App, Drivers, TextView, Menus;
{ EXEMPLE DE GESTION DE LA SOURIS SOUS TURBO VISION }
Type
Pw=^Tw;
Tw=Object(TWindow)
t: Text;
p: PTerminal;
Constructor Init;
Procedure HandleEvent(Var e:TEvent); Virtual;
End;
Ta=Object(TApplication)
Constructor Init;
Procedure InitStatusLine; Virtual;
End;
Constructor Tw.Init;
Var
r: TRect; hor, ver: PScrollBar;
Begin
Desktop^.GetExtent(r);
Inherited Init(r, 'Cliquez dans la fentre!', wnNoNumber);
r.Grow(-1, -1);
hor := StandardScrollBar(sbHorizontal Or sbHandleKeyboard);
ver := StandardScrollBar(sbVertical Or sbHandleKeyboard);
(*
Insert(h);
Insert(v);
*)
New(p,Init(r, hor, ver, 8192));
If Application^.ValidView(p)<>nil Then
Begin
AssignDevice(t,p);
Rewrite(t);
Insert(p);
End;
End;
Function IntToStr2(i: Integer): string; Var s: string;
Begin
Str(i, s); If i < 10 Then s := '0' + s; IntToStr2 := s;
End;
Procedure Tw.HandleEvent(Var e: TEvent);
Begin
If e.What And evMouseDown<>0 Then
Begin
If e.Buttons And mbLeftButton<>0 Then
Write(t,'bouton gauche')
Else
Write(t,'bouton droit ');
Writeln(t, ' (', IntToStr2(e.Where.X), ',', IntToStr2(e.Where.Y), ')');
End;
Inherited HandleEvent(e);
End;
Constructor Ta.Init;
Var
w: Pw;
Begin
Inherited Init;
New(w,Init);
If ValidView(w)<>nil then InsertWindow(w);
End;
Procedure Ta.InitStatusLine;
Var
r: TRect;
Begin
GetExtent(r);
r.a.y:=r.b.y-1;
StatusLine:=New(PStatusLine,Init(r,NewStatusDef(0,$FFFF,
NewStatusKey('~Alt+X~ pour quitter', kbAltX, cmQuit,
StdStatusKeys(nil)), nil)));
End;
Var
a: Ta;
Begin
a.Init;
a.Run;
a.Done;
End. |
Partager