grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / nlist / demo / NList-Demo3.c
blob7327f1d71b8be032bc9ca3de3fea3d83e8f81b66
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>
42 #include <graphics/gfxmacros.h>
43 #undef GetOutlinePen
45 #if !defined(__amigaos4__)
46 #include <clib/alib_protos.h>
47 #endif
49 #include <proto/exec.h>
50 #include <proto/dos.h>
51 #include <proto/gadtools.h>
52 #include <proto/graphics.h>
53 #include <proto/utility.h>
54 #include <proto/asl.h>
55 #include <proto/intuition.h>
57 extern struct Library *MUIMasterBase;
59 #include <mui/NListview_mcc.h>
60 #include <mui/NFloattext_mcc.h>
62 #include "NList-Demo3.h"
64 #include <proto/muimaster.h>
66 #include "SDI_hook.h"
68 /* *********************************************** */
71 struct MUI_CustomClass *NLI_Class = NULL;
74 /* *********************************************** */
77 struct NLIData
79 LONG special;
80 LONG EntryCurrent;
81 LONG EntryHeight;
85 /* *********************************************** */
88 IPTR mNLI_Draw(struct IClass *cl,Object *obj,struct MUIP_Draw *msg)
90 struct NLIData *data = INST_DATA(cl,obj);
91 DoSuperMethodA(cl,obj,(Msg) msg);
92 if ((msg->flags & MADF_DRAWOBJECT) || (msg->flags & MADF_DRAWUPDATE))
93 { WORD x1,x2,x3,x4,x5,y1,y2,y3,y4,y5;
94 y1 = _top(obj);
95 y2 = _bottom(obj);
96 x1 = _left(obj);
97 x2 = _right(obj);
98 if ((data->special == 0) || (data->special == 1))
100 y3 = (y1+y2)/2;
101 x3 = (x1+x2)/2;
102 SetAPen(_rp(obj),_pens(obj)[MPEN_MARK]);
103 SetBPen(_rp(obj),_pens(obj)[MPEN_SHADOW]);
104 SetDrMd(_rp(obj),JAM2);
105 SetDrPt(_rp(obj),(UWORD) ~0);
106 if (data->special == 0)
107 { Move(_rp(obj), x3-2, y1+1);
108 Draw(_rp(obj), x3-2, y2-1);
109 Move(_rp(obj), x3, y1+1);
110 Draw(_rp(obj), x3, y2-1);
111 Move(_rp(obj), x3+2, y1+1);
112 Draw(_rp(obj), x3+2, y2-1);
114 else if (data->special == 1)
115 { Move(_rp(obj), x1, y3-2);
116 Draw(_rp(obj), x2, y3-2);
117 Move(_rp(obj), x1, y3);
118 Draw(_rp(obj), x2, y3);
119 Move(_rp(obj), x1, y3+2);
120 Draw(_rp(obj), x2, y3+2);
122 SetAPen(_rp(obj),_pens(obj)[MPEN_SHADOW]);
123 Move(_rp(obj), x1, y2-1);
124 Draw(_rp(obj), x1, y1+1);
125 Draw(_rp(obj), x2, y1+1);
126 SetAPen(_rp(obj),_pens(obj)[MPEN_SHINE]);
127 Draw(_rp(obj), x2, y2-1);
128 Draw(_rp(obj), x1, y2-1);
129 SetDrMd(_rp(obj),JAM1);
131 else if (((x2 - x1) >= 10) && ((y2 - y1) >= 8)) /* and special==2 to 9 */
133 y3 = (y1+y2)/2;
134 x3 = x1 + 1;
135 x2--;
136 SetAPen(_rp(obj),_pens(obj)[MPEN_SHADOW]);
137 SetDrMd(_rp(obj),JAM1);
139 y4 = y1;
140 x4 = x3 + 2;
141 y5 = y2;
142 x5 = x2-6;
143 if ((data->EntryHeight & 1) && (data->EntryCurrent & 1))
144 y4++;
145 if ((y4 & 1) != (y3 & 1))
146 x4--;
147 if (data->special > 5)
148 x5 = x2;
149 if (data->special & 1)
150 y5 = y3;
151 while (y4 <= y5)
152 { WritePixel(_rp(obj), x3, y4);
153 y4 += 2;
155 if (data->special <= 7)
157 while (x4 <= x5)
158 { WritePixel(_rp(obj), x4, y3);
159 x4 += 2;
162 if (data->special <= 5)
164 Move(_rp(obj), x2-6, y3);
165 Draw(_rp(obj), x2-6, y3-3);
166 Draw(_rp(obj), x2, y3-3);
167 Draw(_rp(obj), x2, y3+3);
168 Draw(_rp(obj), x2-6, y3+3);
169 Draw(_rp(obj), x2-6, y3);
170 Move(_rp(obj), x2-4, y3);
171 Draw(_rp(obj), x2-2, y3);
172 if ((data->special == 2) || (data->special == 3))
173 { Move(_rp(obj), x2-3, y3-1);
174 Draw(_rp(obj), x2-3, y3+1);
179 msg->flags = 0;
180 return(0);
184 IPTR mNLI_New(struct IClass *cl,Object *obj,struct opSet *msg)
186 struct NLIData *data;
187 if (!(obj = (Object *)DoSuperMethodA(cl,obj,(Msg) msg)))
188 return(0);
189 data = INST_DATA(cl,obj);
190 data->special = 0;
191 return((IPTR) obj);
195 IPTR mNLI_AskMinMax(struct IClass *cl,Object *obj,struct MUIP_AskMinMax *msg)
197 DoSuperMethodA(cl,obj,(Msg) msg);
198 msg->MinMaxInfo->MinWidth += 8;
199 msg->MinMaxInfo->DefWidth += 18; /* the only width def value really used by NList object */
200 msg->MinMaxInfo->MaxWidth += MUI_MAXMAX;
201 msg->MinMaxInfo->MinHeight += 7; /* the only height def value really used by NList object */
202 msg->MinMaxInfo->DefHeight += 12;
203 msg->MinMaxInfo->MaxHeight += MUI_MAXMAX;
204 return(0);
208 IPTR mNLI_Set(struct IClass *cl,Object *obj,Msg msg)
210 struct NLIData *data = INST_DATA(cl,obj);
211 struct TagItem *tags,*tag;
213 for(tags=((struct opSet *)msg)->ops_AttrList; (tag=(struct TagItem *)NextTagItem((APTR)&tags)); )
215 switch (tag->ti_Tag)
217 case MUIA_NLIMG_EntryCurrent:
218 data->EntryCurrent = tag->ti_Data;
219 break;
220 case MUIA_NLIMG_EntryHeight:
221 data->EntryHeight = tag->ti_Data;
222 break;
223 case MUIA_NLIMG_Spec:
224 data->special = tag->ti_Data;
225 break;
228 return (0);
231 DISPATCHER(NLI_Dispatcher)
233 switch (msg->MethodID)
235 case OM_NEW : return ( mNLI_New(cl,obj,(APTR)msg));
236 case OM_SET : return ( mNLI_Set(cl,obj,(APTR)msg));
237 case MUIM_AskMinMax : return (mNLI_AskMinMax(cl,obj,(APTR)msg));
238 case MUIM_Draw : return ( mNLI_Draw(cl,obj,(APTR)msg));
241 return(DoSuperMethodA(cl,obj,msg));
247 struct MUI_CustomClass *NLI_Create(void)
249 NLI_Class = MUI_CreateCustomClass(NULL, (STRPTR)MUIC_Area, NULL, sizeof(struct NLIData), ENTRY(NLI_Dispatcher));
251 return (NLI_Class);
255 void NLI_Delete(void)
257 if (NLI_Class)
258 MUI_DeleteCustomClass(NLI_Class);
259 NLI_Class = NULL;