Merging NList MCC 0.119 into the main branch.
[AROS.git] / workbench / classes / zune / nlist / demo / NList-Demo.c
blob344196617dbca482d38d333c82b6bd3758739def
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>
28 #include <stdio.h>
29 #include <dos/dos.h>
30 #include <exec/types.h>
31 #include <exec/memory.h>
32 #include <exec/ports.h>
33 #include <exec/io.h>
34 #include <libraries/dos.h>
35 #include <libraries/dosextens.h>
36 #include <libraries/gadtools.h>
37 #include <libraries/asl.h>
38 #include <libraries/mui.h>
39 #include <workbench/workbench.h>
40 #include <intuition/intuition.h>
41 #include <intuition/classusr.h>
43 #include <proto/exec.h>
44 #include <proto/dos.h>
45 #include <proto/gadtools.h>
46 #include <proto/asl.h>
47 #include <proto/muimaster.h>
48 #include <proto/graphics.h>
49 #include <proto/intuition.h>
50 #include <proto/utility.h>
52 #if !defined(__amigaos4__)
53 #include <clib/alib_protos.h>
54 #endif
56 struct Library *MUIMasterBase = NULL;
57 #if defined(__AROS__)
58 struct UtilityBase *UtilityBase = NULL;
59 #else
60 struct Library *UtilityBase = NULL;
61 #endif
63 #if defined(__amigaos4__)
64 struct Library *IntuitionBase = NULL;
65 struct Library *GfxBase = NULL;
66 #else
67 struct IntuitionBase *IntuitionBase = NULL;
68 struct GfxBase *GfxBase = NULL;
69 #endif
71 #if defined(__amigaos4__)
72 struct GraphicsIFace *IGraphics = NULL;
73 struct IntuitionIFace *IIntuition = NULL;
74 struct MUIMasterIFace *IMUIMaster = NULL;
75 struct UtilityIFace *IUtility = NULL;
76 #endif
78 #include <mui/NListview_mcc.h>
79 #include <mui/NFloattext_mcc.h>
81 #include "NList-Demo2.h"
82 #include "NList-Demo3.h"
84 #include "SDI_compiler.h"
86 /* *********************************************** */
89 static APTR APP_Main,
90 WIN_Main,
91 WIN_2,
92 BM_img,
93 BM_img2,
94 BT_TitleOn,
95 BT_TitleOff,
96 BT_NoMulti,
97 BT_Multidef,
98 BT_Multi,
99 BT_AllMulti,
100 BT_InputOn,
101 BT_InputOff,
102 BT_Sort,
103 BT_DragSortOn,
104 BT_DragSortOff,
105 BT_SelLine,
106 BT_SelChar,
107 BT_OpenWin2,
108 BT_RemAct,
109 BT_RemSel,
110 BT_Clear,
111 BT_Add,
112 LV_Text,
113 LI_Text,
114 LV_Text2,
115 LI_Text2,
116 PR_Horiz,
117 ST_string;
120 /* ************ IMG definitions ************** */
122 const ULONG list_colors[24] =
124 0xadadadad,0xadadadad,0xadadadad,
125 0x7b7b7b7b,0x7b7b7b7b,0x7b7b7b7b,
126 0x3b3b3b3b,0x67676767,0xa2a2a2a2,
127 0xadadadad,0xadadadad,0xadadadad,
128 0xadadadad,0xadadadad,0xadadadad,
129 0xadadadad,0xadadadad,0xadadadad,
130 0xffffffff,0xffffffff,0xffffffff,
131 0x00000000,0x00000000,0x00000000,
134 const UBYTE list_body[168] = {
135 0x00,0x00,0x44,0x00,0xff,0xff,0xb8,0x00,0xff,0xff,0xb8,0x00,0x00,0x00,0x00,
136 0x00,0x80,0x00,0x64,0x00,0xff,0xff,0xb8,0x00,0x3b,0xb8,0x46,0x00,0x80,0x00,
137 0x64,0x00,0xc4,0x47,0xfc,0x00,0x00,0x00,0x46,0x00,0x80,0x00,0x64,0x00,0xff,
138 0xff,0xfc,0x00,0x36,0xd8,0x46,0x00,0x80,0x00,0x64,0x00,0xc9,0x27,0xfc,0x00,
139 0x00,0x00,0x46,0x00,0x80,0x00,0x64,0x00,0xff,0xff,0xfc,0x00,0x3d,0xe8,0x6e,
140 0x00,0x80,0x00,0x5c,0x00,0xc2,0x17,0xcc,0x00,0x00,0x00,0x46,0x00,0x80,0x00,
141 0x78,0x00,0xff,0xff,0xf8,0x00,0x00,0x00,0x40,0x00,0x80,0x00,0x64,0x00,0xff,
142 0xff,0xf8,0x00,0xbf,0xff,0xee,0x00,0x7f,0xff,0xdc,0x00,0x3f,0xff,0xcc,0x00,
143 0x00,0x44,0x46,0x00,0xff,0xbb,0xb8,0x00,0xff,0xbb,0xb8,0x00,0x00,0x00,0x00,
144 0x00,0x80,0x66,0x64,0x00,0xff,0xbb,0xb8,0x00,0xbf,0xee,0xee,0x00,0x7f,0xdd,
145 0xdc,0x00,0x3f,0xcc,0xcc,0x00,0x3f,0xee,0xee,0x00,0x00,0x00,0x00,0x00,0x00,
146 0x00,0x00,0x00, };
148 #define LIST_WIDTH 23
149 #define LIST_HEIGHT 14
150 #define LIST_DEPTH 3
151 #define LIST_COMPRESSION 0
152 #define LIST_MASKING 2
154 #define IMG \
155 BodychunkObject,\
156 MUIA_FixWidth , LIST_WIDTH ,\
157 MUIA_FixHeight , LIST_HEIGHT,\
158 MUIA_Bitmap_Width , LIST_WIDTH ,\
159 MUIA_Bitmap_Height , LIST_HEIGHT,\
160 MUIA_Bodychunk_Depth , LIST_DEPTH ,\
161 MUIA_Bodychunk_Body , (UBYTE *) list_body,\
162 MUIA_Bodychunk_Compression, LIST_COMPRESSION,\
163 MUIA_Bodychunk_Masking , LIST_MASKING,\
164 MUIA_Bitmap_SourceColors , (ULONG *) list_colors,\
165 MUIA_Bitmap_Transparent , 0,\
169 /* ************ IMG2 definitions ************** */
171 const ULONG list2_colors[24] =
173 0xabababab,0xadadadad,0xc5c5c5c5,
174 0x7b7b7b7b,0x7b7b7b7b,0x7b7b7b7b,
175 0x3b3b3b3b,0x67676767,0xa2a2a2a2,
176 0x00000000,0x00000000,0x00000000,
177 0xffffffff,0xa9a9a9a9,0x97979797,
178 0xffffffff,0xffffffff,0xffffffff,
179 0x00000000,0x00000000,0x00000000,
180 0xadadadad,0xadadadad,0xadadadad,
183 const UBYTE list2_body[156] = {
184 0x04,0x00,0x04,0x00,0x78,0x00,0x08,0x00,0x30,0x00,0x08,0x00,0x79,0x00,0x02,
185 0x00,0x8e,0x00,0x1c,0x00,0x3e,0x00,0x1c,0x00,0x7e,0x10,0x04,0x00,0x83,0xe0,
186 0x08,0x00,0xfe,0x80,0x08,0x00,0x45,0x02,0x00,0x00,0x85,0x9c,0x00,0x00,0xff,
187 0x70,0x00,0x00,0x7e,0x1c,0x80,0x00,0xc1,0x3b,0x78,0x00,0xfe,0xf9,0x30,0x00,
188 0x00,0x2f,0xb0,0x00,0xff,0x60,0x4c,0x00,0x7e,0xbf,0x48,0x00,0x7c,0x27,0x68,
189 0x00,0x03,0xc1,0xa4,0x00,0x01,0x7f,0xb4,0x00,0x01,0x1a,0xd8,0x00,0x03,0xe3,
190 0xa4,0x00,0x01,0xbf,0xac,0x00,0x00,0x6c,0xaa,0x00,0x04,0x99,0xd4,0x00,0x03,
191 0x97,0xfc,0x00,0x01,0x76,0x5a,0x00,0x38,0x8d,0xec,0x00,0x1e,0x8b,0x7c,0x00,
192 0x02,0xeb,0x72,0x00,0x0d,0x04,0xfc,0x00,0x09,0x06,0xf8,0x00,0x01,0x84,0x06,
193 0x00,0x0e,0x02,0xf8,0x00,0x06,0x01,0xb0,0x00,0x00,0x03,0xfc,0x00,0x00,0x00,
194 0x00,0x00,0x00,0x00,0x00,0x00, };
196 #define LIST2_WIDTH 23
197 #define LIST2_HEIGHT 13
198 #define LIST2_DEPTH 3
199 #define LIST2_COMPRESSION 0
200 #define LIST2_MASKING 2
202 #define IMG2 \
203 BodychunkObject,\
204 MUIA_FixWidth , LIST2_WIDTH ,\
205 MUIA_FixHeight , LIST2_HEIGHT,\
206 MUIA_Bitmap_Width , LIST2_WIDTH ,\
207 MUIA_Bitmap_Height , LIST2_HEIGHT,\
208 MUIA_Bodychunk_Depth , LIST2_DEPTH ,\
209 MUIA_Bodychunk_Body , (UBYTE *) list2_body,\
210 MUIA_Bodychunk_Compression, LIST2_COMPRESSION,\
211 MUIA_Bodychunk_Masking , LIST2_MASKING,\
212 MUIA_Bitmap_SourceColors , (ULONG *) list2_colors,\
213 MUIA_Bitmap_Transparent , 0,\
217 /* *********************************************** */
220 #define ID_LIST2_ACTIVE 1
222 #define NL "\n"
223 #define NL2 " "
226 /* *********************************************** */
228 const char MainTextString2[] =
230 "This new list/listview custom class has its own backgrounds" NL2
231 "and pens setables from mui prefs with NListviews.mcp !" NL2
232 "It doesn't use the same way to handle multiselection" NL2
233 "with mouse and keys than standard List/Listview." NL
234 "\033C" NL
235 "You can horizontally scroll with cursor keys," NL2
236 "or going on the right and left of the list" NL2
237 "while selecting with the mouse." NL2
238 "(When there is no immediate draggin stuff active...)" NL2
239 "Try just clicking on the left/right borders !" NL
240 "\033C" NL
241 "\033r\033uGive some feedback about it ! :-)" NL
242 "\033r\033bhttp://www.sf.net/projects/nlist-classes/"
245 /* *********************************************** */
246 const char MainTextString[] =
248 "\033cNList.mcc \033o[0] NListview.mcc \033o[1] NListviews.mcp" NL
249 "\033E\033t\033c\033o[2@1]" NL
250 "\033c\033nThis new list/listview custom class has its own backgrounds" NL
251 "\033cand pens setables from mui prefs with NListviews.mcp !" NL
252 "\033E\033t[M7]\033c\033o[3@2]" NL
253 "" NL
254 "\033cIt doesn't use the same way to handle multiselection" NL
255 "\033cwith mouse and keys than standard List/Listview." NL
256 "" NL
257 "\033cYou can horizontally scroll with cursor keys," NL
258 "\033cor going on the right and left of the list" NL
259 "\033cwhile selecting with the mouse." NL
260 "\033c(When there is no immediate draggin stuff active...)" NL
261 "\033cTry just clicking on the left/right borders !" NL
262 "" NL
263 "\033r\033uGive some feedback about it ! :-)" NL
264 "\033r\033bhttp://www.sf.net/projects/nlist-classes/"
267 /* *********************************************** */
269 const char *MainTextArray[] =
271 "\033c\033nThis new list/listview custom class has its own backgrounds",
272 "\033cand pens setables from mui prefs with NListviews.mcp !",
273 " ",
274 "\033cIt doesn't use the same way to handle multiselection",
275 "\033cwith mouse and keys than standard List/Listview.",
276 " ",
277 "\033cYou can horizontally scroll with cursor keys,",
278 "\033cor going on the right and left of the list",
279 "\033cwhile selecting with the mouse.",
280 "\033c(When there is no draggin stuff active...)",
281 "\033cTry just clicking on the left/right borders !",
283 "\033r\033uGive some feedback about it ! :-)",
284 "\033r\033bhttp://www.sf.net/projects/nlist-classes/"
288 "You can push column titles as real buttons...",
290 "You can drag column separator bar in",
291 "the title to adjust column width...",
292 "(or in upper half of first entry if title is off)",
294 "If, while dragging the bar, you press the",
295 "menu button, the width of the column will",
296 "come back to its default...",
298 "You can click on columns title to sort the list contents.",
299 "You can shift-click (or other qualifier if you modify the",
300 "default one) to add a secondary sorting column.",
304 "\033cF2 to copy selected lines to printer",
305 "\033cF3 to copy all lines to file RAM:tmp.txt",
307 "\033cF4 to copy selected lines to clipboard 0.",
308 "\033cF5 to copy active line to clipboard 0.",
309 "\033cF6 to copy all lines to clipboard 0.",
311 "\033cThe classic RightAmiga+C to copy selected",
312 "\033clines to clipboard 0 is made builtin.",
313 " ",
314 " ",
315 "\033cYou can sort the entries by dragging.",
316 "\033cYou start a drag using one of the qualifier",
317 "\033ckeys which are set in prefs,",
318 "\033cor going on the left and right of entries.",
321 "Example of horizontal line in top of entry",
322 "\033TExample of horizontal line in top of entry",
323 "Example of horizontal line in top of entry",
325 "Examples of horizontal line and thick line centered on entry",
326 "\033C",
327 "\033C\033t",
328 "\033C\033t[I7]",
329 "\033C\033t[M7]",
330 "\033C\033t[-5]",
331 "\033C\033t[N]",
332 "\033C\033t[NI3]",
333 "\033C\033t[NM7]",
334 "\033C\033t[N-5]",
335 "Examples of horizontal line and thick line centered on entry",
337 "Example of horizontal line in bottom of entry",
338 "\033BExample of horizontal line in bottom of entry",
339 "Example of horizontal line in bottom of entry",
341 "Examples of horizontal line centered on entry visible on left and rigth only",
342 "\033c\033EExample of left-right horizontal line",
343 "\033ESame, but left aligned",
344 "\033r\033ESame, but right aligned",
345 "\033t\033c\033ELeft-right horizontal thick line",
346 "\033t[N]\033c\033ELeft-right horizontal thick line",
347 "Examples of horizontal line centered on entry visible on left and rigth only",
350 "\033E\033cExamples of bitmap images :",
351 "\033c\033o[0] \033o[1]",
352 "which can be used without subclassing the NList class.",
354 "\033E\033cExamples of custom object images : ",
355 "\033o[2;9d51ffff;1] (default width/special 1)",
356 "\033o[2;9d51ffff;0,24] (24 pixel width/special 0)",
357 "\033o[2;9d51ffff;1,48] (48 pixel width/special 1)",
358 "\033o[2;9d51ffff;0,96] (96 pixel width/special 0)",
360 "\033E\033cExamples of custom object images : ",
361 "\033o[2;9d51ffff;8,30] (default width/special 8)",
362 "\033o[2;9d51ffff;6,40] (default width/special 6)",
363 "\033o[2;9d51ffff;7,40] (40 pixel width/special 7)",
364 "\033o[2;9d51ffff;4,50] (50 pixel width/special 4)",
365 "\033o[2;9d51ffff;5,50] (50 pixel width/special 5)",
366 "\033o[2;9d51ffff;2,30] (30 pixel width/special 2)",
367 "\033o[2;9d51ffff;3,30] (30 pixel width/special 3)",
369 "\033E\033cExamples of direct ImageSpec :",
370 "kmel/kmel_arrowdown.image : \033I[3:kmel/kmel_arrowdown.image]",
371 "WD/11pt/ArrowLeft.mf0 : \033I[3:WD/11pt/ArrowLeft.mf0]",
373 "\033C",
375 "ww\tTabulation test",
376 "w\tTabulation test",
377 "\033cww\tTabulation test",
378 "\033cw\tTabulation test",
379 "\033rww\tTabulation test",
380 "\033rw\tTabulation test",
383 "long line for FULLAUTO horizontal scroller test, long line for FullAuto horizontal scroller test, long line for FULLAUTO horizontal scroller test.",
385 "0 just a little \033bline to test\033n stuffs",
386 "1 just a little \033bline to test\033n stuffs",
387 "2 just a little \033bline to test\033n stuffs",
388 "3 just a little \033bline to test\033n stuffs",
389 "\033c4 just a little \033uline to test\033n (center)",
390 "\033c5 just a little \033uline to test\033n (center)",
391 "\033c6 just a little \033uline to test\033n (center)",
392 "\033r7 just a little \033uline to test\033n (right)",
393 "\033r8 just a little \033uline to test\033n (right)",
394 "\033r9 just a little \033uline to test\033n (right)",
395 "10 just a little line to test stuffs and bugs",
396 "11 just a little line to test stuffs and bugs",
397 "12 just a little line to test stuffs and bugs",
398 "13 just a little line to test stuffs and bugs",
399 "14 just a little line to test stuffs and bugs",
400 "15 just a little \033iline to test stuffs\033n and bugs",
401 "16 just a little line to test stuffs and bugs",
402 "17 just a little line to test stuffs and bugs",
403 "18 just a little line to test stuffs and bugs",
404 "19 just a little line to test stuffs and bugs",
405 "\033c20 just a little line to test stuffs and bugs (center)",
406 "\033c21 just a little line to test stuffs and bugs (center)",
407 "\033c22 just a little line to test stuffs and bugs (center)",
408 "\033c23 just a little line to test stuffs and bugs (center)",
409 "24 just a little line to test stuffs and bugs, just a little line",
410 "25 just a little line to test stuffs and bugs, just a little line",
411 "\033r26 just a little line to test stuffs and bugs (right)",
412 "\033r27 just a little line to test stuffs and bugs (right)",
413 "\033r28 just a little line to test stuffs and bugs (right)",
414 "\033r29 just a little line to test stuffs and bugs (right)",
415 "30 just a little line to test stuffs and bugs, just a little line to test",
416 "31 just a little line to test stuffs and bugs, just a little line to test",
417 "32 \0332just a little line to test stuffs and bugs, just a little line to test",
418 "33 \0333just a little line to test stuffs and bugs, just a little line to test",
419 "34 \0334just a little line to test stuffs and bugs, just a little line to test",
420 "35 \0335just a little line to test stuffs and bugs, just a little line to test",
421 "36 \0336just a little line to test stuffs and bugs, just a little line to test",
422 "37 \0337just a little line to test stuffs and bugs, just a little line to test",
423 "38 \0338just a little line to test stuffs and bugs, just a little line to test",
424 "39 \0339just a little line to test stuffs and bugs, just a little line to test",
425 "40 \033P[]just a little line to test stuffs and bugs, just a little line to test stuffs ",
426 "41 \033P[1]just a little line to test\033P[] stuffs and bugs, just a little line to test stuffs ",
427 "42 \033P[2]just a little line to test\033P[] stuffs and bugs, just a little line to test stuffs ",
428 "43 \033P[-1]just a little line to test\033P[] stuffs and bugs, just a little line to test stuffs ",
429 "44 \033P[-3]just a little line to test\033P[] stuffs and bugs, just a little line to test stuffs ",
430 "45 just a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
431 "46 just a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
432 "47 just a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
433 "48 just a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
434 "49 just a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
435 "50 \033ijust a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
436 "51 \033ujust a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
437 "52 \033bjust a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
438 "53 \033i\033ujust a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
439 "54 \033i\033bjust a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
440 "55 \033b\033ujust a little line to test stuffs and bugs, just a little line to test, just a little line to test, just a little line to test",
441 "56 \033i\033b\033ujust a little line to test stuffs and bugs, just a little line to test, just a little line to test, just a little line to test",
442 "57 just a little line to test stuffs and bugs, just a little line to test, just a little line to test, just a little line to test",
443 "58 just a little line to test stuffs and bugs, just a little line to test, just a little line to test, just a little line to test",
444 "59 just a little line to test stuffs and bugs, just a little line to test, just a little line to test, just a little line to test",
445 " ",
446 " ",
447 "\033c\033uI find it \033bnice\033n :-)",
448 NULL
451 /* *********************************************** */
453 #if defined(__amigaos4__)
454 #define GETINTERFACE(iface, base) (iface = (APTR)GetInterface((struct Library *)(base), "main", 1L, NULL))
455 #define DROPINTERFACE(iface) (DropInterface((struct Interface *)iface), iface = NULL)
456 #else
457 #define GETINTERFACE(iface, base) TRUE
458 #define DROPINTERFACE(iface)
459 #endif
461 static VOID fail(APTR APP_Main,const char *str)
463 if (APP_Main)
464 MUI_DisposeObject(APP_Main);
465 NLI_Delete();
467 if(MUIMasterBase)
469 DROPINTERFACE(IMUIMaster);
470 CloseLibrary(MUIMasterBase);
473 if(IntuitionBase)
475 DROPINTERFACE(IIntuition);
476 CloseLibrary((struct Library *)IntuitionBase);
479 if(GfxBase)
481 DROPINTERFACE(IGraphics);
482 CloseLibrary((struct Library *)GfxBase);
485 if(UtilityBase)
487 DROPINTERFACE(IUtility);
488 CloseLibrary((struct Library *)UtilityBase);
491 if (str)
492 { puts(str);
493 exit(20);
495 exit(0);
498 static VOID init(VOID)
500 APP_Main = NULL;
502 if((UtilityBase = (APTR)OpenLibrary("utility.library", 36)) &&
503 GETINTERFACE(IUtility, UtilityBase))
505 if((GfxBase = (APTR)OpenLibrary("graphics.library", 36)) &&
506 GETINTERFACE(IGraphics, GfxBase))
508 if((IntuitionBase = (APTR)OpenLibrary("intuition.library", 36)) &&
509 GETINTERFACE(IIntuition, IntuitionBase))
511 if((MUIMasterBase = OpenLibrary("muimaster.library", 19)) &&
512 GETINTERFACE(IMUIMaster, MUIMasterBase))
515 if(!NLI_Create())
516 fail(NULL,"Failed to create NLI class.");
518 else
519 fail(NULL,"Failed to open muimaster.library.");
521 else
522 fail(NULL,"Failed to open intuition.library.");
524 else
525 fail(NULL,"Failed to open graphics.library.");
527 else
528 fail(NULL,"Failed to open utility.library.");
533 /* *********************************************** */
536 int main(UNUSED int argc, UNUSED char *argv[])
538 LONG win_opened = 0;
539 LONG result;
540 static const char *const UsedClasses[] = {
541 "NList.mcc",
542 "NListviews.mcc",
543 NULL
546 init();
548 APP_Main = ApplicationObject,
549 MUIA_Application_Title , "NList-Demo",
550 MUIA_Application_Version , "$VER: NList-Demo 1.0 (" __DATE__ ")",
551 MUIA_Application_Copyright , "(C) 2001-2014 NList Open Source Team",
552 MUIA_Application_Author , "NList Open Source Team",
553 MUIA_Application_Description, "NList-Demo",
554 MUIA_Application_Base , "NList-Demo",
555 MUIA_Application_UsedClasses, UsedClasses,
557 SubWindow, WIN_Main = WindowObject,
558 MUIA_Window_Title, "NList-Demo 1996-2014",
559 MUIA_Window_ID , MAKE_ID('T','W','I','N'),
560 WindowContents, VGroup,
561 Child, HGroup,
562 Child, BT_InputOn = SimpleButtonCycle("InputOn"),
563 Child, BT_InputOff = SimpleButtonCycle("InputOff"),
564 Child, BT_SelLine = SimpleButtonCycle("SelLine"),
565 Child, BT_SelChar = SimpleButtonCycle("SelChar"),
566 Child, BT_Clear = SimpleButtonCycle("Clear"),
567 Child, BT_Add = SimpleButtonCycle("Add"),
568 End,
569 Child, HGroup,
570 Child, BT_NoMulti = SimpleButtonCycle("NoMulti"),
571 Child, BT_Multidef = SimpleButtonCycle("Def"),
572 Child, BT_Multi = SimpleButtonCycle("Multi"),
573 Child, BT_AllMulti = SimpleButtonCycle("AllMulti"),
574 Child, BM_img = IMG,
575 Child, BT_RemAct = SimpleButtonCycle("RemAct"),
576 Child, BT_RemSel = SimpleButtonCycle("RemSel"),
577 End,
578 Child, HGroup,
579 Child, BT_DragSortOn = SimpleButtonCycle("DragSortOn"),
580 Child, BT_DragSortOff = SimpleButtonCycle("DragSortOff"),
581 Child, BM_img2 = IMG2,
582 Child, BT_TitleOn = SimpleButtonCycle("TitleOn"),
583 Child, BT_TitleOff = SimpleButtonCycle("TitleOff"),
584 Child, BT_Sort = SimpleButtonCycle("Sort"),
585 Child, BT_OpenWin2 = SimpleButtonCycle("Win2"),
586 End,
587 Child, LV_Text = NListviewObject,
588 MUIA_CycleChain, 1,
590 MUIA_NListview_NList, LI_Text = NListObject,
591 MUIA_ObjectID, MAKE_ID('N','L','0','1'),
592 MUIA_NList_DefaultObjectOnClick, TRUE,
593 MUIA_NList_MultiSelect, MUIV_NList_MultiSelect_None,
594 MUIA_NList_DisplayHook2, &DisplayLI_TextHook,
595 MUIA_NList_CompareHook2, &CompareLI_TextHook,
596 MUIA_NList_ConstructHook2, &ConstructLI_TextHook,
597 MUIA_NList_DestructHook2, &DestructLI_TextHook,
598 MUIA_NList_Format, "BAR W=-1,BAR W=-1,BAR",
599 MUIA_NList_SourceArray, MainTextArray,
600 MUIA_NList_AutoVisible, TRUE,
601 MUIA_NList_TitleSeparator, TRUE,
602 MUIA_NList_Title, TRUE,
603 MUIA_NList_EntryValueDependent, TRUE,
604 MUIA_NList_MinColSortable, 0,
605 MUIA_NList_Imports, MUIV_NList_Imports_All,
606 MUIA_NList_Exports, MUIV_NList_Exports_All,
607 End,
608 MUIA_ShortHelp, "The nice multicolumn\ndraggable list\nwith char selection\npossibility :)",
609 End,
610 End,
611 End,
612 SubWindow, WIN_2 = WindowObject,
613 MUIA_Window_Title, "NList-Demo 1996-2006 Win 2",
614 MUIA_Window_ID , MAKE_ID('W','I','N','2'),
615 MUIA_Window_UseBottomBorderScroller, TRUE,
616 WindowContents, VGroup,
617 Child, NFloattext(MainTextString2),
618 Child, BalanceObject, End,
619 Child, VGroup,
620 MUIA_Group_VertSpacing, 1,
621 Child, LV_Text2 = NListviewObject,
622 MUIA_CycleChain, 1,
623 MUIA_NListview_Horiz_ScrollBar, MUIV_NListview_HSB_None,
624 MUIA_NListview_NList, LI_Text2 = NListObject,
625 MUIA_NList_DefaultObjectOnClick, TRUE,
626 MUIA_NList_ConstructHook, MUIV_NList_ConstructHook_String,
627 MUIA_NList_DestructHook, MUIV_NList_DestructHook_String,
628 MUIA_NList_SourceString, MainTextString,
629 End,
630 MUIA_ShortHelp, "The 2nd list",
631 End,
632 Child, ST_string = StringObject,
633 MUIA_CycleChain, 1,
634 StringFrame,
635 End,
636 Child, PR_Horiz = ScrollbarObject,
637 MUIA_Group_Horiz, TRUE,
638 MUIA_Prop_UseWinBorder,MUIV_Prop_UseWinBorder_Bottom,
639 End,
640 End,
641 End,
642 End,
643 End;
645 if(!APP_Main) fail(APP_Main,"Failed to create Application.");
648 /* ********** MAIN LIST NOTIFIES ********** */
650 DoMethod(LI_Text, MUIM_Notify, MUIA_NList_TitleClick,MUIV_EveryTime,
651 LI_Text, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_Both);
652 DoMethod(LI_Text, MUIM_Notify, MUIA_NList_TitleClick2,MUIV_EveryTime,
653 LI_Text, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_2);
654 DoMethod(LI_Text, MUIM_Notify, MUIA_NList_SortType,MUIV_EveryTime,
655 LI_Text, 3, MUIM_Set,MUIA_NList_TitleMark,MUIV_TriggerValue);
656 DoMethod(LI_Text, MUIM_Notify, MUIA_NList_SortType2,MUIV_EveryTime,
657 LI_Text, 3, MUIM_Set,MUIA_NList_TitleMark2,MUIV_TriggerValue);
660 /* ********** MAIN LIST IMAGES ********** */
662 DoMethod(LI_Text,MUIM_NList_UseImage,BM_img,0,0);
663 DoMethod(LI_Text,MUIM_NList_UseImage,BM_img2,1,0);
665 DoMethod(LI_Text,MUIM_NList_UseImage,NImageObject,2,~0L);
668 /* ********** BUTTONS NOTIFIES ********** */
670 DoMethod(BT_TitleOn, MUIM_Notify, MUIA_Pressed,FALSE,
671 LI_Text, 3, MUIM_Set,MUIA_NList_Title,"\033cThis is that list title ! :-)");
672 DoMethod(BT_TitleOff, MUIM_Notify, MUIA_Pressed,FALSE,
673 LI_Text, 3, MUIM_Set,MUIA_NList_Title,NULL);
674 DoMethod(BT_NoMulti, MUIM_Notify, MUIA_Pressed,FALSE,
675 LI_Text, 3, MUIM_Set,MUIA_NList_MultiSelect,MUIV_NList_MultiSelect_None);
676 DoMethod(BT_Multidef, MUIM_Notify, MUIA_Pressed,FALSE,
677 LI_Text, 3, MUIM_Set,MUIA_NList_MultiSelect,MUIV_NList_MultiSelect_Default);
678 DoMethod(BT_Multi, MUIM_Notify, MUIA_Pressed,FALSE,
679 LI_Text, 3, MUIM_Set,MUIA_NList_MultiSelect,MUIV_NList_MultiSelect_Shifted);
680 DoMethod(BT_AllMulti, MUIM_Notify, MUIA_Pressed,FALSE,
681 LI_Text, 3, MUIM_Set,MUIA_NList_MultiSelect,MUIV_NList_MultiSelect_Always);
682 DoMethod(BT_InputOn, MUIM_Notify, MUIA_Pressed,FALSE,
683 LI_Text, 3, MUIM_Set,MUIA_NList_Input,TRUE);
684 DoMethod(BT_InputOff, MUIM_Notify, MUIA_Pressed,FALSE,
685 LI_Text, 3, MUIM_Set,MUIA_NList_Input,FALSE);
686 DoMethod(BT_DragSortOn, MUIM_Notify, MUIA_Pressed,FALSE,
687 LI_Text, 3, MUIM_Set,MUIA_NList_DragSortable,TRUE);
688 DoMethod(BT_DragSortOff, MUIM_Notify, MUIA_Pressed,FALSE,
689 LI_Text, 3, MUIM_Set,MUIA_NList_DragSortable,FALSE);
690 DoMethod(BT_RemAct, MUIM_Notify, MUIA_Pressed,FALSE,
691 LI_Text, 2, MUIM_NList_Remove,MUIV_NList_Remove_Active);
692 DoMethod(BT_RemSel, MUIM_Notify, MUIA_Pressed,FALSE,
693 LI_Text, 2, MUIM_NList_Remove,MUIV_NList_Remove_Selected);
694 DoMethod(BT_Clear, MUIM_Notify, MUIA_Pressed,FALSE,
695 LI_Text, 1, MUIM_NList_Clear);
696 DoMethod(BT_Add, MUIM_Notify, MUIA_Pressed,FALSE,
697 LI_Text, 4, MUIM_NList_Insert,MainTextArray,15,MUIV_NList_Insert_Bottom);
698 DoMethod(BT_Sort, MUIM_Notify, MUIA_Pressed,FALSE,
699 LI_Text, 1, MUIM_NList_Sort);
700 DoMethod(BT_SelLine, MUIM_Notify, MUIA_Pressed,FALSE,
701 LI_Text, 3, MUIM_Set,MUIA_NList_TypeSelect,MUIV_NList_TypeSelect_Line);
702 DoMethod(BT_SelChar, MUIM_Notify, MUIA_Pressed,FALSE,
703 LI_Text, 3, MUIM_Set,MUIA_NList_TypeSelect,MUIV_NList_TypeSelect_Char);
704 DoMethod(BT_OpenWin2, MUIM_Notify, MUIA_Pressed,FALSE,
705 WIN_2, 3, MUIM_Set,MUIA_Window_Open,TRUE);
708 /* ********** WINDOW1 KEYS NOTIFIES ********** */
710 DoMethod(WIN_Main,MUIM_Notify, MUIA_Window_InputEvent, "f2",
711 LI_Text, 4,MUIM_NList_CopyTo,MUIV_NList_CopyTo_Selected,"PRT:",&result,NULL);
712 DoMethod(WIN_Main,MUIM_Notify, MUIA_Window_InputEvent, "f3",
713 LI_Text, 4,MUIM_NList_CopyTo,MUIV_NList_CopyTo_All,"RAM:tmp.txt",&result,NULL);
714 DoMethod(WIN_Main,MUIM_Notify, MUIA_Window_InputEvent, "f4",
715 LI_Text, 4,MUIM_NList_CopyToClip,MUIV_NList_CopyToClip_Selected,0L,NULL,NULL);
716 DoMethod(WIN_Main,MUIM_Notify, MUIA_Window_InputEvent, "f5",
717 LI_Text, 4,MUIM_NList_CopyToClip,MUIV_NList_CopyToClip_Active,0L,NULL,NULL);
718 DoMethod(WIN_Main,MUIM_Notify, MUIA_Window_InputEvent, "f6",
719 LI_Text, 4,MUIM_NList_CopyToClip,MUIV_NList_CopyToClip_All,0L,NULL,NULL);
722 /* ********** WINDOW2 LIST NOTIFIES ********** */
724 DoMethod(LI_Text2,MUIM_Notify,MUIA_NList_ButtonClick, 1,
725 APP_Main, 6, MUIM_Application_PushMethod,
726 WIN_2, 3, MUIM_Set,MUIA_Window_Open,FALSE);
728 DoMethod(LI_Text2,MUIM_Notify,MUIA_NList_ButtonClick, 2,
729 LI_Text, 1, MUIM_NList_Clear);
732 DoMethod(LI_Text2, MUIM_Notify, MUIA_NList_Horiz_Entries,MUIV_EveryTime,
733 PR_Horiz, 3, MUIM_NoNotifySet,MUIA_Prop_Entries,MUIV_TriggerValue);
734 DoMethod(LI_Text2, MUIM_Notify, MUIA_NList_Horiz_Visible,MUIV_EveryTime,
735 PR_Horiz, 3, MUIM_NoNotifySet,MUIA_Prop_Visible,MUIV_TriggerValue);
736 DoMethod(LI_Text2, MUIM_Notify, MUIA_NList_Horiz_First,MUIV_EveryTime,
737 PR_Horiz, 3, MUIM_NoNotifySet,MUIA_Prop_First,MUIV_TriggerValue);
738 DoMethod(PR_Horiz, MUIM_Notify, MUIA_Prop_First,MUIV_EveryTime,
739 LI_Text2, 3, MUIM_NoNotifySet,MUIA_NList_Horiz_First,MUIV_TriggerValue);
740 DoMethod(LI_Text2, MUIM_Notify, MUIA_NList_HorizDeltaFactor,MUIV_EveryTime,
741 PR_Horiz, 3, MUIM_NoNotifySet,MUIA_Prop_DeltaFactor,MUIV_TriggerValue);
743 set(ST_string, MUIA_String_AttachedList, LI_Text2);
744 DoMethod(LI_Text2,MUIM_Notify,MUIA_NList_SelectChange,TRUE,APP_Main,2,MUIM_Application_ReturnID,ID_LIST2_ACTIVE);
745 DoMethod(LI_Text2,MUIM_Notify,MUIA_NList_Active,MUIV_EveryTime,APP_Main,2,MUIM_Application_ReturnID,ID_LIST2_ACTIVE);
746 set(LI_Text2, MUIA_NList_Active, 2);
749 /* ********** WINDOW2 LIST IMAGES ********** */
751 DoMethod(LI_Text2,MUIM_NList_UseImage,BM_img,0,0);
752 DoMethod(LI_Text2,MUIM_NList_UseImage,BM_img2,1,0);
754 DoMethod(LI_Text2,MUIM_NList_UseImage,SimpleButtonTiny("Click me to close"),2,~0L);
755 DoMethod(LI_Text2,MUIM_NList_UseImage,SimpleButtonTiny("Clear main list"),3,~0L);
758 /* ********** WINDOW2 NOTIFIES ********** */
760 DoMethod(WIN_Main,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
761 APP_Main, 5, MUIM_Application_PushMethod,
762 APP_Main,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
764 DoMethod(WIN_2,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
765 APP_Main, 6, MUIM_Application_PushMethod,
766 WIN_2, 3, MUIM_Set,MUIA_Window_Open,FALSE);
768 set(WIN_Main, MUIA_Window_DefaultObject, LV_Text);
769 set(WIN_Main, MUIA_Window_ActiveObject, LV_Text);
770 set(WIN_2, MUIA_Window_ActiveObject, ST_string);
771 set(WIN_2, MUIA_Window_DefaultObject, LV_Text2);
774 /* ************************************** */
776 DoMethod(APP_Main,MUIM_Application_Load,MUIV_Application_Load_ENVARC);
778 /* *** If need to be sorted, sort then restore the active and first *** */
779 /* *** which were set in the Application_Load *** */
781 ULONG active = 0,first = 0,sorttype = 0;
782 get(LI_Text,MUIA_NList_SortType,&sorttype);
783 if (sorttype != MUIV_NList_SortType_None)
784 { get(LI_Text,MUIA_NList_Active,&active);
785 get(LI_Text,MUIA_NList_First,&first);
786 DoMethod(LI_Text, MUIM_NList_Sort);
787 set(LI_Text,MUIA_NList_Active,active);
788 set(LI_Text,MUIA_NList_First,first);
792 set(WIN_2,MUIA_Window_Open,TRUE);
793 set(WIN_Main,MUIA_Window_Open,TRUE);
795 get(WIN_Main,MUIA_Window_Open,&win_opened);
796 if (win_opened)
798 LONG id;
799 ULONG sigs = 0;
800 char *line;
802 while ((id = DoMethod(APP_Main,MUIM_Application_NewInput,&sigs)) != (LONG)MUIV_Application_ReturnID_Quit)
804 if (id == ID_LIST2_ACTIVE)
805 { DoMethod(LI_Text2, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, &line);
806 set(ST_string, MUIA_String_Contents, line);
807 set(WIN_2, MUIA_Window_ActiveObject, ST_string);
809 if (sigs)
810 { sigs = Wait(sigs | SIGBREAKF_CTRL_C);
811 if (sigs & SIGBREAKF_CTRL_C) break;
815 else
816 printf("failed to open main window !\n");
818 DoMethod(APP_Main,MUIM_Application_Save,MUIV_Application_Save_ENVARC);
820 set(WIN_2,MUIA_Window_Open,FALSE);
821 set(WIN_Main,MUIA_Window_Open,FALSE);
823 DoMethod(LI_Text,MUIM_NList_UseImage,NULL,-1,0);
824 DoMethod(LI_Text2,MUIM_NList_UseImage,NULL,-1,0);
826 fail(APP_Main,NULL);
828 return 0;