revert between 56095 -> 55830 in arch
[AROS.git] / workbench / classes / zune / nlist / nlist_mcc / NList_mcc4.c
blob287aa6b326ac349af83851f3c5994b5f6f0d8fb9
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 <stdlib.h>
27 #include <string.h>
29 #include <clib/alib_protos.h>
30 #include <proto/exec.h>
31 #include <proto/intuition.h>
32 #include <proto/graphics.h>
34 #include "private.h"
36 #include "NList_func.h"
38 /* DRI's draw pens */
39 /* #define DETAILPEN (0x0000) // compatible Intuition rendering pens */
40 /* #define BLOCKPEN (0x0001) // compatible Intuition rendering pens */
41 /* #define TEXTPEN (0x0002) // text on background */
42 /* #define SHINEPEN (0x0003) // bright edge on 3D objects */
43 /* #define SHADOWPEN (0x0004) // dark edge on 3D objects */
44 /* #define FILLPEN (0x0005) // active-window/selected-gadget fill */
45 /* #define FILLTEXTPEN (0x0006) // text over FILLPEN */
46 /* #define BACKGROUNDPEN (0x0007) // always color 0 */
47 /* #define HIGHLIGHTTEXTPEN (0x0008) // special color text, on background */
48 /* V39 only : */
49 /* #define BARDETAILPEN (0x0009) // text/detail in screen-bar/menus */
50 /* #define BARBLOCKPEN (0x000A) // screen-bar/menus fill */
51 /* #define BARTRIMPEN (0x000B) // trim under screen-bar */
53 /* MUI's draw pens */
54 /* #define MPEN_SHINE 0 */
55 /* #define MPEN_HALFSHINE 1 */
56 /* #define MPEN_BACKGROUND 2 */
57 /* #define MPEN_HALFSHADOW 3 */
58 /* #define MPEN_SHADOW 4 */
59 /* #define MPEN_TEXT 5 */
60 /* #define MPEN_FILL 6 */
61 /* #define MPEN_MARK 7 */
62 /* #define MPEN_COUNT 8 */
66 * SetABPenDrMd is V39+ !!!!
67 * SetABPenDrMd(data->rp,data->pens[MPEN_TEXT],data->pens[MPEN_BACKGROUND],JAM1);
68 * SetABPenDrMd(data->rp,_dri(obj)->dri_Pens[TEXTPEN],_dri(obj)->dri_Pens[BACKGROUNDPEN],JAM1);
69 * replace with for < V39:
70 * SetAPen(data->rp,data->pens[MPEN_SHINE]);
71 * SetBPen(data->rp,data->pens[MPEN_SHADOW]);
72 * SetDrMd(data->rp,JAM2);
77 * \t Tabulation. Go to the next tab boundary of the column.
78 * tab positions are separated by 8 spaces by default.
79 * ESC - Disable text engine, following chars will be printed
80 * without further parsing.
81 * ESC u Set the soft style to underline.
82 * ESC b Set the soft style to bold.
83 * ESC i Set the soft style to italic.
84 * ESC n Set the soft style back to normal.
85 * ESC <n> Use pen number n (2..9) as front pen. n must be a valid
86 * DrawInfo pen as specified in "intuition/screens.h".
87 * ESC c Center current line. only valid at the beginning.
88 * ESC r Right justify current line. only valid at the beginning.
89 * ESC l Left justify current line. only valid at the beginning.
91 * These ones are new or modified :
93 * ESC j Justify left and right current line. only at beginning.
94 * ESC I[<s>] (ESC I[<s>|<width>|<height>])
95 * Draw MUI image with specification <s>.
96 * See Image.mui/MUIA_Image_Spec for image spec definition.
97 * <width> and <height> should be omited because NList
98 * draw the image to its standard size himself now.
99 * ESC O[<p>] Draw the MUIM_NList_CreateImage at adress <p>.
100 * (<p> should be an 8 hex digits number).
101 * ESC o[<n>] Draw the MUIM_NList_UseImage number <n>. If the <n> UseImage
102 * don't exist or has been set to NULL, no image is drawn.
103 * ESC P[] Use default front pen.
104 * ESC P[<n>] Use pen number <n>. (it's a direct pen number, so you must
105 * make MUI_ObtainPen and MUI_ReleasePen for it yourself,
106 * best to do it is in Setup() and Cleanup() of a subclass).
107 * ESC T Draw horizontal line on top of the entry for the column.
108 * ESC C Draw horizontal line centered in the entry for the column.
109 * ESC B Draw horizontal line on bottom of the entry for the column
110 * ESC E Draw horizontal line centered in the entry for the column,
111 * but only on the left and right of the line contents.
115 * "0:<x>" where <x> is between MUII_BACKGROUND and
116 * MUII_FILLBACK2 identifying a builtin pattern.
118 * "1:<x>" where <x> identifies a builtin standard image.
119 * Don't use this, use "6:<x>" instead.
121 * "2:<r>,<g>,<b>" where <r>, <g> and <b> are 32-bit RGB
122 * color values specified as 8-digit hex
123 * string (e.g. 00000000 or ffffffff).
124 * Kick 2.x users will get an empty image.
126 * "3:<n>" where <n> is the name of an external boopsi
127 * image class.
129 * "4:<n>" where <n> is the name of an external MUI brush.
131 * "5:<n>" where <n> is the name of an external picture
132 * file that should be loaded with datatypes.
133 * Kick 2.x users will get an empty image.
135 * "6:<x>" where <x> is between MUII_WindowBack and
136 * MUII_Count-1 identifying a preconfigured
137 * image/background.
141 BOOL DontDoColumn(struct NLData *data,LONG ent,WORD column)
143 if ((ent >= 0) && (ent < data->NList_Entries) && (column >= 0) && (column < data->numcols) &&
144 (data->cols[column].c->col < 8) &&
145 (data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine) &&
146 !(data->EntriesArray[ent]->Wrap & (1 << data->cols[column].c->col)))
147 return (TRUE);
148 else
149 return (FALSE);
153 void FreeAffInfo(struct NLData *data)
155 if(data->aff_infos)
157 FreeVecPooled(data->Pool, data->aff_infos);
158 data->aff_infos = NULL;
160 data->numaff_infos = 0;
164 BOOL NeedAffInfo(struct NLData *data,WORD niask)
166 struct affinfo *affinfotmp;
167 WORD ni;
169 if (data->numaff_infos-1 < niask)
170 { LONG num = niask + niask/2;
171 if (num < 12)
172 num = 12;
174 //D(bug( "Adding %ld aff infos.\n", num ));
176 if((affinfotmp = (struct affinfo *)AllocVecPooled(data->Pool, sizeof(struct affinfo)*num)) != NULL)
178 ni = 0;
179 while (ni < data->numaff_infos)
180 { affinfotmp[ni].strptr = data->aff_infos[ni].strptr;
181 affinfotmp[ni].pos = data->aff_infos->pos;
182 affinfotmp[ni].addchar = data->aff_infos[ni].addchar;
183 affinfotmp[ni].addinfo = data->aff_infos[ni].addinfo;
184 affinfotmp[ni].pen = data->aff_infos[ni].pen;
185 affinfotmp[ni].len = data->aff_infos[ni].len;
186 affinfotmp[ni].style = data->aff_infos[ni].style;
187 ni++;
189 while (ni < num)
190 { affinfotmp[ni].strptr = NULL;
191 affinfotmp[ni].pos = 0;
192 affinfotmp[ni].addchar = 0;
193 affinfotmp[ni].addinfo = 0;
194 affinfotmp[ni].pen = 0;
195 affinfotmp[ni].len = 0;
196 affinfotmp[ni].style = 0;
197 ni++;
199 FreeAffInfo(data);
200 data->aff_infos = affinfotmp;
201 data->numaff_infos = num;
202 return (TRUE);
204 return (FALSE);
206 return (TRUE);
210 void NL_GetDisplayArray(struct NLData *data, SIPTR ent)
212 char *useptr;
214 ENTER();
216 if(ent >= 0 && ent < data->NList_Entries)
218 data->parse_ent = ent;
220 if(data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine)
222 if(data->EntriesArray[ent]->len < -1)
224 useptr = NULL;
226 else
228 ent -= data->EntriesArray[data->parse_ent]->dnum;
230 if(ent < 0 || ent >= data->NList_Entries)
231 ent = 0;
233 useptr = (char *)data->EntriesArray[ent]->Entry;
236 else
238 useptr = (char *)data->EntriesArray[ent]->Entry;
241 else
243 useptr = (char *)data->NList_Title;
244 data->display_ptr = NULL;
245 data->parse_ent = -1;
246 ent = -1;
249 if(data->display_ptr == NULL || useptr != data->display_ptr || ent != (SIPTR)data->DisplayArray[1])
251 char **display_array = &data->DisplayArray[2];
252 WORD column;
254 data->display_ptr = useptr;
255 data->DisplayArray[1] = (char *)ent;
257 // set up the string and preparses pointers
258 for(column = 0; column < data->numcols; column++)
260 display_array[data->cols[column].c->col] = NULL;
261 display_array[data->cols[column].c->col + DISPLAY_ARRAY_MAX] = NULL;
263 if(useptr != NULL)
265 display_array[0] = useptr;
267 if(ent < 0 || ent >= data->NList_Entries)
268 useptr = NULL;
270 // invoke the display method
271 // if this method is not catched by a subclass our own implementation will
272 // correctly choose one of the two possible hook functions as default
273 data->DisplayArray[0] = (char *)useptr;
274 DoMethod(data->this, MUIM_NList_Display, data->DisplayArray[0], data->DisplayArray[1], &data->DisplayArray[2], &data->DisplayArray[2+DISPLAY_ARRAY_MAX]);
276 data->parse_column = -1;
279 LEAVE();
283 void ParseColumn(struct NLData *data,WORD column,IPTR mypen)
285 struct colinfo *cinfo = data->cols[column].c;
286 struct affinfo *afinfo;
287 char *ptr1,*ptr2,*ptro,*ptrs;
288 char **display_array = &data->DisplayArray[2];
289 IPTR pen;
290 LONG col,ent = data->parse_ent,maxlen = 300;
291 WORD ni,style,do_format,prep,dx,there_is_char;
292 WORD tmppos = 0;
293 LONG numimg = 0; // RHP: Added for Special ShortHelp
294 int good = 1;
296 /* if (data->parse_column == column) return;*/
298 data->parse_column = column;
299 col = NL_ColumnToCol(data,column);
301 there_is_char = 0;
302 prep = 2;
304 do_format = TRUE;
305 cinfo->style = 0;
307 ni = 0;
308 afinfo = &data->aff_infos[ni];
310 pen = mypen;
311 style = 0;
312 afinfo->len = 0;
314 if ((ent >= 0) && data->EntriesArray[ent]->Wrap)
315 { UBYTE colmask = (UBYTE) ((1 << col) & TE_Wrap_TmpMask);
316 if (data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine)
317 { prep = 0;
318 if (data->EntriesArray[ent]->Wrap & colmask)
319 { tmppos = data->EntriesArray[ent]->pos;
320 cinfo->style = style = data->EntriesArray[ent]->style;
321 if (IS_FIXPEN(style))
322 pen = (IPTR)data->EntriesArray[ent]->Entry;
323 if (data->EntriesArray[ent]->len >= 0)
324 maxlen = data->EntriesArray[ent]->len;
326 else
327 maxlen = 0;
329 else if (data->EntriesArray[ent]->Wrap & colmask)
330 { cinfo->style = style = data->EntriesArray[ent]->style;
331 if (data->EntriesArray[ent]->len >= 0)
332 maxlen = data->EntriesArray[ent]->len;
335 ptrs = ptr1 = display_array[cinfo->col];
337 while ((prep>=0) && NeedAffInfo(data,ni+1))
339 if ((prep == 1) && !display_array[cinfo->col+DISPLAY_ARRAY_MAX])
340 prep = 0;
341 if (prep == 2)
342 { ptr1 = cinfo->preparse;
343 ptrs = ptr1 + PREPARSE_OFFSET_COL;
345 //$$$WRAPCHANGE1
346 ptr2 = ptr1 + 100;
347 //ptr2 = ptr1 + 120;
349 else if (prep == 1)
350 { ptr1 = display_array[cinfo->col+DISPLAY_ARRAY_MAX];
351 ptrs = ptr1 + PREPARSE_OFFSET_ENTRY;
353 //$$$WRAPCHANGE1
354 ptr2 = ptr1 + 100;
355 //ptr2 = ptr1 + 120;
357 else if ((ent >= 0) && (data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine))
358 { ptrs = ptr1 = display_array[cinfo->col];
359 ptr1 += tmppos;
360 ptr2 = ptr1 + maxlen;
362 else
363 { ptrs = ptr1 = display_array[cinfo->col];
364 ptr2 = ptr1 + maxlen;
367 if (afinfo->len > 0)
368 { ni++;
369 afinfo = &data->aff_infos[ni];
371 afinfo->pen = pen;
372 afinfo->len = 0;
373 afinfo->addchar = 0;
374 afinfo->addinfo = 0;
375 afinfo->button = -1;
376 afinfo->imgnum = -1; // RHP: Added for Special ShortHelp
377 afinfo->style = style;
378 afinfo->strptr = ptr1;
379 afinfo->pos = (WORD) (ptr1 - ptrs);
381 //D(bug( "%ld - Setting aff info %ld: %15.15s - pos: %ld, len: %ld, style: %ld.\n", __LINE__, ni, afinfo->strptr, afinfo->pos, afinfo->len, afinfo->style ));
383 while (ptr1 && (ptr1<ptr2) && (ptr1[0] != '\0') && (ptr1[0] != '\n') && (ptr1[0] != '\r') && (good = NeedAffInfo(data,ni+2)))
385 if (data->NList_SkipChars)
386 { char *sc = data->NList_SkipChars;
387 while (sc[0] && (sc[0] != ptr1[0]))
388 sc++;
389 if (sc[0])
391 if (afinfo->len > 0)
392 { ni++;
393 afinfo = &data->aff_infos[ni];
395 ptr1++;
396 afinfo->pen = pen;
397 afinfo->len = 0;
398 afinfo->addchar = 0;
399 afinfo->addinfo = 0;
400 afinfo->button = -1;
401 afinfo->imgnum = -1; // RHP: Added for Special ShortHelp
402 afinfo->style = style;
403 afinfo->strptr = ptr1;
404 afinfo->pos = (WORD) (ptr1 - ptrs);
406 //D(bug( "%ld - Setting aff info %ld: %15.15s - pos: %ld, len: %ld, style: %ld.\n", __LINE__, ni, afinfo->strptr, afinfo->pos, afinfo->len, afinfo->style ));
408 continue;
411 if (do_format && (ptr1[0] == '\033'))
413 ptro = ptr1;
414 ptr1++;
416 //$$$WRAPADD1
417 //ptr2 += 2;
419 if (ptr1[0] == 'c')
420 { SET_ALIGN_CENTER(cinfo->style); SET_ALIGN_CENTER(style); ptr1++; }
421 else if (ptr1[0] == 'r')
422 { SET_ALIGN_RIGHT(cinfo->style); SET_ALIGN_RIGHT(style); ptr1++; }
423 else if (ptr1[0] == 'l')
424 { SET_ALIGN_LEFT(cinfo->style); SET_ALIGN_LEFT(style); ptr1++; }
425 else if (ptr1[0] == 'j')
426 { SET_ALIGN_JUSTIFY(cinfo->style); SET_ALIGN_JUSTIFY(style); ptr1++; }
427 else if (ptr1[0] == 'u')
428 { SET_STYLE_UNDERLINE(style); ptr1++; }
429 else if (ptr1[0] == 'b')
430 { SET_STYLE_BOLD(style); ptr1++; }
431 else if (ptr1[0] == 'i')
432 { SET_STYLE_ITALIC(style); ptr1++; }
433 else if (ptr1[0] == 'n')
434 { SET_STYLE_NORMAL(style); ptr1++; }
435 else if (ptr1[0] == '-')
436 { do_format = FALSE; ptr1++; }
437 else if (ptr1[0] == '2')
438 { if (data->SHOW) { pen = _dri(data->this)->dri_Pens[2]; SET_FIXPEN(style); } ptr1++; }
439 else if (ptr1[0] == '3')
440 { if (data->SHOW) { pen = _dri(data->this)->dri_Pens[3]; SET_FIXPEN(style); } ptr1++; }
441 else if (ptr1[0] == '4')
442 { if (data->SHOW) { pen = _dri(data->this)->dri_Pens[4]; SET_FIXPEN(style); } ptr1++; }
443 else if (ptr1[0] == '5')
444 { if (data->SHOW) { pen = _dri(data->this)->dri_Pens[5]; SET_FIXPEN(style); } ptr1++; }
445 else if (ptr1[0] == '6')
446 { if (data->SHOW) { pen = _dri(data->this)->dri_Pens[6]; SET_FIXPEN(style); } ptr1++; }
447 else if (ptr1[0] == '7')
448 { if (data->SHOW) { pen = _dri(data->this)->dri_Pens[7]; SET_FIXPEN(style); } ptr1++; }
449 else if (ptr1[0] == '8')
450 { if (data->SHOW) { pen = _dri(data->this)->dri_Pens[8]; SET_FIXPEN(style); } ptr1++; }
451 else if (ptr1[0] == '9')
452 { if (data->SHOW) { pen = _dri(data->this)->dri_Pens[9]; SET_FIXPEN(style); } ptr1++; }
453 else if (ptr1[0] == 'T')
454 { SET_HLINE_T(cinfo->style); SET_HLINE_T(style); ptr1++; }
455 else if (ptr1[0] == 'C')
456 { SET_HLINE_C(cinfo->style); SET_HLINE_C(style); ptr1++; }
457 else if (ptr1[0] == 'B')
458 { SET_HLINE_B(cinfo->style); SET_HLINE_B(style); ptr1++; }
459 else if (ptr1[0] == 'E')
460 { SET_HLINE_E(cinfo->style); SET_HLINE_E(style); ptr1++; }
461 else if (ptr1[0] == 't')
462 { SET_HLINE_thick(cinfo->style);
463 SET_HLINE_thick(style);
464 if (muiRenderInfo(data->this) && _pens(data->this))
465 data->HLINE_thick_pen = MUIPEN(_pens(data->this)[MPEN_FILL]);
466 else
467 data->HLINE_thick_pen = 3;
468 ptr1++;
469 if (ptr1[0] == '[')
470 { long np = 1;
471 long np2 = 1;
472 long pnum;
473 if (ptr1[np] == 'N')
474 { SET_HLINE_nothick(cinfo->style);
475 SET_HLINE_nothick(style);
476 if (muiRenderInfo(data->this) && _pens(data->this))
477 data->HLINE_thick_pen = MUIPEN(_pens(data->this)[MPEN_SHADOW]);
478 else
479 data->HLINE_thick_pen = 1;
480 np = np2 = 2;
482 if ((ptr1[np2] == 'M') || (ptr1[np2] == 'I'))
483 np++;
485 while ((ptr1[np] != '\0') && (ptr1[np] != '\n') && (ptr1[np] != '\r') && (ptr1[np] != ']'))
486 np++;
487 if (ptr1[np] == ']')
489 if (np == np2)
492 else if (ptr1[np2] == 'M')
494 pnum = atol(&ptr1[np2+1]);
495 if ((pnum >= 0) && (pnum <= 8) && muiRenderInfo(data->this) && _pens(data->this))
496 data->HLINE_thick_pen = MUIPEN(_pens(data->this)[pnum]);
498 else if (ptr1[np2] == 'I')
500 pnum = atol(&ptr1[np2+1]);
501 if ((pnum >= 0) && (pnum <= 11))
503 if (pnum >= 9)
504 pnum = 2;
505 if ((pnum >= 0) && muiRenderInfo(data->this) && _dri(data->this) && _dri(data->this)->dri_Pens)
506 data->HLINE_thick_pen = _dri(data->this)->dri_Pens[pnum];
509 else if (np < 8)
510 data->HLINE_thick_pen = atol(&ptr1[np2]);
511 ptr1 = &ptr1[np+1];
513 //$$$WRAPADD1
514 //ptr2 += np+1;
518 else if (ptr1[0] == 'P')
520 ptr1++;
521 if (ptr1[0] == '[')
523 long np = 1;
525 while ((ptr1[np] != '\0') && (ptr1[np] != '\n') && (ptr1[np] != '\r') && (ptr1[np] != ']'))
526 np++;
527 if (ptr1[np] == ']')
529 if (np == 1)
531 pen = mypen;
532 SET_NOFIXPEN(style);
534 else if (np < 8)
536 pen = atol(&ptr1[1]);
537 SET_FIXPEN(style);
539 ptr1 = &ptr1[np+1];
541 //$$$WRAPADD1
542 //ptr2 += np+1;
546 else if (ptr1[0] == 'I')
548 ptr1++;
549 if (ptr1[0] == '[')
551 LONG dx = -1, dy = -1;
552 LONG minx = -1, button = -1;
553 ULONG tag=0L, tagval=0L;
554 size_t np = 1;
556 // skip everything until we find the final closing brace
557 while(ptr1[np] != '\0' && ptr1[np] != ']')
558 np++;
560 if(ptr1[np] == ']')
562 if (afinfo->len > 0)
563 { ni++;
564 afinfo = &data->aff_infos[ni];
566 afinfo->tag = tag;
567 afinfo->tagval = tagval;
568 afinfo->button = button;
569 afinfo->imgnum = -1; // RHP: Added for Special ShortHelp
570 afinfo->addchar = 0;
571 afinfo->addinfo = 0;
572 afinfo->style = STYLE_IMAGE;
573 strlcpy(data->imagebuf, &ptr1[1], MIN(np, sizeof(data->imagebuf)));
574 afinfo->pos = (WORD) (ptro - ptrs);
575 D(DBF_DRAW, "image spec '%s' tag %ld, tagval %ld, button %08lx, dx %ld, dy %ld, minx %ld", data->imagebuf, tag, tagval, button, dx, dy, minx);
576 if (data->imagebuf[0] == '\0')
577 afinfo->strptr = NULL;
578 else
579 afinfo->strptr = (APTR) GetNImage(data,data->imagebuf);
580 if (afinfo->strptr)
581 { if (dx <= 0)
582 dx = ((struct NImgList *) afinfo->strptr)->width;
583 if (dy < 0)
584 dy = ((struct NImgList *) afinfo->strptr)->height;
586 if (dx < 0)
587 dx = 0;
588 if (dy <= 0)
589 dy = data->vinc;
590 if (minx < dx)
591 minx = dx;
592 afinfo->len = minx;
593 afinfo->pen = ((dy & 0x0000FFFF) << 16) + (dx & 0x0000FFFF);
595 //D(bug( "%ld - Setting aff info %ld: %15.15s - pos: %ld, len: %ld, style: %ld.\n", __LINE__, ni, afinfo->strptr, afinfo->pos, afinfo->len, afinfo->style ));
597 if (afinfo->strptr || (data->imagebuf[0] == '\0')) {
598 ptr1 = &ptr1[np+1];
600 //$$$WRAPADD1
601 //ptr2 += np+1;
606 else if ((ptr1[0] == 'O') || (ptr1[0] == 'o'))
608 char imgtype = ptr1[0];
609 ptr1++;
610 if (ptr1[0] == '[')
612 LONG dy,dy2 = -2;
613 LONG minx = -1,minx2 = -1,button = -1;
614 ULONG tag=0L,tagval=0L;
615 long np = 1;
617 dx = -1;
618 dy = -1;
619 while ((ptr1[np] != '\0') && (ptr1[np] != '\n') && (ptr1[np] != '\r') && (ptr1[np] != ']') && (ptr1[np] != ';') && (ptr1[np] != '|') && (ptr1[np] != ',') && (ptr1[np] != '@'))
620 np++;
621 if (ptr1[np] == '@')
622 { np++;
623 button = atol(&ptr1[np]);
624 while ((ptr1[np] != '\0') && (ptr1[np] != '\n') && (ptr1[np] != '\r') && (ptr1[np] != ']') && (ptr1[np] != ';') && (ptr1[np] != '|') && (ptr1[np] != ','))
625 np++;
627 while (ptr1[np] == ';')
628 { np++;
629 if (!tag)
630 tag = strtoul(&ptr1[np],NULL,16);
631 else
632 tagval = strtoul(&ptr1[np],NULL,16);
633 while ((ptr1[np] != '\0') && (ptr1[np] != '\n') && (ptr1[np] != '\r') && (ptr1[np] != ']') && (ptr1[np] != ';') && (ptr1[np] != ','))
634 np++;
636 if (ptr1[np] == ',')
637 { np++;
638 minx2 = minx = atol(&ptr1[np]);
639 while ((ptr1[np] != '\0') && (ptr1[np] != '\n') && (ptr1[np] != '\r') && (ptr1[np] != ']') && (ptr1[np] != '|'))
640 np++;
642 if (ptr1[np] == '|')
643 { np++;
644 if ((ptr1[np] != '\0') && (ptr1[np] != '\n') && (ptr1[np] != '\r') && (ptr1[np] != '|') && (ptr1[np] != ']') && (ptr1[np] != ','))
645 dx = atol(&ptr1[np]);
646 while ((ptr1[np] != '\0') && (ptr1[np] != '\n') && (ptr1[np] != '\r') && (ptr1[np] != '|') && (ptr1[np] != ']') && (ptr1[np] != ','))
647 np++;
648 if (ptr1[np] == '|')
649 { np++;
650 if ((ptr1[np] != '\0') && (ptr1[np] != '\n') && (ptr1[np] != '\r') && (ptr1[np] != ']') && (ptr1[np] != ','))
651 dy2 = dy = atol(&ptr1[np]);
652 while ((ptr1[np] != '\0') && (ptr1[np] != '\n') && (ptr1[np] != '\r') && (ptr1[np] != ']') && (ptr1[np] != ','))
653 np++;
656 if (ptr1[np] == ',')
658 np++;
659 minx2 = minx = atol(&ptr1[np]);
660 while ((ptr1[np] != '\0') && (ptr1[np] != '\n') && (ptr1[np] != '\r') && (ptr1[np] != ']'))
661 np++;
663 if (ptr1[np] == ']')
665 struct BitMapImage *bitmapimage = NULL;
666 LONG dx2;
668 if (imgtype == 'O')
669 bitmapimage = (struct BitMapImage *) strtoul(&ptr1[1],NULL,16);
670 else
672 numimg = atol(&ptr1[1]); // RHP: Changed for Special ShortHelp
673 if ((numimg >= 0) && (numimg < data->LastImage) && data->NList_UseImages)
674 bitmapimage = data->NList_UseImages[numimg].bmimg;
676 if (bitmapimage != NULL && (bitmapimage->control == MUIA_Image_Spec))
678 if (afinfo->len > 0)
680 ni++;
681 afinfo = &data->aff_infos[ni];
683 afinfo->tag = tag;
684 afinfo->tagval = tagval;
685 afinfo->button = button;
686 afinfo->imgnum = numimg; // RHP: Added for Special ShortHelp
687 afinfo->addchar = 0;
688 afinfo->addinfo = 0;
689 afinfo->style = STYLE_IMAGE;
690 afinfo->strptr = (APTR) GetNImage2(data,bitmapimage->obtainpens);
691 afinfo->pos = (WORD) (ptro - ptrs);
692 if ((afinfo->strptr) && !(((struct NImgList *) afinfo->strptr)->NImgObj))
693 afinfo->strptr = NULL;
694 dx2 = dx;
695 if (afinfo->strptr)
697 if (dx <= 0)
698 dx = ((struct NImgList *) afinfo->strptr)->width;
699 if (dy < 0)
700 dy = ((struct NImgList *) afinfo->strptr)->height;
702 if (dx < 0)
703 dx = 0;
704 if ((dy2 != -1) && ((dy <= 0) || ((minx2 >= 0) && (dx2 == -1))))
705 dy = data->vinc;
706 if (minx < dx)
707 minx = dx;
708 if ((dx < minx) && (minx2 >= 0) && (dx2 == -1))
709 dx = minx;
710 afinfo->len = minx;
711 afinfo->pen = ((dy & 0x0000FFFF) << 16) + (dx & 0x0000FFFF);
713 D(DBF_DRAW, "Setting aff info %ld: %15.15s - pos: %ld, len: %ld, style: %ld", ni, afinfo->strptr, afinfo->pos, afinfo->len, afinfo->style);
715 ptr1 = &ptr1[np+1];
717 //$$$WRAPADD1
718 //ptr2 += np+1;
720 else
722 if (bitmapimage == NULL || (bitmapimage->control != MUIM_NList_CreateImage))
723 bitmapimage = NULL;
725 if (bitmapimage != NULL || (minx > 0))
727 if (afinfo->len > 0)
729 ni++;
730 afinfo = &data->aff_infos[ni];
732 if (bitmapimage)
734 dx = bitmapimage->width;
735 if (dx <= 0)
736 dx = 1;
737 if ((dy > bitmapimage->height) || (dy < 0))
738 dy = bitmapimage->height;
739 else if (dy == 0)
740 dy = data->vinc;
742 if (minx < dx)
743 minx = dx;
744 afinfo->len = minx;
745 afinfo->addchar = 0;
746 afinfo->addinfo = 0;
747 afinfo->button = -1;
748 afinfo->imgnum = -1; // RHP: Added for Special ShortHelp
749 afinfo->pen = ((dy & 0x0000FFFF) << 16) + (dx & 0x0000FFFF);
750 afinfo->style = STYLE_IMAGE2;
751 afinfo->strptr = (APTR) bitmapimage;
752 afinfo->pos = (WORD) (ptro - ptrs);
754 //D(bug( "%ld - Setting aff info %ld: %15.15s - pos: %ld, len: %ld, style: %ld.\n", __LINE__, ni, afinfo->strptr, afinfo->pos, afinfo->len, afinfo->style ));
756 ptr1 = &ptr1[np+1];
758 //$$$WRAPADD1
759 //ptr2 += np+1;
764 else
765 ptr1++;
767 if (afinfo->len > 0)
769 ni++;
770 afinfo = &data->aff_infos[ni];
772 afinfo->pen = pen;
773 afinfo->len = 0;
774 afinfo->addchar = 0;
775 afinfo->addinfo = 0;
776 afinfo->button = -1;
777 afinfo->imgnum = -1; // RHP: Added for Special ShortHelp
778 afinfo->style = style;
779 afinfo->strptr = ptr1;
780 afinfo->pos = (WORD) (ptr1 - ptrs);
782 //D(bug( "%ld - Setting aff info %ld: %15.15s - pos: %ld, len: %ld, style: %ld.\n", __LINE__, ni, afinfo->strptr, afinfo->pos, afinfo->len, afinfo->style ));
784 else if ((ptr1[0] == '\t' && (data->NList_IgnoreSpecialChars == NULL || strchr(data->NList_IgnoreSpecialChars, '\t') == 0)) ||
785 (((unsigned char)ptr1[0]) == 0xA0 && (data->NList_IgnoreSpecialChars == NULL || strchr(data->NList_IgnoreSpecialChars, 0xa0) == 0)))
787 there_is_char = 1;
788 if (afinfo->len > 0)
789 { ni++;
790 afinfo = &data->aff_infos[ni];
792 afinfo->pen = pen;
793 afinfo->addchar = 0;
794 afinfo->addinfo = 0;
795 afinfo->button = -1;
796 afinfo->imgnum = -1; // RHP: Added for Special ShortHelp
797 afinfo->strptr = ptr1;
798 afinfo->pos = (WORD) (ptr1 - ptrs);
799 if (ptr1[0] == '\t')
800 { afinfo->style = STYLE_TAB;
801 afinfo->len = 1;
803 else if (((unsigned char)ptr1[0]) == 0xA0)
804 { afinfo->style = STYLE_FIXSPACE;
805 afinfo->len = data->spacesize;
807 else
808 { afinfo->style = STYLE_SPACE;
809 afinfo->len = data->spacesize;
812 //D(bug( "%ld - Setting aff info %ld: %15.15s - pos: %ld, len: %ld, style: %ld.\n", __LINE__, ni, afinfo->strptr, afinfo->pos, afinfo->len, afinfo->style ));
814 ni++;
815 afinfo = &data->aff_infos[ni];
817 ptr1++;
818 afinfo->pen = pen;
819 afinfo->len = 0;
820 afinfo->addchar = 0;
821 afinfo->addinfo = 0;
822 afinfo->button = -1;
823 afinfo->imgnum = -1; // RHP: Added for Special ShortHelp
824 afinfo->style = style;
825 afinfo->strptr = ptr1;
826 afinfo->pos = (WORD) (ptr1 - ptrs);
828 //D(bug( "%ld - Setting aff info %ld: %15.15s - pos: %ld, len: %ld, style: %ld.\n", __LINE__, ni, afinfo->strptr, afinfo->pos, afinfo->len, afinfo->style ));
830 else
831 { there_is_char = 1;
832 afinfo->len += 1;
833 ptr1++;
836 prep--;
838 if (!there_is_char && IS_HLINE_E(style))
839 { SET_HLINE_C(cinfo->style); SET_HLINE_C(style); }
840 cinfo->ninfo = ni;
841 if (NeedAffInfo(data,ni+1))
842 { ni++;
843 afinfo = &data->aff_infos[ni];
845 afinfo->pen = pen;
846 afinfo->style = style;
847 afinfo->button = -1;
848 afinfo->imgnum = -1; // RHP: Added for Special ShortHelp
849 afinfo->len = 0;
850 afinfo->pos = (WORD) (ptr1 - ptrs);
852 //D(bug( "%ld - Setting aff info %ld: %15.15s - pos: %ld, len: %ld, style: %ld.\n", __LINE__, ni, afinfo->strptr, afinfo->pos, afinfo->len, afinfo->style ));
857 static void ParseColumns(struct NLData *data,LONG ent)
859 WORD column;
861 NL_GetDisplayArray(data,ent);
862 for (column = 0;column < data->numcols;column++)
863 { if (DontDoColumn(data,ent,column))
864 continue;
865 ParseColumn(data,column,0);
870 * void OneParseColumns(Object *obj,struct NLData *data,LONG ent)
872 * if ((ent >= -1) && (ent < data->NList_Entries))
874 * if (!data->do_parse || data->NList_Quiet || data->NList_Disabled)
875 * return;
876 * if (data->SETUP)
877 * { if (data->adding_member != 2)
878 * data->adding_member = 1;
880 * else
881 * data->adding_member = 3;
882 * data->parse_column = -1;
883 * ParseColumns(obj,data,ent);
884 * data->parse_column = -1;
885 * GetNImage_End(data);
886 * data->do_parse = FALSE;
891 void AllParseColumns(struct NLData *data)
893 LONG ent;
894 if (!data->do_parse || data->NList_Quiet || data->NList_Disabled)
895 return;
896 if (data->SETUP)
897 { if (data->adding_member != 2)
898 data->adding_member = 1;
900 else
901 data->adding_member = 3;
902 data->do_images = TRUE;
903 data->display_ptr = NULL;
904 data->parse_column = -1;
905 if (data->NList_Title)
906 ParseColumns(data,-1);
907 for (ent = 0;ent < data->NList_Entries;ent++)
908 ParseColumns(data,ent);
909 data->display_ptr = NULL;
910 data->parse_column = -1;
911 GetImages(data);
912 data->do_parse = FALSE;
916 static WORD AddSpaceInfos(struct NLData *data,WORD column,WORD ni1)
918 struct colinfo *cinfo = data->cols[column].c;
919 struct affinfo *afinfo;
920 WORD curlen,ni,ni2;
921 WORD numinfo = 0;
922 char *str;
924 if (!data->DRAW || data->do_setcols)
925 return (numinfo);
927 ni2 = cinfo->ninfo;
928 ni = ni1; afinfo = &data->aff_infos[ni];
929 while ((ni <= cinfo->ninfo) && (afinfo->len > 0))
930 { if (!(afinfo->style & STYLE_STRMASK))
931 { str = (char *) afinfo->strptr;
932 curlen = 0;
933 while ((curlen < afinfo->len) && (str[curlen] != ' '))
934 curlen++;
935 curlen++;
936 if ((curlen < afinfo->len) && NeedAffInfo(data,cinfo->ninfo+1))
937 { ni2 = cinfo->ninfo++;
938 while (ni2 >= ni)
939 { data->aff_infos[ni2+1].strptr = data->aff_infos[ni2].strptr;
940 data->aff_infos[ni2+1].pen = data->aff_infos[ni2].pen;
941 data->aff_infos[ni2+1].len = data->aff_infos[ni2].len;
942 data->aff_infos[ni2+1].style = data->aff_infos[ni2].style;
943 data->aff_infos[ni2+1].pos = data->aff_infos[ni2].pos;
944 data->aff_infos[ni2+1].addchar = data->aff_infos[ni2].addchar;
945 data->aff_infos[ni2+1].addinfo = data->aff_infos[ni2].addinfo;
946 ni2--;
948 afinfo->len = curlen;
950 ni++; afinfo = &data->aff_infos[ni];
952 afinfo->len -= curlen;
953 afinfo->strptr = &str[curlen];
954 afinfo->pos += curlen;
955 numinfo++;
957 else
959 ni++; afinfo = &data->aff_infos[ni];
962 else
964 ni++; afinfo = &data->aff_infos[ni];
967 return (numinfo);
971 void WidthColumn(struct NLData *data,WORD column,WORD updinfo)
973 struct colinfo *cinfo = data->cols[column].c;
974 struct affinfo *afinfo;
975 WORD curlen,ni,ni1;
976 WORD numchar = 0;
977 WORD numinfo = 0;
978 WORD colwidth;
979 struct TextExtent te;
980 BOOL text_last = FALSE;
981 BOOL is_text = FALSE;
983 if (!data->SETUP)
984 { if (updinfo)
985 { cinfo->colwidthbiggest = -2;
986 cinfo->colwidthbiggest2 = -2;
987 cinfo->colwidthbiggestptr = -2;
988 cinfo->colwidthbiggestptr2 = -2;
989 if (cinfo->userwidth == -1)
990 data->do_setcols = TRUE;
991 data->do_images = TRUE;
993 return;
996 ReSetFont;
998 curlen = 0;
1000 ni1 = 0;
1001 ni = 0;
1002 afinfo = &data->aff_infos[ni];
1004 while ((ni <= cinfo->ninfo) && (afinfo->len > 0))
1005 { numinfo++;
1006 text_last = FALSE;
1007 if (afinfo->style == STYLE_IMAGE)
1008 curlen += afinfo->len + 2;
1009 else if (afinfo->style == STYLE_IMAGE2)
1010 curlen += afinfo->len + 2;
1011 else if (afinfo->style == STYLE_TAB)
1012 { curlen = ((((curlen-1) / data->tabsize) + 1) * data->tabsize) + 1;
1013 numchar = 0;
1014 numinfo = 0;
1015 ni1 = ni;
1017 else if ((afinfo->style == STYLE_FIXSPACE) || (afinfo->style == STYLE_SPACE))
1018 { curlen += afinfo->len;
1019 numchar++;
1020 is_text = TRUE;
1022 else
1023 { SetSoftStyle(data->rp, GET_STYLE(afinfo->style), STYLE_MASK);
1024 TextExtent(data->rp, afinfo->strptr, afinfo->len, &te);
1025 curlen += te.te_Width;
1026 if ((ni == 0) && (te.te_Extent.MinX < 0))
1027 curlen -= te.te_Extent.MinX;
1028 numchar += afinfo->len;
1029 text_last = TRUE;
1030 is_text = TRUE;
1032 ni++;
1033 afinfo = &data->aff_infos[ni];
1035 if (is_text)
1036 { if (text_last && (te.te_Extent.MaxX > te.te_Width))
1037 curlen += (te.te_Extent.MaxX - te.te_Width);
1038 curlen += 2;
1039 cinfo->colwidth = curlen;
1041 cinfo->colwidth = curlen;
1042 SetSoftStyle(data->rp, 0, STYLE_MASK);
1044 if (!data->DRAW || data->do_setcols)
1045 cinfo->xoffset = 0;
1046 else if (IS_ALIGN_CENTER(cinfo->style))
1047 cinfo->xoffset = (cinfo->dx - cinfo->colwidth)/2;
1048 else if (IS_ALIGN_RIGHT(cinfo->style))
1049 cinfo->xoffset = cinfo->dx - 1 - cinfo->colwidth;
1050 else if (IS_ALIGN_JUSTIFY(cinfo->style))
1051 { WORD diff = cinfo->dx - 1 - cinfo->colwidth;
1052 cinfo->xoffset = 0;
1053 if (diff > 0)
1054 { UBYTE addchar = 0;
1055 UBYTE addinfo = 0;
1056 BOOL cont = TRUE;
1057 if ((numchar > 0) && (numinfo > 0))
1058 numinfo += AddSpaceInfos(data,column,ni1);
1059 numinfo--;
1060 while (cont)
1061 { cont = FALSE;
1062 if ((diff > numinfo) && (numinfo > 0))
1063 { addinfo++;
1064 diff -= numinfo;
1065 cont = TRUE;
1067 if ((diff > numinfo) && (numinfo > 0))
1068 { addinfo++;
1069 diff -= numinfo;
1070 cont = TRUE;
1072 if ((diff > numchar) && (numchar > 0) && (addchar < data->hinc/3) && (addchar < data->spacesize))
1073 { addchar++;
1074 diff -= numchar;
1075 cont = TRUE;
1077 if ((diff > numinfo) && (numinfo > 0))
1078 { addinfo++;
1079 diff -= numinfo;
1080 cont = TRUE;
1082 if ((diff > numchar) && (numchar > 0) && (addchar < data->hinc/3) && (addchar < data->spacesize))
1083 { addchar++;
1084 diff -= numchar;
1085 cont = TRUE;
1088 if ((addchar > 0) || (addinfo > 0) || (diff > 0))
1089 { ni = ni1; afinfo = &data->aff_infos[ni];
1090 while ((ni <= cinfo->ninfo) && (afinfo->len > 0))
1091 { afinfo->addchar = addchar;
1092 if (ni < cinfo->ninfo)
1093 { afinfo->addinfo = addinfo;
1094 if (diff > 0)
1095 { diff--;
1096 afinfo->addinfo++;
1099 ni++; afinfo = &data->aff_infos[ni];
1102 cinfo->colwidth += (numchar * addchar) + (numinfo * addinfo);
1105 else
1106 cinfo->xoffset = 0;
1107 if (cinfo->xoffset < 0)
1108 cinfo->xoffset = 0;
1109 colwidth = cinfo->colwidth + 2;
1110 if ((data->parse_ent == -1) &&
1111 (((data->NList_TitleMark & MUIV_NList_TitleMark_TypeMask) != MUIV_NList_TitleMark_None) ||
1112 ((data->NList_TitleMark2 & MUIV_NList_TitleMark2_TypeMask) != MUIV_NList_TitleMark2_None)))
1113 colwidth += 3;
1115 if (colwidth > cinfo->colwidthmax)
1116 cinfo->colwidthmax = colwidth;
1118 if (updinfo)
1120 if (updinfo == 1)
1122 if ((colwidth > cinfo->colwidthbiggest) && (cinfo->colwidthbiggest >= -1))
1123 { cinfo->colwidthbiggest2 = cinfo->colwidthbiggest;
1124 cinfo->colwidthbiggestptr2 = cinfo->colwidthbiggestptr;
1125 cinfo->colwidthbiggest = colwidth;
1126 cinfo->colwidthbiggestptr = (IPTR) data->display_ptr;
1127 if (((cinfo->width == -1) || (cinfo->minwidth == -1)) && (cinfo->userwidth == -1))
1128 data->do_setcols = TRUE;
1130 else if ((colwidth > cinfo->colwidthbiggest2) && (cinfo->colwidthbiggest2 >= -1))
1131 { cinfo->colwidthbiggest2 = colwidth;
1132 cinfo->colwidthbiggestptr2 = (SIPTR) data->display_ptr;
1135 else
1137 if (((colwidth > cinfo->colwidthbiggest) && (cinfo->colwidthbiggest >= -1)) ||
1138 (cinfo->colwidthbiggestptr == (SIPTR) data->display_ptr))
1140 cinfo->colwidthbiggestptr = cinfo->colwidthbiggestptr2;
1141 cinfo->colwidthbiggest = cinfo->colwidthbiggest2;
1142 cinfo->colwidthbiggestptr2 = -2;
1143 cinfo->colwidthbiggest2 = -2;
1144 if (((cinfo->width == -1) || (cinfo->minwidth == -1)) && (cinfo->userwidth == -1))
1145 { if (cinfo->colwidthbiggest < 0)
1146 { cinfo->colwidthbiggestptr = -2;
1147 cinfo->colwidthbiggest = -2;
1149 data->do_setcols = TRUE;
1152 else if ((IPTR)cinfo->colwidthbiggestptr2 == (IPTR) data->display_ptr)
1154 cinfo->colwidthbiggest2 = -2;
1155 cinfo->colwidthbiggestptr2 = -2;
1162 void FindCharInColumn(struct NLData *data,LONG ent,WORD column,WORD xoffset,WORD *charxoffset,WORD *charnum)
1164 struct colinfo *cinfo = data->cols[column].c;
1165 struct affinfo *afinfo;
1166 WORD curx,curx2,ni;
1167 struct TextExtent te;
1169 if (DontDoColumn(data,ent,column) || !data->DRAW || data->do_setcols)
1170 { *charnum = -1;
1171 *charxoffset = xoffset;
1172 return;
1175 NL_GetDisplayArray(data,ent);
1176 ParseColumn(data,column,0);
1177 WidthColumn(data,column,0);
1179 curx = cinfo->xoffset;
1181 ni = 0;
1182 afinfo = &data->aff_infos[ni];
1184 if (xoffset < curx)
1185 { *charnum = -1;
1186 *charxoffset = xoffset - curx;
1187 return;
1189 while ((ni <= cinfo->ninfo) && (afinfo->len > 0))
1190 { curx2 = curx;
1191 if (afinfo->style == STYLE_IMAGE)
1192 { curx += afinfo->len + afinfo->addinfo + 2;
1193 if (xoffset < curx)
1194 { *charnum = afinfo->pos;
1195 *charxoffset = xoffset - curx2;
1196 if (*charxoffset > afinfo->len/2)
1197 *charxoffset = xoffset - curx;
1198 if (data->storebutton && ((LONG)afinfo->button >= 0))
1200 data->affimage = afinfo->imgnum; // RHP: Added for Special Shorthelp
1201 data->affbutton = afinfo->button;
1202 data->affbuttonline = ent;
1203 data->affbuttoncol = column;
1204 data->affbuttonstate = 0;
1205 data->storebutton = FALSE;
1207 return;
1210 else if (afinfo->style == STYLE_IMAGE2)
1211 { curx += afinfo->len + afinfo->addinfo + 2;
1212 if (xoffset < curx)
1213 { *charnum = afinfo->pos;
1214 *charxoffset = xoffset - curx2;
1215 if (*charxoffset > afinfo->len/2)
1216 *charxoffset = xoffset - curx;
1217 if (data->storebutton && ((LONG)afinfo->button >= 0))
1219 data->affimage = afinfo->imgnum; // RHP: Added for Special Shorthelp
1220 data->affbutton = afinfo->button;
1221 data->affbuttonline = ent;
1222 data->affbuttoncol = column;
1223 data->affbuttonstate = 0;
1224 data->storebutton = FALSE;
1226 return;
1229 else if (afinfo->style == STYLE_TAB)
1230 { curx = ((((curx-cinfo->xoffset) / data->tabsize) + 1) * data->tabsize) + cinfo->xoffset;
1231 if (xoffset < curx)
1232 { *charnum = afinfo->pos;
1233 *charxoffset = xoffset - curx2;
1234 if (*charxoffset > curx - xoffset)
1235 *charxoffset = xoffset - curx;
1236 return;
1239 else if ((afinfo->style == STYLE_FIXSPACE) || (afinfo->style == STYLE_SPACE))
1240 { curx += afinfo->len + afinfo->addinfo + afinfo->addchar;
1241 if (xoffset < curx)
1242 { *charnum = afinfo->pos;
1243 *charxoffset = xoffset - curx2;
1244 if (*charxoffset > afinfo->len/2)
1245 *charxoffset = xoffset - curx;
1246 return;
1249 else
1250 { SetSoftStyle(data->rp, GET_STYLE(afinfo->style), STYLE_MASK);
1251 data->rp->TxSpacing = afinfo->addchar;
1252 TextExtent(data->rp, afinfo->strptr, afinfo->len, &te);
1253 curx += te.te_Width + afinfo->addinfo;
1254 if ((ni == 0) && (te.te_Extent.MinX < 0))
1255 { curx -= te.te_Extent.MinX;
1256 curx2 -= te.te_Extent.MinX;
1258 if (xoffset < curx)
1259 { WORD curx3 = curx2;
1260 char *strptr;
1261 WORD pos = 0;
1262 strptr = (char *) afinfo->strptr;
1263 while (pos < afinfo->len)
1264 { curx2 = curx3;
1265 TextExtent(data->rp, &strptr[pos], 1, &te);
1266 curx3 += te.te_Width;
1267 if (xoffset < curx3)
1268 { *charnum = afinfo->pos + pos;
1269 *charxoffset = xoffset - curx2;
1270 if (*charxoffset > curx3 - xoffset)
1271 *charxoffset = xoffset - curx3;
1272 data->rp->TxSpacing = 0;
1273 return;
1275 pos++;
1277 *charnum = afinfo->pos + pos;
1278 *charxoffset = xoffset - curx;
1279 data->rp->TxSpacing = 0;
1280 return;
1282 data->rp->TxSpacing = 0;
1284 ni++;
1285 afinfo = &data->aff_infos[ni];
1287 SetSoftStyle(data->rp, 0, STYLE_MASK);
1288 *charnum = -1;
1289 *charxoffset = xoffset - curx;
1293 static LONG NL_DoWrapLine(struct NLData *data,LONG ent,BOOL force)
1295 struct colinfo *cinfo;
1296 struct affinfo *afinfo;
1297 struct TextExtent te;
1298 LONG ent1 = ent,selects,column,col = 0;
1299 WORD curlen,endpos,ni,colwidth,style;
1300 UWORD dnum = 0;
1301 IPTR pen;
1302 UBYTE colmask;
1304 if (!data->SHOW)
1305 return (ent+1);
1307 if ((ent < 0) || !data->EntriesArray[ent]->Wrap ||
1308 (data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine))
1309 return (ent+1);
1311 if ((data->EntriesArray[ent]->len >= 0) && !force && (data->EntriesArray[ent1]->dnum > 0))
1313 ent += data->EntriesArray[ent1]->dnum;
1314 return (ent);
1317 colmask = data->EntriesArray[ent]->Wrap & TE_Wrap_TmpMask;
1318 while((colmask = colmask >> 1))
1319 col++;
1320 column = NL_ColToColumn(data,col);
1322 if (data->EntriesArray[ent]->len < 0)
1323 selects = data->EntriesArray[ent]->pos;
1324 else
1325 selects = NL_GetSelects(data,ent);
1327 data->EntriesArray[ent]->PixLen = -1;
1328 data->EntriesArray[ent]->Wrap &= TE_Wrap_TmpMask;
1329 data->EntriesArray[ent]->pos = (WORD) selects;
1330 data->EntriesArray[ent]->len = -1;
1331 data->EntriesArray[ent]->dnum = 1;
1332 if (((selects & 0x0001) && data->multiselect) || ((ent == data->NList_Active) && (data->multiselect == MUIV_NList_MultiSelect_None)))
1333 data->EntriesArray[ent]->Select = TE_Select_Line;
1334 else
1335 data->EntriesArray[ent]->Select = TE_Select_None;
1337 if ((column < 0) || (column >= data->numcols))
1338 return (ent+1);
1340 data->EntriesArray[ent]->pos = 0;
1342 cinfo = data->cols[column].c;
1343 /*colwidth = cinfo->colwidth;*/
1344 colwidth = cinfo->dx - 4;
1345 if (colwidth < 3*data->hinc)
1346 colwidth = 3*data->hinc;
1348 colmask = data->EntriesArray[ent]->Wrap | TE_Wrap_TmpLine;
1350 ReSetFont;
1352 pen = 1;
1353 style = data->EntriesArray[ent]->style;
1355 while (TRUE)
1357 data->EntriesArray[ent]->len = -1;
1358 NL_GetDisplayArray(data,ent);
1359 ParseColumn(data,column,pen);
1360 NL_Changed(data,ent);
1361 ni = 0;
1362 afinfo = &data->aff_infos[ni];
1364 curlen = 0;
1365 endpos = -1;
1367 while ((ni <= cinfo->ninfo) && (afinfo->len > 0))
1369 if (curlen > colwidth)
1370 break;
1371 if (afinfo->style == STYLE_IMAGE)
1372 curlen += afinfo->len + 2;
1373 else if (afinfo->style == STYLE_IMAGE2)
1374 curlen += afinfo->len + 2;
1375 else if (afinfo->style == STYLE_TAB)
1377 pen = afinfo->pen;
1378 curlen = ((((curlen-1) / data->tabsize) + 1) * data->tabsize) + 1;
1379 if ((curlen > colwidth) && (ni > 0) && (ni < cinfo->ninfo))
1381 ni++;
1382 afinfo = &data->aff_infos[ni];
1383 break;
1386 else if ((afinfo->style == STYLE_FIXSPACE) || (afinfo->style == STYLE_SPACE))
1388 pen = afinfo->pen;
1389 curlen += afinfo->len;
1390 if ((curlen > colwidth) && (ni > 0) && (ni < cinfo->ninfo))
1392 ni++;
1393 afinfo = &data->aff_infos[ni];
1394 break;
1397 else
1399 WORD clen = afinfo->len;
1400 WORD blanklen = clen;
1401 WORD oldcurlen,difflen;
1402 char *strptr;
1404 strptr = (char *) afinfo->strptr;
1405 pen = afinfo->pen;
1406 style = afinfo->style;
1407 SetSoftStyle(data->rp, GET_STYLE(style), STYLE_MASK);
1408 TextExtent(data->rp, strptr, clen, &te);
1409 if ((ni == 0) && (te.te_Extent.MinX < 0))
1410 curlen -= te.te_Extent.MinX;
1411 oldcurlen = curlen;
1412 curlen += te.te_Width;
1413 if (te.te_Extent.MaxX > te.te_Width)
1414 difflen = te.te_Extent.MaxX - te.te_Width;
1415 else
1416 difflen = 0;
1417 if ((clen > 0) && ((curlen + difflen) >= colwidth))
1419 if (afinfo->pos < 0)
1421 afinfo->pos = 0;
1422 afinfo->len = 0;
1423 break;
1425 curlen += difflen;
1426 while ((clen > 0) && (curlen >= colwidth))
1428 clen--;
1429 while ((clen > 0) && (strptr[clen] != ' '))
1430 clen--;
1431 if (clen > 0)
1432 blanklen = clen;
1433 else if (clen <= 0)
1434 break;
1435 TextExtent(data->rp, strptr, clen, &te);
1436 if (te.te_Extent.MaxX > te.te_Width)
1437 curlen = oldcurlen + te.te_Extent.MaxX;
1438 else
1439 curlen = oldcurlen + te.te_Width;
1441 if ((clen <= 0) && (ni == 0) && (blanklen > 0))
1443 clen = blanklen;
1444 TextExtent(data->rp, strptr, clen, &te);
1445 if (te.te_Extent.MaxX > te.te_Width)
1446 curlen = oldcurlen + te.te_Extent.MaxX;
1447 else
1448 curlen = oldcurlen + te.te_Width;
1449 while ((clen > 0) && (curlen >= colwidth))
1451 clen--;
1452 if (clen <= 0)
1453 break;
1454 TextExtent(data->rp, strptr, clen, &te);
1455 if (te.te_Extent.MaxX > te.te_Width)
1456 curlen = oldcurlen + te.te_Extent.MaxX;
1457 else
1458 curlen = oldcurlen + te.te_Width;
1460 afinfo->pos += clen;
1462 else
1464 endpos = afinfo->pos + clen;
1465 if (clen > 0)
1466 afinfo->pos += (clen + 1);
1468 break;
1472 if ((curlen > colwidth) && (ni > 0))
1473 break;
1474 ni++;
1475 afinfo = &data->aff_infos[ni];
1478 if (afinfo->pos <= 0)
1479 data->EntriesArray[ent]->len = 0;
1480 else if (endpos >= 0)
1481 data->EntriesArray[ent]->len = endpos - data->EntriesArray[ent]->pos;
1482 else
1483 data->EntriesArray[ent]->len = afinfo->pos - data->EntriesArray[ent]->pos;
1485 dnum++;
1487 if ((ni > cinfo->ninfo) || (afinfo->len <= 0) || (afinfo->pos < 0))
1489 if (IS_ALIGN_JUSTIFY(data->EntriesArray[ent]->style))
1491 SET_ALIGN_LEFT(data->EntriesArray[ent]->style);
1493 ent++;
1494 break;
1496 else
1497 ent++;
1499 if ((ent >= data->NList_Entries) || !(data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine))
1501 if (!NL_InsertTmpLine(data,ent))
1502 break;
1505 if (dnum <= 15)
1506 selects = selects >> 1;
1507 if (((selects & 0x0001) && data->multiselect) || ((ent == data->NList_Active) && (data->multiselect == MUIV_NList_MultiSelect_None)))
1508 data->EntriesArray[ent]->Select = TE_Select_Line;
1509 else
1510 data->EntriesArray[ent]->Select = TE_Select_None;
1511 data->EntriesArray[ent]->PixLen = -1;
1512 data->EntriesArray[ent]->Wrap = colmask;
1513 data->EntriesArray[ent]->pos = afinfo->pos;
1514 data->EntriesArray[ent]->len = -2;
1515 data->EntriesArray[ent]->style = style;
1516 data->EntriesArray[ent]->Entry = (APTR)pen;
1517 data->EntriesArray[ent]->dnum = dnum;
1519 data->EntriesArray[ent1]->dnum = dnum;
1520 SetSoftStyle(data->rp, 0, STYLE_MASK);
1521 while ((ent < data->NList_Entries) && (data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine))
1522 NL_DeleteTmpLine(data,ent);
1524 return (ent);
1528 void NL_DoWrapAll(struct NLData *data,BOOL force,BOOL update)
1530 LONG entorig = data->NList_Entries;
1531 LONG ent = 0;
1533 if (!data->do_wwrap || !data->EntriesArray || data->do_setcols)
1534 return;
1535 else if (!data->SHOW || !data->DRAW || data->NList_Quiet || data->NList_Disabled)
1537 LONG len = -1;
1539 while (ent < data->NList_Entries)
1541 if (data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine)
1543 if (len < 0)
1544 data->EntriesArray[ent]->len = -2;
1546 else if (data->EntriesArray[ent]->Wrap)
1547 len = data->EntriesArray[ent]->len;
1548 else
1549 len = 0;
1550 ent++;
1552 return;
1554 else if (!data->DRAW)
1555 return;
1557 if (data->force_wwrap)
1558 force = TRUE;
1560 while (ent < data->NList_Entries)
1562 if (data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine)
1564 NL_DeleteTmpLine(data,ent);
1565 NL_SegChanged(data,ent,data->NList_Entries);
1566 data->do_draw = TRUE;
1568 else if (data->EntriesArray[ent]->Wrap)
1570 if ((data->EntriesArray[ent]->len < 0) || force || (data->EntriesArray[ent]->dnum < 1))
1572 ent = NL_DoWrapLine(data,ent,force);
1573 if (data->NList_Entries != entorig)
1574 NL_SegChanged(data,ent,data->NList_Entries);
1575 data->do_draw = TRUE;
1577 else
1578 ent += data->EntriesArray[ent]->dnum;
1580 else
1581 ent++;
1583 if (data->NList_Entries != entorig)
1585 data->do_updatesb = TRUE;
1586 DO_NOTIFY(NTF_Entries|NTF_MinMax);
1588 if ((data->NList_First > 0) && (data->NList_First + data->NList_Visible >= data->NList_Entries))
1590 data->NList_First = data->NList_Entries - data->NList_Visible;
1591 if (data->NList_First < 0)
1592 data->NList_First = 0;
1593 DO_NOTIFY(NTF_First);
1595 data->do_wwrap = data->force_wwrap = FALSE;
1596 if (update)
1598 data->do_updatesb = TRUE;
1599 REDRAW;
1600 /* do_notifies(NTF_AllChanges|NTF_MinMax);*/
1605 static void WidthColumns(struct NLData *data,LONG ent,WORD updinfo)
1607 WORD column;
1609 //D(bug( "%ld - Calling NL_GDA() width %ld entries!\n", __LINE__, ent ));
1611 /* sba: was > 1 but in this case the images weren't parsed */
1612 if ( data->numcols > 0 )
1614 NL_GetDisplayArray(data,ent);
1616 for (column = 0;column < data->numcols;column++) /* sba: was (data->numcols-1) */
1617 { if (DontDoColumn(data,ent,column))
1618 continue;
1619 if (updinfo != 2)
1620 ParseColumn(data,column,0);
1621 if (data->SHOW)
1622 WidthColumn(data,column,updinfo);
1628 void AllWidthColumns(struct NLData *data)
1630 LONG ent;
1631 WORD column;
1634 ** We must omit this, because floattext will be broken if not.
1636 //if ( data->numcols > 1 )
1638 data->display_ptr = NULL;
1639 data->parse_column = -1;
1640 for (column = 0;column < data->numcols;column++)
1641 //for (column = 0;column < ( data->numcols - 1 );column++)
1642 { data->cols[column].c->colwidthmax = 4;
1643 data->cols[column].c->dx = 4;
1645 if (data->NList_Title)
1646 WidthColumns(data,-1,0);
1647 if (data->EntriesArray)
1648 { for (ent = 0;ent < data->NList_Entries;ent++)
1649 WidthColumns(data,ent,0);
1651 data->display_ptr = NULL;
1652 data->parse_column = -1;
1657 void NL_SetColsAdd(struct NLData *data,LONG ent,WORD addimages)
1659 WORD column;
1661 //if ( !data->NList_Pause )
1663 if (data->SETUP)
1664 { if (data->adding_member != 2)
1665 data->adding_member = 1;
1667 else
1668 data->adding_member = 3;
1670 data->display_ptr = NULL;
1671 data->parse_column = -1;
1672 if ((ent == -2) || (ent == -3))
1673 { for (column = 0;column < data->numcols;column++)
1674 { data->cols[column].c->colwidthbiggest = -1;
1675 data->cols[column].c->colwidthbiggest2 = -1;
1676 data->cols[column].c->colwidthbiggestptr = -2;
1677 data->cols[column].c->colwidthbiggestptr2 = -2;
1678 data->cols[column].c->colwidthmax = 4;
1679 data->cols[column].c->dx = 4;
1680 data->Title_PixLen = -1;
1681 if (((data->cols[column].c->width == -1) || (data->cols[column].c->minwidth == -1)) && (data->cols[column].c->userwidth == -1))
1682 data->do_setcols = TRUE;
1685 if (data->NList_Title)
1686 WidthColumns(data,-1,1);
1688 if (data->EntriesArray)
1690 if (ent == -2 )
1692 for (ent = 0;ent < data->NList_Entries;ent++)
1693 WidthColumns(data,ent,1);
1695 else /* -3 == Recalculate only visible (cs@aphaso.de) */
1697 for (ent = data->NList_First; ent < ( data->NList_First + data->NList_Visible ); ent++ )
1698 WidthColumns(data,ent,1);
1701 data->display_ptr = NULL;
1702 data->parse_column = -1;
1704 else
1706 //D(bug( "%ld - Calling WidthColumns() width entry %ld!\n", __LINE__, ent ));
1707 if (data->SETUP != 3)
1708 WidthColumns(data,ent,1);
1711 if (addimages)
1712 GetNImage_End(data);
1713 else
1714 data->do_images = TRUE;
1715 if (!data->SHOW)
1716 data->do_setcols = TRUE;
1721 void NL_SetColsRem(struct NLData *data,LONG ent)
1723 WORD column;
1725 //if ( !data->NList_Pause )
1727 if (!data->SHOW || (ent == -2))
1728 { data->parse_column = -1;
1729 data->display_ptr = NULL;
1730 for (column = 0;column < data->numcols;column++)
1731 { data->cols[column].c->colwidthbiggest = -1;
1732 data->cols[column].c->colwidthbiggest2 = -1;
1733 data->cols[column].c->colwidthbiggestptr = -2;
1734 data->cols[column].c->colwidthbiggestptr2 = -2;
1735 data->cols[column].c->colwidthmax = 4;
1736 data->cols[column].c->dx = 4;
1737 data->Title_PixLen = -1;
1738 if (((data->cols[column].c->width == -1) || (data->cols[column].c->minwidth == -1)) && (data->cols[column].c->userwidth == -1))
1739 data->do_setcols = TRUE;
1741 if (!data->SHOW)
1742 data->do_setcols = TRUE;
1744 else
1746 //D(bug( "%ld - Calling WidthColumns() width entry %ld!\n", __LINE__, ent ));
1748 if (data->SETUP != 3)
1749 WidthColumns(data,ent,2);
1751 if (ent == -1)
1752 data->Title_PixLen = -1;