2 Copyright © 1995-2007, 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(), icon.library/DrawIconStateA()
206 ******************************************************************************/
210 const struct TagItem
*tagState
= taglist
;
211 const struct TagItem
*tag
;
212 struct AppIcon
*appIcon
;
214 if (diskobj
== NULL
|| msgport
== NULL
||
215 diskobj
->do_Gadget
.GadgetRender
== NULL
)
220 appIcon
= AllocVec(sizeof(struct AppIcon
), MEMF_CLEAR
| MEMF_ANY
);
228 appIcon
->ai_UserData
= userdata
;
229 appIcon
->ai_Text
= text
;
230 appIcon
->ai_MsgPort
= msgport
;
231 appIcon
->ai_Flags
= WBAPPICONF_SupportsOpen
;
233 while ((tag
= NextTagItem(&tagState
)))
237 case WBAPPICONA_SupportsOpen
:
240 appIcon
->ai_Flags
|= WBAPPICONF_SupportsOpen
;
244 case WBAPPICONA_SupportsCopy
:
247 appIcon
->ai_Flags
|= WBAPPICONF_SupportsCopy
;
251 case WBAPPICONA_SupportsRename
:
254 appIcon
->ai_Flags
|= WBAPPICONF_SupportsRename
;
258 case WBAPPICONA_SupportsInformation
:
261 appIcon
->ai_Flags
|= WBAPPICONF_SupportsInformation
;
265 case WBAPPICONA_SupportsSnapshot
:
268 appIcon
->ai_Flags
|= WBAPPICONF_SupportsSnapshot
;
272 case WBAPPICONA_SupportsUnSnapshot
:
275 appIcon
->ai_Flags
|= WBAPPICONF_SupportsUnSnapshot
;
279 case WBAPPICONA_SupportsLeaveOut
:
282 appIcon
->ai_Flags
|= WBAPPICONF_SupportsLeaveOut
;
286 case WBAPPICONA_SupportsPutAway
:
289 appIcon
->ai_Flags
|= WBAPPICONF_SupportsPutAway
;
293 case WBAPPICONA_SupportsDelete
:
296 appIcon
->ai_Flags
|= WBAPPICONF_SupportsDelete
;
300 case WBAPPICONA_SupportsFormatDisk
:
303 appIcon
->ai_Flags
|= WBAPPICONF_SupportsFormatDisk
;
307 case WBAPPICONA_SupportsEmptyTrash
:
310 appIcon
->ai_Flags
|= WBAPPICONF_SupportsEmptyTrash
;
314 case WBAPPICONA_PropagatePosition
:
317 appIcon
->ai_Flags
|= WBAPPICONF_PropagatePosition
;
321 case WBAPPICONA_RenderHook
:
322 if (appIcon
->ai_RenderHook
!= NULL
)
324 appIcon
->ai_RenderHook
= (struct Hook
*)tag
->ti_Data
;
328 case WBAPPICONA_NotifySelectState
:
331 appIcon
->ai_Flags
|= WBAPPICONF_NotifySelectState
;
337 if (appIcon
->ai_Flags
& WBAPPICONF_PropagatePosition
)
339 appIcon
->ai_DiskObject
= DupDiskObject(diskobj
, TAG_DONE
);
341 if (appIcon
->ai_DiskObject
== NULL
)
350 appIcon
->ai_DiskObject
= diskobj
;
354 AddTail(&WorkbenchBase
->wb_AppIcons
, (struct Node
*)appIcon
);
358 NotifyWorkbench(WBNOTIFY_Create, WBNOTIFY_AppIcon, WorkbenchBase);
364 } /* AddAppIconA() */