fix properties
[AROS.git] / rom / intuition / menudecorclass.c
blob7b301ba789bda14ede701e959b925b2309c280a2
1 /*
2 Copyright 1995-2005, 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 IntuitionBase
71 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
73 #undef DEBUG
74 #define DEBUG 0
75 #include <aros/debug.h>
76 /**************************************************************************************************/
78 void menu_draw_thick_line(Class *cl, struct RastPort *rport,
79 LONG x1, LONG y1, LONG x2, LONG y2,
80 UWORD thickness)
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 scrdecor_data *data;
93 obj = (Object *)DoSuperMethodA(cl, obj, (Msg)msg);
94 if (obj)
96 data = INST_DATA(cl, obj);
98 data->userbuffersize = (ULONG) GetTagData(MDA_UserBuffer, 0, msg->ops_AttrList);
102 return (IPTR)obj;
105 /**************************************************************************************************/
107 IPTR MenuDecorClass__OM_GET(Class *cl, Object *obj, struct opGet *msg)
109 struct scrdecor_data *data = INST_DATA(cl, obj);
111 switch(msg->opg_AttrID)
113 case MDA_UserBuffer:
114 *msg->opg_Storage = (IPTR) data->userbuffersize;
115 break;
117 case MDA_TrueColorOnly:
118 *msg->opg_Storage = FALSE;
119 break;
121 default:
122 return DoSuperMethodA(cl, obj, (Msg)msg);
125 return 1;
129 /**************************************************************************************************/
131 IPTR MenuDecorClass__MDM_GETDEFSIZE_SYSIMAGE(Class *cl, Object *obj, struct mdpGetDefSizeSysImage *msg)
134 switch(msg->mdp_Which)
136 case SUBMENUIMAGE:
137 *msg->mdp_Width = 0;
138 *msg->mdp_Height = 0;
139 struct RastPort *rp = CreateRastPort();
140 if (rp)
142 struct TextExtent TextExt;
143 SetFont(rp, msg->mdp_ReferenceFont);
144 TextExtent(rp, ">>", 2, &TextExt);
145 *msg->mdp_Width = TextExt.te_Width;
146 *msg->mdp_Height = TextExt.te_Height;
147 FreeRastPort(rp);
149 break;
151 case MENUCHECK:
152 *msg->mdp_Width = REFWIDTH / 2 + 4; // reffont->tf_XSize * 3 / 2;
153 *msg->mdp_Height= REFHEIGHT;
154 break;
156 default:
157 *msg->mdp_Width = DEFSIZE_WIDTH;
158 *msg->mdp_Height = DEFSIZE_HEIGHT;
159 break;
162 return TRUE;
165 IPTR MenuDecorClass__MDM_DRAW_SYSIMAGE(Class *cl, Object *obj, struct mdpDrawSysImage *msg)
167 struct RastPort *rport = msg->mdp_RPort;
168 UWORD *pens = DRI(msg->mdp_Dri)->dri_Pens;
169 LONG left = msg->mdp_X;
170 LONG top = msg->mdp_Y;
171 LONG width = msg->mdp_Width;
172 LONG height = msg->mdp_Height;
173 LONG right = left + width - 1;
174 LONG bottom = top + height - 1;
176 SetDrMd(rport, JAM1);
178 switch(msg->mdp_Which)
180 case SUBMENUIMAGE:
182 if (MENUS_AMIGALOOK)
184 SetAPen(rport, pens[BARBLOCKPEN]);
186 else
188 SetAPen(rport, pens[(msg->mdp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
190 RectFill(rport, left, top, right, bottom);
191 SetAPen(rport, pens[BARDETAILPEN]);
192 SetDrMd(rport, JAM1);
193 WORD x = left;
195 Move(rport, x, top + rport->Font->tf_Baseline);
196 Text(rport, ">>", 2);
197 break;
200 case MENUCHECK:
202 if (MENUS_AMIGALOOK)
204 SetAPen(rport, pens[BARBLOCKPEN]);
206 else
208 SetAPen(rport, pens[(msg->mdp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
211 RectFill(rport, left, top, right, bottom);
213 SetAPen(rport, pens[BARDETAILPEN]);
214 menu_draw_thick_line(cl, rport, left + 1, top + height / 3 , left + 1, bottom, 0);
215 menu_draw_thick_line(cl, rport, left + 2, bottom, right - 2, top, 0);
217 break;
220 case AMIGAKEY:
222 struct TextFont *oldfont;
223 UBYTE oldstyle;
225 if (MENUS_AMIGALOOK)
227 SetAPen(rport, pens[BARDETAILPEN]);
229 else
231 SetAPen(rport, pens[SHINEPEN]);
234 RectFill(rport, left, top, right, bottom);
236 if (MENUS_AMIGALOOK)
238 SetAPen(rport, pens[BARBLOCKPEN]);
240 oldfont = rport->Font;
241 oldstyle = rport->AlgoStyle;
243 SetFont(rport, GfxBase->DefaultFont);
244 SetSoftStyle(rport, FSF_ITALIC, AskSoftStyle(rport));
246 Move(rport, left + (width - rport->TxWidth) / 2,
247 top + (height - rport->TxHeight) / 2 + rport->TxBaseline);
248 Text(rport, "A", 1);
250 SetSoftStyle(rport, oldstyle, AskSoftStyle(rport));
251 SetFont(rport, oldfont);
253 SetAPen(rport, pens[BARBLOCKPEN]);
255 else
257 SetAPen(rport, pens[SHADOWPEN]);
259 RectFill(rport, left + 1, top, right - 1, top);
260 RectFill(rport, right, top + 1, right, bottom - 1);
261 RectFill(rport, left + 1, bottom, right - 1, bottom);
262 RectFill(rport, left, top + 1, left, bottom - 1);
264 SetAPen(rport, pens[BACKGROUNDPEN]);
265 RectFill(rport, left + 1, bottom - 1, right - 1, bottom - 1);
266 RectFill(rport, right - 1, top + 1, right - 1, bottom - 2);
268 RectFill(rport, left + 2, top + 2, left + 4, top + 2);
269 RectFill(rport, left + 2, top + 3, left + 2, top + 4);
271 SetAPen(rport, pens[SHADOWPEN]);
272 RectFill(rport, left + 2, bottom - 2, right - 2, bottom - 2);
273 RectFill(rport, right - 2, top + 2, right - 2, bottom - 4);
276 WORD a_size = height - 7;
277 WORD a_left = left + 5;
278 WORD a_top = top + 2;
279 WORD a_right = a_left + a_size;
280 WORD a_bottom = a_top + a_size;
282 Move(rport, a_left, a_bottom);
283 Draw(rport, a_right, a_top);
284 Draw(rport, a_right, a_bottom);
285 Move(rport, a_right - 1, a_top + 1);
286 Draw(rport, a_right - 1, a_bottom);
289 SetAPen(rport, pens[(msg->mdp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
292 WritePixel(rport, left, top);
293 WritePixel(rport, right, top);
294 WritePixel(rport, right, bottom);
295 WritePixel(rport, left, bottom);
298 return TRUE;
301 IPTR MenuDecorClass__MDM_GETMENUSPACES(Class *cl, Object *obj, struct mdpGetMenuSpaces *msg)
303 return FALSE;
306 /**************************************************************************************************/
308 IPTR MenuDecorClass__MDM_DRAWBACKGROUND(Class *cl, Object *obj, struct mdpDrawBackground *msg)
310 return FALSE;
313 IPTR MenuDecorClass__MDM_INITMENU(Class *cl, Object *obj, struct mdpInitMenu *msg)
315 return FALSE;
318 IPTR MenuDecorClass__MDM_EXITMENU(Class *cl, Object *obj, struct mdpExitMenu *msg)
320 return FALSE;
323 /**************************************************************************************************/