2020-05-25 22:48:33 +02:00
|
|
|
MODULE Dialogs;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
IMPORT
|
|
|
|
KOSAPI, SYSTEM, OpenDlg, ColorDlg;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
CONST
|
|
|
|
btnNone = 0;
|
|
|
|
btnClose = 1;
|
|
|
|
btnOpen = 17;
|
|
|
|
btnColor = 18;
|
|
|
|
|
|
|
|
|
|
|
|
VAR
|
|
|
|
header: ARRAY 1024 OF CHAR;
|
|
|
|
back_color: INTEGER;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE BeginDraw;
|
|
|
|
BEGIN
|
|
|
|
KOSAPI.sysfunc2(12, 1)
|
|
|
|
END BeginDraw;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE EndDraw;
|
2016-10-24 01:30:27 +02:00
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
KOSAPI.sysfunc2(12, 2)
|
|
|
|
END EndDraw;
|
|
|
|
|
2016-10-24 01:30:27 +02:00
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
PROCEDURE DefineAndDrawWindow (left, top, width, height, color, style, hcolor, hstyle: INTEGER; header: ARRAY OF CHAR);
|
2016-10-24 01:30:27 +02:00
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
KOSAPI.sysfunc6(0, left*65536 + width, top*65536 + height, color + LSL(style, 24), hcolor + LSL(hstyle, 24), SYSTEM.ADR(header[0]))
|
2016-10-24 01:30:27 +02:00
|
|
|
END DefineAndDrawWindow;
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
|
|
|
|
PROCEDURE WaitForEvent (): INTEGER;
|
|
|
|
RETURN KOSAPI.sysfunc1(10)
|
2016-10-24 01:30:27 +02:00
|
|
|
END WaitForEvent;
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
|
2016-10-24 01:30:27 +02:00
|
|
|
PROCEDURE ExitApp;
|
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
KOSAPI.sysfunc1(-1)
|
2016-10-24 01:30:27 +02:00
|
|
|
END ExitApp;
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
|
|
|
|
PROCEDURE pause (t: INTEGER);
|
2016-10-24 01:30:27 +02:00
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
KOSAPI.sysfunc2(5, t)
|
2016-10-24 01:30:27 +02:00
|
|
|
END pause;
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
|
2016-10-24 01:30:27 +02:00
|
|
|
PROCEDURE Buttons;
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
PROCEDURE Button (id, X, Y, W, H: INTEGER; Caption: ARRAY OF CHAR);
|
|
|
|
VAR
|
|
|
|
n: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
n := LENGTH(Caption);
|
|
|
|
KOSAPI.sysfunc5(8, X*65536 + W, Y*65536 + H, id, 00C0C0C0H);
|
|
|
|
X := X + (W - 8*n) DIV 2;
|
|
|
|
Y := Y + (H - 14) DIV 2;
|
|
|
|
KOSAPI.sysfunc6(4, X*65536 + Y, LSL(48, 24), SYSTEM.ADR(Caption[0]), n, 0)
|
|
|
|
END Button;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
Button(btnOpen, 5, 5, 70, 25, "open");
|
|
|
|
Button(btnColor, 85, 5, 70, 25, "color");
|
2016-10-24 01:30:27 +02:00
|
|
|
END Buttons;
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
|
2016-10-24 01:30:27 +02:00
|
|
|
PROCEDURE draw_window;
|
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
BeginDraw;
|
|
|
|
DefineAndDrawWindow(200, 200, 500, 100, back_color, 51, 0, 0, header);
|
|
|
|
Buttons;
|
|
|
|
EndDraw;
|
2016-10-24 01:30:27 +02:00
|
|
|
END draw_window;
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
|
|
|
|
PROCEDURE OpenFile (Open: OpenDlg.Dialog);
|
2016-10-24 01:30:27 +02:00
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
IF Open # NIL THEN
|
|
|
|
OpenDlg.Show(Open, 500, 450);
|
|
|
|
WHILE Open.status = 2 DO
|
|
|
|
pause(30)
|
|
|
|
END;
|
|
|
|
IF Open.status = 1 THEN
|
|
|
|
COPY(Open.FilePath, header)
|
|
|
|
END
|
|
|
|
END
|
2016-10-24 01:30:27 +02:00
|
|
|
END OpenFile;
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
|
|
|
|
PROCEDURE SelColor (Color: ColorDlg.Dialog);
|
2016-10-24 01:30:27 +02:00
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
IF Color # NIL THEN
|
|
|
|
ColorDlg.Show(Color);
|
|
|
|
WHILE Color.status = 2 DO
|
|
|
|
pause(30)
|
|
|
|
END;
|
|
|
|
IF Color.status = 1 THEN
|
|
|
|
back_color := Color.color
|
|
|
|
END
|
|
|
|
END
|
2016-10-24 01:30:27 +02:00
|
|
|
END SelColor;
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
|
|
|
|
PROCEDURE GetButton (): INTEGER;
|
|
|
|
VAR
|
|
|
|
btn: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
btn := KOSAPI.sysfunc1(17);
|
|
|
|
IF btn MOD 256 = 0 THEN
|
|
|
|
btn := btn DIV 256
|
|
|
|
ELSE
|
|
|
|
btn := btnNone
|
|
|
|
END
|
|
|
|
RETURN btn
|
|
|
|
END GetButton;
|
|
|
|
|
|
|
|
|
2016-10-24 01:30:27 +02:00
|
|
|
PROCEDURE main;
|
2022-01-18 17:23:19 +01:00
|
|
|
CONST
|
|
|
|
EVENT_REDRAW = 1;
|
|
|
|
EVENT_KEY = 2;
|
|
|
|
EVENT_BUTTON = 3;
|
|
|
|
VAR
|
|
|
|
Open: OpenDlg.Dialog;
|
|
|
|
Color: ColorDlg.Dialog;
|
2016-10-24 01:30:27 +02:00
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
back_color := 00FFFFFFH;
|
|
|
|
header := "Dialogs";
|
|
|
|
Open := OpenDlg.Create(draw_window, 0, "/sys", "ASM|TXT|INI");
|
|
|
|
Color := ColorDlg.Create(draw_window);
|
|
|
|
|
|
|
|
WHILE TRUE DO
|
|
|
|
CASE WaitForEvent() OF
|
|
|
|
|EVENT_REDRAW:
|
|
|
|
draw_window
|
|
|
|
|
|
|
|
|EVENT_KEY:
|
|
|
|
|
|
|
|
|EVENT_BUTTON:
|
|
|
|
CASE GetButton() OF
|
|
|
|
|btnNone:
|
|
|
|
|btnClose: ExitApp
|
|
|
|
|btnOpen: OpenFile(Open)
|
|
|
|
|btnColor: SelColor(Color)
|
|
|
|
END
|
|
|
|
END
|
|
|
|
END
|
2016-10-24 01:30:27 +02:00
|
|
|
END main;
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
|
2016-10-24 01:30:27 +02:00
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
main
|
2020-05-25 22:48:33 +02:00
|
|
|
END Dialogs.
|