added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / system / Wanderer / iconwindowcontents.c
blob81ddde4da65a8d09eac57abf50106e89e1e7889a
1 /*
2 Copyright 2004-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define MUIMASTER_YES_INLINE_STDARG
8 //#define DEBUG_NETWORKBROWSER
9 //#define DEBUG_SHOWUSERFILES
10 #define TXTBUFF_LEN 1024
12 #define DEBUG 0
13 #include <aros/debug.h>
15 #include <exec/types.h>
16 #include <libraries/mui.h>
17 #include <zune/customclasses.h>
19 #include <proto/utility.h>
20 #include <proto/intuition.h>
21 #include <proto/graphics.h>
22 #include <proto/muimaster.h>
23 #include <proto/exec.h>
24 #include <proto/datatypes.h>
25 #include <proto/icon.h>
27 #include <dos/dos.h>
28 #include <proto/dos.h>
30 #include <stdio.h>
31 #include <string.h>
33 #include <intuition/screens.h>
34 #include <datatypes/pictureclass.h>
35 #include <clib/macros.h>
37 #include "../../libs/muimaster/classes/iconlist.h"
38 #include "../../libs/muimaster/classes/iconlist_attributes.h"
40 #include "wanderer.h"
41 #include "wandererprefs.h"
42 #include "iconwindow.h"
43 #include "iconwindowcontents.h"
45 extern struct IconWindow_BackFill_Descriptor *iconwindow_BackFill_Active;
47 #define BG_DRAWFLAG 0xf00dd00f
49 /*** Instance Data **********************************************************/
51 struct IconWindowIconList_DATA
53 Object *iwcd_IconWindow;
54 struct MUI_EventHandlerNode iwcd_EventHandlerNode;
55 struct Hook iwcd_ProcessIconListPrefs_hook;
56 IPTR iwcd_ViewPrefs_ID;
57 Object *iwcd_ViewPrefs_NotificationObject;
60 struct IconWindowIconDrawerList_DATA
62 Object *iwcd_IconWindow;
63 struct MUI_EventHandlerNode iwcd_EventHandlerNode;
64 struct Hook iwcd_ProcessIconListPrefs_hook;
65 IPTR iwcd_ViewPrefs_ID;
66 Object *iwcd_ViewPrefs_NotificationObject;
67 struct NotifyRequest iwdcd_DrawerNotifyRequest;
70 struct IconWindowIconVolumeList_DATA
72 Object *iwcd_IconWindow;
73 struct MUI_EventHandlerNode iwcd_EventHandlerNode;
74 struct Hook iwcd_ProcessIconListPrefs_hook;
75 IPTR iwcd_ViewPrefs_ID;
76 Object *iwcd_ViewPrefs_NotificationObject;
77 struct Hook iwvcd_UpdateNetworkPrefs_hook;
78 IPTR iwvcd_ShowNetworkBrowser;
79 IPTR iwvcd_ShowUserFolder;
80 char *iwvcd_UserFolderPath;
84 struct IconWindowIconNetworkBrowserList_DATA
86 Object *iwcd_IconWindow;
87 struct MUI_EventHandlerNode iwcd_EventHandlerNode;
88 struct Hook iwcd_ProcessIconListPrefs_hook;
89 IPTR iwcd_ViewPrefs_ID;
90 Object *iwcd_ViewPrefs_NotificationObject;
91 struct Hook iwnbcd_UpdateNetworkPrefs_hook;
92 struct List iwnbcd_NetworkClasses;
95 static char __icwc_intern_TxtBuff[TXTBUFF_LEN];
97 /*** Macros *****************************************************************/
98 #define SETUP_INST_DATA struct IconWindowIconList_DATA *data = INST_DATA(CLASS, self)
100 /*** Hook functions *********************************************************/
101 AROS_UFH3(
102 void, IconWindowIconList__HookFunc_ProcessIconListPrefsFunc,
103 AROS_UFHA(struct Hook *, hook, A0),
104 AROS_UFHA(APTR *, obj, A2),
105 AROS_UFHA(APTR, param, A1)
108 AROS_USERFUNC_INIT
110 /* Get our private data */
111 Object *self = ( Object *)obj;
112 Object *prefs = NULL;
113 Class *CLASS = *( Class **)param;
115 SETUP_INST_DATA;
117 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc()\n"));
119 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
121 if (prefs)
123 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: Setting IconList options ..\n"));
124 BOOL options_changed = FALSE;
126 IPTR current_ListMode = 0,
127 current_TextMode = 0,
128 current_TextMaxLen = 0,
129 current_MultiLine = 0,
130 current_MultiLineOnFocus = 0,
131 current_IconHorizontalSpacing = 0,
132 current_IconVerticalSpacing = 0,
133 current_IconImageSpacing = 0,
134 current_LabelTextHorizontalPadding = 0,
135 current_LabelTextVerticalPadding = 0,
136 current_LabelTextBorderWidth = 0,
137 current_LabelTextBorderHeight = 0;
139 GET(self, MUIA_IconList_IconListMode, &current_ListMode);
140 GET(self, MUIA_IconList_LabelText_Mode, &current_TextMode);
141 GET(self, MUIA_IconList_LabelText_MaxLineLen, &current_TextMaxLen);
143 GET(self, MUIA_IconList_LabelText_MultiLine, &current_MultiLine);
144 GET(self, MUIA_IconList_LabelText_MultiLineOnFocus, &current_MultiLineOnFocus);
145 GET(self, MUIA_IconList_Icon_HorizontalSpacing, &current_IconHorizontalSpacing);
146 GET(self, MUIA_IconList_Icon_VerticalSpacing, &current_IconVerticalSpacing);
147 GET(self, MUIA_IconList_Icon_ImageSpacing, &current_IconImageSpacing);
148 GET(self, MUIA_IconList_LabelText_HorizontalPadding, &current_LabelTextHorizontalPadding);
149 GET(self, MUIA_IconList_LabelText_VerticalPadding, &current_LabelTextVerticalPadding);
150 GET(self, MUIA_IconList_LabelText_BorderWidth, &current_LabelTextBorderWidth);
151 GET(self, MUIA_IconList_LabelText_BorderHeight, &current_LabelTextBorderHeight);
153 //D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: Current = %d %d %d\n", current_ListMode, current_TextMode, current_TextMaxLen));
155 IPTR prefs_ListMode = 0,
156 prefs_TextMode = 0,
157 prefs_TextMaxLen = 0,
158 prefs_MultiLine = 0,
159 prefs_MultiLineOnFocus = 0,
160 prefs_IconHorizontalSpacing = 0,
161 prefs_IconVerticalSpacing = 0,
162 prefs_IconImageSpacing = 0,
163 prefs_LabelTextHorizontalPadding = 0,
164 prefs_LabelTextVerticalPadding = 0,
165 prefs_LabelTextBorderWidth = 0,
166 prefs_LabelTextBorderHeight = 0,
167 prefs_Processing = 0;
169 prefs_ListMode = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_IconListMode);
170 prefs_TextMode = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_Mode);
171 prefs_TextMaxLen = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_MaxLineLen);
173 prefs_MultiLine = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_MultiLine);
174 prefs_MultiLineOnFocus = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_MultiLineOnFocus);
175 prefs_IconHorizontalSpacing = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_Icon_HorizontalSpacing);
176 prefs_IconVerticalSpacing = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_Icon_VerticalSpacing);
177 prefs_IconImageSpacing = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_Icon_ImageSpacing);
178 prefs_LabelTextHorizontalPadding = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_HorizontalPadding);
179 prefs_LabelTextVerticalPadding = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_VerticalPadding);
180 prefs_LabelTextBorderWidth = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_BorderWidth);
181 prefs_LabelTextBorderHeight = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_BorderHeight);
183 GET(prefs, MUIA_WandererPrefs_Processing, &prefs_Processing);
185 //D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: Prefs = %d %d %d\n", prefs_ListMode, prefs_TextMode, prefs_TextMaxLen));
187 if ((prefs_ListMode != -1) && (current_ListMode != prefs_ListMode))
189 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: IconList ListMode changed - updating ..\n"));
190 options_changed = TRUE;
191 SET(self, MUIA_IconList_IconListMode, prefs_ListMode);
193 if ((prefs_TextMode != -1) && (current_TextMode != prefs_TextMode))
195 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: IconList TextRenderMode changed - updating ..\n"));
196 options_changed = TRUE;
197 SET(self, MUIA_IconList_LabelText_Mode, prefs_TextMode);
199 if ((prefs_TextMaxLen != -1) && (current_TextMaxLen != prefs_TextMaxLen))
201 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: IconList Max Text Length changed - updating ..\n"));
202 options_changed = TRUE;
203 SET(self, MUIA_IconList_LabelText_MaxLineLen, prefs_TextMaxLen);
205 if ((prefs_MultiLine != -1) && (current_MultiLine != prefs_MultiLine))
207 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: IconList Multi-Line changed - updating ..\n"));
208 options_changed = TRUE;
209 SET(self, MUIA_IconList_LabelText_MultiLine, prefs_MultiLine);
211 if ((prefs_MultiLineOnFocus != -1) && (current_MultiLineOnFocus != prefs_MultiLineOnFocus))
213 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: Multi-Line on Focus changed - updating ..\n"));
214 options_changed = TRUE;
215 SET(self, MUIA_IconList_LabelText_MultiLineOnFocus, prefs_MultiLineOnFocus);
217 if ((prefs_IconHorizontalSpacing != -1) && (current_IconHorizontalSpacing != prefs_IconHorizontalSpacing))
219 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: Icon Horizontal Spacing changed - updating ..\n"));
220 options_changed = TRUE;
221 SET(self, MUIA_IconList_Icon_HorizontalSpacing, prefs_IconHorizontalSpacing);
223 if ((prefs_IconVerticalSpacing != -1) && (current_IconVerticalSpacing != prefs_IconVerticalSpacing))
225 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: Icon Vertical Spacing changed - updating ..\n"));
226 options_changed = TRUE;
227 SET(self, MUIA_IconList_Icon_VerticalSpacing, prefs_IconVerticalSpacing);
229 if ((prefs_IconImageSpacing != -1) && (current_IconImageSpacing != prefs_IconImageSpacing))
231 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: Icon Label Image Spacing changed - updating ..\n"));
232 options_changed = TRUE;
233 SET(self, MUIA_IconList_Icon_ImageSpacing, prefs_IconImageSpacing);
235 if ((prefs_LabelTextHorizontalPadding != -1) && (current_LabelTextHorizontalPadding != prefs_LabelTextHorizontalPadding))
237 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: Icon Label Horizontal Padding changed - updating ..\n"));
238 options_changed = TRUE;
239 SET(self, MUIA_IconList_LabelText_HorizontalPadding, prefs_LabelTextHorizontalPadding);
241 if ((prefs_LabelTextVerticalPadding != -1) &&(current_LabelTextVerticalPadding != prefs_LabelTextVerticalPadding))
243 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: Icon Label Vertical Padding changed - updating ..\n"));
244 options_changed = TRUE;
245 SET(self, MUIA_IconList_LabelText_VerticalPadding, prefs_LabelTextVerticalPadding);
247 if ((prefs_LabelTextBorderWidth != -1) && (current_LabelTextBorderWidth != prefs_LabelTextBorderWidth))
249 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: Icon Label Border Width changed - updating ..\n"));
250 options_changed = TRUE;
251 SET(self, MUIA_IconList_LabelText_BorderWidth, prefs_LabelTextBorderWidth);
253 if ((prefs_LabelTextBorderHeight != -1) && (current_LabelTextBorderHeight != prefs_LabelTextBorderHeight))
255 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: Icon Label Border Height changed - updating ..\n"));
256 options_changed = TRUE;
257 SET(self, MUIA_IconList_LabelText_BorderHeight, prefs_LabelTextBorderHeight);
260 if ((options_changed) && !(prefs_Processing))
262 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_ProcessIconListPrefsFunc: IconList Options have changed, causing an update ..\n"));
263 DoMethod(self, MUIM_IconList_Update);
265 else if (data->iwcd_IconWindow)
267 SET(data->iwcd_IconWindow, MUIA_IconWindow_Changed, TRUE);
270 AROS_USERFUNC_EXIT
273 AROS_UFH3(
274 void, IconWindowIconList__HookFunc_UpdateNetworkPrefsFunc,
275 AROS_UFHA(struct Hook *, hook, A0),
276 AROS_UFHA(APTR *, obj, A2),
277 AROS_UFHA(APTR, param, A1)
280 AROS_USERFUNC_INIT
282 /* Get our private data */
283 Object *self = ( Object *)obj;
284 Object *prefs = NULL;
285 Class *CLASS = *( Class **)param;
287 SETUP_INST_DATA;
289 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_UpdateNetworkPrefsFunc()\n"));
291 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
293 if (prefs)
295 BOOL options_changed = FALSE;
296 IPTR prefs_Processing = 0;
298 GET(prefs, MUIA_WandererPrefs_Processing, &prefs_Processing);
300 if ((BOOL)XGET(_win(self), MUIA_IconWindow_IsRoot))
302 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_UpdateNetworkPrefsFunc: Setting ROOT view Network options ..\n"));
303 ULONG current_ShowNetwork = 0;
305 GET(self, MUIA_IconWindowExt_NetworkBrowser_Show, &current_ShowNetwork);
307 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_UpdateNetworkPrefsFunc: Current = %d\n", current_ShowNetwork));
309 ULONG prefs_ShowNetwork = 0;
311 GET(prefs, MUIA_IconWindowExt_NetworkBrowser_Show, &prefs_ShowNetwork);
313 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_UpdateNetworkPrefsFunc: Prefs = %d\n", prefs_ShowNetwork));
315 if ((BOOL)current_ShowNetwork != (BOOL)prefs_ShowNetwork)
317 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_UpdateNetworkPrefsFunc: ROOT view Network prefs changed - updating ..\n"));
318 options_changed = TRUE;
319 ((struct IconWindowIconVolumeList_DATA *)data)->iwvcd_ShowNetworkBrowser = prefs_ShowNetwork;
322 if ((options_changed) && !(prefs_Processing))
324 D(bug("[IconWindowIconList] IconWindowIconList__HookFunc_UpdateNetworkPrefsFunc: Network prefs changed, causing an update ..\n"));
325 DoMethod(self, MUIM_IconList_Update);
327 else if (data->iwcd_IconWindow)
329 SET(data->iwcd_IconWindow, MUIA_IconWindow_Changed, TRUE);
332 AROS_USERFUNC_EXIT
335 /*** Methods ****************************************************************/
337 Object *IconWindowIconList__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
339 D(bug("[IconWindowIconList] IconWindowIconList__OM_NEW()\n"));
341 IPTR _newIconList__FSNotifyPort = NULL;
343 _newIconList__FSNotifyPort = (Object *)GetTagData(MUIA_Wanderer_FileSysNotifyPort, (IPTR) NULL, message->ops_AttrList);
345 self = (Object *) DoSuperNewTags
347 CLASS, self, NULL,
348 MUIA_CycleChain, 1,
349 TAG_MORE, (IPTR) message->ops_AttrList
352 if (self != NULL)
354 SETUP_INST_DATA;
355 D(bug("[IconWindowIconList] IconWindowIconList__OM_NEW: SELF = 0x%p\n", self));
356 data->iwcd_ProcessIconListPrefs_hook.h_Entry = ( HOOKFUNC )IconWindowIconList__HookFunc_ProcessIconListPrefsFunc;
357 if (_newIconList__FSNotifyPort != NULL)
359 struct IconWindowIconDrawerList_DATA *drawerlist_data = (IPTR)data;
360 drawerlist_data->iwdcd_DrawerNotifyRequest.nr_stuff.nr_Msg.nr_Port = _newIconList__FSNotifyPort;
361 D(bug("[IconWindowIconList] IconWindowIconList__OM_NEW: FS Notify Port @ 0x%p\n", _newIconList__FSNotifyPort));
365 return self;
368 IPTR IconWindowIconList__OM_SET(Class *CLASS, Object *self, struct opSet *message)
370 SETUP_INST_DATA;
372 struct TagItem *tstate = message->ops_AttrList, *tag;
374 while ((tag = NextTagItem((const struct TagItem**)&tstate)) != NULL)
376 switch (tag->ti_Tag)
378 case MUIA_Background:
380 D(bug("[IconWindowIconList] IconWindowIconList__OM_SET: MUIA_Background\n"));
381 break;
383 case MUIA_IconWindow_Window:
385 data->iwcd_IconWindow = tag->ti_Data;
386 break;
390 return DoSuperMethodA(CLASS, self, (Msg) message);
393 IPTR IconWindowIconList__OM_GET(Class *CLASS, Object *self, struct opGet *message)
395 SETUP_INST_DATA;
396 IPTR *store = message->opg_Storage;
397 IPTR rv = TRUE;
399 switch (message->opg_AttrID)
401 default:
402 rv = DoSuperMethodA(CLASS, self, (Msg) message);
405 return rv;
408 IPTR IconWindowIconList__MUIM_Setup
410 Class *CLASS, Object *self, Msg message
413 SETUP_INST_DATA;
415 if (!DoSuperMethodA(CLASS, self, message)) return FALSE;
417 Object *prefs = NULL;
419 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
421 if (prefs)
423 GET(_win(self), MUIA_IconWindow_BackgroundAttrib, &data->iwcd_ViewPrefs_ID);
424 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_Setup: Window Background = '%s'\n", data->iwcd_ViewPrefs_ID));
425 data->iwcd_ViewPrefs_NotificationObject = DoMethod(prefs,
426 MUIM_WandererPrefs_ViewSettings_GetNotifyObject,
427 data->iwcd_ViewPrefs_ID);
429 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_Setup: Background Notification Obj @ 0x%p\n", data->iwcd_ViewPrefs_NotificationObject));
431 /* Set our initial options */
432 IPTR prefs_ListMode = 0,
433 prefs_TextMode = 0,
434 prefs_TextMaxLen = 0,
435 prefs_MultiLine = 0,
436 prefs_MultiLineOnFocus = 0,
437 prefs_IconHorizontalSpacing = 0,
438 prefs_IconVerticalSpacing = 0,
439 prefs_IconImageSpacing = 0,
440 prefs_LabelTextHorizontalPadding = 0,
441 prefs_LabelTextVerticalPadding = 0,
442 prefs_LabelTextBorderWidth = 0,
443 prefs_LabelTextBorderHeight = 0,
444 prefs_Processing = 0;
446 prefs_ListMode = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_IconListMode);
447 prefs_TextMode = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_Mode);
448 prefs_TextMaxLen = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_MaxLineLen);
450 prefs_MultiLine = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_MultiLine);
451 prefs_MultiLineOnFocus = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_MultiLineOnFocus);
452 prefs_IconHorizontalSpacing = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_Icon_HorizontalSpacing);
453 prefs_IconVerticalSpacing = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_Icon_VerticalSpacing);
454 prefs_IconImageSpacing = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_Icon_ImageSpacing);
455 prefs_LabelTextHorizontalPadding = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_HorizontalPadding);
456 prefs_LabelTextVerticalPadding = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_VerticalPadding);
457 prefs_LabelTextBorderWidth = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_BorderWidth);
458 prefs_LabelTextBorderHeight = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, MUIA_IconList_LabelText_BorderHeight);
460 if (prefs_ListMode != (IPTR)-1) SET(self, MUIA_IconList_IconListMode, prefs_ListMode);
461 if (prefs_TextMode != (IPTR)-1) SET(self, MUIA_IconList_LabelText_Mode, prefs_TextMode);
462 if (prefs_TextMaxLen != (IPTR)-1) SET(self, MUIA_IconList_LabelText_MaxLineLen, prefs_TextMaxLen);
463 if (prefs_MultiLine != (IPTR)-1) SET(self, MUIA_IconList_LabelText_MultiLine, prefs_MultiLine);
464 if (prefs_MultiLineOnFocus != (IPTR)-1) SET(self, MUIA_IconList_LabelText_MultiLineOnFocus, prefs_MultiLineOnFocus);
465 if (prefs_IconHorizontalSpacing != (IPTR)-1) SET(self, MUIA_IconList_Icon_HorizontalSpacing, prefs_IconHorizontalSpacing);
466 if (prefs_IconVerticalSpacing != (IPTR)-1) SET(self, MUIA_IconList_Icon_VerticalSpacing, prefs_IconVerticalSpacing);
467 if (prefs_IconImageSpacing != (IPTR)-1) SET(self, MUIA_IconList_Icon_ImageSpacing, prefs_IconImageSpacing);
468 if (prefs_LabelTextHorizontalPadding != (IPTR)-1) SET(self, MUIA_IconList_LabelText_HorizontalPadding, prefs_LabelTextHorizontalPadding);
469 if (prefs_LabelTextVerticalPadding != (IPTR)-1) SET(self, MUIA_IconList_LabelText_VerticalPadding, prefs_LabelTextVerticalPadding);
470 if (prefs_LabelTextBorderWidth != (IPTR)-1) SET(self, MUIA_IconList_LabelText_BorderWidth, prefs_LabelTextBorderWidth);
471 if (prefs_LabelTextBorderHeight != (IPTR)-1) SET(self, MUIA_IconList_LabelText_BorderHeight, prefs_LabelTextBorderHeight);
473 /* Configure notifications incase they get updated =) */
474 DoMethod
476 data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_IconListMode, MUIV_EveryTime,
477 (IPTR) self, 3,
478 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)CLASS
481 DoMethod
483 data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_Mode, MUIV_EveryTime,
484 (IPTR) self, 3,
485 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)CLASS
488 DoMethod
490 data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_MaxLineLen, MUIV_EveryTime,
491 (IPTR) self, 3,
492 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)CLASS
495 DoMethod
497 data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_MultiLine, MUIV_EveryTime,
498 (IPTR) self, 3,
499 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)CLASS
502 DoMethod
504 data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_MultiLineOnFocus, MUIV_EveryTime,
505 (IPTR) self, 3,
506 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)CLASS
509 DoMethod
511 data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_Icon_HorizontalSpacing, MUIV_EveryTime,
512 (IPTR) self, 3,
513 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)CLASS
516 DoMethod
518 data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_Icon_VerticalSpacing, MUIV_EveryTime,
519 (IPTR) self, 3,
520 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)CLASS
523 DoMethod
525 data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_Icon_ImageSpacing, MUIV_EveryTime,
526 (IPTR) self, 3,
527 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)CLASS
530 DoMethod
532 data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_HorizontalPadding, MUIV_EveryTime,
533 (IPTR) self, 3,
534 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)CLASS
537 DoMethod
539 data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_VerticalPadding, MUIV_EveryTime,
540 (IPTR) self, 3,
541 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)CLASS
544 DoMethod
546 data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_BorderWidth, MUIV_EveryTime,
547 (IPTR) self, 3,
548 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)CLASS
551 DoMethod
553 data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_BorderHeight, MUIV_EveryTime,
554 (IPTR) self, 3,
555 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)CLASS
559 if ((BOOL)XGET(_win(self), MUIA_IconWindow_IsRoot))
561 if (prefs)
563 ((struct IconWindowIconVolumeList_DATA *)data)->iwvcd_UpdateNetworkPrefs_hook.h_Entry = ( HOOKFUNC )IconWindowIconList__HookFunc_UpdateNetworkPrefsFunc;
565 DoMethod
567 prefs, MUIM_Notify, MUIA_IconWindowExt_NetworkBrowser_Show, MUIV_EveryTime,
568 (IPTR) self, 3,
569 MUIM_CallHook, &((struct IconWindowIconVolumeList_DATA *)data)->iwvcd_UpdateNetworkPrefs_hook, (IPTR)CLASS
573 if (muiRenderInfo(self))
575 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_Window_Setup: Setting up EventHandler for (IDCMP_DISKINSERTED | IDCMP_DISKREMOVED)\n"));
577 data->iwcd_EventHandlerNode.ehn_Priority = 1;
578 data->iwcd_EventHandlerNode.ehn_Flags = MUI_EHF_GUIMODE;
579 data->iwcd_EventHandlerNode.ehn_Object = self;
580 data->iwcd_EventHandlerNode.ehn_Class = CLASS;
581 data->iwcd_EventHandlerNode.ehn_Events = IDCMP_DISKINSERTED | IDCMP_DISKREMOVED;
583 DoMethod(_win(self), MUIM_Window_AddEventHandler, &data->iwcd_EventHandlerNode);
585 else
587 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_Window_Setup: Couldnt add IDCMP EventHandler!\n"));
590 else
592 /* Setup notification on the directory -------------------------------- */
593 STRPTR directory_path = NULL;
594 GET(self, MUIA_IconDrawerList_Drawer, &directory_path);
596 if (directory_path != NULL)
598 struct IconWindowIconDrawerList_DATA *drawerlist_data = (IPTR)data;
600 if (drawerlist_data->iwdcd_DrawerNotifyRequest.nr_stuff.nr_Msg.nr_Port != NULL)
602 drawerlist_data->iwdcd_DrawerNotifyRequest.nr_Name = directory_path;
603 drawerlist_data->iwdcd_DrawerNotifyRequest.nr_Flags = NRF_SEND_MESSAGE;
604 drawerlist_data->iwdcd_DrawerNotifyRequest.nr_UserData = self;
606 if (StartNotify(&drawerlist_data->iwdcd_DrawerNotifyRequest))
608 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_Window_Setup: Drawer-notification setup on '%s'\n", drawerlist_data->iwdcd_DrawerNotifyRequest.nr_Name));
610 else
612 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_Window_Setup: FAILED to setup Drawer-notification!\n"));
613 drawerlist_data->iwdcd_DrawerNotifyRequest.nr_Name = NULL;
619 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_Window_Setup: Setup complete!\n"));
621 return TRUE;
624 IPTR IconWindowIconList__MUIM_Cleanup
626 Class *CLASS, Object *self, Msg message
629 SETUP_INST_DATA;
631 Object *prefs = NULL;
633 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_Cleanup()\n"));
634 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
636 if (prefs)
638 DoMethod
640 data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_IconListMode, (IPTR)self
643 DoMethod
645 data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_Mode, (IPTR)self
648 DoMethod
650 data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_MaxLineLen, (IPTR)self
653 DoMethod
655 data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_MultiLine, (IPTR)self
658 DoMethod
660 data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_MultiLineOnFocus, (IPTR)self
663 DoMethod
665 data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_Icon_HorizontalSpacing, (IPTR)self
668 DoMethod
670 data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_Icon_VerticalSpacing, (IPTR)self
673 DoMethod
675 data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_Icon_ImageSpacing, (IPTR)self
678 DoMethod
680 data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_HorizontalPadding, (IPTR)self
683 DoMethod
685 data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_VerticalPadding, (IPTR)self
688 DoMethod
690 data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_BorderWidth, (IPTR)self
693 DoMethod
695 data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_BorderHeight, (IPTR)self
699 if ((BOOL)XGET(_win(self), MUIA_IconWindow_IsRoot))
701 if (prefs)
703 DoMethod
705 prefs,
706 MUIM_KillNotifyObj, MUIA_IconWindowExt_NetworkBrowser_Show, (IPTR) self
709 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_Cleanup: (ROOT WINDOW) Removing our Disk Event Handler\n"));
710 DoMethod(_win(self), MUIM_Window_RemEventHandler, &data->iwcd_EventHandlerNode);
712 else
714 struct IconWindowIconDrawerList_DATA *drawerlist_data = (IPTR)data;
715 if (drawerlist_data->iwdcd_DrawerNotifyRequest.nr_Name != NULL)
717 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_Cleanup: (DRAWER WINDOW) Removing our Drawer Notification Request\n"));
718 EndNotify(&drawerlist_data->iwdcd_DrawerNotifyRequest);
722 return DoSuperMethodA(CLASS, self, message);
725 IPTR IconWindowIconList__MUIM_HandleEvent
727 Class *CLASS, Object *self, struct MUIP_HandleEvent *message
730 SETUP_INST_DATA;
732 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_HandleEvent()\n"));
733 struct IntuiMessage *imsg = message->imsg;
735 if(imsg->Class == IDCMP_DISKINSERTED)
737 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_HandleEvent: IDCMP_DISKINSERTED\n"));
738 DoMethod(self, MUIM_IconList_Update);
739 return(MUI_EventHandlerRC_Eat);
741 else if (imsg->Class == IDCMP_DISKREMOVED)
743 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_HandleEvent: IDCMP_DISKREMOVED\n"));
744 DoMethod(self, MUIM_IconList_Update);
745 return(MUI_EventHandlerRC_Eat);
747 return 0;
750 IPTR IconWindowIconList__MUIM_DrawBackground
752 Class *CLASS, Object *self, struct MUIP_DrawBackground *message
755 SETUP_INST_DATA;
757 IPTR retVal = (IPTR)TRUE;
758 IPTR clip = NULL, adjust_left = 0, adjust_top = 0;
760 D(bug("[IconWindow] IconWindowIconList__MUIM_DrawBackground()\n"));
762 if ((iconwindow_BackFill_Active == NULL) ||
763 (data->iwcd_IconWindow == NULL))
765 D(bug("[IconWindow] IconWindowIconList__MUIM_DrawBackground: No Backfill support/Window not set .. causing parent class to render\n"));
766 goto iwc_ParentBackground;
769 struct RastPort *DrawBackGround_RastPort = _rp(self);
770 struct IconWindowBackFillMsg DrawBackGround_BackFillMsg;
772 DrawBackGround_BackFillMsg.Layer = DrawBackGround_RastPort->Layer;
774 DrawBackGround_BackFillMsg.AreaBounds.MinX = _mleft(self);
775 DrawBackGround_BackFillMsg.AreaBounds.MinY = _mtop(self);
776 DrawBackGround_BackFillMsg.AreaBounds.MaxX = (_mleft(self) + _mwidth(self));
777 DrawBackGround_BackFillMsg.AreaBounds.MaxY = (_mtop(self) + _mheight(self));
779 DrawBackGround_BackFillMsg.DrawBounds.MinX = message->left;
780 DrawBackGround_BackFillMsg.DrawBounds.MinY = message->top;
781 DrawBackGround_BackFillMsg.DrawBounds.MaxX = (message->left + message->width);
782 DrawBackGround_BackFillMsg.DrawBounds.MaxY = (message->top + message->height);
784 /* Offset into source image (ala scroll bar position) */
785 DrawBackGround_BackFillMsg.OffsetX = message->xoffset;
786 DrawBackGround_BackFillMsg.OffsetY = message->yoffset;
788 D(bug("[IconWindow] IconWindowIconList__MUIM_DrawBackground: RastPort @ 0x%p\n", DrawBackGround_RastPort));
790 if ((retVal = DoMethod(data->iwcd_IconWindow, MUIM_IconWindow_BackFill_DrawBackground, XGET(data->iwcd_IconWindow, MUIA_IconWindow_BackFillData), &DrawBackGround_BackFillMsg, DrawBackGround_RastPort)) == (IPTR)TRUE)
792 D(bug("[IconWindow] IconWindowIconList__MUIM_DrawBackground: Backfill module rendered background ..\n"));
793 return retVal;
795 D(bug("[IconWindow] IconWindowIconList__MUIM_DrawBackground: Backfill module failed to render background ..\n"));
797 iwc_ParentBackground:
799 clip = MUI_AddClipping(muiRenderInfo(self), message->left, message->top, message->width, message->height);
801 message->width = _mwidth(self);
802 message->height = _mheight(self);
803 message->left = _mleft(self);
804 message->top = _mtop(self);
806 retVal = DoSuperMethodA(CLASS, self, (Msg) message);
808 MUI_RemoveClipping(muiRenderInfo(self),clip);
810 return retVal;
813 IPTR IconWindowIconList__MUIM_IconList_Update
815 Class *CLASS, Object *self, struct MUIP_IconList_Update *message
818 SETUP_INST_DATA;
820 IPTR retVal = (IPTR)TRUE;
822 if ((BOOL)XGET(_win(self), MUIA_IconWindow_IsRoot))
824 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_IconList_Update: (ROOT WINDOW) Causing parent to update\n"));
825 retVal = DoSuperMethodA(CLASS, self, (Msg) message);
827 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_IconList_Update: Check if we should show NetworkBrowser Icon ..\n"));
829 Object *prefs = NULL;
830 BOOL sort_list = FALSE;
832 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
834 if (prefs)
836 struct IconWindowIconVolumeList_DATA *volumel_data = (struct IconWindowIconVolumeList_DATA *)data;
838 GET(prefs, MUIA_IconWindowExt_NetworkBrowser_Show, &volumel_data->iwvcd_ShowNetworkBrowser);
840 #if defined(DEBUG_NETWORKBROWSER)
841 volumel_data->iwvcd_ShowNetworkBrowser = TRUE;
842 #endif
844 if (volumel_data->iwvcd_ShowNetworkBrowser)
846 struct DiskObject *_nb_dob = NULL;
847 _nb_dob = GetIconTags
849 "ENV:SYS/def_NetworkHost",
850 ICONGETA_FailIfUnavailable, FALSE,
851 ICONGETA_Label, (IPTR)"Network Access..",
852 TAG_DONE
855 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_IconList_Update: NetworkBrowser Icon DOB @ 0x%p\n", _nb_dob));
857 if (_nb_dob)
859 struct Node *this_entry = NULL;
860 if (this_entry = DoMethod(self, MUIM_IconList_CreateEntry, (IPTR)"?wanderer.networkbrowse?", (IPTR)"Network Access..", (IPTR)NULL, (IPTR)_nb_dob))
862 this_entry->ln_Pri = 3; /// Network Access gets Priority 3 so its displayed after special dirs
863 sort_list = TRUE;
864 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_IconList_Update: NetworkBrowser Icon Entry @ 0x%p\n", this_entry));
869 GET(prefs, MUIA_IconWindowExt_UserFiles_ShowFilesFolder, &volumel_data->iwvcd_ShowUserFolder);
871 #if defined(DEBUG_SHOWUSERFILES)
872 volumel_data->iwvcd_ShowUserFolder = TRUE;
873 #endif
874 if (volumel_data->iwvcd_ShowUserFolder)
876 if (GetVar("SYS/UserFilesLocation", __icwc_intern_TxtBuff, TXTBUFF_LEN, GVF_GLOBAL_ONLY) != -1)
878 char * userfiles_path = NULL;
880 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_IconList_Update: SYS/UserFilesLocation = '%s'\n", __icwc_intern_TxtBuff));
882 if ((userfiles_path = AllocVec(strlen(__icwc_intern_TxtBuff) + 1, MEMF_CLEAR|MEMF_PUBLIC)) != NULL)
884 struct DiskObject *_nb_dob = NULL;
886 volumel_data->iwvcd_UserFolderPath = userfiles_path;
888 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_IconList_Update: UserFilesLocation Path storage @ 0x%p\n", userfiles_path));
890 strcpy(userfiles_path, __icwc_intern_TxtBuff);
892 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_IconList_Update: UserFilesLocation Path storage contains '%s'\n", userfiles_path));
894 _nb_dob = GetIconTags
896 "ENV:SYS/def_UserHome",
897 ICONGETA_FailIfUnavailable, FALSE,
898 ICONGETA_Label, (IPTR)"User Files..",
899 TAG_DONE
902 D(bug("[IconWindowIconList] IconWindowIconList__MUIM_Window_Setup: UserFiles Icon DOB @ 0x%p\n", _nb_dob));
904 if (_nb_dob)
906 struct Node *this_entry = NULL;
907 if (this_entry = DoMethod(self, MUIM_IconList_CreateEntry, userfiles_path, (IPTR)"User Files..", (IPTR)NULL, (IPTR)_nb_dob))
909 this_entry->ln_Pri = 5; /// Special dirs get Priority 5
910 sort_list = TRUE;
916 if (sort_list) DoMethod(self, MUIM_IconList_Sort);
919 else
921 retVal = TRUE;
922 DoMethod(self, MUIM_IconList_Clear);
925 return retVal;
928 /*** Setup ******************************************************************/
929 ICONWINDOWICONDRAWERLIST_CUSTOMCLASS
931 IconWindowIconDrawerList, IconWindowIconList, NULL, MUIC_IconDrawerList, NULL,
932 OM_NEW, struct opSet *,
933 OM_SET, struct opSet *,
934 OM_GET, struct opGet *,
935 MUIM_Setup, Msg,
936 MUIM_Cleanup, Msg,
937 MUIM_DrawBackground, Msg
940 ICONWINDOWICONVOLUMELIST_CUSTOMCLASS
942 IconWindowIconVolumeList, IconWindowIconList, NULL, MUIC_IconVolumeList, NULL,
943 OM_NEW, struct opSet *,
944 OM_SET, struct opSet *,
945 OM_GET, struct opGet *,
946 MUIM_Setup, Msg,
947 MUIM_Cleanup, Msg,
948 MUIM_DrawBackground, Msg,
949 MUIM_HandleEvent, Msg,
950 MUIM_IconList_Update, struct MUIP_IconList_Update *
953 ICONWINDOWICONNETWORKBROWSERLIST_CUSTOMCLASS
955 IconWindowIconNetworkBrowserList, IconWindowIconList, NULL, MUIC_IconList, NULL,
956 OM_NEW, struct opSet *,
957 OM_SET, struct opSet *,
958 OM_GET, struct opGet *,
959 MUIM_Setup, Msg,
960 MUIM_Cleanup, Msg,
961 MUIM_DrawBackground, Msg,
962 MUIM_HandleEvent, Msg,
963 MUIM_IconList_Update, struct MUIP_IconList_Update *