Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / system / Wanderer / Classes / icon.c
blob50bce60aa022a547d194a2a17e50b3ecf06aebef
1 /*
2 Copyright © 2008-2013, 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, __iconList_DrawIconStateTags);
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 = AllocVecPooled(data->icld_Pool,
800 tmpLen + 1)) != NULL)
802 memset(curlabel_StrPtr, 0, tmpLen + 1);
803 strncpy(curlabel_StrPtr, tmpLine, tmpLen - 3);
804 strcat(curlabel_StrPtr , " ..");
806 else return FALSE;
810 IcD_LabelLength = strlen(curlabel_StrPtr);
811 offset_y = 0;
813 // Center message->icon's label
814 tx = (labelX + (message->icon->IcD_DisplayedLabel_Width / 2) - (TextLength(data->icld_BufferRastPort, curlabel_StrPtr, strlen(curlabel_StrPtr)) / 2));
816 if (message->icon->IcD_DisplayedLabel_Width < txtarea_width)
817 tx += ((txtarea_width - message->icon->IcD_DisplayedLabel_Width)/2);
819 ty = ty + data->icld_IconLabelFont->tf_YSize;
821 switch ( data->icld__Option_LabelTextMode )
823 case ICON_TEXTMODE_DROPSHADOW:
824 SetAPen(data->icld_BufferRastPort, data->icld_LabelShadowPen);
825 Move(data->icld_BufferRastPort, tx + 1, ty + 1);
826 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
827 offset_y = 1;
828 case ICON_TEXTMODE_PLAIN:
829 SetAPen(data->icld_BufferRastPort, data->icld_LabelPen);
830 Move(data->icld_BufferRastPort, tx, ty);
831 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
832 break;
834 default:
835 // Outline mode:
837 SetSoftStyle(data->icld_BufferRastPort, FSF_BOLD, AskSoftStyle(data->icld_BufferRastPort));
839 SetAPen(data->icld_BufferRastPort, data->icld_LabelShadowPen);
840 Move(data->icld_BufferRastPort, tx + 1, ty );
841 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
842 Move(data->icld_BufferRastPort, tx - 1, ty );
843 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
844 Move(data->icld_BufferRastPort, tx, ty + 1);
845 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
846 Move(data->icld_BufferRastPort, tx, ty - 1);
847 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
849 SetAPen(data->icld_BufferRastPort, data->icld_LabelPen);
850 Move(data->icld_BufferRastPort, tx , ty );
851 Text(data->icld_BufferRastPort, curlabel_StrPtr, IcD_LabelLength);
853 SetSoftStyle(data->icld_BufferRastPort, FS_NORMAL, AskSoftStyle(data->icld_BufferRastPort));
854 offset_y = 2;
855 break;
857 if ((curlabel_CurrentLine >= (curlabel_TotalLines -1)) && (curlabel_TotalLines < message->icon->IcD_DisplayedLabel_SplitParts))
859 FreeVecPooled(data->icld_Pool, curlabel_StrPtr);
861 ty = ty + offset_y;
864 /*date/size sorting has the date/size appended under the message->icon label*/
866 if ((message->icon->IcD_IconEntry.type != ST_USERDIR) && ((data->icld_SortFlags & ICONLIST_SORT_BY_SIZE|ICONLIST_SORT_BY_DATE) != 0))
868 buf = NULL;
869 SetFont(data->icld_BufferRastPort, data->icld_IconInfoFont);
871 if ((data->icld_SortFlags & ICONLIST_SORT_MASK) == ICONLIST_SORT_BY_SIZE)
873 buf = message->icon->IcD_Size_TXTBUFF;
874 txwidth = message->icon->IcD_Size_Width;
876 else if ((data->icld_SortFlags & ICONLIST_SORT_MASK) == ICONLIST_SORT_BY_DATE)
878 if (message->icon->IcD_Flags & ICONENTRY_FLAG_TODAY)
880 buf = message->icon->IcD_Time_TXTBUFF;
881 txwidth = message->icon->IcD_Time_Width;
883 else
885 buf = message->icon->IcD_Date_TXTBUFF;
886 txwidth = message->icon->IcD_Date_Width;
890 if (buf)
892 ULONG IcD_LabelLength = strlen(buf);
893 tx = labelX;
895 if (txwidth < txtarea_width)
896 tx += ((txtarea_width - txwidth)/2);
898 ty = labelY + ((data->icld__Option_LabelTextVerticalPadding + data->icld_IconLabelFont->tf_YSize ) * curlabel_TotalLines) + data->icld_IconInfoFont->tf_YSize;
900 switch ( data->icld__Option_LabelTextMode )
902 case ICON_TEXTMODE_DROPSHADOW:
903 SetAPen(data->icld_BufferRastPort, data->icld_InfoShadowPen);
904 Move(data->icld_BufferRastPort, tx + 1, ty + 1); Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
905 case ICON_TEXTMODE_PLAIN:
906 SetAPen(data->icld_BufferRastPort, XGET(_parent(obj), MUIA_IconList_LabelInfoText_Pen));
907 Move(data->icld_BufferRastPort, tx, ty); Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
908 break;
910 default:
911 // Outline mode..
912 SetSoftStyle(data->icld_BufferRastPort, FSF_BOLD, AskSoftStyle(data->icld_BufferRastPort));
913 SetAPen(data->icld_BufferRastPort, data->icld_InfoShadowPen);
915 Move(data->icld_BufferRastPort, tx + 1, ty );
916 Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
917 Move(data->icld_BufferRastPort, tx - 1, ty );
918 Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
919 Move(data->icld_BufferRastPort, tx, ty - 1 );
920 Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
921 Move(data->icld_BufferRastPort, tx, ty + 1 );
922 Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
924 SetAPen(data->icld_BufferRastPort, XGET(_parent(obj), MUIA_IconList_LabelInfoText_Pen));
926 Move(data->icld_BufferRastPort, tx, ty );
927 Text(data->icld_BufferRastPort, buf, IcD_LabelLength);
929 SetSoftStyle(data->icld_BufferRastPort, FS_NORMAL, AskSoftStyle(data->icld_BufferRastPort));
930 break;
936 return TRUE;
939 ///OM_NEW()
940 /**************************************************************************
941 OM_NEW
942 **************************************************************************/
943 IPTR Icon__OM_NEW(struct IClass *CLASS, Object *obj, struct opSet *message)
945 struct Icon_DATA *data = NULL;
947 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
949 obj = (Object *)DoSuperNewTags(CLASS, obj, NULL,
950 MUIA_FillArea, FALSE,
951 TAG_MORE, (IPTR) message->ops_AttrList);
953 if (!obj) return FALSE;
955 data = INST_DATA(CLASS, obj);
957 struct DateTime dt;
958 struct DateStamp now;
959 UBYTE *sp = NULL;
961 struct Rectangle rect;
963 IPTR geticon_error = 0;
965 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
967 /*disk object (icon)*/
968 if (message->icon_dob == NULL)
970 data->dob = GetIconTags
972 message->filename,
973 ICONGETA_FailIfUnavailable, FALSE,
974 ICONGETA_GenerateImageMasks, TRUE,
975 ICONA_ErrorCode, &geticon_error,
976 TAG_DONE
979 if (data->dob == NULL)
981 D(bug("[Icon] %s: Fatal: Couldnt get DiskObject! (error code = 0x%p)\n", __PRETTY_FUNCTION__, geticon_error));
983 return NULL;
986 else
988 data->dob = message->icon_dob;
991 D(bug("[Icon] %s: DiskObject @ 0x%p\n", __PRETTY_FUNCTION__, data->dob));
993 if ((entry = AllocPooled(data->icld_Pool, sizeof(struct IconEntry))) == NULL)
995 D(bug("[Icon] %s: Failed to Allocate Entry Storage!\n", __PRETTY_FUNCTION__));
996 FreeDiskObject(data->dob);
997 return NULL;
999 memset(entry, 0, sizeof(struct IconEntry));
1001 /* Allocate Text Buffers */
1003 if ((data->IcD_Date_TXTBUFF = AllocPooled(data->icld_Pool, LEN_DATSTRING)) == NULL)
1005 D(bug("[Icon] %s: Failed to Allocate Entry DATE Storage!\n", __PRETTY_FUNCTION__));
1006 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1007 return NULL;
1009 memset(data->IcD_Date_TXTBUFF, 0, LEN_DATSTRING);
1011 if ((data->IcD_Time_TXTBUFF = AllocPooled(data->icld_Pool, LEN_DATSTRING)) == NULL)
1013 D(bug("[Icon] %s: Failed to Allocate Entry TIME string Storage!\n", __PRETTY_FUNCTION__));
1014 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1015 return NULL;
1017 memset(data->IcD_Time_TXTBUFF, 0, LEN_DATSTRING);
1019 if ((data->IcD_Size_TXTBUFF = AllocPooled(data->icld_Pool, 30)) == NULL)
1021 D(bug("[Icon] %s: Failed to Allocate Entry SIZE string Storage!\n", __PRETTY_FUNCTION__));
1022 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1023 return NULL;
1025 memset(data->IcD_Size_TXTBUFF, 0, 30);
1027 if ((data->IcD_TxtBuf_PROT = AllocPooled(data->icld_Pool, 8)) == NULL)
1029 D(bug("[Icon] %s: Failed to Allocate Entry PROT Flag string Storage!\n", __PRETTY_FUNCTION__));
1030 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1031 return NULL;
1033 memset(data->IcD_TxtBuf_PROT, 0, 8);
1035 /*alloc filename*/
1036 if ((data->IcD_IconEntry.filename = AllocPooled(data->icld_Pool, strlen(message->filename) + 1)) == NULL)
1038 D(bug("[Icon] %s: Failed to Allocate Entry filename string Storage!\n", __PRETTY_FUNCTION__));
1039 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1040 return NULL;
1043 /*alloc icon label*/
1044 if ((data->IcD_Label_TXTBUFF = AllocPooled(data->icld_Pool, strlen(message->label) + 1)) == NULL)
1046 D(bug("[Icon] %s: Failed to Allocate Entry label string Storage!\n", __PRETTY_FUNCTION__));
1047 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1048 return NULL;
1051 /*file info block*/
1052 if(message->fib != NULL)
1054 entry->IcD_FileInfoBlock = *message->fib;
1056 if (entry->IcD_FileInfoBlock.fib_DirEntryType > 0)
1058 strcpy(entry->IcD_Size_TXTBUFF, "Drawer");
1060 else
1062 int i = entry->IcD_FileInfoBlock.fib_Size;
1064 /*show byte size for small files*/
1065 if (i > 9999)
1066 sprintf(entry->IcD_Size_TXTBUFF, "%ld KB", (LONG)(i/1024));
1067 else
1068 sprintf(entry->IcD_Size_TXTBUFF, "%ld B", (LONG)i);
1071 dt.dat_Stamp = entry->IcD_FileInfoBlock.fib_Date;
1072 dt.dat_Format = FORMAT_DEF;
1073 dt.dat_Flags = 0;
1074 dt.dat_StrDay = NULL;
1075 dt.dat_StrDate = entry->IcD_Date_TXTBUFF;
1076 dt.dat_StrTime = entry->IcD_Time_TXTBUFF;
1078 DateToStr(&dt);
1079 DateStamp(&now);
1081 /*if modified today show time, otherwise just show date*/
1082 if (now.ds_Days == entry->IcD_FileInfoBlock.fib_Date.ds_Days)
1083 entry->IcD_Flags |= ICONENTRY_FLAG_TODAY;
1084 else
1085 entry->IcD_Flags &= ~ICONENTRY_FLAG_TODAY;
1087 sp = entry->IcD_TxtBuf_PROT;
1088 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_SCRIPT) ? 's' : '-';
1089 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_PURE) ? 'p' : '-';
1090 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_ARCHIVE) ? 'a' : '-';
1091 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_READ) ? '-' : 'r';
1092 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_WRITE) ? '-' : 'w';
1093 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_EXECUTE) ? '-' : 'e';
1094 *sp++ = (entry->IcD_FileInfoBlock.fib_Protection & FIBF_DELETE) ? '-' : 'd';
1095 *sp++ = '\0';
1097 entry->IcD_IconEntry.type = entry->IcD_FileInfoBlock.fib_DirEntryType;
1099 else
1101 entry->IcD_IconEntry.type = ST_USERDIR;
1104 /* Override type if specified during createntry */
1105 if (message->type != 0)
1107 entry->IcD_IconEntry.type = message->type;
1108 D(bug("[Icon] %s: Overide Entry Type. New Type = %x\n", __PRETTY_FUNCTION__, entry->IcD_IconEntry.type));
1110 else
1112 D(bug("[Icon] %s: Entry Type = %x\n", __PRETTY_FUNCTION__, entry->IcD_IconEntry.type));
1115 strcpy(entry->IcD_IconEntry.filename, message->filename);
1116 strcpy(entry->IcD_Label_TXTBUFF, message->label);
1118 if (Icon__LabelFunc_CreateLabel(obj, data, entry) != NULL)
1120 entry->IcD_DiskObj = dob;
1121 entry->IcD_IconEntry.udata = NULL;
1123 /* Use a geticonrectangle routine that gets textwidth! */
1124 Icon_GetIconAreaRectangle(obj, data, entry, &rect);
1126 AddTail((struct List*)&data->icld_Icon, (struct Node*)&entry->IcD_IconNode);
1128 return (IPTR)entry;
1131 DoMethod(obj, MUIM_Icon_DestroyEntry, entry);
1132 return NULL;
1134 D(bug("[Icon] %s: SELF = 0x%p, muiRenderInfo = 0x%p\n", __PRETTY_FUNCTION__, obj, muiRenderInfo(obj)));
1136 return (IPTR)obj;
1140 ///OM_DISPOSE()
1141 /**************************************************************************
1142 OM_DISPOSE
1143 **************************************************************************/
1144 IPTR Icon__OM_DISPOSE(struct IClass *CLASS, Object *obj, Msg message)
1146 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1147 struct IconEntry *node = NULL;
1149 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1151 DoSuperMethodA(CLASS,obj,message);
1152 return 0;
1156 ///OM_SET()
1157 /**************************************************************************
1158 OM_SET
1159 **************************************************************************/
1160 IPTR Icon__OM_SET(struct IClass *CLASS, Object *obj, struct opSet *message)
1162 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1163 struct TagItem *tag = NULL,
1164 *tags = NULL;
1166 WORD oldleft = data->icld_ViewX,
1167 oldtop = data->icld_ViewY;
1168 //oldwidth = data->icld_ViewWidth,
1169 //oldheight = data->icld_ViewHeight;
1171 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1173 for (tags = message->ops_AttrList; (tag = NextTagItem((TAGITEM)&tags)); )
1175 switch (tag->ti_Tag)
1177 case MUIA_Icon_Left:
1178 D(bug("[Icon] %s: MUIA_Icon_Left %ld\n", __PRETTY_FUNCTION__, tag->ti_Data));
1179 if (data->icld_ViewX != tag->ti_Data)
1180 data->icld_ViewX = tag->ti_Data;
1181 break;
1183 case MUIA_Icon_Top:
1184 D(bug("[Icon] %s: MUIA_Icon_Top %ld\n", __PRETTY_FUNCTION__, tag->ti_Data));
1185 if (data->icld_ViewY != tag->ti_Data)
1186 data->icld_ViewY = tag->ti_Data;
1187 break;
1189 case MUIA_Icon_Rastport:
1190 D(bug("[Icon] %s: MUIA_Icon_Rastport 0x%p\n", __PRETTY_FUNCTION__, tag->ti_Data));
1191 data->icld_DisplayRastPort = (struct RastPort*)tag->ti_Data;
1192 data->icld_DrawOffsetX = _mleft(obj);
1193 data->icld_DrawOffsetY = _mtop(obj);
1194 if (data->icld_BufferRastPort != NULL)
1196 //Buffer still set!?!?!
1198 SET(obj, MUIA_Icon_BufferRastport, tag->ti_Data);
1199 break;
1201 case MUIA_Icon_BufferRastport:
1202 D(bug("[Icon] %s: MUIA_Icon_BufferRastport 0x%p\n", __PRETTY_FUNCTION__, tag->ti_Data));
1203 data->icld_BufferRastPort = (struct RastPort*)tag->ti_Data;
1204 break;
1206 case MUIA_Font:
1207 D(bug("[Icon] %s: MUIA_Font 0x%p\n", __PRETTY_FUNCTION__, tag->ti_Data));
1208 data->icld_IconLabelFont = (struct TextFont*)tag->ti_Data;
1209 break;
1211 case MUIA_Icon_LabelInfoText_Font:
1212 D(bug("[Icon] %s: MUIA_Icon_LabelInfoText_Font 0x%p\n", __PRETTY_FUNCTION__, tag->ti_Data));
1213 data->icld_IconInfoFont = (struct TextFont*)tag->ti_Data;
1214 break;
1216 case MUIA_Icon_DisplayFlags:
1218 D(bug("[Icon] %s: MUIA_Icon_DisplayFlags\n", __PRETTY_FUNCTION__));
1219 data->icld_DisplayFlags = (ULONG)tag->ti_Data;
1220 if (data->icld_DisplayFlags & ICONLIST_DISP_BUFFERED)
1222 struct BitMap *tmp_BuffBitMap = NULL;
1223 ULONG tmp_RastDepth;
1225 #if defined(DEBUG_ILC_ICONRENDERING)
1226 D(bug("[Icon] %s: MUIA_Icon_DisplayFlags & ICONLIST_DISP_BUFFERED\n", __PRETTY_FUNCTION__));
1227 #endif
1228 if ((data->icld_BufferRastPort) && (data->icld_BufferRastPort != data->icld_DisplayRastPort))
1230 //Free up the buffers rastport and bitmap so we can replace them ..
1231 FreeBitMap(data->icld_BufferRastPort->BitMap);
1232 FreeRastPort(data->icld_BufferRastPort);
1233 SET(obj, MUIA_Icon_BufferRastport, NULL);
1235 tmp_RastDepth = GetCyberMapAttr(data->icld_DisplayRastPort->BitMap, CYBRMATTR_DEPTH);
1236 if ((tmp_BuffBitMap = AllocBitMap(data->icld_ViewWidth,
1237 data->icld_ViewHeight,
1238 tmp_RastDepth,
1239 BMF_CLEAR,
1240 data->icld_DisplayRastPort->BitMap))!=NULL)
1242 if ((data->icld_BufferRastPort = CreateRastPort())!=NULL)
1244 data->icld_BufferRastPort->BitMap = tmp_BuffBitMap;
1245 SET(obj, MUIA_Icon_BufferRastport, data->icld_BufferRastPort);
1246 data->icld_DrawOffsetX = 0;
1247 data->icld_DrawOffsetY = 0;
1249 else
1251 FreeBitMap(tmp_BuffBitMap);
1252 data->icld_BufferRastPort = data->icld_DisplayRastPort;
1253 data->icld_DrawOffsetX = _mleft(obj);
1254 data->icld_DrawOffsetY = _mtop(obj);
1258 else
1260 if ((data->icld_BufferRastPort) && (data->icld_BufferRastPort != data->icld_DisplayRastPort))
1262 //Free up the buffers rastport and bitmap since they are no longer needed ..
1263 FreeBitMap(data->icld_BufferRastPort->BitMap);
1264 FreeRastPort(data->icld_BufferRastPort);
1265 data->icld_BufferRastPort = data->icld_DisplayRastPort;
1266 data->icld_DrawOffsetX = _mleft(obj);
1267 data->icld_DrawOffsetY = _mtop(obj);
1271 break;
1273 case MUIA_Icon_SortFlags:
1274 D(bug("[Icon] %s: MUIA_Icon_SortFlags\n", __PRETTY_FUNCTION__));
1275 data->icld_SortFlags = (ULONG)tag->ti_Data;
1276 break;
1278 case MUIA_Icon_IconMode:
1279 D(bug("[Icon] %s: MUIA_Icon_IconMode %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1280 data->icld__Option_IconMode = (UBYTE)tag->ti_Data;
1281 break;
1283 case MUIA_Icon_LabelText_Mode:
1284 D(bug("[Icon] %s: MUIA_Icon_LabelText_Mode %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1285 data->icld__Option_LabelTextMode = (UBYTE)tag->ti_Data;
1286 break;
1288 case MUIA_Icon_LabelText_MultiLineOnFocus:
1289 D(bug("[Icon] %s: MUIA_Icon_LabelText_MultiLineOnFocus %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1290 data->icld__Option_LabelTextMultiLineOnFocus = (BOOL)tag->ti_Data;
1291 break;
1293 case MUIA_Icon_Icon_HorizontalSpacing:
1294 D(bug("[Icon] %s: MUIA_Icon_Icon_HorizontalSpacing %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1295 data->icld__Option_IconHorizontalSpacing = (UBYTE)tag->ti_Data;
1296 break;
1298 case MUIA_Icon_Icon_VerticalSpacing:
1299 D(bug("[Icon] %s: MUIA_Icon_Icon_VerticalSpacing %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1300 data->icld__Option_IconVerticalSpacing = (UBYTE)tag->ti_Data;
1301 break;
1303 case MUIA_Icon_Icon_ImageSpacing:
1304 D(bug("[Icon] %s: MUIA_Icon_Icon_ImageSpacing %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1305 data->icld__Option_IconImageSpacing = (UBYTE)tag->ti_Data;
1306 break;
1308 case MUIA_Icon_LabelText_HorizontalPadding:
1309 D(bug("[Icon] %s: MUIA_Icon_LabelText_HorizontalPadding %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1310 data->icld__Option_LabelTextHorizontalPadding = (UBYTE)tag->ti_Data;
1311 break;
1313 case MUIA_Icon_LabelText_VerticalPadding:
1314 D(bug("[Icon] %s: MUIA_Icon_LabelText_VerticalPadding %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1315 data->icld__Option_LabelTextVerticalPadding = (UBYTE)tag->ti_Data;
1316 break;
1318 case MUIA_Icon_LabelText_BorderWidth:
1319 D(bug("[Icon] %s: MUIA_Icon_LabelText_BorderWidth %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1320 data->icld__Option_LabelTextBorderWidth = (UBYTE)tag->ti_Data;
1321 break;
1323 case MUIA_Icon_LabelText_BorderHeight:
1324 D(bug("[Icon] %s: MUIA_Icon_LabelText_BorderHeight %d\n", __PRETTY_FUNCTION__, tag->ti_Data));
1325 data->icld__Option_LabelTextBorderHeight = (UBYTE)tag->ti_Data;
1326 break;
1328 case MUIA_Icon_LabelText_Pen:
1329 data->icld_LabelPen = (ULONG)tag->ti_Data;
1330 break;
1332 case MUIA_Icon_LabelText_ShadowPen:
1333 data->icld_LabelShadowPen = (ULONG)tag->ti_Data;
1334 break;
1336 case MUIA_Icon_LabelInfoText_ShadowPen:
1337 data->icld_InfoShadowPen = (ULONG)tag->ti_Data;
1338 break;
1340 /* Settings defined by the view class */
1341 case MUIA_Iconview_FixedBackground:
1342 D(bug("[Icon] %s: MUIA_Iconview_FixedBackground\n", __PRETTY_FUNCTION__));
1343 data->icld__Option_IconFixedBackground = (BOOL)tag->ti_Data;
1344 break;
1346 case MUIA_Iconview_ScaledBackground:
1347 D(bug("[Icon] %s: MUIA_Iconview_ScaledBackground\n", __PRETTY_FUNCTION__));
1348 data->icld__Option_IconScaledBackground = (BOOL)tag->ti_Data;
1349 break;
1351 /* We listen for MUIA_Background and set default values for known types */
1352 case MUIA_Background:
1353 #if defined(DEBUG_ILC_ICONRENDERING)
1354 D(bug("[Icon] %s: MUIA_Background\n", __PRETTY_FUNCTION__));
1355 #endif
1357 char *bgmode_string = (char *)tag->ti_Data;
1358 BYTE this_mode = bgmode_string[0] - 48;
1360 #if defined(DEBUG_ILC_ICONRENDERING)
1361 D(bug("[Icon] %s: MUIA_Background | MUI BG Mode = %d\n", __PRETTY_FUNCTION__, this_mode));
1362 #endif
1363 switch (this_mode)
1365 case 0:
1366 //MUI Pattern
1367 NNSET(obj, MUIA_Iconview_FixedBackground, FALSE);
1368 NNSET(obj, MUIA_Iconview_ScaledBackground, FALSE);
1369 break;
1370 case 2:
1371 //MUI RGB color
1372 NNSET(obj, MUIA_Iconview_FixedBackground, FALSE);
1373 NNSET(obj, MUIA_Iconview_ScaledBackground, FALSE);
1374 break;
1375 case 7:
1376 //Zune Gradient
1377 NNSET(obj, MUIA_Iconview_FixedBackground, TRUE);
1378 NNSET(obj, MUIA_Iconview_ScaledBackground, TRUE);
1379 break;
1380 case 5:
1381 //Image
1382 NNSET(obj, MUIA_Iconview_FixedBackground, FALSE);
1383 NNSET(obj, MUIA_Iconview_ScaledBackground, FALSE);
1384 break;
1387 return (IPTR)FALSE;
1391 D(bug("[Icon] %s(), out of switch\n", __PRETTY_FUNCTION__));
1393 if ((oldleft != data->icld_ViewX) || (oldtop != data->icld_ViewY))
1395 data->icld_UpdateMode = UPDATE_SCROLL;
1396 data->update_scrolldx = data->icld_ViewX - oldleft;
1397 data->update_scrolldy = data->icld_ViewY - oldtop;
1398 D(bug("[Icon] %s(), call MUI_Redraw()\n", __PRETTY_FUNCTION__));
1399 MUI_Redraw(obj, MADF_DRAWUPDATE);
1402 D(bug("[Icon] %s(), call DoSuperMethodA()\n", __PRETTY_FUNCTION__));
1403 return DoSuperMethodA(CLASS, obj, (struct opSet *)message);
1407 ///OM_GET()
1408 /**************************************************************************
1409 OM_GET
1410 **************************************************************************/
1411 IPTR Icon__OM_GET(struct IClass *CLASS, Object *obj, struct opGet *message)
1413 /* small macro to simplify return value storage */
1414 #define STORE *(message->opg_Storage)
1415 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1417 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1419 switch (message->opg_AttrID)
1421 case MUIA_Icon_Rastport: STORE = (IPTR)data->icld_DisplayRastPort; return 1;
1422 case MUIA_Icon_BufferRastport: STORE = (IPTR)data->icld_BufferRastPort; return 1;
1423 case MUIA_Icon_BufferLeft: STORE = (IPTR)data->icld_DrawOffsetX; return 1;
1424 case MUIA_Icon_BufferTop: STORE = (IPTR)data->icld_DrawOffsetY; return 1;
1425 case MUIA_Icon_Left: STORE = (IPTR)data->icld_ViewX; return 1;
1426 case MUIA_Icon_Top: STORE = (IPTR)data->icld_ViewY; return 1;
1427 case MUIA_Icon_BufferWidth:
1428 case MUIA_Icon_Width: STORE = (IPTR)data->icld_AreaWidth; return 1;
1429 case MUIA_Icon_BufferHeight:
1430 case MUIA_Icon_Height: STORE = (IPTR)data->icld_AreaHeight; return 1;
1431 case MUIA_Icon_IconsDropped: STORE = (IPTR)&data->icld_DragDropEvent; return 1;
1432 case MUIA_Icon_Clicked: STORE = (IPTR)&data->icld_ClickEvent; return 1;
1433 case MUIA_Icon_IconMode: STORE = (IPTR)data->icld__Option_IconMode; return 1;
1434 case MUIA_Icon_LabelText_Mode: STORE = (IPTR)data->icld__Option_LabelTextMode; return 1;
1435 case MUIA_Icon_LabelText_MultiLineOnFocus: STORE = (IPTR)data->icld__Option_LabelTextMultiLineOnFocus; return 1;
1436 case MUIA_Icon_DisplayFlags: STORE = (IPTR)data->icld_DisplayFlags; return 1;
1437 case MUIA_Icon_SortFlags: STORE = (IPTR)data->icld_SortFlags; return 1;
1439 case MUIA_Icon_FocusIcon: STORE = (IPTR)data->icld_FocusIcon; return 1;
1441 case MUIA_Font: STORE = (IPTR)data->icld_IconLabelFont; return 1;
1442 case MUIA_Icon_LabelText_Pen: STORE = (IPTR)data->icld_LabelPen; return 1;
1443 case MUIA_Icon_LabelText_ShadowPen: STORE = (IPTR)data->icld_LabelShadowPen; return 1;
1444 case MUIA_Icon_LabelInfoText_Font: STORE = (IPTR)data->icld_IconInfoFont; return 1;
1445 case MUIA_Icon_LabelInfoText_ShadowPen: STORE = (IPTR)data->icld_InfoShadowPen; return 1;
1447 case MUIA_Icon_Icon_HorizontalSpacing: STORE = (IPTR)data->icld__Option_IconHorizontalSpacing; return 1;
1448 case MUIA_Icon_Icon_VerticalSpacing: STORE = (IPTR)data->icld__Option_IconVerticalSpacing; return 1;
1449 case MUIA_Icon_Icon_ImageSpacing: STORE = (IPTR)data->icld__Option_IconImageSpacing; return 1;
1450 case MUIA_Icon_LabelText_HorizontalPadding: STORE = (IPTR)data->icld__Option_LabelTextHorizontalPadding; return 1;
1451 case MUIA_Icon_LabelText_VerticalPadding: STORE = (IPTR)data->icld__Option_LabelTextVerticalPadding; return 1;
1452 case MUIA_Icon_LabelText_BorderWidth: STORE = (IPTR)data->icld__Option_LabelTextBorderWidth; return 1;
1453 case MUIA_Icon_LabelText_BorderHeight: STORE = (IPTR)data->icld__Option_LabelTextBorderHeight; return 1;
1455 /* Settings defined by the view class */
1456 case MUIA_Iconview_FixedBackground: STORE = (IPTR)data->icld__Option_IconFixedBackground; return 1;
1457 case MUIA_Iconview_ScaledBackground: STORE = (IPTR)data->icld__Option_IconScaledBackground; return 1;
1460 if (DoSuperMethodA(CLASS, obj, (Msg) message))
1461 return 1;
1462 return 0;
1463 #undef STORE
1467 ///MUIM_Setup()
1468 /**************************************************************************
1469 MUIM_Setup
1470 **************************************************************************/
1471 IPTR Icon__MUIM_Setup(struct IClass *CLASS, Object *obj, struct MUIP_Setup *message)
1473 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1474 struct IconEntry *node = NULL;
1475 IPTR geticon_error = 0;
1477 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1479 if (!DoSuperMethodA(CLASS, obj, (Msg) message)) return 0;
1481 DoMethod(_win(obj), MUIM_Window_AddEventHandler, (IPTR)&data->ehn);
1483 /* Get Internal Objects to use if not set .. */
1484 data->icld_DisplayRastPort = NULL;
1485 data->icld_BufferRastPort = NULL;
1487 if (data->icld_IconLabelFont == NULL) data->icld_IconLabelFont = _font(obj);
1488 if (data->icld_IconInfoFont == NULL) data->icld_IconInfoFont = data->icld_IconLabelFont;
1489 D(bug("[Icon] %s: Use Font @ 0x%p, RastPort @ 0x%p\n", __PRETTY_FUNCTION__, data->icld_IconLabelFont, data->icld_BufferRastPort ));
1491 /* Set our base options .. */
1492 data->icld_LabelPen = _pens(obj)[MPEN_SHINE];
1493 data->icld_LabelShadowPen = _pens(obj)[MPEN_SHADOW];
1494 data->icld_InfoShadowPen = _pens(obj)[MPEN_SHADOW];
1496 data->icld__Option_LabelTextMultiLineOnFocus = FALSE;
1498 data->icld__Option_IconHorizontalSpacing = ILC_ICON_HORIZONTALMARGIN_DEFAULT;
1499 data->icld__Option_IconVerticalSpacing = ILC_ICON_VERTICALMARGIN_DEFAULT;
1500 data->icld__Option_IconImageSpacing = ILC_ICONLABEL_IMAGEMARGIN_DEFAULT;
1501 data->icld__Option_LabelTextHorizontalPadding = ILC_ICONLABEL_HORIZONTALTEXTMARGIN_DEFAULT;
1502 data->icld__Option_LabelTextVerticalPadding = ILC_ICONLABEL_VERTICALTEXTMARGIN_DEFAULT;
1503 data->icld__Option_LabelTextBorderWidth = ILC_ICONLABEL_BORDERWIDTH_DEFAULT;
1504 data->icld__Option_LabelTextBorderHeight = ILC_ICONLABEL_BORDERHEIGHT_DEFAULT;
1506 #ifdef __AROS__
1507 ForeachNode(&data->icld_Icon, node)
1508 #else
1509 Foreach_Node(&data->icld_Icon, node);
1510 #endif
1512 if (!node->IcD_DiskObj)
1514 if (!(node->IcD_DiskObj = GetIconTags(node->IcD_IconEntry.filename, ICONGETA_GenerateImageMasks, TRUE, ICONGETA_FailIfUnavailable, FALSE, ICONA_ErrorCode, &geticon_error, TAG_DONE)))
1516 D(bug("[Icon] %s: Failed to obtain Icon '%s's diskobj! (error code = 0x%p)\n", __PRETTY_FUNCTION__, node->IcD_IconEntry.filename, geticon_error));
1517 /* We should probably remove this node if the icon cant be obtained ? */
1521 return 1;
1525 ///MUIM_Show()
1526 /**************************************************************************
1527 MUIM_Show
1528 **************************************************************************/
1529 IPTR Icon__MUIM_Show(struct IClass *CLASS, Object *obj, struct MUIP_Show *message)
1531 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1532 LONG newleft,
1533 newtop;
1534 IPTR rc;
1536 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1538 if ((rc = DoSuperMethodA(CLASS, obj, (Msg)message)))
1541 return rc;
1545 ///MUIM_Hide()
1546 /**************************************************************************
1547 MUIM_Hide
1548 **************************************************************************/
1549 IPTR Icon__MUIM_Hide(struct IClass *CLASS, Object *obj, struct MUIP_Hide *message)
1551 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1552 IPTR rc;
1554 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1556 if ((rc = DoSuperMethodA(CLASS, obj, (Msg)message)))
1559 return rc;
1563 ///MUIM_Cleanup()
1564 /**************************************************************************
1565 MUIM_Cleanup
1566 **************************************************************************/
1567 IPTR Icon__MUIM_Cleanup(struct IClass *CLASS, Object *obj, struct MUIP_Cleanup *message)
1569 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1570 struct IconEntry *node = NULL;
1572 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1574 return DoSuperMethodA(CLASS, obj, (Msg)message);
1578 ///MUIM_AskMinMax()
1579 /**************************************************************************
1580 MUIM_AskMinMax
1581 **************************************************************************/
1582 IPTR Icon__MUIM_AskMinMax(struct IClass *CLASS, Object *obj, struct MUIP_AskMinMax *message)
1584 ULONG rc = DoSuperMethodA(CLASS, obj, (Msg) message);
1586 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1588 /* Get Icon "Image" Size in MinN */
1589 message->MinMaxInfo->MinWidth += 96;
1590 message->MinMaxInfo->MinHeight += 64;
1592 /* Get Icon "Label" Size in DefN */
1593 message->MinMaxInfo->DefWidth += 200;
1594 message->MinMaxInfo->DefHeight += 180;
1596 /* Get Complete Icon Area Size in MaxN */
1597 message->MinMaxInfo->MaxWidth = MUI_MAXMAX;
1598 message->MinMaxInfo->MaxHeight = MUI_MAXMAX;
1600 return rc;
1604 ///MUIM_Layout()
1605 /**************************************************************************
1606 MUIM_Layout
1607 **************************************************************************/
1608 IPTR Icon__MUIM_Layout(struct IClass *CLASS, Object *obj,struct MUIP_Layout *message)
1610 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1611 ULONG rc;
1613 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
1615 rc = DoSuperMethodA(CLASS, obj, (Msg)message);
1617 return rc;
1621 ///MUIM_Draw()
1622 /**************************************************************************
1623 MUIM_Draw - draw the Icon
1624 **************************************************************************/
1625 IPTR DrawCount;
1626 IPTR Icon__MUIM_Draw(struct IClass *CLASS, Object *obj, struct MUIP_Draw *message)
1628 struct Icon_DATA *data = INST_DATA(CLASS, obj);
1629 struct IconEntry *icon = NULL;
1631 APTR clip;
1633 ULONG update_oldwidth = 0,
1634 update_oldheight = 0;
1636 LONG clear_xoffset = 0,
1637 clear_yoffset = 0;
1639 IPTR draw_id = DrawCount++;
1641 D(bug("[Icon]: %s(obj @ 0x%p)\n", __PRETTY_FUNCTION__, obj));
1643 D(bug("[Icon] %s: id %d\n", __PRETTY_FUNCTION__, draw_id));
1645 DoSuperMethodA(CLASS, obj, (Msg)message);
1647 if (!(data->icld__Option_IconFixedBackground))
1649 clear_xoffset = data->icld_ViewX;
1650 clear_yoffset = data->icld_ViewY;
1653 // If window size changes, only update needed areas
1654 if (data->update_oldwidth == 0) data->update_oldwidth = data->icld_ViewWidth;
1655 if (data->update_oldheight == 0) data->update_oldheight = data->icld_ViewHeight;
1656 if ((data->update_oldwidth != data->icld_ViewWidth) || (data->update_oldheight != data->icld_ViewHeight))
1658 if (data->icld_UpdateMode != UPDATE_SCROLL)
1660 data->icld_UpdateMode = UPDATE_RESIZE;
1661 update_oldwidth = data->update_oldwidth;
1662 update_oldheight = data->update_oldheight;
1663 data->update_oldwidth = data->icld_ViewWidth;
1664 data->update_oldheight = data->icld_ViewHeight;
1668 if ((message->flags & MADF_DRAWUPDATE) || (data->icld_UpdateMode == UPDATE_RESIZE))
1670 #if defined(DEBUG_ILC_ICONRENDERING)
1671 if (message->flags & MADF_DRAWUPDATE)
1673 D(bug("[Icon] %s#%d: MADF_DRAWUPDATE\n", __PRETTY_FUNCTION__, draw_id));
1675 else
1677 D(bug("[Icon] %s#%d: UPDATE_RESIZE\n", __PRETTY_FUNCTION__, draw_id));
1679 #endif
1680 if ((data->icld_UpdateMode == UPDATE_SINGLEICON) && (data->update_icon != NULL)) /* draw only a single icon at update_icon */
1682 struct Rectangle rect;
1684 D(bug("[Icon] %s#%d: UPDATE_SINGLEICON (icon @ 0x%p)\n", __PRETTY_FUNCTION__, draw_id, data->update_icon));
1686 Icon_GetIconAreaRectangle(obj, data, data->update_icon, &rect);
1688 rect.MinX += _mleft(obj) + (data->update_icon->IcD_IconX - data->icld_ViewX);
1689 rect.MaxX += _mleft(obj) + (data->update_icon->IcD_IconX - data->icld_ViewX);
1690 rect.MinY += _mtop(obj) + (data->update_icon->IcD_IconY - data->icld_ViewY);
1691 rect.MaxY += _mtop(obj) + (data->update_icon->IcD_IconY - data->icld_ViewY);
1693 if (data->icld__Option_IconMode == ICON_LISTMODE_GRID)
1695 if (data->update_icon->IcD_AreaWidth < data->icld_IconAreaLargestWidth)
1697 rect.MinX += ((data->icld_IconAreaLargestWidth - data->update_icon->IcD_AreaWidth)/2);
1698 rect.MaxX += ((data->icld_IconAreaLargestWidth - data->update_icon->IcD_AreaWidth)/2);
1701 if (data->update_icon->IcD_AreaHeight < data->icld_IconAreaLargestHeight)
1703 rect.MinY += ((data->icld_IconAreaLargestHeight - data->update_icon->IcD_AreaHeight)/2);
1704 rect.MaxY += ((data->icld_IconAreaLargestHeight - data->update_icon->IcD_AreaHeight)/2);
1708 clip = MUI_AddClipping(muiRenderInfo(obj), _mleft(obj), _mtop(obj), _mwidth(obj), _mheight(obj));
1710 #if defined(DEBUG_ILC_ICONRENDERING)
1711 D(bug("[Icon] %s#%d: UPDATE_SINGLEICON: Calling MUIM_DrawBackground (A)\n", __PRETTY_FUNCTION__, draw_id));
1712 #endif
1713 DoMethod(obj, MUIM_DrawBackground,
1714 rect.MinX, rect.MinY,
1715 rect.MaxX - rect.MinX + 1, rect.MaxY - rect.MinY + 1,
1716 clear_xoffset, clear_yoffset,
1719 /* We could have deleted also other icons so they must be redrawn */
1720 #ifdef __AROS__
1721 ForeachNode(&data->icld_Icon, icon)
1722 #else
1723 Foreach_Node(&data->icld_Icon, icon);
1724 #endif
1726 if ((icon != data->update_icon) && (icon->IcD_Flags & ICONENTRY_FLAG_VISIBLE))
1728 struct Rectangle rect2;
1729 Icon_GetIconAreaRectangle(obj, data, icon, &rect2);
1731 rect2.MinX += _mleft(obj) - data->icld_ViewX + icon->IcD_IconX;
1732 rect2.MaxX += _mleft(obj) - data->icld_ViewX + icon->IcD_IconX;
1733 rect2.MinY += _mtop(obj) - data->icld_ViewY + icon->IcD_IconY;
1734 rect2.MaxY += _mtop(obj) - data->icld_ViewY + icon->IcD_IconY;
1736 if (data->icld__Option_IconMode == ICON_LISTMODE_GRID)
1738 if (icon->IcD_AreaWidth < data->icld_IconAreaLargestWidth)
1740 rect2.MinX += ((data->icld_IconAreaLargestWidth - icon->IcD_AreaWidth)/2);
1741 rect2.MaxX += ((data->icld_IconAreaLargestWidth - icon->IcD_AreaWidth)/2);
1744 if (icon->IcD_AreaHeight < data->icld_IconAreaLargestHeight)
1746 rect2.MinY += ((data->icld_IconAreaLargestHeight - icon->IcD_AreaHeight)/2);
1747 rect2.MaxY += ((data->icld_IconAreaLargestHeight - icon->IcD_AreaHeight)/2);
1751 if (RectAndRect(&rect, &rect2))
1753 // Update icon here
1754 DoMethod(obj, MUIM_Icon_DrawEntry, icon, ICONENTRY_DRAWMODE_PLAIN);
1755 DoMethod(obj, MUIM_Icon_DrawEntryLabel, icon, ICONENTRY_DRAWMODE_PLAIN);
1760 DoMethod(obj, MUIM_Icon_DrawEntry, data->update_icon, ICONENTRY_DRAWMODE_PLAIN);
1761 DoMethod(obj, MUIM_Icon_DrawEntryLabel, data->update_icon, ICONENTRY_DRAWMODE_PLAIN);
1762 data->icld_UpdateMode = 0;
1763 data->update_icon = NULL;
1765 if (data->icld_DisplayRastPort != data->icld_BufferRastPort)
1767 #if defined(DEBUG_ILC_ICONRENDERING)
1768 D(bug("[Icon] %s#%d: UPDATE_SINGLEICON Blitting to front rastport..\n", __PRETTY_FUNCTION__, draw_id));
1769 #endif
1770 BltBitMapRastPort(data->icld_BufferRastPort->BitMap,
1771 rect.MinX - _mleft(obj), rect.MinY - _mtop(obj),
1772 data->icld_DisplayRastPort,
1773 rect.MinX, rect.MinY,
1774 rect.MaxX - rect.MinX + 1, rect.MaxY - rect.MinY + 1,
1775 0xC0);
1778 MUI_RemoveClipping(muiRenderInfo(obj),clip);
1779 goto draw_done;
1781 else if (data->icld_UpdateMode == UPDATE_SCROLL)
1783 struct Region *region = NULL;
1784 struct Rectangle xrect,
1785 yrect;
1786 BOOL scroll_caused_damage;
1788 #if defined(DEBUG_ILC_ICONRENDERING)
1789 D(bug("[Icon] %s#%d: UPDATE_SCROLL.\n", __PRETTY_FUNCTION__, draw_id));
1790 #endif
1792 if (!data->icld__Option_IconFixedBackground)
1794 scroll_caused_damage = (_rp(obj)->Layer->Flags & LAYERREFRESH) ? FALSE : TRUE;
1796 data->icld_UpdateMode = 0;
1798 if ((abs(data->update_scrolldx) >= _mwidth(obj)) ||
1799 (abs(data->update_scrolldy) >= _mheight(obj)))
1801 #if defined(DEBUG_ILC_ICONRENDERING)
1802 D(bug("[Icon] %s#%d: UPDATE_SCROLL: Moved outside current view\n", __PRETTY_FUNCTION__, draw_id));
1803 #endif
1804 MUI_Redraw(obj, MADF_DRAWOBJECT);
1805 goto draw_done;
1808 if (!(region = NewRegion()))
1810 #if defined(DEBUG_ILC_ICONRENDERING)
1811 D(bug("[Icon] %s#%d: UPDATE_SCROLL: Couldnt Alloc Region\n", __PRETTY_FUNCTION__, draw_id));
1812 #endif
1813 MUI_Redraw(obj, MADF_DRAWOBJECT);
1814 goto draw_done;
1817 if (data->update_scrolldx > 0)
1819 xrect.MinX = _mright(obj) - data->update_scrolldx;
1820 xrect.MinY = _mtop(obj);
1821 xrect.MaxX = _mright(obj);
1822 xrect.MaxY = _mbottom(obj);
1824 OrRectRegion(region, &xrect);
1826 data->update_rect1 = &xrect;
1828 else if (data->update_scrolldx < 0)
1830 xrect.MinX = _mleft(obj);
1831 xrect.MinY = _mtop(obj);
1832 xrect.MaxX = _mleft(obj) - data->update_scrolldx;
1833 xrect.MaxY = _mbottom(obj);
1835 OrRectRegion(region, &xrect);
1837 data->update_rect1 = &xrect;
1840 if (data->update_scrolldy > 0)
1842 yrect.MinX = _mleft(obj);
1843 yrect.MinY = _mbottom(obj) - data->update_scrolldy;
1844 yrect.MaxX = _mright(obj);
1845 yrect.MaxY = _mbottom(obj);
1847 OrRectRegion(region, &yrect);
1849 data->update_rect2 = &yrect;
1851 else if (data->update_scrolldy < 0)
1853 yrect.MinX = _mleft(obj);
1854 yrect.MinY = _mtop(obj);
1855 yrect.MaxX = _mright(obj);
1856 yrect.MaxY = _mtop(obj) - data->update_scrolldy;
1858 OrRectRegion(region, &yrect);
1860 data->update_rect2 = &yrect;
1863 #if defined(DEBUG_ILC_ICONRENDERING)
1864 D(bug("[Icon] %s#%d: UPDATE_SCROLL: Scrolling Raster..\n", __PRETTY_FUNCTION__, draw_id));
1865 #endif
1866 if (data->icld_DisplayRastPort == data->icld_BufferRastPort)
1868 ScrollRasterBF(data->icld_BufferRastPort,
1869 data->update_scrolldx,
1870 data->update_scrolldy,
1871 _mleft(obj),
1872 _mtop(obj),
1873 _mright(obj),
1874 _mbottom(obj));
1876 else
1878 ScrollRasterBF(data->icld_BufferRastPort,
1879 data->update_scrolldx,
1880 data->update_scrolldy,
1883 _mwidth(obj),
1884 _mheight(obj));
1887 scroll_caused_damage = scroll_caused_damage && (_rp(obj)->Layer->Flags & LAYERREFRESH) ? TRUE : FALSE;
1889 clip = MUI_AddClipRegion(muiRenderInfo(obj), region);
1892 #if defined(DEBUG_ILC_ICONRENDERING)
1893 D(bug("[Icon] %s#%d: UPDATE_SCROLL: Causing Redraw..\n", __PRETTY_FUNCTION__, draw_id));
1894 #endif
1895 MUI_Redraw(obj, MADF_DRAWOBJECT);
1897 data->update_rect1 = data->update_rect2 = NULL;
1899 if (!data->icld__Option_IconFixedBackground)
1901 MUI_RemoveClipRegion(muiRenderInfo(obj), clip);
1903 if (scroll_caused_damage)
1905 if (MUI_BeginRefresh(muiRenderInfo(obj), 0))
1907 /* Theoretically it might happen that more damage is caused
1908 after ScrollRaster. By something else, like window movement
1909 in front of our window. Therefore refresh root object of
1910 window, not just this object */
1912 Object *o = NULL;
1914 GET(_win(obj),MUIA_Window_RootObject, &o);
1915 MUI_Redraw(o, MADF_DRAWOBJECT);
1917 MUI_EndRefresh(muiRenderInfo(obj), 0);
1921 if (data->icld_DisplayRastPort != data->icld_BufferRastPort)
1923 #if defined(DEBUG_ILC_ICONRENDERING)
1924 D(bug("[Icon] %s#%d: UPDATE_SCROLL: Blitting to front rastport..\n", __PRETTY_FUNCTION__, draw_id));
1925 #endif
1926 BltBitMapRastPort(data->icld_BufferRastPort->BitMap,
1927 0, 0,
1928 data->icld_DisplayRastPort,
1929 _mleft(obj), _mtop(obj),
1930 _mwidth(obj), _mheight(obj),
1931 0xC0);
1933 goto draw_done;
1935 else if (data->icld_UpdateMode == UPDATE_RESIZE)
1937 struct Region *region = NULL;
1938 struct Rectangle wrect,
1939 hrect;
1940 ULONG diffw = 0,
1941 diffh = 0;
1943 #if defined(DEBUG_ILC_ICONRENDERING)
1944 D(bug("[Icon] %s#%d: UPDATE_RESIZE.\n", __PRETTY_FUNCTION__, draw_id));
1945 #endif
1947 if ((data->icld_BufferRastPort) && (data->icld_BufferRastPort != data->icld_DisplayRastPort))
1949 //Free up the buffers rastport and bitmap so we can replace them ..
1950 struct Bitmap *bitmap_Old = data->icld_BufferRastPort->BitMap;
1951 struct Bitmap *bitmap_New;
1953 ULONG tmp_RastDepth;
1955 data->icld_BufferRastPort->BitMap = NULL;
1957 FreeRastPort(data->icld_BufferRastPort);
1958 SET(obj, MUIA_Icon_BufferRastport, NULL);
1960 tmp_RastDepth = GetCyberMapAttr(data->icld_DisplayRastPort->BitMap, CYBRMATTR_DEPTH);
1961 if ((bitmap_New = AllocBitMap(data->icld_ViewWidth,
1962 data->icld_ViewHeight,
1963 tmp_RastDepth,
1964 BMF_CLEAR,
1965 data->icld_DisplayRastPort->BitMap))!=NULL)
1967 if ((data->icld_BufferRastPort = CreateRastPort())!=NULL)
1969 data->icld_BufferRastPort->BitMap = bitmap_New;
1970 SET(obj, MUIA_Icon_BufferRastport, data->icld_BufferRastPort);
1971 data->icld_DrawOffsetX = 0;
1972 data->icld_DrawOffsetY = 0;
1974 else
1976 FreeBitMap(bitmap_New);
1977 data->icld_BufferRastPort = data->icld_DisplayRastPort;
1978 data->icld_DrawOffsetX = _mleft(obj);
1979 data->icld_DrawOffsetY = _mtop(obj);
1983 if (bitmap_Old != data->icld_BufferRastPort->BitMap)
1984 FreeBitMap(bitmap_Old);
1987 data->icld_UpdateMode = 0;
1989 if (!data->icld__Option_IconScaledBackground)
1991 if (!(region = NewRegion()))
1993 MUI_Redraw(obj, MADF_DRAWOBJECT);
1994 goto draw_done;
1997 if ( data->icld_ViewWidth > update_oldwidth )
1998 diffw = data->icld_ViewWidth - update_oldwidth;
1999 if ( data->icld_ViewHeight > update_oldheight )
2000 diffh = data->icld_ViewHeight - update_oldheight;
2002 if (diffw)
2004 wrect.MinX = _mright(obj) - diffw;
2005 wrect.MinY = _mtop(obj);
2006 wrect.MaxX = _mright(obj);
2007 wrect.MaxY = _mbottom(obj);
2008 OrRectRegion(region, &wrect);
2009 data->update_rect1 = &wrect;
2012 if (diffh)
2014 hrect.MinX = _mleft(obj);
2015 hrect.MinY = _mbottom(obj) - diffh;
2016 hrect.MaxX = _mright(obj);
2017 hrect.MaxX = _mright(obj);
2018 hrect.MaxY = _mbottom(obj);
2019 OrRectRegion(region, &hrect);
2020 data->update_rect2 = &hrect;
2022 if (diffh||diffw)
2024 clip = MUI_AddClipRegion(muiRenderInfo(obj), region);
2026 else
2028 /* View became smaller both in horizontal and vertical direction.
2029 Nothing to do */
2031 DisposeRegion(region);
2032 goto draw_done;
2036 MUI_Redraw(obj, MADF_DRAWOBJECT);
2038 if (!data->icld__Option_IconScaledBackground)
2040 if (diffh||diffw)
2042 data->update_rect1 = data->update_rect2 = NULL;
2043 MUI_RemoveClipRegion(muiRenderInfo(obj), clip);
2044 } else DisposeRegion(region);
2047 goto draw_done;
2051 if (message->flags & MADF_DRAWOBJECT)
2053 struct Rectangle viewrect;
2055 #if defined(DEBUG_ILC_ICONRENDERING)
2056 D(bug("[Icon] %s#%d: MADF_DRAWOBJECT\n", __PRETTY_FUNCTION__, draw_id));
2057 #endif
2059 clip = MUI_AddClipping(muiRenderInfo(obj), _mleft(obj), _mtop(obj), _mwidth(obj), _mheight(obj));
2061 viewrect.MinX = _mleft(obj);
2062 viewrect.MaxX = _mleft(obj) + _mwidth(obj);
2063 viewrect.MinY = _mtop(obj);
2064 viewrect.MaxY = _mtop(obj) + _mheight(obj);
2066 #if defined(DEBUG_ILC_ICONRENDERING)
2067 D(bug("[Icon] %s#%d: MADF_DRAWOBJECT: Calling MUIM_DrawBackground (B)\n", __PRETTY_FUNCTION__, draw_id));
2068 #endif
2069 DoMethod(
2070 obj, MUIM_DrawBackground, _mleft(obj), _mtop(obj), _mwidth(obj), _mheight(obj),
2071 clear_xoffset, clear_yoffset, 0
2073 #ifdef __AROS__
2074 ForeachNode(&data->icld_Icon, icon)
2075 #else
2076 Foreach_Node(&data->icld_Icon, icon);
2077 #endif
2079 if ((icon->IcD_Flags & ICONENTRY_FLAG_VISIBLE) &&
2080 (icon->IcD_DiskObj) &&
2081 (icon->IcD_IconX != NO_ICON_POSITION) &&
2082 (icon->IcD_IconY != NO_ICON_POSITION))
2084 struct Rectangle iconrect;
2085 Icon_GetIconAreaRectangle(obj, data, icon, &iconrect);
2087 iconrect.MinX += _mleft(obj) - data->icld_ViewX + icon->IcD_IconX;
2088 iconrect.MaxX += _mleft(obj) - data->icld_ViewX + icon->IcD_IconX;
2089 iconrect.MinY += _mtop(obj) - data->icld_ViewY + icon->IcD_IconY;
2090 iconrect.MaxY += _mtop(obj) - data->icld_ViewY + icon->IcD_IconY;
2092 if (RectAndRect(&viewrect, &iconrect))
2094 DoMethod(obj, MUIM_Icon_DrawEntry, icon, ICONENTRY_DRAWMODE_PLAIN);
2095 DoMethod(obj, MUIM_Icon_DrawEntryLabel, icon, ICONENTRY_DRAWMODE_PLAIN);
2100 if (data->icld_DisplayRastPort != data->icld_BufferRastPort)
2102 #if defined(DEBUG_ILC_ICONRENDERING)
2103 D(bug("[Icon] %s#%d: MADF_DRAWOBJECT: Blitting to front rastport..\n", __PRETTY_FUNCTION__, draw_id));
2104 #endif
2105 BltBitMapRastPort(data->icld_BufferRastPort->BitMap,
2106 0, 0,
2107 data->icld_DisplayRastPort,
2108 _mleft(obj), _mtop(obj),
2109 _mwidth(obj), _mheight(obj),
2110 0xC0);
2113 MUI_RemoveClipping(muiRenderInfo(obj), clip);
2115 data->icld_UpdateMode = 0;
2117 draw_done:;
2119 D(bug("[Icon] %s: Draw finished for id %d\n", __PRETTY_FUNCTION__, draw_id));
2121 return 0;
2125 ///Icon__MUIM_Icon_Update()
2126 /**************************************************************************
2127 MUIM_Icon_Refresh
2128 Implemented by subclasses
2129 **************************************************************************/
2130 IPTR Icon__MUIM_Icon_Update(struct IClass *CLASS, Object *obj, struct MUIP_Icon_Update *message)
2132 struct Icon_DATA *data = INST_DATA(CLASS, obj);
2134 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
2136 return 1;
2140 ///Icon__MUIM_Icon_DestroyEntry()
2141 IPTR Icon__MUIM_Icon_DestroyEntry(struct IClass *CLASS, Object *obj, struct MUIP_Icon_DestroyEntry *message)
2143 struct Icon_DATA *data = INST_DATA(CLASS, obj);
2145 D(bug("[Icon]: %s()\n", __PRETTY_FUNCTION__));
2147 if (message->icon)
2149 if (message->icon->IcD_Flags & ICONENTRY_FLAG_SELECTED)
2151 Remove(&message->icon->IcD_SelectionNode);
2153 FreeVecPooled(data->icld_Pool, message->icon->IcD_DisplayedLabel_TXTBUFF);
2154 if (message->icon->IcD_TxtBuf_PROT)
2155 FreePooled(data->icld_Pool, message->icon->IcD_TxtBuf_PROT, 8);
2156 if (message->icon->IcD_Size_TXTBUFF)
2157 FreePooled(data->icld_Pool, message->icon->IcD_Size_TXTBUFF, 30);
2158 if (message->icon->IcD_Time_TXTBUFF)
2159 FreePooled(data->icld_Pool, message->icon->IcD_Time_TXTBUFF,
2160 LEN_DATSTRING);
2161 if (message->icon->IcD_Date_TXTBUFF)
2162 FreePooled(data->icld_Pool, message->icon->IcD_Date_TXTBUFF,
2163 LEN_DATSTRING);
2164 if (message->icon->IcD_DiskObj) FreeDiskObject(message->icon->IcD_DiskObj);
2165 if (message->icon->IcD_Label_TXTBUFF) FreePooled(data->icld_Pool, message->icon->IcD_Label_TXTBUFF, strlen(message->icon->IcD_Label_TXTBUFF)+1);
2166 if (message->icon->IcD_IconEntry.filename) FreePooled(data->icld_Pool, message->icon->IcD_IconEntry.filename, strlen(message->icon->IcD_IconEntry.filename)+1);
2168 return TRUE;
2172 ///Icon__MUIM_Icon_CreateEntry()
2173 /**************************************************************************
2174 MUIM_Icon_CreateEntry.
2175 Returns 0 on failure; otherwise it returns the icon's entry.
2176 **************************************************************************/
2177 IPTR Icon__MUIM_Icon_CreateEntry(struct IClass *CLASS, Object *obj, struct MUIP_Icon_CreateEntry *message)
2183 #if WANDERER_BUILTIN_ICONLIST
2184 BOOPSI_DISPATCHER(IPTR,Icon_Dispatcher, CLASS, obj, message)
2186 #ifdef __AROS__
2187 switch (message->MethodID)
2188 #else
2189 struct IClass *CLASS = cl;
2190 Msg message = msg;
2192 switch (msg->MethodID)
2193 #endif
2195 case OM_NEW: return Icon__OM_NEW(CLASS, obj, (struct opSet *)message);
2196 case OM_DISPOSE: return Icon__OM_DISPOSE(CLASS, obj, message);
2197 case OM_SET: return Icon__OM_SET(CLASS, obj, (struct opSet *)message);
2198 case OM_GET: return Icon__OM_GET(CLASS, obj, (struct opGet *)message);
2200 case MUIM_Setup: return Icon__MUIM_Setup(CLASS, obj, (struct MUIP_Setup *)message);
2202 case MUIM_Show: return Icon__MUIM_Show(CLASS,obj, (struct MUIP_Show *)message);
2203 case MUIM_Hide: return Icon__MUIM_Hide(CLASS,obj, (struct MUIP_Hide *)message);
2204 case MUIM_Cleanup: return Icon__MUIM_Cleanup(CLASS, obj, (struct MUIP_Cleanup *)message);
2205 case MUIM_AskMinMax: return Icon__MUIM_AskMinMax(CLASS, obj, (struct MUIP_AskMinMax *)message);
2206 case MUIM_Draw: return Icon__MUIM_Draw(CLASS, obj, (struct MUIP_Draw *)message);
2207 #ifdef __AROS__
2208 case MUIM_Layout: return Icon__MUIM_Layout(CLASS, obj, (struct MUIP_Layout *)message);
2209 #endif
2210 case MUIM_CreateDragImage: return Icon__MUIM_CreateDragImage(CLASS, obj, (APTR)message);
2211 case MUIM_DeleteDragImage: return Icon__MUIM_DeleteDragImage(CLASS, obj, (APTR)message);
2213 case MUIM_Icon_DrawEntry: return Icon__MUIM_Icon_DrawEntry(CLASS, obj, (APTR)message);
2214 case MUIM_Icon_DrawEntryLabel: return Icon__MUIM_Icon_DrawEntryLabel(CLASS, obj, (APTR)message);
2215 case MUIM_Icon_GetIconPrivate: return Icon__MUIM_Icon_GetIconPrivate(CLASS, obj, (APTR)message);
2217 return DoSuperMethodA(CLASS, obj, message);
2219 BOOPSI_DISPATCHER_END
2221 #ifdef __AROS__
2222 /* Class descriptor. */
2223 const struct __MUIBuiltinClass _MUI_Icon_desc = {
2224 MUIC_Icon,
2225 MUIC_Area,
2226 sizeof(struct Icon_DATA),
2227 (void*)Icon_Dispatcher
2229 #endif
2230 #endif
2232 #ifndef __AROS__
2233 struct MUI_CustomClass *initIconClass(void)
2235 return (struct MUI_CustomClass *) MUI_CreateCustomClass(NULL, MUIC_Area, NULL, sizeof(struct Icon_DATA), ENTRY(Icon_Dispatcher));
2238 #endif