Added missing properties and fixed a few typos.
[cake.git] / rom / intuition / windecorclass.c
blob3e32fb040969959893481a741cd82814714bdf05
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 windecor_data *data = INST_DATA(cl, obj);
360 struct RastPort *rp = msg->wdp_RPort;
361 UWORD *pens = DRI(msg->wdp_Dri)->dri_Pens;
362 LONG state = msg->wdp_State;
363 LONG left = msg->wdp_X;
364 LONG top = msg->wdp_Y;
365 LONG width = msg->wdp_Width;
366 LONG height = msg->wdp_Height;
367 LONG right = left + width - 1;
368 LONG bottom = top + height - 1;
369 LONG h_spacing, v_spacing;
371 SetDrMd(rp, JAM1);
373 switch(msg->wdp_Which)
376 case MUIIMAGE:
378 renderimageframe(rp, CLOSEIMAGE, state, pens, left, top, width, height, IntuitionBase);
379 /* no code yet */
380 break;
382 case POPUPIMAGE:
384 renderimageframe(rp, CLOSEIMAGE, state, pens, left, top, width, height, IntuitionBase);
385 /* code should be added later */
386 break;
388 case CLOSEIMAGE:
390 renderimageframe(rp, CLOSEIMAGE, state, pens, left, top, width, height, IntuitionBase);
391 left++;
392 top++;
393 width -= 2;
394 height -= 2;
396 right = left + width - 1;
397 bottom = top + height - 1;
398 h_spacing = width * 4 / 10;
399 v_spacing = height * 3 / 10;
401 SetAPen(rp, getbgpen(state, pens));
402 RectFill(rp, left, top, right, bottom);
404 left += h_spacing;
405 right -= h_spacing;
406 top += v_spacing;
407 bottom -= v_spacing;
409 SetAPen(rp, pens[SHADOWPEN]);
410 RectFill(rp, left, top, right, bottom);
412 left++;
413 top++;
414 right--;
415 bottom--;
417 SetAPen(rp, pens[(state == IDS_NORMAL) ? SHINEPEN : BACKGROUNDPEN]);
418 RectFill(rp, left, top, right, bottom);
420 break;
423 case ZOOMIMAGE:
425 UWORD bg;
426 WORD h_spacing;
427 WORD v_spacing;
429 renderimageframe(rp, ZOOMIMAGE, state, pens,
430 left, top, width, height, IntuitionBase);
431 left++;
432 top++;
433 width -= 2;
434 height -= 2;
436 right = left + width - 1;
437 bottom = top + height - 1 ;
438 h_spacing = width / 6;
439 v_spacing = height / 6;
441 bg = getbgpen(state, pens);
443 /* Clear background into correct color */
444 SetAPen(rp, bg);
445 RectFill(rp, left, top, right, bottom);
447 left += h_spacing;
448 right -= h_spacing;
449 top += v_spacing;
450 bottom -= v_spacing;
452 SetAPen(rp, pens[SHADOWPEN]);
453 RectFill(rp, left, top, right, bottom);
455 SetAPen(rp, pens[(state == IDS_SELECTED) ? SHINEPEN :
456 (state == IDS_NORMAL) ? FILLPEN : BACKGROUNDPEN]);
457 RectFill(rp, left + 1, top + 1, right - 1, bottom - 1);
459 right = left + (right - left + 1) / 2;
460 bottom = top + (bottom - top + 1) / 2;
462 if (right - left < 4) right = left + 4;
464 SetAPen(rp, pens[SHADOWPEN]);
465 RectFill(rp, left, top, right, bottom);
467 left += 2;
468 right -= 2;
469 top += 1;
470 bottom -= 1;
472 SetAPen(rp, pens[(state == IDS_SELECTED) ? FILLPEN :
473 (state == IDS_NORMAL) ? SHINEPEN : BACKGROUNDPEN]);
474 RectFill(rp,left, top, right, bottom);
475 break;
478 case DEPTHIMAGE:
480 UWORD bg;
481 WORD h_spacing;
482 WORD v_spacing;
484 renderimageframe(rp, DEPTHIMAGE, state, pens,
485 left, top, width, height, IntuitionBase);
486 left++;
487 top++;
488 right--;
489 bottom--;
490 width -= 2;
491 height -= 2;
493 h_spacing = width / 6;
494 v_spacing = height / 6;
496 bg = getbgpen(state, pens);
498 /* Clear background into correct color */
499 SetAPen(rp, bg);
500 RectFill(rp, left, top, right, bottom);
502 /* Draw a image of two partly overlapped tiny windows,
505 left += h_spacing;
506 top += v_spacing;
508 width -= h_spacing * 2;
509 height -= v_spacing * 2;
511 right = left + width - 1;
512 bottom = top + height - 1;
514 /* Render top left window */
516 SetAPen(rp, pens[SHADOWPEN]);
517 drawrect(rp
518 , left
519 , top
520 , right - (width / 3 )
521 , bottom - (height / 3)
522 , IntuitionBase);
525 /* Fill top left window (inside of the frame above) */
527 if ((state != IDS_INACTIVENORMAL))
529 SetAPen(rp, pens[BACKGROUNDPEN]);
530 RectFill(rp, left + 1, top + 1,
531 right - (width / 3) - 1, bottom - (height / 3) - 1);
535 /* Render bottom right window */
536 SetAPen(rp, pens[SHADOWPEN]);
537 drawrect(rp, left + (width / 3), top + (height / 3),
538 right, bottom, IntuitionBase);
540 /* Fill bottom right window (inside of the frame above) */
541 SetAPen(rp, pens[(state == IDS_INACTIVENORMAL) ? BACKGROUNDPEN : SHINEPEN]);
542 RectFill(rp, left + (width / 3) + 1, top + (height / 3) + 1,
543 right - 1, bottom - 1);
545 if (state == IDS_SELECTED)
547 /* Re-Render top left window */
549 SetAPen(rp, pens[SHADOWPEN]);
550 drawrect(rp, left, top,
551 right - (width / 3 ), bottom - (height / 3), IntuitionBase);
553 break;
556 case SIZEIMAGE:
558 UWORD bg;
559 WORD h_spacing;
560 WORD v_spacing;
561 WORD x, y;
563 renderimageframe(rp, SIZEIMAGE, state, pens,
564 left, top, width, height, IntuitionBase);
565 left++;
566 top++;
567 right--;
568 bottom--;
569 width -= 2;
570 height -= 2;
572 h_spacing = width / 5;
573 v_spacing = height / 5;
575 bg = getbgpen(state, pens);
577 /* Clear background into correct color */
578 SetAPen(rp, bg);
579 RectFill(rp, left, top, right, bottom);
581 /* A triangle image */
583 left += h_spacing;
584 top += v_spacing;
586 right = left + width - 1 - (h_spacing * 2);
587 bottom = top + height - 1 - (v_spacing * 2);
589 width = right - left + 1;
590 height = bottom - top + 1;
592 if (state != IDS_INACTIVENORMAL)
594 SetAPen(rp, pens[SHINEPEN]);
596 for(y = top; y <= bottom; y++)
598 x = left + (bottom - y) * width / height;
599 RectFill(rp, x, y, right, y);
603 SetAPen(rp, pens[SHADOWPEN]);
604 /* Draw triangle border */
605 Move(rp, left, bottom);
606 Draw(rp, right, top);
607 Draw(rp, right, bottom);
608 Draw(rp, left, bottom);
610 break;
613 case LEFTIMAGE:
615 UWORD hspacing,vspacing;
616 WORD cy, i;
618 hspacing = HSPACING;
619 vspacing = VSPACING;
621 if (width <= 12)
623 hspacing = HSPACING_MIDDLE;
626 if (width <= 10)
628 hspacing = HSPACING_SMALL;
631 if (height <= 12)
633 vspacing = VSPACING_MIDDLE;
636 if (height <= 10)
638 vspacing = VSPACING_SMALL;
641 renderimageframe(rp, LEFTIMAGE, state, pens,
642 left, top, width, height, IntuitionBase);
643 left++;
644 top++;
645 right--;
646 bottom--;
647 width -= 2;
648 height -= 2;
650 SetAPen(rp, getbgpen(state, pens));
651 RectFill(rp, left, top, right, bottom);
653 left += hspacing;
654 top += vspacing;
655 width -= hspacing * 2;
656 height -= vspacing * 2;
658 right = left + width - 1;
659 bottom = top + height - 1;
661 cy = (height + 1) / 2;
663 SetAPen(rp, pens[SHADOWPEN]);
665 for(i = 0; i < cy; i++)
667 RectFill(rp, left + (cy - i - 1) * width / cy,
668 top + i,
669 right - i * width / cy / 2,
670 top + i);
671 RectFill(rp, left + (cy - i - 1) * width / cy,
672 bottom - i,
673 right - i * width / cy / 2,
674 bottom - i);
676 break;
679 case UPIMAGE:
681 UWORD hspacing,vspacing;
682 WORD cx, i;
684 hspacing = HSPACING;
685 vspacing = VSPACING;
687 if (width <= 12)
689 hspacing = HSPACING_MIDDLE;
692 if (width <= 10)
694 hspacing = HSPACING_SMALL;
697 if (height <= 12)
699 vspacing = VSPACING_MIDDLE;
702 if (height <= 10)
704 vspacing = VSPACING_SMALL;
707 renderimageframe(rp, UPIMAGE, state, pens,
708 left, top, width, height, IntuitionBase);
709 left++;
710 top++;
711 right--;
712 bottom--;
713 width -= 2;
714 height -= 2;
716 SetAPen(rp, getbgpen(state, pens));
717 RectFill(rp, left, top, right, bottom);
719 left += hspacing;
720 top += vspacing;
721 width -= hspacing * 2;
722 height -= vspacing * 2;
724 right = left + width - 1;
725 bottom = top + height - 1;
727 cx = (width + 1) / 2;
729 SetAPen(rp, pens[SHADOWPEN]);
731 for(i = 0; i < cx; i++)
733 RectFill(rp, left + i,
734 top + (cx - i - 1) * height / cx,
735 left + i,
736 bottom - i * height / cx / 2);
737 RectFill(rp, right - i,
738 top + (cx - i - 1) * height / cx,
739 right - i,
740 bottom - i * height / cx / 2);
743 break;
746 case RIGHTIMAGE:
748 UWORD hspacing,vspacing;
749 WORD cy, i;
751 hspacing = HSPACING;
752 vspacing = VSPACING;
754 if (width <= 12)
756 hspacing = HSPACING_MIDDLE;
759 if (width <= 10)
761 hspacing = HSPACING_SMALL;
764 if (height <= 12)
766 vspacing = VSPACING_MIDDLE;
769 if (height <= 10)
771 vspacing = VSPACING_SMALL;
774 renderimageframe(rp, RIGHTIMAGE, state, pens,
775 left, top, width, height, IntuitionBase);
776 left++;
777 top++;
778 right--;
779 bottom--;
780 width -= 2;
781 height -= 2;
784 SetAPen(rp, getbgpen(state, pens));
785 RectFill(rp, left, top, right, bottom);
787 left += hspacing;
788 top += vspacing;
789 width -= hspacing * 2;
790 height -= vspacing * 2;
792 right = left + width - 1;
793 bottom = top + height - 1;
795 cy = (height + 1) / 2;
797 SetAPen(rp, pens[SHADOWPEN]);
799 for(i = 0; i < cy; i++)
801 RectFill(rp, left + i * width / cy / 2,
802 top + i,
803 right - (cy - i - 1) * width / cy,
804 top + i);
805 RectFill(rp, left + i * width / cy / 2,
806 bottom - i,
807 right - (cy - i - 1) * width / cy,
808 bottom - i);
810 break;
813 case DOWNIMAGE:
815 UWORD hspacing,vspacing;
816 WORD cx, i;
818 hspacing = HSPACING;
819 vspacing = VSPACING;
821 if (width <= 12)
823 hspacing = HSPACING_MIDDLE;
826 if (width <= 10)
828 hspacing = HSPACING_SMALL;
831 if (height <= 12)
833 vspacing = VSPACING_MIDDLE;
836 if (height <= 10)
838 vspacing = VSPACING_SMALL;
841 renderimageframe(rp, DOWNIMAGE, state, pens,
842 left, top, width, height, IntuitionBase);
843 left++;
844 top++;
845 right--;
846 bottom--;
847 width -= 2;
848 height -= 2;
850 SetAPen(rp, getbgpen(state, pens));
851 RectFill(rp, left, top, right, bottom);
853 left += hspacing;
854 top += vspacing;
855 width -= hspacing * 2;
856 height -= vspacing * 2;
858 right = left + width - 1;
859 bottom = top + height - 1;
861 cx = (width + 1) / 2;
863 SetAPen(rp, pens[SHADOWPEN]);
865 for(i = 0; i < cx; i++)
867 RectFill(rp, left + i,
868 top + i * height / cx / 2,
869 left + i,
870 bottom - (cx - i - 1) * height / cx);
871 RectFill(rp, right - i,
872 top + i * height / cx / 2,
873 right - i,
874 bottom - (cx - i - 1) * height / cx);
877 break;
881 default:
882 return FALSE;
885 return TRUE;
888 /**************************************************************************************************/
890 static void findtitlearea(struct Window *win, LONG *left, LONG *right)
892 struct Gadget *g;
894 *left = 0;
895 *right = win->Width - 1;
897 for (g = win->FirstGadget; g; g = g->NextGadget)
899 if (g->Activation & GACT_TOPBORDER && g != (struct Gadget *)IW(win)->sysgads[DRAGBAR])
901 if (!(g->Flags & GFLG_RELRIGHT))
903 if (g->LeftEdge + g->Width > *left)
904 *left = g->LeftEdge + g->Width;
906 else
908 if (g->LeftEdge + win->Width - 1 - 1 < *right)
909 *right = g->LeftEdge + win->Width - 1 - 1;
916 /**************************************************************************************************/
918 IPTR INTERNAL_WDM_DRAW_WINTITLE(Class *cl, Object *obj, struct wdpDrawWinBorder *msg)
920 struct windecor_data *data = INST_DATA(cl, obj);
921 struct RastPort *rp = msg->wdp_RPort;
922 struct Window *window = msg->wdp_Window;
923 UWORD *pens = DRI(msg->wdp_Dri)->dri_Pens;
924 LONG right, left;
926 findtitlearea(window, &left, &right);
928 SetDrMd(rp, JAM1);
929 SetAPen(rp, pens[(window->Flags & WFLG_WINDOWACTIVE) ? FILLPEN : BACKGROUNDPEN]);
930 CheckRectFill(rp, left + 1, 1, right - 1, window->BorderTop - 2, IntuitionBase);
932 if (right - left > 6)
934 ULONG textlen, titlelen, textpixellen;
935 struct TextExtent te;
937 SetFont(rp, DRI(msg->wdp_Dri)->dri_Font);
939 titlelen = strlen(window->Title);
940 textlen = TextFit(rp
941 , window->Title
942 , titlelen
943 , &te
944 , NULL
946 , right - left - 6
947 , window->BorderTop - 2);
948 if (textlen)
950 textpixellen = te.te_Extent.MaxX - te.te_Extent.MinX + 1;
952 left = left + 3;
954 SetAPen(rp, pens[(window->Flags & WFLG_WINDOWACTIVE) ? FILLTEXTPEN : TEXTPEN]);
956 Move(rp, left, DRI(msg->wdp_Dri)->dri_Font->tf_Baseline + 2);
957 Text(rp, window->Title, textlen);
961 return TRUE;
964 /**************************************************************************************************/
966 IPTR WinDecorClass__WDM_DRAW_WINBORDER(Class *cl, Object *obj, struct wdpDrawWinBorder *msg)
968 struct windecor_data *data = INST_DATA(cl, obj);
969 struct RastPort *rp = msg->wdp_RPort;
970 struct Window *window = msg->wdp_Window;
971 UWORD *pens = DRI(msg->wdp_Dri)->dri_Pens;
972 LONG left, right;
974 SetDrMd(rp, JAM1);
975 SetAPen(rp, pens[SHINEPEN]);
977 if (window->BorderTop > 0)
979 /* Outer shine edge on top side */
981 CheckRectFill(rp, 0, 0, window->Width - 1, 0, IntuitionBase);
984 if (!(msg->wdp_Flags & WDF_DWB_TOP_ONLY))
986 if (window->BorderLeft > 0)
988 /* Outer shine edge on left side */
990 CheckRectFill(rp, 0, 0, 0, window->Height - 1, IntuitionBase);
993 if (window->BorderRight > 1)
995 /* Inner shine edge on right side */
997 CheckRectFill(rp,
998 window->Width - window->BorderRight, window->BorderTop,
999 window->Width - window->BorderRight, window->Height - window->BorderBottom,
1000 IntuitionBase);
1003 if (window->BorderBottom > 1)
1005 /* Inner shine edge on bottom side */
1007 CheckRectFill(rp,
1008 window->BorderLeft, window->Height - window->BorderBottom,
1009 window->Width - window->BorderRight, window->Height - window->BorderBottom,
1010 IntuitionBase);
1014 SetAPen(rp, pens[SHADOWPEN]);
1016 if (!(msg->wdp_Flags & WDF_DWB_TOP_ONLY))
1018 if (window->BorderRight > 0)
1020 /* Outer shadow edge on right side */
1022 CheckRectFill(rp, window->Width - 1, 1,
1023 window->Width - 1, window->Height - 1, IntuitionBase);
1026 if (window->BorderBottom > 0)
1028 /* Outer shadow edge on bottom side */
1030 CheckRectFill(rp, 1, window->Height - 1,
1031 window->Width - 1, window->Height - 1, IntuitionBase);
1034 if (window->BorderLeft > 1)
1036 /* Inner shadow edge on left side */
1038 CheckRectFill(rp, window->BorderLeft - 1, window->BorderTop - 1,
1039 window->BorderLeft - 1, window->Height - window->BorderBottom,
1040 IntuitionBase);
1045 if (window->BorderTop > 1)
1047 /* Inner shadow edge on top side */
1049 CheckRectFill(rp, window->BorderLeft - 1, window->BorderTop - 1,
1050 window->Width - window->BorderRight, window->BorderTop - 1,
1051 IntuitionBase);
1054 SetAPen(rp, pens[(window->Flags & WFLG_WINDOWACTIVE) ? FILLPEN : BACKGROUNDPEN]);
1056 if (window->BorderTop > 2)
1058 /* Fill on top side */
1060 CheckRectFill(rp, 1, 1, window->Width - 2, window->BorderTop - 2, IntuitionBase);
1063 if (!(msg->wdp_Flags & WDF_DWB_TOP_ONLY))
1065 if (window->BorderLeft > 2)
1067 /* Fill on left side */
1069 CheckRectFill(rp, 1, 1, window->BorderLeft - 2, window->Height - 2, IntuitionBase);
1073 if (window->BorderRight > 2)
1075 /* Fill on right side */
1077 CheckRectFill(rp, window->Width - window->BorderRight + 1, 1,
1078 window->Width - 2, window->Height - 2, IntuitionBase);
1081 if (window->BorderBottom > 2)
1083 /* Fill on bottom side */
1085 CheckRectFill(rp, 1, window->Height - window->BorderBottom + 1,
1086 window->Width - 2, window->Height - 2, IntuitionBase);
1090 findtitlearea(window, &left, &right);
1092 if (left != 0)
1094 /* Left edge of title area */
1096 SetAPen(rp, pens[SHINEPEN]);
1097 Move(rp, left, 1);
1098 Draw(rp, left, window->BorderTop - 2);
1101 if (right != window->Width - 1)
1103 /* Right edges of title area */
1105 SetAPen(rp, pens[SHADOWPEN]);
1106 Move(rp, right, 1);
1107 Draw(rp, right, window->BorderTop - 2);
1110 if (window->Title) INTERNAL_WDM_DRAW_WINTITLE(cl, obj, msg);
1112 return TRUE;
1115 /**************************************************************************************************/
1117 IPTR WinDecorClass__WDM_LAYOUT_BORDERGADGETS(Class *cl, Object *obj, struct wdpLayoutBorderGadgets *msg)
1119 //struct windecor_data *data = INST_DATA(cl, obj);
1120 //struct Window *window = msg->wdp_Window;
1121 struct Gadget *gadget = msg->wdp_Gadgets;
1123 if (!(msg->wdp_Flags & WDF_LBG_SYSTEMGADGET)) return TRUE;
1125 while(gadget)
1127 switch(gadget->GadgetType & GTYP_SYSTYPEMASK)
1129 case GTYP_CLOSE:
1130 gadget->LeftEdge = 0;
1131 gadget->Width = gadget->Height;
1132 gadget->Flags &= ~(GFLG_RELRIGHT | GFLG_RELWIDTH);
1133 break;
1135 case GTYP_WDEPTH:
1136 gadget->LeftEdge = -gadget->Height + 1;
1137 gadget->Width = gadget->Height;
1138 gadget->Flags &= ~GFLG_RELWIDTH;
1139 gadget->Flags |= GFLG_RELRIGHT;
1140 break;
1142 case GTYP_WZOOM:
1143 gadget->LeftEdge = -gadget->Height * 2 + 1;
1144 gadget->Width = gadget->Height;
1145 gadget->Flags &= ~GFLG_RELWIDTH;
1146 gadget->Flags |= GFLG_RELRIGHT;
1147 break;
1149 case GTYP_WDRAGGING:
1150 gadget->LeftEdge = 0;
1151 gadget->Width = 0;
1152 gadget->Flags &= ~GFLG_RELRIGHT;
1153 gadget->Flags |= GFLG_RELWIDTH;
1154 break;
1157 if (msg->wdp_Flags & WDF_LBG_MULTIPLE)
1159 gadget = gadget->NextGadget;
1161 else
1163 gadget = NULL;
1167 return TRUE;
1170 /**************************************************************************************************/
1172 IPTR WinDecorClass__WDM_DRAW_BORDERPROPBACK(Class *cl, Object *obj, struct wdpDrawBorderPropBack *msg)
1174 struct windecor_data *data = INST_DATA(cl, obj);
1175 struct Window *window = msg->wdp_Window;
1176 struct RastPort *rp = msg->wdp_RPort;
1177 struct Gadget *gadget = msg->wdp_Gadget;
1178 struct Rectangle *r = msg->wdp_RenderRect;
1179 struct PropInfo *pi = ((struct PropInfo *)gadget->SpecialInfo);
1180 UWORD *pens = DRI(msg->wdp_Dri)->dri_Pens;
1182 SetDrMd(rp, JAM2);
1184 if (pi->Flags & PROPNEWLOOK)
1186 static UWORD pattern[] = {0x5555,0xAAAA};
1188 SetAfPt(rp, pattern, 1);
1189 SetAPen(rp, pens[SHADOWPEN]);
1190 SetBPen(rp, pens[(window->Flags & WFLG_WINDOWACTIVE) ? FILLPEN : BACKGROUNDPEN]);
1191 RectFill(rp, r->MinX, r->MinY, r->MaxX, r->MaxY);
1192 SetAfPt(rp, NULL, 0);
1194 else
1196 SetAPen(rp, pens[BACKGROUNDPEN]);
1197 RectFill(rp, r->MinX, r->MinY, r->MaxX, r->MaxY);
1200 return TRUE;
1203 /**************************************************************************************************/
1205 IPTR WinDecorClass__WDM_DRAW_BORDERPROPKNOB(Class *cl, Object *obj, struct wdpDrawBorderPropKnob *msg)
1207 struct windecor_data *data = INST_DATA(cl, obj);
1208 struct Window *window = msg->wdp_Window;
1209 struct RastPort *rp = msg->wdp_RPort;
1210 struct Gadget *gadget = msg->wdp_Gadget;
1211 struct Rectangle *r = msg->wdp_RenderRect;
1212 struct PropInfo *pi = ((struct PropInfo *)gadget->SpecialInfo);
1213 UWORD *pens = DRI(msg->wdp_Dri)->dri_Pens;
1215 SetDrMd(rp, JAM2);
1217 if (pi->Flags & PROPBORDERLESS)
1219 SetAPen(rp, pens[SHINEPEN]);
1221 /* Top edge */
1222 RectFill(rp, r->MinX, r->MinY, r->MaxX - 1, r->MinY);
1224 /* Left edge */
1225 RectFill(rp, r->MinX, r->MinY + 1, r->MinX, r->MaxY - 1);
1227 SetAPen(rp, pens[SHADOWPEN]);
1229 /* Right edge */
1230 RectFill(rp, r->MaxX, r->MinY, r->MaxX, r->MaxY);
1232 /* Bottom edge */
1233 RectFill(rp, r->MinX, r->MaxY, r->MaxX - 1, r->MaxY);
1235 r->MinX++;
1236 r->MinY++;
1237 r->MaxX--;
1238 r->MaxY--;
1240 } /* PROPBORDERLESS */
1241 else
1243 SetAPen(rp, pens[SHADOWPEN]);
1245 if (pi->Flags & FREEHORIZ)
1247 /* black line at the left and at the right */
1249 RectFill(rp, r->MinX, r->MinY, r->MinX, r->MaxY);
1250 RectFill(rp, r->MaxX, r->MinY, r->MaxX, r->MaxY);
1252 r->MinX++;
1253 r->MaxX--;
1257 if (pi->Flags & FREEVERT)
1259 /* black line at the top and at the bottom */
1261 RectFill(rp, r->MinX, r->MinY, r->MaxX, r->MinY);
1262 RectFill(rp, r->MinX, r->MaxY, r->MaxX, r->MaxY);
1264 r->MinY++,
1265 r->MaxY--;
1269 } /* not PROPBORDERLESS */
1272 SetAPen(rp, pens[(window->Flags & WFLG_WINDOWACTIVE) ? FILLPEN : BACKGROUNDPEN]);
1274 /* interior */
1275 RectFill(rp, r->MinX, r->MinY, r->MaxX, r->MaxY);
1277 return TRUE;
1281 /**************************************************************************************************/
1283 IPTR WinDecorClass__WDM_INITWINDOW(Class *cl, Object *obj, struct wdpInitWindow *msg)
1285 return TRUE;
1288 /**************************************************************************************************/
1290 IPTR WinDecorClass__WDM_EXITWINDOW(Class *cl, Object *obj, struct wdpExitWindow *msg)
1292 return TRUE;
1295 /**************************************************************************************************/
1297 IPTR WinDecorClass__WDM_WINDOWSHAPE(Class *cl, Object *obj, struct wdpWindowShape *msg)
1299 return NULL;