2 Copyright 1995-2005, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
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>
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"
41 /**************************************************************************************************/
44 #define USE_AROS_DEFSIZE 1
46 #define USE_AROS_DEFSIZE 0
49 #define DEFSIZE_WIDTH 14
50 #define DEFSIZE_HEIGHT 14
54 #define REFHEIGHT (msg->mdp_ReferenceFont->tf_YSize)
55 #define REFWIDTH REFHEIGHT
58 * heuristics for smaller arrows used in apps
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 /**************************************************************************************************/
71 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
75 #include <aros/debug.h>
76 /**************************************************************************************************/
78 void menu_draw_thick_line(struct RastPort
*rport
,
79 LONG x1
, LONG y1
, LONG x2
, LONG y2
,
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
);
96 data
= INST_DATA(cl
, obj
);
98 data
->userbuffersize
= (ULONG
) GetTagData(MDA_UserBuffer
, 0, msg
->ops_AttrList
);
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
)
114 *msg
->opg_Storage
= (IPTR
) data
->userbuffersize
;
117 case MDA_TrueColorOnly
:
118 *msg
->opg_Storage
= FALSE
;
122 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
129 /**************************************************************************************************/
131 IPTR
MenuDecorClass__MDM_GETDEFSIZE_SYSIMAGE(Class
*cl
, Object
*obj
, struct mdpGetDefSizeSysImage
*msg
)
134 switch(msg
->mdp_Which
)
138 *msg
->mdp_Height
= 0;
139 struct RastPort
*rp
= CreateRastPort();
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
;
152 *msg
->mdp_Width
= REFWIDTH
/ 2 + 4; // reffont->tf_XSize * 3 / 2;
153 *msg
->mdp_Height
= REFHEIGHT
;
157 *msg
->mdp_Width
= DEFSIZE_WIDTH
;
158 *msg
->mdp_Height
= DEFSIZE_HEIGHT
;
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
)
184 SetAPen(rport
, pens
[BARBLOCKPEN
]);
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
);
195 Move(rport
, x
, top
+ rport
->Font
->tf_Baseline
);
196 Text(rport
, ">>", 2);
204 SetAPen(rport
, pens
[BARBLOCKPEN
]);
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(rport
, left
+ 1, top
+ height
/ 3 , left
+ 1, bottom
, 0);
215 menu_draw_thick_line(rport
, left
+ 2, bottom
, right
- 2, top
, 0);
222 struct TextFont
*oldfont
;
227 SetAPen(rport
, pens
[BARDETAILPEN
]);
231 SetAPen(rport
, pens
[SHINEPEN
]);
234 RectFill(rport
, left
, top
, right
, bottom
);
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
);
250 SetSoftStyle(rport
, oldstyle
, AskSoftStyle(rport
));
251 SetFont(rport
, oldfont
);
253 SetAPen(rport
, pens
[BARBLOCKPEN
]);
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
);
301 IPTR
MenuDecorClass__MDM_GETMENUSPACES(Class
*cl
, Object
*obj
, struct mdpGetMenuSpaces
*msg
)
306 /**************************************************************************************************/
308 IPTR
MenuDecorClass__MDM_DRAWBACKGROUND(Class
*cl
, Object
*obj
, struct mdpDrawBackground
*msg
)
313 IPTR
MenuDecorClass__MDM_INITMENU(Class
*cl
, Object
*obj
, struct mdpInitMenu
*msg
)
318 IPTR
MenuDecorClass__MDM_EXITMENU(Class
*cl
, Object
*obj
, struct mdpExitMenu
*msg
)
323 /**************************************************************************************************/