CopyToAFS: Remove dead FMF_* flags
[AROS.git] / rom / intuition / scrdecorclass.c
blobb94b78cbc2e97751118ef1759a69635d2e0ae500
1 /*
2 Copyright 1995-2005, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #define DEBUG 0
8 #include <aros/debug.h>
10 #include <dos/dos.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>
30 #include <string.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"
40 #include "gadgets.h"
42 /**************************************************************************************************/
44 #ifdef __AROS__
45 #define USE_AROS_DEFSIZE 1
46 #else
47 #define USE_AROS_DEFSIZE 0
48 #endif
50 #define DEFSIZE_WIDTH 14
51 #define DEFSIZE_HEIGHT 14
53 #define HSPACING 3
54 #define VSPACING 3
55 /* Ralph Schmidt
56 * heuristics for smaller arrows used in apps
57 * like filer
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]);
82 /* left edge */
83 RectFill(rp, left,
84 top,
85 left,
86 bottom - (leftedgegodown ? 0 : 1));
88 /* top edge */
89 RectFill(rp, left + 1,
90 top,
91 right - (topedgegoright ? 0 : 1),
92 top);
94 SetAPen(rp, pens[((state == IDS_SELECTED) || (state == IDS_INACTIVESELECTED)) ? SHINEPEN : SHADOWPEN]);
96 /* right edge */
97 RectFill(rp, right,
98 top + (topedgegoright ? 1 : 0),
99 right,
100 bottom);
102 /* bottom edge */
103 RectFill(rp, left + (leftedgegodown ? 1 : 0),
104 bottom,
105 right - 1,
106 bottom);
109 /**************************************************************************************************/
111 #if 0
112 static UWORD getbgpen(ULONG state, UWORD *pens)
114 UWORD bg;
116 switch (state)
118 case IDS_NORMAL:
119 case IDS_SELECTED:
120 bg = pens[FILLPEN];
121 break;
123 default:
124 bg = pens[BACKGROUNDPEN];
125 break;
128 return bg;
130 #endif
132 /**************************************************************************************************/
134 #undef IntuitionBase
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);
146 if (obj)
148 data = INST_DATA(cl, obj);
150 data->userbuffersize = (ULONG) GetTagData(SDA_UserBuffer, 0, msg->ops_AttrList);
154 return (IPTR)obj;
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)
167 case SDA_UserBuffer:
168 *msg->opg_Storage = (IPTR) data->userbuffersize;
169 break;
171 case SDA_TrueColorOnly:
172 *msg->opg_Storage = FALSE;
173 break;
175 default:
176 return DoSuperMethodA(cl, obj, (Msg)msg);
179 return 1;
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)
195 case SDEPTHIMAGE:
196 #if USE_AROS_DEFSIZE
197 def_low_width = def_med_width = def_high_width = DEFSIZE_WIDTH;
198 def_low_height = def_med_height = def_high_height = DEFSIZE_HEIGHT;
199 #else
200 def_low_width = 17;
201 def_med_width = 23;
202 def_high_width = 23;
203 #endif
204 break;
206 default:
207 return FALSE;
210 switch(msg->sdp_SysiSize)
212 case SYSISIZE_LOWRES:
213 *msg->sdp_Width = def_low_width;
214 *msg->sdp_Height = def_low_height;
215 break;
217 case SYSISIZE_MEDRES:
218 *msg->sdp_Width = def_med_width;
219 *msg->sdp_Height = def_med_height;
220 break;
222 case SYSISIZE_HIRES:
223 default:
224 *msg->sdp_Width = def_high_width;
225 *msg->sdp_Height = def_high_height;
226 break;
229 return TRUE;
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"));
248 SetDrMd(rp, JAM1);
250 switch(msg->sdp_Which)
252 case SDEPTHIMAGE:
254 UWORD bg;
255 WORD h_spacing;
256 WORD v_spacing;
258 renderimageframe(rp, DEPTHIMAGE, state, pens,
259 left, top, width, height, IntuitionBase);
260 left++;
261 top++;
262 right--;
263 bottom--;
264 width -= 2;
265 height -= 2;
267 h_spacing = width / 6;
268 v_spacing = height / 6;
270 bg = pens[BACKGROUNDPEN];
272 /* Clear background into correct color */
273 SetAPen(rp, bg);
274 RectFill(rp, left, top, right, bottom);
276 /* Draw a image of two partly overlapped tiny windows,
279 left += h_spacing;
280 top += v_spacing;
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);
310 break;
313 default:
314 return FALSE;
317 return TRUE;
320 /**************************************************************************************************/
322 static void findtitlearea(struct Screen *scr, LONG *left, LONG *right)
324 struct Gadget *g;
326 *left = 0;
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;
336 else
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;
352 LONG left, right;
353 BOOL beeping = FALSE;
355 #if 0
356 #if USE_NEWDISPLAYBEEP
357 beeping = (msg->sdp_Screen->Flags & BEEPING) && GetBitMapAttr(rp->BitMap, BMA_DEPTH) > 8;
358 #endif
359 #endif
361 SetDrMd(rp, JAM1);
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);
374 return TRUE;
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;
384 LONG right, left;
385 BOOL beeping = FALSE;
387 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR()\n"));
389 #if USE_NEWDISPLAYBEEP
390 beeping = msg->sdp_Screen->Flags & BEEPING;
391 #endif
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));
401 SetDrMd(rp, JAM1);
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"));
426 return TRUE;
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"));
437 while(gadget)
439 switch(gadget->GadgetType & GTYP_SYSTYPEMASK)
441 case GTYP_SDEPTH:
442 gadget->LeftEdge = -gadget->Height + 1;
443 gadget->Width = gadget->Height;
444 gadget->Flags &= ~GFLG_RELWIDTH;
445 gadget->Flags |= GFLG_RELRIGHT;
446 break;
450 if (msg->sdp_Flags & SDF_LSG_MULTIPLE)
452 gadget = gadget->NextGadget;
454 else
456 gadget = NULL;
460 return TRUE;
463 IPTR ScrDecorClass__SDM_INITSCREEN(Class *cl, Object *obj, struct sdpInitScreen *msg)
465 D(bug("[SCRDECOR] ScrDecorClass__SDM_INITSCREEN()\n"));
467 return TRUE;
470 IPTR ScrDecorClass__SDM_EXITSCREEN(Class *cl, Object *obj, struct sdpExitScreen *msg)
472 D(bug("[SCRDECOR] ScrDecorClass__SDM_EXITSCREEN()\n"));
474 return TRUE;
477 /**************************************************************************************************/