Subversion Repositories Kolibri OS

Rev

Rev 6613 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. MODULE Dialogs;
  2.  
  3. IMPORT KOSAPI, sys := SYSTEM, OpenDlg, ColorDlg;
  4.  
  5. VAR header: ARRAY 1024 OF CHAR; back_color: INTEGER;
  6.  
  7. PROCEDURE WindowRedrawStatus(p: INTEGER);
  8. BEGIN
  9.   KOSAPI.sysfunc2(12, p)
  10. END WindowRedrawStatus;
  11.  
  12. PROCEDURE DefineAndDrawWindow(x, y, w, h, color, style, hcolor, hstyle, htext: INTEGER);
  13. BEGIN
  14.   KOSAPI.sysfunc6(0, x * 65536 + w, y * 65536 + h, color + LSL(style, 24), hcolor + LSL(hstyle, 24), htext)
  15. END DefineAndDrawWindow;
  16.  
  17. PROCEDURE WaitForEvent(): INTEGER;
  18.   RETURN KOSAPI.sysfunc1(10)
  19. END WaitForEvent;
  20.  
  21. PROCEDURE ExitApp;
  22. BEGIN
  23.   KOSAPI.sysfunc1(-1)
  24. END ExitApp;
  25.  
  26. PROCEDURE pause(t: INTEGER);
  27. BEGIN
  28.   KOSAPI.sysfunc2(5, t)
  29. END pause;
  30.  
  31. PROCEDURE Buttons;
  32.  
  33.   PROCEDURE Button(id, X, Y, W, H: INTEGER; Caption: ARRAY OF CHAR);
  34.   VAR n, aux: INTEGER;
  35.   BEGIN
  36.     n := LENGTH(Caption);
  37.     aux := KOSAPI.sysfunc5(8, X * 65536 + W, Y * 65536 + H, id, 00C0C0C0H);
  38.     X := X + (W - 8 * n) DIV 2;
  39.     Y := Y + (H - 14) DIV 2;
  40.     aux := KOSAPI.sysfunc6(4, X * 65536 + Y, LSL(48, 24), sys.ADR(Caption[0]), n, 0)
  41.   END Button;
  42.  
  43. BEGIN
  44.   Button(17,  5, 5, 70, 25, "open");
  45.   Button(18, 85, 5, 70, 25, "color");
  46. END Buttons;
  47.  
  48. PROCEDURE draw_window;
  49. BEGIN
  50.   WindowRedrawStatus(1);
  51.   DefineAndDrawWindow(200, 200, 500, 100, back_color, 51, 0, 0, sys.ADR(header[0]));
  52.   Buttons;
  53.   WindowRedrawStatus(2);
  54. END draw_window;
  55.  
  56. PROCEDURE OpenFile(Open: OpenDlg.Dialog);
  57. BEGIN
  58.   IF Open # NIL THEN
  59.     OpenDlg.Show(Open, 500, 450);
  60.     WHILE Open.status = 2 DO
  61.       pause(30)
  62.     END;
  63.     IF Open.status = 1 THEN
  64.       COPY(Open.FilePath, header)
  65.     END
  66.   END
  67. END OpenFile;
  68.  
  69. PROCEDURE SelColor(Color: ColorDlg.Dialog);
  70. BEGIN
  71.   IF Color # NIL THEN
  72.     ColorDlg.Show(Color);
  73.     WHILE Color.status = 2 DO
  74.       pause(30)
  75.     END;
  76.     IF Color.status = 1 THEN
  77.       back_color := Color.color
  78.     END
  79.   END
  80. END SelColor;
  81.  
  82. PROCEDURE main;
  83. VAR Open: OpenDlg.Dialog; Color: ColorDlg.Dialog; res, al: INTEGER;
  84. BEGIN
  85.   back_color := 00FFFFFFH;
  86.   header := "Dialogs";
  87.   draw_window;
  88.   Open := OpenDlg.Create(draw_window, 0, "/rd/1", "ASM|TXT|INI");
  89.   Color := ColorDlg.Create(draw_window);
  90.   WHILE TRUE DO
  91.     CASE WaitForEvent() OF
  92.     |1: draw_window
  93.     |3: res := KOSAPI.sysfunc1(17);
  94.         al := LSR(LSL(res, 24), 24);
  95.         res := LSR(res, 8);
  96.         IF al = 0 THEN
  97.           CASE res OF
  98.           | 1: ExitApp
  99.           |17: OpenFile(Open)
  100.           |18: SelColor(Color)
  101.           END
  102.         END
  103.     ELSE
  104.     END
  105.   END
  106. END main;
  107.  
  108. BEGIN
  109.   main
  110. END Dialogs.