Updated Sourceforge username and host.
[tangerine.git] / rom / intuition / menudecorclass.c
blobc0fb2a7e3109d9006ec08367a1169c9bbb885f78
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(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 menuecor_data *data = INST_DATA(cl, obj);
168 struct RastPort *rport = msg->mdp_RPort;
169 UWORD *pens = DRI(msg->mdp_Dri)->dri_Pens;
170 LONG state = msg->mdp_State;
171 LONG left = msg->mdp_X;
172 LONG top = msg->mdp_Y;
173 LONG width = msg->mdp_Width;
174 LONG height = msg->mdp_Height;
175 LONG right = left + width - 1;
176 LONG bottom = top + height - 1;
177 LONG h_spacing, v_spacing;
179 SetDrMd(rport, JAM1);
181 switch(msg->mdp_Which)
183 case SUBMENUIMAGE:
185 if (MENUS_AMIGALOOK)
187 SetAPen(rport, pens[BARBLOCKPEN]);
189 else
191 SetAPen(rport, pens[(msg->mdp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
193 RectFill(rport, left, top, right, bottom);
194 SetAPen(rport, pens[BARDETAILPEN]);
195 SetDrMd(rport, JAM1);
196 WORD x = left;
198 Move(rport, x, top + rport->Font->tf_Baseline);
199 Text(rport, ">>", 2);
200 break;
203 case MENUCHECK:
205 if (MENUS_AMIGALOOK)
207 SetAPen(rport, pens[BARBLOCKPEN]);
209 else
211 SetAPen(rport, pens[(msg->mdp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
214 RectFill(rport, left, top, right, bottom);
216 SetAPen(rport, pens[BARDETAILPEN]);
217 menu_draw_thick_line(rport, left + 1, top + height / 3 , left + 1, bottom, 0);
218 menu_draw_thick_line(rport, left + 2, bottom, right - 2, top, 0);
220 break;
223 case AMIGAKEY:
225 struct TextFont *oldfont;
226 UBYTE oldstyle;
228 if (MENUS_AMIGALOOK)
230 SetAPen(rport, pens[BARDETAILPEN]);
232 else
234 SetAPen(rport, pens[SHINEPEN]);
237 RectFill(rport, left, top, right, bottom);
239 if (MENUS_AMIGALOOK)
241 SetAPen(rport, pens[BARBLOCKPEN]);
243 oldfont = rport->Font;
244 oldstyle = rport->AlgoStyle;
246 SetFont(rport, GfxBase->DefaultFont);
247 SetSoftStyle(rport, FSF_ITALIC, AskSoftStyle(rport));
249 Move(rport, left + (width - rport->TxWidth) / 2,
250 top + (height - rport->TxHeight) / 2 + rport->TxBaseline);
251 Text(rport, "A", 1);
253 SetSoftStyle(rport, oldstyle, AskSoftStyle(rport));
254 SetFont(rport, oldfont);
256 SetAPen(rport, pens[BARBLOCKPEN]);
258 else
260 SetAPen(rport, pens[SHADOWPEN]);
262 RectFill(rport, left + 1, top, right - 1, top);
263 RectFill(rport, right, top + 1, right, bottom - 1);
264 RectFill(rport, left + 1, bottom, right - 1, bottom);
265 RectFill(rport, left, top + 1, left, bottom - 1);
267 SetAPen(rport, pens[BACKGROUNDPEN]);
268 RectFill(rport, left + 1, bottom - 1, right - 1, bottom - 1);
269 RectFill(rport, right - 1, top + 1, right - 1, bottom - 2);
271 RectFill(rport, left + 2, top + 2, left + 4, top + 2);
272 RectFill(rport, left + 2, top + 3, left + 2, top + 4);
274 SetAPen(rport, pens[SHADOWPEN]);
275 RectFill(rport, left + 2, bottom - 2, right - 2, bottom - 2);
276 RectFill(rport, right - 2, top + 2, right - 2, bottom - 4);
279 WORD a_size = height - 7;
280 WORD a_left = left + 5;
281 WORD a_top = top + 2;
282 WORD a_right = a_left + a_size;
283 WORD a_bottom = a_top + a_size;
285 Move(rport, a_left, a_bottom);
286 Draw(rport, a_right, a_top);
287 Draw(rport, a_right, a_bottom);
288 Move(rport, a_right - 1, a_top + 1);
289 Draw(rport, a_right - 1, a_bottom);
292 SetAPen(rport, pens[(msg->mdp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
295 WritePixel(rport, left, top);
296 WritePixel(rport, right, top);
297 WritePixel(rport, right, bottom);
298 WritePixel(rport, left, bottom);
301 return TRUE;
304 IPTR MenuDecorClass__MDM_GETMENUSPACES(Class *cl, Object *obj, struct mdpGetMenuSpaces *msg)
306 return FALSE;
309 /**************************************************************************************************/
311 IPTR MenuDecorClass__MDM_DRAWBACKGROUND(Class *cl, Object *obj, struct mdpDrawBackground *msg)
313 return FALSE;
316 IPTR MenuDecorClass__MDM_INITMENU(Class *cl, Object *obj, struct mdpInitMenu *msg)
318 return FALSE;
321 IPTR MenuDecorClass__MDM_EXITMENU(Class *cl, Object *obj, struct mdpExitMenu *msg)
323 return FALSE;
326 /**************************************************************************************************/