1 /***************************************************************************
3 NList.mcc - New List MUI Custom Class
4 Registered MUI class, Serial Number: 1d51 0x9d510030 to 0x9d5100A0
5 0x9d5100C0 to 0x9d5100FF
7 Copyright (C) 1996-2001 by Gilles Masson
8 Copyright (C) 2001-2014 NList Open Source Team
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 NList classes Support Site: http://www.sf.net/projects/nlist-classes
24 ***************************************************************************/
28 #include <exec/execbase.h>
29 #include <exec/memory.h>
30 #include <intuition/pointerclass.h>
31 #include <datatypes/pictureclass.h>
33 #include <proto/exec.h>
34 #include <proto/graphics.h>
35 #include <proto/muimaster.h>
36 #include <proto/intuition.h>
37 #include <proto/exec.h>
38 #include <proto/layers.h>
42 #include "NList_func.h"
44 #if !defined(__amigaos4__) && !defined(__MORPHOS__) && !defined(__AROS__)
45 LONG
ObtainBestPen( struct ColorMap
*cm
, ULONG r
, ULONG g
, ULONG b
, ULONG tag1Type
, ... );
48 /****************************************************************************************/
49 /****************************************************************************************/
50 /****************************** **************************************/
51 /****************************** NList Class **************************************/
52 /****************************** **************************************/
53 /****************************************************************************************/
54 /****************************************************************************************/
56 BOOL
NL_OnWindow(struct NLData
*data
,LONG x
,LONG y
)
58 BOOL onWindow
= FALSE
;
59 Object
*obj
= data
->this;
61 #if defined(__MORPHOS__)
62 /* No need for hit test in MorphOS 2.0 */
63 if (SysBase
->LibNode
.lib_Version
>= 51)
67 if (data
->SHOW
&& muiRenderInfo(obj
) && _screen(obj
) != NULL
&& _window(obj
) != NULL
)
69 // first check whether the mouse is over the object itself
70 if(x
>= _mleft(obj
) && x
<= _mright(obj
) && y
>= _mtop(obj
) && y
<= _mbottom(obj
))
72 // now check if the mouse is currently over the object and over the object's window
73 struct Layer_Info
*li
= &(_screen(obj
)->LayerInfo
);
76 // get the layer that belongs to the current mouse coordinates
78 layer
= WhichLayer(li
, _window(obj
)->LeftEdge
+ x
, _window(obj
)->TopEdge
+ y
);
81 if(layer
!= NULL
&& layer
->Window
== _window(obj
))
86 struct Layer *wlay,*lay;
87 ULONG lkib = LockIBase( 0 );
88 x += _window(obj)->LeftEdge;
89 y += _window(obj)->TopEdge;
90 wlay = _window(obj)->WLayer;
91 for (lay = wlay->front; wlay && lay; lay = lay->front)
92 { win = (struct Window *) lay->Window;
93 for (win = _screen(obj)->FirstWindow; win ; win = win->NextWindow)
94 { if (win->WLayer == lay)
95 { if ((x >= win->LeftEdge) && (y >= win->TopEdge) &&
96 (x < win->LeftEdge + win->Width) && (y < win->TopEdge + win->Height))
97 { UnlockIBase( lkib );
112 struct NImgList
*GetNImage(struct NLData
*data
,char *ImgName
)
114 struct NImgList
*nimg
= &data
->NImage
;
115 int nameLen
= strlen(ImgName
)+2;
117 while (nimg
&& nimg
->ImgName
&& strcmp(nimg
->ImgName
,ImgName
))
119 if (!nimg
&& (nimg
= (struct NImgList
*)AllocVecPooled(data
->Pool
, sizeof(struct NImgList
)+nameLen
)) != NULL
)
120 { nimg
->ImgName
= (char *) nimg
;
121 nimg
->ImgName
= &nimg
->ImgName
[sizeof(struct NImgList
)];
122 strlcpy(nimg
->ImgName
, ImgName
, nameLen
);
123 nimg
->NImgObj
= NULL
;
128 nimg
->next
= data
->NImage
.next
;
129 data
->NImage
.next
= nimg
;
131 if (nimg
&& !nimg
->NImgObj
&& data
->adding_member
&& (nimg
->width
!= -1000))
132 { if ((data
->adding_member
== 1) && !data
->NList_Quiet
&& !data
->NList_Disabled
&& data
->SETUP
&& data
->SHOW
&& DoMethod(data
->NL_Group
,MUIM_Group_InitChange
))
133 data
->adding_member
= 2;
134 if (data
->adding_member
>= 2)
136 nimg
->NImgObj
= MUI_NewObject(MUIC_Image
,
138 MUIA_Image_Spec
,nimg
->ImgName
,
140 * MUIA_InputMode,MUIV_InputMode_Toggle,
141 * MUIA_Image_State, IDS_NORMAL,
142 * MUIA_Selected, FALSE,
143 * MUIA_Image_FontMatch, TRUE,
144 * MUIA_Font, Topaz_8,
149 /*D(bug("%lx|OM_ADDMEMBER,nimg->NImgObj %ld\n",obj,data->adding_member));*/
150 DoMethod(data
->NL_Group
,OM_ADDMEMBER
,nimg
->NImgObj
);
151 set(nimg
->NImgObj
, MUIA_Disabled
, FALSE
);
154 nimg
->width
= _defwidth(nimg
->NImgObj
);
155 nimg
->height
= _defheight(nimg
->NImgObj
);
158 data
->do_images
= TRUE
;
161 { nimg
->width
= -1000;
166 data
->do_images
= TRUE
;
172 void DeleteNImages(struct NLData
*data
)
174 struct NImgList
*nimg
= data
->NImage
.next
;
178 data
->NImage
.next
= nimg
->next
;
179 FreeVecPooled(data
->Pool
, nimg
);
180 nimg
= data
->NImage
.next
;
185 struct NImgList
*GetNImage2(struct NLData
*data
,APTR imgobj
)
187 struct NImgList
*nimg2
= data
->NImage2
;
188 while (nimg2
&& (nimg2
->NImgObj
!= imgobj
) && (nimg2
->ImgName
!= imgobj
))
190 if (!nimg2
&& (nimg2
= (struct NImgList
*)AllocVecPooled(data
->Pool
, sizeof(struct NImgList
))) != NULL
)
191 { nimg2
->NImgObj
= NULL
;
192 nimg2
->width
= -1000;
196 nimg2
->ImgName
= imgobj
;
197 nimg2
->next
= data
->NImage2
;
198 data
->NImage2
= nimg2
;
200 if (nimg2
&& nimg2
->ImgName
&& !nimg2
->NImgObj
&& (nimg2
->width
== -1000) && data
->adding_member
)
202 if(xget((Object
*)nimg2
->ImgName
, MUIA_Parent
))
205 * D(bug("%lx|GetNImage2 %lx already attached !\n",obj,nimg2->ImgName));
209 { if ((data
->adding_member
== 1) && !data
->NList_Quiet
&& !data
->NList_Disabled
&& data
->SETUP
&& data
->SHOW
&& DoMethod(data
->NL_Group
,MUIM_Group_InitChange
))
210 data
->adding_member
= 2;
211 if (data
->adding_member
>= 2)
212 { nimg2
->NImgObj
= (APTR
) nimg2
->ImgName
;
213 nimg2
->ImgName
= NULL
;
214 /*D(bug("%lx|OM_ADDMEMBER,nimg2->NImgObj %ld\n",obj,data->adding_member));*/
215 DoMethod(data
->NL_Group
,OM_ADDMEMBER
,nimg2
->NImgObj
);
216 set(nimg2
->NImgObj
, MUIA_Disabled
, FALSE
);
219 { nimg2
->width
= _defwidth(nimg2
->NImgObj
);
220 nimg2
->height
= _defheight(nimg2
->NImgObj
);
225 data
->do_images
= TRUE
;
229 data
->do_images
= TRUE
;
236 void DeleteNImages2(struct NLData
*data
)
238 struct NImgList
*nimg2
= data
->NImage2
;
242 data
->NImage2
= nimg2
->next
;
243 if (nimg2
->ImgName
&& !nimg2
->NImgObj
)
244 MUI_DisposeObject((APTR
) nimg2
->ImgName
);
245 FreeVecPooled(data
->Pool
, nimg2
);
246 nimg2
= data
->NImage2
;
251 void GetNImage_Sizes(struct NLData
*data
)
255 struct NImgList
*nimg
= &data
->NImage
;
256 struct NImgList
*nimg2
= data
->NImage2
;
262 nimg
->width
= _defwidth(nimg
->NImgObj
);
263 nimg
->height
= _defheight(nimg
->NImgObj
);
264 if (data
->MinImageHeight
< _minheight(nimg
->NImgObj
))
266 if (_minheight(nimg
->NImgObj
) > 20)
268 if (data
->MinImageHeight
< 20)
269 data
->MinImageHeight
= 20;
272 data
->MinImageHeight
= _minheight(nimg
->NImgObj
);
274 _left(nimg
->NImgObj
) = _left(data
->NL_Group
);
275 _top(nimg
->NImgObj
) = _top(data
->NL_Group
);
282 if (nimg2
->NImgObj
&& (nimg2
->width
!= -1000))
284 nimg2
->width
= _defwidth(nimg2
->NImgObj
);
285 nimg2
->height
= _defheight(nimg2
->NImgObj
);
286 if (data
->MinImageHeight
< _minheight(nimg2
->NImgObj
))
288 if (_minheight(nimg2
->NImgObj
) > 30)
290 if (data
->MinImageHeight
< 30)
291 data
->MinImageHeight
= 30;
294 data
->MinImageHeight
= _minheight(nimg2
->NImgObj
);
296 _left(nimg2
->NImgObj
) = _left(data
->NL_Group
);
297 _top(nimg2
->NImgObj
) = _top(data
->NL_Group
);
303 data
->do_images
= TRUE
;
307 void GetNImage_End(struct NLData
*data
)
309 if (data
->adding_member
== 2)
311 data
->adding_member
= 0;
312 /*D(bug("%lx|GNIE Group_ExitChange\n",obj));*/
314 DoMethod(data
->NL_Group
,MUIM_Group_ExitChange
);
316 GetNImage_Sizes(data
);
318 data
->adding_member
= 0;
322 void GetImages(struct NLData
*data
)
324 if (data
->SHOW
&& data
->do_images
)
326 struct NImgList
*nimg
= &data
->NImage
;
327 struct NImgList
*nimg2
= data
->NImage2
;
329 if (data
->adding_member
!= 2)
330 data
->adding_member
= 1;
335 GetNImage(data
,nimg
->ImgName
);
341 if (nimg2
->ImgName
&& !nimg2
->NImgObj
&& (nimg2
->width
== -1000))
342 GetNImage2(data
,nimg2
->ImgName
);
345 data
->do_images
= FALSE
;
355 static void disposeBitMap(struct NLData
*data
,struct BitMap
*bitmap
, LONG width
, LONG height
)
359 for (ktr
= 0; ktr
< bitmap
->Depth
; ktr
++)
360 { if (bitmap
->Planes
[ktr
])
362 /*D(bug("FreeRaster(%lx) (dispBM_planes)\n",bitmap->Planes[ktr]));*/
363 FreeRaster(bitmap
->Planes
[ktr
], width
, height
);
366 FreeVecPooled(data
->Pool
, bitmap
);
371 static void disposeBitMapImage(struct NLData
*data
,struct BitMapImage
*bmimg
)
373 if (bmimg
&& data
->SETUP
)
377 for (ktr
= 0; ktr
< bmimg
->imgbmp
.Depth
; ktr
++)
379 if (bmimg
->imgbmp
.Planes
[ktr
])
381 /*D(bug("FreeRaster(%lx) (dispBMI_planes)\n",bmimg->imgbmp.Planes[ktr]));*/
382 FreeRaster(bmimg
->imgbmp
.Planes
[ktr
], bmimg
->width
, bmimg
->height
);
387 /*D(bug("FreeRaster(%lx) (dispBMI_mask)\n",bmimg->mask));*/
388 FreeRaster(bmimg
->mask
, bmimg
->width
, bmimg
->height
);
390 if (bmimg
->obtainpens
)
393 while (bmimg
->obtainpens
[ktr
] != -3)
395 if ((bmimg
->obtainpens
[ktr
] >= 0) || (bmimg
->obtainpens
[ktr
] < -3))
396 ReleasePen(_screen(data
->this)->ViewPort
.ColorMap
, (ULONG
) bmimg
->obtainpens
[ktr
]);
399 FreeVecPooled(data
->Pool
, bmimg
->obtainpens
);
401 FreeVecPooled(data
->Pool
, bmimg
);
406 IPTR
NL_CreateImage2(struct NLData
*data
,Object
*imgobj
,ULONG flags
)
408 struct BitMapImage
*bmimg
= NULL
;
412 if((bmimg
= AllocVecPooled(data
->Pool
,sizeof(struct BitMapImage
))) != NULL
)
414 if (GetNImage2(data
,imgobj
))
416 bmimg
->control
= MUIA_Image_Spec
;
419 bmimg
->obtainpens
= (APTR
) imgobj
;
420 if (flags
!= (ULONG
)~0L)
421 nnset(imgobj
,MUIA_FillArea
,FALSE
);
423 * nnset(imgobj,MUIA_Image_FontMatch,FALSE);
424 * nnset(imgobj,MUIA_Image_FontMatchHeight,FALSE);
425 * nnset(imgobj,MUIA_Image_FontMatchWidth,FALSE);
426 * nnset(imgobj,MUIA_Image_State,IDS_SELECTED);
427 * nnset(imgobj,MUIA_Selected,FALSE);
428 * nnset(imgobj,MUIA_InputMode,MUIV_InputMode_Toggle);
434 FreeVecPooled(data
->Pool
, bmimg
);
439 MUI_DisposeObject((APTR
) imgobj
);
441 return ((IPTR
) bmimg
);
445 IPTR
NL_CreateImage(struct NLData
*data
,Object
*imgobj
,ULONG flags
)
447 SIPTR CI_BM_Width
= 0;
452 // check if the Bitmap_Width attribute doesn't exists
453 if((flags
== (ULONG
)~0L) || GetAttr(MUIA_Bitmap_Width
, imgobj
, (IPTR
*)&CI_BM_Width
) == FALSE
)
454 return (NL_CreateImage2(data
,imgobj
,flags
));
456 if (imgobj
&& data
->SETUP
)
458 LONG last_numpen
,last_newnumpen
;
459 struct BitMap
*CI_BM_Bitmap
= NULL
;
460 struct BitMap
*bm_src
= NULL
;
461 struct BitMapImage
*bmimg
= NULL
;
462 WORD
*obtainpens
= NULL
;
464 UBYTE
*CI_BC_Body
= NULL
;
465 LONG CI_BC_Depth
= 0;
466 LONG CI_BC_Compression
= 0;
467 LONG CI_BC_Masking
= 0;
468 LONG CI_BM_Height
= 0;
469 UBYTE
*CI_BM_MappingTable
= NULL
;
470 ULONG
*CI_BM_SourceColors
= NULL
;
471 LONG CI_BM_Precision
= 0;
472 LONG CI_BM_Transparent
= 0;
474 CI_BM_Bitmap
= (struct BitMap
*)xget(imgobj
, MUIA_Bitmap_Bitmap
);
475 CI_BM_Width
= xget(imgobj
, MUIA_Bitmap_Width
);
476 CI_BM_Height
= xget(imgobj
, MUIA_Bitmap_Height
);
477 CI_BM_MappingTable
= (UBYTE
*)xget(imgobj
, MUIA_Bitmap_MappingTable
);
478 CI_BM_Transparent
= xget(imgobj
, MUIA_Bitmap_Transparent
);
479 CI_BM_SourceColors
= (ULONG
*)xget(imgobj
, MUIA_Bitmap_SourceColors
);
480 CI_BM_Precision
= xget(imgobj
, MUIA_Bitmap_Precision
);
484 CI_BC_Body
= (UBYTE
*)xget(imgobj
, MUIA_Bodychunk_Body
);
485 CI_BC_Depth
= xget(imgobj
, MUIA_Bodychunk_Depth
);
486 CI_BC_Compression
= xget(imgobj
, MUIA_Bodychunk_Compression
);
487 CI_BC_Masking
= xget(imgobj
, MUIA_Bodychunk_Masking
);
491 if((bm_src
= AllocVecPooled(data
->Pool
, sizeof(struct BitMap
))) != NULL
)
494 BOOL bit_map_failed
= FALSE
;
496 InitBitMap(bm_src
,CI_BC_Depth
,CI_BM_Width
,CI_BM_Height
);
498 for (ktr
= 0; ktr
< bm_src
->Depth
; ktr
++)
500 if (!(bm_src
->Planes
[ktr
] = (PLANEPTR
) AllocRaster(CI_BM_Width
,CI_BM_Height
)))
501 bit_map_failed
= TRUE
;
505 disposeBitMap(data
,bm_src
,CI_BM_Width
,CI_BM_Height
);
510 WORD cptb
,cptr
,cptd
,offr
;
514 UBYTE
*body
= CI_BC_Body
;
516 for (cptr
= 0; cptr
< bm_src
->Rows
; cptr
++)
518 offr
= cptr
* bm_src
->BytesPerRow
;
519 for (cptd
= 0; cptd
< bm_src
->Depth
; cptd
++)
521 for (cptb
= 0; cptb
< bm_src
->BytesPerRow
; cptb
++)
523 if (CI_BC_Compression
== cmpByteRun1
)
528 bm_src
->Planes
[cptd
][offr
+cptb
] = val
;
530 bm_src
->Planes
[cptd
][offr
+cptb
] = *body
;
539 num
= (WORD
) *body
; type
= 1; body
++;
540 bm_src
->Planes
[cptd
][offr
+cptb
] = *body
;
544 num
= 256 - ((WORD
) *body
); type
= 0; body
++; val
= *body
;
545 bm_src
->Planes
[cptd
][offr
+cptb
] = val
;
550 bm_src
->Planes
[cptd
][offr
+cptb
] = *body
;
554 if (CI_BC_Masking
== mskHasMask
)
556 for (cptb
= 0; cptb
< bm_src
->BytesPerRow
; cptb
++)
558 if (CI_BC_Compression
== cmpByteRun1
)
574 num
= 256 - ((WORD
) *body
);
592 bm_src
= CI_BM_Bitmap
;
596 UBYTE mypen
,bit1
,bit2
;
597 WORD cptb
,cptr
,cptd
,offr
,offr1
,cptpen
;
599 last_numpen
= (1 << bm_src
->Depth
);
601 newdepth
= bm_src
->Depth
;
603 if (CI_BM_MappingTable
!= NULL
)
607 for (num
= 0;num
< last_numpen
;num
++)
609 if (last_newnumpen
< CI_BM_MappingTable
[num
])
610 last_newnumpen
= CI_BM_MappingTable
[num
];
613 while (last_newnumpen
)
616 last_newnumpen
= last_newnumpen
>> 1;
619 else if (CI_BM_SourceColors
!= NULL
)
623 obtainpens
= AllocVecPooled(data
->Pool
, (last_numpen
+1)*sizeof(*obtainpens
));
624 if (obtainpens
!= NULL
)
626 obtainpens
[last_numpen
] = -3;
627 for (cptpen
= 0; cptpen
< last_numpen
; cptpen
++)
628 obtainpens
[cptpen
] = -1;
629 for (cptr
= 0; cptr
< bm_src
->Rows
; cptr
++)
631 offr
= cptr
* bm_src
->BytesPerRow
;
632 for (cptb
= 0; cptb
< bm_src
->BytesPerRow
; cptb
++)
636 { /* get the source dot pen number */
639 for (cptd
= 0; cptd
< bm_src
->Depth
; cptd
++)
641 if (bm_src
->Planes
[cptd
][offr
+cptb
] & bit1
)
646 /* map the pen number */
647 if (mypen
== CI_BM_Transparent
)
648 obtainpens
[mypen
] = -2;
649 else if (obtainpens
[mypen
] == -1)
651 mycolor
= &CI_BM_SourceColors
[mypen
*3];
653 obtainpens
[mypen
] = (WORD
) ObtainBestPen(_screen(data
->this)->ViewPort
.ColorMap
,
654 mycolor
[0],mycolor
[1],mycolor
[2],
655 OBP_Precision
, CI_BM_Precision
,
657 if (obtainpens
[mypen
] == -1)
659 obtainpens
[mypen
] = (WORD
) ObtainBestPen(_screen(data
->this)->ViewPort
.ColorMap
,
660 mycolor
[0],mycolor
[1],mycolor
[2],
661 OBP_Precision
, PRECISION_GUI
,
664 if(last_newnumpen
< obtainpens
[mypen
])
665 last_newnumpen
= obtainpens
[mypen
];
672 while (last_newnumpen
)
675 last_newnumpen
= last_newnumpen
>> 1;
681 last_newnumpen
= 1 << newdepth
;
683 if ((newdepth
> 0) && (bmimg
= AllocVecPooled(data
->Pool
, sizeof(struct BitMapImage
))) != NULL
)
686 BOOL bmimg_failed
= FALSE
;
688 InitBitMap(&(bmimg
->imgbmp
),newdepth
,CI_BM_Width
,CI_BM_Height
);
689 bmimg
->control
= MUIM_NList_CreateImage
;
690 bmimg
->width
= CI_BM_Width
;
691 bmimg
->height
= CI_BM_Height
;
692 bmimg
->obtainpens
= obtainpens
;
693 for (ktr
= 0; ktr
< bmimg
->imgbmp
.Depth
; ktr
++)
695 if (!(bmimg
->imgbmp
.Planes
[ktr
] = (PLANEPTR
) AllocRaster(CI_BM_Width
,CI_BM_Height
)))
698 if (!(bmimg
->mask
= (PLANEPTR
) AllocRaster(CI_BM_Width
,CI_BM_Height
)))
702 disposeBitMapImage(data
,bmimg
);
708 int kprintf( const char *, ... );
709 kprintf( "SrcBitMap Width %ld Height %ld Depth %ld BytesPerRow %ld Rows %ld Depth %ld.\n",
710 GetBitMapAttr( bm_src, BMA_WIDTH ),
711 GetBitMapAttr( bm_src, BMA_HEIGHT ),
712 GetBitMapAttr( bm_src, BMA_DEPTH ),
716 kprintf( "BytesPerRow %ld Rows %ld.\n", bmimg->imgbmp.BytesPerRow, bmimg->imgbmp.Rows );
718 for (cptr
= 0; cptr
< bmimg
->imgbmp
.Rows
; cptr
++)
720 offr
= cptr
* bmimg
->imgbmp
.BytesPerRow
;
721 offr1
= cptr
* bm_src
->BytesPerRow
;
722 for (cptb
= 0; cptb
< bmimg
->imgbmp
.BytesPerRow
; cptb
++)
726 { /* get the source dot pen number */
729 for (cptd
= 0; cptd
< bm_src
->Depth
; cptd
++)
731 if (bm_src
->Planes
[cptd
][offr1
+cptb
] & bit1
) // here was bug!!!
735 /* map the pen number */
736 if (mypen
== CI_BM_Transparent
)
738 bmimg
->mask
[offr
+cptb
] &= ~bit1
;
743 bmimg
->mask
[offr
+cptb
] |= bit1
;
744 if (CI_BM_MappingTable
)
745 mypen
= (UBYTE
) CI_BM_MappingTable
[mypen
];
746 else if (CI_BM_SourceColors
&& obtainpens
&& ((obtainpens
[mypen
] >= 0) || (obtainpens
[mypen
] < -3)))
747 mypen
= (UBYTE
) obtainpens
[mypen
];
749 /* set the dest dot pen number */
751 for (cptd
= 0; cptd
< bmimg
->imgbmp
.Depth
; cptd
++)
754 bmimg
->imgbmp
.Planes
[cptd
][offr
+cptb
] |= bit1
;
756 bmimg
->imgbmp
.Planes
[cptd
][offr
+cptb
] &= ~bit1
;
767 if (!bmimg
&& obtainpens
)
768 FreeVecPooled(data
->Pool
, obtainpens
);
772 disposeBitMap(data
,bm_src
,CI_BM_Width
,CI_BM_Height
);
775 if (bmimg
&& (data
->MinImageHeight
< bmimg
->height
) && !flags
)
776 data
->MinImageHeight
= bmimg
->height
;
778 return ((IPTR
) bmimg
);
785 ULONG
NL_DeleteImage(struct NLData
*data
,APTR listimg
)
787 struct BitMapImage
*bmimg
= (struct BitMapImage
*) listimg
;
789 if (bmimg
&& (bmimg
->control
== MUIM_NList_CreateImage
))
792 disposeBitMapImage(data
,bmimg
);
794 else if (bmimg
&& (bmimg
->control
== MUIA_Image_Spec
))
796 APTR imgobj
= (APTR
) bmimg
->obtainpens
;
797 struct NImgList
*nimg2
= data
->NImage2
,*nimgprec
= NULL
;
799 while (nimg2
&& (nimg2
->NImgObj
!= imgobj
) && (nimg2
->ImgName
!= imgobj
))
808 nimgprec
->next
= nimg2
->next
;
810 data
->NImage2
= nimg2
->next
;
811 if (nimg2
->NImgObj
== imgobj
)
815 if((parent
= (Object
*)xget(imgobj
, MUIA_Parent
)) && (parent
== data
->NL_Group
))
817 if (data
->SETUP
&& DoMethod(data
->NL_Group
,MUIM_Group_InitChange
))
819 DoMethod(data
->NL_Group
,OM_REMMEMBER
,imgobj
);
820 DoMethod(data
->NL_Group
,MUIM_Group_ExitChange
);
823 DoMethod(data
->NL_Group
,OM_REMMEMBER
,imgobj
);
826 FreeVecPooled(data
->Pool
, nimg2
);
828 FreeVecPooled(data
->Pool
, bmimg
);
834 ULONG
NL_CreateImages(struct NLData
*data
)
836 if (data
->NList_UseImages
&& data
->SETUP
)
840 while (pos
< data
->LastImage
)
842 if (data
->NList_UseImages
[pos
].imgobj
)
843 data
->NList_UseImages
[pos
].bmimg
= (struct BitMapImage
*)
844 NL_CreateImage(data
,data
->NList_UseImages
[pos
].imgobj
,data
->NList_UseImages
[pos
].flags
);
846 data
->NList_UseImages
[pos
].bmimg
= NULL
;
855 ULONG
NL_DeleteImages(struct NLData
*data
)
857 if (data
->NList_UseImages
)
861 while (pos
< data
->LastImage
)
863 if (data
->NList_UseImages
[pos
].bmimg
)
864 NL_DeleteImage(data
,(APTR
) data
->NList_UseImages
[pos
].bmimg
);
865 data
->NList_UseImages
[pos
].bmimg
= NULL
;
874 ULONG
NL_UseImage(struct NLData
*data
,Object
*imgobj
,LONG imgnum
,ULONG flags
)
879 if ((imgnum
>= 0) && (imgnum
< 8192))
883 if (!data
->NList_UseImages
|| (imgnum
>= data
->LastImage
))
885 LONG last
= imgnum
+ 8;
886 struct UseImage
*useimages
= (struct UseImage
*)AllocVecPooled(data
->Pool
, (last
+1)*sizeof(struct UseImage
));
892 while (pos
< data
->LastImage
)
893 { useimages
[pos
].bmimg
= data
->NList_UseImages
[pos
].bmimg
;
894 useimages
[pos
].imgobj
= data
->NList_UseImages
[pos
].imgobj
;
895 useimages
[pos
].flags
= data
->NList_UseImages
[pos
].flags
;
901 useimages
[pos
].bmimg
= 0;
902 useimages
[pos
].imgobj
= NULL
;
903 useimages
[pos
].flags
= 0;
906 if (data
->NList_UseImages
)
907 FreeVecPooled(data
->Pool
, data
->NList_UseImages
);
908 data
->NList_UseImages
= useimages
;
909 data
->LastImage
= last
;
911 else if (!data
->NList_UseImages
)
914 if (imgnum
< data
->LastImage
)
916 if (data
->NList_UseImages
[imgnum
].bmimg
)
918 NL_DeleteImage(data
,(APTR
) data
->NList_UseImages
[imgnum
].bmimg
);
922 data
->NList_UseImages
[imgnum
].bmimg
= NULL
;
923 data
->NList_UseImages
[imgnum
].imgobj
= imgobj
;
924 data
->NList_UseImages
[imgnum
].flags
= flags
;
927 data
->NList_UseImages
[imgnum
].bmimg
= (struct BitMapImage
*)
928 NL_CreateImage(data
,data
->NList_UseImages
[imgnum
].imgobj
,data
->NList_UseImages
[imgnum
].flags
);
934 else if (imgnum
< data
->LastImage
)
936 if (data
->NList_UseImages
[imgnum
].bmimg
)
938 NL_DeleteImage(data
,(APTR
) data
->NList_UseImages
[imgnum
].bmimg
);
941 data
->NList_UseImages
[imgnum
].bmimg
= NULL
;
942 data
->NList_UseImages
[imgnum
].imgobj
= NULL
;
943 data
->NList_UseImages
[imgnum
].flags
= 0;
947 else if (!imgobj
&& (imgnum
== MUIV_NList_UseImage_All
) && data
->NList_UseImages
)
951 while (pos
< data
->LastImage
)
953 if (data
->NList_UseImages
[pos
].bmimg
)
955 NL_DeleteImage(data
,(APTR
) data
->NList_UseImages
[pos
].bmimg
);
958 data
->NList_UseImages
[pos
].bmimg
= NULL
;
959 data
->NList_UseImages
[pos
].imgobj
= NULL
;
960 data
->NList_UseImages
[pos
].flags
= 0;
967 data
->do_draw_all
= data
->do_draw_title
= data
->do_draw
= TRUE
;
968 data
->do_parse
= data
->do_setcols
= data
->do_updatesb
= data
->do_wwrap
= TRUE
;
970 return ((ULONG
)retval
);
974 IPTR
mNL_CreateImage(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_CreateImage
*msg
)
976 struct NLData
*data
= INST_DATA(cl
,obj
);
977 /*DoSuperMethodA(cl,obj,(Msg) msg);*/
978 return (NL_CreateImage(data
,msg
->obj
,msg
->flags
));
982 IPTR
mNL_DeleteImage(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_DeleteImage
*msg
)
984 struct NLData
*data
= INST_DATA(cl
,obj
);
985 /*DoSuperMethodA(cl,obj,(Msg) msg);*/
986 return (NL_DeleteImage(data
,msg
->listimg
));
990 IPTR
mNL_UseImage(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_UseImage
*msg
)
992 struct NLData
*data
= INST_DATA(cl
,obj
);
993 /*DoSuperMethodA(cl,obj,(Msg) msg);*/
994 return (NL_UseImage(data
,msg
->obj
,msg
->imgnum
,msg
->flags
));