more rendering corrections
[AROS.git] / workbench / libs / desktop / iconcontainerclass.c
blob382b7711afdf06113e3933868a61bdcea80959d0
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define MUIMASTER_YES_INLINE_STDARG
8 #define DEBUG 1
9 #include <aros/debug.h>
11 #include <exec/types.h>
12 #include <exec/memory.h>
13 #include <libraries/mui.h>
15 #include <proto/exec.h>
16 #include <proto/dos.h>
17 #include <proto/graphics.h>
18 #include <proto/intuition.h>
19 #include <proto/layers.h>
20 #include <proto/muimaster.h>
21 #include <proto/utility.h>
23 #include "desktop_intern.h"
24 #include "presentation.h"
25 #include "iconcontainerclass.h"
26 #include "iconclass.h"
28 #include "desktop_intern_protos.h"
30 #include <stdlib.h>
33 static ULONG DoSetupMethod(Object * obj, struct MUI_RenderInfo *info)
36 MUI set the correct render info *before* it calls MUIM_Setup so please
37 only use this function instead of DoMethodA()
39 muiRenderInfo(obj) = info;
41 return DoMethod(obj, MUIM_Setup, (IPTR) info);
44 IPTR iconConNew(Class * cl, Object * obj, struct opSet *ops)
46 IPTR retval = 0;
47 struct IconContainerClassData *data;
48 struct TagItem *tag,
49 *tstate = ops->ops_AttrList;
50 Object *vert = NULL,
51 *horiz = NULL;
52 BYTE viewMode = ICAVM_LARGE;
54 while ((tag = NextTagItem(&tstate)) != NULL)
56 switch (tag->ti_Tag)
58 case ICA_VertScroller:
59 vert = (Object *) tag->ti_Data;
60 break;
62 case ICA_HorizScroller:
63 horiz = (Object *) tag->ti_Data;
64 break;
66 case ICA_ViewMode:
67 viewMode = tag->ti_Data;
68 break;
70 default:
71 continue; /* Don't supress non-processed tags */
74 tag->ti_Tag = TAG_IGNORE;
77 retval = DoSuperMethodA(cl, obj, (Msg) ops);
79 if (retval)
81 obj = (Object *) retval;
82 data = INST_DATA(cl, obj);
84 data->perfectLayout = TRUE;
85 data->thisColumnWidth = 0;
86 data->thisColumnHeight = 0;
87 data->virtualWidth = 0;
88 data->virtualHeight = 0;
89 data->xView = 0;
90 data->yView = 0;
91 data->visibleWidth = 0;
92 data->visibleHeight = 0;
93 data->heightAdjusted = 0;
94 data->widthAdjusted = 0;
95 data->horizScroll = FALSE;
96 data->vertScroll = FALSE;
97 data->horizProp = horiz;
98 data->vertProp = vert;
99 data->open = TRUE;
100 data->ehn.ehn_Priority = 0;
101 data->ehn.ehn_Flags = (1 << 1);
102 data->ehn.ehn_Object = obj;
103 data->ehn.ehn_Class = NULL;
104 data->ehn.ehn_Events = IDCMP_MOUSEBUTTONS;
105 data->viewMode = viewMode;
107 data->columns = AllocVec(sizeof(struct DetailColumn) * 4, MEMF_ANY);
108 data->columns[0].dc_Content = IA_Label;
109 data->columns[0].dc_X = 0;
110 data->columns[0].dc_Width = 120;
111 data->columns[1].dc_Content = IA_Size;
112 data->columns[1].dc_X = 121;
113 data->columns[1].dc_Width = 60;
114 data->columns[2].dc_Content = IA_Type;
115 data->columns[2].dc_X = 182;
116 data->columns[2].dc_Width = 80;
117 data->columns[3].dc_Content = IA_LastModified;
118 data->columns[3].dc_X = 263;
119 data->columns[3].dc_Width = 160;
121 data->numColumns = 4;
124 return retval;
127 IPTR iconConSetup(Class * cl, Object * obj, struct MUIP_Setup * msg)
129 IPTR retval;
130 //struct MemberNode *mn;
131 struct IconContainerClassData *data;
133 data = (struct IconContainerClassData *) INST_DATA(cl, obj);
135 // the superclass will send the method to the memberlist
136 retval = DoSuperMethodA(cl, obj, (Msg) msg);
138 if (data->horizProp)
139 DoSetupMethod(data->horizProp, msg->RenderInfo);
141 if (data->vertProp)
142 DoSetupMethod(data->vertProp, msg->RenderInfo);
144 DoMethod(_win(obj), MUIM_Window_AddEventHandler, (IPTR) &data->ehn);
146 return retval;
149 IPTR iconConCleanup(Class * cl, Object * obj, struct MUIP_Cleanup * msg)
151 IPTR retval = 0;
152 struct IconContainerClassData *data;
154 data = (struct IconContainerClassData *) INST_DATA(cl, obj);
156 DoMethod(obj, MUIM_Window_RemEventHandler, (IPTR) &data->ehn);
158 // the superclass will send this method to the memberlist
159 retval = DoSuperMethodA(cl, obj, msg);
161 return retval;
164 IPTR iconConShow(Class * cl, Object * obj, Msg msg)
166 IPTR retval;
167 //struct MemberNode *mn;
168 struct IconContainerClassData *data;
170 data = (struct IconContainerClassData *) INST_DATA(cl, obj);
172 // the superclass will send this method to the memberlist
173 retval = DoSuperMethodA(cl, obj, (Msg) msg);
175 if (data->horizProp)
176 DoMethod(data->horizProp, MUIM_Show);
178 if (data->vertProp)
179 DoMethod(data->vertProp, MUIM_Show);
181 return retval;
184 IPTR iconConAskMinMax(Class * cl, Object * obj, struct MUIP_AskMinMax * msg)
186 IPTR retval;
187 struct MUI_MinMax minMax;
188 struct IconContainerClassData *data;
190 data = (struct IconContainerClassData *) INST_DATA(cl, obj);
192 // the superclass will send this method to the memberlist
193 retval = DoSuperMethodA(cl, obj, (Msg) msg);
195 msg->MinMaxInfo->MinWidth += 20;
196 msg->MinMaxInfo->DefWidth += 300;
197 msg->MinMaxInfo->MaxWidth = MUI_MAXMAX;
198 msg->MinMaxInfo->MinHeight += 20;
199 msg->MinMaxInfo->DefHeight += 300;
200 msg->MinMaxInfo->MaxHeight = MUI_MAXMAX;
202 if (data->vertProp)
204 minMax.MinWidth = 0;
205 minMax.DefWidth = 0;
206 minMax.MaxWidth = 0;
207 minMax.MinHeight = 0;
208 minMax.DefHeight = 0;
209 minMax.MaxHeight = 0;
210 DoMethod(data->vertProp, MUIM_AskMinMax, (IPTR) &minMax);
213 if (data->horizProp)
215 minMax.MinWidth = 0;
216 minMax.DefWidth = 0;
217 minMax.MaxWidth = 0;
218 minMax.MinHeight = 0;
219 minMax.DefHeight = 0;
220 minMax.MaxHeight = 0;
221 DoMethod(data->horizProp, MUIM_AskMinMax, (IPTR) &minMax);
224 return retval;
227 BOOL canLay(Object * parent, Object * newObject, ULONG newX, ULONG newY,
228 struct MinList * memberList, struct IconContainerClassData * data)
230 struct MemberNode *mn;
232 if (_memberCount(parent) != 1)
234 mn = (struct MemberNode *) _memberList(parent).mlh_Head;
235 while (mn->m_Node.mln_Succ)
237 if (!
238 ((newX < _left(mn->m_Object) || newX > _right(mn->m_Object))
239 && (newY < _top(mn->m_Object)
240 || newY > _bottom(mn->m_Object))
241 && (newX + _defwidth(mn->m_Object) < _left(mn->m_Object)
242 || newX + _defwidth(mn->m_Object) > _right(mn->m_Object))
243 && (newY + _defheight(mn->m_Object) < _top(mn->m_Object)
244 || newY + _defheight(mn->m_Object) >
245 _bottom(mn->m_Object))))
247 return FALSE;
250 mn = (struct MemberNode *) mn->m_Node.mln_Succ;
253 return TRUE;
255 else
256 return TRUE;
258 return FALSE;
261 // lay out a newly added icon
262 ULONG layoutObject(struct IconContainerClassData * data, Object * obj,
263 Object * newObject)
265 ULONG retval = 0;
266 ULONG newX,
267 newY;
268 BOOL laid = TRUE;
270 if (data->viewMode == ICAVM_DETAIL)
272 newX = ICONSPACINGX;
273 if (_memberCount(obj) == 1)
274 newY = ICONSPACINGY;
275 else
276 newY = _bottom(data->last) + ICONSPACINGY - _mtop(obj);
277 if (newX + _defwidth(newObject) + ICONSPACINGX > data->virtualWidth)
278 data->virtualWidth = newX + _defwidth(newObject) + ICONSPACINGX;
280 if (newY + _defheight(newObject) + ICONSPACINGY > data->virtualHeight)
281 data->virtualHeight = newY + _defheight(newObject) + ICONSPACINGX;
283 MUI_Layout(newObject, newX, newY, _defwidth(newObject),
284 _defheight(newObject), 0);
286 else
288 if (data->perfectLayout)
290 if (_memberCount(obj) == 1)
292 newX = ICONSPACINGX;
293 newY = ICONSPACINGY;
295 // data->virtualWidth=_defwidth(newObject)+ICONSPACINGX;
296 data->thisColumnWidth = _defwidth(newObject);
298 else
300 newX = _left(data->last) - _mleft(obj);
301 newY = _bottom(data->last) + ICONSPACINGY - _mtop(obj);
302 if (newY + _defheight(newObject) > _mheight(obj))
304 // new column
305 newX += data->thisColumnWidth + ICONSPACINGX;
306 newY = ICONSPACINGY;
307 // data->virtualWidth+=(_defwidth(newObject)+ICONSPACINGX);
308 data->thisColumnHeight = 0;
309 data->thisColumnWidth = 0;
312 if (_defwidth(newObject) > data->thisColumnWidth)
314 // data->virtualWidth+=(_defwidth(newObject)-data->thisColumnWidth);
315 data->thisColumnWidth = _defwidth(newObject);
319 data->thisColumnHeight += (ICONSPACINGY + _defheight(newObject));
320 // if(data->thisColumnHeight+_defheight(newObject)+ICONSPACINGY >
321 // data->virtualHeight)
322 // data->virtualHeight+=data->thisColumnHeight;
324 else
326 struct MemberNode *mn;
327 BOOL laid = FALSE;
329 newX = ICONSPACINGX;
330 newY = ICONSPACINGY;
332 laid =
333 canLay(obj, newObject, newX, newY, &(_memberList(obj)), data);
335 mn = (struct MemberNode *) _memberList(obj).mlh_Head;
336 while (mn->m_Node.mln_Succ && !laid)
338 newX = _left(mn->m_Object) - _mleft(obj);
339 newY = _bottom(mn->m_Object) + ICONSPACINGY - _mtop(obj);
341 // will the icon go off the bottom of the screen?
342 if ((newY + _defwidth(newObject) > _mheight(obj))
343 && _mheight(obj) > _defheight(newObject))
345 newX += _width(mn->m_Object) + ICONSPACINGX;
346 newY = ICONSPACINGY;
349 laid =
350 canLay(obj, newObject, newX, newY, &(_memberList(obj)),
351 data);
353 mn = (struct MemberNode *) mn->m_Node.mln_Succ;
357 if (laid)
359 if (newX + _defwidth(newObject) + ICONSPACINGX >
360 data->virtualWidth)
361 data->virtualWidth =
362 newX + _defwidth(newObject + ICONSPACINGX);
364 if (newY + _defheight(newObject) + ICONSPACINGY >
365 data->virtualHeight)
366 data->virtualHeight =
367 newY + _defheight(newObject) + ICONSPACINGX;
369 MUI_Layout(newObject, newX, newY, _defwidth(newObject),
370 _defheight(newObject), 0);
374 data->last = newObject;
376 return retval;
380 ULONG iconConLayout(Class * cl, Object * obj, Msg msg)
382 ULONG retval;
383 struct IconContainerClassData *data;
385 data = INST_DATA(cl, obj);
386 retval = DoSuperMethodA(cl, obj, msg);
388 if (data->visibleHeight == 0)
390 // first layout
391 SetAttrs(data->horizProp, MUIA_Prop_Visible, _mwidth(obj), TAG_END);
392 SetAttrs(data->vertProp, MUIA_Prop_Visible, _mheight(obj), TAG_END);
394 else
396 if (data->visibleHeight != _mheight(obj))
398 // height adjusted
399 data->heightAdjusted = _mheight(obj) - data->visibleHeight;
402 if (data->visibleWidth != _mwidth(obj))
404 // width adjusted
405 data->widthAdjusted = _mwidth(obj) - data->visibleWidth;
410 return retval;
413 IPTR iconConAdd(Class * cl, Object * obj, struct opMember * msg)
415 struct IconContainerClassData *data;
416 //struct MemberNode *mn;
417 ULONG retval = 1;
418 struct MUI_MinMax minMax;
419 APTR clip;
421 minMax.MinWidth = 0;
422 minMax.DefWidth = 0;
423 minMax.MaxWidth = 0;
424 minMax.MinHeight = 0;
425 minMax.DefHeight = 0;
426 minMax.MaxHeight = 0;
428 data = (struct IconContainerClassData *) INST_DATA(cl, obj);
430 DoSuperMethodA(cl, obj, (Msg)msg);
432 DoSetupMethod(msg->opam_Object, muiRenderInfo(obj));
434 DoMethod(msg->opam_Object, MUIM_AskMinMax, (IPTR) &minMax);
436 _minwidth(msg->opam_Object) = minMax.MinWidth;
437 _minheight(msg->opam_Object) = minMax.MinHeight;
438 _maxwidth(msg->opam_Object) = minMax.MaxWidth;
439 _maxheight(msg->opam_Object) = minMax.MaxHeight;
440 _defwidth(msg->opam_Object) = minMax.DefWidth;
441 _defheight(msg->opam_Object) = minMax.DefHeight;
443 layoutObject(data, obj, msg->opam_Object);
445 DoMethod(msg->opam_Object, MUIM_Show);
447 clip =
448 MUI_AddClipping(muiRenderInfo(obj), _mleft(obj), _mtop(obj),
449 _mwidth(obj), _mheight(obj));
450 MUI_Redraw(msg->opam_Object, MADF_DRAWOBJECT);
451 MUI_RemoveClipping(muiRenderInfo(obj), clip);
452 // _memberCount(obj)++;
453 // AddTail((struct List *) &(_memberList(obj)), (struct Node *) mn);
454 SetAttrs(data->horizProp, MUIA_Prop_Entries, data->virtualWidth, TAG_END);
455 SetAttrs(data->vertProp, MUIA_Prop_Entries, data->virtualHeight, TAG_END);
457 return retval;
460 void redrawRectangle(LONG x1, LONG y1, LONG x2, LONG y2, Object * obj,
461 struct IconContainerClassData *data)
463 struct MemberNode *mn;
465 mn = (struct MemberNode *) _memberList(obj).mlh_Head;
466 while (mn->m_Node.mln_Succ)
468 // check to see if the left or right edge is in the damaged
469 // area - also, check to see whether an object is in the area where
470 // both edges are to the left and right of the damaged area
471 if ((_mleft(mn->m_Object) >= x1 && _mleft(mn->m_Object) <= x2) ||
472 (_mright(mn->m_Object) >= x1 && _mright(mn->m_Object) <= x2) ||
473 (_mleft(mn->m_Object) <= x1 && _mright(mn->m_Object) >= x2))
475 // as above, except with the top and bottom edges of the member
476 // objects
477 if ((_mtop(mn->m_Object) >= y1 && _mtop(mn->m_Object) <= y2) ||
478 (_mbottom(mn->m_Object) >= y1 && _mbottom(mn->m_Object) <= y2)
479 || (_mtop(mn->m_Object) <= y1
480 && _mbottom(mn->m_Object) >= y2))
482 MUI_Redraw(mn->m_Object, MADF_DRAWOBJECT);
486 mn = (struct MemberNode *) mn->m_Node.mln_Succ;
490 IPTR drawAll(Class * cl, Object * obj, struct MUIP_Draw *msg,
491 struct IconContainerClassData *data)
493 IPTR retval = 1;
494 struct MemberNode *mn;
495 APTR clip;
497 clip =
498 MUI_AddClipping(muiRenderInfo(obj), _mleft(obj), _mtop(obj),
499 _mwidth(obj), _mheight(obj));
501 if (data->widthAdjusted != 0)
503 if (data->widthAdjusted > 0)
504 redrawRectangle(_mright(obj) - data->widthAdjusted, _mtop(obj),
505 _mright(obj), _mbottom(obj), obj, data);
506 SetAttrs(data->horizProp, MUIA_Prop_Visible, _mwidth(obj), TAG_END);
509 if (data->heightAdjusted != 0)
511 if (data->heightAdjusted > 0)
512 redrawRectangle(_mleft(obj), _mbottom(obj) - data->heightAdjusted,
513 _mright(obj), _mbottom(obj), obj, data);
514 SetAttrs(data->vertProp, MUIA_Prop_Visible, _mheight(obj), TAG_END);
517 if (data->heightAdjusted == 0 && data->widthAdjusted == 0)
519 // if(!(muiRenderInfo(obj)->mri_Flags & MUIMRI_REFRESHMODE))
520 // {
521 // SetAttrs(data->horizProp, MUIA_Prop_Visible, _mwidth(obj), TAG_END);
522 // SetAttrs(data->vertProp, MUIA_Prop_Visible, _mheight(obj), TAG_END);
523 // }
524 EraseRect(_rp(obj), _mleft(obj), _mtop(obj), _mright(obj),
525 _mbottom(obj));
527 mn = (struct MemberNode *) _memberList(obj).mlh_Head;
528 while (mn->m_Node.mln_Succ)
530 MUI_Redraw(mn->m_Object, MADF_DRAWOBJECT);
531 mn = (struct MemberNode *) mn->m_Node.mln_Succ;
535 data->visibleWidth = _mwidth(obj);
536 data->visibleHeight = _mheight(obj);
537 data->widthAdjusted = 0;
538 data->heightAdjusted = 0;
540 MUI_RemoveClipping(muiRenderInfo(obj), clip);
542 return retval;
545 IPTR iconConDraw(Class * cl, Object * obj, struct MUIP_Draw * msg)
547 struct IconContainerClassData *data;
548 struct MemberNode *mn;
549 IPTR retval = 1;
550 APTR clip = NULL;
551 BOOL layerrefresh,
552 scroll_caused_damage;
554 data = (struct IconContainerClassData *) INST_DATA(cl, obj);
556 SetAttrs(obj, AICA_ApplyMethodsToMembers, FALSE, TAG_END);
557 retval = DoSuperMethodA(cl, obj, (Msg) msg);
558 SetAttrs(obj, AICA_ApplyMethodsToMembers, TRUE, TAG_END);
560 if ((msg->flags & MADF_DRAWOBJECT) || (msg->flags & MADF_DRAWALL))
562 retval = drawAll(cl, obj, msg, data);
564 else if (msg->flags & MADF_DRAWUPDATE)
566 LONG scrollAmountX = 0,
567 scrollAmountY = 0;
568 LONG redrawX1 = 0,
569 redrawY1 = 0,
570 redrawX2 = 0,
571 redrawY2 = 0;
573 if (data->vertScroll)
575 // vertical scroll
576 scrollAmountY = data->yView - data->lastYView;
578 if (scrollAmountY > 0)
580 // scroll bottom, displays shifts up, redraw gap at bottom
581 redrawY1 = _mbottom(obj) - abs(scrollAmountY);
582 redrawY2 = _mbottom(obj);
584 else if (scrollAmountY < 0)
586 // scroll top, display shifts bottom, redraw gap at top
587 redrawY1 = _mtop(obj);
588 redrawY2 = _mtop(obj) + abs(scrollAmountY);
591 redrawX1 = _mleft(obj);
592 redrawX2 = _mright(obj);
594 // shift the positions of the member objects
595 mn = (struct MemberNode *) _memberList(obj).mlh_Head;
596 while (mn->m_Node.mln_Succ)
598 MUI_Layout(mn->m_Object,
599 _left(mn->m_Object) - scrollAmountX - _mleft(obj),
600 _top(mn->m_Object) - scrollAmountY - _mtop(obj),
601 _width(mn->m_Object), _height(mn->m_Object), 0);
602 mn = (struct MemberNode *) mn->m_Node.mln_Succ;
605 clip =
606 MUI_AddClipping(muiRenderInfo(obj), _mleft(obj), _mtop(obj),
607 _mwidth(obj), _mheight(obj));
609 layerrefresh =
610 (_rp(obj)->Layer->Flags & LAYERREFRESH) ? TRUE : FALSE;
612 ScrollRaster(_rp(obj), 0, scrollAmountY, _mleft(obj), _mtop(obj),
613 _mright(obj), _mbottom(obj));
615 // redraw in gap
616 redrawRectangle(redrawX1, redrawY1, redrawX2, redrawY2, obj,
617 data);
619 if ((_rp(obj)->Layer->Flags & LAYERREFRESH) && !layerrefresh)
620 scroll_caused_damage = TRUE;
621 else
622 scroll_caused_damage = FALSE;
624 MUI_RemoveClipping(muiRenderInfo(obj), clip);
626 if (scroll_caused_damage)
628 struct Region *damageList;
629 WORD x1,
634 // get the damage area bounds in x1,x2,y1,y2
635 LockLayer(0, _window(obj)->WLayer);
636 damageList = _window(obj)->WLayer->DamageList;
637 x1 = damageList->bounds.MinX;
638 y1 = damageList->bounds.MinY;
639 x2 = damageList->bounds.MaxX;
640 y2 = damageList->bounds.MaxY;
641 UnlockLayer(_window(obj)->WLayer);
643 if (MUI_BeginRefresh(muiRenderInfo(obj), 0))
645 EraseRect(_rp(obj), x1, y1, x2, y2);
646 redrawRectangle(x1, y1, x2, y2, obj, data);
648 MUI_EndRefresh(muiRenderInfo(obj), 0);
652 data->vertScroll = FALSE;
654 else if (data->horizScroll)
656 // horizontal scroll
657 scrollAmountX = data->xView - data->lastXView;
659 // redraw gap area
660 if (scrollAmountX > 0)
662 // scroll right, displays shifts left, redraw gap at right
663 redrawX1 = _mright(obj) - abs(scrollAmountX);
664 redrawX2 = _mright(obj);
667 else if (scrollAmountX < 0)
669 // scroll left, display shifts right, redraw gap at left
670 redrawX1 = _mleft(obj);
671 redrawX2 = _mleft(obj) + abs(scrollAmountX);
674 redrawY1 = _mtop(obj);
675 redrawY2 = _mbottom(obj);
677 // shift the positions of the member objects
678 mn = (struct MemberNode *) _memberList(obj).mlh_Head;
679 while (mn->m_Node.mln_Succ)
681 MUI_Layout(mn->m_Object,
682 _left(mn->m_Object) - scrollAmountX - _mleft(obj),
683 _top(mn->m_Object) - scrollAmountY - _mtop(obj),
684 _width(mn->m_Object), _height(mn->m_Object), 0);
686 mn = (struct MemberNode *) mn->m_Node.mln_Succ;
689 clip =
690 MUI_AddClipping(muiRenderInfo(obj), _mleft(obj), _mtop(obj),
691 _mwidth(obj), _mheight(obj));
693 layerrefresh =
694 (_rp(obj)->Layer->Flags & LAYERREFRESH) ? TRUE : FALSE;
696 ScrollRaster(_rp(obj), scrollAmountX, 0, _mleft(obj), _mtop(obj),
697 _mright(obj), _mbottom(obj));
699 redrawRectangle(redrawX1, redrawY1, redrawX2, redrawY2, obj,
700 data);
702 if ((_rp(obj)->Layer->Flags & LAYERREFRESH) && !layerrefresh)
703 scroll_caused_damage = TRUE;
704 else
705 scroll_caused_damage = FALSE;
707 MUI_RemoveClipping(muiRenderInfo(obj), clip);
709 if (scroll_caused_damage)
711 struct Region *damageList;
712 WORD x1,
717 // get the damage area bounds in x1,x2,y1,y2
718 LockLayer(0, _window(obj)->WLayer);
719 damageList = _window(obj)->WLayer->DamageList;
720 x1 = damageList->bounds.MinX;
721 y1 = damageList->bounds.MinY;
722 x2 = damageList->bounds.MaxX;
723 y2 = damageList->bounds.MaxY;
724 UnlockLayer(_window(obj)->WLayer);
726 if (MUI_BeginRefresh(muiRenderInfo(obj), 0))
728 EraseRect(_rp(obj), x1, y1, x2, y2);
729 redrawRectangle(x1, y1, x2, y2, obj, data);
731 MUI_EndRefresh(muiRenderInfo(obj), 0);
735 data->horizScroll = FALSE;
738 return retval;
741 IPTR iconConSet(Class * cl, Object * obj, struct opSet * msg)
743 struct IconContainerClassData *data;
744 IPTR retval;
745 struct TagItem *tag,
746 *tstate = msg->ops_AttrList;
748 data = (struct IconContainerClassData *) INST_DATA(cl, obj);
750 while ((tag = NextTagItem(&tstate)))
752 switch (tag->ti_Tag)
754 case ICA_ScrollToHoriz:
756 data->lastXView = data->xView;
757 data->xView = tag->ti_Data;
758 data->horizScroll = TRUE;
759 MUI_Redraw(obj, MADF_DRAWUPDATE);
760 break;
762 case ICA_ScrollToVert:
764 data->lastYView = data->yView;
765 data->yView = tag->ti_Data;
766 data->vertScroll = TRUE;
767 MUI_Redraw(obj, MADF_DRAWUPDATE);
768 break;
769 case ICA_Open:
771 data->open = tag->ti_Data;
772 SetAttrs(_win(obj), MUIA_Window_Open, FALSE, TAG_END);
773 break;
774 case ICA_ViewMode:
776 ULONG iconViewMode = IAVM_LARGEICON;
777 struct MemberNode *mn;
778 struct MUI_MinMax minMax;
780 data->viewMode = tag->ti_Data;
781 switch (data->viewMode)
783 case ICAVM_LARGE:
784 iconViewMode = IAVM_LARGEICON;
785 break;
786 case ICAVM_SMALL:
787 iconViewMode = IAVM_SMALLICON;
788 break;
789 case ICAVM_DETAIL:
790 iconViewMode = IAVM_DETAIL;
791 break;
794 _memberCount(obj) = 0;
795 data->thisColumnWidth = 0;
796 data->thisColumnHeight = 0;
797 data->virtualWidth = 0;
798 data->virtualHeight = 0;
800 // mn = (struct MemberNode *) data->memberList.mlh_Head;
801 mn = (struct MemberNode *) _memberList(obj).mlh_Head;
802 while (mn->m_Node.mln_Succ)
804 DoMethod(mn->m_Object, MUIM_Hide);
805 SetAttrs(mn->m_Object, IA_ViewMode, iconViewMode,
806 TAG_END);
807 muiNotifyData(mn->m_Object)->mnd_ParentObject = obj;
808 DoMethod(mn->m_Object, MUIM_ConnectParent, (IPTR) obj);
809 DoMethod(mn->m_Object, MUIM_AskMinMax, (IPTR) &minMax);
811 _minwidth(mn->m_Object) = minMax.MinWidth;
812 _minheight(mn->m_Object) = minMax.MinHeight;
813 _maxwidth(mn->m_Object) = minMax.MaxWidth;
814 _maxheight(mn->m_Object) = minMax.MaxHeight;
815 _defwidth(mn->m_Object) = minMax.DefWidth;
816 _defheight(mn->m_Object) = minMax.DefHeight;
818 _memberCount(obj)++;
820 layoutObject(data, obj, mn->m_Object);
821 DoMethod(mn->m_Object, MUIM_Show);
823 SetAttrs(data->horizProp, MUIA_Prop_Entries,
824 data->virtualWidth, TAG_END);
825 SetAttrs(data->vertProp, MUIA_Prop_Entries,
826 data->virtualHeight, TAG_END);
828 mn = (struct MemberNode *) mn->m_Node.mln_Succ;
831 MUI_Redraw(obj, MADF_DRAWALL);
832 break;
834 default:
835 break;
839 retval = DoSuperMethodA(cl, obj, (Msg) msg);
841 return 0;
844 IPTR iconConGet(Class * cl, Object * obj, struct opGet * msg)
846 IPTR retval = 1;
847 struct IconContainerClassData *data;
849 data = (struct IconContainerClassData *) INST_DATA(cl, obj);
851 switch (msg->opg_AttrID)
853 case ICA_Open:
854 *msg->opg_Storage = (ULONG) data->open;
855 break;
856 default:
857 retval = DoSuperMethodA(cl, obj, (Msg) msg);
858 break;
861 return retval;
864 IPTR iconConConnectParent(Class * cl, Object * obj,
865 struct MUIP_ConnectParent * msg)
867 struct IconContainerClassData *data;
868 IPTR retval;
870 retval = DoSuperMethodA(cl, obj, msg);
872 data = (struct IconContainerClassData *) INST_DATA(cl, obj);
874 if (data->horizProp)
876 muiNotifyData(data->horizProp)->mnd_ParentObject = obj;
877 DoMethod(data->horizProp, MUIM_ConnectParent, (IPTR) obj);
879 if (data->vertProp)
881 muiNotifyData(data->vertProp)->mnd_ParentObject = obj;
882 DoMethod(data->vertProp, MUIM_ConnectParent, (IPTR) obj);
885 return retval;
888 IPTR iconConHandleInput(Class * cl, Object * obj,
889 struct MUIP_HandleInput * msg)
891 IPTR retval = 0;
893 struct IconContainerClassData *data;
895 data = (struct IconContainerClassData *) INST_DATA(cl, obj);
897 if (msg->imsg)
899 switch (msg->imsg->Class)
901 case IDCMP_MOUSEBUTTONS:
903 if (msg->imsg->Code == SELECTDOWN)
905 // kprintf("ic handleinput\n");
907 if (msg->imsg->MouseX >= _mleft(obj)
908 && msg->imsg->MouseX <= _mright(obj)
909 && msg->imsg->MouseY >= _mtop(obj)
910 && msg->imsg->MouseY <= _mbottom(obj))
912 // kprintf("ic1\n");
913 // if(!data->justSelected)
914 // {
915 // kprintf("ic2\n");
916 // DoMethod(obj, ICM_UnselectAll);
917 // }
918 // else
919 // {
920 // kprintf("ic3\n");
921 // data->justSelected=FALSE;
922 // }
923 // kprintf("ic4\n");
926 break;
931 return retval;
934 IPTR iconConDispose(Class * cl, Object * obj, Msg msg)
936 IPTR retval;
938 SetAttrs(obj, ICA_DeleteMe, TRUE, TAG_END);
940 retval = DoSuperMethodA(cl, obj, msg);
942 return retval;
945 IPTR iconConGetColumn(Class * cl, Object * obj, struct opGetColumn * msg)
947 struct IconContainerClassData *data;
948 BOOL found = FALSE;
949 ULONG i = 0;
950 struct DetailColumn *dc = NULL;
952 data = (struct IconContainerClassData *) INST_DATA(cl, obj);
954 while (!found && i < data->numColumns)
956 if (data->columns[i].dc_Content == msg->colType)
958 found = TRUE;
959 dc = &data->columns[i];
961 i++;
964 return (IPTR) dc;
967 BOOPSI_DISPATCHER(IPTR, iconContainerDispatcher, cl, obj, msg)
969 ULONG retval = 0;
971 switch (msg->MethodID)
973 case OM_NEW:
974 retval = iconConNew(cl, obj, (struct opSet *) msg);
975 break;
976 case MUIM_Setup:
977 retval = iconConSetup(cl, obj, (struct MUIP_Setup *) msg);
978 break;
979 case MUIM_Cleanup:
980 retval = iconConCleanup(cl, obj, (struct MUIP_Cleanup *) msg);
981 break;
982 case MUIM_Show:
983 retval = iconConShow(cl, obj, msg);
984 break;
985 case MUIM_Draw:
986 retval = iconConDraw(cl, obj, (struct MUIP_Draw *) msg);
987 break;
988 case MUIM_AskMinMax:
989 retval = iconConAskMinMax(cl, obj, (struct MUIP_AskMinMax *) msg);
990 break;
991 case MUIM_Layout:
992 retval = iconConLayout(cl, obj, msg);
993 break;
994 case MUIM_DrawBackground:
995 break;
996 case OM_ADDMEMBER:
997 retval = iconConAdd(cl, obj, (struct opMember *) msg);
998 break;
999 case OM_SET:
1000 retval = iconConSet(cl, obj, (struct opSet *) msg);
1001 break;
1002 case OM_GET:
1003 retval = iconConGet(cl, obj, (struct opGet *) msg);
1004 break;
1005 case MUIM_ConnectParent:
1006 retval =
1007 iconConConnectParent(cl, obj,
1008 (struct MUIP_ConnectParent *) msg);
1009 break;
1010 case MUIM_HandleInput:
1011 retval =
1012 iconConHandleInput(cl, obj, (struct MUIP_HandleInput *) msg);
1013 break;
1014 case OM_DISPOSE:
1015 retval = iconConDispose(cl, obj, msg);
1016 break;
1017 case ICM_GetColumn:
1018 retval = iconConGetColumn(cl, obj, (struct opGetColumn *) msg);
1019 break;
1020 default:
1021 retval = DoSuperMethodA(cl, obj, msg);
1022 break;
1025 return retval;
1027 BOOPSI_DISPATCHER_END