Added kernel module for starting the usb stack at boot time. It's not activated thoug...
[cake.git] / rom / intuition / scrdecorclass.c
blobe0eea5a7d21c466d624172ed9444f30949c6e809
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 static UWORD getbgpen(ULONG state, UWORD *pens)
113 UWORD bg;
115 switch (state)
117 case IDS_NORMAL:
118 case IDS_SELECTED:
119 bg = pens[FILLPEN];
120 break;
122 default:
123 bg = pens[BACKGROUNDPEN];
124 break;
127 return bg;
131 /**************************************************************************************************/
133 #undef IntuitionBase
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);
145 if (obj)
147 data = INST_DATA(cl, obj);
149 data->userbuffersize = (ULONG) GetTagData(SDA_UserBuffer, 0, msg->ops_AttrList);
153 return (IPTR)obj;
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)
166 case SDA_UserBuffer:
167 *msg->opg_Storage = (IPTR) data->userbuffersize;
168 break;
170 case SDA_TrueColorOnly:
171 *msg->opg_Storage = FALSE;
172 break;
174 default:
175 return DoSuperMethodA(cl, obj, (Msg)msg);
178 return 1;
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)
194 case SDEPTHIMAGE:
195 #if USE_AROS_DEFSIZE
196 def_low_width = def_med_width = def_high_width = DEFSIZE_WIDTH;
197 def_low_height = def_med_height = def_high_height = DEFSIZE_HEIGHT;
198 #else
199 def_low_width = 17;
200 def_med_width = 23;
201 def_high_width = 23;
202 #endif
203 break;
205 default:
206 return FALSE;
209 switch(msg->sdp_SysiSize)
211 case SYSISIZE_LOWRES:
212 *msg->sdp_Width = def_low_width;
213 *msg->sdp_Height = def_low_height;
214 break;
216 case SYSISIZE_MEDRES:
217 *msg->sdp_Width = def_med_width;
218 *msg->sdp_Height = def_med_height;
219 break;
221 case SYSISIZE_HIRES:
222 default:
223 *msg->sdp_Width = def_high_width;
224 *msg->sdp_Height = def_high_height;
225 break;
228 return TRUE;
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"));
247 SetDrMd(rp, JAM1);
249 switch(msg->sdp_Which)
251 case SDEPTHIMAGE:
253 UWORD bg;
254 WORD h_spacing;
255 WORD v_spacing;
257 renderimageframe(rp, DEPTHIMAGE, state, pens,
258 left, top, width, height, IntuitionBase);
259 left++;
260 top++;
261 right--;
262 bottom--;
263 width -= 2;
264 height -= 2;
266 h_spacing = width / 6;
267 v_spacing = height / 6;
269 bg = pens[BACKGROUNDPEN];
271 /* Clear background into correct color */
272 SetAPen(rp, bg);
273 RectFill(rp, left, top, right, bottom);
275 /* Draw a image of two partly overlapped tiny windows,
278 left += h_spacing;
279 top += v_spacing;
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);
309 break;
312 default:
313 return FALSE;
316 return TRUE;
319 /**************************************************************************************************/
321 static void findtitlearea(struct Screen *scr, LONG *left, LONG *right)
323 struct Gadget *g;
325 *left = 0;
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;
335 else
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;
351 LONG left, right;
352 BOOL beeping = FALSE;
354 #if 0
355 #if USE_NEWDISPLAYBEEP
356 beeping = (msg->sdp_Screen->Flags & BEEPING) && GetBitMapAttr(rp->BitMap, BMA_DEPTH) > 8;
357 #endif
358 #endif
360 SetDrMd(rp, JAM1);
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);
373 return TRUE;
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;
383 LONG right, left;
384 BOOL beeping = FALSE;
386 D(bug("[SCRDECOR] ScrDecorClass__SDM_DRAW_SCREENBAR()\n"));
388 #if 0
389 #if USE_NEWDISPLAYBEEP
390 beeping = (BOOL)((msg->sdp_Screen->Flags & BEEPING) && (GetBitMapAttr(rp->BitMap, BMA_DEPTH) > 8));
391 #endif
392 #endif
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));
402 SetDrMd(rp, JAM1);
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"));
427 return TRUE;
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"));
438 while(gadget)
440 switch(gadget->GadgetType & GTYP_SYSTYPEMASK)
442 case GTYP_SDEPTH:
443 gadget->LeftEdge = -gadget->Height + 1;
444 gadget->Width = gadget->Height;
445 gadget->Flags &= ~GFLG_RELWIDTH;
446 gadget->Flags |= GFLG_RELRIGHT;
447 break;
451 if (msg->sdp_Flags & SDF_LSG_MULTIPLE)
453 gadget = gadget->NextGadget;
455 else
457 gadget = NULL;
461 return TRUE;
464 IPTR ScrDecorClass__SDM_INITSCREEN(Class *cl, Object *obj, struct sdpInitScreen *msg)
466 D(bug("[SCRDECOR] ScrDecorClass__SDM_INITSCREEN()\n"));
468 return TRUE;
471 IPTR ScrDecorClass__SDM_EXITSCREEN(Class *cl, Object *obj, struct sdpExitScreen *msg)
473 D(bug("[SCRDECOR] ScrDecorClass__SDM_EXITSCREEN()\n"));
475 return TRUE;
478 /**************************************************************************************************/