2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Add an icon to Workbench's list of AppIcons.
9 #include <exec/types.h>
10 #include <exec/ports.h>
11 #include <utility/tagitem.h>
13 #include <graphics/gfx.h>
15 #include <proto/utility.h>
17 #include "workbench_intern.h"
18 #include <workbench/workbench.h>
21 /*****************************************************************************
24 #include <proto/workbench.h>
26 AROS_LH7(struct AppIcon
*, AddAppIconA
,
28 AROS_LHA(ULONG
, id
, D0
),
29 AROS_LHA(ULONG
, userdata
, D1
),
30 AROS_LHA(char *, text
, A0
),
31 AROS_LHA(struct MsgPort
*, msgport
, A1
),
32 AROS_LHA(BPTR
, lock
, A2
),
33 AROS_LHA(struct DiskObject
*, diskobj
, A3
),
34 AROS_LHA(struct TagItem
*, taglist
, A4
),
37 struct WorkbenchBase
*, WorkbenchBase
, 10, Workbench
)
41 Add an icon to the workbench's list of AppIcons. If a workbench is
42 running, the icon will appear on the workbench screen given that the
44 When a user interacts with the AppIcon, an AppMessage of type
45 MTYPE_APPICON is sent to the message port specified. The different
46 supported actions are:
48 1. User double-clicking on the icon. am_NumArgs is zero and am_ArgList is
50 2. Dropping one or more icons on the AppIcon. am_Numargs is the number of
51 icons dropped plus one; am_ArgList is an array of pointers to WBArg
52 structures of the icons dropped.
53 3. Dropping the AppIcon on another icon -- NOT SUPPORTED.
54 4. Invoking an "Icons" menu item when the AppIcon is selected. am_Class
55 will be set to a value in AMCLASSICON_Open ... AMCLASSICON_EmptyTrash.
59 id -- AppIcon identification number; only for your use (ignored by
61 userdata -- user specific data (ignored by workbench.library)
62 text -- name of the icon
63 lock -- currently unused (must be set to NULL)
64 msgport -- message port to which notification messages will be sent
65 diskobj -- pointer to a DiskObject structure filled in as described
69 do_Gadget -- a gadget structure filled in as follows:
73 Width -- width of icon hit box
74 Height -- height of icon hit box
75 Flags -- 0 or GADGHIMAGE
78 GadgetRender -- pointer to an Image structure
82 Width -- width of image (must be <=
83 width of icon hit box)
84 Height -- height of image (must be <=
85 height of icon hit box)
86 Depth -- number of bit planes of
88 ImageData -- pointer to word aligned
90 PlanePick -- plane mask
101 do_DefaultTool -- NULL
103 do_CurrentX -- NO_ICON_POSITION (recommended)
104 do_CurrentY -- NO_ICON_POSITION (recommended)
105 do_DrawerData -- NULL
106 do_ToolWindow -- NULL
109 taglist -- tags (see below)
113 WBAPPICONA_SupportsOpen (BOOL)
114 Set to TRUE if the AppIcon should respond to the "Open" menu.
117 WBAPPICONA_SupportsCopy (BOOL)
118 Set to TRUE if the AppIcon should respond to the "Copy" menu.
121 WBAPPICONA_SupportsRename (BOOL)
122 Set to TRUE if the AppIcon should respond to the "Rename" menu.
125 WBAPPICONA_SupportsInformation (BOOL)
126 Set to TRUE if the AppIcon should respond to the "Information" menu.
129 WBAPPICONA_SupportsSnapshot (BOOL)
130 Set to TRUE if the AppIcon should respond to the "Snapshot" menu.
133 WBAPPICONA_SupportsUnSnapshot (BOOL)
134 Set to TRUE if the AppIcon should respond to the "UnSnapshot" menu.
137 WBAPPICONA_SupportsLeaveOut (BOOL)
138 Set to TRUE if the AppIcon should respond to the "Leave Out" menu.
141 WBAPPICONA_SupportsPutAway (BOOL)
142 Set to TRUE if the AppIcon should respond to the "Put Away" menu.
145 WBAPPICONA_SupportsDelete (BOOL)
146 Set to TRUE if the AppIcon should respond to the "Delete" menu.
149 WBAPPICONA_SupportsFormatDisk (BOOL)
150 Set to TRUE if the AppIcon should respond to the "Format Disk" menu.
153 WBAPPICONA_SupportsEmptyTrash (BOOL)
154 Set to TRUE if the AppIcon should respond to the "Empty Trash" menu.
157 WBAPPICONA_PropagatePosition (BOOL)
158 Set to TRUE if the AppIcon's position should be updated in the DiskObject
159 passed to this function when the AppIcon is moved. If this is set to TRUE,
160 workbench.library will assume that the structure is not freed as long as
161 the AppIcon is alive.
164 WBAPPICONA_RenderHook (struct Hook *)
165 Pointer to a hook that will be invoked when the AppIcon is rendered.
166 Using this hook and WorkbenchControlA() dynamic or animated AppIcons may
167 be created. The hook will be called with the following parameters:
169 result = hookFunc(hook, reserved, arm);
171 where the 'hookFunc' has the prototype
173 LONG hookFunc(struct Hook *hook, APTR reserved,
174 struct AppIconRenderMsg *arm);
176 If the hook function returns TRUE, the regular image of the AppIcon will
177 be drawn; if it returns FALSE, nothing will be drawn. This allows you to
178 do all the icon rendering except for when dragging the icon on the screen.
180 WBAPPICONA_NotifySelectState (BOOL)
181 When TRUE, you will be notificed whenever the AppIcon becomes selected or
182 unselected; the am_Class will be set to AMCLASSICON_Selected or
183 AMCLASSICON_Unselected.
187 A pointer to an AppIcon structure -- which should be used with
188 RemoveAppIcon() when you want to remove the icon -- or NULL if it was
189 not possible to add the AppIcon.
193 Contrary to AmigaOS, AppIcons may be added when there is no workbench
202 RemoveAppIcon(), WorkbenchControlA(), DrawIconStateA()
206 ******************************************************************************/
209 AROS_LIBBASE_EXT_DECL(struct WorkbenchBase
*, WorkbenchBase
)
211 struct TagItem
*tagState
= taglist
;
213 struct AppIcon
*appIcon
;
215 if (diskobj
== NULL
|| msgport
== NULL
||
216 diskobj
->do_Gadget
.GadgetRender
== NULL
)
221 appIcon
= AllocVec(sizeof(struct AppIcon
), MEMF_CLEAR
| MEMF_ANY
);
229 appIcon
->ai_UserData
= userdata
;
230 appIcon
->ai_Text
= text
;
231 appIcon
->ai_MsgPort
= msgport
;
232 appIcon
->ai_Flags
= WBAPPICONF_SupportsOpen
;
234 while ((tag
= NextTagItem(&tagState
)))
238 case WBAPPICONA_SupportsOpen
:
239 if (tag
->ti_Data
== TRUE
)
241 appIcon
->ai_Flags
|= WBAPPICONF_SupportsOpen
;
245 case WBAPPICONA_SupportsCopy
:
246 if (tag
->ti_Data
== TRUE
)
248 appIcon
->ai_Flags
|= WBAPPICONF_SupportsCopy
;
252 case WBAPPICONA_SupportsRename
:
253 if (tag
->ti_Data
== TRUE
)
255 appIcon
->ai_Flags
|= WBAPPICONF_SupportsRename
;
259 case WBAPPICONA_SupportsInformation
:
260 if (tag
->ti_Data
== TRUE
)
262 appIcon
->ai_Flags
|= WBAPPICONF_SupportsInformation
;
266 case WBAPPICONA_SupportsSnapshot
:
267 if (tag
->ti_Data
== TRUE
)
269 appIcon
->ai_Flags
|= WBAPPICONF_SupportsSnapshot
;
273 case WBAPPICONA_SupportsUnSnapshot
:
274 if (tag
->ti_Data
== TRUE
)
276 appIcon
->ai_Flags
|= WBAPPICONF_SupportsUnSnapshot
;
280 case WBAPPICONA_SupportsLeaveOut
:
281 if (tag
->ti_Data
== TRUE
)
283 appIcon
->ai_Flags
|= WBAPPICONF_SupportsLeaveOut
;
287 case WBAPPICONA_SupportsPutAway
:
288 if (tag
->ti_Data
== TRUE
)
290 appIcon
->ai_Flags
|= WBAPPICONF_SupportsPutAway
;
294 case WBAPPICONA_SupportsDelete
:
295 if (tag
->ti_Data
== TRUE
)
297 appIcon
->ai_Flags
|= WBAPPICONF_SupportsDelete
;
301 case WBAPPICONA_SupportsFormatDisk
:
302 if (tag
->ti_Data
== TRUE
)
304 appIcon
->ai_Flags
|= WBAPPICONF_SupportsFormatDisk
;
308 case WBAPPICONA_SupportsEmptyTrash
:
309 if (tag
->ti_Data
== TRUE
)
311 appIcon
->ai_Flags
|= WBAPPICONF_SupportsEmptyTrash
;
315 case WBAPPICONA_PropagatePosition
:
316 if (tag
->ti_Data
== TRUE
)
318 appIcon
->ai_Flags
|= WBAPPICONF_PropagatePosition
;
322 case WBAPPICONA_RenderHook
:
323 if (appIcon
->ai_RenderHook
!= NULL
)
325 appIcon
->ai_RenderHook
= (struct Hook
*)tag
->ti_Data
;
329 case WBAPPICONA_NotifySelectState
:
330 if (tag
->ti_Data
== TRUE
)
332 appIcon
->ai_Flags
|= WBAPPICONF_NotifySelectState
;
338 if (appIcon
->ai_Flags
& WBAPPICONF_PropagatePosition
)
340 appIcon
->ai_DiskObject
= DupDiskObject(diskobj
, TAG_DONE
);
342 if (appIcon
->ai_DiskObject
== NULL
)
351 appIcon
->ai_DiskObject
= diskobj
;
355 AddTail(&WorkbenchBase
->wb_AppIcons
, (struct Node
*)appIcon
);
359 NotifyWorkbench(WBNOTIFY_Create, WBNOTIFY_AppIcon, WorkbenchBase);
365 } /* AddAppIconA() */