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 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
)
187 SetAPen(rport
, pens
[BARBLOCKPEN
]);
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
);
198 Move(rport
, x
, top
+ rport
->Font
->tf_Baseline
);
199 Text(rport
, ">>", 2);
207 SetAPen(rport
, pens
[BARBLOCKPEN
]);
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);
225 struct TextFont
*oldfont
;
230 SetAPen(rport
, pens
[BARDETAILPEN
]);
234 SetAPen(rport
, pens
[SHINEPEN
]);
237 RectFill(rport
, left
, top
, right
, bottom
);
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
);
253 SetSoftStyle(rport
, oldstyle
, AskSoftStyle(rport
));
254 SetFont(rport
, oldfont
);
256 SetAPen(rport
, pens
[BARBLOCKPEN
]);
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
);
304 IPTR
MenuDecorClass__MDM_GETMENUSPACES(Class
*cl
, Object
*obj
, struct mdpGetMenuSpaces
*msg
)
309 /**************************************************************************************************/
311 IPTR
MenuDecorClass__MDM_DRAWBACKGROUND(Class
*cl
, Object
*obj
, struct mdpDrawBackground
*msg
)
316 IPTR
MenuDecorClass__MDM_INITMENU(Class
*cl
, Object
*obj
, struct mdpInitMenu
*msg
)
321 IPTR
MenuDecorClass__MDM_EXITMENU(Class
*cl
, Object
*obj
, struct mdpExitMenu
*msg
)
326 /**************************************************************************************************/