Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / system / Wanderer / Classes / icon.c
blob4eab8f702b614e7e2785124652e8bc4a0272b200
1 /*
2 Copyright 2008-2009, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "../portable_macros.h"
7 #ifndef __AROS__
8 #define WANDERER_BUILTIN_ICONLIST 1
9 #else
10 #define DEBUG 0
11 #include <aros/debug.h>
12 #endif
14 #define DEBUG_ILC_EVENTS
15 #define DEBUG_ILC_KEYEVENTS
16 #define DEBUG_ILC_ICONRENDERING
17 #define DEBUG_ILC_ICONSORTING
18 #define DEBUG_ILC_ICONSORTING_DUMP
19 #define DEBUG_ILC_ICONPOSITIONING
20 #define DEBUG_ILC_LASSO
21 #define DEBUG_ILC_MEMALLOC
23 #define CREATE_FULL_DRAGIMAGE
25 #include <string.h>
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <string.h>
29 #include <math.h>
31 #include <dos/dos.h>
32 #include <dos/datetime.h>
33 #include <dos/filehandler.h>
35 #include <exec/memory.h>
36 #include <graphics/gfx.h>
37 #include <graphics/view.h>
38 #include <graphics/rpattr.h>
39 #include <workbench/icon.h>
40 #include <workbench/workbench.h>
42 #ifdef __AROS__
43 #include <devices/rawkeycodes.h>
44 #include <clib/alib_protos.h>
45 #else
46 #include <devices_AROS/rawkeycodes.h>
47 #endif
50 #include <proto/exec.h>
51 #include <proto/graphics.h>
52 #include <proto/utility.h>
53 #include <proto/dos.h>
54 #include <proto/icon.h>
55 #include <proto/layers.h>
56 #include <proto/dos.h>
57 #include <proto/iffparse.h>
59 #ifdef __AROS__
60 #include <prefs/prefhdr.h>
61 #include <prefs/wanderer.h>
62 #else
63 #include <prefs_AROS/prefhdr.h>
64 #include <prefs_AROS/wanderer.h>
65 #endif
67 #include <proto/cybergraphics.h>
69 #ifdef __AROS__
70 #include <cybergraphx/cybergraphics.h>
71 #else
72 #include <cybergraphx_AROS/cybergraphics.h>
73 #endif
76 #if defined(__AMIGA__) && !defined(__PPC__)
77 #define NO_INLINE_STDARG
78 #endif
79 #include <proto/intuition.h>
80 #include <proto/muimaster.h>
81 #include <libraries/mui.h>
82 #include "icon_attributes.h"
83 #include "icon.h"
84 #include "icon_private.h"
86 #include "iconlist_attributes.h"
88 #include "iconlistview.h"
90 #ifndef __AROS__
91 #define DEBUG 1
93 #ifdef DEBUG
94 #define D(x) if (DEBUG) x
95 #ifdef __amigaos4__
96 #define bug DebugPrintF
97 #else
98 #define bug kprintf
99 #endif
100 #else
101 #define D(...)
102 #endif
103 #endif
105 #define _between(a,x,b) ((x)>=(a) && (x)<=(b))
106 #define _isinobject(x,y) (_between(_mleft(obj),(x),_mright (obj)) \
107 && _between(_mtop(obj) ,(y),_mbottom(obj)))
109 extern struct Library *MUIMasterBase;
111 struct Hook __icon_UpdateLabels_hook;
113 // N.B: We Handle frame/background rendering so make sure icon.library doesnt do it ..
114 struct TagItem __iconList_DrawIconStateTags[] = {
115 { ICONDRAWA_Frameless, TRUE},
116 { ICONDRAWA_Borderless, TRUE},
117 { ICONDRAWA_EraseBackground, FALSE},
118 { TAG_DONE, }
121 #ifndef NO_ICON_POSITION
122 #define NO_ICON_POSITION (0x8000000) /* belongs to workbench/workbench.h */
123 #endif
125 #define UPDATE_SINGLEICON 1
126 #define UPDATE_SCROLL 2
127 #define UPDATE_SORT 3
128 #define UPDATE_RESIZE 4
130 #define LEFT_BUTTON 1
131 #define RIGHT_BUTTON 2
132 #define MIDDLE_BUTTON 4
134 #define ICONLIST_DRAWMODE_NORMAL 1
135 #define ICONLIST_DRAWMODE_FAST 2
137 /**************************************************************************
138 Support Functions
139 **************************************************************************/
141 #define ForeachNodeReversed(list, node) \
142 for \
144 node = (void *)(((struct List *)(list))->lh_TailPred); \
145 ((struct Node *)(node))->ln_Pred; \
146 node = (void *)(((struct Node *)(node))->ln_Pred) \
149 #ifdef AndRectRect
150 /* Fine */
151 #else
152 #ifdef __AROS__
153 #error "Implement AndRectRect (rom/graphics/andrectrect.c)"
154 #else
155 #warning "Implement AndRectRect (rom/graphics/andrectrect.c)"
156 #endif
157 #endif
159 ///RectAndRect()
160 // Icon/Label Area support functions
161 int RectAndRect(struct Rectangle *a, struct Rectangle *b)
163 if ((a->MinX > b->MaxX) || (a->MinY > b->MaxY) || (a->MaxX < b->MinX) || (a->MaxY < b->MinY))
164 return 0;
165 return 1;
169 ///Icon_GetIconImageRectangle()
170 //We don't use icon.library's label drawing so we do this by hand
171 static void Icon_GetIconImageRectangle(Object *obj, struct Icon_DATA *data, struct Rectangle *rect)
173 #if defined(DEBUG_ILC_ICONPOSITIONING)
174 D(bug("[Icon]: %s(icon @ %p)\n", __PRETTY_FUNCTION__, icon));
175 #endif
177 /* Get basic width/height */
178 GetIconRectangleA(NULL, data->IcD_DiskObj, NULL, rect, NULL);
179 #if defined(DEBUG_ILC_ICONPOSITIONING)
180 D(bug("[Icon] %s: MinX %d, MinY %d MaxX %d, MaxY %d\n", __PRETTY_FUNCTION__, rect->MinX, rect->MinY, rect->MaxX, rect->MaxY));
181 #endif
182 data->IcD_IconWidth = (rect->MaxX - rect->MinX) + 1;
183 data->IcD_IconHeight = (rect->MaxY - rect->MinY) + 1;
185 // if (data->IcD_IconHeight > data->icld_IconLargestHeight)
186 // data->icld_IconLargestHeight = icon->IcD_IconHeight;
190 ///Icon_GetIconLabelRectangle()
191 static void Icon_GetIconLabelRectangle(Object *obj, struct Icon_DATA *data, struct Rectangle *rect)
193 ULONG outline_offset = 0;
194 ULONG textwidth = 0;
196 #if defined(DEBUG_ILC_ICONPOSITIONING)
197 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
198 #endif
200 switch ( XGET(_parent(obj), MUIA_IconList_LabelText_Mode) )
202 case ICON_TEXTMODE_DROPSHADOW:
203 outline_offset = 1;
204 break;
206 case ICON_TEXTMODE_PLAIN:
207 break;
209 default:
210 outline_offset = 2;
211 break;
214 /* Get icon box width including text width */
215 if ((icon->IcD_Label_TXTBUFF != NULL) && (icon->IcD_DisplayedLabel_TXTBUFF != NULL))
217 ULONG curlabel_TotalLines;
218 SetFont(data->icld_BufferRastPort, data->icld_IconLabelFont);
220 rect->MinX = 0;
221 rect->MaxX = (((data->icld__Option_LabelTextHorizontalPadding + data->icld__Option_LabelTextBorderWidth) * 2) + icon->IcD_DisplayedLabel_Width + outline_offset) - 1;
223 rect->MinY = 0;
225 curlabel_TotalLines = icon->IcD_DisplayedLabel_SplitParts;
226 if (curlabel_TotalLines == 0)
227 curlabel_TotalLines = 1;
228 if (curlabel_TotalLines > XGET(_parent(obj), MUIA_Icon_LabelText_MultiLine))
229 curlabel_TotalLines = XGET(_parent(obj), MUIA_Icon_LabelText_MultiLine);
231 rect->MaxY = (((data->icld__Option_LabelTextBorderHeight + data->icld__Option_LabelTextVerticalPadding) * 2) +
232 ((data->icld_IconLabelFont->tf_YSize + outline_offset) * curlabel_TotalLines)) - 1;
234 /* Date/size sorting has the date/size appended under the icon label
235 only list regular files like this (drawers have no size/date output) */
237 icon->IcD_IconEntry.type != ST_USERDIR &&
238 ((data->icld_SortFlags & ICONLIST_SORT_BY_SIZE) || (data->icld_SortFlags & ICONLIST_SORT_BY_DATE))
241 SetFont(data->icld_BufferRastPort, data->icld_IconInfoFont);
243 if( (data->icld_SortFlags & ICONLIST_SORT_BY_SIZE) && !(data->icld_SortFlags & ICONLIST_SORT_BY_DATE) )
245 icon->IcD_Size_Width = TextLength(data->icld_BufferRastPort, icon->IcD_Size_TXTBUFF, strlen(icon->IcD_Size_TXTBUFF));
246 textwidth = icon->IcD_Size_Width;
248 else
250 if( !(data->icld_SortFlags & ICONLIST_SORT_BY_SIZE) && (data->icld_SortFlags & ICONLIST_SORT_BY_DATE) )
252 if( icon->IcD_Flags & ICONENTRY_FLAG_TODAY )
254 icon->IcD_Time_Width = TextLength(data->icld_BufferRastPort, icon->IcD_Time_TXTBUFF, strlen(icon->IcD_Time_TXTBUFF));
255 textwidth = icon->IcD_Time_Width;
257 else
259 icon->IcD_Date_Width = TextLength(data->icld_BufferRastPort, icon->IcD_Date_TXTBUFF, strlen(icon->IcD_Date_TXTBUFF));
260 textwidth = icon->IcD_Date_Width;
265 if (textwidth > 0)
267 rect->MaxY = rect->MaxY + data->icld_IconInfoFont->tf_YSize + outline_offset;
268 if ((textwidth + outline_offset + ((data->icld__Option_LabelTextHorizontalPadding + data->icld__Option_LabelTextBorderWidth) * 2)) > ((rect->MaxX - rect->MinX) + 1))
269 rect->MaxX = (textwidth + outline_offset + ((data->icld__Option_LabelTextVerticalPadding + data->icld__Option_LabelTextBorderWidth) * 2)) - 1;
273 if (((rect->MaxY - rect->MinY) + 1) > data->icld_LabelLargestHeight) data->icld_LabelLargestHeight = ((rect->MaxY - rect->MinY) + 1);
277 ///Icon_GetIconAreaRectangle()
278 static void Icon_GetIconAreaRectangle(Object *obj, struct Icon_DATA *data, struct IconEntry *icon, struct Rectangle *rect)
280 struct Rectangle labelrect;
281 ULONG iconlabel_Width;
282 ULONG iconlabel_Height;
284 #if defined(DEBUG_ILC_ICONPOSITIONING)
285 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
286 #endif
288 /* Get icon box width including text width */
289 memset(rect, 0, sizeof(struct Rectangle));
291 Icon_GetIconImageRectangle(obj, data, icon, rect);
293 icon->IcD_AreaWidth = icon->IcD_IconWidth;
294 if (data->icld__Option_IconMode == ICON_LISTMODE_GRID)
296 icon->IcD_AreaHeight = data->icld_IconLargestHeight;
298 else
300 icon->IcD_AreaHeight = icon->IcD_IconHeight;
303 Icon_GetIconLabelRectangle(obj, data, icon, &labelrect);
305 iconlabel_Width = ((labelrect.MaxX - labelrect.MinX) + 1);
306 iconlabel_Height = ((labelrect.MaxY - labelrect.MinY) + 1);
308 if (iconlabel_Width > icon->IcD_AreaWidth)
309 icon->IcD_AreaWidth = iconlabel_Width;
311 icon->IcD_AreaHeight = icon->IcD_AreaHeight + data->icld__Option_IconImageSpacing + iconlabel_Height;
313 /* Store */
314 rect->MaxX = (rect->MinX + icon->IcD_AreaWidth) - 1;
315 rect->MaxY = (rect->MinY + icon->IcD_AreaHeight) - 1;
317 if (icon->IcD_AreaWidth > data->icld_IconAreaLargestWidth) data->icld_IconAreaLargestWidth = icon->IcD_AreaWidth;
318 if (icon->IcD_AreaHeight > data->icld_IconAreaLargestHeight) data->icld_IconAreaLargestHeight = icon->IcD_AreaHeight;
321 /**************************************************************************
322 Draw the icon at its position
323 **************************************************************************/
324 ///Icon__MUIM_Icon_DrawEntry()
325 IPTR Icon__MUIM_Icon_DrawEntry(struct IClass *CLASS, Object *obj, struct MUIP_Icon_DrawEntry *message)
327 struct Icon_DATA *data = INST_DATA(CLASS, obj);
329 struct Rectangle iconrect;
330 struct Rectangle objrect;
332 //LONG tx,ty;
333 LONG offsetx,offsety;
334 //LONG txwidth, txheight;
336 ULONG iconX;
337 ULONG iconY;
339 #if defined(DEBUG_ILC_ICONRENDERING)
340 D(bug("[Icon]: %s(message->icon = 0x%p)\n", __PRETTY_FUNCTION__, message->icon));
341 #endif
343 if ((!(message->icon->IcD_Flags & ICONENTRY_FLAG_VISIBLE)) ||
344 (data->icld_BufferRastPort == NULL) ||
345 (!(message->icon->IcD_DiskObj)))
347 #if defined(DEBUG_ILC_ICONRENDERING)
348 D(bug("[Icon] %s: Not visible or missing DOB\n", __PRETTY_FUNCTION__));
349 #endif
350 return FALSE;
353 /* Get the dimensions and affected area of message->icon */
354 Icon_GetIconImageRectangle(obj, data, message->icon, &iconrect);
356 /* Add the relative position offset of the message->icon */
357 offsetx = _mleft(obj) - data->icld_ViewX + message->icon->IcD_IconX;
358 /* Centre our image with our text */
359 if (message->icon->IcD_IconWidth < message->icon->IcD_AreaWidth)
360 offsetx += (message->icon->IcD_AreaWidth - message->icon->IcD_IconWidth)/2;
362 if ((data->icld__Option_IconMode == ICON_LISTMODE_GRID) &&
363 (message->icon->IcD_AreaWidth < data->icld_IconAreaLargestWidth))
364 offsetx += ((data->icld_IconAreaLargestWidth - message->icon->IcD_AreaWidth)/2);
366 iconrect.MinX += offsetx;
367 iconrect.MaxX += offsetx;
369 offsety = _mtop(obj) - data->icld_ViewY + message->icon->IcD_IconY;
370 iconrect.MinY += offsety;
371 iconrect.MaxY += offsety;
373 /* Add the relative position of the window */
374 objrect.MinX = _mleft(obj);
375 objrect.MinY = _mtop(obj);
376 objrect.MaxX = _mright(obj);
377 objrect.MaxY = _mbottom(obj);
379 if (!RectAndRect(&iconrect, &objrect)) return FALSE;
381 /* data->update_rect1 and data->update_rect2 may
382 point to rectangles to indicate that only icons
383 in any of this rectangles need to be drawn */
385 if (data->update_rect1 && data->update_rect2)
387 if (!RectAndRect(&iconrect, data->update_rect1) &&
388 !RectAndRect(&iconrect, data->update_rect2)) return FALSE;
390 else if (data->update_rect1)
392 if (!RectAndRect(&iconrect, data->update_rect1)) return FALSE;
394 else if (data->update_rect2)
396 if (!RectAndRect(&iconrect, data->update_rect2)) return FALSE;
399 if (message->drawmode == ICONENTRY_DRAWMODE_NONE) return TRUE;
401 // Center icon image
402 iconX = iconrect.MinX - _mleft(obj) + data->icld_DrawOffsetX;
403 iconY = iconrect.MinY - _mtop(obj) + data->icld_DrawOffsetY;
405 DrawIconStateA
407 data->icld_BufferRastPort ? data->icld_BufferRastPort : data->icld_BufferRastPort, message->icon->IcD_DiskObj, NULL,
408 iconX,
409 iconY,
410 (message->icon->IcD_Flags & ICONENTRY_FLAG_SELECTED) ? IDS_SELECTED : IDS_NORMAL,
411 __iconList_DrawIconStateTags
414 return TRUE;
418 ///Icon__LabelFunc_SplitLabel()
419 void Icon__LabelFunc_SplitLabel(Object *obj, struct Icon_DATA *data, struct IconEntry *icon)
421 ULONG labelSplit_MaxLabelLineLength = XGET(_parent(obj), MUIA_Icon_LabelText_MaxLineLen);
422 ULONG labelSplit_LabelLength = strlen(icon->IcD_Label_TXTBUFF);
423 ULONG txwidth;
424 ULONG labelSplit_FontY = data->icld_IconLabelFont->tf_YSize;
425 int labelSplit_CharsDone, labelSplit_CharsSplit;
426 ULONG labelSplit_CurSplitWidth;
428 if ((data->icld__Option_TrimVolumeNames) &&
429 ((icon->IcD_IconEntry.type == ST_ROOT) && (icon->IcD_Label_TXTBUFF[labelSplit_LabelLength - 1] == ':')))
430 labelSplit_LabelLength--;
432 if (labelSplit_MaxLabelLineLength >= labelSplit_LabelLength)
434 #if defined(DEBUG_ILC_ICONRENDERING)
435 D(bug("[Icon]: %s: Label'%s' doesnt need split (onyl %d chars)\n", __PRETTY_FUNCTION__, icon->IcD_Label_TXTBUFF, labelSplit_LabelLength));
436 #endif
437 return;
440 SetFont(data->icld_BufferRastPort, data->icld_IconLabelFont);
441 txwidth = TextLength(data->icld_BufferRastPort, icon->IcD_Label_TXTBUFF, labelSplit_MaxLabelLineLength);
442 #if defined(DEBUG_ILC_ICONRENDERING)
443 D(bug("[Icon]: %s: txwidth = %d\n", __PRETTY_FUNCTION__, txwidth));
444 #endif
445 icon->IcD_DisplayedLabel_TXTBUFF = AllocVecPooled(data->icld_Pool, 256);
446 memset(icon->IcD_DisplayedLabel_TXTBUFF, 0, 256);
447 icon->IcD_DisplayedLabel_SplitParts = 0;
449 labelSplit_CharsDone = 0;
450 labelSplit_CharsSplit = 0;
452 while (labelSplit_CharsDone < labelSplit_LabelLength)
454 ULONG labelSplit_CurSplitLength = labelSplit_LabelLength - labelSplit_CharsDone;
455 IPTR labelSplit_SplitStart = icon->IcD_Label_TXTBUFF + labelSplit_CharsDone;
456 int tmp_checkoffs = 0;
457 IPTR labelSplit_RemainingCharsAfterSplit;
458 IPTR labelSplit_CurSplitDest;
460 while (*(char *)(labelSplit_SplitStart) == ' ')
462 //Skip preceding spaces..
463 labelSplit_SplitStart = labelSplit_SplitStart + 1;
464 labelSplit_CurSplitLength = labelSplit_CurSplitLength - 1;
465 labelSplit_CharsDone = labelSplit_CharsDone + 1;
468 while(TextLength(data->icld_BufferRastPort, labelSplit_SplitStart, labelSplit_CurSplitLength) < txwidth) labelSplit_CurSplitLength++;
469 while(TextLength(data->icld_BufferRastPort, labelSplit_SplitStart, labelSplit_CurSplitLength) > txwidth) labelSplit_CurSplitLength--;
470 #if defined(DEBUG_ILC_ICONRENDERING)
471 D(bug("[Icon]: %s: labelSplit_CurSplitLength = %d\n", __PRETTY_FUNCTION__, labelSplit_CurSplitLength));
472 #endif
474 #if defined(DEBUG_ILC_ICONRENDERING)
475 D(bug("[Icon]: %s: Attempting to find neat split ", __PRETTY_FUNCTION__));
476 #endif
477 while(tmp_checkoffs < (labelSplit_CurSplitLength - ILC_ICONLABEL_SHORTEST))
479 #if defined(DEBUG_ILC_ICONRENDERING)
480 D(bug("%d", tmp_checkoffs));
481 #endif
482 labelSplit_RemainingCharsAfterSplit = labelSplit_LabelLength - (labelSplit_CharsDone + labelSplit_CurSplitLength);
484 if ((labelSplit_CurSplitLength - tmp_checkoffs) > ILC_ICONLABEL_SHORTEST)
486 #if defined(DEBUG_ILC_ICONRENDERING)
487 D(bug("<"));
488 #endif
489 if ((*(char *)(labelSplit_SplitStart + labelSplit_CurSplitLength - tmp_checkoffs) == ' ') ||
490 (*(char *)(labelSplit_SplitStart + labelSplit_CurSplitLength - tmp_checkoffs) == '.') ||
491 (*(char *)(labelSplit_SplitStart + labelSplit_CurSplitLength - tmp_checkoffs) == '-'))
493 #if defined(DEBUG_ILC_ICONRENDERING)
494 D(bug("!"));
495 #endif
496 labelSplit_CurSplitLength = labelSplit_CurSplitLength - tmp_checkoffs;
497 labelSplit_RemainingCharsAfterSplit = labelSplit_RemainingCharsAfterSplit - tmp_checkoffs;
498 tmp_checkoffs = 0;
499 break;
503 if ((labelSplit_RemainingCharsAfterSplit - tmp_checkoffs) < 0)
505 #if defined(DEBUG_ILC_ICONRENDERING)
506 D(bug("="));
507 #endif
508 labelSplit_CurSplitLength = labelSplit_CurSplitLength + tmp_checkoffs;
509 labelSplit_RemainingCharsAfterSplit = labelSplit_RemainingCharsAfterSplit + tmp_checkoffs;
510 tmp_checkoffs = 0;
511 break;
514 if ((labelSplit_RemainingCharsAfterSplit - tmp_checkoffs) >= ILC_ICONLABEL_SHORTEST)
516 #if defined(DEBUG_ILC_ICONRENDERING)
517 D(bug(">"));
518 #endif
519 if ((*(char *)(labelSplit_SplitStart + labelSplit_CurSplitLength + tmp_checkoffs) == ' ') ||
520 (*(char *)(labelSplit_SplitStart + labelSplit_CurSplitLength + tmp_checkoffs) == '.') ||
521 (*(char *)(labelSplit_SplitStart + labelSplit_CurSplitLength + tmp_checkoffs) == '-'))
523 #if defined(DEBUG_ILC_ICONRENDERING)
524 D(bug("!"));
525 #endif
526 labelSplit_CurSplitLength = labelSplit_CurSplitLength + tmp_checkoffs;
527 labelSplit_RemainingCharsAfterSplit = labelSplit_RemainingCharsAfterSplit + tmp_checkoffs;
528 tmp_checkoffs = 0;
529 break;
533 tmp_checkoffs = tmp_checkoffs + 1;
535 #if defined(DEBUG_ILC_ICONRENDERING)
536 D(bug("\n"));
537 #endif
538 if (tmp_checkoffs != 0)
540 #if defined(DEBUG_ILC_ICONRENDERING)
541 D(bug("[Icon]: %s: Couldnt find neat split : Still %d chars\n", __PRETTY_FUNCTION__, labelSplit_RemainingCharsAfterSplit));
542 #endif
543 if (labelSplit_RemainingCharsAfterSplit <= ILC_ICONLABEL_SHORTEST)
545 labelSplit_CurSplitLength = labelSplit_CurSplitLength + (labelSplit_RemainingCharsAfterSplit - ILC_ICONLABEL_SHORTEST);
548 if ((labelSplit_CharsDone + labelSplit_CurSplitLength) > labelSplit_LabelLength) labelSplit_CurSplitLength = labelSplit_LabelLength - labelSplit_CharsDone;
550 labelSplit_CurSplitDest = icon->IcD_DisplayedLabel_TXTBUFF + labelSplit_CharsSplit + icon->IcD_DisplayedLabel_SplitParts;
552 strncpy(labelSplit_CurSplitDest, labelSplit_SplitStart, labelSplit_CurSplitLength);
554 labelSplit_CurSplitWidth = TextLength(data->icld_BufferRastPort, labelSplit_CurSplitDest, labelSplit_CurSplitLength);
556 icon->IcD_DisplayedLabel_SplitParts = icon->IcD_DisplayedLabel_SplitParts + 1;
558 labelSplit_CharsDone = labelSplit_CharsDone + labelSplit_CurSplitLength;
559 labelSplit_CharsSplit = labelSplit_CharsSplit + labelSplit_CurSplitLength;
561 if (labelSplit_CurSplitWidth > icon->IcD_DisplayedLabel_Width) icon->IcD_DisplayedLabel_Width = labelSplit_CurSplitWidth;
563 if ((icon->IcD_DisplayedLabel_SplitParts <= 1) && icon->IcD_DisplayedLabel_TXTBUFF)
565 FreeVecPooled(data->icld_Pool, icon->IcD_DisplayedLabel_TXTBUFF);
566 icon->IcD_DisplayedLabel_TXTBUFF = NULL;
567 icon->IcD_DisplayedLabel_SplitParts = 0;
569 // if ((labelSplit_FontY * icon->IcD_DisplayedLabel_SplitParts) > data->icld_LabelLargestHeight) data->icld_LabelLargestHeight = (labelSplit_FontY * icon->IcD_DisplayedLabel_SplitParts);
573 ///Icon__LabelFunc_CreateLabel()
574 IPTR Icon__LabelFunc_CreateLabel(Object *obj, struct Icon_DATA *data, struct IconEntry *icon)
576 #if defined(DEBUG_ILC_ICONRENDERING)
577 D(bug("[Icon]: %s('%s')\n", __PRETTY_FUNCTION__, icon->IcD_Label_TXTBUFF));
578 #endif
579 if (icon->IcD_DisplayedLabel_TXTBUFF)
581 FreeVecPooled(data->icld_Pool, icon->IcD_DisplayedLabel_TXTBUFF);
582 icon->IcD_DisplayedLabel_TXTBUFF = NULL;
583 icon->IcD_DisplayedLabel_SplitParts = 0;
586 if (XGET(_parent(obj), MUIA_Icon_LabelText_MultiLine) > 1)
588 #if defined(DEBUG_ILC_ICONRENDERING)
589 D(bug("[Icon]: %s: Attempting to split label ..\n", __PRETTY_FUNCTION__));
590 #endif
591 Icon__LabelFunc_SplitLabel(obj, data, icon);
594 if (icon->IcD_DisplayedLabel_TXTBUFF == NULL)
596 ULONG IcD_LabelLength = strlen(icon->IcD_Label_TXTBUFF);
597 icon->IcD_DisplayedLabel_SplitParts = 1;
599 #if defined(DEBUG_ILC_ICONRENDERING)
600 D(bug("[Icon]: %s: Building unsplit label (len = %d) ..\n", __PRETTY_FUNCTION__, IcD_LabelLength));
601 #endif
603 if ((data->icld__Option_TrimVolumeNames) &&
604 ((icon->IcD_IconEntry.type == ST_ROOT) && (icon->IcD_Label_TXTBUFF[IcD_LabelLength - 1] == ':')))
605 IcD_LabelLength--;
607 if(IcD_LabelLength > XGET(_parent(obj), MUIA_Icon_LabelText_MaxLineLen))
609 if (!(icon->IcD_DisplayedLabel_TXTBUFF = AllocVecPooled(data->icld_Pool, XGET(_parent(obj), MUIA_Icon_LabelText_MaxLineLen) + 1)))
611 return NULL;
613 memset(icon->IcD_DisplayedLabel_TXTBUFF, 0, XGET(_parent(obj), MUIA_Icon_LabelText_MaxLineLen) + 1);
614 strncpy(icon->IcD_DisplayedLabel_TXTBUFF, icon->IcD_Label_TXTBUFF, XGET(_parent(obj), MUIA_Icon_LabelText_MaxLineLen) - 3);
615 strcat(icon->IcD_DisplayedLabel_TXTBUFF , " ..");
617 else
619 if (!(icon->IcD_DisplayedLabel_TXTBUFF = AllocVecPooled(data->icld_Pool, IcD_LabelLength + 1)))
621 return NULL;
623 memset(icon->IcD_DisplayedLabel_TXTBUFF, 0, IcD_LabelLength + 1);
624 strncpy(icon->IcD_DisplayedLabel_TXTBUFF, icon->IcD_Label_TXTBUFF, IcD_LabelLength );
626 icon->IcD_DisplayedLabel_Width = TextLength(data->icld_BufferRastPort, icon->IcD_DisplayedLabel_TXTBUFF, strlen(icon->IcD_DisplayedLabel_TXTBUFF));
627 // if ((data->icld_IconLabelFont->tf_YSize) > data->icld_LabelLargestHeight) data->icld_LabelLargestHeight = data->icld_IconLabelFont->tf_YSize;
630 // if (icon->IcD_DisplayedLabel_Width > data->icld_LabelLargestWidth) data->icld_LabelLargestWidth = icon->IcD_DisplayedLabel_Width;
632 return icon->IcD_DisplayedLabel_TXTBUFF;
636 ///Icon__MUIM_Icon_DrawEntryLabel()
637 IPTR Icon__MUIM_Icon_DrawEntryLabel(struct IClass *CLASS, Object *obj, struct MUIP_Icon_DrawEntry *message)
639 struct Icon_DATA *data = INST_DATA(CLASS, obj);
641 STRPTR buf = NULL;
643 struct Rectangle iconlabelrect;
644 struct Rectangle objrect;
646 ULONG txtbox_width = 0;
647 LONG tx,ty,offsetx,offsety;
648 LONG txwidth; // txheight;
650 ULONG labelX;
651 ULONG labelY;
652 ULONG txtarea_width;
653 ULONG curlabel_TotalLines, curlabel_CurrentLine, offset_y;
655 #if defined(DEBUG_ILC_ICONRENDERING)
656 D(bug("[Icon]: %s(message->icon = 0x%p), '%s'\n", __PRETTY_FUNCTION__, message->icon, message->icon->IcD_Label_TXTBUFF));
657 #endif
659 if ((!(message->icon->IcD_Flags & ICONENTRY_FLAG_VISIBLE)) ||
660 (data->icld_BufferRastPort == NULL) ||
661 (!(message->icon->IcD_DiskObj)))
663 #if defined(DEBUG_ILC_ICONRENDERING)
664 D(bug("[Icon] %s: Not visible or missing DOB\n", __PRETTY_FUNCTION__));
665 #endif
666 return FALSE;
669 /* Get the dimensions and affected area of message->icon's label */
670 Icon_GetIconLabelRectangle(obj, data, message->icon, &iconlabelrect);
672 /* Add the relative position offset of the message->icon's label */
673 offsetx = (_mleft(obj) - data->icld_ViewX) + message->icon->IcD_IconX;
674 txtbox_width = (iconlabelrect.MaxX - iconlabelrect.MinX) + 1;
676 if (txtbox_width < message->icon->IcD_AreaWidth)
677 offsetx += ((message->icon->IcD_AreaWidth - txtbox_width)/2);
679 if ((data->icld__Option_IconMode == ICON_LISTMODE_GRID) &&
680 (message->icon->IcD_AreaWidth < data->icld_IconAreaLargestWidth))
681 offsetx += ((data->icld_IconAreaLargestWidth - message->icon->IcD_AreaWidth)/2);
683 iconlabelrect.MinX += offsetx;
684 iconlabelrect.MaxX += offsetx;
686 offsety = (_mtop(obj) - data->icld_ViewY) + message->icon->IcD_IconY + data->icld__Option_IconImageSpacing;
687 if (data->icld__Option_IconMode == ICON_LISTMODE_GRID)
689 offsety = offsety + data->icld_IconLargestHeight;
691 else
693 offsety = offsety + message->icon->IcD_IconHeight;
695 iconlabelrect.MinY += offsety;
696 iconlabelrect.MaxY += offsety;
698 /* Add the relative position of the window */
699 objrect.MinX = _mleft(obj);
700 objrect.MinY = _mtop(obj);
701 objrect.MaxX = _mright(obj);
702 objrect.MaxY = _mbottom(obj);
704 if (!RectAndRect(&iconlabelrect, &objrect)) return FALSE;
706 /* data->update_rect1 and data->update_rect2 may
707 point to rectangles to indicate that only icons
708 in any of this rectangles need to be drawn */
710 if (data->update_rect1 && data->update_rect2)
712 if (!RectAndRect(&iconlabelrect, data->update_rect1) &&
713 !RectAndRect(&iconlabelrect, data->update_rect2)) return FALSE;
715 else if (data->update_rect1)
717 if (!RectAndRect(&iconlabelrect, data->update_rect1)) return FALSE;
719 else if (data->update_rect2)
721 if (!RectAndRect(&iconlabelrect, data->update_rect2)) return FALSE;
724 if (message->drawmode == ICONENTRY_DRAWMODE_NONE) return TRUE;
726 SetABPenDrMd(data->icld_BufferRastPort, _pens(obj)[MPEN_TEXT], 0, JAM1);
728 iconlabelrect.MinX = (iconlabelrect.MinX - _mleft(obj)) + data->icld_DrawOffsetX;
729 iconlabelrect.MinY = (iconlabelrect.MinY - _mtop(obj)) + data->icld_DrawOffsetY;
730 iconlabelrect.MaxX = (iconlabelrect.MaxX - _mleft(obj)) + data->icld_DrawOffsetX;
731 iconlabelrect.MaxY = (iconlabelrect.MaxY - _mtop(obj)) + data->icld_DrawOffsetY;
733 labelX = iconlabelrect.MinX + data->icld__Option_LabelTextBorderWidth + data->icld__Option_LabelTextHorizontalPadding;
734 labelY = iconlabelrect.MinY + data->icld__Option_LabelTextBorderHeight + data->icld__Option_LabelTextVerticalPadding;
736 txtarea_width = txtbox_width - ((data->icld__Option_LabelTextBorderWidth + data->icld__Option_LabelTextHorizontalPadding) * 2);
738 if (message->icon->IcD_Label_TXTBUFF && message->icon->IcD_DisplayedLabel_TXTBUFF)
740 char *curlabel_StrPtr;
742 if ((message->icon->IcD_Flags & ICONENTRY_FLAG_FOCUS) && ((BOOL)XGET(_win(obj), MUIA_Window_Activate)))
744 //Draw the focus box around the selected label ..
745 if (data->icld__Option_LabelTextBorderHeight > 0)
747 InvertPixelArray(data->icld_BufferRastPort,
748 iconlabelrect.MinX, iconlabelrect.MinY,
749 (iconlabelrect.MaxX - iconlabelrect.MinX) + 1, data->icld__Option_LabelTextBorderHeight);
751 InvertPixelArray(data->icld_BufferRastPort,
752 iconlabelrect.MinX, iconlabelrect.MaxY - (data->icld__Option_LabelTextBorderHeight - 1),
753 (iconlabelrect.MaxX - iconlabelrect.MinX) + 1, data->icld__Option_LabelTextBorderHeight);
755 if (data->icld__Option_LabelTextBorderWidth > 0)
757 InvertPixelArray(data->icld_BufferRastPort,
758 iconlabelrect.MinX, iconlabelrect.MinY + data->icld__Option_LabelTextBorderHeight,
759 data->icld__Option_LabelTextBorderWidth, (((iconlabelrect.MaxY - iconlabelrect.MinY) + 1) - (data->icld__Option_LabelTextBorderHeight * 2)));
761 InvertPixelArray(data->icld_BufferRastPort,
762 iconlabelrect.MaxX - (data->icld__Option_LabelTextBorderWidth - 1), iconlabelrect.MinY + data->icld__Option_LabelTextBorderHeight,
763 data->icld__Option_LabelTextBorderWidth, (((iconlabelrect.MaxY - iconlabelrect.MinY) + 1) - (data->icld__Option_LabelTextBorderHeight * 2)));
767 SetFont(data->icld_BufferRastPort, data->icld_IconLabelFont);
769 curlabel_TotalLines = message->icon->IcD_DisplayedLabel_SplitParts;
770 curlabel_CurrentLine = 0;
772 if (curlabel_TotalLines == 0)
773 curlabel_TotalLines = 1;
775 if (!(data->icld__Option_LabelTextMultiLineOnFocus) || (data->icld__Option_LabelTextMultiLineOnFocus && (message->icon->IcD_Flags & ICONENTRY_FLAG_FOCUS)))
777 if (curlabel_TotalLines > XGET(_parent(obj), MUIA_Icon_LabelText_MultiLine))
778 curlabel_TotalLines = XGET(_parent(obj), MUIA_Icon_LabelText_MultiLine);
780 else
781 curlabel_TotalLines = 1;
783 curlabel_StrPtr = message->icon->IcD_DisplayedLabel_TXTBUFF;
785 ty = labelY - 1;
787 D(bug("[Icon] %s: Font YSize %d Baseline %d\n", __PRETTY_FUNCTION__,data->icld_IconLabelFont->tf_YSize, data->icld_IconLabelFont->tf_Baseline));
789 for (curlabel_CurrentLine = 0; curlabel_CurrentLine < curlabel_TotalLines; curlabel_CurrentLine++)
791 ULONG IcD_LabelLength;
793 if (curlabel_CurrentLine > 0) curlabel_StrPtr = curlabel_StrPtr + strlen(curlabel_StrPtr) + 1;
794 if ((curlabel_CurrentLine >= (curlabel_TotalLines -1)) && (curlabel_TotalLines < message->icon->IcD_DisplayedLabel_SplitParts))
796 char *tmpLine = curlabel_StrPtr;
797 ULONG tmpLen = strlen(tmpLine);
799 if ((curlabel_StrPtr = AllocVec(tmpLen + 1)) != NULL)
801 memset(curlabel_StrPtr, 0, tmpLen + 1);
802 strncpy(curlabel_StrPtr, tmpLine, tmpLen - 3);
803 strcat(curlabel_StrPtr , " ..");
805 else return FALSE;
809 IcD_LabelLength = strlen(curlabel_StrPtr);
810 offset_y = 0;
812 // Center message->icon's label
813 tx = (labelX + (message->icon->IcD_DisplayedLabel_Width / 2) - (TextLength(data->icld_BufferRastPort, curlabel_StrPtr, strlen(curlabel_StrPtr)) / 2));
815 if (message->icon->IcD_DisplayedLabel_Width < txtarea_width)
816 tx += ((txtarea_width - message->icon->IcD_DisplayedLabel_Width)/2);
818 ty = ty + data->icld_IconLabelFont->tf_YSize;
820 switch ( data->icld__Option_LabelTextMode )
822 case ICON_TEXTMODE_DROPSHADOW:
823 SetAPen(data->icld_BufferRastPort, data->icld_LabelShadowPen);
824 Move(data->icld_BufferRastPort, tx + 1, ty + 1);
825 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
826 offset_y = 1;
827 case ICON_TEXTMODE_PLAIN:
828 SetAPen(data->icld_BufferRastPort, data->icld_LabelPen);
829 Move(data->icld_BufferRastPort, tx, ty);
830 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
831 break;
833 default:
834 // Outline mode:
836 SetSoftStyle(data->icld_BufferRastPort, FSF_BOLD, AskSoftStyle(data->icld_BufferRastPort));
838 SetAPen(data->icld_BufferRastPort, data->icld_LabelShadowPen);
839 Move(data->icld_BufferRastPort, tx + 1, ty );
840 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
841 Move(data->icld_BufferRastPort, tx - 1, ty );
842 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
843 Move(data->icld_BufferRastPort, tx, ty + 1);
844 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
845 Move(data->icld_BufferRastPort, tx, ty - 1);
846 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
848 SetAPen(data->icld_BufferRastPort, data->icld_LabelPen);
849 Move(data->icld_BufferRastPort, tx , ty );
850 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
852 SetSoftStyle(data->icld_BufferRastPort, FS_NORMAL, AskSoftStyle(data->icld_BufferRastPort));
853 offset_y = 2;
854 break;
856 if ((curlabel_CurrentLine >= (curlabel_TotalLines -1)) && (curlabel_TotalLines < message->icon->IcD_DisplayedLabel_SplitParts))
858 FreeVecPooled(data->icld_Pool, curlabel_StrPtr);
860 ty = ty + offset_y;
863 /*date/size sorting has the date/size appended under the message->icon label*/
865 if ((message->icon->IcD_IconEntry.type != ST_USERDIR) && ((data->icld_SortFlags & ICONLIST_SORT_BY_SIZE|ICONLIST_SORT_BY_DATE) != 0))
867 buf = NULL;
868 SetFont(data->icld_BufferRastPort, data->icld_IconInfoFont);
870 if ((data->icld_SortFlags & ICONLIST_SORT_MASK) == ICONLIST_SORT_BY_SIZE)
872 buf = message->icon->IcD_Size_TXTBUFF;
873 txwidth = message->icon->IcD_Size_Width;
875 else if ((data->icld_SortFlags & ICONLIST_SORT_MASK) == ICONLIST_SORT_BY_DATE)
877 if (message->icon->IcD_Flags & ICONENTRY_FLAG_TODAY)
879 buf = message->icon->IcD_Time_TXTBUFF;
880 txwidth = message->icon->IcD_Time_Width;
882 else
884 buf = message->icon->IcD_Date_TXTBUFF;
885 txwidth = message->icon->IcD_Date_Width;
889 if (buf)
891 ULONG IcD_LabelLength = strlen(buf);
892 tx = labelX;
894 if (txwidth < txtarea_width)
895 tx += ((txtarea_width - txwidth)/2);
897 ty = labelY + ((data->icld__Option_LabelTextVerticalPadding + data->icld_IconLabelFont->tf_YSize ) * curlabel_TotalLines) + data->icld_IconInfoFont->tf_YSize;
899 switch ( data->icld__Option_LabelTextMode )
901 case ICON_TEXTMODE_DROPSHADOW:
902 SetAPen(data->icld_BufferRastPort, data->icld_InfoShadowPen);
903 Move(data->icld_BufferRastPort, tx + 1, ty + 1); Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
904 case ICON_TEXTMODE_PLAIN:
905 SetAPen(data->icld_BufferRastPort, XGET(_parent(obj), MUIA_IconList_LabelInfoText_Pen));
906 Move(data->icld_BufferRastPort, tx, ty); Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
907 break;
909 default:
910 // Outline mode..
911 SetSoftStyle(data->icld_BufferRastPort, FSF_BOLD, AskSoftStyle(data->icld_BufferRastPort));
912 SetAPen(data->icld_BufferRastPort, data->icld_InfoShadowPen);
914 Move(data->icld_BufferRastPort, tx + 1, ty );
915 Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
916 Move(data->icld_BufferRastPort, tx - 1, ty );
917 Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
918 Move(data->icld_BufferRastPort, tx, ty - 1 );
919 Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
920 Move(data->icld_BufferRastPort, tx, ty + 1 );
921 Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
923 SetAPen(data->icld_BufferRastPort, XGET(_parent(obj), MUIA_IconList_LabelInfoText_Pen));
925 Move(data->icld_BufferRastPort, tx, ty );
926 Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
928 SetSoftStyle(data->icld_BufferRastPort, FS_NORMAL, AskSoftStyle(data->icld_BufferRastPort));
929 break;
935 return TRUE;
938 ///OM_NEW()
939 /**************************************************************************
940 OM_NEW
941 **************************************************************************/
942 IPTR Icon__OM_NEW(struct IClass *CLASS, Object *obj, struct opSet *message)
944 struct Icon_DATA *data = NULL;
946 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
948 obj = (Object *)DoSuperNewTags(CLASS, obj, NULL,
949 MUIA_FillArea, FALSE,
950 TAG_MORE, (IPTR) message->ops_AttrList);
952 if (!obj) return FALSE;
954 data = INST_DATA(CLASS, obj);
956 struct DateTime dt;
957 struct DateStamp now;
958 UBYTE *sp = NULL;
960 struct Rectangle rect;
962 IPTR geticon_error = 0;
964 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
966 /*disk object (icon)*/
967 if (message->icon_dob == NULL)
969 data->dob = GetIconTags
971 message->filename,
972 ICONGETA_FailIfUnavailable, FALSE,
973 ICONGETA_GenerateImageMasks, TRUE,
974 ICONA_ErrorCode, &geticon_error,
975 TAG_DONE
978 if (data->dob == NULL)
980 D(bug("[Icon] %s: Fatal: Couldnt get DiskObject! (error code = 0x%p)\n", __PRETTY_FUNCTION__, geticon_error));
982 return NULL;
985 else
987 data->dob = message->icon_dob;
990 D(bug("[Icon] %s: DiskObject @ 0x%p\n", __PRETTY_FUNCTION__, data->dob));
992 if ((entry = AllocPooled(data->icld_Pool, sizeof(struct IconEntry))) == NULL)
994 D(bug("[Icon] %s: Failed to Allocate Entry Storage!\n", __PRETTY_FUNCTION__));
995 FreeDiskObject(data->dob);
996 return NULL;
998 memset(entry, 0, sizeof(struct IconEntry));
1000 /* Allocate Text Buffers */
1002 if ((data->IcD_Date_TXTBUFF = AllocPooled(data->icld_Pool, LEN_DATSTRING)) == NULL)
1004 D(bug("[Icon] %s: Failed to Allocate Entry DATE Storage!\n", __PRETTY_FUNCTION__));
1005 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1006 return NULL;
1008 memset(data->IcD_Date_TXTBUFF, 0, LEN_DATSTRING);
1010 if ((data->IcD_Time_TXTBUFF = AllocPooled(data->icld_Pool, LEN_DATSTRING)) == NULL)
1012 D(bug("[Icon] %s: Failed to Allocate Entry TIME string Storage!\n", __PRETTY_FUNCTION__));
1013 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1014 return NULL;
1016 memset(data->IcD_Time_TXTBUFF, 0, LEN_DATSTRING);
1018 if ((data->IcD_Size_TXTBUFF = AllocPooled(data->icld_Pool, 30)) == NULL)
1020 D(bug("[Icon] %s: Failed to Allocate Entry SIZE string Storage!\n", __PRETTY_FUNCTION__));
1021 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1022 return NULL;
1024 memset(data->IcD_Size_TXTBUFF, 0, 30);
1026 if ((data->IcD_TxtBuf_PROT = AllocPooled(data->icld_Pool, 8)) == NULL)
1028 D(bug("[Icon] %s: Failed to Allocate Entry PROT Flag string Storage!\n", __PRETTY_FUNCTION__));
1029 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1030 return NULL;
1032 memset(data->IcD_TxtBuf_PROT, 0, 8);
1034 /*alloc filename*/
1035 if ((data->IcD_IconEntry.filename = AllocPooled(data->icld_Pool, strlen(message->filename) + 1)) == NULL)
1037 D(bug("[Icon] %s: Failed to Allocate Entry filename string Storage!\n", __PRETTY_FUNCTION__));
1038 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1039 return NULL;
1042 /*alloc icon label*/
1043 if ((data->IcD_Label_TXTBUFF = AllocPooled(data->icld_Pool, strlen(message->label) + 1)) == NULL)
1045 D(bug("[Icon] %s: Failed to Allocate Entry label string Storage!\n", __PRETTY_FUNCTION__));
1046 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1047 return NULL;
1050 /*file info block*/
1051 if(message->fib != NULL)
1053 entry->IcD_FileInfoBlock = *message->fib;
1055 if (entry->IcD_FileInfoBlock.fib_DirEntryType > 0)
1057 strcpy(entry->IcD_Size_TXTBUFF, "Drawer");
1059 else
1061 int i = entry->IcD_FileInfoBlock.fib_Size;
1063 /*show byte size for small files*/
1064 if (i > 9999)
1065 sprintf(entry->IcD_Size_TXTBUFF, "%ld KB", (LONG)(i/1024));
1066 else
1067 sprintf(entry->IcD_Size_TXTBUFF, "%ld B", (LONG)i);
1070 dt.dat_Stamp = entry->IcD_FileInfoBlock.fib_Date;
1071 dt.dat_Format = FORMAT_DEF;
1072 dt.dat_Flags = 0;
1073 dt.dat_StrDay = NULL;
1074 dt.dat_StrDate = entry->IcD_Date_TXTBUFF;
1075 dt.dat_StrTime = entry->IcD_Time_TXTBUFF;
1077 DateToStr(&dt);
1078 DateStamp(&now);
1080 /*if modified today show time, otherwise just show date*/
1081 if (now.ds_Days == entry->IcD_FileInfoBlock.fib_Date.ds_Days)
1082 entry->IcD_Flags |= ICONENTRY_FLAG_TODAY;
1083 else
1084 entry->IcD_Flags &= ~ICONENTRY_FLAG_TODAY;
1086 sp = entry->IcD_TxtBuf_PROT;
1087 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_SCRIPT) ? 's' : '-';
1088 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_PURE) ? 'p' : '-';
1089 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_ARCHIVE) ? 'a' : '-';
1090 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_READ) ? '-' : 'r';
1091 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_WRITE) ? '-' : 'w';
1092 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_EXECUTE) ? '-' : 'e';
1093 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_DELETE) ? '-' : 'd';
1094 *sp++ = '\0';
1096 entry->IcD_IconEntry.type = entry->IcD_FileInfoBlock.fib_DirEntryType;
1098 else
1100 entry->IcD_IconEntry.type = ST_USERDIR;
1103 /* Override type if specified during createntry */
1104 if (message->type != 0)
1106 entry->IcD_IconEntry.type = message->type;
1107 D(bug("[Icon] %s: Overide Entry Type. New Type = %x\n", __PRETTY_FUNCTION__, entry->IcD_IconEntry.type));
1109 else
1111 D(bug("[Icon] %s: Entry Type = %x\n", __PRETTY_FUNCTION__, entry->IcD_IconEntry.type));
1114 strcpy(entry->IcD_IconEntry.filename, message->filename);
1115 strcpy(entry->IcD_Label_TXTBUFF, message->label);
1117 if (Icon__LabelFunc_CreateLabel(obj, data, entry) != NULL)
1119 entry->IcD_DiskObj = dob;
1120 entry->IcD_IconEntry.udata = NULL;
1122 /* Use a geticonrectangle routine that gets textwidth! */
1123 Icon_GetIconAreaRectangle(obj, data, entry, &rect);
1125 AddTail((struct List*)&data->icld_Icon, (struct Node*)&entry->IcD_IconNode);
1127 return (IPTR)entry;
1130 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1131 return NULL;
1133 D(bug("[Icon] %s: SELF = 0x%p, muiRenderInfo = 0x%p\n", __PRETTY_FUNCTION__, obj, muiRenderInfo(obj)));
1135 return (IPTR)obj;
1139 ///OM_DISPOSE()
1140 /**************************************************************************
1141 OM_DISPOSE
1142 **************************************************************************/
1143 IPTR Icon__OM_DISPOSE(struct IClass *CLASS, Object *obj, Msg message)
1145 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1146 struct IconEntry *node = NULL;
1148 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1150 DoSuperMethodA(CLASS,obj,message);
1151 return 0;
1155 ///OM_SET()
1156 /**************************************************************************
1157 OM_SET
1158 **************************************************************************/
1159 IPTR Icon__OM_SET(struct IClass *CLASS, Object *obj, struct opSet *message)
1161 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1162 struct TagItem *tag = NULL,
1163 *tags = NULL;
1165 WORD oldleft = data->icld_ViewX,
1166 oldtop = data->icld_ViewY;
1167 //oldwidth = data->icld_ViewWidth,
1168 //oldheight = data->icld_ViewHeight;
1170 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1172 for (tags = message->ops_AttrList; (tag = NextTagItem((TAGITEM)&tags)); )
1174 switch (tag->ti_Tag)
1176 case MUIA_Icon_Left:
1177 D(bug("[Icon] %s: MUIA_Icon_Left %ld\n", __PRETTY_FUNCTION__, tag->ti_Data));
1178 if (data->icld_ViewX != tag->ti_Data)
1179 data->icld_ViewX = tag->ti_Data;
1180 break;
1182 case MUIA_Icon_Top:
1183 D(bug("[Icon] %s: MUIA_Icon_Top %ld\n", __PRETTY_FUNCTION__, tag->ti_Data));
1184 if (data->icld_ViewY != tag->ti_Data)
1185 data->icld_ViewY = tag->ti_Data;
1186 break;
1188 case MUIA_Icon_Rastport:
1189 D(bug("[Icon] %s: MUIA_Icon_Rastport 0x%p\n", __PRETTY_FUNCTION__, tag->ti_Data));
1190 data->icld_DisplayRastPort = (struct RastPort*)tag->ti_Data;
1191 data->icld_DrawOffsetX = _mleft(obj);
1192 data->icld_DrawOffsetY = _mtop(obj);
1193 if (data->icld_BufferRastPort != NULL)
1195 //Buffer still set!?!?!
1197 SET(obj, MUIA_Icon_BufferRastport, tag->ti_Data);
1198 break;
1200 case MUIA_Icon_BufferRastport:
1201 D(bug("[Icon] %s: MUIA_Icon_BufferRastport 0x%p\n", __PRETTY_FUNCTION__, tag->ti_Data));
1202 data->icld_BufferRastPort = (struct RastPort*)tag->ti_Data;
1203 break;
1205 case MUIA_Font:
1206 D(bug("[Icon] %s: MUIA_Font 0x%p\n", __PRETTY_FUNCTION__, tag->ti_Data));
1207 data->icld_IconLabelFont = (struct TextFont*)tag->ti_Data;
1208 break;
1210 case MUIA_Icon_LabelInfoText_Font:
1211 D(bug("[Icon] %s: MUIA_Icon_LabelInfoText_Font 0x%p\n", __PRETTY_FUNCTION__, tag->ti_Data));
1212 data->icld_IconInfoFont = (struct TextFont*)tag->ti_Data;
1213 break;
1215 case MUIA_Icon_DisplayFlags:
1217 D(bug("[Icon] %s: MUIA_Icon_DisplayFlags\n", __PRETTY_FUNCTION__));
1218 data->icld_DisplayFlags = (ULONG)tag->ti_Data;
1219 if (data->icld_DisplayFlags & ICONLIST_DISP_BUFFERED)
1221 struct BitMap *tmp_BuffBitMap = NULL;
1222 ULONG tmp_RastDepth;
1224 #if defined(DEBUG_ILC_ICONRENDERING)
1225 D(bug("[Icon] %s: MUIA_Icon_DisplayFlags & ICONLIST_DISP_BUFFERED\n", __PRETTY_FUNCTION__));
1226 #endif
1227 if ((data->icld_BufferRastPort) && (data->icld_BufferRastPort != data->icld_DisplayRastPort))
1229 //Free up the buffers rastport and bitmap so we can replace them ..
1230 FreeBitMap(data->icld_BufferRastPort->BitMap);
1231 FreeRastPort(data->icld_BufferRastPort);
1232 SET(obj, MUIA_Icon_BufferRastport, NULL);
1234 tmp_RastDepth = GetCyberMapAttr(data->icld_DisplayRastPort->BitMap, CYBRMATTR_DEPTH);
1235 if ((tmp_BuffBitMap = AllocBitMap(data->icld_ViewWidth,
1236 data->icld_ViewHeight,
1237 tmp_RastDepth,
1238 BMF_CLEAR,
1239 data->icld_DisplayRastPort->BitMap))!=NULL)
1241 if ((data->icld_BufferRastPort = CreateRastPort())!=NULL)
1243 data->icld_BufferRastPort->BitMap = tmp_BuffBitMap;
1244 SET(obj, MUIA_Icon_BufferRastport, data->icld_BufferRastPort);
1245 data->icld_DrawOffsetX = 0;
1246 data->icld_DrawOffsetY = 0;
1248 else
1250 FreeBitMap(tmp_BuffBitMap);
1251 data->icld_BufferRastPort = data->icld_DisplayRastPort;
1252 data->icld_DrawOffsetX = _mleft(obj);
1253 data->icld_DrawOffsetY = _mtop(obj);
1257 else
1259 if ((data->icld_BufferRastPort) && (data->icld_BufferRastPort != data->icld_DisplayRastPort))
1261 //Free up the buffers rastport and bitmap since they are no longer needed ..
1262 FreeBitMap(data->icld_BufferRastPort->BitMap);
1263 FreeRastPort(data->icld_BufferRastPort);
1264 data->icld_BufferRastPort = data->icld_DisplayRastPort;
1265 data->icld_DrawOffsetX = _mleft(obj);
1266 data->icld_DrawOffsetY = _mtop(obj);
1270 break;
1272 case MUIA_Icon_SortFlags:
1273 D(bug("[Icon] %s: MUIA_Icon_SortFlags\n", __PRETTY_FUNCTION__));
1274 data->icld_SortFlags = (ULONG)tag->ti_Data;
1275 break;
1277 case MUIA_Icon_IconMode:
1278 D(bug("[Icon] %s: MUIA_Icon_IconMode %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1279 data->icld__Option_IconMode = (UBYTE)tag->ti_Data;
1280 break;
1282 case MUIA_Icon_LabelText_Mode:
1283 D(bug("[Icon] %s: MUIA_Icon_LabelText_Mode %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1284 data->icld__Option_LabelTextMode = (UBYTE)tag->ti_Data;
1285 break;
1287 case MUIA_Icon_LabelText_MultiLineOnFocus:
1288 D(bug("[Icon] %s: MUIA_Icon_LabelText_MultiLineOnFocus %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1289 data->icld__Option_LabelTextMultiLineOnFocus = (BOOL)tag->ti_Data;
1290 break;
1292 case MUIA_Icon_Icon_HorizontalSpacing:
1293 D(bug("[Icon] %s: MUIA_Icon_Icon_HorizontalSpacing %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1294 data->icld__Option_IconHorizontalSpacing = (UBYTE)tag->ti_Data;
1295 break;
1297 case MUIA_Icon_Icon_VerticalSpacing:
1298 D(bug("[Icon] %s: MUIA_Icon_Icon_VerticalSpacing %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1299 data->icld__Option_IconVerticalSpacing = (UBYTE)tag->ti_Data;
1300 break;
1302 case MUIA_Icon_Icon_ImageSpacing:
1303 D(bug("[Icon] %s: MUIA_Icon_Icon_ImageSpacing %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1304 data->icld__Option_IconImageSpacing = (UBYTE)tag->ti_Data;
1305 break;
1307 case MUIA_Icon_LabelText_HorizontalPadding:
1308 D(bug("[Icon] %s: MUIA_Icon_LabelText_HorizontalPadding %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1309 data->icld__Option_LabelTextHorizontalPadding = (UBYTE)tag->ti_Data;
1310 break;
1312 case MUIA_Icon_LabelText_VerticalPadding:
1313 D(bug("[Icon] %s: MUIA_Icon_LabelText_VerticalPadding %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1314 data->icld__Option_LabelTextVerticalPadding = (UBYTE)tag->ti_Data;
1315 break;
1317 case MUIA_Icon_LabelText_BorderWidth:
1318 D(bug("[Icon] %s: MUIA_Icon_LabelText_BorderWidth %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1319 data->icld__Option_LabelTextBorderWidth = (UBYTE)tag->ti_Data;
1320 break;
1322 case MUIA_Icon_LabelText_BorderHeight:
1323 D(bug("[Icon] %s: MUIA_Icon_LabelText_BorderHeight %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1324 data->icld__Option_LabelTextBorderHeight = (UBYTE)tag->ti_Data;
1325 break;
1327 case MUIA_Icon_LabelText_Pen:
1328 data->icld_LabelPen = (ULONG)tag->ti_Data;
1329 break;
1331 case MUIA_Icon_LabelText_ShadowPen:
1332 data->icld_LabelShadowPen = (ULONG)tag->ti_Data;
1333 break;
1335 case MUIA_Icon_LabelInfoText_ShadowPen:
1336 data->icld_InfoShadowPen = (ULONG)tag->ti_Data;
1337 break;
1339 /* Settings defined by the view class */
1340 case MUIA_Iconview_FixedBackground:
1341 D(bug("[Icon] %s: MUIA_Iconview_FixedBackground\n", __PRETTY_FUNCTION__));
1342 data->icld__Option_IconFixedBackground = (BOOL)tag->ti_Data;
1343 break;
1345 case MUIA_Iconview_ScaledBackground:
1346 D(bug("[Icon] %s: MUIA_Iconview_ScaledBackground\n", __PRETTY_FUNCTION__));
1347 data->icld__Option_IconScaledBackground = (BOOL)tag->ti_Data;
1348 break;
1350 /* We listen for MUIA_Background and set default values for known types */
1351 case MUIA_Background:
1352 #if defined(DEBUG_ILC_ICONRENDERING)
1353 D(bug("[Icon] %s: MUIA_Background\n", __PRETTY_FUNCTION__));
1354 #endif
1356 char *bgmode_string = (char *)tag->ti_Data;
1357 BYTE this_mode = bgmode_string[0] - 48;
1359 #if defined(DEBUG_ILC_ICONRENDERING)
1360 D(bug("[Icon] %s: MUIA_Background | MUI BG Mode = %d\n", __PRETTY_FUNCTION__, this_mode));
1361 #endif
1362 switch (this_mode)
1364 case 0:
1365 //MUI Pattern
1366 NNSET(obj, MUIA_Iconview_FixedBackground, FALSE);
1367 NNSET(obj, MUIA_Iconview_ScaledBackground, FALSE);
1368 break;
1369 case 2:
1370 //MUI RGB color
1371 NNSET(obj, MUIA_Iconview_FixedBackground, FALSE);
1372 NNSET(obj, MUIA_Iconview_ScaledBackground, FALSE);
1373 break;
1374 case 7:
1375 //Zune Gradient
1376 NNSET(obj, MUIA_Iconview_FixedBackground, TRUE);
1377 NNSET(obj, MUIA_Iconview_ScaledBackground, TRUE);
1378 break;
1379 case 5:
1380 //Image
1381 NNSET(obj, MUIA_Iconview_FixedBackground, FALSE);
1382 NNSET(obj, MUIA_Iconview_ScaledBackground, FALSE);
1383 break;
1386 return (IPTR)FALSE;
1390 D(bug("[Icon] %s(), out of switch\n", __PRETTY_FUNCTION__));
1392 if ((oldleft != data->icld_ViewX) || (oldtop != data->icld_ViewY))
1394 data->icld_UpdateMode = UPDATE_SCROLL;
1395 data->update_scrolldx = data->icld_ViewX - oldleft;
1396 data->update_scrolldy = data->icld_ViewY - oldtop;
1397 D(bug("[Icon] %s(), call MUI_Redraw()\n", __PRETTY_FUNCTION__));
1398 MUI_Redraw(obj, MADF_DRAWUPDATE);
1401 D(bug("[Icon] %s(), call DoSuperMethodA()\n", __PRETTY_FUNCTION__));
1402 return DoSuperMethodA(CLASS, obj, (struct opSet *)message);
1406 ///OM_GET()
1407 /**************************************************************************
1408 OM_GET
1409 **************************************************************************/
1410 IPTR Icon__OM_GET(struct IClass *CLASS, Object *obj, struct opGet *message)
1412 /* small macro to simplify return value storage */
1413 #define STORE *(message->opg_Storage)
1414 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1416 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1418 switch (message->opg_AttrID)
1420 case MUIA_Icon_Rastport: STORE = (IPTR)data->icld_DisplayRastPort; return 1;
1421 case MUIA_Icon_BufferRastport: STORE = (IPTR)data->icld_BufferRastPort; return 1;
1422 case MUIA_Icon_BufferLeft: STORE = (IPTR)data->icld_DrawOffsetX; return 1;
1423 case MUIA_Icon_BufferTop: STORE = (IPTR)data->icld_DrawOffsetY; return 1;
1424 case MUIA_Icon_Left: STORE = (IPTR)data->icld_ViewX; return 1;
1425 case MUIA_Icon_Top: STORE = (IPTR)data->icld_ViewY; return 1;
1426 case MUIA_Icon_BufferWidth:
1427 case MUIA_Icon_Width: STORE = (IPTR)data->icld_AreaWidth; return 1;
1428 case MUIA_Icon_BufferHeight:
1429 case MUIA_Icon_Height: STORE = (IPTR)data->icld_AreaHeight; return 1;
1430 case MUIA_Icon_IconsDropped: STORE = (IPTR)&data->icld_DragDropEvent; return 1;
1431 case MUIA_Icon_Clicked: STORE = (IPTR)&data->icld_ClickEvent; return 1;
1432 case MUIA_Icon_IconMode: STORE = (IPTR)data->icld__Option_IconMode; return 1;
1433 case MUIA_Icon_LabelText_Mode: STORE = (IPTR)data->icld__Option_LabelTextMode; return 1;
1434 case MUIA_Icon_LabelText_MultiLineOnFocus: STORE = (IPTR)data->icld__Option_LabelTextMultiLineOnFocus; return 1;
1435 case MUIA_Icon_DisplayFlags: STORE = (IPTR)data->icld_DisplayFlags; return 1;
1436 case MUIA_Icon_SortFlags: STORE = (IPTR)data->icld_SortFlags; return 1;
1438 case MUIA_Icon_FocusIcon: STORE = (IPTR)data->icld_FocusIcon; return 1;
1440 case MUIA_Font: STORE = (IPTR)data->icld_IconLabelFont; return 1;
1441 case MUIA_Icon_LabelText_Pen: STORE = (IPTR)data->icld_LabelPen; return 1;
1442 case MUIA_Icon_LabelText_ShadowPen: STORE = (IPTR)data->icld_LabelShadowPen; return 1;
1443 case MUIA_Icon_LabelInfoText_Font: STORE = (IPTR)data->icld_IconInfoFont; return 1;
1444 case MUIA_Icon_LabelInfoText_ShadowPen: STORE = (IPTR)data->icld_InfoShadowPen; return 1;
1446 case MUIA_Icon_Icon_HorizontalSpacing: STORE = (IPTR)data->icld__Option_IconHorizontalSpacing; return 1;
1447 case MUIA_Icon_Icon_VerticalSpacing: STORE = (IPTR)data->icld__Option_IconVerticalSpacing; return 1;
1448 case MUIA_Icon_Icon_ImageSpacing: STORE = (IPTR)data->icld__Option_IconImageSpacing; return 1;
1449 case MUIA_Icon_LabelText_HorizontalPadding: STORE = (IPTR)data->icld__Option_LabelTextHorizontalPadding; return 1;
1450 case MUIA_Icon_LabelText_VerticalPadding: STORE = (IPTR)data->icld__Option_LabelTextVerticalPadding; return 1;
1451 case MUIA_Icon_LabelText_BorderWidth: STORE = (IPTR)data->icld__Option_LabelTextBorderWidth; return 1;
1452 case MUIA_Icon_LabelText_BorderHeight: STORE = (IPTR)data->icld__Option_LabelTextBorderHeight; return 1;
1454 /* Settings defined by the view class */
1455 case MUIA_Iconview_FixedBackground: STORE = (IPTR)data->icld__Option_IconFixedBackground; return 1;
1456 case MUIA_Iconview_ScaledBackground: STORE = (IPTR)data->icld__Option_IconScaledBackground; return 1;
1459 if (DoSuperMethodA(CLASS, obj, (Msg) message))
1460 return 1;
1461 return 0;
1462 #undef STORE
1466 ///MUIM_Setup()
1467 /**************************************************************************
1468 MUIM_Setup
1469 **************************************************************************/
1470 IPTR Icon__MUIM_Setup(struct IClass *CLASS, Object *obj, struct MUIP_Setup *message)
1472 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1473 struct IconEntry *node = NULL;
1474 IPTR geticon_error = 0;
1476 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1478 if (!DoSuperMethodA(CLASS, obj, (Msg) message)) return 0;
1480 DoMethod(_win(obj), MUIM_Window_AddEventHandler, (IPTR)&data->ehn);
1482 /* Get Internal Objects to use if not set .. */
1483 data->icld_DisplayRastPort = NULL;
1484 data->icld_BufferRastPort = NULL;
1486 if (data->icld_IconLabelFont == NULL) data->icld_IconLabelFont = _font(obj);
1487 if (data->icld_IconInfoFont == NULL) data->icld_IconInfoFont = data->icld_IconLabelFont;
1488 D(bug("[Icon] %s: Use Font @ 0x%p, RastPort @ 0x%p\n", __PRETTY_FUNCTION__, data->icld_IconLabelFont, data->icld_BufferRastPort ));
1490 /* Set our base options .. */
1491 data->icld_LabelPen = _pens(obj)[MPEN_SHINE];
1492 data->icld_LabelShadowPen = _pens(obj)[MPEN_SHADOW];
1493 data->icld_InfoShadowPen = _pens(obj)[MPEN_SHADOW];
1495 data->icld__Option_LabelTextMultiLineOnFocus = FALSE;
1497 data->icld__Option_IconHorizontalSpacing = ILC_ICON_HORIZONTALMARGIN_DEFAULT;
1498 data->icld__Option_IconVerticalSpacing = ILC_ICON_VERTICALMARGIN_DEFAULT;
1499 data->icld__Option_IconImageSpacing = ILC_ICONLABEL_IMAGEMARGIN_DEFAULT;
1500 data->icld__Option_LabelTextHorizontalPadding = ILC_ICONLABEL_HORIZONTALTEXTMARGIN_DEFAULT;
1501 data->icld__Option_LabelTextVerticalPadding = ILC_ICONLABEL_VERTICALTEXTMARGIN_DEFAULT;
1502 data->icld__Option_LabelTextBorderWidth = ILC_ICONLABEL_BORDERWIDTH_DEFAULT;
1503 data->icld__Option_LabelTextBorderHeight = ILC_ICONLABEL_BORDERHEIGHT_DEFAULT;
1505 #ifdef __AROS__
1506 ForeachNode(&data->icld_Icon, node)
1507 #else
1508 Foreach_Node(&data->icld_Icon, node);
1509 #endif
1511 if (!node->IcD_DiskObj)
1513 if (!(node->IcD_DiskObj = GetIconTags(node->IcD_IconEntry.filename, ICONGETA_GenerateImageMasks, TRUE, ICONGETA_FailIfUnavailable, FALSE, ICONA_ErrorCode, &geticon_error, TAG_DONE)))
1515 D(bug("[Icon] %s: Failed to obtain Icon '%s's diskobj! (error code = 0x%p)\n", __PRETTY_FUNCTION__, node->IcD_IconEntry.filename, geticon_error));
1516 /* We should probably remove this node if the icon cant be obtained ? */
1520 return 1;
1524 ///MUIM_Show()
1525 /**************************************************************************
1526 MUIM_Show
1527 **************************************************************************/
1528 IPTR Icon__MUIM_Show(struct IClass *CLASS, Object *obj, struct MUIP_Show *message)
1530 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1531 LONG newleft,
1532 newtop;
1533 IPTR rc;
1535 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1537 if ((rc = DoSuperMethodA(CLASS, obj, (Msg)message)))
1540 return rc;
1544 ///MUIM_Hide()
1545 /**************************************************************************
1546 MUIM_Hide
1547 **************************************************************************/
1548 IPTR Icon__MUIM_Hide(struct IClass *CLASS, Object *obj, struct MUIP_Hide *message)
1550 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1551 IPTR rc;
1553 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1555 if ((rc = DoSuperMethodA(CLASS, obj, (Msg)message)))
1558 return rc;
1562 ///MUIM_Cleanup()
1563 /**************************************************************************
1564 MUIM_Cleanup
1565 **************************************************************************/
1566 IPTR Icon__MUIM_Cleanup(struct IClass *CLASS, Object *obj, struct MUIP_Cleanup *message)
1568 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1569 struct IconEntry *node = NULL;
1571 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1573 return DoSuperMethodA(CLASS, obj, (Msg)message);
1577 ///MUIM_AskMinMax()
1578 /**************************************************************************
1579 MUIM_AskMinMax
1580 **************************************************************************/
1581 IPTR Icon__MUIM_AskMinMax(struct IClass *CLASS, Object *obj, struct MUIP_AskMinMax *message)
1583 ULONG rc = DoSuperMethodA(CLASS, obj, (Msg) message);
1585 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1587 /* Get Icon "Image" Size in MinN */
1588 message->MinMaxInfo->MinWidth += 96;
1589 message->MinMaxInfo->MinHeight += 64;
1591 /* Get Icon "Label" Size in DefN */
1592 message->MinMaxInfo->DefWidth += 200;
1593 message->MinMaxInfo->DefHeight += 180;
1595 /* Get Complete Icon Area Size in MaxN */
1596 message->MinMaxInfo->MaxWidth = MUI_MAXMAX;
1597 message->MinMaxInfo->MaxHeight = MUI_MAXMAX;
1599 return rc;
1603 ///MUIM_Layout()
1604 /**************************************************************************
1605 MUIM_Layout
1606 **************************************************************************/
1607 IPTR Icon__MUIM_Layout(struct IClass *CLASS, Object *obj,struct MUIP_Layout *message)
1609 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1610 ULONG rc;
1612 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1614 rc = DoSuperMethodA(CLASS, obj, (Msg)message);
1616 return rc;
1620 ///MUIM_Draw()
1621 /**************************************************************************
1622 MUIM_Draw - draw the Icon
1623 **************************************************************************/
1624 IPTR DrawCount;
1625 IPTR Icon__MUIM_Draw(struct IClass *CLASS, Object *obj, struct MUIP_Draw *message)
1627 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1628 struct IconEntry *icon = NULL;
1630 APTR clip;
1632 ULONG update_oldwidth = 0,
1633 update_oldheight = 0;
1635 LONG clear_xoffset = 0,
1636 clear_yoffset = 0;
1638 IPTR draw_id = DrawCount++;
1640 D(bug("[Icon]: %s(obj @ 0x%p)\n", __PRETTY_FUNCTION__, obj));
1642 D(bug("[Icon] %s: id %d\n", __PRETTY_FUNCTION__, draw_id));
1644 DoSuperMethodA(CLASS, obj, (Msg)message);
1646 if (!(data->icld__Option_IconFixedBackground))
1648 clear_xoffset = data->icld_ViewX;
1649 clear_yoffset = data->icld_ViewY;
1652 // If window size changes, only update needed areas
1653 if (data->update_oldwidth == 0) data->update_oldwidth = data->icld_ViewWidth;
1654 if (data->update_oldheight == 0) data->update_oldheight = data->icld_ViewHeight;
1655 if ((data->update_oldwidth != data->icld_ViewWidth) || (data->update_oldheight != data->icld_ViewHeight))
1657 if (data->icld_UpdateMode != UPDATE_SCROLL)
1659 data->icld_UpdateMode = UPDATE_RESIZE;
1660 update_oldwidth = data->update_oldwidth;
1661 update_oldheight = data->update_oldheight;
1662 data->update_oldwidth = data->icld_ViewWidth;
1663 data->update_oldheight = data->icld_ViewHeight;
1667 if ((message->flags & MADF_DRAWUPDATE) || (data->icld_UpdateMode == UPDATE_RESIZE))
1669 #if defined(DEBUG_ILC_ICONRENDERING)
1670 if (message->flags & MADF_DRAWUPDATE)
1672 D(bug("[Icon] %s#%d: MADF_DRAWUPDATE\n", __PRETTY_FUNCTION__, draw_id));
1674 else
1676 D(bug("[Icon] %s#%d: UPDATE_RESIZE\n", __PRETTY_FUNCTION__, draw_id));
1678 #endif
1679 if ((data->icld_UpdateMode == UPDATE_SINGLEICON) && (data->update_icon != NULL)) /* draw only a single icon at update_icon */
1681 struct Rectangle rect;
1683 D(bug("[Icon] %s#%d: UPDATE_SINGLEICON (icon @ 0x%p)\n", __PRETTY_FUNCTION__, draw_id, data->update_icon));
1685 Icon_GetIconAreaRectangle(obj, data, data->update_icon, &rect);
1687 rect.MinX += _mleft(obj) + (data->update_icon->IcD_IconX - data->icld_ViewX);
1688 rect.MaxX += _mleft(obj) + (data->update_icon->IcD_IconX - data->icld_ViewX);
1689 rect.MinY += _mtop(obj) + (data->update_icon->IcD_IconY - data->icld_ViewY);
1690 rect.MaxY += _mtop(obj) + (data->update_icon->IcD_IconY - data->icld_ViewY);
1692 if (data->icld__Option_IconMode == ICON_LISTMODE_GRID)
1694 if (data->update_icon->IcD_AreaWidth < data->icld_IconAreaLargestWidth)
1696 rect.MinX += ((data->icld_IconAreaLargestWidth - data->update_icon->IcD_AreaWidth)/2);
1697 rect.MaxX += ((data->icld_IconAreaLargestWidth - data->update_icon->IcD_AreaWidth)/2);
1700 if (data->update_icon->IcD_AreaHeight < data->icld_IconAreaLargestHeight)
1702 rect.MinY += ((data->icld_IconAreaLargestHeight - data->update_icon->IcD_AreaHeight)/2);
1703 rect.MaxY += ((data->icld_IconAreaLargestHeight - data->update_icon->IcD_AreaHeight)/2);
1707 clip = MUI_AddClipping(muiRenderInfo(obj), _mleft(obj), _mtop(obj), _mwidth(obj), _mheight(obj));
1709 #if defined(DEBUG_ILC_ICONRENDERING)
1710 D(bug("[Icon] %s#%d: UPDATE_SINGLEICON: Calling MUIM_DrawBackground (A)\n", __PRETTY_FUNCTION__, draw_id));
1711 #endif
1712 DoMethod(obj, MUIM_DrawBackground,
1713 rect.MinX, rect.MinY,
1714 rect.MaxX - rect.MinX + 1, rect.MaxY - rect.MinY + 1,
1715 clear_xoffset, clear_yoffset,
1718 /* We could have deleted also other icons so they must be redrawn */
1719 #ifdef __AROS__
1720 ForeachNode(&data->icld_Icon, icon)
1721 #else
1722 Foreach_Node(&data->icld_Icon, icon);
1723 #endif
1725 if ((icon != data->update_icon) && (icon->IcD_Flags & ICONENTRY_FLAG_VISIBLE))
1727 struct Rectangle rect2;
1728 Icon_GetIconAreaRectangle(obj, data, icon, &rect2);
1730 rect2.MinX += _mleft(obj) - data->icld_ViewX + icon->IcD_IconX;
1731 rect2.MaxX += _mleft(obj) - data->icld_ViewX + icon->IcD_IconX;
1732 rect2.MinY += _mtop(obj) - data->icld_ViewY + icon->IcD_IconY;
1733 rect2.MaxY += _mtop(obj) - data->icld_ViewY + icon->IcD_IconY;
1735 if (data->icld__Option_IconMode == ICON_LISTMODE_GRID)
1737 if (icon->IcD_AreaWidth < data->icld_IconAreaLargestWidth)
1739 rect2.MinX += ((data->icld_IconAreaLargestWidth - icon->IcD_AreaWidth)/2);
1740 rect2.MaxX += ((data->icld_IconAreaLargestWidth - icon->IcD_AreaWidth)/2);
1743 if (icon->IcD_AreaHeight < data->icld_IconAreaLargestHeight)
1745 rect2.MinY += ((data->icld_IconAreaLargestHeight - icon->IcD_AreaHeight)/2);
1746 rect2.MaxY += ((data->icld_IconAreaLargestHeight - icon->IcD_AreaHeight)/2);
1750 if (RectAndRect(&rect, &rect2))
1752 // Update icon here
1753 DoMethod(obj, MUIM_Icon_DrawEntry, icon, ICONENTRY_DRAWMODE_PLAIN);
1754 DoMethod(obj, MUIM_Icon_DrawEntryLabel, icon, ICONENTRY_DRAWMODE_PLAIN);
1759 DoMethod(obj, MUIM_Icon_DrawEntry, data->update_icon, ICONENTRY_DRAWMODE_PLAIN);
1760 DoMethod(obj, MUIM_Icon_DrawEntryLabel, data->update_icon, ICONENTRY_DRAWMODE_PLAIN);
1761 data->icld_UpdateMode = 0;
1762 data->update_icon = NULL;
1764 if (data->icld_DisplayRastPort != data->icld_BufferRastPort)
1766 #if defined(DEBUG_ILC_ICONRENDERING)
1767 D(bug("[Icon] %s#%d: UPDATE_SINGLEICON Blitting to front rastport..\n", __PRETTY_FUNCTION__, draw_id));
1768 #endif
1769 BltBitMapRastPort(data->icld_BufferRastPort->BitMap,
1770 rect.MinX - _mleft(obj), rect.MinY - _mtop(obj),
1771 data->icld_DisplayRastPort,
1772 rect.MinX, rect.MinY,
1773 rect.MaxX - rect.MinX + 1, rect.MaxY - rect.MinY + 1,
1774 0xC0);
1777 MUI_RemoveClipping(muiRenderInfo(obj),clip);
1778 goto draw_done;
1780 else if (data->icld_UpdateMode == UPDATE_SCROLL)
1782 struct Region *region = NULL;
1783 struct Rectangle xrect,
1784 yrect;
1785 BOOL scroll_caused_damage;
1787 #if defined(DEBUG_ILC_ICONRENDERING)
1788 D(bug("[Icon] %s#%d: UPDATE_SCROLL.\n", __PRETTY_FUNCTION__, draw_id));
1789 #endif
1791 if (!data->icld__Option_IconFixedBackground)
1793 scroll_caused_damage = (_rp(obj)->Layer->Flags & LAYERREFRESH) ? FALSE : TRUE;
1795 data->icld_UpdateMode = 0;
1797 if ((abs(data->update_scrolldx) >= _mwidth(obj)) ||
1798 (abs(data->update_scrolldy) >= _mheight(obj)))
1800 #if defined(DEBUG_ILC_ICONRENDERING)
1801 D(bug("[Icon] %s#%d: UPDATE_SCROLL: Moved outside current view\n", __PRETTY_FUNCTION__, draw_id));
1802 #endif
1803 MUI_Redraw(obj, MADF_DRAWOBJECT);
1804 goto draw_done;
1807 if (!(region = NewRegion()))
1809 #if defined(DEBUG_ILC_ICONRENDERING)
1810 D(bug("[Icon] %s#%d: UPDATE_SCROLL: Couldnt Alloc Region\n", __PRETTY_FUNCTION__, draw_id));
1811 #endif
1812 MUI_Redraw(obj, MADF_DRAWOBJECT);
1813 goto draw_done;
1816 if (data->update_scrolldx > 0)
1818 xrect.MinX = _mright(obj) - data->update_scrolldx;
1819 xrect.MinY = _mtop(obj);
1820 xrect.MaxX = _mright(obj);
1821 xrect.MaxY = _mbottom(obj);
1823 OrRectRegion(region, &xrect);
1825 data->update_rect1 = &xrect;
1827 else if (data->update_scrolldx < 0)
1829 xrect.MinX = _mleft(obj);
1830 xrect.MinY = _mtop(obj);
1831 xrect.MaxX = _mleft(obj) - data->update_scrolldx;
1832 xrect.MaxY = _mbottom(obj);
1834 OrRectRegion(region, &xrect);
1836 data->update_rect1 = &xrect;
1839 if (data->update_scrolldy > 0)
1841 yrect.MinX = _mleft(obj);
1842 yrect.MinY = _mbottom(obj) - data->update_scrolldy;
1843 yrect.MaxX = _mright(obj);
1844 yrect.MaxY = _mbottom(obj);
1846 OrRectRegion(region, &yrect);
1848 data->update_rect2 = &yrect;
1850 else if (data->update_scrolldy < 0)
1852 yrect.MinX = _mleft(obj);
1853 yrect.MinY = _mtop(obj);
1854 yrect.MaxX = _mright(obj);
1855 yrect.MaxY = _mtop(obj) - data->update_scrolldy;
1857 OrRectRegion(region, &yrect);
1859 data->update_rect2 = &yrect;
1862 #if defined(DEBUG_ILC_ICONRENDERING)
1863 D(bug("[Icon] %s#%d: UPDATE_SCROLL: Scrolling Raster..\n", __PRETTY_FUNCTION__, draw_id));
1864 #endif
1865 if (data->icld_DisplayRastPort == data->icld_BufferRastPort)
1867 ScrollRasterBF(data->icld_BufferRastPort,
1868 data->update_scrolldx,
1869 data->update_scrolldy,
1870 _mleft(obj),
1871 _mtop(obj),
1872 _mright(obj),
1873 _mbottom(obj));
1875 else
1877 ScrollRasterBF(data->icld_BufferRastPort,
1878 data->update_scrolldx,
1879 data->update_scrolldy,
1882 _mwidth(obj),
1883 _mheight(obj));
1886 scroll_caused_damage = scroll_caused_damage && (_rp(obj)->Layer->Flags & LAYERREFRESH) ? TRUE : FALSE;
1888 clip = MUI_AddClipRegion(muiRenderInfo(obj), region);
1891 #if defined(DEBUG_ILC_ICONRENDERING)
1892 D(bug("[Icon] %s#%d: UPDATE_SCROLL: Causing Redraw..\n", __PRETTY_FUNCTION__, draw_id));
1893 #endif
1894 MUI_Redraw(obj, MADF_DRAWOBJECT);
1896 data->update_rect1 = data->update_rect2 = NULL;
1898 if (!data->icld__Option_IconFixedBackground)
1900 MUI_RemoveClipRegion(muiRenderInfo(obj), clip);
1902 if (scroll_caused_damage)
1904 if (MUI_BeginRefresh(muiRenderInfo(obj), 0))
1906 /* Theoretically it might happen that more damage is caused
1907 after ScrollRaster. By something else, like window movement
1908 in front of our window. Therefore refresh root object of
1909 window, not just this object */
1911 Object *o = NULL;
1913 GET(_win(obj),MUIA_Window_RootObject, &o);
1914 MUI_Redraw(o, MADF_DRAWOBJECT);
1916 MUI_EndRefresh(muiRenderInfo(obj), 0);
1920 if (data->icld_DisplayRastPort != data->icld_BufferRastPort)
1922 #if defined(DEBUG_ILC_ICONRENDERING)
1923 D(bug("[Icon] %s#%d: UPDATE_SCROLL: Blitting to front rastport..\n", __PRETTY_FUNCTION__, draw_id));
1924 #endif
1925 BltBitMapRastPort(data->icld_BufferRastPort->BitMap,
1926 0, 0,
1927 data->icld_DisplayRastPort,
1928 _mleft(obj), _mtop(obj),
1929 _mwidth(obj), _mheight(obj),
1930 0xC0);
1932 goto draw_done;
1934 else if (data->icld_UpdateMode == UPDATE_RESIZE)
1936 struct Region *region = NULL;
1937 struct Rectangle wrect,
1938 hrect;
1939 ULONG diffw = 0,
1940 diffh = 0;
1942 #if defined(DEBUG_ILC_ICONRENDERING)
1943 D(bug("[Icon] %s#%d: UPDATE_RESIZE.\n", __PRETTY_FUNCTION__, draw_id));
1944 #endif
1946 if ((data->icld_BufferRastPort) && (data->icld_BufferRastPort != data->icld_DisplayRastPort))
1948 //Free up the buffers rastport and bitmap so we can replace them ..
1949 struct Bitmap *bitmap_Old = data->icld_BufferRastPort->BitMap;
1950 struct Bitmap *bitmap_New;
1952 ULONG tmp_RastDepth;
1954 data->icld_BufferRastPort->BitMap = NULL;
1956 FreeRastPort(data->icld_BufferRastPort);
1957 SET(obj, MUIA_Icon_BufferRastport, NULL);
1959 tmp_RastDepth = GetCyberMapAttr(data->icld_DisplayRastPort->BitMap, CYBRMATTR_DEPTH);
1960 if ((bitmap_New = AllocBitMap(data->icld_ViewWidth,
1961 data->icld_ViewHeight,
1962 tmp_RastDepth,
1963 BMF_CLEAR,
1964 data->icld_DisplayRastPort->BitMap))!=NULL)
1966 if ((data->icld_BufferRastPort = CreateRastPort())!=NULL)
1968 data->icld_BufferRastPort->BitMap = bitmap_New;
1969 SET(obj, MUIA_Icon_BufferRastport, data->icld_BufferRastPort);
1970 data->icld_DrawOffsetX = 0;
1971 data->icld_DrawOffsetY = 0;
1973 else
1975 FreeBitMap(bitmap_New);
1976 data->icld_BufferRastPort = data->icld_DisplayRastPort;
1977 data->icld_DrawOffsetX = _mleft(obj);
1978 data->icld_DrawOffsetY = _mtop(obj);
1982 if (bitmap_Old != data->icld_BufferRastPort->BitMap)
1983 FreeBitMap(bitmap_Old);
1986 data->icld_UpdateMode = 0;
1988 if (!data->icld__Option_IconScaledBackground)
1990 if (!(region = NewRegion()))
1992 MUI_Redraw(obj, MADF_DRAWOBJECT);
1993 goto draw_done;
1996 if ( data->icld_ViewWidth > update_oldwidth )
1997 diffw = data->icld_ViewWidth - update_oldwidth;
1998 if ( data->icld_ViewHeight > update_oldheight )
1999 diffh = data->icld_ViewHeight - update_oldheight;
2001 if (diffw)
2003 wrect.MinX = _mright(obj) - diffw;
2004 wrect.MinY = _mtop(obj);
2005 wrect.MaxX = _mright(obj);
2006 wrect.MaxY = _mbottom(obj);
2007 OrRectRegion(region, &wrect);
2008 data->update_rect1 = &wrect;
2011 if (diffh)
2013 hrect.MinX = _mleft(obj);
2014 hrect.MinY = _mbottom(obj) - diffh;
2015 hrect.MaxX = _mright(obj);
2016 hrect.MaxX = _mright(obj);
2017 hrect.MaxY = _mbottom(obj);
2018 OrRectRegion(region, &hrect);
2019 data->update_rect2 = &hrect;
2021 if (diffh||diffw)
2023 clip = MUI_AddClipRegion(muiRenderInfo(obj), region);
2025 else
2027 /* View became smaller both in horizontal and vertical direction.
2028 Nothing to do */
2030 DisposeRegion(region);
2031 goto draw_done;
2035 MUI_Redraw(obj, MADF_DRAWOBJECT);
2037 if (!data->icld__Option_IconScaledBackground)
2039 if (diffh||diffw)
2041 data->update_rect1 = data->update_rect2 = NULL;
2042 MUI_RemoveClipRegion(muiRenderInfo(obj), clip);
2043 } else DisposeRegion(region);
2046 goto draw_done;
2050 if (message->flags & MADF_DRAWOBJECT)
2052 struct Rectangle viewrect;
2054 #if defined(DEBUG_ILC_ICONRENDERING)
2055 D(bug("[Icon] %s#%d: MADF_DRAWOBJECT\n", __PRETTY_FUNCTION__, draw_id));
2056 #endif
2058 clip = MUI_AddClipping(muiRenderInfo(obj), _mleft(obj), _mtop(obj), _mwidth(obj), _mheight(obj));
2060 viewrect.MinX = _mleft(obj);
2061 viewrect.MaxX = _mleft(obj) + _mwidth(obj);
2062 viewrect.MinY = _mtop(obj);
2063 viewrect.MaxY = _mtop(obj) + _mheight(obj);
2065 #if defined(DEBUG_ILC_ICONRENDERING)
2066 D(bug("[Icon] %s#%d: MADF_DRAWOBJECT: Calling MUIM_DrawBackground (B)\n", __PRETTY_FUNCTION__, draw_id));
2067 #endif
2068 DoMethod(
2069 obj, MUIM_DrawBackground, _mleft(obj), _mtop(obj), _mwidth(obj), _mheight(obj),
2070 clear_xoffset, clear_yoffset, 0
2072 #ifdef __AROS__
2073 ForeachNode(&data->icld_Icon, icon)
2074 #else
2075 Foreach_Node(&data->icld_Icon, icon);
2076 #endif
2078 if ((icon->IcD_Flags & ICONENTRY_FLAG_VISIBLE) &&
2079 (icon->IcD_DiskObj) &&
2080 (icon->IcD_IconX != NO_ICON_POSITION) &&
2081 (icon->IcD_IconY != NO_ICON_POSITION))
2083 struct Rectangle iconrect;
2084 Icon_GetIconAreaRectangle(obj, data, icon, &iconrect);
2086 iconrect.MinX += _mleft(obj) - data->icld_ViewX + icon->IcD_IconX;
2087 iconrect.MaxX += _mleft(obj) - data->icld_ViewX + icon->IcD_IconX;
2088 iconrect.MinY += _mtop(obj) - data->icld_ViewY + icon->IcD_IconY;
2089 iconrect.MaxY += _mtop(obj) - data->icld_ViewY + icon->IcD_IconY;
2091 if (RectAndRect(&viewrect, &iconrect))
2093 DoMethod(obj, MUIM_Icon_DrawEntry, icon, ICONENTRY_DRAWMODE_PLAIN);
2094 DoMethod(obj, MUIM_Icon_DrawEntryLabel, icon, ICONENTRY_DRAWMODE_PLAIN);
2099 if (data->icld_DisplayRastPort != data->icld_BufferRastPort)
2101 #if defined(DEBUG_ILC_ICONRENDERING)
2102 D(bug("[Icon] %s#%d: MADF_DRAWOBJECT: Blitting to front rastport..\n", __PRETTY_FUNCTION__, draw_id));
2103 #endif
2104 BltBitMapRastPort(data->icld_BufferRastPort->BitMap,
2105 0, 0,
2106 data->icld_DisplayRastPort,
2107 _mleft(obj), _mtop(obj),
2108 _mwidth(obj), _mheight(obj),
2109 0xC0);
2112 MUI_RemoveClipping(muiRenderInfo(obj), clip);
2114 data->icld_UpdateMode = 0;
2116 draw_done:;
2118 D(bug("[Icon] %s: Draw finished for id %d\n", __PRETTY_FUNCTION__, draw_id));
2120 return 0;
2124 ///Icon__MUIM_Icon_Update()
2125 /**************************************************************************
2126 MUIM_Icon_Refresh
2127 Implemented by subclasses
2128 **************************************************************************/
2129 IPTR Icon__MUIM_Icon_Update(struct IClass *CLASS, Object *obj, struct MUIP_Icon_Update *message)
2131 struct Icon_DATA *data = INST_DATA(CLASS, obj);
2133 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
2135 return 1;
2139 ///Icon__MUIM_Icon_DestroyEntry()
2140 IPTR Icon__MUIM_Icon_DestroyEntry(struct IClass *CLASS, Object *obj, struct MUIP_Icon_DestroyEntry *message)
2142 struct Icon_DATA *data = INST_DATA(CLASS, obj);
2144 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
2146 if (message->icon)
2148 if (message->icon->IcD_Flags & ICONENTRY_FLAG_SELECTED)
2150 Remove(&message->icon->IcD_SelectionNode);
2152 if (message->icon->IcD_DisplayedLabel_TXTBUFF) FreeVecPooled(data->icld_Pool, message->icon->IcD_DisplayedLabel_TXTBUFF);
2153 if (message->icon->IcD_TxtBuf_PROT) FreeVec(message->icon->IcD_TxtBuf_PROT, 8);
2154 if (message->icon->IcD_Size_TXTBUFF) FreePooled(message->icon->IcD_Size_TXTBUFF, 30);
2155 if (message->icon->IcD_Time_TXTBUFF) FreePooled(message->icon->IcD_Time_TXTBUFF, LEN_DATSTRING);
2156 if (message->icon->IcD_Date_TXTBUFF) FreePooled(message->icon->IcD_Date_TXTBUFF, LEN_DATSTRING);
2157 if (message->icon->IcD_DiskObj) FreeDiskObject(message->icon->IcD_DiskObj);
2158 if (message->icon->IcD_Label_TXTBUFF) FreePooled(data->icld_Pool, message->icon->IcD_Label_TXTBUFF, strlen(message->icon->IcD_Label_TXTBUFF)+1);
2159 if (message->icon->IcD_IconEntry.filename) FreePooled(data->icld_Pool, message->icon->IcD_IconEntry.filename, strlen(message->icon->IcD_IconEntry.filename)+1);
2161 return TRUE;
2165 ///Icon__MUIM_Icon_CreateEntry()
2166 /**************************************************************************
2167 MUIM_Icon_CreateEntry.
2168 Returns 0 on failure otherwise it returns the icons entry ..
2169 **************************************************************************/
2170 IPTR Icon__MUIM_Icon_CreateEntry(struct IClass *CLASS, Object *obj, struct MUIP_Icon_CreateEntry *message)
2176 #if WANDERER_BUILTIN_ICONLIST
2177 BOOPSI_DISPATCHER(IPTR,Icon_Dispatcher, CLASS, obj, message)
2179 #ifdef __AROS__
2180 switch (message->MethodID)
2181 #else
2182 struct IClass *CLASS = cl;
2183 Msg message = msg;
2185 switch (msg->MethodID)
2186 #endif
2188 case OM_NEW: return Icon__OM_NEW(CLASS, obj, (struct opSet *)message);
2189 case OM_DISPOSE: return Icon__OM_DISPOSE(CLASS, obj, message);
2190 case OM_SET: return Icon__OM_SET(CLASS, obj, (struct opSet *)message);
2191 case OM_GET: return Icon__OM_GET(CLASS, obj, (struct opGet *)message);
2193 case MUIM_Setup: return Icon__MUIM_Setup(CLASS, obj, (struct MUIP_Setup *)message);
2195 case MUIM_Show: return Icon__MUIM_Show(CLASS,obj, (struct MUIP_Show *)message);
2196 case MUIM_Hide: return Icon__MUIM_Hide(CLASS,obj, (struct MUIP_Hide *)message);
2197 case MUIM_Cleanup: return Icon__MUIM_Cleanup(CLASS, obj, (struct MUIP_Cleanup *)message);
2198 case MUIM_AskMinMax: return Icon__MUIM_AskMinMax(CLASS, obj, (struct MUIP_AskMinMax *)message);
2199 case MUIM_Draw: return Icon__MUIM_Draw(CLASS, obj, (struct MUIP_Draw *)message);
2200 #ifdef __AROS__
2201 case MUIM_Layout: return Icon__MUIM_Layout(CLASS, obj, (struct MUIP_Layout *)message);
2202 #endif
2203 case MUIM_CreateDragImage: return Icon__MUIM_CreateDragImage(CLASS, obj, (APTR)message);
2204 case MUIM_DeleteDragImage: return Icon__MUIM_DeleteDragImage(CLASS, obj, (APTR)message);
2206 case MUIM_Icon_DrawEntry: return Icon__MUIM_Icon_DrawEntry(CLASS, obj, (APTR)message);
2207 case MUIM_Icon_DrawEntryLabel: return Icon__MUIM_Icon_DrawEntryLabel(CLASS, obj, (APTR)message);
2208 case MUIM_Icon_GetIconPrivate: return Icon__MUIM_Icon_GetIconPrivate(CLASS, obj, (APTR)message);
2210 return DoSuperMethodA(CLASS, obj, message);
2212 BOOPSI_DISPATCHER_END
2214 #ifdef __AROS__
2215 /* Class descriptor. */
2216 const struct __MUIBuiltinClass _MUI_Icon_desc = {
2217 MUIC_Icon,
2218 MUIC_Area,
2219 sizeof(struct Icon_DATA),
2220 (void*)Icon_Dispatcher
2222 #endif
2223 #endif
2225 #ifndef __AROS__
2226 struct MUI_CustomClass *initIconClass(void)
2228 return (struct MUI_CustomClass *) MUI_CreateCustomClass(NULL, MUIC_Area, NULL, sizeof(struct Icon_DATA), ENTRY(Icon_Dispatcher));
2231 #endif