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 /**************************************************************************************************/
111 static UWORD
getbgpen(ULONG state
, UWORD
*pens
)
123 bg
= pens
[BACKGROUNDPEN
];
131 /**************************************************************************************************/
134 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
136 /**************************************************************************************************/
138 IPTR
ScrDecorClass__OM_NEW(Class
*cl
, Object
*obj
, struct opSet
*msg
)
140 struct scrdecor_data
*data
;
142 D(bug("[SCRDECOR] ScrDecorClass__OM_NEW()\n"));
144 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
147 data
= INST_DATA(cl
, obj
);
149 data
->userbuffersize
= (ULONG
) GetTagData(SDA_UserBuffer
, 0, msg
->ops_AttrList
);
156 /**************************************************************************************************/
158 IPTR
ScrDecorClass__OM_GET(Class
*cl
, Object
*obj
, struct opGet
*msg
)
160 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
162 D(bug("[SCRDECOR] ScrDecorClass__OM_GET()\n"));
164 switch(msg
->opg_AttrID
)
167 *msg
->opg_Storage
= (IPTR
) data
->userbuffersize
;
170 case SDA_TrueColorOnly
:
171 *msg
->opg_Storage
= FALSE
;
175 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
182 /**************************************************************************************************/
184 IPTR
ScrDecorClass__SDM_GETDEFSIZE_SYSIMAGE(Class
*cl
, Object
*obj
, struct sdpGetDefSizeSysImage
*msg
)
186 ULONG def_low_width
= DEFSIZE_WIDTH
, def_low_height
= DEFSIZE_HEIGHT
;
187 ULONG def_med_width
= DEFSIZE_WIDTH
, def_med_height
= DEFSIZE_HEIGHT
;
188 ULONG def_high_width
= DEFSIZE_WIDTH
, def_high_height
= DEFSIZE_HEIGHT
;
190 D(bug("[SCRDECOR] ScrDecorClass__SDM_GETDEFSIZE_SYSIMAGE()\n"));
192 switch(msg
->sdp_Which
)
196 def_low_width
= def_med_width
= def_high_width
= DEFSIZE_WIDTH
;
197 def_low_height
= def_med_height
= def_high_height
= DEFSIZE_HEIGHT
;
209 switch(msg
->sdp_SysiSize
)
211 case SYSISIZE_LOWRES
:
212 *msg
->sdp_Width
= def_low_width
;
213 *msg
->sdp_Height
= def_low_height
;
216 case SYSISIZE_MEDRES
:
217 *msg
->sdp_Width
= def_med_width
;
218 *msg
->sdp_Height
= def_med_height
;
223 *msg
->sdp_Width
= def_high_width
;
224 *msg
->sdp_Height
= def_high_height
;
231 /**************************************************************************************************/
233 IPTR
ScrDecorClass__SDM_DRAW_SYSIMAGE(Class
*cl
, Object
*obj
, struct sdpDrawSysImage
*msg
)
235 struct RastPort
*rp
= msg
->sdp_RPort
;
236 UWORD
*pens
= DRI(msg
->sdp_Dri
)->dri_Pens
;
237 LONG state
= msg
->sdp_State
;
238 LONG left
= msg
->sdp_X
;
239 LONG top
= msg
->sdp_Y
;
240 LONG width
= msg
->sdp_Width
;
241 LONG height
= msg
->sdp_Height
;
242 LONG right
= left
+ width
- 1;
243 LONG bottom
= top
+ height
- 1;
245 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SYSIMAGE()\n"));
249 switch(msg
->sdp_Which
)
257 renderimageframe(rp
, DEPTHIMAGE
, state
, pens
,
258 left
, top
, width
, height
, IntuitionBase
);
266 h_spacing
= width
/ 6;
267 v_spacing
= height
/ 6;
269 bg
= pens
[BACKGROUNDPEN
];
271 /* Clear background into correct color */
273 RectFill(rp
, left
, top
, right
, bottom
);
275 /* Draw a image of two partly overlapped tiny windows,
281 width
-= h_spacing
* 2;
282 height
-= v_spacing
* 2;
284 right
= left
+ width
- 1;
285 bottom
= top
+ height
- 1;
287 /* Render top left window */
289 SetAPen(rp
, pens
[SHADOWPEN
]);
290 drawrect(rp
, left
, top
, right
- (width
/ 3 ), bottom
- (height
/ 3), IntuitionBase
);
292 /* Render bottom right window */
293 SetAPen(rp
, pens
[SHADOWPEN
]);
294 drawrect(rp
, left
+ (width
/ 3), top
+ (height
/ 3), right
, bottom
, IntuitionBase
);
296 /* Fill bottom right window (inside of the frame above) */
297 SetAPen(rp
, pens
[SHINEPEN
]);
298 RectFill(rp
, left
+ (width
/ 3) + 1, top
+ (height
/ 3) + 1,
299 right
- 1, bottom
- 1);
302 if (state
== IDS_SELECTED
)
304 /* Re-Render top left window */
306 SetAPen(rp
, pens
[SHADOWPEN
]);
307 drawrect(rp
, left
, top
, right
- (width
/ 3 ), bottom
- (height
/ 3), IntuitionBase
);
319 /**************************************************************************************************/
321 static void findtitlearea(struct Screen
*scr
, LONG
*left
, LONG
*right
)
326 *right
= scr
->Width
- 1;
328 for (g
= scr
->FirstGadget
; g
; g
= g
->NextGadget
)
330 if (!(g
->Flags
& GFLG_RELRIGHT
))
332 if (g
->LeftEdge
+ g
->Width
> *left
)
333 *left
= g
->LeftEdge
+ g
->Width
;
337 if (g
->LeftEdge
+ scr
->Width
- 1 - 1 < *right
)
338 *right
= g
->LeftEdge
+ scr
->Width
- 1 - 1;
344 /**************************************************************************************************/
346 IPTR ScrDecorClass__SDM_DRAW_SCREENBAR(Class *cl, Object *obj, struct sdpDrawScreenBar *msg)
348 struct scrdecor_data *data = INST_DATA(cl, obj);
349 struct RastPort *rp = msg->sdp_RPort;
350 UWORD *pens = DRI(msg->sdp_Dri)->dri_Pens;
352 BOOL beeping = FALSE;
355 #if USE_NEWDISPLAYBEEP
356 beeping = (msg->sdp_Screen->Flags & BEEPING) && GetBitMapAttr(rp->BitMap, BMA_DEPTH) > 8;
362 SetAPen(rp, pens[beeping ? BARDETAILPEN : BARBLOCKPEN]);
363 RectFill(rp, 0, 0, msg->sdp_Screen->Width - 1, msg->sdp_Screen->BarHeight - 1);
365 SetAPen(rp, pens[beeping ? BARDETAILPEN : BARTRIMPEN]);
366 RectFill(rp, 0, msg->sdp_Screen->BarHeight, msg->sdp_Screen->Width - 1, msg->sdp_Screen->BarHeight);
368 findtitlearea(msg->sdp_Screen, &left, &right);
370 SetAPen(rp, pens[SHADOWPEN]);
371 RectFill(rp, right, 1, right, msg->sdp_Screen->BarHeight - 1);
377 /**************************************************************************************************/
379 IPTR
ScrDecorClass__SDM_DRAW_SCREENBAR(Class
*cl
, Object
*obj
, struct sdpDrawScreenBar
*msg
)
381 struct RastPort
*rp
= msg
->sdp_RPort
;
382 UWORD
*pens
= DRI(msg
->sdp_Dri
)->dri_Pens
;
384 BOOL beeping
= FALSE
;
386 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR()\n"));
389 #if USE_NEWDISPLAYBEEP
390 beeping
= (BOOL
)((msg
->sdp_Screen
->Flags
& BEEPING
) && (GetBitMapAttr(rp
->BitMap
, BMA_DEPTH
) > 8));
394 findtitlearea(msg
->sdp_Screen
, &left
, &right
);
396 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Title_Left = %d, Title_Right = %d\n", left
, right
));
398 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: RastPort @ %p, Screen @ %p\n", rp
, msg
->sdp_Screen
));
399 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Screen Dimensions %dx%d\n", msg
->sdp_Screen
->Width
, msg
->sdp_Screen
->Height
));
400 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Bar Height %d\n", msg
->sdp_Screen
->BarHeight
));
404 SetAPen(rp
, pens
[beeping
? BARDETAILPEN
: BARBLOCKPEN
]);
405 RectFill(rp
, left
+ 1, 0, right
- 1, msg
->sdp_Screen
->BarHeight
- 1);
407 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Filled Bar Area\n"));
409 SetAPen(rp
, pens
[beeping
? BARDETAILPEN
: BARTRIMPEN
]);
410 RectFill(rp
, 0, msg
->sdp_Screen
->BarHeight
, msg
->sdp_Screen
->Width
- 1, msg
->sdp_Screen
->BarHeight
);
412 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Filled Bar Area\n"));
414 if (msg
->sdp_Screen
->Title
)
416 SetAPen(rp
, pens
[beeping
? BARBLOCKPEN
: BARDETAILPEN
]);
417 SetBPen(rp
, pens
[beeping
? BARDETAILPEN
: BARBLOCKPEN
]);
419 Move(rp
, msg
->sdp_Screen
->BarHBorder
, msg
->sdp_Screen
->BarVBorder
+ rp
->TxBaseline
);
421 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Title Text @ %p\n", msg
->sdp_Screen
->Title
));
422 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Title '%s'\n", msg
->sdp_Screen
->Title
));
423 Text(rp
, msg
->sdp_Screen
->Title
, strlen(msg
->sdp_Screen
->Title
));
425 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Text Rendered\n"));
430 /**************************************************************************************************/
432 IPTR
ScrDecorClass__SDM_LAYOUT_SCREENGADGETS(Class
*cl
, Object
*obj
, struct sdpLayoutScreenGadgets
*msg
)
434 struct Gadget
*gadget
= msg
->sdp_Gadgets
;
436 D(bug("[SCRDECOR] ScrDecorClass__SDM_LAYOUT_SCREENGADGETS()\n"));
440 switch(gadget
->GadgetType
& GTYP_SYSTYPEMASK
)
443 gadget
->LeftEdge
= -gadget
->Height
+ 1;
444 gadget
->Width
= gadget
->Height
;
445 gadget
->Flags
&= ~GFLG_RELWIDTH
;
446 gadget
->Flags
|= GFLG_RELRIGHT
;
451 if (msg
->sdp_Flags
& SDF_LSG_MULTIPLE
)
453 gadget
= gadget
->NextGadget
;
464 IPTR
ScrDecorClass__SDM_INITSCREEN(Class
*cl
, Object
*obj
, struct sdpInitScreen
*msg
)
466 D(bug("[SCRDECOR] ScrDecorClass__SDM_INITSCREEN()\n"));
471 IPTR
ScrDecorClass__SDM_EXITSCREEN(Class
*cl
, Object
*obj
, struct sdpExitScreen
*msg
)
473 D(bug("[SCRDECOR] ScrDecorClass__SDM_EXITSCREEN()\n"));
478 /**************************************************************************************************/