1 /***************************************************************************
3 NList.mcc - New List MUI Custom Class
4 Registered MUI class, Serial Number: 1d51 0x9d510030 to 0x9d5100A0
5 0x9d5100C0 to 0x9d5100FF
7 Copyright (C) 1996-2001 by Gilles Masson
8 Copyright (C) 2001-2014 NList Open Source Team
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 NList classes Support Site: http://www.sf.net/projects/nlist-classes
24 ***************************************************************************/
26 #include <clib/alib_protos.h>
27 #include <proto/intuition.h>
31 #include "NList_func.h"
33 // static functions in this file
34 static BOOL
NL_List_Jump(struct NLData
*data
, LONG pos
);
35 static BOOL
NL_List_GetPos(struct NLData
*data
, APTR entry
, LONG
*pos
);
37 /* Extent the selection between ent1 and ent2.
38 Make the first_change and last_change optimal for redrawing optimiztion */
39 void NL_SegChanged(struct NLData
*data
,LONG ent1
,LONG ent2
)
41 // D(bug("ent1=%ld ent2=%ld\n",ent1,ent2));
42 // D(bug("first_change=%ld last_change=%ld\n",data->first_change,data->last_change));
43 if (ent1
< data
->first_change
)
44 { if (ent1
>= data
->NList_First
)
45 { data
->first_change
= ent1
;
46 if (data
->last_change
< data
->first_change
)
47 data
->last_change
= data
->first_change
;
49 else if (ent2
>= data
->NList_First
)
50 { data
->first_change
= data
->NList_First
;
51 if (data
->last_change
< data
->first_change
)
52 data
->last_change
= data
->first_change
;
55 if (ent2
> data
->last_change
)
56 { if (ent2
< data
->NList_First
+data
->NList_Visible
)
57 { data
->last_change
= ent2
;
58 if (data
->first_change
> data
->last_change
)
59 data
->first_change
= data
->last_change
;
61 else if (ent1
< data
->NList_First
+data
->NList_Visible
)
62 { data
->last_change
= data
->NList_First
+data
->NList_Visible
;
63 if (data
->first_change
> data
->last_change
)
64 data
->first_change
= data
->last_change
;
67 // D(bug("NL_SegChanged: first_change=%ld last_change=%ld\n",data->first_change,data->last_change));
70 /* Extent the selection by this entry optimal */
71 void NL_Changed(struct NLData
*data
,LONG ent
)
73 // D(bug("ent=%ld\n",ent));
74 // D(bug("first_change=%ld last_change=%ld\n",data->first_change,data->last_change));
75 if ((ent
< data
->first_change
) && (ent
>= data
->NList_First
))
76 { data
->first_change
= ent
;
77 if (data
->last_change
< data
->first_change
)
78 data
->last_change
= data
->first_change
;
80 if ((ent
> data
->last_change
) && (ent
< data
->NList_First
+data
->NList_Visible
))
81 { data
->last_change
= ent
;
82 if (data
->first_change
> data
->last_change
)
83 data
->first_change
= data
->last_change
;
85 // D(bug("first_change=%ld last_change=%ld\n",data->first_change,data->last_change));
89 void NL_UnSelectAll(struct NLData
*data
,LONG untouch_ent
)
93 DONE_NOTIFY(NTF_Select
| NTF_LV_Select
);
95 while (ent
< data
->NList_Entries
)
96 { if (ent
!= untouch_ent
)
97 { SELECT2_CHGE(ent
,TE_Select_None
);
98 data
->lastselected
= MUIV_NList_Active_Off
;
99 data
->lastactived
= MUIV_NList_Active_Off
;
104 /* do_notifies(NTF_AllChanges|NTF_MinMax);*/
108 void UnSelectCharSel(struct NLData
*data
,BOOL redraw
)
110 if (data
->NList_TypeSelect
&& !data
->UpdatingScrollbars
)
112 if ((data
->sel_pt
[data
->min_sel
].ent
>= 0) && (data
->sel_pt
[data
->max_sel
].ent
>= 0))
113 NL_SegChanged(data
,data
->sel_pt
[data
->min_sel
].ent
,data
->sel_pt
[data
->max_sel
].ent
);
115 data
->sel_pt
[1].ent
= -1;
124 void SelectFirstPoint(struct NLData
*data
,WORD x
,WORD y
)
126 struct MUI_NList_TestPos_Result res
;
127 LONG e1
= data
->sel_pt
[data
->min_sel
].ent
;
128 LONG e1x
= data
->sel_pt
[data
->min_sel
].xoffset
;
129 LONG e2
= data
->sel_pt
[data
->max_sel
].ent
;
130 LONG e2x
= data
->sel_pt
[data
->max_sel
].xoffset
;
132 data
->last_sel_click_x
= x
;
133 data
->last_sel_click_y
= y
;
134 NL_List_TestPos(data
,x
,y
,&res
);
135 if ((res
.column
< 0) || (res
.column
>= data
->numcols
))
137 if ((e1
>= 0) && (e2
>= 0))
138 { if ((e2
> e1
) && (e2x
== PMIN
))
139 NL_SegChanged(data
,e1
,e2
-1);
141 NL_SegChanged(data
,e1
,e2
);
143 if ((data
->NList_TypeSelect
== MUIV_NList_TypeSelect_CLine
) && (res
.entry
>= 0))
145 data
->sel_pt
[2].column
= 0;
146 data
->sel_pt
[2].xoffset
= PMIN
;
147 data
->sel_pt
[2].colpos
= -1;
148 data
->sel_pt
[2].ent
= res
.entry
;
149 data
->sel_pt
[3] = data
->sel_pt
[2];
150 data
->sel_pt
[3].ent
= res
.entry
+1;
151 data
->sel_pt
[0] = data
->sel_pt
[2];
152 data
->sel_pt
[1] = data
->sel_pt
[3];
155 NL_Changed(data
,res
.entry
);
156 data
->minx_change_entry
= res
.entry
;
157 data
->minx_change_offset
= PMIN
;
158 data
->maxx_change_entry
= res
.entry
+1;
159 data
->maxx_change_offset
= PMIN
;
163 * else if ((data->NList_TypeSelect == MUIV_NList_TypeSelect_CWord) && (res.entry >= 0))
165 * data->sel_pt[0].column = res.column;
166 * data->sel_pt[0].xoffset = res.xoffset;
167 * data->sel_pt[0].colpos = res.char_number;
168 * data->sel_pt[0].ent = res.entry;
169 * data->sel_pt[1] = data->sel_pt[0];
172 * if (res.char_number == -1)
173 * { if (res.char_xoffset < 0)
174 * { if (res.column == 0)
175 * { data->sel_pt[0].xoffset = PMIN;
176 * data->sel_pt[1].xoffset += data->cols[res.column].c->minx - res.char_xoffset;
177 * data->sel_pt[1].colpos = 0;
180 * { data->sel_pt[0].xoffset = data->cols[res.column].c->minx;
181 * data->sel_pt[1].xoffset += data->cols[res.column].c->minx - res.char_xoffset;
182 * data->sel_pt[1].colpos = 0;
185 * else if (res.char_xoffset >= 0)
186 * { if (res.column == data->numcols-1)
187 * { data->sel_pt[0].xoffset += data->cols[res.column].c->minx - res.char_xoffset;
188 * data->sel_pt[0].colpos = -2;
189 * data->sel_pt[1].column = 0;
190 * data->sel_pt[1].xoffset = PMIN;
191 * data->sel_pt[1].colpos = -1;
192 * data->sel_pt[1].ent++;
195 * { data->sel_pt[0].xoffset += data->cols[res.column].c->minx - res.char_xoffset;
196 * data->sel_pt[0].colpos = -2;
197 * data->sel_pt[1].xoffset = data->cols[res.column].c->maxx;
198 * data->sel_pt[1].colpos = -2;
204 * data->sel_pt[0].xoffset += data->cols[res.column].c->minx - res.char_xoffset;
205 * data->sel_pt[1].xoffset = data->sel_pt[0].xoffset + data->hinc;
206 * if (res.char_xoffset < 0)
207 * data->sel_pt[0].colpos++;
208 * data->sel_pt[1].colpos = data->sel_pt[0].colpos + 1;
210 * data->sel_pt[2] = data->sel_pt[0];
211 * data->sel_pt[3] = data->sel_pt[1];
213 * NL_Changed(data,res.entry);
214 * data->minx_change_entry = data->sel_pt[0].ent;
215 * data->minx_change_offset = data->sel_pt[0].xoffset;
216 * data->maxx_change_entry = data->sel_pt[1].ent;
217 * data->maxx_change_offset = data->sel_pt[1].xoffset;
222 { if (res
.char_number
== -1)
223 { if (res
.char_xoffset
< 0)
224 { if (res
.column
== 0)
227 res
.xoffset
= data
->cols
[res
.column
].c
->minx
;
229 else if (res
.char_xoffset
>= 0)
230 { if (res
.column
== data
->numcols
-1)
231 { res
.xoffset
= PMAX
; /* when on full right, go full left of next line */
233 // The last releases had these lines while the one above had been commented out.
234 // The problem with these 4 lines is, that the beginning of then next line will
235 // be copied as well if the line is marked until the very right position, which
236 // is definitely wrong (see bugs #1190788 and #1720456). I hope this fix does
237 // not have any other negative side effects.
240 res.char_xoffset = PMIN;
245 res
.xoffset
= data
->cols
[res
.column
].c
->maxx
;
246 res
.char_number
= -2;
250 { res
.xoffset
+= data
->cols
[res
.column
].c
->minx
- res
.char_xoffset
;
251 if (res
.char_xoffset
< 0)
254 data
->sel_pt
[0].column
= res
.column
;
255 data
->sel_pt
[0].xoffset
= res
.xoffset
;
256 data
->sel_pt
[0].colpos
= res
.char_number
;
257 data
->sel_pt
[0].ent
= res
.entry
;
258 data
->sel_pt
[1].ent
= -1;
261 if ((e1
>= 0) && (e2
>= 0))
262 { data
->minx_change_entry
= e1
;
263 data
->minx_change_offset
= e1x
;
264 data
->maxx_change_entry
= e2
;
265 data
->maxx_change_offset
= e2x
;
272 void SelectSecondPoint(struct NLData
*data
,WORD x
,WORD y
)
274 struct MUI_NList_TestPos_Result res
;
275 LONG e1
= data
->sel_pt
[1].ent
;
276 LONG e1x
= data
->sel_pt
[1].xoffset
;
278 data
->last_sel_click_x
= x
;
279 data
->last_sel_click_y
= y
;
281 NL_List_TestPos(data
,x
,y
,&res
);
282 if ((res
.column
< 0) || (res
.column
>= data
->numcols
))
284 if ((data
->NList_TypeSelect
== MUIV_NList_TypeSelect_CLine
) && (res
.entry
>= 0))
285 { data
->sel_pt
[1].column
= 0;
286 data
->sel_pt
[1].xoffset
= PMIN
;
287 data
->sel_pt
[1].colpos
= -1;
290 if (res
.entry
> data
->sel_pt
[2].ent
)
292 data
->sel_pt
[1].ent
= res
.entry
+1;
294 else if (res
.entry
< data
->sel_pt
[2].ent
)
296 data
->sel_pt
[1].ent
= res
.entry
;
302 data
->sel_pt
[1] = data
->sel_pt
[3];
304 data
->sel_pt
[0] = data
->sel_pt
[e3
];
305 e2
= data
->sel_pt
[1].ent
;
307 { if (e1
> e2
) { e3
= e1
; e1
= e2
; e2
= e3
; }
308 data
->minx_change_entry
= e1
;
309 data
->minx_change_offset
= PMIN
;
310 data
->maxx_change_entry
= e2
;
311 data
->maxx_change_offset
= PMIN
;
314 NL_SegChanged(data
,e1
,e2
);
319 * else if ((data->NList_TypeSelect == MUIV_NList_TypeSelect_CWord) && (res.entry >= 0))
321 * LONG e0 = data->sel_pt[0].ent;
322 * LONG e0x = data->sel_pt[0].xoffset;
323 * data->sel_pt[0].column = res.column;
324 * data->sel_pt[0].xoffset = res.xoffset;
325 * data->sel_pt[0].colpos = res.char_number;
326 * data->sel_pt[0].ent = res.entry;
327 * data->sel_pt[1] = data->sel_pt[0];
330 * if (res.char_number == -1)
331 * { if (res.char_xoffset < 0)
332 * { if (res.column == 0)
333 * { data->sel_pt[0].xoffset = PMIN;
334 * data->sel_pt[1].xoffset += data->cols[res.column].c->minx - res.char_xoffset;
335 * data->sel_pt[1].colpos = 0;
338 * { data->sel_pt[0].xoffset = data->cols[res.column].c->minx;
339 * data->sel_pt[1].xoffset += data->cols[res.column].c->minx - res.char_xoffset;
340 * data->sel_pt[1].colpos = 0;
343 * else if (res.char_xoffset >= 0)
344 * { if (res.column == data->numcols-1)
345 * { data->sel_pt[0].xoffset += data->cols[res.column].c->minx - res.char_xoffset;
346 * data->sel_pt[0].colpos = -2;
347 * data->sel_pt[1].column = 0;
348 * data->sel_pt[1].xoffset = PMIN;
349 * data->sel_pt[1].colpos = -1;
350 * data->sel_pt[1].ent++;
353 * { data->sel_pt[0].xoffset += data->cols[res.column].c->minx - res.char_xoffset;
354 * data->sel_pt[0].colpos = -2;
355 * data->sel_pt[1].xoffset = data->cols[res.column].c->maxx;
356 * data->sel_pt[1].colpos = -2;
362 * data->sel_pt[0].xoffset += data->cols[res.column].c->minx - res.char_xoffset;
363 * data->sel_pt[1].xoffset = data->sel_pt[0].xoffset + data->hinc;
364 * if (res.char_xoffset < 0)
365 * data->sel_pt[0].colpos++;
366 * data->sel_pt[1].colpos = data->sel_pt[0].colpos + 1;
369 * if ( (data->sel_pt[0].ent > data->sel_pt[2].ent) ||
370 * ( (data->sel_pt[0].ent == data->sel_pt[2].ent) &&
371 * ( (data->sel_pt[0].column > data->sel_pt[2].column) ||
372 * ( (data->sel_pt[0].column == data->sel_pt[2].column) &&
373 * (data->sel_pt[0].xoffset > data->sel_pt[2].xoffset)
378 * { data->sel_pt[0] = data->sel_pt[2];
379 * if ((e1 < data->sel_pt[1].ent) || (e1x < data->sel_pt[1].xoffset))
380 * { data->minx_change_entry = e1;
381 * data->minx_change_offset = e1x;
382 * data->maxx_change_entry = data->sel_pt[1].ent;
383 * data->maxx_change_offset = data->sel_pt[1].xoffset;
384 * NL_SegChanged(data,e1,data->sel_pt[1].ent);
387 * { data->minx_change_entry = data->sel_pt[1].ent;
388 * data->minx_change_offset = data->sel_pt[1].xoffset;
389 * data->maxx_change_entry = e1;
390 * data->maxx_change_offset = e1x;
391 * NL_SegChanged(data,data->sel_pt[1].ent,e1);
394 * else if ( (data->sel_pt[1].ent < data->sel_pt[3].ent) ||
395 * ( (data->sel_pt[1].ent == data->sel_pt[3].ent) &&
396 * ( (data->sel_pt[1].column < data->sel_pt[3].column) ||
397 * ( (data->sel_pt[1].column == data->sel_pt[3].column) &&
398 * (data->sel_pt[1].xoffset < data->sel_pt[3].xoffset)
403 * { data->sel_pt[1] = data->sel_pt[3];
404 * if ((e0 < data->sel_pt[0].ent) || (e0x < data->sel_pt[0].xoffset))
405 * { data->minx_change_entry = e0;
406 * data->minx_change_offset = e0x;
407 * data->maxx_change_entry = data->sel_pt[0].ent;
408 * data->maxx_change_offset = data->sel_pt[0].xoffset;
409 * NL_SegChanged(data,e0,data->sel_pt[0].ent);
412 * { data->minx_change_entry = data->sel_pt[0].ent;
413 * data->minx_change_offset = data->sel_pt[0].xoffset;
414 * data->maxx_change_entry = e0;
415 * data->maxx_change_offset = e0x;
416 * NL_SegChanged(data,data->sel_pt[0].ent,e0);
422 else if (res
.entry
>= 0)
424 if (res
.char_number
== -1)
425 { if (res
.char_xoffset
< 0)
426 { if (res
.column
== 0)
429 res
.xoffset
= data
->cols
[res
.column
].c
->minx
;
431 else if (res
.char_xoffset
>= 0)
433 if (res
.column
== data
->numcols
-1)
435 res
.xoffset
= PMAX
; /* when on full right, go full left of next line */
437 // before this part was active while the assignment above was inactive
438 // see bugs #1190788 and #1720456
441 res.char_xoffset = PMIN;
446 res
.xoffset
= data
->cols
[res
.column
].c
->maxx
;
447 res
.char_number
= -2;
452 res
.xoffset
+= data
->cols
[res
.column
].c
->minx
- res
.char_xoffset
;
453 if (res
.char_xoffset
< 0)
456 if ((data
->sel_pt
[1].ent
!= res
.entry
) || (data
->sel_pt
[1].column
!= res
.column
) || (data
->sel_pt
[1].xoffset
!= res
.xoffset
))
458 data
->sel_pt
[1].column
= res
.column
;
459 data
->sel_pt
[1].xoffset
= res
.xoffset
;
460 data
->sel_pt
[1].colpos
= res
.char_number
;
461 data
->sel_pt
[1].ent
= res
.entry
;
464 if ( (data
->sel_pt
[0].ent
> data
->sel_pt
[1].ent
) ||
465 ( (data
->sel_pt
[0].ent
== data
->sel_pt
[1].ent
) &&
466 ( (data
->sel_pt
[0].column
> data
->sel_pt
[1].column
) ||
467 ( (data
->sel_pt
[0].column
== data
->sel_pt
[1].column
) &&
468 (data
->sel_pt
[0].xoffset
> data
->sel_pt
[1].xoffset
)
476 else if ((data
->sel_pt
[0].ent
== data
->sel_pt
[1].ent
) &&
477 (data
->sel_pt
[0].column
== data
->sel_pt
[1].column
) &&
478 (data
->sel_pt
[0].xoffset
== data
->sel_pt
[1].xoffset
))
481 data
->sel_pt
[1].ent
= -1;
484 e2
= data
->sel_pt
[1].ent
;
485 e2x
= data
->sel_pt
[1].xoffset
;
487 { e1
= data
->sel_pt
[0].ent
;
488 e1x
= data
->sel_pt
[0].xoffset
;
491 { e2
= data
->sel_pt
[0].ent
;
492 e2x
= data
->sel_pt
[0].xoffset
;
494 if ((e2
< e1
) || ((e2
== e1
) && (e2x
< e1x
)))
495 { e3
= e2
; e2
= e1
; e1
= e3
; e3x
= e2x
; e2x
= e1x
; e1x
= e3x
; }
496 if ((e1
>= 0) && (e2
>= 0))
497 { NL_SegChanged(data
,e1
,e2
);
498 data
->minx_change_entry
= e1
;
499 data
->minx_change_offset
= e1x
;
500 data
->maxx_change_entry
= e2
;
501 data
->maxx_change_offset
= e2x
;
509 BOOL
NL_List_First(struct NLData
*data
,LONG lf
,struct TagItem
*tag
)
512 BOOL scrolled
= FALSE
;
519 if((data
->NList_Entries
> 0) && (lf
!= data
->NList_First
))
523 case MUIV_NList_First_Top
:
527 case MUIV_NList_First_Bottom
:
529 lf
= data
->NList_Entries
- data
->NList_Visible
;
535 case MUIV_NList_First_Up
:
537 lf
= data
->NList_First
- 1;
543 case MUIV_NList_First_Down
:
545 lf
= data
->NList_First
+ 1;
546 if (lf
+ data
->NList_Visible
>= data
->NList_Entries
)
547 lf
= data
->NList_Entries
- data
->NList_Visible
;
553 case MUIV_NList_First_PageUp
:
555 lf
= data
->NList_First
- data
->NList_Visible
+ 1;
561 case MUIV_NList_First_PageDown
:
563 lf
= data
->NList_First
+ data
->NList_Visible
- 1;
564 if (lf
+ data
->NList_Visible
>= data
->NList_Entries
)
565 lf
= data
->NList_Entries
- data
->NList_Visible
;
571 case MUIV_NList_First_Up2
:
573 lf
= data
->NList_First
- 2;
579 case MUIV_NList_First_Down2
:
581 lf
= data
->NList_First
+ 2;
582 if (lf
+ data
->NList_Visible
>= data
->NList_Entries
)
583 lf
= data
->NList_Entries
- data
->NList_Visible
;
589 case MUIV_NList_First_Up4
:
591 lf
= data
->NList_First
- 4;
597 case MUIV_NList_First_Down4
:
599 lf
= data
->NList_First
+ 4;
600 if (lf
+ data
->NList_Visible
>= data
->NList_Entries
)
601 lf
= data
->NList_Entries
- data
->NList_Visible
;
608 if ((lf
>= 0) && (lf
< data
->NList_Entries
))
610 if (data
->NList_First
!= lf
)
612 DO_NOTIFY(NTF_First
);
616 data
->NList_First
= lf
;
618 /* do_notifies(NTF_AllChanges|NTF_MinMax);*/
622 tag
->ti_Tag
= TAG_IGNORE
;
625 tag
->ti_Tag
= TAG_IGNORE
;
632 BOOL
NL_List_Active(struct NLData
*data
, LONG la
, struct TagItem
*tag
, LONG newactsel
, LONG acceptsame
, ULONG flags
)
635 struct TagItem
*tag2
= tag
;
637 BOOL changed
= FALSE
;
641 //D(DBF_STARTUP, "NL_List_Active: 0x%lx la=%ld newactsel=%ld acceptsame=%ld data->pad1=%ld",obj,la,newactsel,acceptsame,data->pad1);
643 if (data
->NList_TypeSelect
|| !data
->NList_Input
)
646 tag
->ti_Data
= MUIV_NList_Active_Off
;
648 if((la
== MUIV_NList_Active_Off
) || (data
->NList_Entries
<= 0))
650 data
->pad1
= MUIV_NList_Active_Off
;
659 changed
= NL_List_First(data
,la
,tag
);
664 else if (data
->NList_Entries
> 0)
668 case MUIV_NList_Active_Top
:
669 case MUIV_NList_Active_UntilTop
:
672 case MUIV_NList_Active_Bottom
:
673 case MUIV_NList_Active_UntilBottom
:
676 case MUIV_NList_Active_Up
:
677 if (data
->NList_Active
!= MUIV_NList_Active_Off
)
680 la
= data
->NList_First
- 1 + data
->NList_Visible
;
682 case MUIV_NList_Active_Down
:
683 if (data
->pad1
!= MUIV_NList_Active_Off
)
686 la
= data
->NList_First
;
688 case MUIV_NList_Active_PageUp
:
689 case MUIV_NList_Active_UntilPageUp
:
690 if (data
->pad1
== data
->NList_First
)
691 la
= data
->pad1
+ 1 - data
->NList_Visible
;
693 la
= data
->NList_First
;
695 case MUIV_NList_Active_PageDown
:
696 case MUIV_NList_Active_UntilPageDown
:
697 if (data
->pad1
== data
->NList_First
- 1 + data
->NList_Visible
)
698 la
= data
->pad1
- 1 + data
->NList_Visible
;
700 la
= data
->NList_First
- 1 + data
->NList_Visible
;
708 else if (la
>= data
->NList_Entries
)
709 la
= data
->NList_Entries
- 1;
713 // if the SetActive_Jump_Center flag is active we make sure
714 // the new active entry will be centered
715 if(isFlagSet(flags
, MUIV_NList_SetActive_Jump_Center
))
716 la
= MUIV_NList_Jump_Active_Center
;
718 // make sure the entry is visible
719 if(NL_List_Jump(data
, la
) == TRUE
)
721 DO_NOTIFY(NTF_First
);
734 if(data
->NList_Entries
> 0)
740 case MUIV_NList_Active_Top
:
743 case MUIV_NList_Active_Bottom
:
744 la
= data
->NList_Entries
- 1;
746 case MUIV_NList_Active_Up
:
747 if (data
->NList_Active
!= MUIV_NList_Active_Off
)
748 la
= data
->NList_Active
- 1;
750 la
= data
->NList_First
- 1 + data
->NList_Visible
;
753 if (la
>= data
->NList_Entries
)
754 la
= data
->NList_Entries
- 1;
756 case MUIV_NList_Active_Down
:
757 if (data
->NList_Active
!= MUIV_NList_Active_Off
)
758 la
= data
->NList_Active
+ 1;
760 la
= data
->NList_First
;
761 if (la
>= data
->NList_Entries
)
762 la
= data
->NList_Entries
- 1;
764 case MUIV_NList_Active_PageUp
:
765 if (data
->NList_Active
== data
->NList_First
)
766 la
= data
->NList_Active
+ 1 - data
->NList_Visible
;
768 la
= data
->NList_First
;
772 case MUIV_NList_Active_PageDown
:
773 if (data
->NList_Active
== data
->NList_First
- 1 + data
->NList_Visible
)
774 la
= data
->NList_Active
- 1 + data
->NList_Visible
;
776 la
= data
->NList_First
- 1 + data
->NList_Visible
;
777 if (la
>= data
->NList_Entries
)
778 la
= data
->NList_Entries
- 1;
780 case MUIV_NList_Active_UntilPageUp
:
781 if (data
->NList_Active
== data
->NList_First
)
782 la
= data
->NList_Active
+ 1 - data
->NList_Visible
;
784 la
= data
->NList_First
;
787 ent
= data
->NList_Active
;
789 case MUIV_NList_Active_UntilPageDown
:
790 if (data
->NList_Active
== data
->NList_First
- 1 + data
->NList_Visible
)
791 la
= data
->NList_Active
- 1 + data
->NList_Visible
;
793 la
= data
->NList_First
- 1 + data
->NList_Visible
;
794 if (la
>= data
->NList_Entries
)
795 la
= data
->NList_Entries
- 1;
796 ent
= data
->NList_Active
;
798 case MUIV_NList_Active_UntilTop
:
800 ent
= data
->NList_Active
;
802 case MUIV_NList_Active_UntilBottom
:
803 la
= data
->NList_Entries
- 1;
804 ent
= data
->NList_Active
;
806 case MUIV_NList_Active_Off
:
807 la
= MUIV_NList_Active_Off
;
811 if ((la
!= data
->NList_Active
) || (acceptsame
&&
812 !((newactsel
== MUIV_NList_Select_On
) && (la
>= 0) && (la
< data
->NList_Entries
) &&
813 (data
->EntriesArray
[la
]->Select
!= TE_Select_None
))))
815 if ((la
>= 0) && (la
< data
->NList_Entries
))
817 if ((data
->NList_MultiSelect
== MUIV_NList_MultiSelect_None
) && (la
!= data
->NList_Active
))
819 DO_NOTIFY(NTF_Select
| NTF_LV_Select
);
821 if ((data
->NList_Active
>= 0) && (data
->NList_Active
< data
->NList_Entries
))
822 SELECT2(data
->NList_Active
,TE_Select_None
);
825 if ((data
->NList_MultiSelect
!= MUIV_NList_MultiSelect_None
) && (newactsel
== MUIV_NList_Select_List
))
827 DO_NOTIFY(NTF_Select
| NTF_LV_Select
);
828 if((data
->NList_Active
>= 0) && (data
->NList_Active
< data
->NList_Entries
))
830 if (data
->EntriesArray
[data
->NList_Active
]->Select
!= TE_Select_None
)
831 SELECT2(data
->NList_Active
,TE_Select_None
);
833 SELECT(data
->NList_Active
,TE_Select_Line
);
835 data
->lastselected
= data
->NList_Active
;
836 data
->lastactived
= data
->NList_Active
;
840 if((ent
< -1) || (data
->multiselect
== MUIV_NList_MultiSelect_None
))
845 else if (ent
>= data
->NList_Entries
)
846 ent
= data
->NList_Entries
- 1;
852 NL_SegChanged(data
,ent
,la
-1);
854 NL_SegChanged(data
,la
+1,ent
);
863 { case MUIV_NList_Select_Off
:
864 SELECT2(ent
,TE_Select_None
);
865 data
->lastselected
= ent
;
866 data
->lastactived
= ent
;
868 case MUIV_NList_Select_On
:
869 SELECT(ent
,TE_Select_Line
);
870 data
->lastselected
= ent
;
871 data
->lastactived
= ent
;
873 case MUIV_NList_Select_Toggle
:
874 if (data
->EntriesArray
[ent
]->Select
!= TE_Select_None
)
875 { SELECT2(ent
,TE_Select_None
);
878 { SELECT(ent
,TE_Select_Line
);
880 data
->lastselected
= ent
;
881 data
->lastactived
= ent
;
884 case MUIV_NList_Select_List
:
885 if (data
->NList_MultiSelect
!= MUIV_NList_MultiSelect_None
)
887 if (data
->EntriesArray
[ent
]->Select
!= TE_Select_None
)
888 { SELECT2(ent
,TE_Select_None
);
891 { SELECT(ent
,TE_Select_Line
);
893 data
->lastselected
= ent
;
894 data
->lastactived
= ent
;
899 if (data
->NList_MultiSelect
== MUIV_NList_MultiSelect_None
)
900 { SELECT(ent
,TE_Select_Line
);
901 data
->lastselected
= ent
;
902 data
->lastactived
= ent
;
909 data
->do_draw_active
= TRUE
;
911 // if the SetActive_Jump_Center flag is active we make sure
912 // the new active entry will be centered
913 if(isFlagSet(flags
, MUIV_NList_SetActive_Jump_Center
))
914 la
= MUIV_NList_Jump_Active_Center
;
916 // make sure the entry is visible
917 if(NL_List_Jump(data
, la
) == TRUE
)
919 DO_NOTIFY(NTF_First
);
922 // redraw at all means
925 else if (la
== MUIV_NList_Active_Off
)
927 if ((data
->NList_MultiSelect
== MUIV_NList_MultiSelect_None
) && (la
!= data
->NList_Active
))
929 DO_NOTIFY(NTF_Select
| NTF_LV_Select
);
930 if ((data
->NList_Active
>= 0) && (data
->NList_Active
< data
->NList_Entries
))
931 SELECT2(data
->NList_Active
,TE_Select_None
);
934 set_Active(MUIV_NList_Active_Off
);
935 tag
->ti_Data
= MUIV_NList_Active_Off
;
941 tag
->ti_Tag
= TAG_IGNORE
;
944 tag
->ti_Tag
= TAG_IGNORE
;
948 set_Active(MUIV_NList_Active_Off
);
949 tag
->ti_Data
= MUIV_NList_Active_Off
;
951 tag
->ti_Tag
= TAG_IGNORE
;
953 /* do_notifies(NTF_AllChanges|NTF_MinMax);*/
960 BOOL
NL_List_Horiz_First(struct NLData
*data
,LONG hf
,struct TagItem
*tag
)
962 BOOL scrolled
= FALSE
;
966 if(data
->NList_Horiz_First
!= hf
)
979 case MUIV_NList_Horiz_First_Start
:
983 case MUIV_NList_Horiz_First_End
:
985 hf
= data
->NList_Horiz_Entries
- data
->NList_Horiz_Visible
;
991 case MUIV_NList_Horiz_First_Left
:
993 hf
= data
->NList_Horiz_First
- _font(data
->this)->tf_XSize
;
999 case MUIV_NList_Horiz_First_Right
:
1001 hf
= data
->NList_Horiz_First
+ _font(data
->this)->tf_XSize
;
1002 if(hf
> data
->NList_Horiz_Entries
- data
->NList_Horiz_Visible
)
1003 hf
= data
->NList_Horiz_Entries
- data
->NList_Horiz_Visible
;
1007 case MUIV_NList_Horiz_First_PageLeft
:
1009 hf
= data
->NList_Horiz_First
- data
->NList_Horiz_Visible
/ 2;
1015 case MUIV_NList_Horiz_First_PageRight
:
1017 hf
= data
->NList_Horiz_First
+ data
->NList_Horiz_Visible
/ 2;
1018 if (hf
> data
->NList_Horiz_Entries
- data
->NList_Horiz_Visible
)
1019 hf
= data
->NList_Horiz_Entries
- data
->NList_Horiz_Visible
;
1023 case MUIV_NList_Horiz_First_Left2
:
1025 hf
= data
->NList_Horiz_First
- _font(data
->this)->tf_XSize
*2;
1031 case MUIV_NList_Horiz_First_Right2
:
1033 hf
= data
->NList_Horiz_First
+ _font(data
->this)->tf_XSize
*2;
1034 if (hf
> data
->NList_Horiz_Entries
- data
->NList_Horiz_Visible
)
1035 hf
= data
->NList_Horiz_Entries
- data
->NList_Horiz_Visible
;
1039 case MUIV_NList_Horiz_First_Left4
:
1041 hf
= data
->NList_Horiz_First
- _font(data
->this)->tf_XSize
*4;
1047 case MUIV_NList_Horiz_First_Right4
:
1049 hf
= data
->NList_Horiz_First
+ _font(data
->this)->tf_XSize
*4;
1050 if (hf
> data
->NList_Horiz_Entries
- data
->NList_Horiz_Visible
)
1051 hf
= data
->NList_Horiz_Entries
- data
->NList_Horiz_Visible
;
1056 if(data
->NList_Horiz_First
!= hf
)
1058 if((hf
>= 0) && (hf
< data
->NList_Horiz_Entries
))
1060 if(hf
> data
->NList_Horiz_Entries
- data
->NList_Horiz_Visible
)
1061 hf
= data
->NList_Horiz_Entries
- data
->NList_Horiz_Visible
;
1063 data
->NList_Horiz_First
= hf
;
1067 if (tagnul
/*&& data->Notify_HSB*/)
1068 notdoset(data
->this,MUIA_NList_Horiz_First
,hf
);
1073 tag
->ti_Tag
= TAG_IGNORE
;
1076 tag
->ti_Tag
= TAG_IGNORE
;
1084 ULONG
NL_List_SelectChar(struct NLData
*data
,LONG pos
,LONG seltype
,LONG
*state
)
1088 if (seltype
== MUIV_NList_Select_None
)
1091 if (data
->NList_TypeSelect
)
1093 if (seltype
== MUIV_NList_Select_Ask
)
1094 { LONG first
= data
->sel_pt
[data
->min_sel
].ent
;
1095 LONG last
= data
->sel_pt
[data
->max_sel
].ent
;
1096 if ((data
->sel_pt
[data
->max_sel
].column
== 0) && (data
->sel_pt
[data
->max_sel
].xoffset
== PMIN
))
1099 *state
= (LONG
) (last
- first
+ 1);
1101 else if (seltype
== MUIV_NList_Select_Off
)
1102 UnSelectCharSel(data
,TRUE
);
1103 else if ((seltype
== MUIV_NList_Select_On
) && (data
->NList_Entries
> 0))
1105 UnSelectCharSel(data
,FALSE
);
1106 if (pos
== MUIV_NList_Select_All
)
1108 ent2
= data
->NList_Entries
;
1111 { if (pos
== MUIV_NList_Select_Active
)
1112 ent
= data
->NList_Active
;
1117 else if (ent
>= data
->NList_Entries
)
1118 ent
= data
->NList_Entries
- 1;
1121 data
->sel_pt
[0].column
= 0;
1122 data
->sel_pt
[0].xoffset
= PMIN
;
1123 data
->sel_pt
[0].colpos
= -1;
1124 data
->sel_pt
[0].ent
= ent
;
1125 data
->sel_pt
[1].column
= 0;
1126 data
->sel_pt
[1].xoffset
= PMIN
;
1127 data
->sel_pt
[1].colpos
= -1;
1128 data
->sel_pt
[1].ent
= ent2
;
1131 NL_SegChanged(data
,ent
,ent2
);
1132 data
->minx_change_entry
= ent
;
1133 data
->minx_change_offset
= PMIN
;
1134 data
->maxx_change_entry
= ent2
;
1135 data
->maxx_change_offset
= PMIN
;
1145 ULONG
NL_List_Select(struct NLData
*data
,LONG pos
,LONG pos2
,LONG seltype
,LONG
*state
)
1148 /* DONE_NOTIFY(NTF_Select | NTF_LV_Select);*/
1149 if ((seltype
== MUIV_NList_Select_None
) || data
->NList_TypeSelect
|| !data
->NList_Input
)
1151 if ((pos
== MUIV_NList_Select_All
) && data
->multiselect
&& data
->NList_Input
)
1155 { case MUIV_NList_Select_Off
:
1156 while (ent
< data
->NList_Entries
)
1157 { if ((data
->NList_List_Select
== MUIV_NList_Select_List
) && (ent
== data
->NList_Active
))
1158 { SELECT2_CHGE(ent
,TE_Select_Line
);
1162 { SELECT2_CHGE(ent
,TE_Select_None
);
1170 case MUIV_NList_Select_On
:
1171 while (ent
< data
->NList_Entries
)
1172 { SELECT_CHGE(ent
,TE_Select_Line
);
1180 case MUIV_NList_Select_Toggle
:
1181 while (ent
< data
->NList_Entries
)
1182 { if ((data
->NList_List_Select
== MUIV_NList_Select_List
) && (ent
== data
->NList_Active
))
1183 { SELECT2_CHGE(ent
,TE_Select_Line
);
1186 else if (data
->EntriesArray
[ent
]->Select
!= TE_Select_None
)
1187 { SELECT2_CHGE(ent
,TE_Select_None
);
1190 { SELECT_CHGE(ent
,TE_Select_Line
);
1199 default : /* MUIV_NList_Select_Ask */
1200 while (ent
< data
->NList_Entries
)
1201 { if (data
->EntriesArray
[ent
]->Select
!= TE_Select_None
)
1209 data
->lastselected
= MUIV_NList_Active_Off
;
1210 /* do_notifies(NTF_AllChanges|NTF_MinMax);*/
1213 else if ((data
->multiselect
|| (seltype
== MUIV_NList_Select_Ask
)) && data
->NList_Input
)
1214 { if (pos
== MUIV_NList_Select_Active
)
1215 ent
= data
->NList_Active
;
1218 if ((ent
< 0) || (ent
>= data
->NList_Entries
))
1221 if (seltype
!= MUIV_NList_Select_Ask
)
1222 data
->lastselected
= ent
;
1224 * if ((data->NList_List_Select == MUIV_NList_Select_List) && (ent == data->NList_Active) && (seltype == MUIV_NList_Select_Ask))
1225 * seltype = MUIV_NList_Select_On;
1228 if ((ent2
< 0) || (ent2
>= data
->NList_Entries
))
1235 else if (ent2
== ent
)
1239 { case MUIV_NList_Select_Off
:
1240 if (state
) *state
= MUIV_NList_Select_Off
;
1241 SELECT2_CHGE(ent
,TE_Select_None
);
1243 case MUIV_NList_Select_On
:
1244 if (state
) *state
= MUIV_NList_Select_On
;
1245 SELECT_CHGE(ent
,TE_Select_Line
);
1247 case MUIV_NList_Select_Toggle
:
1248 if (data
->EntriesArray
[ent
]->Select
== TE_Select_None
)
1249 { if (state
) *state
= MUIV_NList_Select_On
;
1250 SELECT_CHGE(ent
,TE_Select_Line
);
1253 { if (state
) *state
= MUIV_NList_Select_Off
;
1254 SELECT2_CHGE(ent
,TE_Select_None
);
1257 default : /* MUIV_NList_Select_Ask */
1258 if (data
->EntriesArray
[ent
]->Select
!= TE_Select_None
)
1259 { if (state
) *state
= MUIV_NList_Select_On
; }
1261 { if (state
) *state
= MUIV_NList_Select_Off
; }
1266 if (ASKED_NOTIFY(NTF_Select
| NTF_LV_Select
))
1269 /* do_notifies(NTF_AllChanges|NTF_MinMax);*/
1276 ULONG
NL_List_TestPos(struct NLData
*data
,LONG x
,LONG y
,struct MUI_NList_TestPos_Result
*res
)
1278 if ((x
== MUI_MAXMAX
) && (y
== MUI_MAXMAX
))
1283 else if ((x
== MUI_MAXMAX
) && (y
== 0))
1290 WORD ly
= (y
- data
->vpos
);
1291 WORD lyl
= ly
/ data
->vinc
;
1292 WORD lx
= (x
- data
->hpos
);
1299 if (res
->char_number
!= -2)
1300 res
->char_number
= -1;
1301 res
->char_xoffset
= 0;
1302 if ((lx
>= 0) && (lx
< data
->NList_Horiz_Visible
) &&
1303 (ly
>= 0) && (lyl
< data
->NList_Visible
))
1304 { LONG line
= lyl
+ data
->NList_First
;
1305 if (!data
->NList_Title
&& (ly
< data
->vinc
/2))
1306 res
->flags
|= MUI_NLPR_ONTOP
;
1307 lx
+= data
->NList_Horiz_First
;
1308 if ((line
>= 0) && ((line
< data
->NList_First
+ data
->NList_Visible
) || (line
< data
->NList_Entries
)))
1311 while (res
->column
< data
->numcols
)
1312 { if (data
->cols
[res
->column
].c
->minx
> lx
)
1317 if ((res
->column
== data
->numcols
-1) && (lx
> data
->cols
[res
->column
].c
->maxx
+data
->cols
[res
->column
].c
->delta
))
1321 if ((lx
> data
->cols
[res
->column
].c
->maxx
-2) && (res
->column
< data
->numcols
-1))
1322 res
->flags
|= MUI_NLPR_BAR
;
1323 else if ((res
->column
== data
->numcols
-1) && IS_BAR(res
->column
,data
->cols
[res
->column
].c
) &&
1324 (lx
> data
->cols
[res
->column
].c
->maxx
-4) && (lx
<= data
->cols
[res
->column
].c
->maxx
+data
->cols
[res
->column
].c
->delta
))
1325 res
->flags
|= MUI_NLPR_BAR
;
1326 else if ((res
->column
> 0) && (res
->column
== data
->numcols
-1) &&
1327 (data
->NList_Horiz_First
+ data
->NList_Horiz_Visible
>= data
->NList_Horiz_Entries
) &&
1328 (x
>= data
->mright
- 2) && (res
->flags
& MUI_NLPR_ONTOP
))
1329 res
->flags
|= MUI_NLPR_BAR
;
1330 lx
-= data
->cols
[res
->column
].c
->minx
;
1336 if ((res
->column
>= 0) && (line
>= 0) && (line
< data
->NList_Entries
))
1337 { res
->entry
= line
;
1339 res
->yoffset
= ly
- ((lyl
* data
->vinc
) + (data
->vinc
/ 2));
1340 if (res
->char_number
!= -2)
1341 FindCharInColumn(data
,line
,res
->column
,lx
,&res
->char_xoffset
,&res
->char_number
);
1342 if (res
->char_number
< -PREPARSE_OFFSET_ENTRY
)
1343 { res
->char_number
+= PREPARSE_OFFSET_COL
;
1346 else if (res
->char_number
< -1)
1347 { res
->char_number
+= PREPARSE_OFFSET_ENTRY
;
1353 res
->flags
|= MUI_NLPR_ABOVE
;
1354 if (line
>= data
->NList_Entries
)
1355 res
->flags
|= MUI_NLPR_BELOW
;
1358 else if (data
->NList_Title
&& (lx
>= 0) && (lx
< data
->NList_Horiz_Visible
) &&
1359 (ly
< 0) && (y
>= data
->vdtitlepos
))
1360 { res
->flags
= MUI_NLPR_ABOVE
| MUI_NLPR_TITLE
| MUI_NLPR_ONTOP
;
1361 lx
+= data
->NList_Horiz_First
;
1364 while (res
->column
< data
->numcols
)
1365 { if (data
->cols
[res
->column
].c
->minx
> lx
)
1370 if ((res
->column
== data
->numcols
-1) && (lx
> data
->cols
[res
->column
].c
->maxx
+data
->cols
[res
->column
].c
->delta
))
1374 if ((lx
> data
->cols
[res
->column
].c
->maxx
-2) && (res
->column
< data
->numcols
-1))
1375 res
->flags
|= MUI_NLPR_BAR
;
1376 else if ((res
->column
== data
->numcols
-1) && IS_BAR(res
->column
,data
->cols
[res
->column
].c
) &&
1377 (lx
> data
->cols
[res
->column
].c
->maxx
-4) && (lx
<= data
->cols
[res
->column
].c
->maxx
+data
->cols
[res
->column
].c
->delta
))
1378 res
->flags
|= MUI_NLPR_BAR
;
1379 else if ((res
->column
> 0) && (res
->column
== data
->numcols
-1) &&
1380 (data
->NList_Horiz_First
+ data
->NList_Horiz_Visible
>= data
->NList_Horiz_Entries
) &&
1381 (x
>= data
->mright
- 2))
1382 res
->flags
|= MUI_NLPR_BAR
;
1383 lx
-= data
->cols
[res
->column
].c
->minx
;
1389 res
->yoffset
= y
- ((data
->vdtitlepos
+ data
->vpos
) / 2);
1393 res
->flags
|= MUI_NLPR_LEFT
;
1394 else if (lx
>= data
->NList_Horiz_Visible
)
1395 res
->flags
|= MUI_NLPR_RIGHT
;
1397 res
->flags
|= MUI_NLPR_ABOVE
;
1398 else if (lyl
>= data
->NList_Visible
)
1399 res
->flags
|= MUI_NLPR_BELOW
;
1407 ULONG
NL_List_TestPosOld(struct NLData
*data
,LONG x
,LONG y
,struct MUI_List_TestPos_Result
*res
)
1411 WORD ly
= (y
- data
->vpos
);
1412 WORD lyl
= ly
/ data
->vinc
;
1413 WORD lx
= (x
- data
->hpos
);
1419 if ((lx
>= 0) && (lx
< data
->NList_Horiz_Visible
) &&
1420 (ly
>= 0) && (lyl
< data
->NList_Visible
))
1421 { LONG line
= lyl
+ data
->NList_First
;
1422 if ((line
>= 0) && (line
< data
->NList_Entries
))
1423 { res
->entry
= line
;
1424 lx
+= data
->NList_Horiz_First
;
1427 while (res
->column
< data
->numcols
)
1428 { if (data
->cols
[res
->column
].c
->minx
> lx
)
1433 lx
-= data
->cols
[res
->column
].c
->minx
;
1438 res
->yoffset
= ly
- ((lyl
* data
->vinc
) + (data
->vinc
/ 2));
1442 res
->flags
|= MUI_NLPR_ABOVE
;
1443 if (line
>= data
->NList_Entries
)
1444 res
->flags
|= MUI_NLPR_BELOW
;
1449 res
->flags
|= MUI_NLPR_LEFT
;
1450 else if (lx
>= data
->NList_Horiz_Visible
)
1451 res
->flags
|= MUI_NLPR_RIGHT
;
1453 res
->flags
|= MUI_NLPR_ABOVE
;
1454 else if (lyl
>= data
->NList_Visible
)
1455 res
->flags
|= MUI_NLPR_BELOW
;
1463 IPTR
mNL_List_GetEntry(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_GetEntry
*msg
)
1465 struct NLData
*data
= INST_DATA(cl
,obj
);
1466 LONG ent
= msg
->pos
;
1469 if(ent
== MUIV_NList_GetEntry_Active
)
1470 ent
= data
->NList_Active
;
1472 if(ent
>= 0 && ent
< data
->NList_Entries
&& isFlagSet(data
->EntriesArray
[ent
]->Wrap
, TE_Wrap_TmpLine
))
1473 ent
-= data
->EntriesArray
[ent
]->dnum
;
1475 if(ent
>= 0 && ent
< data
->NList_Entries
)
1476 entry
= data
->EntriesArray
[ent
]->Entry
;
1478 // return the entry in the message if we got a valid pointer to store it
1479 if(msg
->entry
!= NULL
)
1480 *msg
->entry
= entry
;
1482 // return the entry as a normal return value in any case
1487 IPTR
mNL_List_GetEntryInfo(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_GetEntryInfo
*msg
)
1489 struct NLData
*data
= INST_DATA(cl
,obj
);
1490 LONG line
,ent2
,ent
= msg
->res
->pos
;
1491 /*DoSuperMethodA(cl,obj,(Msg) msg);*/
1493 if (ent
== MUIV_NList_GetEntryInfo_Line
)
1495 ent2
= msg
->res
->line
;
1496 while (ent
< data
->NList_Entries
)
1497 { if (!(data
->EntriesArray
[ent
]->Wrap
& TE_Wrap_TmpLine
))
1504 if ((ent
>= 0) && (ent
< data
->NList_Entries
))
1505 { msg
->res
->entry_pos
= ent
;
1506 msg
->res
->entry
= data
->EntriesArray
[ent
]->Entry
;
1507 msg
->res
->wrapcol
= (LONG
) data
->EntriesArray
[ent
]->Wrap
;
1508 msg
->res
->charpos
= (LONG
) data
->EntriesArray
[ent
]->pos
;
1509 msg
->res
->charlen
= (LONG
) data
->EntriesArray
[ent
]->len
;
1512 { msg
->res
->line
= -1;
1513 msg
->res
->entry_pos
= -1;
1514 msg
->res
->entry
= NULL
;
1515 msg
->res
->wrapcol
= (LONG
) 0;
1516 msg
->res
->charpos
= (LONG
) 0;
1517 msg
->res
->charlen
= (LONG
) 0;
1521 { if (ent
== MUIV_NList_GetEntry_Active
)
1522 ent
= data
->NList_Active
;
1524 if (ent
== -3 ) /* Magic number to get the last inserted entry <aphaso> */
1526 if ( data
->NList_LastInserted
== -1 )
1527 ent
= (data
->NList_Entries
- 1);
1529 ent
= data
->NList_LastInserted
;
1533 if ((ent
>= 0) && (ent
< data
->NList_Entries
) && (data
->EntriesArray
[ent
]->Wrap
& TE_Wrap_TmpLine
))
1534 ent
-= data
->EntriesArray
[ent
]->dnum
;
1535 if ((ent
>= 0) && (ent
< data
->NList_Entries
))
1537 if (msg
->res
->line
== -2) /* Magic number to receive the NList entry pointer, not the supplied! <aphaso> */
1539 msg
->res
->entry_pos
= ent
;
1540 msg
->res
->entry
= data
->EntriesArray
[ent
];
1544 msg
->res
->entry_pos
= ent
;
1545 msg
->res
->entry
= data
->EntriesArray
[ent
]->Entry
;
1546 msg
->res
->wrapcol
= (LONG
) data
->EntriesArray
[ent2
]->Wrap
;
1547 msg
->res
->charpos
= (LONG
) data
->EntriesArray
[ent2
]->pos
;
1548 msg
->res
->charlen
= (LONG
) data
->EntriesArray
[ent2
]->len
;
1551 { if (!(data
->EntriesArray
[ent2
]->Wrap
& TE_Wrap_TmpLine
))
1555 msg
->res
->line
= line
;
1559 { msg
->res
->line
= -1;
1560 msg
->res
->entry_pos
= -1;
1561 msg
->res
->entry
= NULL
;
1562 msg
->res
->wrapcol
= (LONG
) 0;
1563 msg
->res
->charpos
= (LONG
) 0;
1564 msg
->res
->charlen
= (LONG
) 0;
1570 static BOOL
NL_List_Jump(struct NLData
*data
, LONG pos
)
1572 BOOL result
= FALSE
;
1577 case MUIV_NList_Jump_Top
:
1583 case MUIV_NList_Jump_Bottom
:
1585 pos
= data
->NList_Entries
- 1;
1589 case MUIV_NList_Jump_Active
:
1591 pos
= data
->NList_Active
;
1595 case MUIV_NList_Jump_Up
:
1597 pos
= data
->NList_First
- 1;
1601 case MUIV_NList_Jump_Down
:
1603 pos
= data
->NList_First
+ data
->NList_Visible
;
1607 case MUIV_NList_Jump_Active_Center
:
1609 // center the item in the visible area
1610 LONG first
= data
->NList_Active
- data
->NList_Visible
/2;
1612 // make sure that the last item is displayed in the last line
1613 while(first
+ data
->NList_Visible
> data
->NList_Entries
)
1619 data
->NList_First
= first
;
1627 if(pos
>= 0 && pos
< data
->NList_Entries
)
1629 // old style jump, just make the requested item visible
1630 if(pos
< data
->NList_First
)
1632 data
->NList_First
= pos
;
1636 else if(pos
>= data
->NList_First
+ data
->NList_Visible
)
1638 data
->NList_First
= pos
- data
->NList_Visible
+ 1;
1640 // make sure that the last item is displayed in the last line
1641 while(data
->NList_First
+ data
->NList_Visible
> data
->NList_Entries
)
1642 data
->NList_First
--;
1644 if(data
->NList_First
< 0)
1645 data
->NList_First
= 0;
1655 IPTR
mNL_List_Jump(struct IClass
*cl
, Object
*obj
, struct MUIP_NList_Jump
*msg
)
1657 struct NLData
*data
= INST_DATA(cl
,obj
);
1661 if(NL_List_Jump(data
, msg
->pos
) == TRUE
)
1663 DO_NOTIFY(NTF_First
);
1667 /* do_notifies(NTF_AllChanges|NTF_MinMax);*/
1673 IPTR
mNL_List_SetActive(struct IClass
*cl
, Object
*obj
, struct MUIP_NList_SetActive
*msg
)
1675 BOOL result
= FALSE
;
1676 struct NLData
*data
= INST_DATA(cl
,obj
);
1677 LONG pos
= (LONG
)(SIPTR
)msg
->pos
;
1681 // check if the user used msg->pos for specifying the entry position (integer)
1682 // or by using the entry address
1683 if(isFlagSet(msg
->flags
, MUIV_NList_SetActive_Entry
))
1685 pos
= MUIV_NList_GetPos_Start
;
1686 NL_List_GetPos(data
, (APTR
)msg
->pos
, &pos
);
1689 result
= NL_List_Active(data
, pos
, NULL
, data
->NList_List_Select
, FALSE
, msg
->flags
);
1692 DO_NOTIFY(NTF_Active
| NTF_L_Active
);
1699 IPTR
mNL_List_Select(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_Select
*msg
)
1701 struct NLData
*data
= INST_DATA(cl
,obj
);
1702 /*DoSuperMethodA(cl,obj,(Msg) msg);*/
1703 if (data
->NList_TypeSelect
)
1704 return (NL_List_SelectChar(data
,msg
->pos
,msg
->seltype
,msg
->state
));
1706 return (NL_List_Select(data
,msg
->pos
,msg
->pos
,msg
->seltype
,msg
->state
));
1711 IPTR
mNL_List_TestPos(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_TestPos
*msg
)
1713 struct NLData
*data
= INST_DATA(cl
,obj
);
1714 /*DoSuperMethodA(cl,obj,(Msg) msg);*/
1715 return (NL_List_TestPos(data
,msg
->x
,msg
->y
,msg
->res
));
1719 IPTR
mNL_List_TestPosOld(struct IClass
*cl
,Object
*obj
,struct MUIP_List_TestPos
*msg
)
1721 struct NLData
*data
= INST_DATA(cl
,obj
);
1722 /*DoSuperMethodA(cl,obj,(Msg) msg);*/
1723 return (NL_List_TestPosOld(data
,msg
->x
,msg
->y
,msg
->res
));
1727 IPTR
mNL_List_Redraw(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_Redraw
*msg
)
1729 struct NLData
*data
= INST_DATA(cl
,obj
);
1734 /*DoSuperMethodA(cl,obj,(Msg) msg);*/
1736 data
->display_ptr
= NULL
;
1737 data
->parse_column
= -1;
1739 /*D(bug("%lx|List_Redraw1 pos=%ld Q=%ld D=%ld S=%ld\n",obj,msg->pos,data->NList_Quiet,data->DRAW,data->SETUP));*/
1743 // defer the redraw process
1744 /*D(bug("%lx|List_Redraw no! %ld %ld (push it)\n",obj,msg->pos,data->DRAW));*/
1745 DoMethod(_app(obj
), MUIM_Application_PushMethod
, obj
, 2, msg
->MethodID
, msg
->pos
);
1749 if(msg
->MethodID
== MUIM_List_Redraw
&& msg
->pos
== MUIV_NList_Redraw_All
)
1758 NL_SetColsAdd(data
,-2,TRUE
);
1759 DoMethod(_app(obj
), MUIM_Application_PushMethod
, obj
, 2, MUIM_NList_Redraw
, MUIV_NList_Redraw_All
);
1764 case MUIV_NList_Redraw_All
:
1766 // redraw all entries
1769 NL_SetColsAdd(data
,-2,TRUE
);
1770 for(ent
= 0; ent
< data
->NList_Entries
; ent
++)
1771 data
->EntriesArray
[ent
]->PixLen
= -1;
1773 data
->Title_PixLen
= -1;
1774 data
->do_draw_title
= TRUE
;
1775 data
->do_parse
= TRUE
;
1776 data
->do_setcols
= TRUE
;
1777 data
->do_updatesb
= TRUE
;
1778 data
->force_wwrap
= TRUE
;
1783 case MUIV_NList_Redraw_VisibleCols
:
1785 // redraw visible columns only
1787 NL_SetColsAdd(data
, -3, TRUE
);
1791 case MUIV_NList_Redraw_Selected
:
1793 // redraw selected entries only
1796 BOOL doDraw
= FALSE
;
1798 if(data
->NList_TypeSelect
== MUIV_NList_TypeSelect_Line
)
1800 for(ent
=0; ent
< data
->NList_Entries
; ent
++)
1802 // mark the selected entries as "to be redrawn"
1803 if(data
->EntriesArray
[ent
]->Select
!= TE_Select_None
)
1805 NL_SetColsAdd(data
, ent
, TRUE
);
1806 data
->EntriesArray
[ent
]->PixLen
= -1;
1807 NL_Changed(data
, ent
);
1814 NL_SegChanged(data
,data
->sel_pt
[data
->min_sel
].ent
,data
->sel_pt
[data
->max_sel
].ent
);
1820 // at least one entry must be redrawn
1821 data
->display_ptr
= NULL
;
1822 data
->do_draw
= TRUE
;
1829 case MUIV_NList_Redraw_Title
:
1831 // redraw title only
1834 NL_SetColsAdd(data
, -1, TRUE
);
1835 data
->Title_PixLen
= -1;
1837 data
->do_draw_title
= TRUE
;
1838 data
->do_setcols
= TRUE
;
1843 case MUIV_NList_Redraw_Active
:
1845 // redraw the active entry only
1846 ent
= data
->NList_Active
;
1848 // fall through to the default redraw
1852 // redraw a specific entry
1853 if(ent
>= 0 && ent
< data
->NList_Entries
)
1857 NL_SetColsAdd(data
, ent
, TRUE
);
1858 data
->EntriesArray
[ent
]->PixLen
= -1;
1860 NL_Changed(data
, ent
);
1867 /*D(bug("%lx|List_Redraw2 pos=%ld Q=%ld D=%ld S=%ld\n",obj,msg->pos,data->NList_Quiet,data->DRAW,data->SETUP));*/
1875 IPTR
mNL_List_RedrawEntry(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_RedrawEntry
*msg
)
1877 struct NLData
*data
= INST_DATA(cl
,obj
);
1879 BOOL dodraw
= FALSE
;
1882 while (ent
< data
->NList_Entries
)
1883 { if (data
->EntriesArray
[ent
]->Entry
== msg
->entry
)
1884 { data
->EntriesArray
[ent
]->PixLen
= -1;
1885 NL_Changed(data
,ent
);
1892 /* sba: This enforces redrawing the entry completly */
1893 data
->display_ptr
= NULL
;
1895 data
->do_draw
= TRUE
;
1904 IPTR
mNL_List_NextSelected(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_NextSelected
*msg
)
1906 struct NLData
*data
= INST_DATA(cl
,obj
);
1907 long ent
= *msg
->pos
;
1908 /*DoSuperMethodA(cl,obj,(Msg) msg);*/
1909 if ((ent
== MUIV_NList_NextSelected_Start
) || (ent
< 0))
1913 if (data
->NList_TypeSelect
)
1915 if (ent
< data
->sel_pt
[data
->min_sel
].ent
)
1916 ent
= data
->sel_pt
[data
->min_sel
].ent
;
1917 else if (ent
> data
->sel_pt
[data
->max_sel
].ent
)
1918 ent
= MUIV_NList_NextSelected_End
;
1919 else if ((ent
== data
->sel_pt
[data
->max_sel
].ent
) &&
1920 (data
->sel_pt
[data
->max_sel
].column
== 0) &&
1921 (data
->sel_pt
[data
->max_sel
].xoffset
== PMIN
))
1922 ent
= MUIV_NList_NextSelected_End
;
1925 { while ((ent
< data
->NList_Entries
) && (data
->EntriesArray
[ent
]->Select
== TE_Select_None
))
1927 if (ent
>= data
->NList_Entries
)
1928 ent
= MUIV_NList_NextSelected_End
;
1935 IPTR
mNL_List_PrevSelected(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_PrevSelected
*msg
)
1937 struct NLData
*data
= INST_DATA(cl
,obj
);
1938 long ent
= *msg
->pos
;
1939 /*DoSuperMethodA(cl,obj,(Msg) msg);*/
1940 if ((ent
== MUIV_NList_PrevSelected_Start
) || (ent
< 0) || (ent
>= data
->NList_Entries
))
1941 ent
= data
->NList_Entries
- 1;
1944 if (data
->NList_TypeSelect
)
1946 if (ent
< data
->sel_pt
[data
->min_sel
].ent
)
1947 ent
= MUIV_NList_PrevSelected_End
;
1948 else if ((ent
== data
->sel_pt
[data
->max_sel
].ent
) &&
1949 (data
->sel_pt
[data
->max_sel
].column
== 0) &&
1950 (data
->sel_pt
[data
->max_sel
].xoffset
== PMIN
))
1951 ent
= data
->sel_pt
[data
->max_sel
].ent
- 1;
1952 else if (ent
> data
->sel_pt
[data
->max_sel
].ent
)
1953 ent
= data
->sel_pt
[data
->max_sel
].ent
;
1956 { while ((ent
> 0) && (data
->EntriesArray
[ent
]->Select
== TE_Select_None
))
1959 ent
= MUIV_NList_PrevSelected_End
;
1966 IPTR
mNL_List_GetSelectInfo(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_GetSelectInfo
*msg
)
1968 struct NLData
*data
= INST_DATA(cl
,obj
);
1971 msg
->res
->start
= 1;
1972 msg
->res
->vstart
= -1;
1974 msg
->res
->vend
= -1;
1977 msg
->res
->start_column
= -1;
1978 msg
->res
->end_column
= -1;
1979 msg
->res
->start_pos
= -1;
1980 msg
->res
->end_pos
= -1;
1982 if(data
->NList_TypeSelect
== MUIV_NList_TypeSelect_Line
)
1986 while(ent
< data
->NList_Entries
)
1988 if(data
->EntriesArray
[ent
] != NULL
&& data
->EntriesArray
[ent
]->Select
!= TE_Select_None
)
1990 if(msg
->res
->start
== -1)
1991 msg
->res
->start
= ent
;
1993 msg
->res
->end
= ent
;
1998 msg
->res
->vstart
= msg
->res
->start
;
1999 msg
->res
->vend
= msg
->res
->end
;
2003 msg
->res
->start_column
= data
->sel_pt
[data
->min_sel
].column
;
2004 msg
->res
->start_pos
= data
->sel_pt
[data
->min_sel
].colpos
;
2005 msg
->res
->end_column
= data
->sel_pt
[data
->max_sel
].column
;
2006 msg
->res
->end_pos
= data
->sel_pt
[data
->max_sel
].colpos
;
2007 msg
->res
->start
= data
->sel_pt
[data
->min_sel
].ent
;
2008 msg
->res
->end
= data
->sel_pt
[data
->max_sel
].ent
;
2009 msg
->res
->vstart
= msg
->res
->start
;
2010 msg
->res
->vend
= msg
->res
->end
;
2012 if((msg
->res
->vstart
>= 0) && (msg
->res
->vend
>= msg
->res
->vstart
))
2013 msg
->res
->vnum
= msg
->res
->vend
- msg
->res
->vstart
+ 1;
2016 if (msg
->res
->start
>= 0 && msg
->res
->start
< data
->NList_Entries
&& data
->EntriesArray
[msg
->res
->start
] != NULL
&& data
->EntriesArray
[msg
->res
->start
]->Wrap
)
2018 if (data
->EntriesArray
[msg
->res
->start
]->Wrap
& TE_Wrap_TmpLine
)
2019 msg
->res
->start
-= data
->EntriesArray
[msg
->res
->start
]->dnum
;
2022 if (msg
->res
->end
>= 0 && msg
->res
->end
< data
->NList_Entries
&& data
->EntriesArray
[msg
->res
->end
] != NULL
&& data
->EntriesArray
[msg
->res
->end
]->Wrap
)
2024 if (data
->EntriesArray
[msg
->res
->end
]->Wrap
& TE_Wrap_TmpLine
)
2025 msg
->res
->end
-= data
->EntriesArray
[msg
->res
->end
]->dnum
;
2032 IPTR
mNL_List_DoMethod(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_DoMethod
*msg
)
2034 struct NLData
*data
= INST_DATA(cl
,obj
);
2035 LONG ent
= msg
->pos
;
2036 APTR dest
= msg
->DestObj
;
2038 if((msg
->FollowParams
>= 1) && (msg
->FollowParams
< 40) &&
2039 ((msg
->pos
== MUIV_NList_DoMethod_Active
) ||
2040 (msg
->pos
== MUIV_NList_DoMethod_Selected
) ||
2041 (msg
->pos
== MUIV_NList_DoMethod_All
) ||
2042 ((msg
->pos
>= 0) && (msg
->pos
< data
->NList_Entries
))))
2044 LONG
*table1
= (LONG
*)&msg
->FollowParams
;
2047 STACKED ULONG MethodID
;
2048 SIPTR params
[64]; /* MAXIMUM 40 (see docs) <aphaso> */
2051 if(msg
->FollowParams
> 63) /* MAXIMUM 40 (see docs) <aphaso> */
2053 msg
->FollowParams
= 63;
2054 newMsg
.params
[63] = 0;
2057 if((IPTR
)msg
->DestObj
== (IPTR
)MUIV_NList_DoMethod_Self
)
2059 else if((IPTR
)msg
->DestObj
== (IPTR
)MUIV_NList_DoMethod_App
)
2062 dest
= (APTR
) _app(obj
);
2066 if(msg
->pos
== MUIV_NList_DoMethod_Active
)
2067 ent
= MUIV_NList_DoMethod_Active
;
2068 else if(msg
->pos
== MUIV_NList_DoMethod_Selected
)
2070 if(data
->NList_TypeSelect
)
2071 ent
= data
->sel_pt
[data
->min_sel
].ent
;
2075 while((ent
< data
->NList_Entries
) && (data
->EntriesArray
[ent
]->Select
== TE_Select_None
))
2079 else if(msg
->pos
== MUIV_NList_DoMethod_All
)
2081 while((ent
>= 0) && (ent
< data
->NList_Entries
))
2083 if((IPTR
) msg
->DestObj
== (IPTR
)MUIV_NList_DoMethod_Entry
)
2084 dest
= data
->EntriesArray
[ent
]->Entry
;
2089 newMsg
.MethodID
= table1
[1];
2091 for(num
= 1;num
< msg
->FollowParams
;num
++)
2093 switch(table1
[num
+1])
2095 case MUIV_NList_EntryValue
:
2096 newMsg
.params
[num
] = (SIPTR
)data
->EntriesArray
[ent
]->Entry
;
2098 case MUIV_NList_EntryPosValue
:
2099 newMsg
.params
[num
] = (LONG
)ent
;
2101 case MUIV_NList_SelfValue
:
2102 newMsg
.params
[num
] = (SIPTR
)obj
;
2104 case MUIV_NList_AppValue
:
2106 newMsg
.params
[num
] = (SIPTR
)_app(obj
);
2108 newMsg
.params
[num
] = 0;
2111 newMsg
.params
[num
] = table1
[num
+1];
2116 DoMethodA(dest
, (Msg
)((APTR
)&newMsg
));
2119 if(msg
->pos
== MUIV_NList_DoMethod_Selected
)
2121 if(data
->NList_TypeSelect
)
2123 if((ent
> data
->sel_pt
[data
->max_sel
].ent
) ||
2124 ((ent
== data
->sel_pt
[data
->max_sel
].ent
) &&
2125 (data
->sel_pt
[data
->max_sel
].column
== 0) &&
2126 (data
->sel_pt
[data
->max_sel
].xoffset
== PMIN
)))
2131 while((ent
< data
->NList_Entries
) && (data
->EntriesArray
[ent
]->Select
== TE_Select_None
))
2135 else if(msg
->pos
!= MUIV_NList_DoMethod_All
)
2142 static BOOL
NL_List_GetPos(struct NLData
*data
, APTR entry
, LONG
*pos
)
2144 BOOL result
= FALSE
;
2150 if((IPTR
)entry
== (IPTR
)-2)
2152 if(data
->NList_LastInserted
== -1)
2153 *pos
= (data
->NList_Entries
- 1);
2155 *pos
= data
->NList_LastInserted
;
2161 LONG ent
= *pos
+ 1;
2163 while(ent
< data
->NList_Entries
)
2165 if(data
->EntriesArray
[ent
]->Entry
== entry
)
2179 *pos
= MUIV_NList_GetPos_End
;
2186 IPTR
mNL_List_GetPos(struct IClass
*cl
,Object
*obj
,struct MUIP_NList_GetPos
*msg
)
2188 struct NLData
*data
= INST_DATA(cl
,obj
);
2191 result
= NL_List_GetPos(data
, msg
->entry
, msg
->pos
);