grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / filesys / CDVDFS / src / intui.c
blobf0d3c0c8830d7980ee349726dd013cbd6e9da2aa
1 /* intui.c:
3 * System requester stuff.
5 * ----------------------------------------------------------------------
6 * This code is (C) Copyright 1993,1994 by Frank Munkert.
7 * (C) Copyright 2002-2009 The AROS Development Team
8 * All rights reserved.
9 * This software may be freely distributed and redistributed for
10 * non-commercial purposes, provided this notice is included.
11 * ----------------------------------------------------------------------
12 * History:
14 * 18-Mar-09 sonic AROS_KERNEL definition is used instead of __AROS__
15 * 15-May-07 sonic Show_CDDA_Icon() behaves better if called twice
16 * 08-Apr-07 sonic Removed DEBUG definition
17 * 31-Mar-03 sonic - fixed warnings
18 * 07-Jul-02 sheutlin various changes when porting to AROS
19 * - global variables are now in a struct Globals *global
20 * 18-Jul-94 fmu - New CDDA icon (by Olivier Tonino)
21 * - User-definable icon
22 * 05-Jan-94 fmu Retry displaying CD-DA icon if WB is not open.
23 * 02-Jan-94 fmu Location for CD-DA icon may be defined by user.
24 * 11-Dec-93 fmu Fixed AddAppIconA() call for DICE.
25 * 28-Nov-93 fmu Added custom CD-DA icon; removed GetDefDiskObject() call.
26 * 09-Oct-93 fmu SAS/C support added
29 #include <proto/exec.h>
30 #include <proto/intuition.h>
31 #include <proto/icon.h>
32 #include <proto/wb.h>
33 #include <exec/types.h>
34 #include <intuition/intuition.h>
35 #include <intuition/iobsolete.h>
36 #include <workbench/workbench.h>
37 #include <workbench/startup.h>
38 #include <stdarg.h>
39 #include <stdio.h>
41 #include "debug.h"
42 #include "intui.h"
43 #include "globals.h"
45 static UWORD const g_image_data[] = {
46 /* Plane 0 */
47 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0001,0x1D5F,0x5000,
48 0x0002,0x8000,0x0000,0x0002,0x8000,0x0000,0x001E,0xB9F1,0xF000,
49 0x0030,0xEF0F,0x1800,0x002E,0xAAF2,0xE800,0x002E,0xEEF6,0xB800,
50 0x002E,0xAB1A,0x8000,0x002E,0xA9EA,0xB800,0x002E,0xA9EA,0xE800,
51 0x0030,0xAA1B,0x1800,0x001F,0x39F1,0xF000,0x0000,0x0000,0x0000,
52 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0003,0xFFAB,0x9110,
53 0x000F,0x04D5,0x6930,0x4430,0xAAAA,0x8BA4,0x0040,0x54D4,0x5440,
54 0x54A8,0x0AA8,0xA87C,0x0955,0x44D5,0x5448,0x52AA,0xA02A,0x8014,
55 0x22AA,0xA7D4,0x0062,0x5001,0x4D6A,0xAAD4,0xAAAA,0x07DF,0x554A,
56 0x5250,0x882F,0xFED4,0xB805,0x5717,0xFDFA,0x552A,0xAE0B,0xFBD4,
57 0xEF95,0x5C45,0xE3EE,0x5D62,0xB80A,0x1F5C,0xFFDD,0x5555,0xFBFE,
58 0x7777,0xF777,0xD776,0xFFFE,0xFFFE,0x7FFE,0xFFFF,0xFFFF,0xFFFE,
59 /* Plane 1 */
60 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x140D,0x1000,
61 0x5455,0x4000,0x0454,0x0001,0x0000,0x0000,0x5541,0x6C04,0x0554,
62 0x888F,0x10F0,0xE088,0x555B,0x5505,0x1554,0xAA91,0x1171,0x02AA,
63 0x5551,0x54E5,0x5554,0xEED1,0x5595,0x46EE,0x555B,0x5415,0x1554,
64 0xFFCF,0x55E4,0xE7FE,0x5540,0x6C04,0x0554,0xFFFF,0xFFFF,0xFFFE,
65 0xDDDD,0xDDDD,0xDDDC,0xFFFF,0xFFFF,0xFFFE,0xFFFC,0x55FE,0x6EEE,
66 0xFFF6,0xAEFB,0xDEEE,0xBB9F,0xFFF7,0x755A,0xFFFF,0xBEEE,0xAFBE,
67 0xAAFF,0xF7DD,0x5FC2,0xF7FF,0xFABA,0xFFB6,0xA9FF,0xFFF7,0xFFEA,
68 0xDF55,0x583F,0xFFBC,0xAAAA,0xB6DF,0xFFAA,0x53F5,0xFBAA,0xAAD4,
69 0xABEF,0x7FF4,0x054A,0x45FB,0xFDFA,0x02C4,0xABDF,0xF9FD,0x0D2A,
70 0x10EF,0xF2BE,0xBA10,0xA2DD,0xE5F7,0xEAA2,0x0013,0xFAAB,0x4800,
71 0x8887,0x088A,0x4888,0x0000,0xD00A,0x8000,0x0000,0x0000,0x0000,
72 /* Plane 2 */
73 0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,0xFFFE,0xFFFE,0xE2A0,0xAFFE,
74 0xFFFC,0x7FFF,0xFFFE,0xFFFC,0x7FFF,0xFFFE,0xFFE0,0x460E,0x0FFE,
75 0xFFD0,0x4505,0x17FE,0xFFC0,0x440C,0x07FE,0xFFC4,0x440C,0x47FE,
76 0xFFC4,0x4514,0x7FFE,0xFFC4,0x4604,0x47FE,0xFFC0,0x4604,0x07FE,
77 0xFFD0,0x4415,0x17FE,0xFFE0,0xC60E,0x0FFE,0xFFFF,0xFFFF,0xFFFE,
78 0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFAB,0xFFFE,
79 0xFFFF,0x51D5,0x7FFE,0xFFF0,0x00A8,0x8BBE,0xFFC0,0x41D1,0x547E,
80 0xFFA8,0x08A2,0xA87E,0xFF55,0x45C5,0x547E,0xFEAA,0xA02A,0x803E,
81 0xFEAA,0xA454,0x007E,0xFD55,0x4BAA,0xAAFE,0xFE0A,0x045F,0x553E,
82 0xFE10,0xA82F,0xFEBE,0xFE04,0x0357,0xFD3E,0xFE20,0x06AB,0xFA7E,
83 0xFF10,0x0D55,0xE4FE,0xFFA2,0x1AAA,0x11FE,0xFFED,0x5555,0x87FE,
84 0xFFF8,0xFFFC,0x3FFE,0xFFFF,0x0001,0xFFFE,0xFFFF,0xFFFF,0xFFFE
87 void Init_Intui(struct CDVDBase *global) {
88 IntuitionBase = (APTR)OpenLibrary("intuition.library", 37);
89 WorkbenchBase = (APTR)OpenLibrary("workbench.library", 37);
90 IconBase = (APTR)OpenLibrary("icon.library", 37);
91 if (IconBase)
92 global->g_user_disk_object = GetDiskObject ("env:cdda");
93 if ((!IconBase) || (!global->g_user_disk_object))
95 global->g_xpos = NO_ICON_POSITION;
96 global->g_ypos = NO_ICON_POSITION;
97 global->g_disk_object_image.LeftEdge = 0;
98 global->g_disk_object_image.TopEdge = 0;
99 global->g_disk_object_image.Width = 47;
100 global->g_disk_object_image.Height = 36;
101 global->g_disk_object_image.Depth = 3;
102 global->g_disk_object_image.ImageData = (APTR)g_image_data;
103 global->g_disk_object_image.PlanePick = 0xff;
104 global->g_disk_object_image.PlaneOnOff = 0x00;
105 global->g_disk_object_image.NextImage = NULL;
107 global->g_disk_object.do_Magic = WB_DISKMAGIC;
108 global->g_disk_object.do_Version = WB_DISKVERSION;
109 global->g_disk_object.do_Gadget.NextGadget = NULL;
110 global->g_disk_object.do_Gadget.LeftEdge = 0;
111 global->g_disk_object.do_Gadget.TopEdge = 0;
112 global->g_disk_object.do_Gadget.Width = 47;
113 global->g_disk_object.do_Gadget.Height = 37;
114 global->g_disk_object.do_Gadget.Flags = GADGIMAGE | GADGHCOMP;
115 global->g_disk_object.do_Gadget.Activation = RELVERIFY | GADGIMMEDIATE;
116 global->g_disk_object.do_Gadget.GadgetType = BOOLGADGET;
117 global->g_disk_object.do_Gadget.GadgetRender = &global->g_disk_object_image;
118 global->g_disk_object.do_Gadget.SelectRender = NULL;
119 global->g_disk_object.do_Gadget.GadgetText = NULL;
120 global->g_disk_object.do_Gadget.MutualExclude = 0;
121 global->g_disk_object.do_Gadget.SpecialInfo = NULL;
122 global->g_disk_object.do_Gadget.GadgetID = 0;
123 global->g_disk_object.do_Gadget.UserData = NULL;
124 global->g_disk_object.do_Type = 0;
125 global->g_disk_object.do_DefaultTool = "";
126 global->g_disk_object.do_ToolTypes = global->g_tool_types;
127 global->g_disk_object.do_CurrentX = NO_ICON_POSITION;
128 global->g_disk_object.do_CurrentY = NO_ICON_POSITION;
129 global->g_disk_object.do_DrawerData = NULL;
130 global->g_disk_object.do_ToolWindow = NULL;
131 global->g_disk_object.do_StackSize = 0;
132 global->g_user_disk_object = &global->g_disk_object;
134 else
136 char *name;
137 name = FindToolType (global->g_user_disk_object->do_ToolTypes, "ICONNAME");
138 if (name)
139 global->g_iconname = name;
142 global->g_app_port = NULL;
143 global->g_app_sigbit = 0;
144 global->g_app_icon = NULL;
147 void Close_Intui(struct CDVDBase *global) {
148 if (WorkbenchBase)
149 CloseLibrary ((struct Library *)WorkbenchBase);
150 if (IconBase)
151 CloseLibrary ((struct Library *)IconBase);
152 if (IntuitionBase)
153 CloseLibrary ((struct Library *)IntuitionBase);
156 void Display_Error_Tags (struct CDVDBase *global, char *p_message, APTR arg)
158 struct EasyStruct req =
160 sizeof (struct EasyStruct),
162 (UBYTE *) "CDROM Handler Error",
163 NULL,
164 (UBYTE *) "Abort"
167 if (IntuitionBase)
169 if (!IntuitionBase->FirstScreen)
170 return;
171 req.es_TextFormat = (UBYTE *) p_message;
172 EasyRequestArgs (NULL, &req, NULL, arg);
176 /* Evil workaround for a gcc 4.5.2 register spill bug on m68k
178 #ifndef __mc68000
179 static inline
180 #endif
181 void Add_CDDA_Icon(struct CDVDBase *global)
183 global->g_app_icon = AddAppIconA
187 (UBYTE *) global->g_iconname,
188 global->g_app_port,
189 BNULL,
190 global->g_user_disk_object,
191 NULL
195 void Show_CDDA_Icon (struct CDVDBase *global) {
197 if (!IconBase || !WorkbenchBase)
198 return;
199 if (global->g_app_icon) {
200 Display_Error("Show_CDDA_Icon called twice!");
201 return;
204 global->g_user_disk_object->do_CurrentX = global->g_xpos;
205 global->g_user_disk_object->do_CurrentY = global->g_ypos;
207 global->g_app_port = CreateMsgPort ();
208 if (!global->g_app_port)
209 return;
211 global->g_app_sigbit = 1<<global->g_app_port->mp_SigBit;
213 Add_CDDA_Icon(global);
216 AddAppIconA may fail if the Workbench has not yet been loaded.
218 if (!global->g_app_icon)
220 DeleteMsgPort (global->g_app_port);
221 global->g_app_port = NULL;
222 global->g_retry_show_cdda_icon = TRUE;
223 return;
225 global->g_retry_show_cdda_icon = FALSE;
228 void Hide_CDDA_Icon(struct CDVDBase *global) {
229 struct Message *msg;
231 global->g_retry_show_cdda_icon = FALSE;
233 if (!IconBase || !WorkbenchBase)
234 return;
236 if (global->g_app_icon)
237 RemoveAppIcon (global->g_app_icon);
238 if (global->g_app_port)
240 while ((msg = GetMsg (global->g_app_port)))
241 ReplyMsg (msg);
242 DeleteMsgPort (global->g_app_port);
245 global->g_app_port = NULL;
246 global->g_app_sigbit = 0;
247 global->g_app_icon = NULL;