And the original interface already implemented an
independent backing mechanism, "shadowing", for updates
which is very didactic.
The file is in the webpage
http://eupt.unizar.es/asignaturas/ittse/programacion/Practica8.def
Enjoy.
Alejandro Rivero
And now I think of, perhaps you would like an example. Well
besides Gurney's "Solver" program, you could enjoy this one,
using both the minitoolkit and direct calls:
(**************************************************************************)
Program Test8;
#include "Practica8.def"
C_PROCEDURE(XGetInputFocus,'XGetInputFocus',
Display : IMMEDIATE DispPtr;
VAR Focus_return : IMMEDIATE Window;
VAR Revert_to_return : IMMEDIATE INTEGER );
C_PROCEDURE(XSetInputFocus,'XSetInputFocus',
Display : IMMEDIATE DispPtr;
Focus : IMMEDIATE Window;
Revert : IMMEDIATE INTEGER;
time : IMMEDIATE LONG );
(*Bring to front ya esta definida*)
VAR
origfocus : Window; OrigFocusMode:integer;
ventana : WinRec;
ventana2 : WinRec;
a : string;
f1,f2,f3 : PTR;
x,y,lastx,lasty : integer;
BEGIN
StartDisplay;
XGetInputFocus(sysinf.dpy,origfocus,origfocusmode);{hope to get our tty window}
LoadFont("BANNERFONT",f1);
LoadFont("TITLEFONT",f2);
LoadFont("DEFAULTFONT",f3);
OpenWindow(ventana,100,100,400,400);
OpenWindow(ventana2,400,100,400,400);
XRaiseWindow(sysinf.dpy,origfocus); {raise tty window again...}
XSetInputFocus(sysinf.dpy,origfocus,origfocusmode,0); {...and set its focus}
SetFont(ventana,f1);
OutTextXY(ventana,200,100,"para terminar");
SetFont(ventana,f2);
OutTextXY(ventana,200,150,"pulsa cualquier tecla");
SetFont(ventana,f3);
OutTextXY(ventana,200,200,"sobre esta ventana");
FlushDisplay;
SetColor(ventana,GetColorID("rgb:00/ff/00"));;
Point(ventana,20,20);
SetColor(ventana,GetColorID("rgb:00/ff/ff"));;
FillRectangle(ventana,30,30,40,70);
SetColor(ventana,GetColorID("rgb:ff/00/00"));;
Line(ventana,40,70,150,180);
while not keypressed(ventana) do
BEGIN
ReadMousePress(ventana,x,y);
writeln(x,':',y);
Line(ventana2,lastx,lasty,x,y);
Point(ventana,x,y);
lastx:=x;
lasty:=y;
Repeat
If damaged(ventana) then
copyfromshadow(ventana);
If damaged(ventana2) then
copyfromshadow(ventana2);
until ( keypressed(ventana) OR Mousepressed(ventana)) ;
END;
CloseWindow(ventana);
CloseWindow(ventana2);
CloseDisplay;
END.