2023-07-12 09:00:08 +02:00
|
|
|
MODULE Desktop;
|
|
|
|
IMPORT OS;
|
|
|
|
|
|
|
|
VAR desktopRunning: CHAR;
|
|
|
|
desktopWindow: ARRAY 36 OF CHAR;
|
|
|
|
desktopIcons: ARRAY 5 OF Fox32OSButtonWidget;
|
|
|
|
|
2023-07-13 02:32:28 +02:00
|
|
|
EXTERN diskIcon: ARRAY 1024 OF INT;
|
|
|
|
|
2023-07-12 09:00:08 +02:00
|
|
|
PROCEDURE DesktopMain();
|
|
|
|
BEGIN
|
|
|
|
desktopRunning := 1;
|
|
|
|
|
|
|
|
(* set up the desktop icon widgets *)
|
|
|
|
SetupDesktopIconStructs();
|
|
|
|
|
2023-07-13 02:32:28 +02:00
|
|
|
(* create the window and make it fully transparent, mark it as "always background", and draw the icons to it *)
|
2023-07-12 09:00:08 +02:00
|
|
|
new_window(PTROF(desktopWindow), "Desktop", 640, 448, 0, 16, 0, PTROF(desktopIcons));
|
|
|
|
fill_overlay(000000000H, get_window_overlay_number(PTROF(desktopWindow)));
|
|
|
|
set_window_flags(000000001H, PTROF(desktopWindow));
|
2023-07-13 02:32:28 +02:00
|
|
|
DrawDesktopIcons(PTROF(desktopWindow));
|
2023-07-12 09:00:08 +02:00
|
|
|
|
|
|
|
WHILE desktopRunning DO
|
|
|
|
GetNextWindowEvent(PTROF(desktopWindow));
|
|
|
|
|
|
|
|
(* mouse click event *)
|
|
|
|
IF eventArgs[0] = PTROF(EVENT_TYPE_MOUSE_CLICK) THEN
|
|
|
|
handle_widget_click(PTROF(desktopWindow), eventArgs[1], eventArgs[2]);
|
|
|
|
|
2023-07-12 09:01:53 +02:00
|
|
|
(* button click event *)
|
2023-07-12 09:00:08 +02:00
|
|
|
ELSIF eventArgs[0] = PTROF(EVENT_TYPE_BUTTON_CLICK) THEN
|
|
|
|
HandleDesktopIconClick(eventArgs[1]);
|
|
|
|
END;
|
|
|
|
|
|
|
|
save_state_and_yield_task();
|
|
|
|
END;
|
|
|
|
END;
|
|
|
|
|
|
|
|
PROCEDURE HandleDesktopIconClick(buttonId: INT;);
|
2023-07-12 19:41:11 +02:00
|
|
|
VAR i, x, y, w, h: INT;
|
|
|
|
icon: POINTER TO Fox32OSButtonWidget;
|
2023-07-12 09:00:08 +02:00
|
|
|
BEGIN
|
2023-07-13 01:41:39 +02:00
|
|
|
(* draw the expanding box animation *)
|
2023-07-12 19:41:11 +02:00
|
|
|
i := 0;
|
|
|
|
icon := PTROF(desktopIcons[buttonId]);
|
2023-07-13 09:11:02 +02:00
|
|
|
WHILE i <| 16 DO
|
2023-07-13 01:41:39 +02:00
|
|
|
x := RSH(icon^.x *| (16 - i) + 64 *| i, 4);
|
|
|
|
y := RSH(icon^.y *| (16 - i) + 64 *| i, 4);
|
|
|
|
w := RSH(32 *| (16 - i) + 384 *| i, 4);
|
|
|
|
h := RSH(32 *| (16 - i) + 192 *| i, 4);
|
|
|
|
DrawWireframeBox(get_window_overlay_number(PTROF(desktopWindow)), x, y, w, h, 020F0F0F0H);
|
2023-07-13 09:11:02 +02:00
|
|
|
Eep(10);
|
2023-07-13 01:41:39 +02:00
|
|
|
draw_filled_rectangle_to_overlay(x, y, w, h, 0, get_window_overlay_number(PTROF(desktopWindow)));
|
2023-07-12 19:41:11 +02:00
|
|
|
i := i + 1;
|
|
|
|
END;
|
2023-07-13 01:41:39 +02:00
|
|
|
|
|
|
|
(* redraw the icons *)
|
2023-07-13 02:32:28 +02:00
|
|
|
DrawDesktopIcons(PTROF(desktopWindow));
|
2023-07-13 01:41:39 +02:00
|
|
|
|
|
|
|
(* launch a new instance of Fetcher *)
|
2023-07-12 19:41:11 +02:00
|
|
|
IF launch_fxf_from_disk("fetcher.fxf", get_boot_disk_id(), 0FFFFFFFFH, buttonId, icon^.x, icon^.y, PTROF(desktopWindow)) = 0FFFFFFFFH THEN
|
2023-07-12 09:00:08 +02:00
|
|
|
new_messagebox("Failed to start new", "instance of fetcher.fxf", 0, 64, 64, 200);
|
|
|
|
END;
|
|
|
|
END;
|
|
|
|
|
2023-07-13 02:32:28 +02:00
|
|
|
PROCEDURE DrawDesktopIcons(desktopWin: PTR;);
|
|
|
|
VAR i, y, overlay: INT;
|
|
|
|
BEGIN
|
|
|
|
IF desktopWin = 0 THEN RETURN(); END;
|
|
|
|
|
|
|
|
(* draw the buttons themselves *)
|
|
|
|
draw_widgets_to_window(desktopWin);
|
|
|
|
|
|
|
|
(* set the tilemap and draw the icons! *)
|
|
|
|
set_tilemap(PTROF(diskIcon), 32, 32);
|
|
|
|
overlay := get_window_overlay_number(desktopWin);
|
|
|
|
i := 5;
|
|
|
|
y := 16;
|
|
|
|
WHILE i DO
|
|
|
|
draw_tile_to_overlay(0, 592, y, overlay);
|
|
|
|
y := y + 64;
|
|
|
|
i := i - 1;
|
|
|
|
END;
|
|
|
|
END;
|
|
|
|
|
2023-07-12 09:00:08 +02:00
|
|
|
PROCEDURE SetupDesktopIconStructs();
|
|
|
|
VAR desktopIcon: POINTER TO Fox32OSButtonWidget;
|
|
|
|
prevDesktopIcon: POINTER TO Fox32OSButtonWidget;
|
|
|
|
BEGIN
|
|
|
|
desktopIcon := PTROF(desktopIcons[0]);
|
|
|
|
desktopIcon^.type := WIDGET_TYPE_BUTTON;
|
|
|
|
desktopIcon^.next := PTROF(desktopIcons[1]);
|
|
|
|
desktopIcon^.id := 0;
|
|
|
|
desktopIcon^.text := "Disk 0";
|
|
|
|
desktopIcon^.fgColor := 0FF000000H;
|
|
|
|
desktopIcon^.bgColor := 0FFFFFFFFH;
|
|
|
|
desktopIcon^.width := 32;
|
|
|
|
desktopIcon^.height := 32 + 16;
|
|
|
|
desktopIcon^.x := 592;
|
|
|
|
desktopIcon^.y := 16;
|
|
|
|
|
|
|
|
prevDesktopIcon := desktopIcon;
|
|
|
|
desktopIcon := PTROF(desktopIcons[1]);
|
|
|
|
desktopIcon^.type := WIDGET_TYPE_BUTTON;
|
|
|
|
desktopIcon^.next := PTROF(desktopIcons[2]);
|
|
|
|
desktopIcon^.id := 1;
|
|
|
|
desktopIcon^.text := "Disk 1";
|
|
|
|
desktopIcon^.fgColor := 0FF000000H;
|
|
|
|
desktopIcon^.bgColor := 0FFFFFFFFH;
|
|
|
|
desktopIcon^.width := 32;
|
|
|
|
desktopIcon^.height := 32 + 16;
|
|
|
|
desktopIcon^.x := 592;
|
|
|
|
desktopIcon^.y := prevDesktopIcon^.y + 32 + 32;
|
|
|
|
|
|
|
|
prevDesktopIcon := desktopIcon;
|
|
|
|
desktopIcon := PTROF(desktopIcons[2]);
|
|
|
|
desktopIcon^.type := WIDGET_TYPE_BUTTON;
|
|
|
|
desktopIcon^.next := PTROF(desktopIcons[3]);
|
2023-07-12 19:41:11 +02:00
|
|
|
desktopIcon^.id := 2;
|
2023-07-12 09:00:08 +02:00
|
|
|
desktopIcon^.text := "Disk 2";
|
|
|
|
desktopIcon^.fgColor := 0FF000000H;
|
|
|
|
desktopIcon^.bgColor := 0FFFFFFFFH;
|
|
|
|
desktopIcon^.width := 32;
|
|
|
|
desktopIcon^.height := 32 + 16;
|
|
|
|
desktopIcon^.x := 592;
|
|
|
|
desktopIcon^.y := prevDesktopIcon^.y + 32 + 32;
|
|
|
|
|
|
|
|
prevDesktopIcon := desktopIcon;
|
|
|
|
desktopIcon := PTROF(desktopIcons[3]);
|
|
|
|
desktopIcon^.type := WIDGET_TYPE_BUTTON;
|
|
|
|
desktopIcon^.next := PTROF(desktopIcons[4]);
|
2023-07-12 19:41:11 +02:00
|
|
|
desktopIcon^.id := 3;
|
2023-07-12 09:00:08 +02:00
|
|
|
desktopIcon^.text := "Disk 3";
|
|
|
|
desktopIcon^.fgColor := 0FF000000H;
|
|
|
|
desktopIcon^.bgColor := 0FFFFFFFFH;
|
|
|
|
desktopIcon^.width := 32;
|
|
|
|
desktopIcon^.height := 32 + 16;
|
|
|
|
desktopIcon^.x := 592;
|
|
|
|
desktopIcon^.y := prevDesktopIcon^.y + 32 + 32;
|
|
|
|
|
|
|
|
prevDesktopIcon := desktopIcon;
|
|
|
|
desktopIcon := PTROF(desktopIcons[4]);
|
|
|
|
desktopIcon^.type := WIDGET_TYPE_BUTTON;
|
|
|
|
desktopIcon^.next := 0;
|
2023-07-12 19:41:11 +02:00
|
|
|
desktopIcon^.id := 4;
|
2023-07-12 09:00:08 +02:00
|
|
|
desktopIcon^.text := "Disk 4";
|
|
|
|
desktopIcon^.fgColor := 0FF000000H;
|
|
|
|
desktopIcon^.bgColor := 0FFFFFFFFH;
|
|
|
|
desktopIcon^.width := 32;
|
|
|
|
desktopIcon^.height := 32 + 16;
|
|
|
|
desktopIcon^.x := 592;
|
|
|
|
desktopIcon^.y := prevDesktopIcon^.y + 32 + 32;
|
|
|
|
END;
|
|
|
|
END.
|