2 Copyright 1995-2005, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
8 #include <aros/debug.h>
11 #include <dos/dosextens.h>
13 #include <intuition/intuition.h>
14 #include <intuition/intuitionbase.h>
15 #include <intuition/classes.h>
16 #include <intuition/classusr.h>
17 #include <intuition/scrdecorclass.h>
18 #include <intuition/cghooks.h>
19 #include <intuition/icclass.h>
20 #include <intuition/extensions.h>
22 #include <graphics/gfxbase.h>
23 #include <graphics/gfxmacros.h>
25 #include <utility/tagitem.h>
26 #include <utility/hooks.h>
28 #include <clib/macros.h>
32 #include <proto/exec.h>
33 #include <proto/intuition.h>
34 #include <proto/graphics.h>
35 #include <proto/utility.h>
37 #include <proto/alib.h>
39 #include "intuition_intern.h"
42 /**************************************************************************************************/
45 #define USE_AROS_DEFSIZE 1
47 #define USE_AROS_DEFSIZE 0
50 #define DEFSIZE_WIDTH 14
51 #define DEFSIZE_HEIGHT 14
56 * heuristics for smaller arrows used in apps
59 #define HSPACING_MIDDLE 2
60 #define VSPACING_MIDDLE 2
61 #define HSPACING_SMALL 1
62 #define VSPACING_SMALL 1
64 #define DRI(dri) ((struct DrawInfo *)(dri))
66 /**************************************************************************************************/
68 static void renderimageframe(struct RastPort
*rp
, ULONG which
, ULONG state
, UWORD
*pens
,
69 WORD left
, WORD top
, WORD width
, WORD height
,
70 struct IntuitionBase
*IntuitionBase
)
72 WORD right
= left
+ width
- 1;
73 WORD bottom
= top
+ height
- 1;
74 BOOL leftedgegodown
= FALSE
;
75 BOOL topedgegoright
= FALSE
;
77 if (left
== 0) leftedgegodown
= TRUE
;
78 if (top
== 0) topedgegoright
= TRUE
;
80 SetAPen(rp
, pens
[((state
== IDS_SELECTED
) || (state
== IDS_INACTIVESELECTED
)) ? SHADOWPEN
: SHINEPEN
]);
86 bottom
- (leftedgegodown
? 0 : 1));
89 RectFill(rp
, left
+ 1,
91 right
- (topedgegoright
? 0 : 1),
94 SetAPen(rp
, pens
[((state
== IDS_SELECTED
) || (state
== IDS_INACTIVESELECTED
)) ? SHINEPEN
: SHADOWPEN
]);
98 top
+ (topedgegoright
? 1 : 0),
103 RectFill(rp
, left
+ (leftedgegodown
? 1 : 0),
109 /**************************************************************************************************/
112 static UWORD
getbgpen(ULONG state
, UWORD
*pens
)
124 bg
= pens
[BACKGROUNDPEN
];
132 /**************************************************************************************************/
135 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
137 /**************************************************************************************************/
139 IPTR
ScrDecorClass__OM_NEW(Class
*cl
, Object
*obj
, struct opSet
*msg
)
141 struct scrdecor_data
*data
;
143 D(bug("[SCRDECOR] ScrDecorClass__OM_NEW()\n"));
145 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
148 data
= INST_DATA(cl
, obj
);
150 data
->userbuffersize
= (ULONG
) GetTagData(SDA_UserBuffer
, 0, msg
->ops_AttrList
);
157 /**************************************************************************************************/
159 IPTR
ScrDecorClass__OM_GET(Class
*cl
, Object
*obj
, struct opGet
*msg
)
161 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
163 D(bug("[SCRDECOR] ScrDecorClass__OM_GET()\n"));
165 switch(msg
->opg_AttrID
)
168 *msg
->opg_Storage
= (IPTR
) data
->userbuffersize
;
171 case SDA_TrueColorOnly
:
172 *msg
->opg_Storage
= FALSE
;
176 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
183 /**************************************************************************************************/
185 IPTR
ScrDecorClass__SDM_GETDEFSIZE_SYSIMAGE(Class
*cl
, Object
*obj
, struct sdpGetDefSizeSysImage
*msg
)
187 ULONG def_low_width
= DEFSIZE_WIDTH
, def_low_height
= DEFSIZE_HEIGHT
;
188 ULONG def_med_width
= DEFSIZE_WIDTH
, def_med_height
= DEFSIZE_HEIGHT
;
189 ULONG def_high_width
= DEFSIZE_WIDTH
, def_high_height
= DEFSIZE_HEIGHT
;
191 D(bug("[SCRDECOR] ScrDecorClass__SDM_GETDEFSIZE_SYSIMAGE()\n"));
193 switch(msg
->sdp_Which
)
197 def_low_width
= def_med_width
= def_high_width
= DEFSIZE_WIDTH
;
198 def_low_height
= def_med_height
= def_high_height
= DEFSIZE_HEIGHT
;
210 switch(msg
->sdp_SysiSize
)
212 case SYSISIZE_LOWRES
:
213 *msg
->sdp_Width
= def_low_width
;
214 *msg
->sdp_Height
= def_low_height
;
217 case SYSISIZE_MEDRES
:
218 *msg
->sdp_Width
= def_med_width
;
219 *msg
->sdp_Height
= def_med_height
;
224 *msg
->sdp_Width
= def_high_width
;
225 *msg
->sdp_Height
= def_high_height
;
232 /**************************************************************************************************/
234 IPTR
ScrDecorClass__SDM_DRAW_SYSIMAGE(Class
*cl
, Object
*obj
, struct sdpDrawSysImage
*msg
)
236 struct RastPort
*rp
= msg
->sdp_RPort
;
237 UWORD
*pens
= DRI(msg
->sdp_Dri
)->dri_Pens
;
238 LONG state
= msg
->sdp_State
;
239 LONG left
= msg
->sdp_X
;
240 LONG top
= msg
->sdp_Y
;
241 LONG width
= msg
->sdp_Width
;
242 LONG height
= msg
->sdp_Height
;
243 LONG right
= left
+ width
- 1;
244 LONG bottom
= top
+ height
- 1;
246 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SYSIMAGE()\n"));
250 switch(msg
->sdp_Which
)
258 renderimageframe(rp
, DEPTHIMAGE
, state
, pens
,
259 left
, top
, width
, height
, IntuitionBase
);
267 h_spacing
= width
/ 6;
268 v_spacing
= height
/ 6;
270 bg
= pens
[BACKGROUNDPEN
];
272 /* Clear background into correct color */
274 RectFill(rp
, left
, top
, right
, bottom
);
276 /* Draw a image of two partly overlapped tiny windows,
282 width
-= h_spacing
* 2;
283 height
-= v_spacing
* 2;
285 right
= left
+ width
- 1;
286 bottom
= top
+ height
- 1;
288 /* Render top left window */
290 SetAPen(rp
, pens
[SHADOWPEN
]);
291 drawrect(rp
, left
, top
, right
- (width
/ 3 ), bottom
- (height
/ 3), IntuitionBase
);
293 /* Render bottom right window */
294 SetAPen(rp
, pens
[SHADOWPEN
]);
295 drawrect(rp
, left
+ (width
/ 3), top
+ (height
/ 3), right
, bottom
, IntuitionBase
);
297 /* Fill bottom right window (inside of the frame above) */
298 SetAPen(rp
, pens
[SHINEPEN
]);
299 RectFill(rp
, left
+ (width
/ 3) + 1, top
+ (height
/ 3) + 1,
300 right
- 1, bottom
- 1);
303 if (state
== IDS_SELECTED
)
305 /* Re-Render top left window */
307 SetAPen(rp
, pens
[SHADOWPEN
]);
308 drawrect(rp
, left
, top
, right
- (width
/ 3 ), bottom
- (height
/ 3), IntuitionBase
);
320 /**************************************************************************************************/
322 static void findtitlearea(struct Screen
*scr
, LONG
*left
, LONG
*right
)
327 *right
= scr
->Width
- 1;
329 for (g
= scr
->FirstGadget
; g
; g
= g
->NextGadget
)
331 if (!(g
->Flags
& GFLG_RELRIGHT
))
333 if (g
->LeftEdge
+ g
->Width
> *left
)
334 *left
= g
->LeftEdge
+ g
->Width
;
338 if (g
->LeftEdge
+ scr
->Width
- 1 - 1 < *right
)
339 *right
= g
->LeftEdge
+ scr
->Width
- 1 - 1;
345 /**************************************************************************************************/
347 IPTR ScrDecorClass__SDM_DRAW_SCREENBAR(Class *cl, Object *obj, struct sdpDrawScreenBar *msg)
349 struct scrdecor_data *data = INST_DATA(cl, obj);
350 struct RastPort *rp = msg->sdp_RPort;
351 UWORD *pens = DRI(msg->sdp_Dri)->dri_Pens;
353 BOOL beeping = FALSE;
356 #if USE_NEWDISPLAYBEEP
357 beeping = (msg->sdp_Screen->Flags & BEEPING) && GetBitMapAttr(rp->BitMap, BMA_DEPTH) > 8;
363 SetAPen(rp, pens[beeping ? BARDETAILPEN : BARBLOCKPEN]);
364 RectFill(rp, 0, 0, msg->sdp_Screen->Width - 1, msg->sdp_Screen->BarHeight - 1);
366 SetAPen(rp, pens[beeping ? BARDETAILPEN : BARTRIMPEN]);
367 RectFill(rp, 0, msg->sdp_Screen->BarHeight, msg->sdp_Screen->Width - 1, msg->sdp_Screen->BarHeight);
369 findtitlearea(msg->sdp_Screen, &left, &right);
371 SetAPen(rp, pens[SHADOWPEN]);
372 RectFill(rp, right, 1, right, msg->sdp_Screen->BarHeight - 1);
378 /**************************************************************************************************/
380 IPTR
ScrDecorClass__SDM_DRAW_SCREENBAR(Class
*cl
, Object
*obj
, struct sdpDrawScreenBar
*msg
)
382 struct RastPort
*rp
= msg
->sdp_RPort
;
383 UWORD
*pens
= DRI(msg
->sdp_Dri
)->dri_Pens
;
385 BOOL beeping
= FALSE
;
387 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR()\n"));
389 #if USE_NEWDISPLAYBEEP
390 beeping
= msg
->sdp_Screen
->Flags
& BEEPING
;
393 findtitlearea(msg
->sdp_Screen
, &left
, &right
);
395 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Title_Left = %d, Title_Right = %d\n", left
, right
));
397 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: RastPort @ %p, Screen @ %p\n", rp
, msg
->sdp_Screen
));
398 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Screen Dimensions %dx%d\n", msg
->sdp_Screen
->Width
, msg
->sdp_Screen
->Height
));
399 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Bar Height %d\n", msg
->sdp_Screen
->BarHeight
));
403 SetAPen(rp
, pens
[beeping
? BARDETAILPEN
: BARBLOCKPEN
]);
404 RectFill(rp
, left
+ 1, 0, right
- 1, msg
->sdp_Screen
->BarHeight
- 1);
406 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Filled Bar Area\n"));
408 SetAPen(rp
, pens
[beeping
? BARDETAILPEN
: BARTRIMPEN
]);
409 RectFill(rp
, 0, msg
->sdp_Screen
->BarHeight
, msg
->sdp_Screen
->Width
- 1, msg
->sdp_Screen
->BarHeight
);
411 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Filled Bar Area\n"));
413 if (msg
->sdp_Screen
->Title
)
415 SetAPen(rp
, pens
[beeping
? BARBLOCKPEN
: BARDETAILPEN
]);
416 SetBPen(rp
, pens
[beeping
? BARDETAILPEN
: BARBLOCKPEN
]);
418 Move(rp
, msg
->sdp_Screen
->BarHBorder
, msg
->sdp_Screen
->BarVBorder
+ rp
->TxBaseline
);
420 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Title Text @ %p\n", msg
->sdp_Screen
->Title
));
421 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Title '%s'\n", msg
->sdp_Screen
->Title
));
422 Text(rp
, msg
->sdp_Screen
->Title
, strlen(msg
->sdp_Screen
->Title
));
424 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Text Rendered\n"));
429 /**************************************************************************************************/
431 IPTR
ScrDecorClass__SDM_LAYOUT_SCREENGADGETS(Class
*cl
, Object
*obj
, struct sdpLayoutScreenGadgets
*msg
)
433 struct Gadget
*gadget
= msg
->sdp_Gadgets
;
435 D(bug("[SCRDECOR] ScrDecorClass__SDM_LAYOUT_SCREENGADGETS()\n"));
439 switch(gadget
->GadgetType
& GTYP_SYSTYPEMASK
)
442 gadget
->LeftEdge
= -gadget
->Height
+ 1;
443 gadget
->Width
= gadget
->Height
;
444 gadget
->Flags
&= ~GFLG_RELWIDTH
;
445 gadget
->Flags
|= GFLG_RELRIGHT
;
450 if (msg
->sdp_Flags
& SDF_LSG_MULTIPLE
)
452 gadget
= gadget
->NextGadget
;
463 IPTR
ScrDecorClass__SDM_INITSCREEN(Class
*cl
, Object
*obj
, struct sdpInitScreen
*msg
)
465 D(bug("[SCRDECOR] ScrDecorClass__SDM_INITSCREEN()\n"));
470 IPTR
ScrDecorClass__SDM_EXITSCREEN(Class
*cl
, Object
*obj
, struct sdpExitScreen
*msg
)
472 D(bug("[SCRDECOR] ScrDecorClass__SDM_EXITSCREEN()\n"));
477 /**************************************************************************************************/