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 ***************************************************************************/
27 #include <clib/alib_protos.h>
34 #include <exec/types.h>
35 #include <exec/memory.h>
36 #include <exec/ports.h>
38 #include <libraries/dos.h>
39 #include <libraries/dosextens.h>
40 #include <libraries/gadtools.h>
41 #include <libraries/asl.h>
42 #include <libraries/mui.h>
43 #include <workbench/workbench.h>
44 #include <intuition/intuition.h>
45 #include <intuition/classusr.h>
46 #include <graphics/gfxmacros.h>
48 #include <proto/exec.h>
49 #include <proto/dos.h>
50 #include <proto/gadtools.h>
51 #include <proto/asl.h>
53 extern struct Library
*MUIMasterBase
;
55 #include <mui/NListview_mcc.h>
56 #include <mui/NFloattext_mcc.h>
58 #include "NList-Demo2.h"
60 #include <proto/muimaster.h>
64 /* *********************************************** */
72 /* *********************************************** */
74 HOOKPROTONHNO(ConstructLI_TextFunc
, APTR
, struct NList_ConstructMessage
*ncm
)
76 struct LITD
*new_entry
= (struct LITD
*) AllocVec(sizeof(struct LITD
),0);
82 new_entry
->str2
= (char *) ncm
->entry
;
83 while ((j
< 3) && new_entry
->str2
[i
])
85 if ((new_entry
->str2
[i
] > 'A') && (new_entry
->str2
[i
] < 'z'))
86 new_entry
->str1
[j
++] = new_entry
->str2
[i
];
87 if (new_entry
->str2
[i
] == '\033')
91 new_entry
->str1
[j
] = '\0';
97 MakeHook(ConstructLI_TextHook
, ConstructLI_TextFunc
);
99 /* *********************************************** */
101 HOOKPROTONHNO(DestructLI_TextFunc
, void, struct NList_DestructMessage
*ndm
)
104 FreeVec((void *) ndm
->entry
);
106 MakeHook(DestructLI_TextHook
, DestructLI_TextFunc
);
108 /* *********************************************** */
112 HOOKPROTONHNO(DisplayLI_TextFunc
, void, struct NList_DisplayMessage
*ndm
)
114 struct LITD
*entry
= (struct LITD
*) ndm
->entry
;
117 { if (entry
->num
< 0)
118 entry
->num
= ndm
->entry_pos
;
120 ndm
->preparses
[0] = (STRPTR
)"\033c";
121 ndm
->preparses
[1] = (STRPTR
)"\033c";
123 if (entry
->num
% 20 == 3)
124 ndm
->strings
[0] = (STRPTR
)"\033o[0]";
125 else if (entry
->num
% 20 == 13)
126 ndm
->strings
[0] = (STRPTR
)"\033o[1]";
129 snprintf(buf
, sizeof(buf
), "%d", (unsigned int)entry
->num
);
130 ndm
->strings
[0] = buf
;
133 ndm
->strings
[1] = (char *) entry
->str1
;
134 ndm
->strings
[2] = (char *) entry
->str2
;
138 ndm
->preparses
[0] = (STRPTR
)"\033c";
139 ndm
->preparses
[1] = (STRPTR
)"\033c";
140 ndm
->preparses
[2] = (STRPTR
)"\033c";
141 ndm
->strings
[0] = (STRPTR
)"Num";
142 ndm
->strings
[1] = (STRPTR
)"Short";
143 ndm
->strings
[2] = (STRPTR
)"This is the list title !\033n\033b :-)";
146 MakeHook(DisplayLI_TextHook
, DisplayLI_TextFunc
);
149 /* *********************************************** */
151 HOOKPROTONHNO(CompareLI_TextFunc
, LONG
, struct NList_CompareMessage
*ncm
)
153 struct LITD
*entry1
= (struct LITD
*) ncm
->entry1
;
154 struct LITD
*entry2
= (struct LITD
*) ncm
->entry2
;
155 LONG col1
= ncm
->sort_type
& MUIV_NList_TitleMark_ColMask
;
156 LONG col2
= ncm
->sort_type2
& MUIV_NList_TitleMark2_ColMask
;
160 LONG st = ncm->sort_type & MUIV_NList_TitleMark_TypeMask;
161 kprintf("%lx|Compare() %lx / %lx / %lx\n",obj,ncm->sort_type,st,ncm->sort_type2);
164 if(ncm
->sort_type
== (LONG
)MUIV_NList_SortType_None
)
168 { if (ncm
->sort_type
& MUIV_NList_TitleMark_TypeMask
)
169 result
= entry2
->num
- entry1
->num
;
171 result
= entry1
->num
- entry2
->num
;
174 { if (ncm
->sort_type
& MUIV_NList_TitleMark_TypeMask
)
175 result
= (LONG
) stricmp(entry2
->str1
,entry1
->str1
);
177 result
= (LONG
) stricmp(entry1
->str1
,entry2
->str1
);
180 { if (ncm
->sort_type
& MUIV_NList_TitleMark_TypeMask
)
181 result
= (LONG
) stricmp(entry2
->str2
,entry1
->str2
);
183 result
= (LONG
) stricmp(entry1
->str2
,entry2
->str2
);
186 if ((result
!= 0) || (col1
== col2
))
190 { if (ncm
->sort_type2
& MUIV_NList_TitleMark2_TypeMask
)
191 result
= entry2
->num
- entry1
->num
;
193 result
= entry1
->num
- entry2
->num
;
196 { if (ncm
->sort_type2
& MUIV_NList_TitleMark2_TypeMask
)
197 result
= (LONG
) stricmp(entry2
->str1
,entry1
->str1
);
199 result
= (LONG
) stricmp(entry1
->str1
,entry2
->str1
);
202 { if (ncm
->sort_type2
& MUIV_NList_TitleMark2_TypeMask
)
203 result
= (LONG
) stricmp(entry2
->str2
,entry1
->str2
);
205 result
= (LONG
) stricmp(entry1
->str2
,entry2
->str2
);
210 MakeHook(CompareLI_TextHook
, CompareLI_TextFunc
);