bug: uses wrong list counter, which incurs an array overflow/undefined behaviour...
[AROS-Contrib.git] / libs / desktop / iconclass.c
blob9206a52651231d6c73aba8e6e54ec933ea897c27
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <exec/types.h>
9 #include <exec/memory.h>
10 #include <intuition/classes.h>
11 #include <intuition/intuition.h>
12 #include <intuition/classusr.h>
13 #include <intuition/imageclass.h>
14 #include <libraries/mui.h>
15 #include <workbench/workbench.h>
17 #include "support.h"
18 #include "worker.h"
19 #include "desktop_intern.h"
21 #include <proto/dos.h>
22 #include <proto/icon.h>
23 #include <proto/input.h>
24 #include <proto/muimaster.h>
25 #include <proto/intuition.h>
26 #include <proto/utility.h>
28 #include "presentation.h"
29 #include "iconcontainerclass.h"
30 #include "iconclass.h"
32 #include "desktop_intern_protos.h"
34 #include <string.h>
36 #define DEBUG 1
37 #include <aros/debug.h>
39 static ULONG DoSetupMethod(Object * obj, struct MUI_RenderInfo *info)
42 MUI set the correct render info *before* it calls MUIM_Setup so please
43 only use this function instead of DoMethodA()
45 muiRenderInfo(obj) = info;
47 return DoMethod(obj, MUIM_Setup, (IPTR) info);
50 IPTR iconNew(Class * cl, Object * obj, struct opSet * msg)
52 IPTR retval = 0;
53 struct IconClassData *data;
54 struct TagItem *tag,
55 *tstate = msg->ops_AttrList;
56 struct DiskObject *diskobject = NULL;
57 UBYTE *label = NULL;
58 BOOL selected = FALSE;
59 UBYTE viewMode = IAVM_LARGEICON;
60 struct DateStamp *lastChanged = NULL;
61 LONG type = 0;
62 ULONG size = 0;
63 Object *desktop = NULL;
65 while ((tag = NextTagItem(&tstate)) != NULL)
67 switch (tag->ti_Tag)
69 case IA_DiskObject:
70 diskobject = (struct DiskObject *) tag->ti_Data;
71 break;
73 case IA_Label:
74 label = (UBYTE *) tag->ti_Data;
75 break;
77 case IA_Selected:
78 selected = (BOOL) tag->ti_Data;
79 break;
81 case IA_ViewMode:
82 viewMode = (UBYTE) tag->ti_Data;
83 break;
85 case IA_Type:
86 type = (LONG) tag->ti_Data;
87 break;
89 case IA_Size:
90 size = (ULONG) tag->ti_Data;
91 break;
93 case IA_LastModified:
94 lastChanged = (struct DateStamp *) tag->ti_Data;
95 break;
97 case IA_Desktop:
98 desktop = (Object *) tag->ti_Data;
99 break;
101 default:
102 continue; /* Don't supress non-processed tags */
105 tag->ti_Tag = TAG_IGNORE;
108 retval = DoSuperMethodA(cl, obj, (Msg) msg);
110 if (retval)
112 obj = (Object *) retval;
113 data = INST_DATA(cl, obj);
114 data->diskObject = diskobject;
115 data->label = label;
116 data->selected = selected;
117 data->viewMode = viewMode;
118 data->type = type;
119 data->size = size;
120 if (lastChanged)
121 data->lastChanged = *lastChanged;
123 data->ehn.ehn_Priority = 10;
124 data->ehn.ehn_Flags = (1 << 1);
125 data->ehn.ehn_Object = obj;
126 data->ehn.ehn_Class = cl;
127 data->ehn.ehn_Events = IDCMP_MOUSEBUTTONS;
129 data->imagePart = NULL;
130 data->labelPart = NULL;
131 data->sizePart = NULL;
132 data->typePart = NULL;
133 data->lastModifiedPart = NULL;
134 data->whyRedraw = 0;
136 data->desktop = desktop;
139 return retval;
142 IPTR iconSet(Class * cl, Object * obj, struct opSet * msg)
144 struct IconClassData *data;
145 IPTR retval = 1;
146 struct TagItem *tag,
147 *tstate = msg->ops_AttrList;
149 data = (struct IconClassData *) INST_DATA(cl, obj);
151 while ((tag = NextTagItem(&tstate)))
153 switch (tag->ti_Tag)
155 case IA_Label:
156 SetAttrs(data->labelPart, MUIA_Text_Contents, tag->ti_Data,
157 TAG_END);
158 break;
159 case IA_Selected:
160 data->selected = tag->ti_Data;
161 data->whyRedraw =
162 SetAttrs(data->imagePart, MUIA_Selected, tag->ti_Data,
163 TAG_END);
164 break;
165 case IA_Executed:
166 break;
167 case IA_Directory:
168 // this is the same as moving a file
169 data->directory = (UBYTE *) tag->ti_Data;
170 break;
171 case IA_Type:
172 data->type = (LONG) tag->ti_Data;
173 break;
174 case IA_Size:
175 data->size = (ULONG) tag->ti_Data;
176 break;
177 case IA_LastModified:
178 data->lastChanged = *((struct DateStamp *) tag->ti_Data);
179 break;
180 case IA_ViewMode:
182 data->viewMode = (ULONG) tag->ti_Data;
183 if (data->viewMode == IAVM_DETAIL)
185 if (data->sizePart)
187 // muiNotifyData(data->sizePart)->mnd_ParentObject =
188 // obj;
189 // DoMethod(data->sizePart, MUIM_ConnectParent, obj);
190 // DoSetupMethod(data->sizePart, muiRenderInfo(obj));
192 if (data->typePart)
194 // muiNotifyData(data->typePart)->mnd_ParentObject =
195 // obj;
196 // DoMethod(data->typePart, MUIM_ConnectParent, obj);
197 // DoSetupMethod(data->typePart, muiRenderInfo(obj));
199 if (data->lastModifiedPart)
201 // muiNotifyData(data->lastModifiedPart)->mnd_ParentObject
202 // = obj;
203 // DoMethod(data->lastModifiedPart,
204 // MUIM_ConnectParent, obj);
205 // DoSetupMethod(data->lastModifiedPart,
206 // muiRenderInfo(obj));
209 else
211 if (data->sizePart)
213 // DoMethod(data->sizePart, MUIM_Cleanup);
214 // these should be disposed of....
215 // data->sizePart=NULL;
217 if (data->typePart)
219 // DoMethod(data->typePart, MUIM_Cleanup);
220 // data->typePart=NULL;
222 if (data->lastModifiedPart)
224 // DoMethod(data->lastModifiedPart, MUIM_Cleanup);
225 // data->lastModifiedPart=NULL;
229 break;
231 default:
232 break;
236 retval = DoSuperMethodA(cl, obj, (Msg) msg);
238 return retval;
241 IPTR iconGet(Class * cl, Object * obj, struct opGet * msg)
243 IPTR retval = 1;
244 struct IconClassData *data;
246 data = (struct IconClassData *) INST_DATA(cl, obj);
248 switch (msg->opg_AttrID)
250 case IA_Desktop:
251 *msg->opg_Storage = (ULONG) data->desktop;
252 break;
253 case IA_DiskObject:
254 *msg->opg_Storage = (ULONG) data->diskObject;
255 break;
256 case IA_Label:
257 *msg->opg_Storage = (ULONG) data->label;
258 break;
259 case IA_Selected:
260 *msg->opg_Storage = (ULONG) data->selected;
261 break;
262 case IA_Directory:
263 *msg->opg_Storage = (ULONG) data->directory;
264 break;
265 default:
266 retval = DoSuperMethodA(cl, obj, (Msg) msg);
267 break;
270 return retval;
273 IPTR iconDispose(Class * cl, Object * obj, Msg msg)
275 IPTR retval;
276 struct IconClassData *data;
278 data = (struct IconClassData *) INST_DATA(cl, obj);
280 retval = DoSuperMethodA(cl, obj, msg);
282 return retval;
285 IPTR iconHandleInput(Class * cl, Object * obj, struct MUIP_HandleInput * msg)
287 IPTR retval = 0;
288 struct IconClassData *data;
290 data = (struct IconClassData *) INST_DATA(cl, obj);
292 if (msg->imsg)
294 switch (msg->imsg->Class)
296 case IDCMP_MOUSEBUTTONS:
298 if (msg->imsg->Code == SELECTDOWN)
300 if (msg->imsg->MouseX >= _mleft(obj)
301 && msg->imsg->MouseX <= _mright(obj)
302 && msg->imsg->MouseY >= _mtop(obj)
303 && msg->imsg->MouseY <= _mbottom(obj))
305 ULONG nowSeconds = 0,
306 nowMicros = 0;
308 CurrentTime(&nowSeconds, &nowMicros);
310 if (data->selected)
312 if (DoubleClick
313 (data->lastClickSecs,
314 data->lastClickMicros, nowSeconds,
315 nowMicros))
317 SetAttrs(obj, IA_Executed, TRUE, TAG_END);
319 else
320 SetAttrs(obj, IA_Selected, TRUE, TAG_END);
322 else
323 SetAttrs(obj, IA_Selected, TRUE, TAG_END);
325 data->lastClickSecs = nowSeconds;
326 data->lastClickMicros = nowMicros;
328 else
330 if (data->selected == TRUE)
332 UWORD qualifiers;
334 qualifiers = PeekQualifier();
335 if (!
336 (qualifiers &
337 (IEQUALIFIER_LSHIFT |
338 IEQUALIFIER_RSHIFT)))
339 SetAttrs(obj, IA_Selected, FALSE,
340 TAG_END);
344 break;
346 default:
347 retval = DoSuperMethodA(cl, obj, (Msg) msg);
348 break;
352 return retval;
355 IPTR iconSetup(Class * cl, Object * obj, struct MUIP_Setup * msg)
357 IPTR retval = 0;
358 struct IconClassData *data;
360 data = (struct IconClassData *) INST_DATA(cl, obj);
362 retval = DoSuperMethodA(cl, obj, (Msg) msg);
364 DoSetupMethod(data->imagePart, muiRenderInfo(obj));
365 DoSetupMethod(data->labelPart, muiRenderInfo(obj));
367 if (data->viewMode == IAVM_DETAIL)
369 if (data->sizePart)
370 DoSetupMethod(data->sizePart, muiRenderInfo(obj));
371 if (data->typePart)
372 DoSetupMethod(data->typePart, muiRenderInfo(obj));
373 if (data->lastModifiedPart)
374 DoSetupMethod(data->lastModifiedPart, muiRenderInfo(obj));
377 DoMethod(_win(obj), MUIM_Window_AddEventHandler, (IPTR) &data->ehn);
379 return retval;
382 IPTR iconCleanup(Class * cl, Object * obj, struct MUIP_Cleanup * msg)
384 IPTR retval = 0;
385 struct IconClassData *data;
387 data = (struct IconClassData *) INST_DATA(cl, obj);
389 DoMethod(obj, MUIM_Window_RemEventHandler, (IPTR) &data->ehn);
391 DoMethodA(data->imagePart, (Msg) msg);
392 DoMethodA(data->labelPart, (Msg) msg);
393 if (data->viewMode == IAVM_DETAIL)
395 if (data->sizePart)
396 DoMethodA(data->sizePart, (Msg) msg);
397 if (data->typePart)
398 DoMethodA(data->typePart, (Msg) msg);
399 if (data->lastModifiedPart)
400 DoMethodA(data->lastModifiedPart, (Msg) msg);
403 retval = DoSuperMethodA(cl, obj, (Msg) msg);
405 return retval;
409 IPTR iconDraw(Class * cl, Object * obj, struct MUIP_Draw * msg)
411 IPTR retval;
412 struct IconClassData *data;
413 ULONG imageDrawState = IDS_NORMAL;
415 data = (struct IconClassData *) INST_DATA(cl, obj);
417 retval = DoSuperMethodA(cl, obj, (Msg) msg);
419 if (data->viewMode == IAVM_LARGEICON)
421 if (data->whyRedraw == WR_SELECTED)
423 if (data->selected == TRUE)
424 imageDrawState = IDS_SELECTED;
427 DrawIconStateA(_rp(obj), data->diskObject, NULL,
428 _left(data->imagePart), _top(data->imagePart),
429 imageDrawState, NULL);
432 MUI_Redraw(data->imagePart, MADF_DRAWOBJECT);
433 MUI_Redraw(data->labelPart, MADF_DRAWOBJECT);
434 if (data->viewMode == IAVM_DETAIL)
436 if (data->sizePart)
437 MUI_Redraw(data->sizePart, MADF_DRAWOBJECT);
438 if (data->typePart)
439 MUI_Redraw(data->typePart, MADF_DRAWOBJECT);
440 if (data->lastModifiedPart)
441 MUI_Redraw(data->lastModifiedPart, MADF_DRAWOBJECT);
444 return retval;
447 #define MAX(x,y) (x>y?x:y)
449 IPTR iconAskMinMax(Class * cl, Object * obj, struct MUIP_AskMinMax * msg)
451 IPTR retval;
452 struct MUI_MinMax minMax;
453 struct IconClassData *data;
454 ULONG iconWidth,
455 iconHeight,
456 labelWidth,
457 labelHeight;
458 ULONG sizeWidth,
459 sizeHeight,
460 typeWidth,
461 typeHeight;
462 ULONG lastModWidth,
463 lastModHeight;
465 data = (struct IconClassData *) INST_DATA(cl, obj);
467 retval = DoSuperMethodA(cl, obj, (Msg) msg);
469 if (data->viewMode == IAVM_LARGEICON)
471 iconWidth = data->diskObject->do_Gadget.Width;
472 iconHeight = data->diskObject->do_Gadget.Height;
474 else
476 iconWidth = 15;
477 iconHeight = 15;
480 // do minmax for icon
481 minMax.MinWidth = 0;
482 minMax.DefWidth = 0;
483 minMax.MaxWidth = 0;
484 minMax.MinHeight = 0;
485 minMax.DefHeight = 0;
486 minMax.MaxHeight = 0;
487 DoMethod(data->imagePart, MUIM_AskMinMax, (IPTR) &minMax);
489 _minwidth(data->imagePart) = iconWidth;
490 _minheight(data->imagePart) = iconHeight;
491 _maxwidth(data->imagePart) = iconWidth;
492 _maxheight(data->imagePart) = iconHeight;
493 _defwidth(data->imagePart) = iconWidth;
494 _defheight(data->imagePart) = iconHeight;
496 // do minmax for label
497 minMax.MinWidth = 0;
498 minMax.DefWidth = 0;
499 minMax.MaxWidth = 0;
500 minMax.MinHeight = 0;
501 minMax.DefHeight = 0;
502 minMax.MaxHeight = 0;
503 DoMethod(data->labelPart, MUIM_AskMinMax, (IPTR) &minMax);
505 _minwidth(data->labelPart) = minMax.MinWidth;
506 _minheight(data->labelPart) = minMax.MinHeight;
507 _maxwidth(data->labelPart) = minMax.MaxWidth;
508 _maxheight(data->labelPart) = minMax.MaxHeight;
509 _defwidth(data->labelPart) = minMax.DefWidth;
510 _defheight(data->labelPart) = minMax.DefHeight;
512 labelWidth = minMax.DefWidth;
513 labelHeight = minMax.DefHeight;
515 if (data->viewMode == IAVM_DETAIL)
517 // do minmax for size
518 if (data->sizePart)
520 minMax.MinWidth = 0;
521 minMax.DefWidth = 0;
522 minMax.MaxWidth = 0;
523 minMax.MinHeight = 0;
524 minMax.DefHeight = 0;
525 minMax.MaxHeight = 0;
526 DoMethod(data->sizePart, MUIM_AskMinMax, (IPTR) &minMax);
528 _minwidth(data->sizePart) = minMax.MinWidth;
529 _minheight(data->sizePart) = minMax.MinHeight;
530 _maxwidth(data->sizePart) = minMax.MaxWidth;
531 _maxheight(data->sizePart) = minMax.MaxHeight;
532 _defwidth(data->sizePart) = minMax.DefWidth;
533 _defheight(data->sizePart) = minMax.DefHeight;
535 sizeHeight = _defheight(data->sizePart);
536 sizeWidth = _defwidth(data->sizePart);
540 if (data->typePart)
542 // do minmax for type
543 minMax.MinWidth = 0;
544 minMax.DefWidth = 0;
545 minMax.MaxWidth = 0;
546 minMax.MinHeight = 0;
547 minMax.DefHeight = 0;
548 minMax.MaxHeight = 0;
549 DoMethod(data->typePart, MUIM_AskMinMax, (IPTR) &minMax);
551 _minwidth(data->typePart) = minMax.MinWidth;
552 _minheight(data->typePart) = minMax.MinHeight;
553 _maxwidth(data->typePart) = minMax.MaxWidth;
554 _maxheight(data->typePart) = minMax.MaxHeight;
555 _defwidth(data->typePart) = minMax.DefWidth;
556 _defheight(data->typePart) = minMax.DefHeight;
558 typeHeight = _defheight(data->typePart);
559 typeWidth = _defwidth(data->typePart);
562 if (data->lastModifiedPart)
564 // do minmax for last-modified
565 minMax.MinWidth = 0;
566 minMax.DefWidth = 0;
567 minMax.MaxWidth = 0;
568 minMax.MinHeight = 0;
569 minMax.DefHeight = 0;
570 minMax.MaxHeight = 0;
571 DoMethod(data->lastModifiedPart, MUIM_AskMinMax, (IPTR) &minMax);
573 _minwidth(data->lastModifiedPart) = minMax.MinWidth;
574 _minheight(data->lastModifiedPart) = minMax.MinHeight;
575 _maxwidth(data->lastModifiedPart) = minMax.MaxWidth;
576 _maxheight(data->lastModifiedPart) = minMax.MaxHeight;
577 _defwidth(data->lastModifiedPart) = minMax.DefWidth;
578 _defheight(data->lastModifiedPart) = minMax.DefHeight;
580 lastModHeight = _defheight(data->lastModifiedPart);
581 lastModWidth = _defwidth(data->lastModifiedPart);
585 switch (data->viewMode)
587 case IAVM_LARGEICON:
588 msg->MinMaxInfo->DefWidth += (MAX(iconWidth, labelWidth));
589 msg->MinMaxInfo->DefHeight += (iconHeight + labelHeight);
590 msg->MinMaxInfo->MinHeight += (iconHeight + labelHeight);
591 msg->MinMaxInfo->MaxHeight += (iconHeight + labelHeight);
592 msg->MinMaxInfo->MinWidth += (MAX(iconWidth, labelWidth));
593 msg->MinMaxInfo->MaxWidth += (MAX(iconWidth, labelWidth));
594 break;
595 case IAVM_SMALLICON:
596 msg->MinMaxInfo->DefWidth += (iconWidth + labelWidth);
597 msg->MinMaxInfo->DefHeight += (MAX(iconHeight, labelHeight));
598 msg->MinMaxInfo->MinHeight += (MAX(iconHeight, labelHeight));
599 msg->MinMaxInfo->MaxHeight += (MAX(iconHeight, labelHeight));
600 msg->MinMaxInfo->MinWidth += (iconWidth + labelWidth);
601 msg->MinMaxInfo->MaxWidth += (iconWidth + labelWidth);
602 break;
603 case IAVM_DETAIL:
605 struct DetailColumn *label,
606 *size,
607 *type,
608 *modified;
610 label =
611 (struct DetailColumn *) DoMethod(_parent(obj),
612 ICM_GetColumn, IA_Label);
613 size =
614 (struct DetailColumn *) DoMethod(_parent(obj),
615 ICM_GetColumn, IA_Size);
616 type =
617 (struct DetailColumn *) DoMethod(_parent(obj),
618 ICM_GetColumn, IA_Type);
619 modified =
620 (struct DetailColumn *) DoMethod(_parent(obj),
621 ICM_GetColumn,
622 IA_LastModified);
624 msg->MinMaxInfo->DefWidth +=
625 (modified->dc_X + modified->dc_Width);
626 msg->MinMaxInfo->DefHeight += (MAX(iconHeight, labelHeight));
627 msg->MinMaxInfo->MinWidth +=
628 (modified->dc_X + modified->dc_Width);
629 msg->MinMaxInfo->MinHeight += (MAX(iconHeight, labelHeight));
630 msg->MinMaxInfo->MaxWidth +=
631 (modified->dc_X + modified->dc_Width);
632 msg->MinMaxInfo->MaxHeight += (MAX(iconHeight, labelHeight));
633 break;
637 return retval;
640 IPTR iconShow(Class * cl, Object * obj, Msg msg)
642 IPTR retval;
643 struct IconClassData *data;
645 data = (struct IconClassData *) INST_DATA(cl, obj);
647 retval = DoSuperMethodA(cl, obj, (Msg) msg);
649 DoMethodA(data->imagePart, msg);
650 DoMethodA(data->labelPart, msg);
651 if (data->viewMode == IAVM_DETAIL)
653 if (data->sizePart)
654 DoMethodA(data->sizePart, msg);
655 if (data->typePart)
656 DoMethodA(data->typePart, msg);
657 if (data->lastModifiedPart)
658 DoMethodA(data->lastModifiedPart, msg);
661 return retval;
664 IPTR iconConnectParent(Class * cl, Object * obj,
665 struct MUIP_ConnectParent * msg)
667 struct IconClassData *data = (struct IconClassData *) INST_DATA(cl, obj);
668 IPTR retval;
669 ULONG iconSize;
671 if (data->viewMode != IAVM_LARGEICON)
672 iconSize = 15;
674 if (!data->imagePart)
676 data->imagePart = RectangleObject,
677 ButtonFrame,
678 MUIA_FixHeight, data->diskObject->do_Gadget.Height,
679 MUIA_FixWidth, data->diskObject->do_Gadget.Width, End;
682 if (data->viewMode == IAVM_LARGEICON)
683 SetAttrs(data->imagePart, MUIA_Frame, MUIV_Frame_None, TAG_END);
684 else
685 SetAttrs(data->imagePart, MUIA_Frame, MUIV_Frame_Button, TAG_END);
687 if (!data->labelPart)
689 data->labelPart = TextObject, MUIA_Text_Contents, (IPTR) data->label, End;
692 if (data->viewMode == IAVM_DETAIL)
694 struct DetailColumn *dc;
696 dc = (struct DetailColumn *) DoMethod
698 _parent(obj), ICM_GetColumn, IA_Size
700 if (dc)
702 STRPTR buffer;
704 buffer = AllocVec(18, MEMF_ANY);
706 __sprintf(buffer, "%u", data->size);
708 data->sizePart = TextObject,
709 MUIA_Text_Contents, (IPTR) buffer,
710 End;
712 FreeVec(buffer);
715 dc = (struct DetailColumn *) DoMethod
717 _parent(obj), ICM_GetColumn, IA_Type
719 if (dc)
721 STRPTR description = NULL;
723 // this will change to tool/project/drawer/etc...
724 if (data->type < 0) description = "File";
725 else if (data->type > 0) description = "Drawer";
726 else description = "Unknown";
728 data->typePart = TextObject,
729 MUIA_Text_Contents, (IPTR) description,
730 End;
733 dc = (struct DetailColumn *) DoMethod(_parent(obj), ICM_GetColumn,
734 IA_LastModified);
735 if (dc)
737 struct DateTime dt;
738 UBYTE day[LEN_DATSTRING];
739 UBYTE date[LEN_DATSTRING];
740 UBYTE time[LEN_DATSTRING];
741 ULONG bufferLength = LEN_DATSTRING * 3; /* FIXME: ??? */
742 UBYTE *buffer = AllocVec(bufferLength, MEMF_ANY);
743 /* FIXME: error checking */
745 dt.dat_Stamp = data->lastChanged;
746 dt.dat_Format = FORMAT_DOS;
747 dt.dat_Flags = DTF_SUBST;
748 dt.dat_StrDay = day;
749 dt.dat_StrDate = date;
750 dt.dat_StrTime = time;
752 if (DateToStr(&dt))
754 if (strcmp(dt.dat_StrDay, "Yesterday") == 0)
756 strlcpy(buffer, dt.dat_StrDay, bufferLength);
758 else if (strcmp(dt.dat_StrDay, "Today") == 0)
760 strlcpy(buffer, dt.dat_StrDay, bufferLength);
762 else
764 strlcpy(buffer, dt.dat_StrDate, bufferLength);
767 strlcat(buffer, " ", bufferLength);
768 strlcat(buffer, dt.dat_StrTime, bufferLength);
770 else
772 kprintf("ERROR\n");
775 data->lastModifiedPart = TextObject,
776 MUIA_Text_Contents, (IPTR) buffer,
777 End;
779 FreeVec(buffer);
783 retval = DoSuperMethodA(cl, obj, (Msg) msg);
785 data = (struct IconClassData *) INST_DATA(cl, obj);
787 muiNotifyData(data->imagePart)->mnd_ParentObject = obj;
788 DoMethod(data->imagePart, MUIM_ConnectParent, (IPTR) obj);
789 muiNotifyData(data->labelPart)->mnd_ParentObject = obj;
790 DoMethod(data->labelPart, MUIM_ConnectParent, (IPTR) obj);
792 if (data->viewMode == IAVM_DETAIL)
794 if (data->sizePart)
796 muiNotifyData(data->sizePart)->mnd_ParentObject = obj;
797 DoMethodA(data->sizePart, (Msg) msg);
798 DoSetupMethod(data->sizePart, muiRenderInfo(obj));
800 if (data->typePart)
802 muiNotifyData(data->typePart)->mnd_ParentObject = obj;
803 DoMethodA(data->typePart, (Msg) msg);
804 DoSetupMethod(data->typePart, muiRenderInfo(obj));
806 if (data->lastModifiedPart)
808 muiNotifyData(data->lastModifiedPart)->mnd_ParentObject = obj;
809 DoMethodA(data->lastModifiedPart, (Msg) msg);
810 DoSetupMethod(data->lastModifiedPart, muiRenderInfo(obj));
814 return retval;
818 ULONG iconLayout(Class * cl, Object * obj, Msg msg)
820 ULONG retval;
821 struct IconClassData *data;
823 data = INST_DATA(cl, obj);
824 retval = DoSuperMethodA(cl, obj, msg);
826 switch (data->viewMode)
828 case IAVM_LARGEICON:
829 MUI_Layout(data->imagePart,
830 (_defwidth(obj) / 2) -
831 (_defwidth(data->imagePart) / 2), 0,
832 _defwidth(data->imagePart),
833 _defheight(data->imagePart), 0);
834 MUI_Layout(data->labelPart,
835 (_defwidth(obj) / 2) -
836 (_defwidth(data->labelPart) / 2),
837 _defheight(data->imagePart) + 1,
838 _defwidth(data->labelPart),
839 _defheight(data->labelPart), 0);
840 break;
841 case IAVM_SMALLICON:
842 MUI_Layout(data->imagePart, 0,
843 (_defheight(obj) / 2) -
844 (_defheight(data->imagePart) / 2),
845 _defwidth(data->imagePart),
846 _defheight(data->imagePart), 0);
847 MUI_Layout(data->labelPart, _defwidth(data->imagePart) + 1,
848 (_defheight(obj) / 2) -
849 (_defheight(data->labelPart) / 2),
850 _defwidth(data->labelPart),
851 _defheight(data->labelPart), 0);
852 break;
853 case IAVM_DETAIL:
855 struct DetailColumn *dc;
857 dc = (struct DetailColumn *) DoMethod(_parent(obj),
858 ICM_GetColumn,
859 IA_Label);
860 if (dc)
862 MUI_Layout(data->imagePart, dc->dc_X,
863 (_defheight(obj) / 2) -
864 (_defheight(data->labelPart) / 2),
865 _defwidth(data->imagePart),
866 _defheight(data->imagePart), 0);
867 MUI_Layout(data->labelPart,
868 _defwidth(data->imagePart) + dc->dc_X + 1,
869 (_defheight(obj) / 2) -
870 (_defheight(data->labelPart) / 2),
871 _defwidth(data->labelPart),
872 _defheight(data->labelPart), 0);
875 if (data->sizePart)
877 dc = (struct DetailColumn *) DoMethod(_parent(obj),
878 ICM_GetColumn,
879 IA_Size);
880 if (dc)
881 MUI_Layout(data->sizePart, dc->dc_X,
882 (_defheight(obj) / 2) -
883 (_defheight(data->labelPart) / 2),
884 _defwidth(data->sizePart),
885 _defheight(data->sizePart), 0);
887 if (data->typePart)
889 dc = (struct DetailColumn *) DoMethod(_parent(obj),
890 ICM_GetColumn,
891 IA_Type);
892 if (dc)
893 MUI_Layout(data->typePart, dc->dc_X,
894 (_defheight(obj) / 2) -
895 (_defheight(data->labelPart) / 2),
896 _defwidth(data->typePart),
897 _defheight(data->typePart), 0);
899 if (data->lastModifiedPart)
901 dc = (struct DetailColumn *) DoMethod(_parent(obj),
902 ICM_GetColumn,
903 IA_LastModified);
904 if (dc)
905 MUI_Layout(data->lastModifiedPart, dc->dc_X,
906 (_defheight(obj) / 2) -
907 (_defheight(data->labelPart) / 2),
908 _defwidth(data->lastModifiedPart),
909 _defheight(data->lastModifiedPart), 0);
911 break;
915 return retval;
918 BOOPSI_DISPATCHER(IPTR, iconDispatcher, cl, obj, msg)
920 ULONG retval = 0;
922 switch (msg->MethodID)
924 case OM_NEW:
925 retval = iconNew(cl, obj, (struct opSet *) msg);
926 break;
927 case OM_SET:
928 retval = iconSet(cl, obj, (struct opSet *) msg);
929 break;
930 case OM_GET:
931 retval = iconGet(cl, obj, (struct opGet *) msg);
932 break;
933 case OM_DISPOSE:
934 retval = iconDispose(cl, obj, msg);
935 break;
936 case MUIM_HandleInput:
937 retval =
938 iconHandleInput(cl, obj, (struct MUIP_HandleInput *) msg);
939 break;
940 case MUIM_Setup:
941 retval = iconSetup(cl, obj, (struct MUIP_Setup *) msg);
942 break;
943 case MUIM_Cleanup:
944 retval = iconCleanup(cl, obj, (struct MUIP_Cleanup *) msg);
945 break;
946 case MUIM_Show:
947 retval = iconShow(cl, obj, msg);
948 break;
949 case MUIM_Draw:
950 retval = iconDraw(cl, obj, (struct MUIP_Draw *) msg);
951 break;
952 case MUIM_ConnectParent:
953 retval =
954 iconConnectParent(cl, obj, (struct MUIP_ConnectParent *) msg);
955 break;
956 case MUIM_DragQuery:
957 return 1;
958 break;
959 case MUIM_Layout:
960 retval = iconLayout(cl, obj, msg);
961 break;
962 case MUIM_AskMinMax:
963 retval = iconAskMinMax(cl, obj, (struct MUIP_AskMinMax *) msg);
964 break;
965 case MUIM_DrawBackground:
966 break;
967 default:
969 struct IconClassData *data;
971 data = INST_DATA(cl, obj);
973 if(data->imagePart)
974 DoMethodA(data->imagePart, msg);
975 if(data->labelPart)
976 DoMethodA(data->labelPart, msg);
979 if (data->viewMode == IAVM_DETAIL)
981 if (data->sizePart)
982 DoMethodA(data->sizePart, msg);
983 if (data->typePart)
984 DoMethodA(data->typePart, msg);
985 if (data->lastModifiedPart)
986 DoMethodA(data->lastModifiedPart, msg);
988 retval = DoSuperMethodA(cl, obj, msg);
989 break;
993 return retval;
995 BOOPSI_DISPATCHER_END