- Give PCI controllers lower unit numbers than legacy controllers.
[cake.git] / rom / intuition / windecorclass.c
blob0673d162ba9e51783e042edd4a746c0547dfd495
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 */
8 #include <dos/dos.h>
9 #include <dos/dosextens.h>
11 #include <intuition/intuition.h>
12 #include <intuition/intuitionbase.h>
13 #include <intuition/classes.h>
14 #include <intuition/classusr.h>
15 #include <intuition/windecorclass.h>
16 #include <intuition/cghooks.h>
17 #include <intuition/icclass.h>
18 #include <intuition/extensions.h>
20 #include <graphics/gfxbase.h>
21 #include <graphics/gfxmacros.h>
23 #include <utility/tagitem.h>
24 #include <utility/hooks.h>
26 #include <clib/macros.h>
28 #include <string.h>
30 #include <proto/exec.h>
31 #include <proto/intuition.h>
32 #include <proto/graphics.h>
33 #include <proto/utility.h>
35 #include <proto/alib.h>
37 #include "intuition_intern.h"
38 #include "gadgets.h"
40 /**************************************************************************************************/
42 #ifdef __AROS__
43 #define USE_AROS_DEFSIZE 1
44 #else
45 #define USE_AROS_DEFSIZE 0
46 #endif
48 #define DEFSIZE_WIDTH 14
49 #define DEFSIZE_HEIGHT 14
51 #define HSPACING 3
52 #define VSPACING 3
53 /* Ralph Schmidt
54 * heuristics for smaller arrows used in apps
55 * like filer
57 #define HSPACING_MIDDLE 2
58 #define VSPACING_MIDDLE 2
59 #define HSPACING_SMALL 1
60 #define VSPACING_SMALL 1
62 #define DRI(dri) ((struct DrawInfo *)(dri))
64 /**************************************************************************************************/
66 static void renderimageframe(struct RastPort *rp, ULONG which, ULONG state, UWORD *pens,
67 WORD left, WORD top, WORD width, WORD height,
68 struct IntuitionBase *IntuitionBase)
70 WORD right = left + width - 1;
71 WORD bottom = top + height - 1;
72 BOOL leftedgegodown = FALSE;
73 BOOL topedgegoright = FALSE;
75 switch(which)
77 #if 0
78 case CLOSEIMAGE:
79 /* draw separator line at the right side */
80 SetAPen(rp, pens[SHINEPEN]);
81 RectFill(rp, right, top, right, bottom - 1);
82 SetAPen(rp, pens[SHADOWPEN]);
83 WritePixel(rp, right, bottom);
85 right--;
86 break;
88 case ZOOMIMAGE:
89 case DEPTHIMAGE:
90 case SDEPTHIMAGE:
91 /* draw separator line at the left side */
92 SetAPen(rp, pens[SHINEPEN]);
93 WritePixel(rp, left, top);
94 SetAPen(rp, pens[SHADOWPEN]);
95 RectFill(rp, left, top + 1, left, bottom);
97 left++;
98 break;
99 #endif
101 case UPIMAGE:
102 case DOWNIMAGE:
103 leftedgegodown = TRUE;
104 break;
106 case LEFTIMAGE:
107 case RIGHTIMAGE:
108 topedgegoright = TRUE;
109 break;
112 if (left == 0) leftedgegodown = TRUE;
113 if (top == 0) topedgegoright = TRUE;
115 SetAPen(rp, pens[((state == IDS_SELECTED) || (state == IDS_INACTIVESELECTED)) ? SHADOWPEN : SHINEPEN]);
117 /* left edge */
118 RectFill(rp, left,
119 top,
120 left,
121 bottom - (leftedgegodown ? 0 : 1));
123 /* top edge */
124 RectFill(rp, left + 1,
125 top,
126 right - (topedgegoright ? 0 : 1),
127 top);
129 SetAPen(rp, pens[((state == IDS_SELECTED) || (state == IDS_INACTIVESELECTED)) ? SHINEPEN : SHADOWPEN]);
131 /* right edge */
132 RectFill(rp, right,
133 top + (topedgegoright ? 1 : 0),
134 right,
135 bottom);
137 /* bottom edge */
138 RectFill(rp, left + (leftedgegodown ? 1 : 0),
139 bottom,
140 right - 1,
141 bottom);
144 /**************************************************************************************************/
146 static UWORD getbgpen(ULONG state, UWORD *pens)
148 UWORD bg;
149 switch (state)
151 case IDS_NORMAL:
152 case IDS_SELECTED:
153 bg = pens[FILLPEN];
154 break;
156 default:
157 bg = pens[BACKGROUNDPEN];
158 break;
161 return bg;
165 /**************************************************************************************************/
167 #undef IntuitionBase
168 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
170 /**************************************************************************************************/
172 IPTR WinDecorClass__OM_NEW(Class *cl, Object *obj, struct opSet *msg)
174 struct windecor_data *data;
176 obj = (Object *)DoSuperMethodA(cl, obj, (Msg)msg);
177 if (obj)
179 data = INST_DATA(cl, obj);
180 data->userbuffersize = (ULONG) GetTagData(WDA_UserBuffer, 0, msg->ops_AttrList);
183 return (IPTR)obj;
186 /**************************************************************************************************/
188 IPTR WinDecorClass__OM_GET(Class *cl, Object *obj, struct opGet *msg)
190 struct windecor_data *data = INST_DATA(cl, obj);
192 switch(msg->opg_AttrID)
194 case WDA_UserBuffer:
195 *msg->opg_Storage = (IPTR) data->userbuffersize;
196 break;
197 case WDA_TrueColorOnly:
198 *msg->opg_Storage = FALSE;
199 break;
201 default:
202 return DoSuperMethodA(cl, obj, (Msg)msg);
205 return 1;
209 /**************************************************************************************************/
211 IPTR WinDecorClass__WDM_GETDEFSIZE_SYSIMAGE(Class *cl, Object *obj, struct wdpGetDefSizeSysImage *msg)
213 ULONG def_low_width = DEFSIZE_WIDTH, def_low_height = DEFSIZE_HEIGHT;
214 ULONG def_med_width = DEFSIZE_WIDTH, def_med_height = DEFSIZE_HEIGHT;
215 ULONG def_high_width = DEFSIZE_WIDTH, def_high_height = DEFSIZE_HEIGHT;
217 #define REFHEIGHT (msg->wdp_ReferenceFont->tf_YSize)
218 #define REFWIDTH REFHEIGHT
220 switch(msg->wdp_Which)
222 case LEFTIMAGE:
223 case RIGHTIMAGE:
224 #if USE_AROS_DEFSIZE
225 def_low_width = def_med_width = def_high_width = DEFSIZE_WIDTH;
226 def_low_height = def_med_height = def_high_height = DEFSIZE_HEIGHT;
227 #else
228 def_low_width = 16;
229 def_med_width = 16;
230 def_high_width = 23;
231 def_low_height = 11;
232 def_med_height = 10;
233 def_high_height = 22;
234 #endif
235 break;
237 case UPIMAGE:
238 case DOWNIMAGE:
239 #if USE_AROS_DEFSIZE
240 def_low_width = def_med_width = def_high_width = DEFSIZE_WIDTH;
241 def_low_height = def_med_height = def_high_height = DEFSIZE_HEIGHT;
242 #else
243 def_low_width = 13;
244 def_med_width = 18;
245 def_high_width = 23;
246 def_low_height = 11;
247 def_med_height = 11;
248 def_high_height = 22;
249 #endif
250 break;
252 case DEPTHIMAGE:
253 case ZOOMIMAGE:
254 case ICONIFYIMAGE:
255 case LOCKIMAGE:
256 case MUIIMAGE:
257 case POPUPIMAGE:
258 case SNAPSHOTIMAGE:
259 case JUMPIMAGE:
260 #if USE_AROS_DEFSIZE
261 def_low_width = def_med_width = def_high_width = DEFSIZE_WIDTH;
262 def_low_height = def_med_height = def_high_height = DEFSIZE_HEIGHT;
263 #else
264 def_low_width = 18;
265 def_med_width = 24;
266 def_high_width = 24;
267 #endif
268 break;
270 case SDEPTHIMAGE:
271 #if USE_AROS_DEFSIZE
272 def_low_width = def_med_width = def_high_width = DEFSIZE_WIDTH;
273 def_low_height = def_med_height = def_high_height = DEFSIZE_HEIGHT;
274 #else
275 def_low_width = 17;
276 def_med_width = 23;
277 def_high_width = 23;
278 #endif
279 break;
281 case CLOSEIMAGE:
282 #if USE_AROS_DEFSIZE
283 def_low_width = def_med_width = def_high_width = DEFSIZE_WIDTH;
284 def_low_height = def_med_height = def_high_height = DEFSIZE_HEIGHT;
285 #else
286 def_low_width = 15;
287 def_med_width = 20;
288 def_high_width = 20;
289 #endif
290 break;
292 case SIZEIMAGE:
293 #if USE_AROS_DEFSIZE
294 def_low_width = def_med_width = def_high_width = DEFSIZE_WIDTH;
295 def_low_height = def_med_height = def_high_height = DEFSIZE_HEIGHT;
296 #else
297 def_low_width = 13;
298 def_med_width = 18;
299 def_high_width = 18;
300 def_low_height = 11;
301 def_med_height = 10;
302 def_high_height = 10;
303 #endif
304 break;
306 case MENUCHECK:
307 def_low_width =
308 def_med_width =
309 def_high_width = REFWIDTH / 2 + 4; // reffont->tf_XSize * 3 / 2;
310 def_low_height =
311 def_med_height =
312 def_high_height= REFHEIGHT;
313 break;
315 case MXIMAGE:
316 def_low_width =
317 def_med_width =
318 def_high_width = (REFWIDTH + 1) * 2; // reffont->tf_XSize * 3 - 1;
319 def_low_height =
320 def_med_height =
321 def_high_height= REFHEIGHT + 1;
322 break;
324 case CHECKIMAGE:
325 def_low_width = (REFWIDTH + 3) * 2;//reffont->tf_XSize * 2;
326 def_low_height = REFHEIGHT + 3;
327 break;
329 default:
330 return FALSE;
333 switch(msg->wdp_SysiSize)
335 case SYSISIZE_LOWRES:
336 *msg->wdp_Width = def_low_width;
337 *msg->wdp_Height = def_low_height;
338 break;
340 case SYSISIZE_MEDRES:
341 *msg->wdp_Width = def_med_width;
342 *msg->wdp_Height = def_med_height;
343 break;
345 case SYSISIZE_HIRES:
346 default:
347 *msg->wdp_Width = def_high_width;
348 *msg->wdp_Height = def_high_height;
349 break;
352 return TRUE;
355 /**************************************************************************************************/
357 IPTR WinDecorClass__WDM_DRAW_SYSIMAGE(Class *cl, Object *obj, struct wdpDrawSysImage *msg)
359 struct RastPort *rp = msg->wdp_RPort;
360 UWORD *pens = DRI(msg->wdp_Dri)->dri_Pens;
361 LONG state = msg->wdp_State;
362 LONG left = msg->wdp_X;
363 LONG top = msg->wdp_Y;
364 LONG width = msg->wdp_Width;
365 LONG height = msg->wdp_Height;
366 LONG right = left + width - 1;
367 LONG bottom = top + height - 1;
368 LONG h_spacing, v_spacing;
370 SetDrMd(rp, JAM1);
372 switch(msg->wdp_Which)
375 case MUIIMAGE:
377 renderimageframe(rp, CLOSEIMAGE, state, pens, left, top, width, height, IntuitionBase);
378 /* no code yet */
379 break;
381 case POPUPIMAGE:
383 renderimageframe(rp, CLOSEIMAGE, state, pens, left, top, width, height, IntuitionBase);
384 /* code should be added later */
385 break;
387 case CLOSEIMAGE:
389 renderimageframe(rp, CLOSEIMAGE, state, pens, left, top, width, height, IntuitionBase);
390 left++;
391 top++;
392 width -= 2;
393 height -= 2;
395 right = left + width - 1;
396 bottom = top + height - 1;
397 h_spacing = width * 4 / 10;
398 v_spacing = height * 3 / 10;
400 SetAPen(rp, getbgpen(state, pens));
401 RectFill(rp, left, top, right, bottom);
403 left += h_spacing;
404 right -= h_spacing;
405 top += v_spacing;
406 bottom -= v_spacing;
408 SetAPen(rp, pens[SHADOWPEN]);
409 RectFill(rp, left, top, right, bottom);
411 left++;
412 top++;
413 right--;
414 bottom--;
416 SetAPen(rp, pens[(state == IDS_NORMAL) ? SHINEPEN : BACKGROUNDPEN]);
417 RectFill(rp, left, top, right, bottom);
419 break;
422 case ZOOMIMAGE:
424 UWORD bg;
425 WORD h_spacing;
426 WORD v_spacing;
428 renderimageframe(rp, ZOOMIMAGE, state, pens,
429 left, top, width, height, IntuitionBase);
430 left++;
431 top++;
432 width -= 2;
433 height -= 2;
435 right = left + width - 1;
436 bottom = top + height - 1 ;
437 h_spacing = width / 6;
438 v_spacing = height / 6;
440 bg = getbgpen(state, pens);
442 /* Clear background into correct color */
443 SetAPen(rp, bg);
444 RectFill(rp, left, top, right, bottom);
446 left += h_spacing;
447 right -= h_spacing;
448 top += v_spacing;
449 bottom -= v_spacing;
451 SetAPen(rp, pens[SHADOWPEN]);
452 RectFill(rp, left, top, right, bottom);
454 SetAPen(rp, pens[(state == IDS_SELECTED) ? SHINEPEN :
455 (state == IDS_NORMAL) ? FILLPEN : BACKGROUNDPEN]);
456 RectFill(rp, left + 1, top + 1, right - 1, bottom - 1);
458 right = left + (right - left + 1) / 2;
459 bottom = top + (bottom - top + 1) / 2;
461 if (right - left < 4) right = left + 4;
463 SetAPen(rp, pens[SHADOWPEN]);
464 RectFill(rp, left, top, right, bottom);
466 left += 2;
467 right -= 2;
468 top += 1;
469 bottom -= 1;
471 SetAPen(rp, pens[(state == IDS_SELECTED) ? FILLPEN :
472 (state == IDS_NORMAL) ? SHINEPEN : BACKGROUNDPEN]);
473 RectFill(rp,left, top, right, bottom);
474 break;
477 case DEPTHIMAGE:
479 UWORD bg;
480 WORD h_spacing;
481 WORD v_spacing;
483 renderimageframe(rp, DEPTHIMAGE, state, pens,
484 left, top, width, height, IntuitionBase);
485 left++;
486 top++;
487 right--;
488 bottom--;
489 width -= 2;
490 height -= 2;
492 h_spacing = width / 6;
493 v_spacing = height / 6;
495 bg = getbgpen(state, pens);
497 /* Clear background into correct color */
498 SetAPen(rp, bg);
499 RectFill(rp, left, top, right, bottom);
501 /* Draw a image of two partly overlapped tiny windows,
504 left += h_spacing;
505 top += v_spacing;
507 width -= h_spacing * 2;
508 height -= v_spacing * 2;
510 right = left + width - 1;
511 bottom = top + height - 1;
513 /* Render top left window */
515 SetAPen(rp, pens[SHADOWPEN]);
516 drawrect(rp
517 , left
518 , top
519 , right - (width / 3 )
520 , bottom - (height / 3)
521 , IntuitionBase);
524 /* Fill top left window (inside of the frame above) */
526 if ((state != IDS_INACTIVENORMAL))
528 SetAPen(rp, pens[BACKGROUNDPEN]);
529 RectFill(rp, left + 1, top + 1,
530 right - (width / 3) - 1, bottom - (height / 3) - 1);
534 /* Render bottom right window */
535 SetAPen(rp, pens[SHADOWPEN]);
536 drawrect(rp, left + (width / 3), top + (height / 3),
537 right, bottom, IntuitionBase);
539 /* Fill bottom right window (inside of the frame above) */
540 SetAPen(rp, pens[(state == IDS_INACTIVENORMAL) ? BACKGROUNDPEN : SHINEPEN]);
541 RectFill(rp, left + (width / 3) + 1, top + (height / 3) + 1,
542 right - 1, bottom - 1);
544 if (state == IDS_SELECTED)
546 /* Re-Render top left window */
548 SetAPen(rp, pens[SHADOWPEN]);
549 drawrect(rp, left, top,
550 right - (width / 3 ), bottom - (height / 3), IntuitionBase);
552 break;
555 case SIZEIMAGE:
557 UWORD bg;
558 WORD h_spacing;
559 WORD v_spacing;
560 WORD x, y;
562 renderimageframe(rp, SIZEIMAGE, state, pens,
563 left, top, width, height, IntuitionBase);
564 left++;
565 top++;
566 right--;
567 bottom--;
568 width -= 2;
569 height -= 2;
571 h_spacing = width / 5;
572 v_spacing = height / 5;
574 bg = getbgpen(state, pens);
576 /* Clear background into correct color */
577 SetAPen(rp, bg);
578 RectFill(rp, left, top, right, bottom);
580 /* A triangle image */
582 left += h_spacing;
583 top += v_spacing;
585 right = left + width - 1 - (h_spacing * 2);
586 bottom = top + height - 1 - (v_spacing * 2);
588 width = right - left + 1;
589 height = bottom - top + 1;
591 if (state != IDS_INACTIVENORMAL)
593 SetAPen(rp, pens[SHINEPEN]);
595 for(y = top; y <= bottom; y++)
597 x = left + (bottom - y) * width / height;
598 RectFill(rp, x, y, right, y);
602 SetAPen(rp, pens[SHADOWPEN]);
603 /* Draw triangle border */
604 Move(rp, left, bottom);
605 Draw(rp, right, top);
606 Draw(rp, right, bottom);
607 Draw(rp, left, bottom);
609 break;
612 case LEFTIMAGE:
614 UWORD hspacing,vspacing;
615 WORD cy, i;
617 hspacing = HSPACING;
618 vspacing = VSPACING;
620 if (width <= 12)
622 hspacing = HSPACING_MIDDLE;
625 if (width <= 10)
627 hspacing = HSPACING_SMALL;
630 if (height <= 12)
632 vspacing = VSPACING_MIDDLE;
635 if (height <= 10)
637 vspacing = VSPACING_SMALL;
640 renderimageframe(rp, LEFTIMAGE, state, pens,
641 left, top, width, height, IntuitionBase);
642 left++;
643 top++;
644 right--;
645 bottom--;
646 width -= 2;
647 height -= 2;
649 SetAPen(rp, getbgpen(state, pens));
650 RectFill(rp, left, top, right, bottom);
652 left += hspacing;
653 top += vspacing;
654 width -= hspacing * 2;
655 height -= vspacing * 2;
657 right = left + width - 1;
658 bottom = top + height - 1;
660 cy = (height + 1) / 2;
662 SetAPen(rp, pens[SHADOWPEN]);
664 for(i = 0; i < cy; i++)
666 RectFill(rp, left + (cy - i - 1) * width / cy,
667 top + i,
668 right - i * width / cy / 2,
669 top + i);
670 RectFill(rp, left + (cy - i - 1) * width / cy,
671 bottom - i,
672 right - i * width / cy / 2,
673 bottom - i);
675 break;
678 case UPIMAGE:
680 UWORD hspacing,vspacing;
681 WORD cx, i;
683 hspacing = HSPACING;
684 vspacing = VSPACING;
686 if (width <= 12)
688 hspacing = HSPACING_MIDDLE;
691 if (width <= 10)
693 hspacing = HSPACING_SMALL;
696 if (height <= 12)
698 vspacing = VSPACING_MIDDLE;
701 if (height <= 10)
703 vspacing = VSPACING_SMALL;
706 renderimageframe(rp, UPIMAGE, state, pens,
707 left, top, width, height, IntuitionBase);
708 left++;
709 top++;
710 right--;
711 bottom--;
712 width -= 2;
713 height -= 2;
715 SetAPen(rp, getbgpen(state, pens));
716 RectFill(rp, left, top, right, bottom);
718 left += hspacing;
719 top += vspacing;
720 width -= hspacing * 2;
721 height -= vspacing * 2;
723 right = left + width - 1;
724 bottom = top + height - 1;
726 cx = (width + 1) / 2;
728 SetAPen(rp, pens[SHADOWPEN]);
730 for(i = 0; i < cx; i++)
732 RectFill(rp, left + i,
733 top + (cx - i - 1) * height / cx,
734 left + i,
735 bottom - i * height / cx / 2);
736 RectFill(rp, right - i,
737 top + (cx - i - 1) * height / cx,
738 right - i,
739 bottom - i * height / cx / 2);
742 break;
745 case RIGHTIMAGE:
747 UWORD hspacing,vspacing;
748 WORD cy, i;
750 hspacing = HSPACING;
751 vspacing = VSPACING;
753 if (width <= 12)
755 hspacing = HSPACING_MIDDLE;
758 if (width <= 10)
760 hspacing = HSPACING_SMALL;
763 if (height <= 12)
765 vspacing = VSPACING_MIDDLE;
768 if (height <= 10)
770 vspacing = VSPACING_SMALL;
773 renderimageframe(rp, RIGHTIMAGE, state, pens,
774 left, top, width, height, IntuitionBase);
775 left++;
776 top++;
777 right--;
778 bottom--;
779 width -= 2;
780 height -= 2;
783 SetAPen(rp, getbgpen(state, pens));
784 RectFill(rp, left, top, right, bottom);
786 left += hspacing;
787 top += vspacing;
788 width -= hspacing * 2;
789 height -= vspacing * 2;
791 right = left + width - 1;
792 bottom = top + height - 1;
794 cy = (height + 1) / 2;
796 SetAPen(rp, pens[SHADOWPEN]);
798 for(i = 0; i < cy; i++)
800 RectFill(rp, left + i * width / cy / 2,
801 top + i,
802 right - (cy - i - 1) * width / cy,
803 top + i);
804 RectFill(rp, left + i * width / cy / 2,
805 bottom - i,
806 right - (cy - i - 1) * width / cy,
807 bottom - i);
809 break;
812 case DOWNIMAGE:
814 UWORD hspacing,vspacing;
815 WORD cx, i;
817 hspacing = HSPACING;
818 vspacing = VSPACING;
820 if (width <= 12)
822 hspacing = HSPACING_MIDDLE;
825 if (width <= 10)
827 hspacing = HSPACING_SMALL;
830 if (height <= 12)
832 vspacing = VSPACING_MIDDLE;
835 if (height <= 10)
837 vspacing = VSPACING_SMALL;
840 renderimageframe(rp, DOWNIMAGE, state, pens,
841 left, top, width, height, IntuitionBase);
842 left++;
843 top++;
844 right--;
845 bottom--;
846 width -= 2;
847 height -= 2;
849 SetAPen(rp, getbgpen(state, pens));
850 RectFill(rp, left, top, right, bottom);
852 left += hspacing;
853 top += vspacing;
854 width -= hspacing * 2;
855 height -= vspacing * 2;
857 right = left + width - 1;
858 bottom = top + height - 1;
860 cx = (width + 1) / 2;
862 SetAPen(rp, pens[SHADOWPEN]);
864 for(i = 0; i < cx; i++)
866 RectFill(rp, left + i,
867 top + i * height / cx / 2,
868 left + i,
869 bottom - (cx - i - 1) * height / cx);
870 RectFill(rp, right - i,
871 top + i * height / cx / 2,
872 right - i,
873 bottom - (cx - i - 1) * height / cx);
876 break;
880 default:
881 return FALSE;
884 return TRUE;
887 /**************************************************************************************************/
889 static void findtitlearea(struct Window *win, LONG *left, LONG *right)
891 struct Gadget *g;
893 *left = 0;
894 *right = win->Width - 1;
896 for (g = win->FirstGadget; g; g = g->NextGadget)
898 if (g->Activation & GACT_TOPBORDER && g != (struct Gadget *)IW(win)->sysgads[DRAGBAR])
900 if (!(g->Flags & GFLG_RELRIGHT))
902 if (g->LeftEdge + g->Width > *left)
903 *left = g->LeftEdge + g->Width;
905 else
907 if (g->LeftEdge + win->Width - 1 - 1 < *right)
908 *right = g->LeftEdge + win->Width - 1 - 1;
915 /**************************************************************************************************/
917 IPTR INTERNAL_WDM_DRAW_WINTITLE(Class *cl, Object *obj, struct wdpDrawWinBorder *msg)
919 struct RastPort *rp = msg->wdp_RPort;
920 struct Window *window = msg->wdp_Window;
921 UWORD *pens = DRI(msg->wdp_Dri)->dri_Pens;
922 LONG right, left;
924 findtitlearea(window, &left, &right);
926 SetDrMd(rp, JAM1);
927 SetAPen(rp, pens[(window->Flags & WFLG_WINDOWACTIVE) ? FILLPEN : BACKGROUNDPEN]);
928 CheckRectFill(rp, left + 1, 1, right - 1, window->BorderTop - 2, IntuitionBase);
930 if (right - left > 6)
932 ULONG textlen, titlelen, textpixellen;
933 struct TextExtent te;
935 SetFont(rp, DRI(msg->wdp_Dri)->dri_Font);
937 titlelen = strlen(window->Title);
938 textlen = TextFit(rp
939 , window->Title
940 , titlelen
941 , &te
942 , NULL
944 , right - left - 6
945 , window->BorderTop - 2);
946 if (textlen)
948 textpixellen = te.te_Extent.MaxX - te.te_Extent.MinX + 1;
950 left = left + 3;
952 SetAPen(rp, pens[(window->Flags & WFLG_WINDOWACTIVE) ? FILLTEXTPEN : TEXTPEN]);
954 Move(rp, left, DRI(msg->wdp_Dri)->dri_Font->tf_Baseline + 2);
955 Text(rp, window->Title, textlen);
959 return TRUE;
962 /**************************************************************************************************/
964 IPTR WinDecorClass__WDM_DRAW_WINBORDER(Class *cl, Object *obj, struct wdpDrawWinBorder *msg)
966 struct RastPort *rp = msg->wdp_RPort;
967 struct Window *window = msg->wdp_Window;
968 UWORD *pens = DRI(msg->wdp_Dri)->dri_Pens;
969 LONG left, right;
971 SetDrMd(rp, JAM1);
972 SetAPen(rp, pens[SHINEPEN]);
974 if (window->BorderTop > 0)
976 /* Outer shine edge on top side */
978 CheckRectFill(rp, 0, 0, window->Width - 1, 0, IntuitionBase);
981 if (!(msg->wdp_Flags & WDF_DWB_TOP_ONLY))
983 if (window->BorderLeft > 0)
985 /* Outer shine edge on left side */
987 CheckRectFill(rp, 0, 0, 0, window->Height - 1, IntuitionBase);
990 if (window->BorderRight > 1)
992 /* Inner shine edge on right side */
994 CheckRectFill(rp,
995 window->Width - window->BorderRight, window->BorderTop,
996 window->Width - window->BorderRight, window->Height - window->BorderBottom,
997 IntuitionBase);
1000 if (window->BorderBottom > 1)
1002 /* Inner shine edge on bottom side */
1004 CheckRectFill(rp,
1005 window->BorderLeft, window->Height - window->BorderBottom,
1006 window->Width - window->BorderRight, window->Height - window->BorderBottom,
1007 IntuitionBase);
1011 SetAPen(rp, pens[SHADOWPEN]);
1013 if (!(msg->wdp_Flags & WDF_DWB_TOP_ONLY))
1015 if (window->BorderRight > 0)
1017 /* Outer shadow edge on right side */
1019 CheckRectFill(rp, window->Width - 1, 1,
1020 window->Width - 1, window->Height - 1, IntuitionBase);
1023 if (window->BorderBottom > 0)
1025 /* Outer shadow edge on bottom side */
1027 CheckRectFill(rp, 1, window->Height - 1,
1028 window->Width - 1, window->Height - 1, IntuitionBase);
1031 if (window->BorderLeft > 1)
1033 /* Inner shadow edge on left side */
1035 CheckRectFill(rp, window->BorderLeft - 1, window->BorderTop - 1,
1036 window->BorderLeft - 1, window->Height - window->BorderBottom,
1037 IntuitionBase);
1042 if (window->BorderTop > 1)
1044 /* Inner shadow edge on top side */
1046 CheckRectFill(rp, window->BorderLeft - 1, window->BorderTop - 1,
1047 window->Width - window->BorderRight, window->BorderTop - 1,
1048 IntuitionBase);
1051 SetAPen(rp, pens[(window->Flags & WFLG_WINDOWACTIVE) ? FILLPEN : BACKGROUNDPEN]);
1053 if (window->BorderTop > 2)
1055 /* Fill on top side */
1057 CheckRectFill(rp, 1, 1, window->Width - 2, window->BorderTop - 2, IntuitionBase);
1060 if (!(msg->wdp_Flags & WDF_DWB_TOP_ONLY))
1062 if (window->BorderLeft > 2)
1064 /* Fill on left side */
1066 CheckRectFill(rp, 1, 1, window->BorderLeft - 2, window->Height - 2, IntuitionBase);
1070 if (window->BorderRight > 2)
1072 /* Fill on right side */
1074 CheckRectFill(rp, window->Width - window->BorderRight + 1, 1,
1075 window->Width - 2, window->Height - 2, IntuitionBase);
1078 if (window->BorderBottom > 2)
1080 /* Fill on bottom side */
1082 CheckRectFill(rp, 1, window->Height - window->BorderBottom + 1,
1083 window->Width - 2, window->Height - 2, IntuitionBase);
1087 findtitlearea(window, &left, &right);
1089 if (left != 0)
1091 /* Left edge of title area */
1093 SetAPen(rp, pens[SHINEPEN]);
1094 Move(rp, left, 1);
1095 Draw(rp, left, window->BorderTop - 2);
1098 if (right != window->Width - 1)
1100 /* Right edges of title area */
1102 SetAPen(rp, pens[SHADOWPEN]);
1103 Move(rp, right, 1);
1104 Draw(rp, right, window->BorderTop - 2);
1107 if (window->Title) INTERNAL_WDM_DRAW_WINTITLE(cl, obj, msg);
1109 return TRUE;
1112 /**************************************************************************************************/
1114 IPTR WinDecorClass__WDM_LAYOUT_BORDERGADGETS(Class *cl, Object *obj, struct wdpLayoutBorderGadgets *msg)
1116 //struct windecor_data *data = INST_DATA(cl, obj);
1117 //struct Window *window = msg->wdp_Window;
1118 struct Gadget *gadget = msg->wdp_Gadgets;
1120 if (!(msg->wdp_Flags & WDF_LBG_SYSTEMGADGET)) return TRUE;
1122 while(gadget)
1124 switch(gadget->GadgetType & GTYP_SYSTYPEMASK)
1126 case GTYP_CLOSE:
1127 gadget->LeftEdge = 0;
1128 gadget->Width = gadget->Height;
1129 gadget->Flags &= ~(GFLG_RELRIGHT | GFLG_RELWIDTH);
1130 break;
1132 case GTYP_WDEPTH:
1133 gadget->LeftEdge = -gadget->Height + 1;
1134 gadget->Width = gadget->Height;
1135 gadget->Flags &= ~GFLG_RELWIDTH;
1136 gadget->Flags |= GFLG_RELRIGHT;
1137 break;
1139 case GTYP_WZOOM:
1140 gadget->LeftEdge = -gadget->Height * 2 + 1;
1141 gadget->Width = gadget->Height;
1142 gadget->Flags &= ~GFLG_RELWIDTH;
1143 gadget->Flags |= GFLG_RELRIGHT;
1144 break;
1146 case GTYP_WDRAGGING:
1147 gadget->LeftEdge = 0;
1148 gadget->Width = 0;
1149 gadget->Flags &= ~GFLG_RELRIGHT;
1150 gadget->Flags |= GFLG_RELWIDTH;
1151 break;
1154 if (msg->wdp_Flags & WDF_LBG_MULTIPLE)
1156 gadget = gadget->NextGadget;
1158 else
1160 gadget = NULL;
1164 return TRUE;
1167 /**************************************************************************************************/
1169 IPTR WinDecorClass__WDM_DRAW_BORDERPROPBACK(Class *cl, Object *obj, struct wdpDrawBorderPropBack *msg)
1171 struct Window *window = msg->wdp_Window;
1172 struct RastPort *rp = msg->wdp_RPort;
1173 struct Gadget *gadget = msg->wdp_Gadget;
1174 struct Rectangle *r = msg->wdp_RenderRect;
1175 struct PropInfo *pi = ((struct PropInfo *)gadget->SpecialInfo);
1176 UWORD *pens = DRI(msg->wdp_Dri)->dri_Pens;
1178 SetDrMd(rp, JAM2);
1180 if (pi->Flags & PROPNEWLOOK)
1182 static UWORD pattern[] = {0x5555,0xAAAA};
1184 SetAfPt(rp, pattern, 1);
1185 SetAPen(rp, pens[SHADOWPEN]);
1186 SetBPen(rp, pens[(window->Flags & WFLG_WINDOWACTIVE) ? FILLPEN : BACKGROUNDPEN]);
1187 RectFill(rp, r->MinX, r->MinY, r->MaxX, r->MaxY);
1188 SetAfPt(rp, NULL, 0);
1190 else
1192 SetAPen(rp, pens[BACKGROUNDPEN]);
1193 RectFill(rp, r->MinX, r->MinY, r->MaxX, r->MaxY);
1196 return TRUE;
1199 /**************************************************************************************************/
1201 IPTR WinDecorClass__WDM_DRAW_BORDERPROPKNOB(Class *cl, Object *obj, struct wdpDrawBorderPropKnob *msg)
1203 struct Window *window = msg->wdp_Window;
1204 struct RastPort *rp = msg->wdp_RPort;
1205 struct Gadget *gadget = msg->wdp_Gadget;
1206 struct Rectangle *r = msg->wdp_RenderRect;
1207 struct PropInfo *pi = ((struct PropInfo *)gadget->SpecialInfo);
1208 UWORD *pens = DRI(msg->wdp_Dri)->dri_Pens;
1210 SetDrMd(rp, JAM2);
1212 if (pi->Flags & PROPBORDERLESS)
1214 SetAPen(rp, pens[SHINEPEN]);
1216 /* Top edge */
1217 RectFill(rp, r->MinX, r->MinY, r->MaxX - 1, r->MinY);
1219 /* Left edge */
1220 RectFill(rp, r->MinX, r->MinY + 1, r->MinX, r->MaxY - 1);
1222 SetAPen(rp, pens[SHADOWPEN]);
1224 /* Right edge */
1225 RectFill(rp, r->MaxX, r->MinY, r->MaxX, r->MaxY);
1227 /* Bottom edge */
1228 RectFill(rp, r->MinX, r->MaxY, r->MaxX - 1, r->MaxY);
1230 r->MinX++;
1231 r->MinY++;
1232 r->MaxX--;
1233 r->MaxY--;
1235 } /* PROPBORDERLESS */
1236 else
1238 SetAPen(rp, pens[SHADOWPEN]);
1240 if (pi->Flags & FREEHORIZ)
1242 /* black line at the left and at the right */
1244 RectFill(rp, r->MinX, r->MinY, r->MinX, r->MaxY);
1245 RectFill(rp, r->MaxX, r->MinY, r->MaxX, r->MaxY);
1247 r->MinX++;
1248 r->MaxX--;
1252 if (pi->Flags & FREEVERT)
1254 /* black line at the top and at the bottom */
1256 RectFill(rp, r->MinX, r->MinY, r->MaxX, r->MinY);
1257 RectFill(rp, r->MinX, r->MaxY, r->MaxX, r->MaxY);
1259 r->MinY++,
1260 r->MaxY--;
1264 } /* not PROPBORDERLESS */
1267 SetAPen(rp, pens[(window->Flags & WFLG_WINDOWACTIVE) ? FILLPEN : BACKGROUNDPEN]);
1269 /* interior */
1270 RectFill(rp, r->MinX, r->MinY, r->MaxX, r->MaxY);
1272 return TRUE;
1276 /**************************************************************************************************/
1278 IPTR WinDecorClass__WDM_INITWINDOW(Class *cl, Object *obj, struct wdpInitWindow *msg)
1280 return TRUE;
1283 /**************************************************************************************************/
1285 IPTR WinDecorClass__WDM_EXITWINDOW(Class *cl, Object *obj, struct wdpExitWindow *msg)
1287 return TRUE;
1290 /**************************************************************************************************/
1292 IPTR WinDecorClass__WDM_WINDOWSHAPE(Class *cl, Object *obj, struct wdpWindowShape *msg)
1294 return 0;