2 Copyright © 1995-2013, 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 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
73 WORD right
= left
+ width
- 1;
74 WORD bottom
= top
+ height
- 1;
75 BOOL leftedgegodown
= FALSE
;
76 BOOL topedgegoright
= FALSE
;
78 if (left
== 0) leftedgegodown
= TRUE
;
79 if (top
== 0) topedgegoright
= TRUE
;
81 SetAPen(rp
, pens
[((state
== IDS_SELECTED
) || (state
== IDS_INACTIVESELECTED
)) ? SHADOWPEN
: SHINEPEN
]);
87 bottom
- (leftedgegodown
? 0 : 1));
90 RectFill(rp
, left
+ 1,
92 right
- (topedgegoright
? 0 : 1),
95 SetAPen(rp
, pens
[((state
== IDS_SELECTED
) || (state
== IDS_INACTIVESELECTED
)) ? SHINEPEN
: SHADOWPEN
]);
99 top
+ (topedgegoright
? 1 : 0),
104 RectFill(rp
, left
+ (leftedgegodown
? 1 : 0),
110 /**************************************************************************************************/
113 static UWORD
getbgpen(ULONG state
, UWORD
*pens
)
125 bg
= pens
[BACKGROUNDPEN
];
133 /**************************************************************************************************/
135 IPTR
ScrDecorClass__OM_NEW(Class
*cl
, Object
*obj
, struct opSet
*msg
)
137 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
138 struct Library
*UtilityBase
= GetPrivIBase(IntuitionBase
)->UtilityBase
;
139 struct scrdecor_data
*data
;
141 D(bug("[SCRDECOR] ScrDecorClass__OM_NEW()\n"));
143 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
146 data
= INST_DATA(cl
, obj
);
148 data
->userbuffersize
= (ULONG
) GetTagData(SDA_UserBuffer
, 0, msg
->ops_AttrList
);
155 /**************************************************************************************************/
157 IPTR
ScrDecorClass__OM_GET(Class
*cl
, Object
*obj
, struct opGet
*msg
)
159 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
161 D(bug("[SCRDECOR] ScrDecorClass__OM_GET()\n"));
163 switch(msg
->opg_AttrID
)
166 *msg
->opg_Storage
= (IPTR
) data
->userbuffersize
;
169 case SDA_TrueColorOnly
:
170 *msg
->opg_Storage
= FALSE
;
174 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
181 /**************************************************************************************************/
183 IPTR
ScrDecorClass__SDM_GETDEFSIZE_SYSIMAGE(Class
*cl
, Object
*obj
, struct sdpGetDefSizeSysImage
*msg
)
185 ULONG def_low_width
= DEFSIZE_WIDTH
, def_low_height
= DEFSIZE_HEIGHT
;
186 ULONG def_med_width
= DEFSIZE_WIDTH
, def_med_height
= DEFSIZE_HEIGHT
;
187 ULONG def_high_width
= DEFSIZE_WIDTH
, def_high_height
= DEFSIZE_HEIGHT
;
189 D(bug("[SCRDECOR] ScrDecorClass__SDM_GETDEFSIZE_SYSIMAGE()\n"));
191 switch(msg
->sdp_Which
)
195 def_low_width
= def_med_width
= def_high_width
= DEFSIZE_WIDTH
;
196 def_low_height
= def_med_height
= def_high_height
= DEFSIZE_HEIGHT
;
208 switch(msg
->sdp_SysiSize
)
210 case SYSISIZE_LOWRES
:
211 *msg
->sdp_Width
= def_low_width
;
212 *msg
->sdp_Height
= def_low_height
;
215 case SYSISIZE_MEDRES
:
216 *msg
->sdp_Width
= def_med_width
;
217 *msg
->sdp_Height
= def_med_height
;
222 *msg
->sdp_Width
= def_high_width
;
223 *msg
->sdp_Height
= def_high_height
;
230 /**************************************************************************************************/
232 IPTR
ScrDecorClass__SDM_DRAW_SYSIMAGE(Class
*cl
, Object
*obj
, struct sdpDrawSysImage
*msg
)
234 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
235 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
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 IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
383 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
384 struct RastPort
*rp
= msg
->sdp_RPort
;
385 UWORD
*pens
= DRI(msg
->sdp_Dri
)->dri_Pens
;
387 BOOL beeping
= FALSE
;
389 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR()\n"));
391 #if USE_NEWDISPLAYBEEP
392 beeping
= msg
->sdp_Screen
->Flags
& BEEPING
;
395 findtitlearea(msg
->sdp_Screen
, &left
, &right
);
397 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Title_Left = %d, Title_Right = %d\n", left
, right
));
399 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: RastPort @ %p, Screen @ %p\n", rp
, msg
->sdp_Screen
));
400 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Screen Dimensions %dx%d\n", msg
->sdp_Screen
->Width
, msg
->sdp_Screen
->Height
));
401 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Bar Height %d\n", msg
->sdp_Screen
->BarHeight
));
405 SetAPen(rp
, pens
[beeping
? BARDETAILPEN
: BARBLOCKPEN
]);
406 RectFill(rp
, left
+ 1, 0, right
- 1, msg
->sdp_Screen
->BarHeight
- 1);
408 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Filled Bar Area\n"));
410 SetAPen(rp
, pens
[beeping
? BARDETAILPEN
: BARTRIMPEN
]);
411 RectFill(rp
, 0, msg
->sdp_Screen
->BarHeight
, msg
->sdp_Screen
->Width
- 1, msg
->sdp_Screen
->BarHeight
);
413 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Filled Bar Area\n"));
415 if (msg
->sdp_Screen
->Title
)
417 SetAPen(rp
, pens
[beeping
? BARBLOCKPEN
: BARDETAILPEN
]);
418 SetBPen(rp
, pens
[beeping
? BARDETAILPEN
: BARBLOCKPEN
]);
420 Move(rp
, msg
->sdp_Screen
->BarHBorder
, msg
->sdp_Screen
->BarVBorder
+ rp
->TxBaseline
);
422 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Title Text @ %p\n", msg
->sdp_Screen
->Title
));
423 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Title '%s'\n", msg
->sdp_Screen
->Title
));
424 Text(rp
, msg
->sdp_Screen
->Title
, strlen(msg
->sdp_Screen
->Title
));
426 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR: Text Rendered\n"));
431 /**************************************************************************************************/
433 IPTR
ScrDecorClass__SDM_LAYOUT_SCREENGADGETS(Class
*cl
, Object
*obj
, struct sdpLayoutScreenGadgets
*msg
)
435 D(bug("[SCRDECOR] ScrDecorClass__SDM_LAYOUT_SCREENGADGETS()\n"));
438 * Nothing to do here any more.
439 * Proper default positioning is done by OpenScreen(). Use this method
440 * only if you actually want to change something.
446 IPTR
ScrDecorClass__SDM_INITSCREEN(Class
*cl
, Object
*obj
, struct sdpInitScreen
*msg
)
448 D(bug("[SCRDECOR] ScrDecorClass__SDM_INITSCREEN()\n"));
453 IPTR
ScrDecorClass__SDM_EXITSCREEN(Class
*cl
, Object
*obj
, struct sdpExitScreen
*msg
)
455 D(bug("[SCRDECOR] ScrDecorClass__SDM_EXITSCREEN()\n"));
460 /**************************************************************************************************/