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/scrdecorclass.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"
40 /**************************************************************************************************/
43 #define USE_AROS_DEFSIZE 1
45 #define USE_AROS_DEFSIZE 0
48 #define DEFSIZE_WIDTH 14
49 #define DEFSIZE_HEIGHT 14
54 * heuristics for smaller arrows used in apps
57 #define HSPACING_MIDDLE 2
58 #define VSPACING_MIDDLE 2
59 #define HSPACING_SMALL 1
60 #define VSPACING_SMALL 1
62 #define DRI(dri) ((struct DrawInfo *)(dri))
64 /**************************************************************************************************/
66 static void renderimageframe(struct RastPort
*rp
, ULONG which
, ULONG state
, UWORD
*pens
,
67 WORD left
, WORD top
, WORD width
, WORD height
,
68 struct IntuitionBase
*IntuitionBase
)
70 WORD right
= left
+ width
- 1;
71 WORD bottom
= top
+ height
- 1;
72 BOOL leftedgegodown
= FALSE
;
73 BOOL topedgegoright
= FALSE
;
75 if (left
== 0) leftedgegodown
= TRUE
;
76 if (top
== 0) topedgegoright
= TRUE
;
78 SetAPen(rp
, pens
[((state
== IDS_SELECTED
) || (state
== IDS_INACTIVESELECTED
)) ? SHADOWPEN
: SHINEPEN
]);
84 bottom
- (leftedgegodown
? 0 : 1));
87 RectFill(rp
, left
+ 1,
89 right
- (topedgegoright
? 0 : 1),
92 SetAPen(rp
, pens
[((state
== IDS_SELECTED
) || (state
== IDS_INACTIVESELECTED
)) ? SHINEPEN
: SHADOWPEN
]);
96 top
+ (topedgegoright
? 1 : 0),
101 RectFill(rp
, left
+ (leftedgegodown
? 1 : 0),
107 /**************************************************************************************************/
109 static UWORD
getbgpen(ULONG state
, UWORD
*pens
)
121 bg
= pens
[BACKGROUNDPEN
];
129 /**************************************************************************************************/
132 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
134 /**************************************************************************************************/
136 IPTR
ScrDecorClass__OM_NEW(Class
*cl
, Object
*obj
, struct opSet
*msg
)
138 struct scrdecor_data
*data
;
140 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
143 data
= INST_DATA(cl
, obj
);
145 data
->userbuffersize
= (ULONG
) GetTagData(SDA_UserBuffer
, 0, msg
->ops_AttrList
);
152 /**************************************************************************************************/
154 IPTR
ScrDecorClass__OM_GET(Class
*cl
, Object
*obj
, struct opGet
*msg
)
156 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
158 switch(msg
->opg_AttrID
)
161 *msg
->opg_Storage
= (IPTR
) data
->userbuffersize
;
164 case SDA_TrueColorOnly
:
165 *msg
->opg_Storage
= FALSE
;
169 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
176 /**************************************************************************************************/
178 IPTR
ScrDecorClass__SDM_GETDEFSIZE_SYSIMAGE(Class
*cl
, Object
*obj
, struct sdpGetDefSizeSysImage
*msg
)
180 ULONG def_low_width
= DEFSIZE_WIDTH
, def_low_height
= DEFSIZE_HEIGHT
;
181 ULONG def_med_width
= DEFSIZE_WIDTH
, def_med_height
= DEFSIZE_HEIGHT
;
182 ULONG def_high_width
= DEFSIZE_WIDTH
, def_high_height
= DEFSIZE_HEIGHT
;
184 switch(msg
->sdp_Which
)
188 def_low_width
= def_med_width
= def_high_width
= DEFSIZE_WIDTH
;
189 def_low_height
= def_med_height
= def_high_height
= DEFSIZE_HEIGHT
;
201 switch(msg
->sdp_SysiSize
)
203 case SYSISIZE_LOWRES
:
204 *msg
->sdp_Width
= def_low_width
;
205 *msg
->sdp_Height
= def_low_height
;
208 case SYSISIZE_MEDRES
:
209 *msg
->sdp_Width
= def_med_width
;
210 *msg
->sdp_Height
= def_med_height
;
215 *msg
->sdp_Width
= def_high_width
;
216 *msg
->sdp_Height
= def_high_height
;
223 /**************************************************************************************************/
225 IPTR
ScrDecorClass__SDM_DRAW_SYSIMAGE(Class
*cl
, Object
*obj
, struct sdpDrawSysImage
*msg
)
227 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
228 struct RastPort
*rp
= msg
->sdp_RPort
;
229 UWORD
*pens
= DRI(msg
->sdp_Dri
)->dri_Pens
;
230 LONG state
= msg
->sdp_State
;
231 LONG left
= msg
->sdp_X
;
232 LONG top
= msg
->sdp_Y
;
233 LONG width
= msg
->sdp_Width
;
234 LONG height
= msg
->sdp_Height
;
235 LONG right
= left
+ width
- 1;
236 LONG bottom
= top
+ height
- 1;
240 switch(msg
->sdp_Which
)
248 renderimageframe(rp
, DEPTHIMAGE
, state
, pens
,
249 left
, top
, width
, height
, IntuitionBase
);
257 h_spacing
= width
/ 6;
258 v_spacing
= height
/ 6;
260 bg
= pens
[BACKGROUNDPEN
];
262 /* Clear background into correct color */
264 RectFill(rp
, left
, top
, right
, bottom
);
266 /* Draw a image of two partly overlapped tiny windows,
272 width
-= h_spacing
* 2;
273 height
-= v_spacing
* 2;
275 right
= left
+ width
- 1;
276 bottom
= top
+ height
- 1;
278 /* Render top left window */
280 SetAPen(rp
, pens
[SHADOWPEN
]);
281 drawrect(rp
, left
, top
, right
- (width
/ 3 ), bottom
- (height
/ 3), IntuitionBase
);
283 /* Render bottom right window */
284 SetAPen(rp
, pens
[SHADOWPEN
]);
285 drawrect(rp
, left
+ (width
/ 3), top
+ (height
/ 3), right
, bottom
, IntuitionBase
);
287 /* Fill bottom right window (inside of the frame above) */
288 SetAPen(rp
, pens
[SHINEPEN
]);
289 RectFill(rp
, left
+ (width
/ 3) + 1, top
+ (height
/ 3) + 1,
290 right
- 1, bottom
- 1);
293 if (state
== IDS_SELECTED
)
295 /* Re-Render top left window */
297 SetAPen(rp
, pens
[SHADOWPEN
]);
298 drawrect(rp
, left
, top
, right
- (width
/ 3 ), bottom
- (height
/ 3), IntuitionBase
);
310 /**************************************************************************************************/
312 static void findtitlearea(struct Screen
*scr
, LONG
*left
, LONG
*right
)
317 *right
= scr
->Width
- 1;
319 for (g
= scr
->FirstGadget
; g
; g
= g
->NextGadget
)
321 if (!(g
->Flags
& GFLG_RELRIGHT
))
323 if (g
->LeftEdge
+ g
->Width
> *left
)
324 *left
= g
->LeftEdge
+ g
->Width
;
328 if (g
->LeftEdge
+ scr
->Width
- 1 - 1 < *right
)
329 *right
= g
->LeftEdge
+ scr
->Width
- 1 - 1;
335 /**************************************************************************************************/
337 IPTR ScrDecorClass__SDM_DRAW_SCREENBAR(Class *cl, Object *obj, struct sdpDrawScreenBar *msg)
339 struct scrdecor_data *data = INST_DATA(cl, obj);
340 struct RastPort *rp = msg->sdp_RPort;
341 UWORD *pens = DRI(msg->sdp_Dri)->dri_Pens;
343 BOOL beeping = FALSE;
346 #if USE_NEWDISPLAYBEEP
347 beeping = (msg->sdp_Screen->Flags & BEEPING) && GetBitMapAttr(rp->BitMap, BMA_DEPTH) > 8;
353 SetAPen(rp, pens[beeping ? BARDETAILPEN : BARBLOCKPEN]);
354 RectFill(rp, 0, 0, msg->sdp_Screen->Width - 1, msg->sdp_Screen->BarHeight - 1);
356 SetAPen(rp, pens[beeping ? BARDETAILPEN : BARTRIMPEN]);
357 RectFill(rp, 0, msg->sdp_Screen->BarHeight, msg->sdp_Screen->Width - 1, msg->sdp_Screen->BarHeight);
359 findtitlearea(msg->sdp_Screen, &left, &right);
361 SetAPen(rp, pens[SHADOWPEN]);
362 RectFill(rp, right, 1, right, msg->sdp_Screen->BarHeight - 1);
368 /**************************************************************************************************/
370 IPTR
ScrDecorClass__SDM_DRAW_SCREENBAR(Class
*cl
, Object
*obj
, struct sdpDrawScreenBar
*msg
)
372 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
373 struct RastPort
*rp
= msg
->sdp_RPort
;
374 UWORD
*pens
= DRI(msg
->sdp_Dri
)->dri_Pens
;
376 BOOL beeping
= FALSE
;
379 #if USE_NEWDISPLAYBEEP
380 beeping
= (msg
->sdp_Screen
->Flags
& BEEPING
) && GetBitMapAttr(rp
->BitMap
, BMA_DEPTH
) > 8;
384 findtitlearea(msg
->sdp_Screen
, &left
, &right
);
388 SetAPen(rp
, pens
[beeping
? BARDETAILPEN
: BARBLOCKPEN
]);
389 RectFill(rp
, left
+ 1, 0, right
- 1, msg
->sdp_Screen
->BarHeight
- 1);
391 SetAPen(rp
, pens
[beeping
? BARDETAILPEN
: BARTRIMPEN
]);
392 RectFill(rp
, 0, msg
->sdp_Screen
->BarHeight
, msg
->sdp_Screen
->Width
- 1, msg
->sdp_Screen
->BarHeight
);
394 SetAPen(rp
, pens
[beeping
? BARBLOCKPEN
: BARDETAILPEN
]);
395 SetBPen(rp
, pens
[beeping
? BARDETAILPEN
: BARBLOCKPEN
]);
397 Move(rp
, msg
->sdp_Screen
->BarHBorder
, msg
->sdp_Screen
->BarVBorder
+ rp
->TxBaseline
);
399 Text(rp
, msg
->sdp_Screen
->Title
, strlen(msg
->sdp_Screen
->Title
));
404 /**************************************************************************************************/
406 IPTR
ScrDecorClass__SDM_LAYOUT_SCREENGADGETS(Class
*cl
, Object
*obj
, struct sdpLayoutScreenGadgets
*msg
)
408 struct Gadget
*gadget
= msg
->sdp_Gadgets
;
412 switch(gadget
->GadgetType
& GTYP_SYSTYPEMASK
)
415 gadget
->LeftEdge
= -gadget
->Height
+ 1;
416 gadget
->Width
= gadget
->Height
;
417 gadget
->Flags
&= ~GFLG_RELWIDTH
;
418 gadget
->Flags
|= GFLG_RELRIGHT
;
423 if (msg
->sdp_Flags
& SDF_LSG_MULTIPLE
)
425 gadget
= gadget
->NextGadget
;
436 IPTR
ScrDecorClass__SDM_INITSCREEN(Class
*cl
, Object
*obj
, struct sdpInitScreen
*msg
)
441 IPTR
ScrDecorClass__SDM_EXITSCREEN(Class
*cl
, Object
*obj
, struct sdpExitScreen
*msg
)
446 /**************************************************************************************************/