IconWindowVolumeList, IconWindowDrawerList - react to preference changes on MUIA_Icon...
[AROS.git] / workbench / system / Wanderer / iconwindow_drawerlist.c
blobce729dec235ddec39fa0728c1e2923eb10071374
1 /*
2 Copyright 2004-2009, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define ZCC_QUIET
8 #include "portable_macros.h"
10 #ifdef __AROS__
11 #define MUIMASTER_YES_INLINE_STDARG
12 #endif
14 #define TXTBUFF_LEN 1024
16 #ifdef __AROS__
17 #define DEBUG 0
18 #include <aros/debug.h>
19 #endif
21 #include <exec/types.h>
22 #include <libraries/mui.h>
24 #ifdef __AROS__
25 #include <zune/customclasses.h>
26 #else
27 #include <zune_AROS/customclasses.h>
28 #endif
31 #include <proto/utility.h>
33 #include <proto/graphics.h>
34 #include <proto/exec.h>
35 #include <proto/datatypes.h>
36 #include <proto/icon.h>
38 #include <dos/dos.h>
39 #include <proto/dos.h>
41 #include <stdio.h>
42 #include <string.h>
44 #include <intuition/screens.h>
45 #include <datatypes/pictureclass.h>
46 #include <clib/macros.h>
48 #if defined(__AMIGA__) && !defined(__PPC__)
49 #define NO_INLINE_STDARG
50 #endif
51 #ifndef _PROTO_INTUITION_H
52 #include <proto/intuition.h>
53 #endif
54 #include <proto/muimaster.h>
56 #include "Classes/iconlist.h"
57 #include "Classes/iconlist_attributes.h"
58 #include "Classes/icon_attributes.h"
60 #include "wanderer.h"
61 #include "wandererprefs.h"
62 #include "iconwindow.h"
63 #include "iconwindow_iconlist.h"
66 #ifndef __AROS__
67 #define DEBUG 1
69 #ifdef DEBUG
70 #define D(x) if (DEBUG) x
71 #ifdef __amigaos4__
72 #define bug DebugPrintF
73 #else
74 #define bug kprintf
75 #endif
76 #else
77 #define D(...)
78 #endif
79 #endif
81 extern struct IconWindow_BackFill_Descriptor *iconwindow_BackFill_Active;
83 #define WIWDLVERS 1
84 #define WIWDLREV 0
86 #define BG_DRAWFLAG 0xf00dd00f
88 /*** Instance Data **********************************************************/
90 struct IconWindowDrawerList_DATA
92 Object *iwidld_IconWindow;
93 struct RastPort *iwidld_RastPort;
94 struct MUI_EventHandlerNode iwidld_EventHandlerNode;
95 #ifdef __AROS__
96 struct Hook iwidld_ProcessIconListPrefs_hook;
97 #else
98 struct Hook *iwidld_ProcessIconListPrefs_hook;
99 #endif
101 IPTR iwidld_ViewPrefs_ID;
102 Object *iwidld_ViewPrefs_NotificationObject;
104 /* File System update handling */
105 struct Wanderer_FSHandler iwidld_FSHandler;
106 struct NotifyRequest iwidld_DrawerNotifyRequest;
107 ULONG iwidld_LastRefresh; /* In seconds */
108 BOOL iwidld_FSChanged;
111 // static char __icwc_intern_TxtBuff[TXTBUFF_LEN];
113 /*** Macros *****************************************************************/
114 #define SETUP_INST_DATA struct IconWindowDrawerList_DATA *data = INST_DATA(CLASS, self)
116 /*** Hook functions *********************************************************/
117 ///IconWindowDrawerList__HookFunc_ProcessIconListPrefsFunc()
118 #ifdef __AROS__
119 AROS_UFH3(
120 void, IconWindowDrawerList__HookFunc_ProcessIconListPrefsFunc,
121 AROS_UFHA(struct Hook *, hook, A0),
122 AROS_UFHA(APTR *, obj, A2),
123 AROS_UFHA(IPTR *, param, A1)
126 #else
127 HOOKPROTO(IconWindowDrawerList__HookFunc_ProcessIconListPrefsFunc, void, APTR *obj, IPTR *param)
129 #endif
130 AROS_USERFUNC_INIT
132 /* Get our private data */
133 Object *self = ( Object *)obj;
134 IPTR CHANGED_ATTRIB = *param;
135 Class *CLASS = OCLASS(self);
137 SETUP_INST_DATA;
139 Object *prefs = NULL;
141 D(bug("[Wanderer:DrawerList]: %s()\n", __PRETTY_FUNCTION__));
143 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
145 if (prefs)
147 IPTR attrib_Current = 0, attrib_Prefs, prefs_Processing = 0;
148 BOOL options_changed = FALSE;
150 D(bug("[Wanderer:DrawerList] %s: Setting IconList options ..\n", __PRETTY_FUNCTION__));
152 GET(prefs, MUIA_WandererPrefs_Processing, &prefs_Processing);
154 switch (CHANGED_ATTRIB)
156 case MUIA_IconList_IconListMode:
157 GET(self, MUIA_IconList_IconListMode, &attrib_Current);
159 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_IconListMode)) != -1) &&
160 (attrib_Current != attrib_Prefs))
162 D(bug("[Wanderer:DrawerList] %s: IconList ListMode changed - updating ..\n", __PRETTY_FUNCTION__));
163 options_changed = TRUE;
164 if (prefs_Processing)
166 NNSET(self, MUIA_IconList_IconListMode, attrib_Prefs);
168 else
170 SET(self, MUIA_IconList_IconListMode, attrib_Prefs);
173 break;
175 case MUIA_IconList_LabelText_Mode:
176 GET(self, MUIA_IconList_LabelText_Mode, &attrib_Current);
178 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_Mode)) != -1) &&
179 (attrib_Current != attrib_Prefs))
181 D(bug("[Wanderer:DrawerList] %s: IconList TextRenderMode changed - updating ..\n", __PRETTY_FUNCTION__));
182 options_changed = TRUE;
183 if (prefs_Processing)
185 NNSET(self, MUIA_IconList_LabelText_Mode, attrib_Prefs);
187 else
189 SET(self, MUIA_IconList_LabelText_Mode, attrib_Prefs);
192 break;
194 case MUIA_IconList_LabelText_MaxLineLen:
195 GET(self, MUIA_IconList_LabelText_MaxLineLen, &attrib_Current);
197 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_MaxLineLen)) != -1) &&
198 (attrib_Current != attrib_Prefs))
200 D(bug("[Wanderer:DrawerList] %s: IconList Max Text Length changed - updating ..\n", __PRETTY_FUNCTION__));
201 options_changed = TRUE;
202 if (prefs_Processing)
204 NNSET(self, MUIA_IconList_LabelText_MaxLineLen, attrib_Prefs);
206 else
208 SET(self, MUIA_IconList_LabelText_MaxLineLen, attrib_Prefs);
211 break;
213 case MUIA_IconList_LabelText_MultiLine:
214 GET(self, MUIA_IconList_LabelText_MultiLine, &attrib_Current);
216 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_MultiLine)) != -1) &&
217 (attrib_Current != attrib_Prefs))
219 D(bug("[Wanderer:DrawerList] %s: IconList Multi-Line changed - updating ..\n", __PRETTY_FUNCTION__));
220 options_changed = TRUE;
221 if (prefs_Processing)
223 NNSET(self, MUIA_IconList_LabelText_MultiLine, attrib_Prefs);
225 else
227 SET(self, MUIA_IconList_LabelText_MultiLine, attrib_Prefs);
230 break;
232 case MUIA_IconList_LabelText_MultiLineOnFocus:
233 GET(self, MUIA_IconList_LabelText_MultiLineOnFocus, &attrib_Current);
235 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_MultiLineOnFocus)) != -1) &&
236 (attrib_Current != attrib_Prefs))
238 D(bug("[Wanderer:DrawerList] %s: Multi-Line on Focus changed - updating ..\n", __PRETTY_FUNCTION__));
239 options_changed = TRUE;
240 if (prefs_Processing)
242 NNSET(self, MUIA_IconList_LabelText_MultiLineOnFocus, attrib_Prefs);
244 else
246 SET(self, MUIA_IconList_LabelText_MultiLineOnFocus, attrib_Prefs);
249 break;
251 case MUIA_IconList_Icon_HorizontalSpacing:
252 GET(self, MUIA_IconList_Icon_HorizontalSpacing, &attrib_Current);
254 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_Icon_HorizontalSpacing)) != -1) &&
255 (attrib_Current != attrib_Prefs))
257 D(bug("[Wanderer:DrawerList] %s: Icon Horizontal Spacing changed - updating ..\n", __PRETTY_FUNCTION__));
258 options_changed = TRUE;
259 if (prefs_Processing)
261 NNSET(self, MUIA_IconList_Icon_HorizontalSpacing, attrib_Prefs);
263 else
265 SET(self, MUIA_IconList_Icon_HorizontalSpacing, attrib_Prefs);
268 break;
270 case MUIA_IconList_Icon_VerticalSpacing:
271 GET(self, MUIA_IconList_Icon_VerticalSpacing, &attrib_Current);
273 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_Icon_VerticalSpacing)) != -1) &&
274 (attrib_Current != attrib_Prefs))
276 D(bug("[Wanderer:DrawerList] %s: Icon Vertical Spacing changed - updating ..\n", __PRETTY_FUNCTION__));
277 options_changed = TRUE;
278 if (prefs_Processing)
280 NNSET(self, MUIA_IconList_Icon_VerticalSpacing, attrib_Prefs);
282 else
284 SET(self, MUIA_IconList_Icon_VerticalSpacing, attrib_Prefs);
287 break;
289 case MUIA_IconList_Icon_ImageSpacing:
290 GET(self, MUIA_IconList_Icon_ImageSpacing, &attrib_Current);
292 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_Icon_ImageSpacing)) != -1) &&
293 (attrib_Current != attrib_Prefs))
295 D(bug("[Wanderer:DrawerList] %s: Icon Label Image Spacing changed - updating ..\n", __PRETTY_FUNCTION__));
296 options_changed = TRUE;
297 if (prefs_Processing)
299 NNSET(self, MUIA_IconList_Icon_ImageSpacing, attrib_Prefs);
301 else
303 SET(self, MUIA_IconList_Icon_ImageSpacing, attrib_Prefs);
306 break;
308 case MUIA_IconList_LabelText_HorizontalPadding:
309 GET(self, MUIA_IconList_LabelText_HorizontalPadding, &attrib_Current);
311 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_HorizontalPadding)) != -1) &&
312 (attrib_Current != attrib_Prefs))
314 D(bug("[Wanderer:DrawerList] %s: Icon Label Horizontal Padding changed - updating ..\n", __PRETTY_FUNCTION__));
315 options_changed = TRUE;
316 if (prefs_Processing)
318 NNSET(self, MUIA_IconList_LabelText_HorizontalPadding, attrib_Prefs);
320 else
322 SET(self, MUIA_IconList_LabelText_HorizontalPadding, attrib_Prefs);
325 break;
327 case MUIA_IconList_LabelText_VerticalPadding:
328 GET(self, MUIA_IconList_LabelText_VerticalPadding, &attrib_Current);
330 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_VerticalPadding)) != -1) &&
331 (attrib_Current != attrib_Prefs))
333 D(bug("[Wanderer:DrawerList] %s: Icon Label Vertical Padding changed - updating ..\n", __PRETTY_FUNCTION__));
334 options_changed = TRUE;
335 if (prefs_Processing)
337 NNSET(self, MUIA_IconList_LabelText_VerticalPadding, attrib_Prefs);
339 else
341 SET(self, MUIA_IconList_LabelText_VerticalPadding, attrib_Prefs);
344 break;
346 case MUIA_IconList_LabelText_BorderWidth:
347 GET(self, MUIA_IconList_LabelText_BorderWidth, &attrib_Current);
349 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_BorderWidth)) != -1) &&
350 (attrib_Current != attrib_Prefs))
352 D(bug("[Wanderer:DrawerList] %s: Icon Label Border Width changed - updating ..\n", __PRETTY_FUNCTION__));
353 options_changed = TRUE;
354 if (prefs_Processing)
356 NNSET(self, MUIA_IconList_LabelText_BorderWidth, attrib_Prefs);
358 else
360 SET(self, MUIA_IconList_LabelText_BorderWidth, attrib_Prefs);
363 break;
365 case MUIA_IconList_LabelText_BorderHeight:
366 GET(self, MUIA_IconList_LabelText_BorderHeight, &attrib_Current);
368 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_BorderHeight)) != -1) &&
369 (attrib_Current != attrib_Prefs))
371 D(bug("[Wanderer:DrawerList] %s: Icon Label Border Height changed - updating ..\n", __PRETTY_FUNCTION__));
372 options_changed = TRUE;
373 if (prefs_Processing)
375 NNSET(self, MUIA_IconList_LabelText_BorderHeight, attrib_Prefs);
377 else
379 SET(self, MUIA_IconList_LabelText_BorderHeight, attrib_Prefs);
382 case MUIA_IconList_DragImageTransparent:
383 case MUIA_IconList_SortFlags:
384 /* Generic code */
385 GET(self, (ULONG)CHANGED_ATTRIB, &attrib_Current);
387 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, (ULONG)CHANGED_ATTRIB)) != -1) &&
388 (attrib_Current != attrib_Prefs))
390 options_changed = TRUE;
391 if (prefs_Processing)
393 NNSET(self, (ULONG)CHANGED_ATTRIB, attrib_Prefs);
395 else
397 SET(self, (ULONG)CHANGED_ATTRIB, attrib_Prefs);
400 break;
402 default:
403 D(bug("[Wanderer:DrawerList] %s: Unhandled change\n", __PRETTY_FUNCTION__));
404 break;
407 if (options_changed)
409 if (!(prefs_Processing))
411 D(bug("[Wanderer:DrawerList] %s: IconList Options have changed, causing an update ..\n", __PRETTY_FUNCTION__));
412 DoMethod(self, MUIM_IconList_Update);
413 DoMethod(self, MUIM_IconList_Sort);
415 else if (data->iwidld_IconWindow)
417 SET(data->iwidld_IconWindow, MUIA_IconWindow_Changed, TRUE);
421 AROS_USERFUNC_EXIT
423 #ifndef __AROS__
424 MakeStaticHook(Hook_ProcessIconListPrefsFunc, IconWindowDrawerList__HookFunc_ProcessIconListPrefsFunc);
425 #endif
429 /*** Methods ****************************************************************/
430 ///OM_NEW()
431 Object *IconWindowDrawerList__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
433 IPTR _newIconList__FSNotifyPort = 0;
435 D(bug("[Wanderer:DrawerList]: %s()\n", __PRETTY_FUNCTION__));
437 _newIconList__FSNotifyPort = GetTagData(MUIA_Wanderer_FileSysNotifyPort, (IPTR) NULL, message->ops_AttrList);
439 self = (Object *) DoSuperNewTags
441 CLASS, self, NULL,
442 MUIA_CycleChain, 1,
443 TAG_MORE, (IPTR) message->ops_AttrList
446 if (self != NULL)
448 SETUP_INST_DATA;
449 D(bug("[Wanderer:DrawerList] %s: SELF @ 0x%p\n", __PRETTY_FUNCTION__, self));
451 #ifdef __AROS__
452 data->iwidld_ProcessIconListPrefs_hook.h_Entry = ( HOOKFUNC )IconWindowDrawerList__HookFunc_ProcessIconListPrefsFunc;
453 #else
454 data->iwidld_ProcessIconListPrefs_hook = &Hook_ProcessIconListPrefsFunc;
455 #endif
457 if (_newIconList__FSNotifyPort != 0)
459 struct IconWindowDrawerList_DATA *drawerlist_data = (struct IconWindowDrawerList_DATA *)data;
460 drawerlist_data->iwidld_DrawerNotifyRequest.nr_stuff.nr_Msg.nr_Port = (struct MsgPort *)_newIconList__FSNotifyPort;
461 D(bug("[Wanderer:DrawerList] %s: FS Notify Port @ 0x%p\n", __PRETTY_FUNCTION__, _newIconList__FSNotifyPort));
465 return self;
469 IPTR IconWindowDrawerList__HandleFSUpdate(Object * iconwindow, struct NotifyMessage *msg)
471 return DoMethod(iconwindow, MUIM_IconWindowDrawerList_FileSystemChanged);
474 ULONG GetCurrentTimeInSeconds()
476 struct DateStamp stamp;
478 DateStamp(&stamp);
480 return (stamp.ds_Days * 60 * 60 * 24) + (stamp.ds_Minute * 60) + (stamp.ds_Tick / 50);
483 VOID RemoveFSNotification(struct IconWindowDrawerList_DATA *data)
485 if (data->iwidld_DrawerNotifyRequest.nr_Name != NULL)
487 D(bug("[Wanderer:DrawerList] %s: Removing Drawer FS Notification Request\n", __PRETTY_FUNCTION__));
488 /* EndNotify also replies all already send messages, so they won't end up hitting dead space in handler->HandleFSUpdate */
489 EndNotify(&data->iwidld_DrawerNotifyRequest);
490 FreeVec(data->iwidld_DrawerNotifyRequest.nr_Name);
491 data->iwidld_DrawerNotifyRequest.nr_Name = NULL;
492 data->iwidld_FSHandler.fshn_Node.ln_Name = NULL;
496 VOID UpdateFSNotification(STRPTR directory_path, struct IconWindowDrawerList_DATA *data, APTR target)
498 /* Remove existing if present */
499 RemoveFSNotification(data);
501 /* Setup new */
502 if (directory_path != NULL)
504 if (data->iwidld_DrawerNotifyRequest.nr_stuff.nr_Msg.nr_Port != NULL)
506 data->iwidld_FSHandler.target = target;
507 data->iwidld_FSHandler.HandleFSUpdate = IconWindowDrawerList__HandleFSUpdate;
508 data->iwidld_DrawerNotifyRequest.nr_Name = StrDup(directory_path);
509 data->iwidld_DrawerNotifyRequest.nr_Flags = NRF_SEND_MESSAGE;
510 data->iwidld_DrawerNotifyRequest.nr_UserData = (IPTR)&data->iwidld_FSHandler;
511 data->iwidld_LastRefresh = GetCurrentTimeInSeconds();
512 data->iwidld_FSChanged = FALSE;
513 data->iwidld_FSHandler.fshn_Node.ln_Name = data->iwidld_DrawerNotifyRequest.nr_Name;
515 if (StartNotify(&data->iwidld_DrawerNotifyRequest))
517 D(bug("[Wanderer:DrawerList] %s: Drawer-notification setup on '%s'\n", __PRETTY_FUNCTION__, directory_path));
519 else
521 D(bug("[Wanderer:DrawerList] %s: FAILED to setup Drawer-notification on '%s'!\n", __PRETTY_FUNCTION__, directory_path));
522 FreeVec(data->iwidld_DrawerNotifyRequest.nr_Name);
523 data->iwidld_DrawerNotifyRequest.nr_Name = NULL;
524 data->iwidld_FSHandler.fshn_Node.ln_Name = NULL;
530 ///OM_SET()
531 IPTR IconWindowDrawerList__OM_SET(Class *CLASS, Object *self, struct opSet *message)
533 SETUP_INST_DATA;
535 struct TagItem *tstate = message->ops_AttrList, *tag;
537 while ((tag = NextTagItem((const struct TagItem**)&tstate)) != NULL)
539 switch (tag->ti_Tag)
541 case MUIA_Background:
543 D(bug("[Wanderer:DrawerList] %s: MUIA_Background\n", __PRETTY_FUNCTION__));
544 break;
546 case MUIA_IconWindow_Window:
548 D(bug("[Wanderer:DrawerList] %s: MUIA_IconWindow_Window @ %p\n", __PRETTY_FUNCTION__, tag->ti_Data));
549 data->iwidld_IconWindow = (Object *)tag->ti_Data;
550 break;
552 case MUIA_IconList_BufferRastport:
554 D(bug("[Wanderer:DrawerList] %s: MUIA_IconList_BufferRastport @ %p\n", __PRETTY_FUNCTION__, tag->ti_Data));
555 data->iwidld_RastPort = (struct RastPort *)tag->ti_Data;
556 break;
558 case MUIA_IconDrawerList_Drawer:
560 D(bug("[Wanderer:DrawerList] %s: MUIA_IconDrawerList_Drawer @ %p\n", __PRETTY_FUNCTION__, tag->ti_Data));
561 UpdateFSNotification((STRPTR)tag->ti_Data, data, self);
562 break; /* Fallthrough and handle this in parent class as well */
566 return DoSuperMethodA(CLASS, self, (Msg) message);
570 ///OM_GET()
571 IPTR IconWindowDrawerList__OM_GET(Class *CLASS, Object *self, struct opGet *message)
573 //SETUP_INST_DATA;
574 IPTR *store = message->opg_Storage;
575 IPTR rv = TRUE;
577 switch (message->opg_AttrID)
579 case MUIA_Version:
580 *store = (IPTR)WIWDLVERS;
581 break;
583 case MUIA_Revision:
584 *store = (IPTR)WIWDLREV;
585 break;
587 default:
588 rv = DoSuperMethodA(CLASS, self, (Msg) message);
591 return rv;
595 ///IconWindowDrawerList__MUIM_Setup()
596 IPTR IconWindowDrawerList__MUIM_Setup
598 Class *CLASS, Object *self, Msg message
601 SETUP_INST_DATA;
603 Object *prefs = NULL;
605 if (!DoSuperMethodA(CLASS, self, message)) return FALSE;
607 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
609 if (prefs)
611 /* Set our initial options */
612 IPTR attrib_Prefs;
614 GET(_win(self), MUIA_IconWindow_BackgroundAttrib, &data->iwidld_ViewPrefs_ID);
615 D(bug("[Wanderer:DrawerList] %s: Window Background = '%s'\n", __PRETTY_FUNCTION__, data->iwidld_ViewPrefs_ID));
616 data->iwidld_ViewPrefs_NotificationObject = (Object *)DoMethod(prefs,
617 MUIM_WandererPrefs_ViewSettings_GetNotifyObject,
618 data->iwidld_ViewPrefs_ID);
620 D(bug("[Wanderer:DrawerList] %s: Background Notification Obj @ 0x%p\n", __PRETTY_FUNCTION__, data->iwidld_ViewPrefs_NotificationObject));
622 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_IconListMode);
623 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_IconListMode))) SET(self, MUIA_IconList_IconListMode, attrib_Prefs);
625 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_Mode);
626 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_LabelText_Mode))) SET(self, MUIA_IconList_LabelText_Mode, attrib_Prefs);
628 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_SortFlags);
629 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_SortFlags))) SET(self, MUIA_IconList_SortFlags, attrib_Prefs);
631 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_DragImageTransparent);
632 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_DragImageTransparent))) SET(self, MUIA_IconList_DragImageTransparent, attrib_Prefs);
634 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_MaxLineLen);
635 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_LabelText_MaxLineLen))) SET(self, MUIA_IconList_LabelText_MaxLineLen, attrib_Prefs);
637 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_MultiLine);
638 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_LabelText_MultiLine))) SET(self, MUIA_IconList_LabelText_MultiLine, attrib_Prefs);
640 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_MultiLineOnFocus);
641 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_LabelText_MultiLineOnFocus))) SET(self, MUIA_IconList_LabelText_MultiLineOnFocus, attrib_Prefs);
643 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_Icon_HorizontalSpacing);
644 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_Icon_HorizontalSpacing))) SET(self, MUIA_IconList_Icon_HorizontalSpacing, attrib_Prefs);
646 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_Icon_VerticalSpacing);
647 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_Icon_VerticalSpacing))) SET(self, MUIA_IconList_Icon_VerticalSpacing, attrib_Prefs);
649 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_Icon_ImageSpacing);
650 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_Icon_ImageSpacing))) SET(self, MUIA_IconList_Icon_ImageSpacing, attrib_Prefs);
652 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_HorizontalPadding);
653 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_LabelText_HorizontalPadding))) SET(self, MUIA_IconList_LabelText_HorizontalPadding, attrib_Prefs);
655 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_VerticalPadding);
656 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_LabelText_VerticalPadding))) SET(self, MUIA_IconList_LabelText_VerticalPadding, attrib_Prefs);
658 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_BorderWidth);
659 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_LabelText_BorderWidth))) SET(self, MUIA_IconList_LabelText_BorderWidth, attrib_Prefs);
661 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_LabelText_BorderHeight);
662 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, MUIA_IconList_LabelText_BorderHeight))) SET(self, MUIA_IconList_LabelText_BorderHeight, attrib_Prefs);
664 /* Configure notifications incase they get updated =) */
665 DoMethod
667 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_IconListMode, MUIV_EveryTime,
668 (IPTR) self, 3,
669 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_IconListMode
672 DoMethod
674 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_Mode, MUIV_EveryTime,
675 (IPTR) self, 3,
676 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_LabelText_Mode
679 DoMethod
681 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_SortFlags, MUIV_EveryTime,
682 (IPTR) self, 3,
683 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_SortFlags
686 DoMethod
688 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_DragImageTransparent, MUIV_EveryTime,
689 (IPTR) self, 3,
690 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_DragImageTransparent
693 DoMethod
695 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_MaxLineLen, MUIV_EveryTime,
696 (IPTR) self, 3,
697 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_LabelText_MaxLineLen
700 DoMethod
702 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_MultiLine, MUIV_EveryTime,
703 (IPTR) self, 3,
704 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_LabelText_MultiLine
707 DoMethod
709 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_MultiLineOnFocus, MUIV_EveryTime,
710 (IPTR) self, 3,
711 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_LabelText_MultiLineOnFocus
714 DoMethod
716 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_Icon_HorizontalSpacing, MUIV_EveryTime,
717 (IPTR) self, 3,
718 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_Icon_HorizontalSpacing
721 DoMethod
723 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_Icon_VerticalSpacing, MUIV_EveryTime,
724 (IPTR) self, 3,
725 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_Icon_VerticalSpacing
728 DoMethod
730 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_Icon_ImageSpacing, MUIV_EveryTime,
731 (IPTR) self, 3,
732 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_Icon_ImageSpacing
735 DoMethod
737 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_HorizontalPadding, MUIV_EveryTime,
738 (IPTR) self, 3,
739 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_LabelText_HorizontalPadding
742 DoMethod
744 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_VerticalPadding, MUIV_EveryTime,
745 (IPTR) self, 3,
746 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_LabelText_VerticalPadding
749 DoMethod
751 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_BorderWidth, MUIV_EveryTime,
752 (IPTR) self, 3,
753 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_LabelText_BorderWidth
756 DoMethod
758 data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, MUIA_IconList_LabelText_BorderHeight, MUIV_EveryTime,
759 (IPTR) self, 3,
760 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)MUIA_IconList_LabelText_BorderHeight
764 /* Setup notification on the directory -------------------------------- */
765 STRPTR directory_path = NULL;
766 GET(self, MUIA_IconDrawerList_Drawer, &directory_path);
768 UpdateFSNotification(directory_path, data, self);
770 D(bug("[Wanderer:DrawerList] %s: Setup complete!\n", __PRETTY_FUNCTION__));
772 return TRUE;
776 ///IconWindowDrawerList__MUIM_Cleanup()
777 IPTR IconWindowDrawerList__MUIM_Cleanup
779 Class *CLASS, Object *self, Msg message
782 SETUP_INST_DATA;
784 Object *prefs = NULL;
786 D(bug("[Wanderer:DrawerList]: %s()\n", __PRETTY_FUNCTION__));
788 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
790 if (prefs)
792 DoMethod
794 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_IconListMode, (IPTR)self
797 DoMethod
799 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_Mode, (IPTR)self
802 DoMethod
804 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_SortFlags, (IPTR)self
807 DoMethod
809 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_DragImageTransparent, (IPTR)self
812 DoMethod
814 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_MaxLineLen, (IPTR)self
817 DoMethod
819 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_MultiLine, (IPTR)self
822 DoMethod
824 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_MultiLineOnFocus, (IPTR)self
827 DoMethod
829 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_Icon_HorizontalSpacing, (IPTR)self
832 DoMethod
834 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_Icon_VerticalSpacing, (IPTR)self
837 DoMethod
839 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_Icon_ImageSpacing, (IPTR)self
842 DoMethod
844 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_HorizontalPadding, (IPTR)self
847 DoMethod
849 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_VerticalPadding, (IPTR)self
852 DoMethod
854 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_BorderWidth, (IPTR)self
857 DoMethod
859 data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, MUIA_IconList_LabelText_BorderHeight, (IPTR)self
863 RemoveFSNotification(data);
865 return DoSuperMethodA(CLASS, self, message);
869 ///IconWindowDrawerList__MUIM_DrawBackground()
870 IPTR IconWindowDrawerList__MUIM_DrawBackground
872 Class *CLASS, Object *self, struct MUIP_DrawBackground *message
875 SETUP_INST_DATA;
877 IPTR retVal = (IPTR)TRUE;
878 IPTR clip = 0;
879 struct RastPort *DrawBackGround_RastPort;
880 struct IconWindowBackFillMsg DrawBackGround_BackFillMsg;
882 D(bug("[Wanderer:DrawerList]: %s()\n", __PRETTY_FUNCTION__));
884 if ((iconwindow_BackFill_Active == NULL) ||
885 (data->iwidld_IconWindow == NULL))
887 D(bug("[Wanderer:DrawerList] %s: No Backfill support/Window not set .. causing parent class to render\n", __PRETTY_FUNCTION__));
888 goto iwc_ParentBackground;
891 DrawBackGround_RastPort = _rp(self);
893 if ((data->iwidld_RastPort != NULL) && (DrawBackGround_RastPort != data->iwidld_RastPort))
895 DrawBackGround_RastPort = data->iwidld_RastPort;
897 DrawBackGround_BackFillMsg.AreaBounds.MinX = 0;
898 DrawBackGround_BackFillMsg.AreaBounds.MinY = 0;
899 DrawBackGround_BackFillMsg.AreaBounds.MaxX = _mwidth(self) - 1;
900 DrawBackGround_BackFillMsg.AreaBounds.MaxY = _mheight(self) - 1;
902 DrawBackGround_BackFillMsg.DrawBounds.MinX = message->left - _mleft(self);
903 DrawBackGround_BackFillMsg.DrawBounds.MinY = message->top - _mtop(self);
904 DrawBackGround_BackFillMsg.DrawBounds.MaxX = DrawBackGround_BackFillMsg.DrawBounds.MinX + message->width - 1;
905 DrawBackGround_BackFillMsg.DrawBounds.MaxY = DrawBackGround_BackFillMsg.DrawBounds.MinY + message->height - 1;
907 else
909 DrawBackGround_BackFillMsg.AreaBounds.MinX = _mleft(self);
910 DrawBackGround_BackFillMsg.AreaBounds.MinY = _mtop(self);
911 DrawBackGround_BackFillMsg.AreaBounds.MaxX = _mleft(self) + _mwidth(self) - 1;
912 DrawBackGround_BackFillMsg.AreaBounds.MaxY = _mtop(self) + _mheight(self) - 1;
914 DrawBackGround_BackFillMsg.DrawBounds.MinX = message->left;
915 DrawBackGround_BackFillMsg.DrawBounds.MinY = message->top;
916 DrawBackGround_BackFillMsg.DrawBounds.MaxX = message->left + message->width - 1;
917 DrawBackGround_BackFillMsg.DrawBounds.MaxY = message->top + message->height - 1;
920 DrawBackGround_BackFillMsg.Layer = DrawBackGround_RastPort->Layer;
922 /* Offset into source image (ala scroll bar position) */
923 DrawBackGround_BackFillMsg.OffsetX = message->xoffset;
924 DrawBackGround_BackFillMsg.OffsetY = message->yoffset;
926 D(bug("[Wanderer:DrawerList] %s: RastPort @ 0x%p\n", __PRETTY_FUNCTION__, DrawBackGround_RastPort));
928 if ((retVal = DoMethod(data->iwidld_IconWindow, MUIM_IconWindow_BackFill_DrawBackground, XGET(data->iwidld_IconWindow, MUIA_IconWindow_BackFillData), &DrawBackGround_BackFillMsg, DrawBackGround_RastPort)) == (IPTR)TRUE)
930 D(bug("[Wanderer:DrawerList] %s: Backfill module rendered background ..\n", __PRETTY_FUNCTION__));
931 return retVal;
933 D(bug("[Wanderer:DrawerList] %s: Backfill module failed to render background ..\n", __PRETTY_FUNCTION__));
935 iwc_ParentBackground:
937 clip = (IPTR)MUI_AddClipping(muiRenderInfo(self), message->left, message->top, message->width, message->height);
939 message->width = _mwidth(self);
940 message->height = _mheight(self);
941 message->left = _mleft(self);
942 message->top = _mtop(self);
944 retVal = DoSuperMethodA(CLASS, self, (Msg) message);
946 MUI_RemoveClipping(muiRenderInfo(self), (APTR)clip);
948 return retVal;
952 /// IconWindowDrawerList__MUIM_IconWindowDrawerList_FileSystemChanged
953 IPTR IconWindowDrawerList__MUIM_IconWindowDrawerList_FileSystemChanged
955 Class *CLASS, Object *self, Msg message
958 SETUP_INST_DATA;
960 data->iwidld_FSChanged = TRUE;
962 return DoMethod(self, MUIM_IconWindowIconList_RateLimitRefresh );
966 /// IconWindowDrawerList__MUIM_IconWindowIconList_RateLimitRefresh
967 IPTR IconWindowDrawerList__MUIM_IconWindowIconList_RateLimitRefresh
969 Class *CLASS, Object *self, Msg message
972 SETUP_INST_DATA;
973 ULONG current = 0;
975 if (!data->iwidld_FSChanged)
976 return (IPTR)FALSE;
978 current = GetCurrentTimeInSeconds();
980 if (data->iwidld_LastRefresh <= current - 3) /* At most every 3 seconds */
982 DoMethod(self, MUIM_IconList_Update);
983 DoMethod(self, MUIM_IconList_Sort);
984 /* Record finish time */
985 data->iwidld_LastRefresh = GetCurrentTimeInSeconds();
986 data->iwidld_FSChanged = FALSE;
987 return (IPTR)TRUE;
990 return (IPTR)FALSE;
994 /*** Setup ******************************************************************/
995 #ifdef __AROS__
996 ICONWINDOWICONDRAWERLIST_CUSTOMCLASS
998 IconWindowDrawerList, NULL, MUIC_IconDrawerList, NULL,
999 OM_NEW, struct opSet *,
1000 OM_SET, struct opSet *,
1001 OM_GET, struct opGet *,
1002 MUIM_Setup, Msg,
1003 MUIM_Cleanup, Msg,
1004 MUIM_DrawBackground, struct MUIP_DrawBackground *,
1005 MUIM_IconWindowDrawerList_FileSystemChanged, Msg,
1006 MUIM_IconWindowIconList_RateLimitRefresh, Msg
1008 #else
1009 ICONWINDOWICONDRAWERLIST_CUSTOMCLASS
1011 IconWindowDrawerList, NULL, NULL, IconDrawerList_Class,
1012 OM_NEW, struct opSet *,
1013 OM_SET, struct opSet *,
1014 OM_GET, struct opGet *,
1015 MUIM_Setup, Msg,
1016 MUIM_Cleanup, Msg,
1017 MUIM_DrawBackground, struct MUIP_DrawBackground *,
1018 MUIM_IconWindowDrawerList_FileSystemChanged, Msg,
1019 MUIM_IconWindowIconList_RateLimitRefresh, Msg
1021 #endif