Merging NList MCC 0.119 into the main branch.
[AROS.git] / workbench / classes / zune / nlist / nlist_mcc / NList_mcc4.c
blob4579757e44e4f1184ae370aea1e20100f08b26b6
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
958 ni++; afinfo = &data->aff_infos[ni];
960 else
961 ni++; afinfo = &data->aff_infos[ni];
963 return (numinfo);
967 void WidthColumn(struct NLData *data,WORD column,WORD updinfo)
969 struct colinfo *cinfo = data->cols[column].c;
970 struct affinfo *afinfo;
971 WORD curlen,ni,ni1;
972 WORD numchar = 0;
973 WORD numinfo = 0;
974 WORD colwidth;
975 struct TextExtent te;
976 BOOL text_last = FALSE;
977 BOOL is_text = FALSE;
979 if (!data->SETUP)
980 { if (updinfo)
981 { cinfo->colwidthbiggest = -2;
982 cinfo->colwidthbiggest2 = -2;
983 cinfo->colwidthbiggestptr = -2;
984 cinfo->colwidthbiggestptr2 = -2;
985 if (cinfo->userwidth == -1)
986 data->do_setcols = TRUE;
987 data->do_images = TRUE;
989 return;
992 ReSetFont;
994 curlen = 0;
996 ni1 = 0;
997 ni = 0;
998 afinfo = &data->aff_infos[ni];
1000 while ((ni <= cinfo->ninfo) && (afinfo->len > 0))
1001 { numinfo++;
1002 text_last = FALSE;
1003 if (afinfo->style == STYLE_IMAGE)
1004 curlen += afinfo->len + 2;
1005 else if (afinfo->style == STYLE_IMAGE2)
1006 curlen += afinfo->len + 2;
1007 else if (afinfo->style == STYLE_TAB)
1008 { curlen = ((((curlen-1) / data->tabsize) + 1) * data->tabsize) + 1;
1009 numchar = 0;
1010 numinfo = 0;
1011 ni1 = ni;
1013 else if ((afinfo->style == STYLE_FIXSPACE) || (afinfo->style == STYLE_SPACE))
1014 { curlen += afinfo->len;
1015 numchar++;
1016 is_text = TRUE;
1018 else
1019 { SetSoftStyle(data->rp, GET_STYLE(afinfo->style), STYLE_MASK);
1020 TextExtent(data->rp, afinfo->strptr, afinfo->len, &te);
1021 curlen += te.te_Width;
1022 if ((ni == 0) && (te.te_Extent.MinX < 0))
1023 curlen -= te.te_Extent.MinX;
1024 numchar += afinfo->len;
1025 text_last = TRUE;
1026 is_text = TRUE;
1028 ni++;
1029 afinfo = &data->aff_infos[ni];
1031 if (is_text)
1032 { if (text_last && (te.te_Extent.MaxX > te.te_Width))
1033 curlen += (te.te_Extent.MaxX - te.te_Width);
1034 curlen += 2;
1035 cinfo->colwidth = curlen;
1037 cinfo->colwidth = curlen;
1038 SetSoftStyle(data->rp, 0, STYLE_MASK);
1040 if (!data->DRAW || data->do_setcols)
1041 cinfo->xoffset = 0;
1042 else if (IS_ALIGN_CENTER(cinfo->style))
1043 cinfo->xoffset = (cinfo->dx - cinfo->colwidth)/2;
1044 else if (IS_ALIGN_RIGHT(cinfo->style))
1045 cinfo->xoffset = cinfo->dx - 1 - cinfo->colwidth;
1046 else if (IS_ALIGN_JUSTIFY(cinfo->style))
1047 { WORD diff = cinfo->dx - 1 - cinfo->colwidth;
1048 cinfo->xoffset = 0;
1049 if (diff > 0)
1050 { UBYTE addchar = 0;
1051 UBYTE addinfo = 0;
1052 BOOL cont = TRUE;
1053 if ((numchar > 0) && (numinfo > 0))
1054 numinfo += AddSpaceInfos(data,column,ni1);
1055 numinfo--;
1056 while (cont)
1057 { cont = FALSE;
1058 if ((diff > numinfo) && (numinfo > 0))
1059 { addinfo++;
1060 diff -= numinfo;
1061 cont = TRUE;
1063 if ((diff > numinfo) && (numinfo > 0))
1064 { addinfo++;
1065 diff -= numinfo;
1066 cont = TRUE;
1068 if ((diff > numchar) && (numchar > 0) && (addchar < data->hinc/3) && (addchar < data->spacesize))
1069 { addchar++;
1070 diff -= numchar;
1071 cont = TRUE;
1073 if ((diff > numinfo) && (numinfo > 0))
1074 { addinfo++;
1075 diff -= numinfo;
1076 cont = TRUE;
1078 if ((diff > numchar) && (numchar > 0) && (addchar < data->hinc/3) && (addchar < data->spacesize))
1079 { addchar++;
1080 diff -= numchar;
1081 cont = TRUE;
1084 if ((addchar > 0) || (addinfo > 0) || (diff > 0))
1085 { ni = ni1; afinfo = &data->aff_infos[ni];
1086 while ((ni <= cinfo->ninfo) && (afinfo->len > 0))
1087 { afinfo->addchar = addchar;
1088 if (ni < cinfo->ninfo)
1089 { afinfo->addinfo = addinfo;
1090 if (diff > 0)
1091 { diff--;
1092 afinfo->addinfo++;
1095 ni++; afinfo = &data->aff_infos[ni];
1098 cinfo->colwidth += (numchar * addchar) + (numinfo * addinfo);
1101 else
1102 cinfo->xoffset = 0;
1103 if (cinfo->xoffset < 0)
1104 cinfo->xoffset = 0;
1105 colwidth = cinfo->colwidth + 2;
1106 if ((data->parse_ent == -1) &&
1107 (((data->NList_TitleMark & MUIV_NList_TitleMark_TypeMask) != MUIV_NList_TitleMark_None) ||
1108 ((data->NList_TitleMark2 & MUIV_NList_TitleMark2_TypeMask) != MUIV_NList_TitleMark2_None)))
1109 colwidth += 3;
1111 if (colwidth > cinfo->colwidthmax)
1112 cinfo->colwidthmax = colwidth;
1114 if (updinfo)
1116 if (updinfo == 1)
1118 if ((colwidth > cinfo->colwidthbiggest) && (cinfo->colwidthbiggest >= -1))
1119 { cinfo->colwidthbiggest2 = cinfo->colwidthbiggest;
1120 cinfo->colwidthbiggestptr2 = cinfo->colwidthbiggestptr;
1121 cinfo->colwidthbiggest = colwidth;
1122 cinfo->colwidthbiggestptr = (IPTR) data->display_ptr;
1123 if (((cinfo->width == -1) || (cinfo->minwidth == -1)) && (cinfo->userwidth == -1))
1124 data->do_setcols = TRUE;
1126 else if ((colwidth > cinfo->colwidthbiggest2) && (cinfo->colwidthbiggest2 >= -1))
1127 { cinfo->colwidthbiggest2 = colwidth;
1128 cinfo->colwidthbiggestptr2 = (SIPTR) data->display_ptr;
1131 else
1133 if (((colwidth > cinfo->colwidthbiggest) && (cinfo->colwidthbiggest >= -1)) ||
1134 (cinfo->colwidthbiggestptr == (SIPTR) data->display_ptr))
1136 cinfo->colwidthbiggestptr = cinfo->colwidthbiggestptr2;
1137 cinfo->colwidthbiggest = cinfo->colwidthbiggest2;
1138 cinfo->colwidthbiggestptr2 = -2;
1139 cinfo->colwidthbiggest2 = -2;
1140 if (((cinfo->width == -1) || (cinfo->minwidth == -1)) && (cinfo->userwidth == -1))
1141 { if (cinfo->colwidthbiggest < 0)
1142 { cinfo->colwidthbiggestptr = -2;
1143 cinfo->colwidthbiggest = -2;
1145 data->do_setcols = TRUE;
1148 else if ((IPTR)cinfo->colwidthbiggestptr2 == (IPTR) data->display_ptr)
1150 cinfo->colwidthbiggest2 = -2;
1151 cinfo->colwidthbiggestptr2 = -2;
1158 void FindCharInColumn(struct NLData *data,LONG ent,WORD column,WORD xoffset,WORD *charxoffset,WORD *charnum)
1160 struct colinfo *cinfo = data->cols[column].c;
1161 struct affinfo *afinfo;
1162 WORD curx,curx2,ni;
1163 struct TextExtent te;
1165 if (DontDoColumn(data,ent,column) || !data->DRAW || data->do_setcols)
1166 { *charnum = -1;
1167 *charxoffset = xoffset;
1168 return;
1171 NL_GetDisplayArray(data,ent);
1172 ParseColumn(data,column,0);
1173 WidthColumn(data,column,0);
1175 curx = cinfo->xoffset;
1177 ni = 0;
1178 afinfo = &data->aff_infos[ni];
1180 if (xoffset < curx)
1181 { *charnum = -1;
1182 *charxoffset = xoffset - curx;
1183 return;
1185 while ((ni <= cinfo->ninfo) && (afinfo->len > 0))
1186 { curx2 = curx;
1187 if (afinfo->style == STYLE_IMAGE)
1188 { curx += afinfo->len + afinfo->addinfo + 2;
1189 if (xoffset < curx)
1190 { *charnum = afinfo->pos;
1191 *charxoffset = xoffset - curx2;
1192 if (*charxoffset > afinfo->len/2)
1193 *charxoffset = xoffset - curx;
1194 if (data->storebutton && ((LONG)afinfo->button >= 0))
1196 data->affimage = afinfo->imgnum; // RHP: Added for Special Shorthelp
1197 data->affbutton = afinfo->button;
1198 data->affbuttonline = ent;
1199 data->affbuttoncol = column;
1200 data->affbuttonstate = 0;
1201 data->storebutton = FALSE;
1203 return;
1206 else if (afinfo->style == STYLE_IMAGE2)
1207 { curx += afinfo->len + afinfo->addinfo + 2;
1208 if (xoffset < curx)
1209 { *charnum = afinfo->pos;
1210 *charxoffset = xoffset - curx2;
1211 if (*charxoffset > afinfo->len/2)
1212 *charxoffset = xoffset - curx;
1213 if (data->storebutton && ((LONG)afinfo->button >= 0))
1215 data->affimage = afinfo->imgnum; // RHP: Added for Special Shorthelp
1216 data->affbutton = afinfo->button;
1217 data->affbuttonline = ent;
1218 data->affbuttoncol = column;
1219 data->affbuttonstate = 0;
1220 data->storebutton = FALSE;
1222 return;
1225 else if (afinfo->style == STYLE_TAB)
1226 { curx = ((((curx-cinfo->xoffset) / data->tabsize) + 1) * data->tabsize) + cinfo->xoffset;
1227 if (xoffset < curx)
1228 { *charnum = afinfo->pos;
1229 *charxoffset = xoffset - curx2;
1230 if (*charxoffset > curx - xoffset)
1231 *charxoffset = xoffset - curx;
1232 return;
1235 else if ((afinfo->style == STYLE_FIXSPACE) || (afinfo->style == STYLE_SPACE))
1236 { curx += afinfo->len + afinfo->addinfo + afinfo->addchar;
1237 if (xoffset < curx)
1238 { *charnum = afinfo->pos;
1239 *charxoffset = xoffset - curx2;
1240 if (*charxoffset > afinfo->len/2)
1241 *charxoffset = xoffset - curx;
1242 return;
1245 else
1246 { SetSoftStyle(data->rp, GET_STYLE(afinfo->style), STYLE_MASK);
1247 data->rp->TxSpacing = afinfo->addchar;
1248 TextExtent(data->rp, afinfo->strptr, afinfo->len, &te);
1249 curx += te.te_Width + afinfo->addinfo;
1250 if ((ni == 0) && (te.te_Extent.MinX < 0))
1251 { curx -= te.te_Extent.MinX;
1252 curx2 -= te.te_Extent.MinX;
1254 if (xoffset < curx)
1255 { WORD curx3 = curx2;
1256 char *strptr;
1257 WORD pos = 0;
1258 strptr = (char *) afinfo->strptr;
1259 while (pos < afinfo->len)
1260 { curx2 = curx3;
1261 TextExtent(data->rp, &strptr[pos], 1, &te);
1262 curx3 += te.te_Width;
1263 if (xoffset < curx3)
1264 { *charnum = afinfo->pos + pos;
1265 *charxoffset = xoffset - curx2;
1266 if (*charxoffset > curx3 - xoffset)
1267 *charxoffset = xoffset - curx3;
1268 data->rp->TxSpacing = 0;
1269 return;
1271 pos++;
1273 *charnum = afinfo->pos + pos;
1274 *charxoffset = xoffset - curx;
1275 data->rp->TxSpacing = 0;
1276 return;
1278 data->rp->TxSpacing = 0;
1280 ni++;
1281 afinfo = &data->aff_infos[ni];
1283 SetSoftStyle(data->rp, 0, STYLE_MASK);
1284 *charnum = -1;
1285 *charxoffset = xoffset - curx;
1289 static LONG NL_DoWrapLine(struct NLData *data,LONG ent,BOOL force)
1291 struct colinfo *cinfo;
1292 struct affinfo *afinfo;
1293 struct TextExtent te;
1294 LONG ent1 = ent,selects,column,col = 0;
1295 WORD curlen,endpos,ni,colwidth,style;
1296 UWORD dnum = 0;
1297 IPTR pen;
1298 UBYTE colmask;
1300 if (!data->SHOW)
1301 return (ent+1);
1303 if ((ent < 0) || !data->EntriesArray[ent]->Wrap ||
1304 (data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine))
1305 return (ent+1);
1307 if ((data->EntriesArray[ent]->len >= 0) && !force && (data->EntriesArray[ent1]->dnum > 0))
1309 ent += data->EntriesArray[ent1]->dnum;
1310 return (ent);
1313 colmask = data->EntriesArray[ent]->Wrap & TE_Wrap_TmpMask;
1314 while((colmask = colmask >> 1))
1315 col++;
1316 column = NL_ColToColumn(data,col);
1318 if (data->EntriesArray[ent]->len < 0)
1319 selects = data->EntriesArray[ent]->pos;
1320 else
1321 selects = NL_GetSelects(data,ent);
1323 data->EntriesArray[ent]->PixLen = -1;
1324 data->EntriesArray[ent]->Wrap &= TE_Wrap_TmpMask;
1325 data->EntriesArray[ent]->pos = (WORD) selects;
1326 data->EntriesArray[ent]->len = -1;
1327 data->EntriesArray[ent]->dnum = 1;
1328 if (((selects & 0x0001) && data->multiselect) || ((ent == data->NList_Active) && (data->multiselect == MUIV_NList_MultiSelect_None)))
1329 data->EntriesArray[ent]->Select = TE_Select_Line;
1330 else
1331 data->EntriesArray[ent]->Select = TE_Select_None;
1333 if ((column < 0) || (column >= data->numcols))
1334 return (ent+1);
1336 data->EntriesArray[ent]->pos = 0;
1338 cinfo = data->cols[column].c;
1339 /*colwidth = cinfo->colwidth;*/
1340 colwidth = cinfo->dx - 4;
1341 if (colwidth < 3*data->hinc)
1342 colwidth = 3*data->hinc;
1344 colmask = data->EntriesArray[ent]->Wrap | TE_Wrap_TmpLine;
1346 ReSetFont;
1348 pen = 1;
1349 style = data->EntriesArray[ent]->style;
1351 while (TRUE)
1353 data->EntriesArray[ent]->len = -1;
1354 NL_GetDisplayArray(data,ent);
1355 ParseColumn(data,column,pen);
1356 NL_Changed(data,ent);
1357 ni = 0;
1358 afinfo = &data->aff_infos[ni];
1360 curlen = 0;
1361 endpos = -1;
1363 while ((ni <= cinfo->ninfo) && (afinfo->len > 0))
1365 if (curlen > colwidth)
1366 break;
1367 if (afinfo->style == STYLE_IMAGE)
1368 curlen += afinfo->len + 2;
1369 else if (afinfo->style == STYLE_IMAGE2)
1370 curlen += afinfo->len + 2;
1371 else if (afinfo->style == STYLE_TAB)
1373 pen = afinfo->pen;
1374 curlen = ((((curlen-1) / data->tabsize) + 1) * data->tabsize) + 1;
1375 if ((curlen > colwidth) && (ni > 0) && (ni < cinfo->ninfo))
1377 ni++;
1378 afinfo = &data->aff_infos[ni];
1379 break;
1382 else if ((afinfo->style == STYLE_FIXSPACE) || (afinfo->style == STYLE_SPACE))
1384 pen = afinfo->pen;
1385 curlen += afinfo->len;
1386 if ((curlen > colwidth) && (ni > 0) && (ni < cinfo->ninfo))
1388 ni++;
1389 afinfo = &data->aff_infos[ni];
1390 break;
1393 else
1395 WORD clen = afinfo->len;
1396 WORD blanklen = clen;
1397 WORD oldcurlen,difflen;
1398 char *strptr;
1400 strptr = (char *) afinfo->strptr;
1401 pen = afinfo->pen;
1402 style = afinfo->style;
1403 SetSoftStyle(data->rp, GET_STYLE(style), STYLE_MASK);
1404 TextExtent(data->rp, strptr, clen, &te);
1405 if ((ni == 0) && (te.te_Extent.MinX < 0))
1406 curlen -= te.te_Extent.MinX;
1407 oldcurlen = curlen;
1408 curlen += te.te_Width;
1409 if (te.te_Extent.MaxX > te.te_Width)
1410 difflen = te.te_Extent.MaxX - te.te_Width;
1411 else
1412 difflen = 0;
1413 if ((clen > 0) && ((curlen + difflen) >= colwidth))
1415 if (afinfo->pos < 0)
1417 afinfo->pos = 0;
1418 afinfo->len = 0;
1419 break;
1421 curlen += difflen;
1422 while ((clen > 0) && (curlen >= colwidth))
1424 clen--;
1425 while ((clen > 0) && (strptr[clen] != ' '))
1426 clen--;
1427 if (clen > 0)
1428 blanklen = clen;
1429 else if (clen <= 0)
1430 break;
1431 TextExtent(data->rp, strptr, clen, &te);
1432 if (te.te_Extent.MaxX > te.te_Width)
1433 curlen = oldcurlen + te.te_Extent.MaxX;
1434 else
1435 curlen = oldcurlen + te.te_Width;
1437 if ((clen <= 0) && (ni == 0) && (blanklen > 0))
1439 clen = blanklen;
1440 TextExtent(data->rp, strptr, clen, &te);
1441 if (te.te_Extent.MaxX > te.te_Width)
1442 curlen = oldcurlen + te.te_Extent.MaxX;
1443 else
1444 curlen = oldcurlen + te.te_Width;
1445 while ((clen > 0) && (curlen >= colwidth))
1447 clen--;
1448 if (clen <= 0)
1449 break;
1450 TextExtent(data->rp, strptr, clen, &te);
1451 if (te.te_Extent.MaxX > te.te_Width)
1452 curlen = oldcurlen + te.te_Extent.MaxX;
1453 else
1454 curlen = oldcurlen + te.te_Width;
1456 afinfo->pos += clen;
1458 else
1460 endpos = afinfo->pos + clen;
1461 if (clen > 0)
1462 afinfo->pos += (clen + 1);
1464 break;
1468 if ((curlen > colwidth) && (ni > 0))
1469 break;
1470 ni++;
1471 afinfo = &data->aff_infos[ni];
1474 if (afinfo->pos <= 0)
1475 data->EntriesArray[ent]->len = 0;
1476 else if (endpos >= 0)
1477 data->EntriesArray[ent]->len = endpos - data->EntriesArray[ent]->pos;
1478 else
1479 data->EntriesArray[ent]->len = afinfo->pos - data->EntriesArray[ent]->pos;
1481 dnum++;
1483 if ((ni > cinfo->ninfo) || (afinfo->len <= 0) || (afinfo->pos < 0))
1485 if (IS_ALIGN_JUSTIFY(data->EntriesArray[ent]->style))
1487 SET_ALIGN_LEFT(data->EntriesArray[ent]->style);
1489 ent++;
1490 break;
1492 else
1493 ent++;
1495 if ((ent >= data->NList_Entries) || !(data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine))
1497 if (!NL_InsertTmpLine(data,ent))
1498 break;
1501 if (dnum <= 15)
1502 selects = selects >> 1;
1503 if (((selects & 0x0001) && data->multiselect) || ((ent == data->NList_Active) && (data->multiselect == MUIV_NList_MultiSelect_None)))
1504 data->EntriesArray[ent]->Select = TE_Select_Line;
1505 else
1506 data->EntriesArray[ent]->Select = TE_Select_None;
1507 data->EntriesArray[ent]->PixLen = -1;
1508 data->EntriesArray[ent]->Wrap = colmask;
1509 data->EntriesArray[ent]->pos = afinfo->pos;
1510 data->EntriesArray[ent]->len = -2;
1511 data->EntriesArray[ent]->style = style;
1512 data->EntriesArray[ent]->Entry = (APTR)pen;
1513 data->EntriesArray[ent]->dnum = dnum;
1515 data->EntriesArray[ent1]->dnum = dnum;
1516 SetSoftStyle(data->rp, 0, STYLE_MASK);
1517 while ((ent < data->NList_Entries) && (data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine))
1518 NL_DeleteTmpLine(data,ent);
1520 return (ent);
1524 void NL_DoWrapAll(struct NLData *data,BOOL force,BOOL update)
1526 LONG entorig = data->NList_Entries;
1527 LONG ent = 0;
1529 if (!data->do_wwrap || !data->EntriesArray || data->do_setcols)
1530 return;
1531 else if (!data->SHOW || !data->DRAW || data->NList_Quiet || data->NList_Disabled)
1533 LONG len = -1;
1535 while (ent < data->NList_Entries)
1537 if (data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine)
1539 if (len < 0)
1540 data->EntriesArray[ent]->len = -2;
1542 else if (data->EntriesArray[ent]->Wrap)
1543 len = data->EntriesArray[ent]->len;
1544 else
1545 len = 0;
1546 ent++;
1548 return;
1550 else if (!data->DRAW)
1551 return;
1553 if (data->force_wwrap)
1554 force = TRUE;
1556 while (ent < data->NList_Entries)
1558 if (data->EntriesArray[ent]->Wrap & TE_Wrap_TmpLine)
1560 NL_DeleteTmpLine(data,ent);
1561 NL_SegChanged(data,ent,data->NList_Entries);
1562 data->do_draw = TRUE;
1564 else if (data->EntriesArray[ent]->Wrap)
1566 if ((data->EntriesArray[ent]->len < 0) || force || (data->EntriesArray[ent]->dnum < 1))
1568 ent = NL_DoWrapLine(data,ent,force);
1569 if (data->NList_Entries != entorig)
1570 NL_SegChanged(data,ent,data->NList_Entries);
1571 data->do_draw = TRUE;
1573 else
1574 ent += data->EntriesArray[ent]->dnum;
1576 else
1577 ent++;
1579 if (data->NList_Entries != entorig)
1581 data->do_updatesb = TRUE;
1582 DO_NOTIFY(NTF_Entries|NTF_MinMax);
1584 if ((data->NList_First > 0) && (data->NList_First + data->NList_Visible >= data->NList_Entries))
1586 data->NList_First = data->NList_Entries - data->NList_Visible;
1587 if (data->NList_First < 0)
1588 data->NList_First = 0;
1589 DO_NOTIFY(NTF_First);
1591 data->do_wwrap = data->force_wwrap = FALSE;
1592 if (update)
1594 data->do_updatesb = TRUE;
1595 REDRAW;
1596 /* do_notifies(NTF_AllChanges|NTF_MinMax);*/
1601 static void WidthColumns(struct NLData *data,LONG ent,WORD updinfo)
1603 WORD column;
1605 //D(bug( "%ld - Calling NL_GDA() width %ld entries!\n", __LINE__, ent ));
1607 /* sba: was > 1 but in this case the images weren't parsed */
1608 if ( data->numcols > 0 )
1610 NL_GetDisplayArray(data,ent);
1612 for (column = 0;column < data->numcols;column++) /* sba: was (data->numcols-1) */
1613 { if (DontDoColumn(data,ent,column))
1614 continue;
1615 if (updinfo != 2)
1616 ParseColumn(data,column,0);
1617 if (data->SHOW)
1618 WidthColumn(data,column,updinfo);
1624 void AllWidthColumns(struct NLData *data)
1626 LONG ent;
1627 WORD column;
1630 ** We must omit this, because floattext will be broken if not.
1632 //if ( data->numcols > 1 )
1634 data->display_ptr = NULL;
1635 data->parse_column = -1;
1636 for (column = 0;column < data->numcols;column++)
1637 //for (column = 0;column < ( data->numcols - 1 );column++)
1638 { data->cols[column].c->colwidthmax = 4;
1639 data->cols[column].c->dx = 4;
1641 if (data->NList_Title)
1642 WidthColumns(data,-1,0);
1643 if (data->EntriesArray)
1644 { for (ent = 0;ent < data->NList_Entries;ent++)
1645 WidthColumns(data,ent,0);
1647 data->display_ptr = NULL;
1648 data->parse_column = -1;
1653 void NL_SetColsAdd(struct NLData *data,LONG ent,WORD addimages)
1655 WORD column;
1657 //if ( !data->NList_Pause )
1659 if (data->SETUP)
1660 { if (data->adding_member != 2)
1661 data->adding_member = 1;
1663 else
1664 data->adding_member = 3;
1666 data->display_ptr = NULL;
1667 data->parse_column = -1;
1668 if ((ent == -2) || (ent == -3))
1669 { for (column = 0;column < data->numcols;column++)
1670 { data->cols[column].c->colwidthbiggest = -1;
1671 data->cols[column].c->colwidthbiggest2 = -1;
1672 data->cols[column].c->colwidthbiggestptr = -2;
1673 data->cols[column].c->colwidthbiggestptr2 = -2;
1674 data->cols[column].c->colwidthmax = 4;
1675 data->cols[column].c->dx = 4;
1676 data->Title_PixLen = -1;
1677 if (((data->cols[column].c->width == -1) || (data->cols[column].c->minwidth == -1)) && (data->cols[column].c->userwidth == -1))
1678 data->do_setcols = TRUE;
1681 if (data->NList_Title)
1682 WidthColumns(data,-1,1);
1684 if (data->EntriesArray)
1686 if (ent == -2 )
1688 for (ent = 0;ent < data->NList_Entries;ent++)
1689 WidthColumns(data,ent,1);
1691 else /* -3 == Recalculate only visible (cs@aphaso.de) */
1693 for (ent = data->NList_First; ent < ( data->NList_First + data->NList_Visible ); ent++ )
1694 WidthColumns(data,ent,1);
1697 data->display_ptr = NULL;
1698 data->parse_column = -1;
1700 else
1702 //D(bug( "%ld - Calling WidthColumns() width entry %ld!\n", __LINE__, ent ));
1703 if (data->SETUP != 3)
1704 WidthColumns(data,ent,1);
1707 if (addimages)
1708 GetNImage_End(data);
1709 else
1710 data->do_images = TRUE;
1711 if (!data->SHOW)
1712 data->do_setcols = TRUE;
1717 void NL_SetColsRem(struct NLData *data,LONG ent)
1719 WORD column;
1721 //if ( !data->NList_Pause )
1723 if (!data->SHOW || (ent == -2))
1724 { data->parse_column = -1;
1725 data->display_ptr = NULL;
1726 for (column = 0;column < data->numcols;column++)
1727 { data->cols[column].c->colwidthbiggest = -1;
1728 data->cols[column].c->colwidthbiggest2 = -1;
1729 data->cols[column].c->colwidthbiggestptr = -2;
1730 data->cols[column].c->colwidthbiggestptr2 = -2;
1731 data->cols[column].c->colwidthmax = 4;
1732 data->cols[column].c->dx = 4;
1733 data->Title_PixLen = -1;
1734 if (((data->cols[column].c->width == -1) || (data->cols[column].c->minwidth == -1)) && (data->cols[column].c->userwidth == -1))
1735 data->do_setcols = TRUE;
1737 if (!data->SHOW)
1738 data->do_setcols = TRUE;
1740 else
1742 //D(bug( "%ld - Calling WidthColumns() width entry %ld!\n", __LINE__, ent ));
1744 if (data->SETUP != 3)
1745 WidthColumns(data,ent,2);
1747 if (ent == -1)
1748 data->Title_PixLen = -1;