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 ***************************************************************************/
29 #if defined(__amigaos4__)
30 #include <hardware/blit.h>
33 #include <graphics/gfxmacros.h>
36 #include <intuition/imageclass.h>
37 #include <clib/alib_protos.h>
38 #include <proto/exec.h>
39 #include <proto/muimaster.h>
40 #include <proto/graphics.h>
41 #include <proto/intuition.h>
45 #include "NList_func.h"
47 void DrawBackground(Object
*obj
, LONG left
, LONG top
, LONG width
, LONG height
, LONG xoff
, LONG yoff
)
49 // MUI 3.9 of AmigaOS 4.1 update #3 and MUI4 treat the offsets as real offsets relative to the given
50 // coordinates and not as absolute corrdinates.
51 // Since all offsets are relative now these must be adapted for older versions of MUI.
52 #if !defined(__MORPHOS__) && !defined(__AROS__)
53 if(MUIMasterBase
->lib_Version
< 20 || (MUIMasterBase
->lib_Version
== 20 && MUIMasterBase
->lib_Revision
< 2326))
59 DoMethod(obj
, MUIM_DrawBackground
, left
, top
, width
, height
, xoff
, yoff
, 0);
62 WORD
DrawTitle(struct NLData
*data
,LONG minx
,LONG maxx
,WORD hfirst
)
64 Object
*obj
= data
->this;
68 clippinghandle
= MUI_AddClipping(muiRenderInfo(obj
),(WORD
) data
->mleft
,(WORD
) _mtop(obj
),
69 (WORD
) data
->mwidth
,(WORD
) data
->vinc
);
72 if (minx
< data
->vleft
)
74 if (maxx
> data
->vright
+ 1)
75 maxx
= data
->vright
+ 1;
77 if (minx
< data
->mleft
)
79 if (maxx
> data
->mleft
+ data
->mwidth
)
80 maxx
= data
->mleft
+ data
->mwidth
;
84 SetBackGround(data
->NList_TitleBackGround
)
85 DrawBackground(obj
, minx
, data
->vdtitlepos
, maxx
-minx
, data
->vdtitleheight
, hfirst
+ data
->vdx
, data
->vdy
);
86 if (data
->NList_TitleSeparator
)
88 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
89 Move(data
->rp
, minx
, data
->vpos
- 2);
90 Draw(data
->rp
, maxx
-1, data
->vpos
- 2);
91 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
92 Move(data
->rp
, minx
, data
->vpos
- 1);
93 Draw(data
->rp
, maxx
-1, data
->vpos
- 1);
95 linelen
= DrawText(data
,-1,data
->hpos
- hfirst
,data
->vdtitlepos
+ data
->voff
,minx
,maxx
,MUIPEN(data
->NList_TitlePen
),data
->hinc
,FALSE
);
96 data
->do_draw_title
= FALSE
;
98 MUI_RemoveClipping(muiRenderInfo(obj
),clippinghandle
);
104 void DrawOldLine(struct NLData
*data
,LONG ent
,LONG minx
,LONG maxx
,WORD hfirst
)
106 Object
*obj
= data
->this;
108 BOOL forcepen
= FALSE
;
110 LONG vert1
,vert2
,vertd
;
115 if (minx
< data
->vleft
)
117 if (maxx
> data
->vright
+ 1)
118 maxx
= data
->vright
+ 1;
120 if (minx
< data
->mleft
)
122 if (maxx
> data
->mleft
+ data
->mwidth
)
123 maxx
= data
->mleft
+ data
->mwidth
;
128 clippinghandle
= MUI_AddClipping(muiRenderInfo(obj
),(WORD
) data
->mleft
,(WORD
) data
->mtop
,
129 (WORD
) data
->mwidth
,(WORD
) data
->mheight
);
132 vert1
= data
->vpos
+(data
->vinc
* (ent
- data
->NList_AffFirst
));
133 vert2
= data
->vpos
+ (ent
*data
->vinc
);
135 if (data
->NList_First_Incr
)
136 { if (ent
== data
->NList_First
)
137 { vertd
-= data
->NList_First_Incr
;
138 vert2
+= data
->NList_First_Incr
;
141 else if (ent
== data
->NList_First
+ data
->NList_Visible
)
142 { vertd
= data
->NList_First_Incr
;
143 vert1
-= data
->NList_First_Incr
;
147 { vert1
-= data
->NList_First_Incr
;
150 if ((ent
< 0) || (ent
>= data
->NList_Entries
))
152 SetBackGround(data
->NList_ListBackGround
); mypen
= data
->NList_ListPen
;
153 DrawBackground(obj
, minx
, vert1
, maxx
-minx
, vertd
, hfirst
+data
->vdx
, vert2
-vert1
+data
->vdy
);
157 if (data
->EntriesArray
[ent
]->Select
== TE_Select_None
)
159 SetBackGround(data
->NList_ListBackGround
); mypen
= data
->NList_ListPen
; forcepen
= FALSE
;
163 if(data
->NList_ActiveObjectOnClick
== TRUE
&& (data
->isActiveObject
== FALSE
|| xget(_win(obj
), MUIA_Window_Activate
) == FALSE
))
165 SetBackGround(MUII_myListInactive
); mypen
= data
->NList_InactivePen
; forcepen
= data
->ForcePen
;
169 SetBackGround(MUII_myListSelect
); mypen
= data
->NList_SelectPen
; forcepen
= data
->ForcePen
;
173 DrawBackground(obj
, minx
, vert1
, maxx
-minx
, vertd
, hfirst
+data
->vdx
, vert2
-vert1
+data
->vdy
);
175 DrawText(data
,ent
,data
->hpos
-hfirst
,vert1
+data
->voff
,minx
,maxx
-1,MUIPEN(mypen
),data
->hinc
,forcepen
);
178 MUI_RemoveClipping(muiRenderInfo(obj
),clippinghandle
);
183 WORD
DrawLines(struct NLData
*data
,LONG e1
,LONG e2
,LONG minx
,LONG maxx
,WORD hfirst
,WORD hmax
,WORD small
,BOOL do_extrems
,WORD not_all
)
185 Object
*obj
= data
->this;
186 LONG ent
,ent2
,ent3
,ent4
,dent
,lim1
,lim2
,lim3
;
187 WORD cursel
,linelen
=0;
189 BOOL forcepen
= FALSE
;
190 LONG vert1
,vert2
,vertd
,vert3
;
191 WORD hfx
= data
->mleft
- hfirst
;
193 APTR clippinghandle
= NULL
;
197 //D(bug( "DRAWING LINES FROM %ld - %ld\n", e1, e2 ));
215 if (minx
< data
->vleft
)
217 if (maxx
> data
->vright
+ 1)
218 maxx
= data
->vright
+ 1;
221 { if ((e1
== data
->minx_change_entry
) && (minx
< hfx
+ data
->minx_change_offset
))
222 minx
= hfx
+ data
->minx_change_offset
;
223 if ((e1
== data
->maxx_change_entry
) && (maxx
> hfx
+ data
->maxx_change_offset
))
224 maxx
= hfx
+ data
->maxx_change_offset
;
226 if (minx
< data
->mleft
)
228 if (maxx
> data
->mleft
+ data
->mwidth
)
229 maxx
= data
->mleft
+ data
->mwidth
;
234 if (ent2
> data
->NList_Entries
)
235 ent2
= data
->NList_Entries
;
241 if (data
->NList_First_Incr
&&
242 ((e1
<= data
->NList_First
) || (e2
>= data
->NList_First
+ data
->NList_Visible
)))
244 clippinghandle
= MUI_AddClipping(muiRenderInfo(obj
),
248 (WORD
) (data
->NList_Visible
*data
->vinc
));
254 if ((ent
!= data
->NList_First
) && (ent
!= (data
->NList_First
+ data
->NList_Visible
- 1)) &&
255 (((not_all
== 1) && ((ent
- data
->NList_First
) & 1L)) ||
256 ((not_all
== 2) && !((ent
- data
->NList_First
) & 1L))))
260 if (!data
->NList_TypeSelect
|| ((ent
!= data
->sel_pt
[data
->min_sel
].ent
) && (ent
!= data
->sel_pt
[data
->max_sel
].ent
)))
262 if (data
->NList_TypeSelect
)
264 if ((ent
> data
->sel_pt
[data
->min_sel
].ent
) && (ent
< data
->sel_pt
[data
->max_sel
].ent
))
269 while ((ent3
< ent2
) && (ent3
< data
->sel_pt
[data
->max_sel
].ent
))
275 ent3
= ent
+ (dent
/ 2);
278 if(data
->NList_ActiveObjectOnClick
== TRUE
&& (data
->isActiveObject
== FALSE
|| xget(_win(obj
), MUIA_Window_Activate
) == FALSE
))
280 SetBackGround(MUII_myListInactive
); mypen
= data
->NList_InactivePen
; forcepen
= data
->ForcePen
;
284 SetBackGround(MUII_myListCursor
); mypen
= data
->NList_CursorPen
; forcepen
= data
->ForcePen
;
292 while ((ent3
< ent2
) && ((ent3
> data
->sel_pt
[data
->max_sel
].ent
) || (ent3
< data
->sel_pt
[data
->min_sel
].ent
)))
297 else if (dent
>= lim3
)
298 ent3
= ent
+ (dent
/ 2);
301 SetBackGround(data
->NList_ListBackGround
); mypen
= data
->NList_ListPen
;
306 if(ent
== data
->NList_Active
)
310 if(data
->NList_ActiveObjectOnClick
== TRUE
&& (data
->isActiveObject
== FALSE
|| xget(_win(obj
), MUIA_Window_Activate
) == FALSE
))
312 SetBackGround(MUII_myListInactive
); mypen
= data
->NList_InactivePen
; forcepen
= data
->ForcePen
;
314 else if(data
->EntriesArray
[ent
]->Select
== TE_Select_None
)
316 SetBackGround(MUII_myListUnselCur
); mypen
= data
->NList_UnselCurPen
; forcepen
= data
->ForcePen
;
320 SetBackGround(MUII_myListCursor
); mypen
= data
->NList_CursorPen
; forcepen
= data
->ForcePen
;
323 data
->do_draw_active
= FALSE
;
326 { cursel
= data
->EntriesArray
[ent
]->Select
;
329 { while ((ent3
< ent2
) && (data
->EntriesArray
[ent3
]->Select
== cursel
) && (ent3
!= data
->NList_Active
))
335 ent3
= ent
+ (dent
/ 2);
338 if(cursel
== TE_Select_None
)
340 SetBackGround(data
->NList_ListBackGround
); mypen
= data
->NList_ListPen
;
342 else if(data
->NList_ActiveObjectOnClick
== TRUE
&& (data
->isActiveObject
== FALSE
|| xget(_win(obj
), MUIA_Window_Activate
) == FALSE
))
344 SetBackGround(MUII_myListInactive
); mypen
= data
->NList_InactivePen
; forcepen
= data
->ForcePen
;
348 SetBackGround(MUII_myListSelect
); mypen
= data
->NList_SelectPen
; forcepen
= data
->ForcePen
;
353 vert3
= vert1
= data
->vpos
+(data
->vinc
* (ent
- data
->NList_First
));
354 vert2
= data
->vpos
+ (ent
*data
->vinc
);
355 vertd
= data
->vinc
* (ent3
- ent
);
356 if (data
->NList_First_Incr
)
357 { vert1
-= data
->NList_First_Incr
;
358 if (ent
== data
->NList_First
)
359 { vertd
-= data
->NList_First_Incr
;
360 vert2
+= data
->NList_First_Incr
;
362 else if (ent3
-1 >= data
->NList_First
+ data
->NList_Visible
)
363 { vertd
= vertd
- data
->vinc
+ data
->NList_First_Incr
;
364 vert3
-= data
->NList_First_Incr
;
367 { vert3
-= data
->NList_First_Incr
;
370 DrawBackground(obj
, minx
, vert3
, maxx
-minx
, vertd
, hfirst
+data
->vdx
, vert2
-vert3
+data
->vdy
);
374 if (!data
->NList_First_Incr
|| do_extrems
|| ((ent
> data
->NList_First
) && (ent
< data
->NList_First
+ data
->NList_Visible
)))
377 linelen
= DrawText(data
,ent
,data
->hpos
-hfirst
,vert1
+data
->voff
,minx
,maxx
-1,MUIPEN(mypen
),data
->hinc
,forcepen
);
391 if ((ent
== data
->minx_change_entry
) && (x1
< hfx
+ data
->minx_change_offset
))
392 x1
= hfx
+ data
->minx_change_offset
;
393 if ((ent
== data
->maxx_change_entry
) && (x4
> hfx
+ data
->maxx_change_offset
))
394 x4
= hfx
+ data
->maxx_change_offset
;
395 x2
= hfx
+ data
->sel_pt
[data
->min_sel
].xoffset
;
396 x3
= hfx
+ data
->sel_pt
[data
->max_sel
].xoffset
;
397 if (x2
< x1
) x2
= x1
;
398 if (x3
< x1
) x3
= x1
;
399 if (x2
> x4
) x2
= x4
;
400 if (x3
> x4
) x3
= x4
;
401 if (ent
!= data
->sel_pt
[data
->min_sel
].ent
)
403 if (ent
!= data
->sel_pt
[data
->max_sel
].ent
)
406 vert3
= vert1
= data
->vpos
+(data
->vinc
* (ent
- data
->NList_First
));
407 vert2
= data
->vpos
+ (ent
*data
->vinc
);
409 if (data
->NList_First_Incr
)
410 { vert1
-= data
->NList_First_Incr
;
411 if (ent
== data
->NList_First
)
412 { vertd
-= data
->NList_First_Incr
;
413 vert2
+= data
->NList_First_Incr
;
415 else if (ent
>= data
->NList_First
+ data
->NList_Visible
)
416 { vertd
= vertd
- data
->vinc
+ data
->NList_First_Incr
;
417 vert3
-= data
->NList_First_Incr
;
420 { vert3
-= data
->NList_First_Incr
;
426 SetBackGround(data
->NList_ListBackGround
);
427 DrawBackground(obj
, x1
, vert3
, x2
-x1
, vertd
, hfirst
+data
->vdx
, vert2
-vert3
+data
->vdy
);
431 if(data
->NList_ActiveObjectOnClick
== TRUE
&& (data
->isActiveObject
== FALSE
|| xget(_win(obj
), MUIA_Window_Activate
) == FALSE
))
433 SetBackGround(MUII_myListInactive
);
437 SetBackGround(MUII_myListCursor
);
440 DrawBackground(obj
, x2
, vert3
, x3
-x2
, vertd
, hfirst
+data
->vdx
, vert2
-vert3
+data
->vdy
);
444 SetBackGround(data
->NList_ListBackGround
);
445 DrawBackground(obj
, x3
, vert3
, x4
-x3
, vertd
, hfirst
+data
->vdx
, vert2
-vert3
-data
->vdy
);
448 // FIXME: This isn't perfect, but it is the fastest 'solution'
449 // to fixing the distorted text output when the text is
450 // italic and anti-aliased. Please note that 'spacesize' isn't entirely
451 // correct as we should moved back by what the char width really is
452 // at the 'x1-1' position. However, this seems to be problematic here
453 // as we don't really have access to this informaton here?!?!
454 if(data
->NList_TypeSelect
)
455 x1
-= data
->spacesize
;
457 x2
= hfx
+ data
->sel_pt
[data
->min_sel
].xoffset
;
458 x3
= hfx
+ data
->sel_pt
[data
->max_sel
].xoffset
;
459 if (x2
< x1
) x2
= x1
;
460 if (x3
< x1
) x3
= x1
;
461 if (x2
> x4
) x2
= x4
;
462 if (x3
> x4
) x3
= x4
;
463 if (ent
!= data
->sel_pt
[data
->min_sel
].ent
)
465 if (ent
!= data
->sel_pt
[data
->max_sel
].ent
)
468 if (!data
->NList_First_Incr
|| do_extrems
|| ((ent
> data
->NList_First
) && (ent
< data
->NList_First
+ data
->NList_Visible
)))
473 mypen
= data
->NList_ListPen
;
474 linelen
= DrawText(data
,ent
,data
->hpos
-hfirst
,vert1
+data
->voff
,x1
,x2
-1,MUIPEN(mypen
),0,FALSE
);
478 mypen
= data
->NList_CursorPen
;
479 linelen
= DrawText(data
,ent
,data
->hpos
-hfirst
,vert1
+data
->voff
,x2
,x3
-1,MUIPEN(mypen
),0,data
->ForcePen
);
483 mypen
= data
->NList_ListPen
;
484 linelen
= DrawText(data
,ent
,data
->hpos
-hfirst
,vert1
+data
->voff
,x3
,x4
-1,MUIPEN(mypen
),0,FALSE
);
495 SetBackGround(data
->NList_ListBackGround
);
496 vert3
= data
->vpos
+(data
->vinc
* (ent
- data
->NList_First
));
497 vert2
= data
->vpos
+ (ent
*data
->vinc
);
498 vertd
= data
->vinc
* (ent4
- ent
);
499 if (data
->NList_First_Incr
)
500 { if (ent
== data
->NList_First
)
501 { vertd
-= data
->NList_First_Incr
;
502 vert2
+= data
->NList_First_Incr
;
504 else if (ent4
-1 >= data
->NList_First
+ data
->NList_Visible
)
505 { vertd
= vertd
- data
->vinc
+ data
->NList_First_Incr
;
506 vert3
-= data
->NList_First_Incr
;
509 { vert3
-= data
->NList_First_Incr
;
512 DrawBackground(obj
, minx
, vert3
, maxx
-minx
, vertd
, hfirst
+data
->vdx
, vert2
-vert3
+data
->vdy
);
514 { struct colinfo
*cinfo
;
515 WORD column
,xbar
,maxx2
;
516 xbar
= data
->hpos
-hfirst
+ data
->cols
[0].c
->minx
- 8;
517 for (column
= 0;column
< data
->numcols
;column
++)
518 { cinfo
= data
->cols
[column
].c
;
519 if (cinfo
->maxx
>= 0)
520 maxx2
= data
->hpos
-hfirst
+ cinfo
->maxx
;
522 maxx2
= data
->mright
;
524 vert2
= vert3
+ vertd
- 1;
525 if ((column
< data
->numcols
-1) && (cinfo
->delta
> 0))
526 xbar
+= ((cinfo
->delta
-1) / 2);
527 if (IS_BAR(column
,cinfo
) &&
528 ((cinfo
->bar
& 1) || ((cinfo
->bar
& 2) && (ent
== -1))) && (cinfo
->delta
> 0))
529 { if ((xbar
+1 >= data
->mleft
) && (xbar
<= data
->mright
) &&
530 (xbar
+1 >= minx
-1) && (xbar
<= maxx
+1) &&
531 ((column
< data
->numcols
-1) ||
532 ((data
->NList_Horiz_Entries
<= data
->NList_Horiz_Visible
+ data
->NList_Horiz_First
) &&
533 (xbar
< data
->mright
- 1 - data
->NList_Horiz_First
))))
534 { if ((xbar
>= data
->mleft
) && (xbar
>= minx
-1))
535 { SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
536 Move(data
->rp
, xbar
, vert3
);
537 Draw(data
->rp
, xbar
, vert2
);
539 if (!(cinfo
->bar
& 4) && (xbar
+1 <= data
->mright
) && (xbar
+1 <= maxx
+1))
540 { SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
541 Move(data
->rp
, xbar
+1, vert3
);
542 Draw(data
->rp
, xbar
+1, vert2
);
551 MUI_RemoveClipping(muiRenderInfo(obj
),clippinghandle
);
560 #define MPEN_HALFSHINE 1
561 #define MPEN_BACKGROUND 2
562 #define MPEN_HALFSHADOW 3
565 void NL_DrawTitleMark(struct NLData
*data
, LONG xf
, WORD yf
)
567 APTR clippinghandle
= NULL
;
568 Object
*obj
= data
->this;
570 if (!data
->NList_PartialChar
)
572 clippinghandle
= MUI_AddClipping(muiRenderInfo(obj
),(WORD
) data
->vleft
,(WORD
) data
->vtop
,
573 (WORD
) data
->vwidth
,(WORD
) data
->vheight
);
576 switch (data
->NList_TitleMark
& MUIV_NList_TitleMark_TypeMask
)
578 case MUIV_NList_TitleMark_Down
:
579 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
580 Move(data
->rp
, xf
-1, yf
);
581 Draw(data
->rp
, xf
-6, yf
);
582 Draw(data
->rp
, xf
-6, yf
+2);
583 Draw(data
->rp
, xf
-4, yf
+4);
584 SetAPen(data
->rp
,data
->pens
[MPEN_HALFSHADOW
]);
585 Move(data
->rp
, xf
-5, yf
+1);
586 Draw(data
->rp
, xf
-1, yf
+1);
587 Move(data
->rp
, xf
-5, yf
+2);
588 Draw(data
->rp
, xf
-1, yf
+2);
589 Move(data
->rp
, xf
-4, yf
+3);
590 Draw(data
->rp
, xf
-2, yf
+3);
591 Draw(data
->rp
, xf
-3, yf
+4);
592 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
593 Move(data
->rp
, xf
-3, yf
+5);
594 Draw(data
->rp
, xf
, yf
+2);
595 Draw(data
->rp
, xf
, yf
);
597 case MUIV_NList_TitleMark_Up
:
598 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
599 Move(data
->rp
, xf
-3, yf
);
600 Draw(data
->rp
, xf
-6, yf
+3);
601 Draw(data
->rp
, xf
-6, yf
+5);
602 SetAPen(data
->rp
,data
->pens
[MPEN_HALFSHADOW
]);
603 Move(data
->rp
, xf
-3, yf
+1);
604 Draw(data
->rp
, xf
-4, yf
+2);
605 Draw(data
->rp
, xf
-2, yf
+2);
606 Move(data
->rp
, xf
-5, yf
+3);
607 Draw(data
->rp
, xf
-1, yf
+3);
608 Move(data
->rp
, xf
-5, yf
+4);
609 Draw(data
->rp
, xf
-1, yf
+4);
610 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
611 Move(data
->rp
, xf
-5, yf
+5);
612 Draw(data
->rp
, xf
, yf
+5);
613 Draw(data
->rp
, xf
, yf
+3);
614 Draw(data
->rp
, xf
-2, yf
+1);
616 case MUIV_NList_TitleMark_Box
:
617 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
618 Move(data
->rp
, xf
-2, yf
);
619 Draw(data
->rp
, xf
-5, yf
);
620 Draw(data
->rp
, xf
-5, yf
+4);
621 SetAPen(data
->rp
,data
->pens
[MPEN_HALFSHADOW
]);
622 Move(data
->rp
, xf
-4, yf
+1);
623 Draw(data
->rp
, xf
-2, yf
+1);
624 Move(data
->rp
, xf
-4, yf
+2);
625 Draw(data
->rp
, xf
-2, yf
+2);
626 Move(data
->rp
, xf
-4, yf
+3);
627 Draw(data
->rp
, xf
-2, yf
+3);
628 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
629 Move(data
->rp
, xf
-4, yf
+4);
630 Draw(data
->rp
, xf
-1, yf
+4);
631 Draw(data
->rp
, xf
-1, yf
);
633 case MUIV_NList_TitleMark_Circle
:
634 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
635 Move(data
->rp
, xf
-2, yf
);
636 Draw(data
->rp
, xf
-4, yf
);
637 Draw(data
->rp
, xf
-5, yf
+1);
638 Draw(data
->rp
, xf
-5, yf
+3);
639 SetAPen(data
->rp
,data
->pens
[MPEN_HALFSHADOW
]);
640 Move(data
->rp
, xf
-4, yf
+1);
641 Draw(data
->rp
, xf
-2, yf
+1);
642 Move(data
->rp
, xf
-4, yf
+2);
643 Draw(data
->rp
, xf
-2, yf
+2);
644 Move(data
->rp
, xf
-4, yf
+3);
645 Draw(data
->rp
, xf
-2, yf
+3);
646 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
647 Move(data
->rp
, xf
-4, yf
+4);
648 Draw(data
->rp
, xf
-2, yf
+4);
649 Draw(data
->rp
, xf
-1, yf
+3);
650 Draw(data
->rp
, xf
-1, yf
+1);
654 if (!data
->NList_PartialChar
)
656 MUI_RemoveClipping(muiRenderInfo(obj
),clippinghandle
);
661 void NL_DrawTitleMark2(struct NLData
*data
, LONG xf
, WORD yf
)
663 Object
*obj
= data
->this;
664 APTR clippinghandle
= NULL
;
666 if (!data
->NList_PartialChar
)
668 clippinghandle
= MUI_AddClipping(muiRenderInfo(obj
),(WORD
) data
->vleft
,(WORD
) data
->vtop
,
669 (WORD
) data
->vwidth
,(WORD
) data
->vheight
);
672 switch (data
->NList_TitleMark2
& MUIV_NList_TitleMark2_TypeMask
)
674 case MUIV_NList_TitleMark2_Down
:
675 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
676 Move(data
->rp
, xf
-1, yf
);
677 Draw(data
->rp
, xf
-5, yf
);
678 Move(data
->rp
, xf
-5, yf
+1);
679 Draw(data
->rp
, xf
-3, yf
+3);
680 SetAPen(data
->rp
,data
->pens
[MPEN_HALFSHADOW
]);
681 Move(data
->rp
, xf
-4, yf
+1);
682 Draw(data
->rp
, xf
-1, yf
+1);
683 Move(data
->rp
, xf
-3, yf
+2);
684 Draw(data
->rp
, xf
-2, yf
+2);
685 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
686 Move(data
->rp
, xf
-2, yf
+3);
687 Draw(data
->rp
, xf
, yf
+1);
688 Draw(data
->rp
, xf
, yf
);
690 case MUIV_NList_TitleMark2_Up
:
691 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
692 Move(data
->rp
, xf
-3, yf
);
693 Draw(data
->rp
, xf
-5, yf
+2);
694 Draw(data
->rp
, xf
-5, yf
+3);
695 SetAPen(data
->rp
,data
->pens
[MPEN_HALFSHADOW
]);
696 Move(data
->rp
, xf
-3, yf
+1);
697 Draw(data
->rp
, xf
-2, yf
+1);
698 Move(data
->rp
, xf
-4, yf
+2);
699 Draw(data
->rp
, xf
-1, yf
+2);
700 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
701 Move(data
->rp
, xf
-4, yf
+3);
702 Draw(data
->rp
, xf
, yf
+3);
703 Draw(data
->rp
, xf
, yf
+2);
704 Draw(data
->rp
, xf
-2, yf
);
706 case MUIV_NList_TitleMark2_Box
:
707 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
708 Move(data
->rp
, xf
-2, yf
);
709 Draw(data
->rp
, xf
-4, yf
);
710 Draw(data
->rp
, xf
-4, yf
+3);
711 SetAPen(data
->rp
,data
->pens
[MPEN_HALFSHADOW
]);
712 Move(data
->rp
, xf
-3, yf
+1);
713 Draw(data
->rp
, xf
-2, yf
+1);
714 Move(data
->rp
, xf
-3, yf
+2);
715 Draw(data
->rp
, xf
-2, yf
+2);
716 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
717 Move(data
->rp
, xf
-3, yf
+3);
718 Draw(data
->rp
, xf
-1, yf
+3);
719 Draw(data
->rp
, xf
-1, yf
);
721 case MUIV_NList_TitleMark2_Circle
:
722 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
723 Move(data
->rp
, xf
-2, yf
);
724 Draw(data
->rp
, xf
-3, yf
);
725 Draw(data
->rp
, xf
-4, yf
+1);
726 Draw(data
->rp
, xf
-4, yf
+2);
727 SetAPen(data
->rp
,data
->pens
[MPEN_HALFSHADOW
]);
728 Move(data
->rp
, xf
-3, yf
+1);
729 Draw(data
->rp
, xf
-2, yf
+1);
730 Move(data
->rp
, xf
-3, yf
+2);
731 Draw(data
->rp
, xf
-2, yf
+2);
732 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
733 Move(data
->rp
, xf
-3, yf
+3);
734 Draw(data
->rp
, xf
-2, yf
+3);
735 Draw(data
->rp
, xf
-1, yf
+2);
736 Draw(data
->rp
, xf
-1, yf
+1);
740 if (!data
->NList_PartialChar
)
742 MUI_RemoveClipping(muiRenderInfo(obj
),clippinghandle
);
747 LONG
DrawText(struct NLData
*data
,LONG ent
,LONG x
,LONG y
,LONG minx
,LONG maxx
,ULONG mypen
,LONG dxpermit
,BOOL forcepen
)
749 Object
*obj
= data
->this;
750 struct colinfo
*cinfo
;
751 struct affinfo
*afinfo
;
752 LONG linelen
, next_x
=0, x2
, x2s
, x2e
, minx2
, maxx2
, minx3
, maxx3
, cmaxx
;
753 WORD xbar
,xbar2
,ybar
,ybar2
;
755 struct TextExtent te
;
756 WORD column
, curclen
, dcurclen
, ni
;
758 if ((ent
< -1) || (ent
>= data
->NList_Entries
))
761 if (((y
- data
->voff
+ data
->vinc
) < data
->vtop
) || ((y
- data
->voff
) > data
->vbottom
))
765 linelen
= (LONG
) data
->EntriesArray
[ent
]->PixLen
;
770 SetABPenDrMd(data
->rp
,mypen
,data
->pens
[MPEN_BACKGROUND
],JAM1
);
772 NL_GetDisplayArray(data
,ent
);
774 xbar
= x
+ data
->cols
[0].c
->minx
- 8;
777 for (column
= 0;column
< data
->numcols
;column
++)
779 cinfo
= data
->cols
[column
].c
;
781 x2
= x
+ cinfo
->minx
;
782 minx2
= x
+ cinfo
->minx
;
783 if (cinfo
->maxx
>= 0)
785 maxx2
= x
+ cinfo
->maxx
;
790 maxx2
= data
->mright
;
796 ybar
= y
- data
->voff
;
797 ybar2
= ybar
+data
->vinc
-1;
799 ybar2
= ybar
+data
->vdtitleheight
-1;
800 if ((column
< data
->numcols
-1) && (cinfo
->delta
> 0))
801 xbar
+= ((cinfo
->delta
-1) / 2);
802 if (IS_BAR(column
,cinfo
) &&
803 ((cinfo
->bar
& 1) || ((cinfo
->bar
& 2) && (ent
== -1))) && (cinfo
->delta
> 0))
805 if ((xbar
+1 >= data
->mleft
) && (xbar
<= data
->mright
) &&
806 (xbar
+1 >= minx
-1) && (xbar
<= maxx
+1) &&
807 ((column
< data
->numcols
-1) ||
808 ((data
->NList_Horiz_Entries
<= data
->NList_Horiz_Visible
+ data
->NList_Horiz_First
) &&
809 (xbar
< data
->mright
- 1 - data
->NList_Horiz_First
))))
811 if ((xbar
>= data
->mleft
) && (xbar
>= minx
-1))
813 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
814 Move(data
->rp
, xbar
, ybar
);
815 Draw(data
->rp
, xbar
, ybar2
);
817 if (!(cinfo
->bar
& 4) && (xbar
+1 <= data
->mright
) && (xbar
+1 <= maxx
+1))
819 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
820 Move(data
->rp
, xbar
+1, ybar
);
821 Draw(data
->rp
, xbar
+1, ybar2
);
826 if ((ent == -1) && IS_BAR(column,cinfo) &&
827 ((data->NList_TitleMark & MUIV_NList_TitleMark_ColMask) == cinfo->col))
829 NL_DrawTitleMark(data,xbar-1,ybar);
831 else if ((ent == -1) && IS_BAR(column,cinfo) &&
832 ((data->NList_TitleMark2 & MUIV_NList_TitleMark2_ColMask) == cinfo->col))
834 NL_DrawTitleMark2(data,xbar-1,ybar);
837 if (minx2
< data
->mleft
- data
->NList_PartialChar
)
838 minx2
= data
->mleft
- data
->NList_PartialChar
;
839 if (maxx2
> data
->mright
+ data
->NList_PartialChar
)
840 maxx2
= data
->mright
+ data
->NList_PartialChar
;
842 if (column
+1 < data
->numcols
)
857 minx3
-= (data
->hinc
+ 2);
858 maxx3
+= (data
->hinc
+ 2);
860 if (DontDoColumn(data
,ent
,column
))
863 ParseColumn(data
,column
,mypen
);
864 WidthColumn(data
,column
,0);
866 if (IS_HLINE(cinfo
->style
))
868 WORD xb1
,xb2
,yb1
,yb2
,thick
,nothick
,xbe1
=0,xbe2
=0;
872 if (IS_HLINE_thick(cinfo
->style
) && (IS_HLINE_C(cinfo
->style
) || IS_HLINE_E(cinfo
->style
)))
874 if (IS_HLINE_C(cinfo
->style
))
875 yb1
+= (data
->vinc
-1)/2;
876 else if (IS_HLINE_E(cinfo
->style
))
878 yb1
+= (data
->vinc
-1)/2;
879 xbe1
= x2
+ cinfo
->xoffset
- 3;
880 xbe2
= xbe1
+ cinfo
->colwidth
+ 4;
882 else if (IS_HLINE_B(cinfo
->style
))
890 else if (IS_HLINE_nothick(cinfo
->style
))
893 if (IS_HLINE_B(cinfo
->style
))
902 if (xb1
< data
->mleft
)
904 if (xb2
> data
->mright
)
908 if (IS_HLINE_E(cinfo
->style
))
918 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
919 Move(data
->rp
, xb1
, yb1
);
920 Draw(data
->rp
, xbe1
, yb1
);
921 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
922 Move(data
->rp
, xb1
, yb2
);
923 Draw(data
->rp
, xbe1
, yb2
);
926 SetAPen(data
->rp
,data
->HLINE_thick_pen
);
927 RectFill(data
->rp
, xb1
, yb1
+1, xbe1
, yb1
+2);
932 SetAPen(data
->rp
,data
->HLINE_thick_pen
);
933 Move(data
->rp
, xb1
, yb1
);
934 Draw(data
->rp
, xbe1
, yb1
);
940 { SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
941 Move(data
->rp
, xbe2
, yb1
);
942 Draw(data
->rp
, xb2
, yb1
);
943 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
944 Move(data
->rp
, xbe2
, yb2
);
945 Draw(data
->rp
, xb2
, yb2
);
948 SetAPen(data
->rp
,data
->HLINE_thick_pen
);
949 RectFill(data
->rp
, xbe2
, yb1
+1, xb2
, yb1
+2);
954 SetAPen(data
->rp
,data
->HLINE_thick_pen
);
955 Move(data
->rp
, xbe2
, yb1
);
956 Draw(data
->rp
, xb2
, yb1
);
964 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
965 Move(data
->rp
, xb1
, yb1
);
966 Draw(data
->rp
, xb2
, yb1
);
967 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
968 Move(data
->rp
, xb1
, yb2
);
969 Draw(data
->rp
, xb2
, yb2
);
972 SetAPen(data
->rp
,data
->HLINE_thick_pen
);
973 RectFill(data
->rp
, xb1
, yb1
+1, xb2
, yb1
+2);
978 SetAPen(data
->rp
,data
->HLINE_thick_pen
);
979 Move(data
->rp
, xb1
, yb1
);
980 Draw(data
->rp
, xb2
, yb1
);
986 /* WidthColumn(data,column,0);*/
988 x2
+= cinfo
->xoffset
;
990 if (column
+1 == data
->numcols
)
992 if (cinfo
->userwidth
> 0)
993 linelen
= cinfo
->userwidth
+ cinfo
->minx
- 1;
996 linelen
= cinfo
->colwidth
+ cinfo
->minx
+ cinfo
->xoffset
;
997 if (IS_ALIGN_CENTER(cinfo
->style
) && (cinfo
->dx
> cinfo
->colwidth
))
998 linelen
= cinfo
->minx
+ cinfo
->dx
- 1;
1000 if (data
->EntriesArray
&& (ent
>= 0))
1001 data
->EntriesArray
[ent
]->PixLen
= linelen
;
1004 if ((x2
>= maxx2
) || ((x2
+ cinfo
->colwidth
) <= minx2
))
1013 D(bug( "BEFORE ==============================>\n" ));
1015 for( yx = 0; yx <= cinfo->ninfo; yx++ )
1017 afinfo = &data->aff_infos[yx];
1019 D(bug( "Drawing line len: %ld - '", afinfo->len ));
1021 for( xy = 0; xy < afinfo->len; xy++ )
1022 D(bug( "%1.1s", &afinfo->strptr[xy] ));
1027 D(bug( "<====================================\n" ));
1032 afinfo
= &data
->aff_infos
[ni
];
1034 while ((ni
<= cinfo
->ninfo
) && (afinfo
->len
> 0) && (x2
< maxx2
))
1036 if (afinfo
->style
== STYLE_TAB
)
1037 next_x
= ((((x2
-x2s
) / data
->tabsize
) + 1) * data
->tabsize
) + x2s
;
1038 else if ((afinfo
->style
== STYLE_FIXSPACE
) || (afinfo
->style
== STYLE_SPACE
))
1039 next_x
= x2
+ afinfo
->len
+ afinfo
->addinfo
+ afinfo
->addchar
;
1040 else if (afinfo
->style
== STYLE_IMAGE
)
1042 LONG dx
,dx3
,x3
,dy
,dy2
;
1043 struct NImgList
*nimg
= (struct NImgList
*) afinfo
->strptr
;
1046 dx
= afinfo
->pen
& 0x0000FFFF;
1048 dy2
= (afinfo
->pen
>> 16) & 0x0000FFFF;
1049 next_x
= x2
+ afinfo
->len
+ afinfo
->addinfo
+ 1;
1052 if ((x3
+ dx3
) > maxx2
)
1056 dx3
-= (minx2
- x3
);
1060 if (nimg
&& nimg
->NImgObj
&& (dx3
> 0) && (x2
<= maxx
) && (next_x
> minx
))
1062 struct IClass
*realclass
= OCLASS(obj
);
1064 APTR clippinghandle
= NULL
;
1065 WORD left
,top
,width
,height
,ol
,ot
;
1066 BOOL doclip
= FALSE
;
1068 * if (muiRenderInfo(obj) != muiRenderInfo(nimg->NImgObj))
1070 * D(bug("%lx|MRI=%lx img %lx|MRI=%lx\n",obj,muiRenderInfo(obj),nimg->NImgObj,muiRenderInfo(nimg->NImgObj)));
1071 * D(bug("%lx|MAD=%lx img %lx|MAD=%lx\n",obj,muiAreaData(obj),nimg->NImgObj,muiAreaData(nimg->NImgObj)));
1074 if (data
->vinc
> dy2
)
1075 dy
= (data
->vinc
- dy2
+ 1)/2;
1076 left
= _left(nimg
->NImgObj
);
1077 top
= _top(nimg
->NImgObj
);
1078 width
= _width(nimg
->NImgObj
);
1079 height
= _height(nimg
->NImgObj
);
1080 ol
= _left(nimg
->NImgObj
) = (WORD
) x2
;
1081 ot
= _top(nimg
->NImgObj
) = (WORD
) (y
-data
->voff
+dy
);
1083 _width(nimg
->NImgObj
) = dx
;
1085 _width(nimg
->NImgObj
) = 1;
1087 _height(nimg
->NImgObj
) = dy2
;
1089 _height(nimg
->NImgObj
) = data
->vinc
;
1090 if ((dy2
> data
->vinc
) || (dx3
< dx
) || (_width(nimg
->NImgObj
) != nimg
->width
) || (_height(nimg
->NImgObj
) != nimg
->height
))
1092 if (dy2
> data
->vinc
)
1095 _height(nimg
->NImgObj
) = data
->vinc
;
1096 ot
= _top(nimg
->NImgObj
) = (WORD
) (y
-data
->voff
+dy
);
1099 clippinghandle
= MUI_AddClipping(muiRenderInfo(obj
),(WORD
) x3
,(WORD
) (y
-data
->voff
+dy
),
1100 (WORD
) dx3
,(WORD
) data
->vinc
);
1102 data
->drawsuper
= nimg
->NImgObj
;
1103 mad_Flags
= muiAreaData(obj
)->mad_Flags
;
1104 OCLASS(obj
) = data
->ncl
;
1107 LONG vinc
= (LONG
) data
->vinc
;
1111 SetAttrs(nimg
->NImgObj
, MUIA_NLIMG_EntryCurrent
, ent
,
1112 MUIA_NLIMG_EntryHeight
, vinc
,
1113 afinfo
->tag
, afinfo
->tagval
, TAG_DONE
);
1117 SetAttrs(nimg
->NImgObj
, MUIA_NLIMG_EntryCurrent
, ent
,
1118 MUIA_NLIMG_EntryHeight
, vinc
, TAG_DONE
);
1122 * SetAttrs(nimg->NImgObj, MUIA_Image_State,IDS_SELECTED,
1123 * MUIA_Selected, TRUE, TAG_DONE);
1124 * SetAttrs(nimg->NImgObj, MUIA_Image_State,IDS_NORMAL,
1125 * MUIA_Selected, FALSE, TAG_DONE);
1127 _left(nimg
->NImgObj
) += nimg
->dx
;
1128 _top(nimg
->NImgObj
) += nimg
->dy
;
1129 if ((data
->affbutton
>= 0) && (data
->affbutton
== (LONG
)afinfo
->button
))
1131 if ((data
->affbuttonstate
== 2) || (data
->affbuttonstate
== -2))
1133 muiAreaData(nimg
->NImgObj
)->mad_Flags
&= ~MADF_VISIBLE
;
1134 SetAttrs(nimg
->NImgObj
, MUIA_Image_State
,IDS_SELECTED
,
1135 MUIA_Selected
, TRUE
, TAG_DONE
);
1137 data
->affbuttonpos
.Left
= (WORD
) x3
;
1138 data
->affbuttonpos
.Top
= _top(nimg
->NImgObj
);
1139 data
->affbuttonpos
.Width
= (WORD
) dx3
;
1140 data
->affbuttonpos
.Height
= _height(nimg
->NImgObj
);
1142 muiAreaData(nimg
->NImgObj
)->mad_Flags
|= MADF_VISIBLE
;
1144 if(xget(nimg
->NImgObj
, MUIA_Disabled
))
1145 set(nimg
->NImgObj
, MUIA_Disabled
, FALSE
);
1147 MUI_Redraw(nimg
->NImgObj
,MADF_DRAWALL
);
1149 if ((data
->affbuttonstate
== 2) || (data
->affbuttonstate
== -2))
1151 muiAreaData(nimg
->NImgObj
)->mad_Flags
&= ~MADF_VISIBLE
;
1152 SetAttrs(nimg
->NImgObj
, MUIA_Image_State
,IDS_NORMAL
,
1153 MUIA_Selected
, FALSE
, TAG_DONE
);
1158 muiAreaData(nimg
->NImgObj
)->mad_Flags
|= MADF_VISIBLE
;
1160 if(xget(nimg
->NImgObj
, MUIA_Disabled
))
1161 set(nimg
->NImgObj
, MUIA_Disabled
, FALSE
);
1163 MUI_Redraw(nimg
->NImgObj
,MADF_DRAWALL
);
1165 nimg
->dx
= _left(nimg
->NImgObj
) - ol
;
1166 nimg
->dy
= _top(nimg
->NImgObj
) - ot
;
1168 muiAreaData(obj
)->mad_Flags
= mad_Flags
;
1169 OCLASS(obj
) = realclass
;
1170 data
->drawsuper
= NULL
;
1174 MUI_RemoveClipping(muiRenderInfo(obj
),clippinghandle
);
1175 _width(nimg
->NImgObj
) = width
;
1176 _height(nimg
->NImgObj
) = height
;
1178 _left(nimg
->NImgObj
) = left
;
1179 _top(nimg
->NImgObj
) = top
;
1181 SetABPenDrMd(data
->rp
,afinfo
->pen
,data
->pens
[MPEN_BACKGROUND
],JAM1
);
1184 else if (afinfo
->style
== STYLE_IMAGE2
)
1189 dx
= afinfo
->pen
& 0x0000FFFF;
1192 dy2
= (afinfo
->pen
>> 16) & 0x0000FFFF;
1193 next_x
= x2
+ afinfo
->len
+ afinfo
->addinfo
+ 1;
1194 if ((x2
+ dx
) > maxx2
)
1202 if ((dx
> 0) && (x2
<= maxx
) && (next_x
> minx
) && afinfo
->strptr
)
1204 struct BitMapImage
*bmimg
= (struct BitMapImage
*) afinfo
->strptr
;
1206 if (data
->vinc
> dy2
)
1207 dy
= (data
->vinc
- dy2
+ 1)/2;
1208 BltMaskBitMapRastPort(&(bmimg
->imgbmp
), (WORD
) dx2
, (WORD
) 0,
1209 data
->rp
, (WORD
) x2
, (WORD
) (y
-data
->voff
+dy
),
1210 (WORD
) dx
, (WORD
) dy2
, (UBYTE
) (ABC
|ABNC
|ANBC
),bmimg
->mask
);
1212 SetABPenDrMd(data
->rp
,afinfo
->pen
,data
->pens
[MPEN_BACKGROUND
],JAM1
);
1213 SetDrPt(data
->rp
,(UWORD
)~0);
1217 // we are having normal text in afinfo->strptr now, so lets
1218 // go and figure out if all of it fits in the current column or
1219 // if we have to strip it.
1221 // set foreground pen
1223 SetAPen(data
->rp
,mypen
);
1225 SetAPen(data
->rp
,afinfo
->pen
);
1227 // set any softstyle in case the user text contains it
1228 SetSoftStyle(data
->rp
, GET_STYLE(afinfo
->style
), STYLE_MASK
);
1230 if (afinfo
->addchar
> 0)
1231 data
->rp
->TxSpacing
= afinfo
->addchar
;
1233 // figure out the pixel constraints the current text would require
1234 curclen
= afinfo
->len
;
1235 ptr1
= afinfo
->strptr
;
1236 TextExtent(data
->rp
, ptr1
, curclen
, &te
);
1237 if ((ni
== 0) && (te
.te_Extent
.MinX
< 0))
1238 x2
-= te
.te_Extent
.MinX
;
1240 // save the coordinate of the next column start
1241 next_x
= x2
+ te
.te_Width
+ afinfo
->addinfo
;
1242 D(DBF_DRAW
, "next_x: %ld cmaxx: %ld");
1244 // save the coordinate where the current column ends in x2e
1245 x2e
= x2
+ te
.te_Width
;
1248 // from now on we try to figure out from where to where we are going
1249 // to strip the text in case it doesn't completely fit into the
1252 // continue only if the start of the column (x2) does not exceed
1253 // the maximum field of view in x direction
1254 if((x2
< maxx2
) && (x2
+ te
.te_Extent
.MaxX
> minx2
))
1258 D(DBF_DRAW
, "curclen: %ld ptr1: '%4.4s'", curclen
, ptr1
);
1259 D(DBF_DRAW
, "x2: %ld x2e: %ld maxx: %ld maxx2: %ld maxx3: %ld minx: %ld minx2: %ld minx3: %ld", x2
, x2e
, maxx
, maxx2
, maxx3
, minx
, minx2
, minx3
);
1261 // check if the coordinate of the END of the string (x2e) does
1262 // not fit into the available regions (maximum x = maxx3). And
1263 // if so we go and calculate a new curclen
1264 if((curclen
> 0) && (x2e
> maxx3
))
1266 curclen
= TextFit(data
->rp
, ptr1
, curclen
, &te
, NULL
, 1, maxx3
- x2
, 32767);
1269 // find out the new end position of the string (x2e)
1270 TextExtent(data
->rp
, ptr1
, curclen
, &te
);
1271 x2e
= x2
+ te
.te_Width
;
1273 D(DBF_DRAW
, "RIGHT: x2: %ld x2e: %ld", x2
, x2e
);
1277 // check if the coordinate of the START of the string (x2) does
1278 // not fit into the available minimal x position (minx3). And if so,
1279 // we go and calculate a new curclen
1280 if((curclen
> 0) && (x2
< minx3
))
1282 dcurclen
= TextFit(data
->rp
, ptr1
, curclen
, &te
, NULL
, 1, minx3
- x2
, 32767);
1283 curclen
-= dcurclen
;
1287 // move the start of the string by the number of characters
1288 // we had to reduce the amount of characters displayed
1291 x2diff
+= te
.te_Width
;
1293 // find out the new end position of the string (x2e)
1294 TextExtent(data
->rp
, ptr1
, curclen
, &te
);
1295 x2e
= x2
+ te
.te_Width
;
1297 D(DBF_DRAW
, "LEFT: x2: %ld x2e: %ld", x2
, x2e
);
1303 TextExtent(data
->rp
, &ptr1
[curclen
-1], 1, &te
);
1306 /* throw away chars on the right that souldn't be draw because out of list */
1307 while ((curclen
> 0) && ((x2e
+ te
.te_Extent
.MaxX
) > maxx2
))
1312 TextExtent(data
->rp
, &ptr1
[curclen
-1], 1, &te
);
1317 /* throw away chars on the right that i don't want to draw because out of maxx */
1320 while ((curclen
> 0) && ((x2e
+ te
.te_Extent
.MinX
) > maxx
))
1325 TextExtent(data
->rp
, &ptr1
[curclen
-1], 1, &te
);
1332 while ((curclen
> 0) && (x2e
> maxx
))
1337 TextExtent(data
->rp
, &ptr1
[curclen
-1], 1, &te
);
1346 TextExtent(data
->rp
, ptr1
, 1, &te
);
1348 /* throw away chars on the left that souldn't be draw because out of list */
1349 while ((curclen
> 0) && ((x2
+ te
.te_Extent
.MinX
) < minx2
))
1352 x2diff
+= te
.te_Width
;
1355 TextExtent(data
->rp
, ptr1
, 1, &te
);
1358 /* throw away chars on the left that i don't want to draw because out of minx */
1361 while ((curclen
> 0) && ((x2
+ te
.te_Extent
.MaxX
) < minx
))
1364 x2diff
+= te
.te_Width
;
1367 TextExtent(data
->rp
, ptr1
, 1, &te
);
1372 while ((curclen
> 0) && ((x2
+te
.te_Width
) <= minx
))
1375 x2diff
+= te
.te_Width
;
1378 TextExtent(data
->rp
, ptr1
, 1, &te
);
1383 D(DBF_DRAW
, "x2: %ld x2e: %ld cmaxx: %ld next_x: %ld cinfo->minx: %ld cinfo->maxx: %ld ", x2
, x2e
, cmaxx
, next_x
, cinfo
->minx
, cinfo
->maxx
);
1387 Move(data
->rp
, x2
, y
);
1389 // before we draw the text we check if it was clipped and if so
1390 // we add "..." at the right position in case the PartialCol
1391 // feature is turned on at all
1392 if(data
->NList_PartialCol
&& cinfo
->partcolsubst
!= PCS_DISABLED
&&
1393 next_x
> cmaxx
&& (xbar
-1 >= data
->mleft
) && (xbar
-1 <= data
->mright
))
1396 int clen
; // number of pixels the current text has for positioning it
1398 // first we get the extent of the "..." text we are going to add
1399 TextExtent(data
->rp
, "...", 3, &te
);
1401 // if this is only a refresh of one/two chars because the user
1402 // is resizing the column we need to use a different clen
1403 clen
= cmaxx
- (x2
- x2diff
);
1405 // only continue of the column fits the minimum of the three dots
1407 if(clen
>= te
.te_Width
)
1412 D(DBF_DRAW
, "c1: %ld, c2: %ld x2: %ld x2e: %ld cmaxx: %ld minx3: %ld x2diff: %ld | %ld'%s'", cinfo
->maxx
-cinfo
->minx
, cmaxx
-(x2
-x2diff
), x2
, x2e
, cmaxx
, minx3
, x2diff
, next_x
, afinfo
->strptr
);
1414 D(DBF_DRAW
, "clen: %ld afinfo->len: %ld str: %08lx ('%s')", clen
, afinfo
->len
, afinfo
->strptr
, afinfo
->strptr
);
1416 // now that we add "..." at the right, left or center of the string we have to calculate the
1417 // TextExtent() in a kind of iterative process so that we identify at which point we need to
1418 // add our substitution "..." text.
1419 txtlen
= strlen(afinfo
->strptr
);
1420 if((txt
= AllocVecPooled(data
->Pool
, txtlen
+3+1)) != NULL
)
1422 if(cinfo
->partcolsubst
== PCS_LEFT
)
1424 snprintf(txt
, txtlen
+3+1, "...%s", afinfo
->strptr
);
1427 else if(cinfo
->partcolsubst
== PCS_RIGHT
)
1429 strlcpy(txt
, afinfo
->strptr
, txtlen
+1);
1430 strlcat(txt
, "...", txtlen
+3+1);
1433 else if(cinfo
->partcolsubst
== PCS_CENTER
)
1435 strlcpy(txt
, afinfo
->strptr
, txtlen
/2);
1436 strlcat(txt
, "...", txtlen
/2+3);
1437 strlcat(txt
, &afinfo
->strptr
[txtlen
/2], txtlen
+3+1);
1438 cstart
= txtlen
/2-1;
1442 // make sure we have a NUL terminated string in any case
1447 // get the new string length
1448 txtlen
= strlen(txt
);
1452 TextExtent(data
->rp
, txt
, txtlen
, &te
);
1454 D(DBF_DRAW
, "te: %ld %ld: '%s'", te
.te_Width
, clen
, txt
);
1455 if(te
.te_Width
<= clen
)
1458 if(cinfo
->partcolsubst
== PCS_LEFT
)
1460 // move the text after the first "..." one to the left
1461 // thus, actually moving the text start
1462 memmove(&txt
[3], &txt
[4], txtlen
+1);
1464 else if(cinfo
->partcolsubst
== PCS_RIGHT
)
1466 // move the "..." text one char to the left
1467 txt
[txtlen
-1] = '\0';
1468 // make sure we don't cause a buffer underrun
1470 txt
[txtlen
-4] = '.';
1472 else if(cinfo
->partcolsubst
== PCS_CENTER
)
1474 // we strip text from the center but alternating
1475 // from the left portion and the from the right
1476 // portion around the "..." text
1479 // move all text starting AT "..." one char to the left
1480 // make sure we don't cause a buffer underrun
1483 D(DBF_DRAW
, "cstart: '%s'", &txt
[cstart
]);
1484 memmove(&txt
[cstart
-1], &txt
[cstart
], strlen(&txt
[cstart
])+1);
1490 // move all text starting AFTER "..." one char to the left
1491 memmove(&txt
[cstart
+3], &txt
[cstart
+3+1], strlen(&txt
[cstart
+3+1])+1);
1499 D(DBF_DRAW
, "curclen: %ld txtlen: %ld, %ld: '%s' '%s'", curclen
, txtlen
, ptr1
-afinfo
->strptr
, ptr1
, txt
);
1501 // calculate the len diff between afinfo->strptr and txt so that resizing
1502 // a column does redraw the right thing.
1503 if((ptr1
-afinfo
->strptr
) > 0)
1505 Text(data
->rp
, &txt
[ptr1
-afinfo
->strptr
], curclen
);
1506 D(DBF_DRAW
, "argh: %ld %ld '%s'", x2
, curclen
, &txt
[ptr1
-afinfo
->strptr
]);
1509 Text(data
->rp
, txt
, txtlen
);
1511 FreeVecPooled(data
->Pool
, txt
);
1516 Text(data
->rp
, ptr1
, curclen
);
1518 D(DBF_DRAW
, "draw text4: %ld %ld %ld %ld %ld - %ld>%ld '%s'", curclen
, x2
, next_x
, maxx2
, cmaxx
, ni
+1, cinfo
->ninfo
, ptr1
);
1524 D(bug( "Drawing line len: %ld, x: %ld, y: %ld - '", curclen, x2, y ));
1526 for( xy = 0; xy < curclen; xy++ )
1528 D(bug( "%1.1s", &ptr1[xy] )); }
1535 snprintf( txt, sizeof(txt), "Drawing line len: %ld, x: %ld, y: %ld - '%%%ld.%lds'", curclen, x2, y, curclen, curclen );
1536 D(bug( txt, ptr1 ));
1542 if (afinfo
->addchar
> 0)
1543 data
->rp
->TxSpacing
= 0;
1548 afinfo
= &data
->aff_infos
[ni
];
1551 if(data
->NList_PartialCol
&& cinfo
->partcolsubst
== PCS_DISABLED
&&
1552 (x2
> cmaxx
) && (xbar
-1 >= data
->mleft
) && (xbar
-1 <= data
->mright
))
1556 SetAPen(data
->rp
,data
->pens
[MPEN_SHINE
]);
1557 for (yb
= ybar
+1; yb
< ybar2
; yb
+= 2)
1558 WritePixel(data
->rp
, xbar
-1, yb
);
1559 SetAPen(data
->rp
,data
->pens
[MPEN_SHADOW
]);
1560 for (yb
= ybar
+2; yb
< ybar2
; yb
+= 2)
1561 WritePixel(data
->rp
, xbar
-1, yb
);
1564 if ((ent
== -1) && IS_BAR(column
,cinfo
) &&
1565 ((data
->NList_TitleMark
& MUIV_NList_TitleMark_ColMask
) == cinfo
->col
))
1567 NL_DrawTitleMark(data
,xbar
-1,ybar
);
1569 else if ((ent
== -1) && IS_BAR(column
,cinfo
) &&
1570 ((data
->NList_TitleMark2
& MUIV_NList_TitleMark2_ColMask
) == cinfo
->col
))
1572 NL_DrawTitleMark2(data
,xbar
-1,ybar
);
1574 if ((ent
== -1) && !IS_BAR(column
,cinfo
) &&
1575 ((data
->NList_TitleMark
& MUIV_NList_TitleMark_ColMask
) == cinfo
->col
))
1577 NL_DrawTitleMark(data
,next_x
+6,ybar
);
1579 else if ((ent
== -1) && !IS_BAR(column
,cinfo
) &&
1580 ((data
->NList_TitleMark2
& MUIV_NList_TitleMark2_ColMask
) == cinfo
->col
))
1582 NL_DrawTitleMark2(data
,next_x
+6,ybar
);
1585 SetSoftStyle(data
->rp
, 0, STYLE_MASK
);
1591 static LONG
DrawEntryTextOnly(struct NLData
*data
,struct RastPort
*rp
,LONG ent
,LONG col
,UNUSED LONG x
,LONG y
,LONG minx
,LONG maxx
,ULONG mypen
,BOOL draw
)
1593 struct colinfo
*cinfo
;
1594 struct affinfo
*afinfo
;
1595 LONG next_x
, x2
, x2e
,column
;
1597 struct TextExtent te
;
1598 WORD curclen
, dcurclen
, ni
;
1600 NL_GetDisplayArray(data
,ent
);
1602 column
= NL_ColToColumn(data
,col
);
1606 cinfo
= data
->cols
[column
].c
;
1608 if (!DontDoColumn(data
,ent
,column
))
1610 ParseColumn(data
,column
,mypen
);
1611 WidthColumn(data
,column
,0);
1615 afinfo
= &data
->aff_infos
[ni
];
1617 while ((ni
<= cinfo
->ninfo
) && (afinfo
->len
> 0) && (x2
< maxx
))
1619 if ((afinfo
->style
== STYLE_TAB
) || (afinfo
->style
== STYLE_FIXSPACE
) || (afinfo
->style
== STYLE_SPACE
))
1620 next_x
= x2
+ data
->spacesize
;
1621 else if ((afinfo
->style
== STYLE_IMAGE
) || (afinfo
->style
== STYLE_IMAGE2
))
1625 SetAPen(rp
,afinfo
->pen
);
1626 SetSoftStyle(rp
, GET_STYLE(afinfo
->style
), STYLE_MASK
);
1630 curclen
= afinfo
->len
;
1631 ptr1
= afinfo
->strptr
;
1633 TextExtent(rp
, ptr1
, curclen
, &te
);
1634 if ((ni
== 0) && (te
.te_Extent
.MinX
< 0))
1635 x2
-= te
.te_Extent
.MinX
;
1636 next_x
= x2
+ te
.te_Width
;
1637 x2e
= x2
+ te
.te_Width
;
1639 if ((x2
< maxx
) && (x2
+ te
.te_Extent
.MaxX
> minx
))
1640 { /* skip most of unwanted chars on the right */
1641 if ((curclen
> 0) && (x2e
> maxx
))
1642 { dcurclen
= te
.te_Extent
.MaxX
- te
.te_Width
- te
.te_Extent
.MinX
+2;
1643 curclen
= TextFit(rp
, ptr1
, curclen
, &te
, NULL
,1,maxx
- x2
+ dcurclen
,32767);
1645 { TextExtent(rp
, ptr1
, curclen
, &te
);
1646 x2e
= x2
+ te
.te_Width
;
1650 { TextExtent(rp
, &ptr1
[curclen
-1], 1, &te
);
1652 /* throw away chars on the right that souldn't be draw because out of list */
1653 while ((curclen
> 0) && ((x2e
+ te
.te_Extent
.MaxX
) > maxx
))
1656 { TextExtent(rp
, &ptr1
[curclen
-1], 1, &te
);
1661 if((curclen
> 0) && draw
)
1664 Text(rp
, ptr1
, curclen
);
1670 afinfo
= &data
->aff_infos
[ni
];
1672 SetSoftStyle(rp
, 0, STYLE_MASK
);
1679 LONG
DrawDragText(struct NLData
*data
,BOOL draw
)
1681 Object
*obj
= data
->this;
1682 struct TextExtent te
;
1683 struct RastPort
*rp
;
1687 rp
= data
->DragRPort
;
1691 if (rp
&& data
->DragText
)
1693 char *text
= data
->DragText
;
1698 data
->DragText
= NULL
;
1699 data
->DragEntry
= -1;
1700 SetBackGround(MUII_myListCursor
);
1701 _rp(obj
) = data
->DragRPort
;
1704 _width(obj
) = data
->DragWidth
;
1705 _height(obj
) = data
->DragHeight
;
1706 DrawBackground(obj
, 0, 0, data
->DragWidth
, data
->DragHeight
, 0, 0);
1707 _rp(obj
) = data
->rp
;
1708 _left(obj
) = data
->left
;
1709 _top(obj
) = data
->top
;
1710 _width(obj
) = data
->width
;
1711 _height(obj
) = data
->height
;
1712 SetABPenDrMd(data
->DragRPort
,MUIPEN(data
->NList_CursorPen
),data
->pens
[MPEN_BACKGROUND
],JAM1
);
1714 SetSoftStyle(rp
, 0, STYLE_MASK
);
1715 curclen
= strlen(text
);
1716 curclen
= TextFit(rp
, text
, curclen
, &te
, NULL
,1,data
->DragWidth
,32767);
1717 if (te
.te_Extent
.MinX
< 0)
1718 x
-= te
.te_Extent
.MinX
;
1719 w
= te
.te_Extent
.MaxX
- te
.te_Extent
.MinX
;
1722 if (w
< data
->DragWidth
)
1723 x
+= ((data
->DragWidth
- w
) / 2);
1726 Move(rp
, x
, data
->voff
);
1727 Text(rp
, text
, curclen
);
1732 else if (rp
&& (data
->DragEntry
>= 0) && (data
->NList_DragColOnly
>= 0))
1734 LONG ent
= data
->DragEntry
;
1738 data
->DragText
= NULL
;
1739 data
->DragEntry
= -1;
1740 SetBackGround(MUII_myListCursor
);
1741 _rp(obj
) = data
->DragRPort
;
1744 _width(obj
) = data
->DragWidth
;
1745 _height(obj
) = data
->DragHeight
;
1746 DrawBackground(obj
, 0, 0, data
->DragWidth
, data
->DragHeight
, 0, 0);
1747 _rp(obj
) = data
->rp
;
1748 _left(obj
) = data
->left
;
1749 _top(obj
) = data
->top
;
1750 _width(obj
) = data
->width
;
1751 _height(obj
) = data
->height
;
1753 w
= DrawEntryTextOnly(data
,rp
,ent
,data
->NList_DragColOnly
,0,data
->voff
,0,data
->DragWidth
,MUIPEN(data
->NList_CursorPen
),draw
);
1754 if (w
> data
->DragWidth
)
1755 w
= data
->DragWidth
;
1760 data
->DragText
= NULL
;
1761 data
->DragEntry
= -1;
1767 void DisposeDragRPort(struct NLData
*data
)
1769 if(data
->DragRPort
!= NULL
)
1771 struct BitMap
*bm
= data
->DragRPort
->BitMap
;
1773 FreeVecPooled(data
->Pool
, data
->DragRPort
);
1774 data
->DragRPort
= NULL
;
1785 struct RastPort
*CreateDragRPort(struct NLData
*data
,LONG numlines
,LONG first
,LONG last
)
1787 Object
*obj
= data
->this;
1791 data
->DragWidth
= data
->mwidth
;
1792 data
->DragHeight
= data
->vinc
* numlines
;
1798 static char text
[40];
1800 data
->DragHeight
= data
->vinc
;
1801 data
->DragWidth
= data
->mwidth
;
1803 if(data
->NList_DragColOnly
< 0)
1806 strlcpy(text
, "Dragging one item...", sizeof(text
));
1808 snprintf(text
, sizeof(text
), "Dragging %ld items...", (long)numlines
);
1810 data
->DragText
= text
;
1811 data
->DragEntry
= -1;
1817 snprintf(text
, sizeof(text
), "%ld items.", (long)numlines
);
1819 data
->DragText
= text
;
1820 data
->DragEntry
= -1;
1822 else if(data
->NList_DragLines
== 1)
1824 strlcpy(text
, "1 item.", sizeof(text
));
1826 data
->DragText
= text
;
1827 data
->DragEntry
= -1;
1831 data
->DragText
= NULL
;
1832 data
->DragEntry
= first
;
1835 data
->DragWidth
= DrawDragText(data
, FALSE
);
1839 if(data
->DragRPort
== NULL
&&
1840 ((data
->DragRPort
= (struct RastPort
*)AllocVecPooled(data
->Pool
, sizeof(struct RastPort
)))) != NULL
)
1842 struct BitMap
*fbm
= _window(obj
)->RPort
->BitMap
;
1844 InitRastPort(data
->DragRPort
);
1846 if((data
->DragRPort
->BitMap
= AllocBitMap((ULONG
)data
->DragWidth
, (ULONG
)data
->DragHeight
, GetBitMapAttr(fbm
, BMA_DEPTH
), BMF_MINPLANES
, fbm
)) != NULL
)
1848 struct IClass
*realclass
= OCLASS(obj
);
1850 SetFont(data
->DragRPort
,data
->font
);
1851 OCLASS(obj
) = data
->ncl
;
1853 OCLASS(obj
) = realclass
;
1855 return data
->DragRPort
;
1859 FreeVecPooled(data
->Pool
, data
->DragRPort
);
1860 data
->DragRPort
= NULL
;