revert between 56095 -> 55830 in arch
[AROS.git] / workbench / system / Wanderer / iconwindow_drawerlist.c
blob21a2fee314e61cafc5a0417445a425dbc700e309
1 /*
2 Copyright 2004-2011, 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 #define RESTORED_BIT (1 << 31)
90 /*** Instance Data **********************************************************/
92 struct IconWindowDrawerList_DATA
94 Object *iwidld_IconWindow;
95 struct RastPort *iwidld_RastPort;
96 struct MUI_EventHandlerNode iwidld_EventHandlerNode;
97 #ifdef __AROS__
98 struct Hook iwidld_ProcessIconListPrefs_hook;
99 #else
100 struct Hook *iwidld_ProcessIconListPrefs_hook;
101 #endif
103 IPTR iwidld_ViewPrefs_ID;
104 Object *iwidld_ViewPrefs_NotificationObject;
105 ULONG iwidld_RestoredSortFlags; /* Flags restored from icon */
106 ULONG iwidld_RestoredDisplayFlags;
108 /* File System update handling */
109 struct Wanderer_FSHandler iwidld_FSHandler;
110 struct NotifyRequest iwidld_DrawerNotifyRequest;
111 ULONG iwidld_LastRefresh; /* In seconds */
112 BOOL iwidld_FSChanged;
115 /*** Macros *****************************************************************/
116 #define SETUP_INST_DATA struct IconWindowDrawerList_DATA *data = INST_DATA(CLASS, self)
118 /*** Hook functions *********************************************************/
119 ///IconWindowDrawerList__HookFunc_ProcessIconListPrefsFunc()
120 #ifdef __AROS__
121 AROS_UFH3(
122 void, IconWindowDrawerList__HookFunc_ProcessIconListPrefsFunc,
123 AROS_UFHA(struct Hook *, hook, A0),
124 AROS_UFHA(APTR *, obj, A2),
125 AROS_UFHA(IPTR *, param, A1)
128 #else
129 HOOKPROTO(IconWindowDrawerList__HookFunc_ProcessIconListPrefsFunc, void, APTR *obj, IPTR *param)
131 #endif
132 AROS_USERFUNC_INIT
134 /* Get our private data */
135 Object *self = ( Object *)obj;
136 IPTR CHANGED_ATTRIB = *param;
137 Class *CLASS = OCLASS(self);
139 SETUP_INST_DATA;
141 Object *prefs = NULL;
143 D(bug("[Wanderer:DrawerList]: %s()\n", __PRETTY_FUNCTION__));
145 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
147 if (prefs)
149 IPTR attrib_Current = 0, attrib_Prefs, prefs_Processing = 0;
150 BOOL options_changed = FALSE;
152 D(bug("[Wanderer:DrawerList] %s: Setting IconList options ..\n", __PRETTY_FUNCTION__));
154 GET(prefs, MUIA_WandererPrefs_Processing, &prefs_Processing);
156 switch (CHANGED_ATTRIB)
158 case MUIA_IconList_DisplayFlags:
159 /* Special handling */
160 GET(self, MUIA_IconList_DisplayFlags, &attrib_Current);
161 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_DisplayFlags);
163 if (attrib_Prefs != (IPTR)-1)
165 if ((attrib_Current & ICONLIST_DISP_SHOWINFO) && !(attrib_Prefs & ICONLIST_DISP_SHOWINFO))
166 attrib_Current &= ~ICONLIST_DISP_SHOWINFO;
167 if (!(attrib_Current & ICONLIST_DISP_SHOWINFO) && (attrib_Prefs & ICONLIST_DISP_SHOWINFO))
168 attrib_Current |= ICONLIST_DISP_SHOWINFO;
170 options_changed = TRUE;
171 if (prefs_Processing)
173 NNSET(self, (ULONG)CHANGED_ATTRIB, attrib_Current);
175 else
177 SET(self, (ULONG)CHANGED_ATTRIB, attrib_Current);
181 break;
182 case MUIA_IconList_IconListMode:
183 case MUIA_IconList_LabelText_Mode:
184 case MUIA_IconList_LabelText_MaxLineLen:
185 case MUIA_IconList_LabelText_MultiLine:
186 case MUIA_IconList_LabelText_MultiLineOnFocus:
187 case MUIA_IconList_Icon_HorizontalSpacing:
188 case MUIA_IconList_Icon_VerticalSpacing:
189 case MUIA_IconList_Icon_ImageSpacing:
190 case MUIA_IconList_LabelText_HorizontalPadding:
191 case MUIA_IconList_LabelText_VerticalPadding:
192 case MUIA_IconList_LabelText_BorderWidth:
193 case MUIA_IconList_LabelText_BorderHeight:
194 case MUIA_IconList_DragImageTransparent:
195 case MUIA_IconList_SortFlags:
196 /* Generic code */
197 GET(self, (ULONG)CHANGED_ATTRIB, &attrib_Current);
199 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, (ULONG)CHANGED_ATTRIB)) != -1) &&
200 (attrib_Current != attrib_Prefs))
202 options_changed = TRUE;
203 if (prefs_Processing)
205 NNSET(self, (ULONG)CHANGED_ATTRIB, attrib_Prefs);
207 else
209 SET(self, (ULONG)CHANGED_ATTRIB, attrib_Prefs);
212 break;
214 default:
215 D(bug("[Wanderer:DrawerList] %s: Unhandled change\n", __PRETTY_FUNCTION__));
216 break;
219 if (options_changed)
221 if (!(prefs_Processing))
223 D(bug("[Wanderer:DrawerList] %s: IconList Options have changed, causing an update ..\n", __PRETTY_FUNCTION__));
224 DoMethod(self, MUIM_IconList_Update);
225 DoMethod(self, MUIM_IconList_Sort);
227 else if (data->iwidld_IconWindow)
229 SET(data->iwidld_IconWindow, MUIA_IconWindow_Changed, TRUE);
233 AROS_USERFUNC_EXIT
235 #ifndef __AROS__
236 MakeStaticHook(Hook_ProcessIconListPrefsFunc, IconWindowDrawerList__HookFunc_ProcessIconListPrefsFunc);
237 #endif
241 /*** Methods ****************************************************************/
242 ///OM_NEW()
243 Object *IconWindowDrawerList__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
245 IPTR _newIconList__FSNotifyPort = 0;
247 D(bug("[Wanderer:DrawerList]: %s()\n", __PRETTY_FUNCTION__));
249 _newIconList__FSNotifyPort = GetTagData(MUIA_Wanderer_FileSysNotifyPort, (IPTR) NULL, message->ops_AttrList);
251 self = (Object *) DoSuperNewTags
253 CLASS, self, NULL,
254 MUIA_CycleChain, 1,
255 TAG_MORE, (IPTR) message->ops_AttrList
258 if (self != NULL)
260 SETUP_INST_DATA;
261 D(bug("[Wanderer:DrawerList] %s: SELF @ 0x%p\n", __PRETTY_FUNCTION__, self));
263 #ifdef __AROS__
264 data->iwidld_ProcessIconListPrefs_hook.h_Entry = ( HOOKFUNC )IconWindowDrawerList__HookFunc_ProcessIconListPrefsFunc;
265 #else
266 data->iwidld_ProcessIconListPrefs_hook = &Hook_ProcessIconListPrefsFunc;
267 #endif
269 if (_newIconList__FSNotifyPort != 0)
271 struct IconWindowDrawerList_DATA *drawerlist_data = (struct IconWindowDrawerList_DATA *)data;
272 drawerlist_data->iwidld_DrawerNotifyRequest.nr_stuff.nr_Msg.nr_Port = (struct MsgPort *)_newIconList__FSNotifyPort;
273 D(bug("[Wanderer:DrawerList] %s: FS Notify Port @ 0x%p\n", __PRETTY_FUNCTION__, _newIconList__FSNotifyPort));
277 return self;
281 IPTR IconWindowDrawerList__HandleFSUpdate(Object * iconwindow, struct NotifyMessage *msg)
283 return DoMethod(iconwindow, MUIM_IconWindowDrawerList_FileSystemChanged);
286 ULONG GetCurrentTimeInSeconds()
288 struct DateStamp stamp;
290 DateStamp(&stamp);
292 return (stamp.ds_Days * 60 * 60 * 24) + (stamp.ds_Minute * 60) + (stamp.ds_Tick / 50);
295 VOID RemoveFSNotification(struct IconWindowDrawerList_DATA *data)
297 if (data->iwidld_DrawerNotifyRequest.nr_Name != NULL)
299 D(bug("[Wanderer:DrawerList] %s: Removing Drawer FS Notification Request\n", __PRETTY_FUNCTION__));
300 /* EndNotify also replies all already send messages, so they won't end up hitting dead space in handler->HandleFSUpdate */
301 EndNotify(&data->iwidld_DrawerNotifyRequest);
302 FreeVec(data->iwidld_DrawerNotifyRequest.nr_Name);
303 data->iwidld_DrawerNotifyRequest.nr_Name = NULL;
304 data->iwidld_FSHandler.fshn_Node.ln_Name = NULL;
308 VOID UpdateFSNotification(STRPTR directory_path, struct IconWindowDrawerList_DATA *data, APTR target)
310 /* Remove existing if present */
311 RemoveFSNotification(data);
313 /* Setup new */
314 if (directory_path != NULL)
316 if (data->iwidld_DrawerNotifyRequest.nr_stuff.nr_Msg.nr_Port != NULL)
318 data->iwidld_FSHandler.target = target;
319 data->iwidld_FSHandler.HandleFSUpdate = IconWindowDrawerList__HandleFSUpdate;
320 data->iwidld_DrawerNotifyRequest.nr_Name = StrDup(directory_path);
321 data->iwidld_DrawerNotifyRequest.nr_Flags = NRF_SEND_MESSAGE;
322 data->iwidld_DrawerNotifyRequest.nr_UserData = (IPTR)&data->iwidld_FSHandler;
323 data->iwidld_LastRefresh = GetCurrentTimeInSeconds();
324 data->iwidld_FSChanged = FALSE;
325 data->iwidld_FSHandler.fshn_Node.ln_Name = data->iwidld_DrawerNotifyRequest.nr_Name;
327 if (StartNotify(&data->iwidld_DrawerNotifyRequest))
329 D(bug("[Wanderer:DrawerList] %s: Drawer-notification setup on '%s'\n", __PRETTY_FUNCTION__, directory_path));
331 else
333 D(bug("[Wanderer:DrawerList] %s: FAILED to setup Drawer-notification on '%s'!\n", __PRETTY_FUNCTION__, directory_path));
334 FreeVec(data->iwidld_DrawerNotifyRequest.nr_Name);
335 data->iwidld_DrawerNotifyRequest.nr_Name = NULL;
336 data->iwidld_FSHandler.fshn_Node.ln_Name = NULL;
342 ///OM_SET()
343 IPTR IconWindowDrawerList__OM_SET(Class *CLASS, Object *self, struct opSet *message)
345 SETUP_INST_DATA;
347 struct TagItem *tstate = message->ops_AttrList, *tag;
349 while ((tag = NextTagItem(&tstate)) != NULL)
351 switch (tag->ti_Tag)
353 case MUIA_Background:
355 D(bug("[Wanderer:DrawerList] %s: MUIA_Background\n", __PRETTY_FUNCTION__));
356 break;
358 case MUIA_IconWindow_Window:
360 D(bug("[Wanderer:DrawerList] %s: MUIA_IconWindow_Window @ %p\n", __PRETTY_FUNCTION__, tag->ti_Data));
361 data->iwidld_IconWindow = (Object *)tag->ti_Data;
362 break;
364 case MUIA_IconList_BufferRastport:
366 D(bug("[Wanderer:DrawerList] %s: MUIA_IconList_BufferRastport @ %p\n", __PRETTY_FUNCTION__, tag->ti_Data));
367 data->iwidld_RastPort = (struct RastPort *)tag->ti_Data;
368 break;
370 case MUIA_IconDrawerList_Drawer:
372 D(bug("[Wanderer:DrawerList] %s: MUIA_IconDrawerList_Drawer @ %p\n", __PRETTY_FUNCTION__, tag->ti_Data));
373 UpdateFSNotification((STRPTR)tag->ti_Data, data, self);
374 break; /* Fallthrough and handle this in parent class as well */
376 case MUIA_IconWindowIconList_RestoredSortFlags:
377 data->iwidld_RestoredSortFlags = (tag->ti_Data | RESTORED_BIT);
378 break;
379 case MUIA_IconWindowIconList_RestoredDisplayFlags:
380 data->iwidld_RestoredDisplayFlags = (tag->ti_Data | RESTORED_BIT);
381 break;
384 return DoSuperMethodA(CLASS, self, (Msg) message);
388 ///OM_GET()
389 IPTR IconWindowDrawerList__OM_GET(Class *CLASS, Object *self, struct opGet *message)
391 //SETUP_INST_DATA;
392 IPTR *store = message->opg_Storage;
393 IPTR rv = TRUE;
395 switch (message->opg_AttrID)
397 case MUIA_Version:
398 *store = (IPTR)WIWDLVERS;
399 break;
401 case MUIA_Revision:
402 *store = (IPTR)WIWDLREV;
403 break;
405 default:
406 rv = DoSuperMethodA(CLASS, self, (Msg) message);
409 return rv;
413 #define SETFROMPREFS(tag) \
414 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, tag); \
415 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, tag))) SET(self, tag, attrib_Prefs);
417 #define ADDPREFSNTF(tag) \
418 DoMethod(data->iwidld_ViewPrefs_NotificationObject, MUIM_Notify, tag, MUIV_EveryTime, (IPTR) self, 3, \
419 MUIM_CallHook, &data->iwidld_ProcessIconListPrefs_hook, (IPTR)tag);
421 #define REMPREFSNTF(tag) \
422 DoMethod(data->iwidld_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, tag, (IPTR)self);
424 ///IconWindowDrawerList__MUIM_Setup()
425 IPTR IconWindowDrawerList__MUIM_Setup
427 Class *CLASS, Object *self, Msg message
430 SETUP_INST_DATA;
432 Object *prefs = NULL;
434 if (!DoSuperMethodA(CLASS, self, message)) return FALSE;
436 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
438 if (prefs)
440 /* Set our initial options */
441 IPTR attrib_Prefs;
443 GET(_win(self), MUIA_IconWindow_BackgroundAttrib, &data->iwidld_ViewPrefs_ID);
444 D(bug("[Wanderer:DrawerList] %s: Window Background = '%s'\n", __PRETTY_FUNCTION__, data->iwidld_ViewPrefs_ID));
445 data->iwidld_ViewPrefs_NotificationObject = (Object *)DoMethod(prefs,
446 MUIM_WandererPrefs_ViewSettings_GetNotifyObject,
447 data->iwidld_ViewPrefs_ID);
449 D(bug("[Wanderer:DrawerList] %s: Background Notification Obj @ 0x%p\n", __PRETTY_FUNCTION__, data->iwidld_ViewPrefs_NotificationObject));
451 SETFROMPREFS(MUIA_IconList_IconListMode);
452 SETFROMPREFS(MUIA_IconList_LabelText_Mode);
453 SETFROMPREFS(MUIA_IconList_SortFlags);
454 SETFROMPREFS(MUIA_IconList_DragImageTransparent);
455 SETFROMPREFS(MUIA_IconList_LabelText_MaxLineLen);
456 SETFROMPREFS(MUIA_IconList_LabelText_MultiLine);
457 SETFROMPREFS(MUIA_IconList_LabelText_MultiLineOnFocus);
458 SETFROMPREFS(MUIA_IconList_Icon_HorizontalSpacing);
459 SETFROMPREFS(MUIA_IconList_Icon_VerticalSpacing);
460 SETFROMPREFS(MUIA_IconList_Icon_ImageSpacing);
461 SETFROMPREFS(MUIA_IconList_LabelText_HorizontalPadding);
462 SETFROMPREFS(MUIA_IconList_LabelText_VerticalPadding);
463 SETFROMPREFS(MUIA_IconList_LabelText_BorderWidth);
464 SETFROMPREFS(MUIA_IconList_LabelText_BorderHeight);
466 /* Special handling */
467 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwidld_ViewPrefs_ID, MUIA_IconList_DisplayFlags);
468 if (attrib_Prefs != (IPTR)-1)
470 IPTR attrib_Current = XGET(self, MUIA_IconList_DisplayFlags);
471 if ((attrib_Current & ICONLIST_DISP_SHOWINFO) && !(attrib_Prefs & ICONLIST_DISP_SHOWINFO))
472 attrib_Current &= ~ICONLIST_DISP_SHOWINFO;
473 if (!(attrib_Current & ICONLIST_DISP_SHOWINFO) && (attrib_Prefs & ICONLIST_DISP_SHOWINFO))
474 attrib_Current |= ICONLIST_DISP_SHOWINFO;
475 SET(self, MUIA_IconList_DisplayFlags, attrib_Current);
479 /* Configure notifications incase they get updated =) */
480 ADDPREFSNTF(MUIA_IconList_IconListMode);
481 ADDPREFSNTF(MUIA_IconList_LabelText_Mode);
482 ADDPREFSNTF(MUIA_IconList_SortFlags);
483 ADDPREFSNTF(MUIA_IconList_DragImageTransparent);
484 ADDPREFSNTF(MUIA_IconList_DisplayFlags);
485 ADDPREFSNTF(MUIA_IconList_LabelText_MaxLineLen);
486 ADDPREFSNTF(MUIA_IconList_LabelText_MultiLine);
487 ADDPREFSNTF(MUIA_IconList_LabelText_MultiLineOnFocus);
488 ADDPREFSNTF(MUIA_IconList_Icon_HorizontalSpacing);
489 ADDPREFSNTF(MUIA_IconList_Icon_VerticalSpacing);
490 ADDPREFSNTF(MUIA_IconList_Icon_ImageSpacing);
491 ADDPREFSNTF(MUIA_IconList_LabelText_HorizontalPadding);
492 ADDPREFSNTF(MUIA_IconList_LabelText_VerticalPadding);
493 ADDPREFSNTF(MUIA_IconList_LabelText_BorderWidth);
494 ADDPREFSNTF(MUIA_IconList_LabelText_BorderHeight);
497 /* Handle information restores from icon, it overwrites the configuration settings */
498 if (data->iwidld_RestoredSortFlags & RESTORED_BIT)
500 ULONG sortFlags = data->iwidld_RestoredSortFlags;
501 sortFlags &= ~RESTORED_BIT;
502 SET(self, MUIA_IconList_SortFlags, sortFlags);
505 if (data->iwidld_RestoredDisplayFlags & RESTORED_BIT)
507 IPTR attrib_Current = XGET(self, MUIA_IconList_DisplayFlags);
509 attrib_Current &= ~(ICONLIST_DISP_MODE_MASK | ICONLIST_DISP_SHOWINFO);
510 attrib_Current |= (data->iwidld_RestoredDisplayFlags & (ICONLIST_DISP_MODE_MASK | ICONLIST_DISP_SHOWINFO));
512 SET(self, MUIA_IconList_DisplayFlags, attrib_Current);
515 /* Setup notification on the directory -------------------------------- */
516 STRPTR directory_path = NULL;
517 GET(self, MUIA_IconDrawerList_Drawer, &directory_path);
519 UpdateFSNotification(directory_path, data, self);
521 D(bug("[Wanderer:DrawerList] %s: Setup complete!\n", __PRETTY_FUNCTION__));
523 return TRUE;
527 ///IconWindowDrawerList__MUIM_Cleanup()
528 IPTR IconWindowDrawerList__MUIM_Cleanup
530 Class *CLASS, Object *self, Msg message
533 SETUP_INST_DATA;
535 Object *prefs = NULL;
537 D(bug("[Wanderer:DrawerList]: %s()\n", __PRETTY_FUNCTION__));
539 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
541 if (prefs)
543 REMPREFSNTF(MUIA_IconList_IconListMode);
544 REMPREFSNTF(MUIA_IconList_LabelText_Mode);
545 REMPREFSNTF(MUIA_IconList_SortFlags);
546 REMPREFSNTF(MUIA_IconList_DragImageTransparent);
547 REMPREFSNTF(MUIA_IconList_DisplayFlags);
548 REMPREFSNTF(MUIA_IconList_LabelText_MaxLineLen);
549 REMPREFSNTF(MUIA_IconList_LabelText_MultiLine);
550 REMPREFSNTF(MUIA_IconList_LabelText_MultiLineOnFocus);
551 REMPREFSNTF(MUIA_IconList_Icon_HorizontalSpacing);
552 REMPREFSNTF(MUIA_IconList_Icon_VerticalSpacing);
553 REMPREFSNTF(MUIA_IconList_Icon_ImageSpacing);
554 REMPREFSNTF(MUIA_IconList_LabelText_HorizontalPadding);
555 REMPREFSNTF(MUIA_IconList_LabelText_VerticalPadding);
556 REMPREFSNTF(MUIA_IconList_LabelText_BorderWidth);
557 REMPREFSNTF(MUIA_IconList_LabelText_BorderHeight);
560 RemoveFSNotification(data);
562 return DoSuperMethodA(CLASS, self, message);
566 ///IconWindowDrawerList__MUIM_DrawBackground()
567 IPTR IconWindowDrawerList__MUIM_DrawBackground
569 Class *CLASS, Object *self, struct MUIP_DrawBackground *message
572 SETUP_INST_DATA;
574 IPTR retVal = (IPTR)TRUE;
575 IPTR clip = 0;
576 struct RastPort *DrawBackGround_RastPort;
577 struct IconWindowBackFillMsg DrawBackGround_BackFillMsg;
579 D(bug("[Wanderer:DrawerList]: %s()\n", __PRETTY_FUNCTION__));
581 if ((iconwindow_BackFill_Active == NULL) ||
582 (data->iwidld_IconWindow == NULL))
584 D(bug("[Wanderer:DrawerList] %s: No Backfill support/Window not set .. causing parent class to render\n", __PRETTY_FUNCTION__));
585 goto iwc_ParentBackground;
588 DrawBackGround_RastPort = _rp(self);
590 if ((data->iwidld_RastPort != NULL) && (DrawBackGround_RastPort != data->iwidld_RastPort))
592 DrawBackGround_RastPort = data->iwidld_RastPort;
594 DrawBackGround_BackFillMsg.AreaBounds.MinX = 0;
595 DrawBackGround_BackFillMsg.AreaBounds.MinY = 0;
596 DrawBackGround_BackFillMsg.AreaBounds.MaxX = _mwidth(self) - 1;
597 DrawBackGround_BackFillMsg.AreaBounds.MaxY = _mheight(self) - 1;
599 DrawBackGround_BackFillMsg.DrawBounds.MinX = message->left - _mleft(self);
600 DrawBackGround_BackFillMsg.DrawBounds.MinY = message->top - _mtop(self);
601 DrawBackGround_BackFillMsg.DrawBounds.MaxX = DrawBackGround_BackFillMsg.DrawBounds.MinX + message->width - 1;
602 DrawBackGround_BackFillMsg.DrawBounds.MaxY = DrawBackGround_BackFillMsg.DrawBounds.MinY + message->height - 1;
604 else
606 DrawBackGround_BackFillMsg.AreaBounds.MinX = _mleft(self);
607 DrawBackGround_BackFillMsg.AreaBounds.MinY = _mtop(self);
608 DrawBackGround_BackFillMsg.AreaBounds.MaxX = _mleft(self) + _mwidth(self) - 1;
609 DrawBackGround_BackFillMsg.AreaBounds.MaxY = _mtop(self) + _mheight(self) - 1;
611 DrawBackGround_BackFillMsg.DrawBounds.MinX = message->left;
612 DrawBackGround_BackFillMsg.DrawBounds.MinY = message->top;
613 DrawBackGround_BackFillMsg.DrawBounds.MaxX = message->left + message->width - 1;
614 DrawBackGround_BackFillMsg.DrawBounds.MaxY = message->top + message->height - 1;
617 DrawBackGround_BackFillMsg.Layer = DrawBackGround_RastPort->Layer;
619 /* Offset into source image (ala scroll bar position) */
620 DrawBackGround_BackFillMsg.OffsetX = message->xoffset;
621 DrawBackGround_BackFillMsg.OffsetY = message->yoffset;
623 D(bug("[Wanderer:DrawerList] %s: RastPort @ 0x%p\n", __PRETTY_FUNCTION__, DrawBackGround_RastPort));
625 if ((retVal = DoMethod(data->iwidld_IconWindow, MUIM_IconWindow_BackFill_DrawBackground, XGET(data->iwidld_IconWindow, MUIA_IconWindow_BackFillData), &DrawBackGround_BackFillMsg, DrawBackGround_RastPort)) == (IPTR)TRUE)
627 D(bug("[Wanderer:DrawerList] %s: Backfill module rendered background ..\n", __PRETTY_FUNCTION__));
628 return retVal;
630 D(bug("[Wanderer:DrawerList] %s: Backfill module failed to render background ..\n", __PRETTY_FUNCTION__));
632 iwc_ParentBackground:
634 clip = (IPTR)MUI_AddClipping(muiRenderInfo(self), message->left, message->top, message->width, message->height);
636 message->width = _mwidth(self);
637 message->height = _mheight(self);
638 message->left = _mleft(self);
639 message->top = _mtop(self);
641 retVal = DoSuperMethodA(CLASS, self, (Msg) message);
643 MUI_RemoveClipping(muiRenderInfo(self), (APTR)clip);
645 return retVal;
649 /// IconWindowDrawerList__MUIM_IconWindowDrawerList_FileSystemChanged
650 IPTR IconWindowDrawerList__MUIM_IconWindowDrawerList_FileSystemChanged
652 Class *CLASS, Object *self, Msg message
655 SETUP_INST_DATA;
657 data->iwidld_FSChanged = TRUE;
659 return DoMethod(self, MUIM_IconWindowIconList_RateLimitRefresh );
663 /// IconWindowDrawerList__MUIM_IconWindowIconList_RateLimitRefresh
664 IPTR IconWindowDrawerList__MUIM_IconWindowIconList_RateLimitRefresh
666 Class *CLASS, Object *self, Msg message
669 SETUP_INST_DATA;
670 ULONG current = 0;
672 if (!data->iwidld_FSChanged)
673 return (IPTR)FALSE;
675 current = GetCurrentTimeInSeconds();
677 if (data->iwidld_LastRefresh <= current - 3) /* At most every 3 seconds */
679 DoMethod(self, MUIM_IconList_Update);
680 DoMethod(self, MUIM_IconList_Sort);
681 /* Record finish time */
682 data->iwidld_LastRefresh = GetCurrentTimeInSeconds();
683 data->iwidld_FSChanged = FALSE;
684 return (IPTR)TRUE;
687 return (IPTR)FALSE;
691 /*** Setup ******************************************************************/
692 #ifdef __AROS__
693 ICONWINDOWICONDRAWERLIST_CUSTOMCLASS
695 IconWindowDrawerList, NULL, MUIC_IconDrawerList, NULL,
696 OM_NEW, struct opSet *,
697 OM_SET, struct opSet *,
698 OM_GET, struct opGet *,
699 MUIM_Setup, Msg,
700 MUIM_Cleanup, Msg,
701 MUIM_DrawBackground, struct MUIP_DrawBackground *,
702 MUIM_IconWindowDrawerList_FileSystemChanged, Msg,
703 MUIM_IconWindowIconList_RateLimitRefresh, Msg
705 #else
706 ICONWINDOWICONDRAWERLIST_CUSTOMCLASS
708 IconWindowDrawerList, NULL, NULL, IconDrawerList_Class,
709 OM_NEW, struct opSet *,
710 OM_SET, struct opSet *,
711 OM_GET, struct opGet *,
712 MUIM_Setup, Msg,
713 MUIM_Cleanup, Msg,
714 MUIM_DrawBackground, struct MUIP_DrawBackground *,
715 MUIM_IconWindowDrawerList_FileSystemChanged, Msg,
716 MUIM_IconWindowIconList_RateLimitRefresh, Msg
718 #endif