New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / intuition / sysiclass_aros.c
blob1fadb5dba97a5416f6658b802f3f85bf7d874633
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 /**************************************************************************************************/
9 #include <exec/types.h>
11 #include <proto/intuition.h>
12 #include <proto/layers.h>
13 #include <intuition/classes.h>
14 #include <intuition/classusr.h>
15 #include <intuition/imageclass.h>
16 #include <intuition/windecorclass.h>
17 #include <intuition/scrdecorclass.h>
18 #include <intuition/intuition.h>
19 #include <intuition/intuitionbase.h>
20 #include <intuition/extensions.h>
21 #include <intuition/screens.h>
23 #include <proto/graphics.h>
24 #include <graphics/rastport.h>
26 #include <proto/utility.h>
27 #include <utility/tagitem.h>
29 #include <proto/alib.h>
31 #include <aros/asmcall.h>
32 #include "intuition_intern.h"
33 #ifdef __MORPHOS__
34 #include "intuition_extend.h"
35 #endif
37 #include "gadgets.h" /* Some handy rendering funtions */
39 #define INTDRI(dri) ((struct IntDrawInfo *)(dri))
41 #if 0
42 extern BYTE *ibPrefs;
43 extern BYTE *ibSnapshot;
44 extern BYTE *ibSnapshotSel;
45 extern BYTE *ibPopupSel;
46 extern BYTE *ibPopup;
47 extern BYTE *ibIconify;
48 extern BYTE *ibIconifySel;
49 extern BYTE *ibLock;
50 extern BYTE *ibLockSel;
51 extern VOID DrawIB(struct RastPort *rp,BYTE *ib,LONG cx,LONG cy,struct IntuitionBase *IntuitionBase);
52 extern void DrawJUMP(struct RastPort *rp,ULONG state,LONG cx,LONG cy,struct IntuitionBase *IntuitionBase);
53 #endif
55 #undef DEBUG
56 #define DEBUG 0
57 #include <aros/debug.h>
59 /**************************************************************************************************/
61 #define DEFSIZE_WIDTH 14
62 #define DEFSIZE_HEIGHT 14
64 /**************************************************************************************************/
66 /* Some handy transparent base class object casting defines.
68 #define IM(o) ((struct Image *)o)
70 static UWORD getbgpen(ULONG state, UWORD *pens);
71 static UWORD getbgpen_gt(ULONG state, UWORD *pens);
72 static void renderimageframe(struct RastPort *rp, ULONG which, ULONG state, UWORD *pens,
73 WORD left, WORD top, WORD width, WORD height,
74 struct IntuitionBase *IntuitionBase);
76 #undef IntuitionBase
77 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
80 /**************************************************************************************************/
82 #define SYSIFLG_GADTOOLS 1
83 #define SYSIFLG_NOBORDER 2
85 /**************************************************************************************************/
87 /* Some handy drawing functions */
89 void draw_thick_line(Class *cl, struct RastPort *rport,
90 LONG x1, LONG y1, LONG x2, LONG y2,
91 UWORD thickness)
93 Move(rport, x1, y1);
94 Draw(rport, x2, y2);
95 /* Georg Steger */
96 Move(rport, x1 + 1, y1);
97 Draw(rport, x2 + 1, y2);
100 /**************************************************************************************************/
102 BOOL sysi_setnew(Class *cl, Object *obj, struct opSet *msg)
104 struct SysIData *data = INST_DATA(cl, obj);
105 struct TagItem *taglist, *tag;
106 struct TextFont *reffont = NULL;
107 int size = SYSISIZE_MEDRES;
108 BOOL unsupported = FALSE;
109 BOOL set_width = FALSE, set_height = FALSE;
111 taglist = msg->ops_AttrList;
112 while ((tag = NextTagItem((const struct TagItem **)&taglist)))
114 switch(tag->ti_Tag)
116 case IA_Width:
117 set_width = TRUE;
118 break;
120 case IA_Height:
121 set_height = TRUE;
122 break;
124 case SYSIA_DrawInfo:
125 data->dri = (struct DrawInfo *)tag->ti_Data;
126 reffont = data->dri->dri_Font;
127 break;
129 case SYSIA_Which:
130 data->type = tag->ti_Data;
132 D(bug("SYSIA_Which type: %d\n", data->type));
134 switch (tag->ti_Data)
136 #warning "if IA_Width, IA_Height was not specified sysiclass should choose size depending on drawinfo (screen resolution)"
138 case LEFTIMAGE:
139 case UPIMAGE:
140 case RIGHTIMAGE:
141 case DOWNIMAGE:
142 case CHECKIMAGE:
143 case MXIMAGE:
144 case DEPTHIMAGE:
145 case SDEPTHIMAGE:
146 case ZOOMIMAGE:
147 case CLOSEIMAGE:
148 case SIZEIMAGE:
149 case MENUCHECK:
150 case AMIGAKEY:
151 case ICONIFYIMAGE:
152 case LOCKIMAGE:
153 case JUMPIMAGE:
154 case MUIIMAGE:
155 case POPUPIMAGE:
156 case SNAPSHOTIMAGE:
157 break;
159 default:
160 unsupported = TRUE;
161 break;
163 break;
165 case SYSIA_ReferenceFont:
166 if (tag->ti_Data) reffont = (struct TextFont *)tag->ti_Data;
167 break;
169 case SYSIA_Size:
170 size = tag->ti_Data;
171 break;
173 /* private tags */
175 case SYSIA_WithBorder:
176 if (tag->ti_Data == FALSE)
178 data->flags |= SYSIFLG_NOBORDER;
180 break;
182 case SYSIA_Style:
183 if (tag->ti_Data == SYSISTYLE_GADTOOLS)
185 data->flags |= SYSIFLG_GADTOOLS;
187 break;
189 } /* switch(tag->ti_Tag) */
191 } /* while ((tag = NextTagItem(&taglist))) */
193 D(bug("dri: %p, unsupported: %d\n", data->dri, unsupported));
195 if ((!data->dri) || (unsupported))
196 return FALSE;
199 struct wdpGetDefSizeSysImage msg;
200 ULONG width = DEFSIZE_WIDTH, height = DEFSIZE_HEIGHT;
202 msg.MethodID = (data->type == SDEPTHIMAGE) ? SDM_GETDEFSIZE_SYSIMAGE :
203 WDM_GETDEFSIZE_SYSIMAGE;
204 msg.wdp_Which = data->type;
205 msg.wdp_SysiSize = size;
206 msg.wdp_ReferenceFont = reffont;
207 msg.wdp_Width = &width;
208 msg.wdp_Height = &height;
209 msg.wdp_Flags = 0;
211 if (data->type == SDEPTHIMAGE)
213 LOCKSHARED_SCRDECOR(data->dri);
214 DoMethodA(INTDRI(data->dri)->dri_ScrDecorObj, (Msg)&msg);
215 UNLOCK_SCRDECOR(data->dri);
217 else
219 LOCKSHARED_WINDECOR(data->dri);
220 DoMethodA(INTDRI(data->dri)->dri_WinDecorObj, (Msg)&msg);
221 UNLOCK_WINDECOR(data->dri);
224 if (!set_width) IM(obj)->Width = width;
225 if (!set_height) IM(obj)->Height = height;
228 return TRUE;
231 /**************************************************************************************************/
233 Object *SysIClass__OM_NEW(Class *cl, Class *rootcl, struct opSet *msg)
235 struct SysIData *data;
236 Object *obj;
238 D(bug("sysi_new()\n"));
239 obj = (Object *)DoSuperMethodA(cl, (Object *)rootcl, (Msg)msg);
240 if (!obj)
241 return NULL;
243 D(bug("sysi_new,: obj=%p\n", obj));
245 data = INST_DATA(cl, obj);
246 data->type = 0L;
247 data->dri = NULL;
248 data->frame = NULL;
249 data->flags = 0;
251 if (!sysi_setnew(cl, obj, (struct opSet *)msg))
253 STACKULONG method = OM_DISPOSE;
254 CoerceMethodA(cl, obj, (Msg)&method);
255 return NULL;
258 D(bug("sysi_setnew called successfully\n"));
260 switch (data->type)
262 case CHECKIMAGE:
264 struct TagItem tags[] =
266 {IA_FrameType, FRAME_BUTTON },
267 {IA_EdgesOnly, FALSE },
268 {TAG_MORE }
271 tags[2].ti_Data = (IPTR)msg->ops_AttrList;
273 data->frame = NewObjectA(NULL, FRAMEICLASS, tags);
274 if (!data->frame)
276 STACKULONG method = OM_DISPOSE;
277 CoerceMethodA(cl, obj, (Msg)&method);
278 return NULL;
280 break;
283 /* Just to prevent it from reaching default: */
284 case MXIMAGE:
285 case LEFTIMAGE:
286 case UPIMAGE:
287 case RIGHTIMAGE:
288 case DOWNIMAGE:
290 case SDEPTHIMAGE:
291 case DEPTHIMAGE:
292 case ZOOMIMAGE:
293 case CLOSEIMAGE:
294 case SIZEIMAGE:
296 case MENUCHECK:
297 case AMIGAKEY:
299 case ICONIFYIMAGE:
300 case LOCKIMAGE:
301 case MUIIMAGE:
302 case POPUPIMAGE:
303 case SNAPSHOTIMAGE:
304 case JUMPIMAGE:
305 break;
307 default:
309 STACKULONG method = OM_DISPOSE;
311 CoerceMethodA(cl, obj, (Msg)&method);
313 return NULL;
316 return obj;
319 /**************************************************************************************************/
321 /* Georg Steger
323 #define HSPACING 3
324 #define VSPACING 3
325 /* Ralph Schmidt
326 * heuristics for smaller arrows used in apps
327 * like filer
329 #define HSPACING_MIDDLE 2
330 #define VSPACING_MIDDLE 2
331 #define HSPACING_SMALL 1
332 #define VSPACING_SMALL 1
334 IPTR SysIClass__IM_DRAW(Class *cl, Object *obj, struct impDraw *msg)
336 struct SysIData *data = INST_DATA(cl, obj);
337 struct RastPort *rport = msg->imp_RPort;
338 WORD left = IM(obj)->LeftEdge + msg->imp_Offset.X;
339 WORD top = IM(obj)->TopEdge + msg->imp_Offset.Y;
340 UWORD width = IM(obj)->Width;
341 UWORD height = IM(obj)->Height;
342 WORD right = left + width - 1;
343 WORD bottom = top + height - 1;
344 struct wdpDrawSysImage decormsg;
346 decormsg.MethodID = WDM_DRAW_SYSIMAGE;
347 decormsg.wdp_RPort = rport;
348 decormsg.wdp_X = left;
349 decormsg.wdp_Y = top;
350 decormsg.wdp_Width = width;
351 decormsg.wdp_Height = height;
352 decormsg.wdp_Which = data->type;
353 decormsg.wdp_State = msg->imp_State;
354 decormsg.wdp_Flags = 0;
356 SetDrMd(rport, JAM1);
358 switch(data->type)
360 case CHECKIMAGE:
362 WORD h_spacing = width / 4;
363 WORD v_spacing = height / 4;
365 /* Draw frame */
366 DrawImageState(rport, data->frame,
367 msg->imp_Offset.X, msg->imp_Offset.Y,
368 IDS_NORMAL, data->dri);
370 /* Draw checkmark (only if image is in selected state) */
371 if (msg->imp_State == IDS_SELECTED)
373 left += h_spacing;
374 right -= h_spacing;
375 width -= h_spacing * 2;
376 top += v_spacing;
377 bottom -= v_spacing;
378 height -= v_spacing * 2;
380 SetAPen(rport, data->dri->dri_Pens[SHADOWPEN]);
381 draw_thick_line(cl, rport, left, top + height / 3 , left, bottom, 0);
382 draw_thick_line(cl, rport, left + 1, bottom, right - 1, top, 0);
384 break;
387 case MXIMAGE:
389 BOOL selected = FALSE;
390 WORD col1 = SHINEPEN;
391 WORD col2 = SHADOWPEN;
393 if ((msg->imp_State == IDS_SELECTED) || (msg->imp_State == IDS_INACTIVESELECTED))
395 col1 = SHADOWPEN;
396 col2 = SHINEPEN;
397 selected = TRUE;
400 SetAPen(rport, data->dri->dri_Pens[BACKGROUNDPEN]);
401 RectFill(rport, left, top, right, bottom);
403 #if 0
404 /* THICK MX IMAGE */
406 SetAPen(rport, data->dri->dri_Pens[col1]);
407 RectFill(rport, left + 2, top, right - 3, top + 1);
408 RectFill(rport, left + 1, top + 2, left + 2, top + 3);
409 RectFill(rport, left, top + 4, left + 1, bottom - 4);
410 RectFill(rport, left + 1, bottom - 3, left + 2, bottom - 2);
411 RectFill(rport, left + 2, bottom - 1, left + 2, bottom);
413 SetAPen(rport, data->dri->dri_Pens[col2]);
414 RectFill(rport, right - 2, top, right - 2, top + 1);
415 RectFill(rport, right - 2, top + 2, right - 1, top + 3);
416 RectFill(rport, right - 1, top + 4, right, bottom - 4);
417 RectFill(rport, right - 2, bottom - 3, right - 1, bottom - 2);
418 RectFill(rport, left + 3, bottom - 1, right - 2, bottom);
420 if (selected)
422 left += 4;
423 right -= 4;
424 width -= 8;
425 top += 4;
426 bottom -= 4;
427 height -= 8;
429 SetAPen(rport, data->dri->dri_Pens[FILLPEN]);
430 if ((width >= 3) && (height >= 3))
432 RectFill(rport, left + 1, top, right - 1, top);
433 RectFill(rport, left, top + 1, right, bottom - 1);
434 RectFill(rport, left + 1, bottom, right - 1, bottom);
436 else
438 RectFill(rport, left, top, right, bottom);
441 #else
442 /* THIN MX IMAGE */
444 SetAPen(rport, data->dri->dri_Pens[col1]);
445 RectFill(rport, left + 3, top, right - 3, top);
446 WritePixel(rport, left + 2, top + 1);
447 RectFill(rport, left + 1, top + 2, left + 1, top + 3);
448 RectFill(rport, left, top + 4, left, bottom - 4);
449 RectFill(rport, left + 1, bottom - 3, left + 1, bottom - 2);
450 WritePixel(rport, left + 2, bottom - 1);
452 SetAPen(rport, data->dri->dri_Pens[col2]);
453 WritePixel(rport, right - 2, top + 1);
454 RectFill(rport, right - 1, top + 2, right - 1, top + 3);
455 RectFill(rport, right, top + 4, right, bottom - 4);
456 RectFill(rport, right - 1, bottom - 3, right - 1, bottom - 2);
457 WritePixel(rport, right - 2, bottom - 1);
458 RectFill(rport, left + 3, bottom, right - 3, bottom);
460 if (selected)
462 left += 3;
463 right -= 3;
464 width -= 6;
465 top += 3;
466 bottom -= 3;
467 height -= 6;
469 SetAPen(rport, data->dri->dri_Pens[FILLPEN]);
470 if ((width >= 5) && (height >= 5))
472 RectFill(rport, left, top + 2, left, bottom - 2);
473 RectFill(rport, left + 1, top + 1, left + 1, bottom - 1);
474 RectFill(rport, left + 2, top, right - 2, bottom);
475 RectFill(rport, right - 1, top + 1, right - 1, bottom - 1);
476 RectFill(rport, right, top + 2, right, bottom - 2);
478 else
480 RectFill(rport, left, top, right, bottom);
484 #endif
485 break;
488 case LEFTIMAGE:
490 UWORD hspacing,vspacing;
491 WORD cy;
493 if (!(data->flags & (SYSIFLG_NOBORDER | SYSIFLG_GADTOOLS)))
495 LOCKSHARED_WINDECOR(data->dri)
496 DoMethodA(INTDRI(data->dri)->dri_WinDecorObj, (Msg)&decormsg);
497 UNLOCK_WINDECOR(data->dri)
498 break;
501 hspacing = HSPACING;
502 vspacing = VSPACING;
504 if (width <= 12)
506 hspacing = HSPACING_MIDDLE;
509 if (width <= 10)
511 hspacing = HSPACING_SMALL;
514 if (height <= 12)
516 vspacing = VSPACING_MIDDLE;
519 if (height <= 10)
521 vspacing = VSPACING_SMALL;
524 if (!(data->flags & SYSIFLG_NOBORDER))
526 renderimageframe(rport, LEFTIMAGE, msg->imp_State, data->dri->dri_Pens,
527 left, top, width, height, IntuitionBase);
528 left++;
529 top++;
530 right--;
531 bottom--;
532 width -= 2;
533 height -= 2;
535 if (data->flags & SYSIFLG_GADTOOLS)
537 SetAPen(rport, getbgpen_gt(msg->imp_State, data->dri->dri_Pens));
538 RectFill(rport, left, top, right, bottom);
542 if (data->flags & SYSIFLG_GADTOOLS)
544 SetAPen(rport, data->dri->dri_Pens[SHADOWPEN]);
546 cy = height / 2;
548 Move(rport, left + width - 1 - hspacing, top + vspacing + 1);
549 Draw(rport, left + hspacing, top + height - cy);
550 Move(rport, left + width - 1 - hspacing, top + vspacing);
551 Draw(rport, left + hspacing, top + height - cy - 1);
553 Move(rport, left + width - 1 - hspacing, top + height - 1- vspacing - 1);
554 Draw(rport, left + hspacing, top + cy - 1);
555 Move(rport, left + width - 1 - hspacing, top + height - 1 - vspacing);
556 Draw(rport, left + hspacing, top + cy);
558 else
560 WORD i;
562 SetAPen(rport, getbgpen(msg->imp_State, data->dri->dri_Pens));
564 RectFill(rport, left, top, right, bottom);
566 left += hspacing;
567 top += vspacing;
568 width -= hspacing * 2;
569 height -= vspacing * 2;
571 right = left + width - 1;
572 bottom = top + height - 1;
574 cy = (height + 1) / 2;
576 SetAPen(rport, data->dri->dri_Pens[SHADOWPEN]);
578 for(i = 0; i < cy; i++)
580 RectFill(rport, left + (cy - i - 1) * width / cy,
581 top + i,
582 right - i * width / cy / 2,
583 top + i);
584 RectFill(rport, left + (cy - i - 1) * width / cy,
585 bottom - i,
586 right - i * width / cy / 2,
587 bottom - i);
591 break;
594 case UPIMAGE:
596 UWORD hspacing,vspacing;
597 WORD cx;
599 if (!(data->flags & (SYSIFLG_NOBORDER | SYSIFLG_GADTOOLS)))
601 LOCKSHARED_WINDECOR(data->dri)
602 DoMethodA(INTDRI(data->dri)->dri_WinDecorObj, (Msg)&decormsg);
603 UNLOCK_WINDECOR(data->dri)
604 break;
607 hspacing = HSPACING;
608 vspacing = VSPACING;
610 if (width <= 12)
612 hspacing = HSPACING_MIDDLE;
615 if (width <= 10)
617 hspacing = HSPACING_SMALL;
620 if (height <= 12)
622 vspacing = VSPACING_MIDDLE;
625 if (height <= 10)
627 vspacing = VSPACING_SMALL;
630 if (!(data->flags & SYSIFLG_NOBORDER))
632 renderimageframe(rport, UPIMAGE, msg->imp_State, data->dri->dri_Pens,
633 left, top, width, height, IntuitionBase);
634 left++;
635 top++;
636 right--;
637 bottom--;
638 width -= 2;
639 height -= 2;
641 if (data->flags & SYSIFLG_GADTOOLS)
643 SetAPen(rport, getbgpen_gt(msg->imp_State, data->dri->dri_Pens));
644 RectFill(rport, left, top, right, bottom);
649 if (data->flags & SYSIFLG_GADTOOLS)
651 SetAPen(rport, data->dri->dri_Pens[SHADOWPEN]);
653 cx = width / 2;
655 Move(rport, left + hspacing + 1, top + height - 1 - vspacing);
656 Draw(rport, left + width - cx, top + vspacing);
657 Move(rport, left + hspacing, top + height - 1 - vspacing);
658 Draw(rport, left + width - cx - 1, top + vspacing);
660 Move(rport, left + width - 1 - hspacing - 1, top + height - 1 - vspacing);
661 Draw(rport, left + cx - 1, top + vspacing);
662 Move(rport, left + width - 1 - hspacing, top + height - 1 - vspacing);
663 Draw(rport, left + cx, top + vspacing);
665 else
667 WORD i;
669 SetAPen(rport, getbgpen(msg->imp_State, data->dri->dri_Pens));
671 RectFill(rport, left, top, right, bottom);
673 left += hspacing;
674 top += vspacing;
675 width -= hspacing * 2;
676 height -= vspacing * 2;
678 right = left + width - 1;
679 bottom = top + height - 1;
681 cx = (width + 1) / 2;
683 SetAPen(rport, data->dri->dri_Pens[SHADOWPEN]);
685 for(i = 0; i < cx; i++)
687 RectFill(rport, left + i,
688 top + (cx - i - 1) * height / cx,
689 left + i,
690 bottom - i * height / cx / 2);
691 RectFill(rport, right - i,
692 top + (cx - i - 1) * height / cx,
693 right - i,
694 bottom - i * height / cx / 2);
698 break;
701 case RIGHTIMAGE:
703 UWORD hspacing,vspacing;
704 WORD cy;
706 if (!(data->flags & (SYSIFLG_NOBORDER | SYSIFLG_GADTOOLS)))
708 LOCKSHARED_WINDECOR(data->dri)
709 DoMethodA(INTDRI(data->dri)->dri_WinDecorObj, (Msg)&decormsg);
710 UNLOCK_WINDECOR(data->dri)
711 break;
714 hspacing = HSPACING;
715 vspacing = VSPACING;
717 if (width <= 12)
719 hspacing = HSPACING_MIDDLE;
722 if (width <= 10)
724 hspacing = HSPACING_SMALL;
727 if (height <= 12)
729 vspacing = VSPACING_MIDDLE;
732 if (height <= 10)
734 vspacing = VSPACING_SMALL;
737 if (!(data->flags & SYSIFLG_NOBORDER))
739 renderimageframe(rport, RIGHTIMAGE, msg->imp_State, data->dri->dri_Pens,
740 left, top, width, height, IntuitionBase);
741 left++;
742 top++;
743 right--;
744 bottom--;
745 width -= 2;
746 height -= 2;
748 if (data->flags & SYSIFLG_GADTOOLS)
750 SetAPen(rport, getbgpen_gt(msg->imp_State, data->dri->dri_Pens));
751 RectFill(rport, left, top, right, bottom);
756 if (data->flags & SYSIFLG_GADTOOLS)
758 SetAPen(rport, data->dri->dri_Pens[SHADOWPEN]);
760 cy = height / 2;
762 Move(rport, left + hspacing, top + vspacing + 1);
763 Draw(rport, left + width - 1 - hspacing, top + height - cy);
764 Move(rport, left + hspacing, top + vspacing);
765 Draw(rport, left + width - 1 - hspacing, top + height - cy - 1);
767 Move(rport, left + hspacing, top + height - 1- vspacing - 1);
768 Draw(rport, left + width - 1 - hspacing, top + cy - 1);
769 Move(rport, left + hspacing, top + height - 1 - vspacing);
770 Draw(rport, left + width - 1 - hspacing, top + cy);
773 else
775 WORD i;
777 SetAPen(rport, getbgpen(msg->imp_State, data->dri->dri_Pens));
779 RectFill(rport, left, top, right, bottom);
781 left += hspacing;
782 top += vspacing;
783 width -= hspacing * 2;
784 height -= vspacing * 2;
786 right = left + width - 1;
787 bottom = top + height - 1;
789 cy = (height + 1) / 2;
791 SetAPen(rport, data->dri->dri_Pens[SHADOWPEN]);
793 for(i = 0; i < cy; i++)
795 RectFill(rport, left + i * width / cy / 2,
796 top + i,
797 right - (cy - i - 1) * width / cy,
798 top + i);
799 RectFill(rport, left + i * width / cy / 2,
800 bottom - i,
801 right - (cy - i - 1) * width / cy,
802 bottom - i);
806 break;
809 case DOWNIMAGE:
811 UWORD hspacing,vspacing;
812 WORD cx;
814 if (!(data->flags & (SYSIFLG_NOBORDER | SYSIFLG_GADTOOLS)))
816 LOCKSHARED_WINDECOR(data->dri)
817 DoMethodA(INTDRI(data->dri)->dri_WinDecorObj, (Msg)&decormsg);
818 UNLOCK_WINDECOR(data->dri)
819 break;
822 hspacing = HSPACING;
823 vspacing = VSPACING;
825 if (width <= 12)
827 hspacing = HSPACING_MIDDLE;
830 if (width <= 10)
832 hspacing = HSPACING_SMALL;
835 if (height <= 12)
837 vspacing = VSPACING_MIDDLE;
840 if (height <= 10)
842 vspacing = VSPACING_SMALL;
845 if (!(data->flags & SYSIFLG_NOBORDER))
847 renderimageframe(rport, DOWNIMAGE, msg->imp_State, data->dri->dri_Pens,
848 left, top, width, height, IntuitionBase);
849 left++;
850 top++;
851 right--;
852 bottom--;
853 width -= 2;
854 height -= 2;
856 if (data->flags & SYSIFLG_GADTOOLS)
858 SetAPen(rport, getbgpen_gt(msg->imp_State, data->dri->dri_Pens));
859 RectFill(rport, left, top, right, bottom);
863 if (data->flags & SYSIFLG_GADTOOLS)
865 SetAPen(rport, data->dri->dri_Pens[SHADOWPEN]);
867 cx = width / 2;
869 Move(rport, left + hspacing + 1, top + vspacing);
870 Draw(rport, left + width - cx, top + height - 1 - vspacing);
871 Move(rport, left + hspacing, top + vspacing);
872 Draw(rport, left + width - cx - 1, top + height - 1 - vspacing);
874 Move(rport, left + width - 1 - hspacing - 1, top + vspacing);
875 Draw(rport, left + cx - 1, top + height - 1 - vspacing);
876 Move(rport, left + width - 1 - hspacing, top + vspacing);
877 Draw(rport, left + cx, top + height - 1 - vspacing);
879 else
881 WORD i;
883 SetAPen(rport, getbgpen(msg->imp_State, data->dri->dri_Pens));
885 RectFill(rport, left, top, right, bottom);
887 left += hspacing;
888 top += vspacing;
889 width -= hspacing * 2;
890 height -= vspacing * 2;
892 right = left + width - 1;
893 bottom = top + height - 1;
895 cx = (width + 1) / 2;
897 SetAPen(rport, data->dri->dri_Pens[SHADOWPEN]);
899 for(i = 0; i < cx; i++)
901 RectFill(rport, left + i,
902 top + i * height / cx / 2,
903 left + i,
904 bottom - (cx - i - 1) * height / cx);
905 RectFill(rport, right - i,
906 top + i * height / cx / 2,
907 right - i,
908 bottom - (cx - i - 1) * height / cx);
913 break;
916 case CLOSEIMAGE:
917 case ZOOMIMAGE:
918 case DEPTHIMAGE:
919 case SIZEIMAGE:
921 LOCKSHARED_WINDECOR(data->dri)
922 DoMethodA(INTDRI(data->dri)->dri_WinDecorObj, (Msg)&decormsg);
923 UNLOCK_WINDECOR(data->dri)
924 break;
927 case SDEPTHIMAGE:
929 decormsg.MethodID = SDM_DRAW_SYSIMAGE;
931 LOCKSHARED_SCRDECOR(data->dri)
932 DoMethodA(INTDRI(data->dri)->dri_ScrDecorObj, (Msg)&decormsg);
933 UNLOCK_SCRDECOR(data->dri)
934 break;
937 case MENUCHECK:
939 UWORD *pens = data->dri->dri_Pens;
941 if (MENUS_AMIGALOOK)
943 SetAPen(rport, pens[BARBLOCKPEN]);
945 else
947 SetAPen(rport, pens[(msg->imp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
950 RectFill(rport, left, top, right, bottom);
952 SetAPen(rport, pens[BARDETAILPEN]);
953 draw_thick_line(cl, rport, left + 1, top + height / 3 , left + 1, bottom, 0);
954 draw_thick_line(cl, rport, left + 2, bottom, right - 2, top, 0);
956 break;
959 case AMIGAKEY:
961 UWORD *pens = data->dri->dri_Pens;
962 struct TextFont *oldfont;
963 UBYTE oldstyle;
965 if (MENUS_AMIGALOOK)
967 SetAPen(rport, pens[BARDETAILPEN]);
969 else
971 SetAPen(rport, pens[SHINEPEN]);
974 RectFill(rport, left, top, right, bottom);
976 if (MENUS_AMIGALOOK)
978 SetAPen(rport, pens[BARBLOCKPEN]);
980 oldfont = rport->Font;
981 oldstyle = rport->AlgoStyle;
983 SetFont(rport, GfxBase->DefaultFont);
984 SetSoftStyle(rport, FSF_ITALIC, AskSoftStyle(rport));
986 Move(rport, left + (width - rport->TxWidth) / 2,
987 top + (height - rport->TxHeight) / 2 + rport->TxBaseline);
988 Text(rport, "A", 1);
990 SetSoftStyle(rport, oldstyle, AskSoftStyle(rport));
991 SetFont(rport, oldfont);
993 SetAPen(rport, pens[BARBLOCKPEN]);
995 else
997 SetAPen(rport, pens[SHADOWPEN]);
999 RectFill(rport, left + 1, top, right - 1, top);
1000 RectFill(rport, right, top + 1, right, bottom - 1);
1001 RectFill(rport, left + 1, bottom, right - 1, bottom);
1002 RectFill(rport, left, top + 1, left, bottom - 1);
1004 SetAPen(rport, pens[BACKGROUNDPEN]);
1005 RectFill(rport, left + 1, bottom - 1, right - 1, bottom - 1);
1006 RectFill(rport, right - 1, top + 1, right - 1, bottom - 2);
1008 RectFill(rport, left + 2, top + 2, left + 4, top + 2);
1009 RectFill(rport, left + 2, top + 3, left + 2, top + 4);
1011 SetAPen(rport, pens[SHADOWPEN]);
1012 RectFill(rport, left + 2, bottom - 2, right - 2, bottom - 2);
1013 RectFill(rport, right - 2, top + 2, right - 2, bottom - 4);
1016 WORD a_size = height - 7;
1017 WORD a_left = left + 5;
1018 WORD a_top = top + 2;
1019 WORD a_right = a_left + a_size;
1020 WORD a_bottom = a_top + a_size;
1022 Move(rport, a_left, a_bottom);
1023 Draw(rport, a_right, a_top);
1024 Draw(rport, a_right, a_bottom);
1025 Move(rport, a_right - 1, a_top + 1);
1026 Draw(rport, a_right - 1, a_bottom);
1029 SetAPen(rport, pens[(msg->imp_State == IDS_SELECTED) ? FILLPEN : BACKGROUNDPEN]);
1032 WritePixel(rport, left, top);
1033 WritePixel(rport, right, top);
1034 WritePixel(rport, right, bottom);
1035 WritePixel(rport, left, bottom);
1037 break;
1040 /* MUI and other non-std images */
1041 #if 0
1042 case MUIIMAGE:
1044 UWORD *pens = data->dri->dri_Pens;
1045 UWORD bg;
1047 if (!(data->flags & SYSIFLG_NOBORDER))
1049 renderimageframe(rport, SIZEIMAGE, msg->imp_State, pens,
1050 left, top, width, height, IntuitionBase);
1051 left++;
1052 top++;
1053 right--;
1054 bottom--;
1055 width -= 2;
1056 height -= 2;
1059 bg = getbgpen(msg->imp_State, pens);
1061 /* Clear background into correct color */
1062 SetAPen(rport, bg);
1063 RectFill(rport, left, top, right, bottom);
1065 /* DRAW IMAGE :) */
1067 DrawIB(rport,(BYTE *)ibPrefs,left+(width/2),top+(height/2),IntuitionBase);
1069 break;
1072 case SNAPSHOTIMAGE:
1073 case POPUPIMAGE:
1074 case ICONIFYIMAGE:
1075 case LOCKIMAGE:
1077 UWORD *pens = data->dri->dri_Pens;
1078 UWORD bg;
1080 if (!(data->flags & SYSIFLG_NOBORDER))
1082 renderimageframe(rport, SIZEIMAGE, msg->imp_State, pens,
1083 left, top, width, height, IntuitionBase);
1084 left++;
1085 top++;
1086 right--;
1087 bottom--;
1088 width -= 2;
1089 height -= 2;
1092 bg = getbgpen(msg->imp_State, pens);
1094 /* Clear background into correct color */
1095 SetAPen(rport, bg);
1096 RectFill(rport, left, top, right, bottom);
1098 /* DRAW IMAGE :) */
1100 if (data->type == SNAPSHOTIMAGE)
1102 if (msg->imp_State == IDS_SELECTED)
1104 DrawIB(rport,(BYTE *)ibSnapshotSel,left+(width/2),top+(height/2),IntuitionBase);
1106 else
1108 DrawIB(rport,(BYTE *)ibSnapshot,left+(width/2),top+(height/2),IntuitionBase);
1112 if (data->type == POPUPIMAGE)
1114 if (msg->imp_State == IDS_SELECTED)
1116 DrawIB(rport,(BYTE *)ibPopupSel,left+(width/2),top+(height/2),IntuitionBase);
1118 else
1120 DrawIB(rport,(BYTE *)ibPopup,left+(width/2),top+(height/2),IntuitionBase);
1124 if (data->type == ICONIFYIMAGE)
1126 if (msg->imp_State == IDS_SELECTED)
1128 DrawIB(rport,(BYTE *)ibIconifySel,left+(width/2),top+(height/2),IntuitionBase);
1130 else
1132 DrawIB(rport,(BYTE *)ibIconify,left+(width/2),top+(height/2),IntuitionBase);
1136 if (data->type == LOCKIMAGE)
1138 if ((msg->imp_State == IDS_SELECTED) || (msg->imp_State == IDS_INACTIVESELECTED))
1140 DrawIB(rport,(BYTE *)ibLockSel,left+(width/2),top+(height/2),IntuitionBase);
1142 else
1144 DrawIB(rport,(BYTE *)ibLock,left+(width/2),top+(height/2),IntuitionBase);
1148 break;
1151 case JUMPIMAGE:
1153 UWORD *pens = data->dri->dri_Pens;
1154 UWORD bg;
1156 if (!(data->flags & SYSIFLG_NOBORDER))
1158 renderimageframe(rport, SIZEIMAGE, msg->imp_State, pens,
1159 left, top, width, height, IntuitionBase);
1160 left++;
1161 top++;
1162 right--;
1163 bottom--;
1164 width -= 2;
1165 height -= 2;
1168 bg = getbgpen(msg->imp_State, pens);
1170 /* Clear background into correct color */
1171 SetAPen(rport, bg);
1172 RectFill(rport, left, top, right, bottom);
1174 /* DRAW IMAGE :) */
1176 DrawJUMP(rport,msg->imp_State,left+(width/2),top+(height/2),IntuitionBase);
1178 break;
1180 #endif
1181 } /* switch (image type) */
1183 return (IPTR)0;
1186 IPTR SysIClass__OM_DISPOSE(Class *cl, Object *obj, Msg msg)
1188 struct SysIData *data = INST_DATA(cl, obj);
1190 DisposeObject(data->frame);
1191 return DoSuperMethodA(cl, obj, msg);
1194 IPTR SysIClass__OM_SET(Class *cl, Object *obj, Msg msg)
1196 struct SysIData *data = INST_DATA(cl, obj);
1198 if (data->frame)
1199 DoMethodA((Object *)data->frame, msg);
1200 return DoSuperMethodA(cl, obj, msg);
1203 /**************************************************************************************************/
1205 #undef IntuitionBase
1207 /**************************************************************************************************/
1209 static UWORD getbgpen(ULONG state, UWORD *pens)
1211 UWORD bg;
1213 switch (state)
1215 case IDS_NORMAL:
1216 case IDS_SELECTED:
1217 bg = pens[FILLPEN];
1218 break;
1220 default:
1221 bg = pens[BACKGROUNDPEN];
1222 break;
1225 return bg;
1228 /**************************************************************************************************/
1230 static UWORD getbgpen_gt(ULONG state, UWORD *pens)
1232 UWORD bg;
1234 switch (state)
1236 case IDS_SELECTED:
1237 case IDS_INACTIVESELECTED:
1238 bg = pens[FILLPEN];
1239 break;
1241 default:
1242 bg = pens[BACKGROUNDPEN];
1243 break;
1246 return bg;
1249 /**************************************************************************************************/
1251 static void renderimageframe(struct RastPort *rp, ULONG which, ULONG state, UWORD *pens,
1252 WORD left, WORD top, WORD width, WORD height,
1253 struct IntuitionBase *IntuitionBase)
1255 WORD right = left + width - 1;
1256 WORD bottom = top + height - 1;
1257 BOOL leftedgegodown = FALSE;
1258 BOOL topedgegoright = FALSE;
1260 switch(which)
1262 case CLOSEIMAGE:
1263 /* draw separator line at the right side */
1264 SetAPen(rp, pens[SHINEPEN]);
1265 RectFill(rp, right, top, right, bottom - 1);
1266 SetAPen(rp, pens[SHADOWPEN]);
1267 WritePixel(rp, right, bottom);
1269 right--;
1270 break;
1272 case ZOOMIMAGE:
1273 case DEPTHIMAGE:
1274 case SDEPTHIMAGE:
1275 /* draw separator line at the left side */
1276 SetAPen(rp, pens[SHINEPEN]);
1277 WritePixel(rp, left, top);
1278 SetAPen(rp, pens[SHADOWPEN]);
1279 RectFill(rp, left, top + 1, left, bottom);
1281 left++;
1282 break;
1284 case UPIMAGE:
1285 case DOWNIMAGE:
1286 leftedgegodown = TRUE;
1287 break;
1289 case LEFTIMAGE:
1290 case RIGHTIMAGE:
1291 topedgegoright = TRUE;
1292 break;
1295 if (left == 0) leftedgegodown = TRUE;
1296 if (top == 0) topedgegoright = TRUE;
1298 SetAPen(rp, pens[((state == IDS_SELECTED) || (state == IDS_INACTIVESELECTED)) ? SHADOWPEN : SHINEPEN]);
1300 /* left edge */
1301 RectFill(rp, left,
1302 top,
1303 left,
1304 bottom - (leftedgegodown ? 0 : 1));
1306 /* top edge */
1307 RectFill(rp, left + 1,
1308 top,
1309 right - (topedgegoright ? 0 : 1),
1310 top);
1312 SetAPen(rp, pens[((state == IDS_SELECTED) || (state == IDS_INACTIVESELECTED)) ? SHINEPEN : SHADOWPEN]);
1314 /* right edge */
1315 RectFill(rp, right,
1316 top + (topedgegoright ? 1 : 0),
1317 right,
1318 bottom);
1320 /* bottom edge */
1321 RectFill(rp, left + (leftedgegodown ? 1 : 0),
1322 bottom,
1323 right - 1,
1324 bottom);
1327 /**************************************************************************************************/