grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / nlist / nlist_mcc / NList_mcc6.c
blobfe961d580788b51f6fa436bd0705ab3148928101
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
22 $Id$
24 ***************************************************************************/
26 #include <stdio.h>
27 #include <string.h>
29 #if defined(__amigaos4__)
30 #include <hardware/blit.h>
31 #endif
33 #include <graphics/gfxmacros.h>
34 #undef GetOutlinePen
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>
43 #include "private.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))
54 #endif
56 xoff += left;
57 yoff += top;
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;
65 WORD linelen = 3;
66 #ifdef DO_CLIPPING
67 APTR clippinghandle;
68 clippinghandle = MUI_AddClipping(muiRenderInfo(obj),(WORD) data->mleft,(WORD) _mtop(obj),
69 (WORD) data->mwidth,(WORD) data->vinc);
70 #endif
72 if (minx < data->vleft)
73 minx = data->vleft;
74 if (maxx > data->vright + 1)
75 maxx = data->vright + 1;
77 if (minx < data->mleft)
78 minx = data->mleft;
79 if (maxx > data->mleft + data->mwidth)
80 maxx = data->mleft + data->mwidth;
81 if (minx >= maxx)
82 return(0);
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;
97 #ifdef DO_CLIPPING
98 MUI_RemoveClipping(muiRenderInfo(obj),clippinghandle);
99 #endif
100 return (linelen);
104 void DrawOldLine(struct NLData *data,LONG ent,LONG minx,LONG maxx,WORD hfirst)
106 Object *obj = data->this;
107 ULONG mypen;
108 BOOL forcepen = FALSE;
109 BOOL drawtxt;
110 LONG vert1,vert2,vertd;
111 #ifdef DO_CLIPPING
112 APTR clippinghandle;
113 #endif
115 if (minx < data->vleft)
116 minx = data->vleft;
117 if (maxx > data->vright + 1)
118 maxx = data->vright + 1;
120 if (minx < data->mleft)
121 minx = data->mleft;
122 if (maxx > data->mleft + data->mwidth)
123 maxx = data->mleft + data->mwidth;
124 if (minx >= maxx)
125 return;
127 #ifdef DO_CLIPPING
128 clippinghandle = MUI_AddClipping(muiRenderInfo(obj),(WORD) data->mleft,(WORD) data->mtop,
129 (WORD) data->mwidth,(WORD) data->mheight);
130 #endif
131 drawtxt = TRUE;
132 vert1 = data->vpos+(data->vinc * (ent - data->NList_AffFirst));
133 vert2 = data->vpos + (ent*data->vinc);
134 vertd = 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;
139 drawtxt = FALSE;
141 else if (ent == data->NList_First + data->NList_Visible)
142 { vertd = data->NList_First_Incr;
143 vert1 -= data->NList_First_Incr;
144 drawtxt = FALSE;
146 else
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);
155 else
157 if (data->EntriesArray[ent]->Select == TE_Select_None)
159 SetBackGround(data->NList_ListBackGround); mypen = data->NList_ListPen; forcepen = FALSE;
161 else
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;
167 else
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);
174 if (drawtxt)
175 DrawText(data,ent,data->hpos-hfirst,vert1+data->voff,minx,maxx-1,MUIPEN(mypen),data->hinc,forcepen);
177 #ifdef DO_CLIPPING
178 MUI_RemoveClipping(muiRenderInfo(obj),clippinghandle);
179 #endif
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;
188 ULONG mypen;
189 BOOL forcepen = FALSE;
190 LONG vert1,vert2,vertd,vert3;
191 WORD hfx = data->mleft - hfirst;
192 #ifdef DO_CLIPPING
193 APTR clippinghandle = NULL;
194 BOOL doclip = FALSE;
195 #endif
197 //D(bug( "DRAWING LINES FROM %ld - %ld\n", e1, e2 ));
199 if (small > 1)
200 { lim1 = 3;
201 lim2 = 2;
202 lim3 = 2;
204 else if (small == 1)
205 { lim1 = 8;
206 lim2 = 4;
207 lim3 = 4;
209 else
210 { lim1 = 14;
211 lim2 = 7;
212 lim3 = 8;
215 if (minx < data->vleft)
216 minx = data->vleft;
217 if (maxx > data->vright + 1)
218 maxx = data->vright + 1;
220 if ((e2 - e1) == 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)
227 minx = data->mleft;
228 if (maxx > data->mleft + data->mwidth)
229 maxx = data->mleft + data->mwidth;
230 if (minx >= maxx)
231 return (hmax);
233 ent4 = ent2 = e2;
234 if (ent2 > data->NList_Entries)
235 ent2 = data->NList_Entries;
236 ent = e1;
237 if (ent < 0)
238 ent = 0;
240 #ifdef DO_CLIPPING
241 if (data->NList_First_Incr &&
242 ((e1 <= data->NList_First) || (e2 >= data->NList_First + data->NList_Visible)))
243 { doclip = TRUE;
244 clippinghandle = MUI_AddClipping(muiRenderInfo(obj),
245 (WORD) data->mleft,
246 (WORD) data->vpos,
247 (WORD) data->mwidth,
248 (WORD) (data->NList_Visible*data->vinc));
250 #endif
251 while (ent < ent2)
253 forcepen = FALSE;
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))))
257 { ent++;
258 continue;
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))
266 ent3 = ent + 1;
267 if (!not_all)
269 while ((ent3 < ent2) && (ent3 < data->sel_pt[data->max_sel].ent))
270 ent3++;
271 dent = ent3 - ent;
272 if (dent >= 14)
273 ent3 = ent + 7;
274 else if (dent >= 8)
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;
282 else
284 SetBackGround(MUII_myListCursor); mypen = data->NList_CursorPen; forcepen = data->ForcePen;
287 else
289 ent3 = ent + 1;
290 if (!not_all)
292 while ((ent3 < ent2) && ((ent3 > data->sel_pt[data->max_sel].ent) || (ent3 < data->sel_pt[data->min_sel].ent)))
293 ent3++;
294 dent = ent3 - ent;
295 if (dent >= lim1)
296 ent3 = ent + lim2;
297 else if (dent >= lim3)
298 ent3 = ent + (dent / 2);
301 SetBackGround(data->NList_ListBackGround); mypen = data->NList_ListPen;
304 else
306 if(ent == data->NList_Active)
308 ent3 = ent + 1;
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;
318 else
320 SetBackGround(MUII_myListCursor); mypen = data->NList_CursorPen; forcepen = data->ForcePen;
323 data->do_draw_active = FALSE;
325 else
326 { cursel = data->EntriesArray[ent]->Select;
327 ent3 = ent + 1;
328 if (!not_all)
329 { while ((ent3 < ent2) && (data->EntriesArray[ent3]->Select == cursel) && (ent3 != data->NList_Active))
330 ent3++;
331 dent = ent3 - ent;
332 if (dent >= 14)
333 ent3 = ent + 7;
334 else if (dent >= 8)
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;
346 else
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;
366 else
367 { vert3 -= data->NList_First_Incr;
370 DrawBackground(obj, minx, vert3, maxx-minx, vertd, hfirst+data->vdx, vert2-vert3+data->vdy);
371 while (ent < ent3)
373 #ifndef DO_CLIPPING
374 if (!data->NList_First_Incr || do_extrems || ((ent > data->NList_First) && (ent < data->NList_First + data->NList_Visible)))
375 #endif
377 linelen = DrawText(data,ent,data->hpos-hfirst,vert1+data->voff,minx,maxx-1,MUIPEN(mypen),data->hinc,forcepen);
378 if(linelen > hmax)
379 hmax = linelen;
381 vert1 += data->vinc;
382 ent++;
385 else
387 WORD x1,x2,x3,x4;
389 x1 = minx;
390 x4 = maxx;
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)
402 x2 = x1;
403 if (ent != data->sel_pt[data->max_sel].ent)
404 x3 = x4;
406 vert3 = vert1 = data->vpos+(data->vinc * (ent - data->NList_First));
407 vert2 = data->vpos + (ent*data->vinc);
408 vertd = 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;
419 else
420 { vert3 -= data->NList_First_Incr;
424 if(x1 < x2)
426 SetBackGround(data->NList_ListBackGround);
427 DrawBackground(obj, x1, vert3, x2-x1, vertd, hfirst+data->vdx, vert2-vert3+data->vdy);
429 if (x2 < x3)
431 if(data->NList_ActiveObjectOnClick == TRUE && (data->isActiveObject == FALSE || xget(_win(obj), MUIA_Window_Activate) == FALSE))
433 SetBackGround(MUII_myListInactive);
435 else
437 SetBackGround(MUII_myListCursor);
440 DrawBackground(obj, x2, vert3, x3-x2, vertd, hfirst+data->vdx, vert2-vert3+data->vdy);
442 if (x3 < x4)
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)
464 x2 = x1;
465 if (ent != data->sel_pt[data->max_sel].ent)
466 x3 = x4;
467 #ifndef DO_CLIPPING
468 if (!data->NList_First_Incr || do_extrems || ((ent > data->NList_First) && (ent < data->NList_First + data->NList_Visible)))
469 #endif
471 if (x1 < x2)
473 mypen = data->NList_ListPen;
474 linelen = DrawText(data,ent,data->hpos-hfirst,vert1+data->voff,x1,x2-1,MUIPEN(mypen),0,FALSE);
476 if (x2 < x3)
478 mypen = data->NList_CursorPen;
479 linelen = DrawText(data,ent,data->hpos-hfirst,vert1+data->voff,x2,x3-1,MUIPEN(mypen),0,data->ForcePen);
481 if (x3 < x4)
483 mypen = data->NList_ListPen;
484 linelen = DrawText(data,ent,data->hpos-hfirst,vert1+data->voff,x3,x4-1,MUIPEN(mypen),0,FALSE);
486 if (linelen > hmax)
487 hmax = linelen;
489 ent++;
493 if (ent < ent4)
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;
508 else
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;
521 else
522 maxx2 = data->mright;
523 xbar = maxx2;
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);
549 #ifdef DO_CLIPPING
550 if (doclip)
551 MUI_RemoveClipping(muiRenderInfo(obj),clippinghandle);
552 #endif
553 return (hmax);
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);
596 break;
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);
615 break;
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);
632 break;
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);
651 break;
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);
689 break;
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);
705 break;
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);
720 break;
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);
737 break;
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;
754 char *ptr1;
755 struct TextExtent te;
756 WORD column, curclen, dcurclen, ni;
758 if ((ent < -1) || (ent >= data->NList_Entries))
759 return (0);
761 if (((y - data->voff + data->vinc) < data->vtop) || ((y - data->voff) > data->vbottom))
763 if (ent > -1)
765 linelen = (LONG) data->EntriesArray[ent]->PixLen;
766 return (linelen);
770 SetABPenDrMd(data->rp,mypen,data->pens[MPEN_BACKGROUND],JAM1);
772 NL_GetDisplayArray(data,ent);
774 xbar = x + data->cols[0].c->minx - 8;
776 linelen = 0;
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;
786 cmaxx = maxx2;
788 else
790 maxx2 = data->mright;
791 cmaxx = 100000;
794 xbar2 = xbar;
795 xbar = maxx2;
796 ybar = y - data->voff;
797 ybar2 = ybar+data->vinc-1;
798 if (ent == -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)
844 if (minx2 >= maxx2)
845 continue;
846 if (minx > maxx2)
847 continue;
848 if (maxx < minx2)
849 continue;
851 minx3 = minx2;
852 if (minx > minx3)
853 minx3 = minx;
854 maxx3 = maxx2;
855 if (maxx < maxx3)
856 maxx3 = maxx;
857 minx3 -= (data->hinc + 2);
858 maxx3 += (data->hinc + 2);
860 if (DontDoColumn(data,ent,column))
861 continue;
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;
870 yb1 = ybar;
871 nothick = thick = 0;
872 if (IS_HLINE_thick(cinfo->style) && (IS_HLINE_C(cinfo->style) || IS_HLINE_E(cinfo->style)))
873 thick = 2;
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))
883 yb1 += data->vinc-2;
884 yb2 = yb1 + 1;
885 if (thick)
887 yb1 -= 1;
888 yb2 += 1;
890 else if (IS_HLINE_nothick(cinfo->style))
892 nothick = 1;
893 if (IS_HLINE_B(cinfo->style))
894 yb1 = yb2;
896 xb1 = xbar2+1;
897 xb2 = xbar-1;
898 if (xb1 < minx-1)
899 xb1 = minx-1;
900 if (xb2 > maxx+1)
901 xb2 = maxx+1;
902 if (xb1 < data->mleft)
903 xb1 = data->mleft;
904 if (xb2 > data->mright)
905 xb2 = data->mright;
906 if (xb1 < xb2)
908 if (IS_HLINE_E(cinfo->style))
910 if (xbe1 > xb2)
911 xbe1 = xb2;
912 if (xbe2 < xb1)
913 xbe2 = xb1;
914 if (xb1 <= xbe1)
916 if (!nothick)
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);
924 if (thick)
926 SetAPen(data->rp,data->HLINE_thick_pen);
927 RectFill(data->rp, xb1, yb1+1, xbe1, yb1+2);
930 else
932 SetAPen(data->rp,data->HLINE_thick_pen);
933 Move(data->rp, xb1, yb1);
934 Draw(data->rp, xbe1, yb1);
937 if (xbe2 <= xb2)
939 if (!nothick)
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);
946 if (thick)
948 SetAPen(data->rp,data->HLINE_thick_pen);
949 RectFill(data->rp, xbe2, yb1+1, xb2, yb1+2);
952 else
954 SetAPen(data->rp,data->HLINE_thick_pen);
955 Move(data->rp, xbe2, yb1);
956 Draw(data->rp, xb2, yb1);
960 else
962 if (!nothick)
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);
970 if (thick)
972 SetAPen(data->rp,data->HLINE_thick_pen);
973 RectFill(data->rp, xb1, yb1+1, xb2, yb1+2);
976 else
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;
994 else
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))
1005 continue;
1007 x2s = x2;
1011 int xy, yx;
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] ));
1024 D(bug( "'\n" ));
1027 D(bug( "<====================================\n" ));
1031 ni = 0;
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;
1045 x2 += 1;
1046 dx = afinfo->pen & 0x0000FFFF;
1047 dy = 0;
1048 dy2 = (afinfo->pen >> 16) & 0x0000FFFF;
1049 next_x = x2 + afinfo->len + afinfo->addinfo + 1;
1050 x3 = x2;
1051 dx3 = dx;
1052 if ((x3 + dx3) > maxx2)
1053 dx3 = maxx2 - x3;
1054 if (x3 < minx2)
1056 dx3 -= (minx2 - x3);
1057 x3 = minx2;
1060 if (nimg && nimg->NImgObj && (dx3 > 0) && (x2 <= maxx) && (next_x > minx))
1062 struct IClass *realclass = OCLASS(obj);
1063 ULONG mad_Flags;
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);
1082 if (dx > 0)
1083 _width(nimg->NImgObj) = dx;
1084 else
1085 _width(nimg->NImgObj) = 1;
1086 if (dy2 > 0)
1087 _height(nimg->NImgObj) = dy2;
1088 else
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)
1094 dy = 0;
1095 _height(nimg->NImgObj) = data->vinc;
1096 ot = _top(nimg->NImgObj) = (WORD) (y-data->voff+dy);
1098 doclip = TRUE;
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;
1105 if (!nimg->ImgName)
1107 LONG vinc = (LONG) data->vinc;
1109 if (afinfo->tag)
1111 SetAttrs(nimg->NImgObj, MUIA_NLIMG_EntryCurrent, ent,
1112 MUIA_NLIMG_EntryHeight, vinc,
1113 afinfo->tag, afinfo->tagval, TAG_DONE);
1115 else
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);
1156 else
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;
1171 if (doclip)
1173 doclip = FALSE;
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);
1182 ReSetFont;
1184 else if (afinfo->style == STYLE_IMAGE2)
1186 LONG dx,dx2,dy,dy2;
1188 x2 += 1;
1189 dx = afinfo->pen & 0x0000FFFF;
1190 dx2 = 0;
1191 dy = 0;
1192 dy2 = (afinfo->pen >> 16) & 0x0000FFFF;
1193 next_x = x2 + afinfo->len + afinfo->addinfo + 1;
1194 if ((x2 + dx) > maxx2)
1195 dx = maxx2 - x2;
1196 if (x2 < minx2)
1198 dx2 = minx2 - x2;
1199 x2 += dx2;
1200 dx -= dx2;
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);
1215 else
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
1222 if (forcepen)
1223 SetAPen(data->rp,mypen);
1224 else
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;
1247 //////////////
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
1250 // current column
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))
1256 int x2diff = 0;
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);
1267 if(curclen > 0)
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;
1285 if(curclen > 0)
1287 // move the start of the string by the number of characters
1288 // we had to reduce the amount of characters displayed
1289 ptr1 += dcurclen;
1290 x2 += te.te_Width;
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);
1301 if (curclen > 0)
1303 TextExtent(data->rp, &ptr1[curclen-1], 1, &te);
1304 x2e -= te.te_Width;
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))
1309 curclen--;
1310 if (curclen > 0)
1312 TextExtent(data->rp, &ptr1[curclen-1], 1, &te);
1313 x2e -= te.te_Width;
1317 /* throw away chars on the right that i don't want to draw because out of maxx */
1318 if (dxpermit)
1320 while ((curclen > 0) && ((x2e + te.te_Extent.MinX) > maxx))
1322 curclen--;
1323 if (curclen > 0)
1325 TextExtent(data->rp, &ptr1[curclen-1], 1, &te);
1326 x2e -= te.te_Width;
1330 else
1332 while ((curclen > 0) && (x2e > maxx))
1334 curclen--;
1335 if (curclen > 0)
1337 TextExtent(data->rp, &ptr1[curclen-1], 1, &te);
1338 x2e -= te.te_Width;
1344 if (curclen > 0)
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))
1351 x2 += te.te_Width;
1352 x2diff += te.te_Width;
1353 ptr1++;
1354 curclen--;
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 */
1359 if (dxpermit)
1361 while ((curclen > 0) && ((x2 + te.te_Extent.MaxX) < minx))
1363 x2 += te.te_Width;
1364 x2diff += te.te_Width;
1365 ptr1++;
1366 curclen--;
1367 TextExtent(data->rp, ptr1, 1, &te);
1370 else
1372 while ((curclen > 0) && ((x2+te.te_Width) <= minx))
1374 x2 += te.te_Width;
1375 x2diff += te.te_Width;
1376 ptr1++;
1377 curclen--;
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);
1385 if(curclen > 0)
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))
1395 int txtlen;
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
1406 // at all
1407 if(clen >= te.te_Width)
1409 char *txt;
1410 int cstart;
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);
1425 cstart = 0;
1427 else if(cinfo->partcolsubst == PCS_RIGHT)
1429 strlcpy(txt, afinfo->strptr, txtlen+1);
1430 strlcat(txt, "...", txtlen+3+1);
1431 cstart = txtlen-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;
1440 else
1442 // make sure we have a NUL terminated string in any case
1443 txt[0] = '\0';
1444 cstart = 0;
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)
1456 break;
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
1469 if(txtlen > 4)
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
1477 if(txtlen % 2 == 0)
1479 // move all text starting AT "..." one char to the left
1480 // make sure we don't cause a buffer underrun
1481 if(cstart > 0)
1483 D(DBF_DRAW, "cstart: '%s'", &txt[cstart]);
1484 memmove(&txt[cstart-1], &txt[cstart], strlen(&txt[cstart])+1);
1485 cstart--;
1488 else
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);
1495 txtlen--;
1497 while(TRUE);
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]);
1508 else
1509 Text(data->rp, txt, txtlen);
1511 FreeVecPooled(data->Pool, txt);
1515 else
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);
1522 int xy;
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] )); }
1529 D(bug( "'\n" ));
1533 char txt[100];
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;
1546 x2 = next_x;
1547 ni++;
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))
1554 WORD yb;
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);
1587 return (linelen);
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;
1596 STRPTR ptr1;
1597 struct TextExtent te;
1598 WORD curclen, dcurclen, ni;
1600 NL_GetDisplayArray(data,ent);
1602 column = NL_ColToColumn(data,col);
1603 if (column < 0)
1604 return (0);
1606 cinfo = data->cols[column].c;
1608 if (!DontDoColumn(data,ent,column))
1610 ParseColumn(data,column,mypen);
1611 WidthColumn(data,column,0);
1612 x2 = 1;
1614 ni = 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))
1622 next_x = x2 + 2;
1623 else
1625 SetAPen(rp,afinfo->pen);
1626 SetSoftStyle(rp, GET_STYLE(afinfo->style), STYLE_MASK);
1628 rp->TxSpacing = 0;
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);
1644 if (curclen > 0)
1645 { TextExtent(rp, ptr1, curclen, &te);
1646 x2e = x2 + te.te_Width;
1649 if (curclen > 0)
1650 { TextExtent(rp, &ptr1[curclen-1], 1, &te);
1651 x2e -= te.te_Width;
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))
1654 { curclen--;
1655 if (curclen > 0)
1656 { TextExtent(rp, &ptr1[curclen-1], 1, &te);
1657 x2e -= te.te_Width;
1661 if((curclen > 0) && draw)
1663 Move(rp, x2, y);
1664 Text(rp, ptr1, curclen);
1668 x2 = next_x;
1669 ni++;
1670 afinfo = &data->aff_infos[ni];
1672 SetSoftStyle(rp, 0, STYLE_MASK);
1673 return (x2);
1675 return (0);
1679 LONG DrawDragText(struct NLData *data,BOOL draw)
1681 Object *obj = data->this;
1682 struct TextExtent te;
1683 struct RastPort *rp;
1684 LONG curclen,x,w;
1686 if (draw)
1687 rp = data->DragRPort;
1688 else
1689 rp = data->rp;
1691 if (rp && data->DragText)
1693 char *text = data->DragText;
1695 x = 0;
1696 if (draw)
1698 data->DragText = NULL;
1699 data->DragEntry = -1;
1700 SetBackGround(MUII_myListCursor);
1701 _rp(obj) = data->DragRPort;
1702 _left(obj) = 0;
1703 _top(obj) = 0;
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;
1720 if (draw)
1722 if (w < data->DragWidth)
1723 x += ((data->DragWidth - w) / 2);
1724 if (curclen > 0)
1726 Move(rp, x, data->voff);
1727 Text(rp, text, curclen);
1730 return (w);
1732 else if (rp && (data->DragEntry >= 0) && (data->NList_DragColOnly >= 0))
1734 LONG ent = data->DragEntry;
1736 if (draw)
1738 data->DragText = NULL;
1739 data->DragEntry = -1;
1740 SetBackGround(MUII_myListCursor);
1741 _rp(obj) = data->DragRPort;
1742 _left(obj) = 0;
1743 _top(obj) = 0;
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;
1756 return (w);
1758 else
1760 data->DragText = NULL;
1761 data->DragEntry = -1;
1763 return (4);
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;
1776 if(bm != NULL)
1778 WaitBlit();
1779 FreeBitMap(bm);
1785 struct RastPort *CreateDragRPort(struct NLData *data,LONG numlines,LONG first,LONG last)
1787 Object *obj = data->this;
1789 if(last >= first)
1791 data->DragWidth = data->mwidth;
1792 data->DragHeight = data->vinc * numlines;
1794 return NULL;
1796 else
1798 static char text[40];
1800 data->DragHeight = data->vinc;
1801 data->DragWidth = data->mwidth;
1803 if(data->NList_DragColOnly < 0)
1805 if(numlines == 1)
1806 strlcpy(text, "Dragging one item...", sizeof(text));
1807 else
1808 snprintf(text, sizeof(text), "Dragging %ld items...", (long)numlines);
1810 data->DragText = text;
1811 data->DragEntry = -1;
1813 else
1815 if(numlines != 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;
1829 else
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;
1852 REDRAW_FORCE;
1853 OCLASS(obj) = realclass;
1855 return data->DragRPort;
1857 else
1859 FreeVecPooled(data->Pool, data->DragRPort);
1860 data->DragRPort = NULL;
1864 return NULL;