add necessary tasklist spinlocks
[AROS.git] / rom / intuition / menudecorclass.c
blobd05f67674efd9c27df2b08b2c9ddceec981f9107
1 /*
2 Copyright 1995-2011, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
8 #include <dos/dos.h>
9 #include <dos/dosextens.h>
11 #include <intuition/intuition.h>
12 #include <intuition/intuitionbase.h>
13 #include <intuition/classes.h>
14 #include <intuition/classusr.h>
15 #include <intuition/menudecorclass.h>
16 #include <intuition/cghooks.h>
17 #include <intuition/icclass.h>
18 #include <intuition/extensions.h>
20 #include <graphics/gfxbase.h>
21 #include <graphics/gfxmacros.h>
23 #include <utility/tagitem.h>
24 #include <utility/hooks.h>
26 #include <clib/macros.h>
28 #include <string.h>
30 #include <proto/exec.h>
31 #include <proto/intuition.h>
32 #include <proto/graphics.h>
33 #include <proto/utility.h>
35 #include <proto/alib.h>
37 #include "intuition_intern.h"
38 #include "gadgets.h"
41 /**************************************************************************************************/
43 #ifdef __AROS__
44 #define USE_AROS_DEFSIZE 1
45 #else
46 #define USE_AROS_DEFSIZE 0
47 #endif
49 #define DEFSIZE_WIDTH 14
50 #define DEFSIZE_HEIGHT 14
52 #define HSPACING 3
53 #define VSPACING 3
54 #define REFHEIGHT (msg->mdp_ReferenceFont->tf_YSize)
55 #define REFWIDTH REFHEIGHT
57 /* Ralph Schmidt
58 * heuristics for smaller arrows used in apps
59 * like filer
61 #define HSPACING_MIDDLE 2
62 #define VSPACING_MIDDLE 2
63 #define HSPACING_SMALL 1
64 #define VSPACING_SMALL 1
66 #define DRI(dri) ((struct DrawInfo *)(dri))
68 /**************************************************************************************************/
70 #undef DEBUG
71 #define DEBUG 0
72 #include <aros/debug.h>
73 /**************************************************************************************************/
75 void menu_draw_thick_line(Class *cl, struct RastPort *rport,
76 LONG x1, LONG y1, LONG x2, LONG y2,
77 UWORD thickness)
79 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
80 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
82 Move(rport, x1, y1);
83 Draw(rport, x2, y2);
84 /* Georg Steger */
85 Move(rport, x1 + 1, y1);
86 Draw(rport, x2 + 1, y2);
89 IPTR MenuDecorClass__OM_NEW(Class *cl, Object *obj, struct opSet *msg)
91 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
92 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
93 struct scrdecor_data *data;
95 obj = (Object *)DoSuperMethodA(cl, obj, (Msg)msg);
96 if (obj)
98 data = INST_DATA(cl, obj);
100 data->userbuffersize = (ULONG) GetTagData(MDA_UserBuffer, 0, msg->ops_AttrList);
104 return (IPTR)obj;
107 /**************************************************************************************************/
109 IPTR MenuDecorClass__OM_GET(Class *cl, Object *obj, struct opGet *msg)
111 struct scrdecor_data *data = INST_DATA(cl, obj);
113 switch(msg->opg_AttrID)
115 case MDA_UserBuffer:
116 *msg->opg_Storage = (IPTR) data->userbuffersize;
117 break;
119 case MDA_TrueColorOnly:
120 *msg->opg_Storage = FALSE;
121 break;
123 default:
124 return DoSuperMethodA(cl, obj, (Msg)msg);
127 return 1;
131 /**************************************************************************************************/
133 IPTR MenuDecorClass__MDM_GETDEFSIZE_SYSIMAGE(Class *cl, Object *obj, struct mdpGetDefSizeSysImage *msg)
135 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
136 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
138 switch(msg->mdp_Which)
140 case SUBMENUIMAGE:
141 *msg->mdp_Width = 0;
142 *msg->mdp_Height = 0;
143 struct RastPort *rp = CreateRastPort();
144 if (rp)
146 struct TextExtent TextExt;
147 SetFont(rp, msg->mdp_ReferenceFont);
148 TextExtent(rp, "\xBB", 1, &TextExt);
149 *msg->mdp_Width = TextExt.te_Width;
150 *msg->mdp_Height = TextExt.te_Height;
151 FreeRastPort(rp);
153 break;
155 case MENUCHECK:
156 *msg->mdp_Width = REFWIDTH / 2 + 4; // reffont->tf_XSize * 3 / 2;
157 *msg->mdp_Height= REFHEIGHT;
158 break;
160 default:
161 *msg->mdp_Width = DEFSIZE_WIDTH;
162 *msg->mdp_Height = DEFSIZE_HEIGHT;
163 break;
166 return TRUE;
169 IPTR MenuDecorClass__MDM_DRAW_SYSIMAGE(Class *cl, Object *obj, struct mdpDrawSysImage *msg)
171 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
172 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
173 struct RastPort *rport = msg->mdp_RPort;
174 UWORD *pens = DRI(msg->mdp_Dri)->dri_Pens;
175 LONG left = msg->mdp_X;
176 LONG top = msg->mdp_Y;
177 LONG width = msg->mdp_Width;
178 LONG height = msg->mdp_Height;
179 LONG right = left + width - 1;
180 LONG bottom = top + height - 1;
182 SetDrMd(rport, JAM1);
184 switch(msg->mdp_Which)
186 case SUBMENUIMAGE:
188 if (MENUS_AMIGALOOK(IntuitionBase))
190 SetAPen(rport, pens[BARBLOCKPEN]);
192 else
194 SetAPen(rport, pens[(msg->mdp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
196 RectFill(rport, left, top, right, bottom);
197 SetAPen(rport, pens[BARDETAILPEN]);
198 SetDrMd(rport, JAM1);
199 WORD x = left;
201 Move(rport, x, top + rport->Font->tf_Baseline);
202 Text(rport, "\xBB", 1);
203 break;
206 case MENUCHECK:
208 if (MENUS_AMIGALOOK(IntuitionBase))
210 SetAPen(rport, pens[BARBLOCKPEN]);
212 else
214 SetAPen(rport, pens[(msg->mdp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
217 RectFill(rport, left, top, right, bottom);
219 SetAPen(rport, pens[BARDETAILPEN]);
220 menu_draw_thick_line(cl, rport, left + 1, top + height / 3 , left + 1, bottom, 0);
221 menu_draw_thick_line(cl, rport, left + 2, bottom, right - 2, top, 0);
223 break;
226 case AMIGAKEY:
228 struct TextFont *oldfont;
229 UBYTE oldstyle;
231 if (MENUS_AMIGALOOK(IntuitionBase))
233 SetAPen(rport, pens[BARDETAILPEN]);
235 else
237 SetAPen(rport, pens[SHINEPEN]);
240 RectFill(rport, left, top, right, bottom);
242 if (MENUS_AMIGALOOK(IntuitionBase))
244 SetAPen(rport, pens[BARBLOCKPEN]);
246 oldfont = rport->Font;
247 oldstyle = rport->AlgoStyle;
249 SetFont(rport, GfxBase->DefaultFont);
250 SetSoftStyle(rport, FSF_ITALIC, AskSoftStyle(rport));
252 Move(rport, left + (width - rport->TxWidth) / 2,
253 top + (height - rport->TxHeight) / 2 + rport->TxBaseline);
254 Text(rport, "A", 1);
256 SetSoftStyle(rport, oldstyle, AskSoftStyle(rport));
257 SetFont(rport, oldfont);
259 SetAPen(rport, pens[BARBLOCKPEN]);
261 else
263 SetAPen(rport, pens[SHADOWPEN]);
265 RectFill(rport, left + 1, top, right - 1, top);
266 RectFill(rport, right, top + 1, right, bottom - 1);
267 RectFill(rport, left + 1, bottom, right - 1, bottom);
268 RectFill(rport, left, top + 1, left, bottom - 1);
270 SetAPen(rport, pens[BACKGROUNDPEN]);
271 RectFill(rport, left + 1, bottom - 1, right - 1, bottom - 1);
272 RectFill(rport, right - 1, top + 1, right - 1, bottom - 2);
274 RectFill(rport, left + 2, top + 2, left + 4, top + 2);
275 RectFill(rport, left + 2, top + 3, left + 2, top + 4);
277 SetAPen(rport, pens[SHADOWPEN]);
278 RectFill(rport, left + 2, bottom - 2, right - 2, bottom - 2);
279 RectFill(rport, right - 2, top + 2, right - 2, bottom - 4);
282 WORD a_size = height - 7;
283 WORD a_left = left + 5;
284 WORD a_top = top + 2;
285 WORD a_right = a_left + a_size;
286 WORD a_bottom = a_top + a_size;
288 Move(rport, a_left, a_bottom);
289 Draw(rport, a_right, a_top);
290 Draw(rport, a_right, a_bottom);
291 Move(rport, a_right - 1, a_top + 1);
292 Draw(rport, a_right - 1, a_bottom);
295 SetAPen(rport, pens[(msg->mdp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
298 WritePixel(rport, left, top);
299 WritePixel(rport, right, top);
300 WritePixel(rport, right, bottom);
301 WritePixel(rport, left, bottom);
304 return TRUE;
307 IPTR MenuDecorClass__MDM_GETMENUSPACES(Class *cl, Object *obj, struct mdpGetMenuSpaces *msg)
309 return FALSE;
312 /**************************************************************************************************/
314 IPTR MenuDecorClass__MDM_DRAWBACKGROUND(Class *cl, Object *obj, struct mdpDrawBackground *msg)
316 return FALSE;
319 IPTR MenuDecorClass__MDM_INITMENU(Class *cl, Object *obj, struct mdpInitMenu *msg)
321 return FALSE;
324 IPTR MenuDecorClass__MDM_EXITMENU(Class *cl, Object *obj, struct mdpExitMenu *msg)
326 return FALSE;
329 /**************************************************************************************************/