Added 'Resident' field to ensure that the handler is included in the
[AROS.git] / rom / intuition / propgadgets.c
blob38dec1aec01a001e9915f754b82ffd4b37829d17
1 /*
2 Copyright 1995-2011, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <proto/graphics.h>
8 #include <proto/intuition.h>
9 #include <proto/cybergraphics.h>
10 #include <proto/layers.h>
11 #include <proto/utility.h>
12 #include <graphics/gfxmacros.h>
13 #include <intuition/cghooks.h>
14 #include <intuition/intuition.h>
15 #include <intuition/imageclass.h>
16 #include <intuition/windecorclass.h>
17 #include <cybergraphx/cybergraphics.h>
18 #include <graphics/rpattr.h>
19 #include "intuition_intern.h"
20 #include "propgadgets.h"
21 #ifdef SKINS
22 #include "intuition_customize.h"
23 #include "intuition_customizesupport.h"
24 #include "morphos/proprender.h"
25 #endif
26 #include "gadgets.h"
28 extern IPTR HookEntry();
30 #undef DEBUG
31 #define DEBUG 0
32 # include <aros/debug.h>
34 BOOL isonborder(struct Gadget *gadget,struct Window *window);
36 static void RenderPropBackground(struct Gadget *gad, struct Window *win, struct DrawInfo *dri,
37 struct Rectangle *rect, struct Rectangle *proprect,
38 struct Rectangle *knobrect, struct PropInfo *pi,
39 struct RastPort *rp, BOOL onborder,
40 struct IntuitionBase *IntuitionBase)
42 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
43 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
45 if (onborder)
47 struct wdpDrawBorderPropBack msg;
49 msg.MethodID = WDM_DRAW_BORDERPROPBACK;
51 msg.wdp_Window = win;
52 msg.wdp_TrueColor = (((struct IntScreen *)win->WScreen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
53 msg.wdp_UserBuffer = ((struct IntWindow *)win)->DecorUserBuffer;
55 msg.wdp_RPort = rp;
56 msg.wdp_Gadget = gad;
57 msg.wdp_RenderRect = rect;
58 msg.wdp_PropRect = proprect;
59 msg.wdp_KnobRect = knobrect;
60 msg.wdp_Flags = 0;
61 msg.wdp_Dri = dri;
63 DoMethodA(((struct IntScreen *)(win->WScreen))->WinDecorObj, (Msg)&msg);
65 else
67 static CONST UWORD pattern[] = {0x5555,0xAAAA};
68 struct Hook *dhook = NULL;
70 if ((gad->Flags & GFLG_EXTENDED) != 0)
72 if ((((struct ExtGadget *) gad)->MoreFlags & GMORE_BOOPSIGADGET) != 0)
74 GetAttr(PGA_DisplayHook, (Object *) gad, (IPTR *)&dhook);
77 if (dhook) {
79 struct wdpDrawBorderPropBack msg;
81 msg.MethodID = WDM_DRAW_BORDERPROPBACK;
83 msg.wdp_Window = win;
84 msg.wdp_TrueColor = (((struct IntScreen *)win->WScreen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
85 msg.wdp_RPort = rp;
86 msg.wdp_Gadget = gad;
87 msg.wdp_RenderRect = rect;
88 msg.wdp_PropRect = proprect;
89 msg.wdp_KnobRect = knobrect;
90 msg.wdp_Flags = 0;
91 msg.wdp_Dri = dri;
93 CallHookPkt(dhook, (Object *) gad, (Msg)&msg);
95 else
97 SetDrMd(rp, JAM2);
99 if (pi->Flags & PROPNEWLOOK)
101 SetAfPt(rp, pattern, 1);
102 SetAPen(rp, dri->dri_Pens[SHADOWPEN]);
103 SetBPen(rp, dri->dri_Pens[BACKGROUNDPEN]);
105 RectFill(rp, rect->MinX, rect->MinY, rect->MaxX, rect->MaxY);
106 SetAfPt(rp, NULL, 0);
108 else
110 SetAPen(rp, dri->dri_Pens[BACKGROUNDPEN]);
111 RectFill(rp, rect->MinX, rect->MinY, rect->MaxX, rect->MaxY);
118 VOID HandlePropSelectDown(struct Gadget *gadget, struct Window *w, struct Requester *req,
119 UWORD mouse_x, UWORD mouse_y, struct IntuitionBase *IntuitionBase)
121 struct BBox knob;
122 struct PropInfo *pi;
123 UWORD dx, dy, flags;
125 pi = (struct PropInfo *)gadget->SpecialInfo;
127 if (!pi)
128 return;
130 CalcBBox (w, req, gadget, &knob);
132 /* This func gets mouse coords relative to gadget box */
134 mouse_x += knob.Left;
135 mouse_y += knob.Top;
137 if (!CalcKnobSize (gadget, &knob))
138 return;
140 GetPrivIBase(IntuitionBase)->prop_clickoffset_x = mouse_x - knob.Left;
141 GetPrivIBase(IntuitionBase)->prop_clickoffset_y = mouse_y - knob.Top;
143 dx = pi->HorizPot;
144 dy = pi->VertPot;
146 if (pi->Flags & FREEHORIZ)
148 if (mouse_x < knob.Left)
150 if (dx > pi->HPotRes)
151 dx -= pi->HPotRes;
152 else
153 dx = 0;
155 else if (mouse_x >= knob.Left + knob.Width)
157 if (dx < MAXPOT - pi->HPotRes)
158 dx += pi->HPotRes;
159 else
160 dx = MAXPOT;
164 if (pi->Flags & FREEVERT)
166 if (mouse_y < knob.Top)
168 if (dy > pi->VPotRes)
169 dy -= pi->VPotRes;
170 else
171 dy = 0;
173 else if (mouse_y >= knob.Top + knob.Height)
175 if (dy < MAXPOT - pi->VPotRes)
176 dy += pi->VPotRes;
177 else
178 dy = MAXPOT;
182 flags = pi->Flags;
184 /* jDc: when clicked on frame, prop gadget also gets activated! */
185 if (!(flags & PROPBORDERLESS))
187 if (pi->Flags & FREEVERT)
189 knob.Left --;
190 knob.Width += 2;
191 } else {
192 knob.Top ++;
193 knob.Height += 2;
197 if (mouse_x >= knob.Left &&
198 mouse_y >= knob.Top &&
199 mouse_x < knob.Left + knob.Width &&
200 mouse_y < knob.Top + knob.Height)
202 flags |= KNOBHIT;
204 else
206 flags &= ~KNOBHIT;
209 gadget->Flags |= GFLG_SELECTED;
211 D(bug("New HPot: %d, new VPot: %d\n", dx, dy));
213 NewModifyProp(gadget, w, req, flags, dx, dy, pi->HorizBody, pi->VertBody, 1);
215 return;
218 VOID HandlePropSelectUp(struct Gadget *gadget, struct Window *w,
219 struct Requester *req, struct IntuitionBase *IntuitionBase)
221 struct PropInfo * pi;
223 pi = (struct PropInfo *)gadget->SpecialInfo;
225 gadget->Flags &= ~GFLG_SELECTED;
226 if (pi) pi->Flags &= ~KNOBHIT;
228 if (pi) RefreshPropGadget (gadget, w, req, IntuitionBase);
230 /* if (pi)
231 NewModifyProp (gadget
233 , req
234 , pi->Flags &= ~KNOBHIT
235 , pi->HorizPot
236 , pi->VertPot
237 , pi->HorizBody
238 , pi->VertBody
240 ); */
242 return;
245 VOID HandlePropMouseMove(struct Gadget *gadget, struct Window *w,struct Requester *req,
246 LONG dx, LONG dy, struct IntuitionBase *IntuitionBase)
248 struct BBox knob;
249 struct PropInfo *pi;
251 pi = (struct PropInfo *)gadget->SpecialInfo;
253 /* Has propinfo and the mouse was over the knob */
254 if (pi && (pi->Flags & KNOBHIT))
256 CalcBBox (w, req, gadget, &knob);
258 if (!CalcKnobSize (gadget, &knob))
259 return;
261 /* Move the knob the same amount, ie.
262 knob.Left += dx; knob.Top += dy;
264 knob.Left = knob.Left
265 + (pi->CWidth - knob.Width)
266 * pi->HorizPot / MAXPOT;
268 ie. dx = (pi->CWidth - knob.Width)
269 * pi->HorizPot / MAXPOT;
273 pi->HorizPot = (dx * MAXPOT) /
274 (pi->CWidth - knob.Width);
277 /* stegerg: dx and dy are not delta values
278 anymore but relative to gadget
279 box */
281 dx = dx - GetPrivIBase(IntuitionBase)->prop_clickoffset_x;
282 dy = dy - GetPrivIBase(IntuitionBase)->prop_clickoffset_y;
284 if (pi->Flags & FREEHORIZ
285 && pi->CWidth != knob.Width)
288 dx = (dx * MAXPOT) / (pi->CWidth - knob.Width);
289 if (dx < 0)
291 dx = 0;
293 else if (dx > MAXPOT)
295 dx = MAXPOT;
298 } /* FREEHORIZ */
300 if (pi->Flags & FREEVERT
301 && pi->CHeight != knob.Height)
303 dy = (dy * MAXPOT) / (pi->CHeight - knob.Height);
305 if (dy < 0)
307 dy = 0;
309 else if (dy > MAXPOT)
311 dy = MAXPOT;
314 } /* FREEVERT */
316 if ( ((pi->Flags & FREEHORIZ) && (dx != pi->HorizPot)) ||
317 ((pi->Flags & FREEVERT) && (dy != pi->VertPot)) )
320 NewModifyProp (gadget, w, req, pi->Flags, dx, dy, pi->HorizBody, pi->VertBody, 1);
323 } /* Has PropInfo and Mouse is over knob */
325 return;
328 int CalcKnobSize (struct Gadget * propGadget, struct BBox * knobbox)
330 struct PropInfo *pi;
331 WORD x, y;
333 pi = (struct PropInfo *)propGadget->SpecialInfo;
335 //dprintf("CalcKnobSize(%lx,%d,%d,%d,%d)\n", propGadget,
336 // propGadget->LeftEdge, propGadget->TopEdge, propGadget->Width, propGadget->Height);
337 //dprintf("knob(%d,%d,%d,%d)\n", knobbox->Left, knobbox->Top, knobbox->Width, knobbox->Height);
339 if (pi->Flags & PROPBORDERLESS)
341 pi->LeftBorder = 0;
342 pi->TopBorder = 0;
344 else
346 x = y = 1;
348 knobbox->Left += x;
349 knobbox->Top += y;
350 knobbox->Width -= x * 2;
351 knobbox->Height -= y * 2;
352 pi->LeftBorder = x;
353 pi->TopBorder = y;
355 //dprintf("knob(%d,%d,%d,%d)\n", knobbox->Left, knobbox->Top, knobbox->Width, knobbox->Height);
357 pi->CWidth = knobbox->Width;
358 pi->CHeight = knobbox->Height;
360 if ((!(pi->Flags & AUTOKNOB)) && propGadget->GadgetRender)
362 struct Image *im = propGadget->GadgetRender;
364 knobbox->Width = im->Width;
365 knobbox->Height = im->Height;
368 if (pi->Flags & FREEHORIZ)
370 if (pi->Flags & AUTOKNOB)
372 knobbox->Width = pi->CWidth * pi->HorizBody / MAXBODY;
373 if (knobbox->Width < KNOBHMIN) knobbox->Width = KNOBHMIN;
376 knobbox->Left = knobbox->Left + (pi->CWidth - knobbox->Width)
377 * pi->HorizPot / MAXPOT;
379 if (pi->HorizBody)
381 if (pi->HorizBody < MAXBODY/2)
382 pi->HPotRes = MAXPOT * 32768 / ((MAXBODY * 32768 / pi->HorizBody) - 32768);
383 else
384 pi->HPotRes = MAXPOT;
386 else
387 pi->HPotRes = 1;
390 if (pi->Flags & FREEVERT)
392 if (pi->Flags & AUTOKNOB)
394 knobbox->Height = pi->CHeight * pi->VertBody / MAXBODY;
395 if (knobbox->Height < KNOBVMIN) knobbox->Height = KNOBVMIN;
398 knobbox->Top = knobbox->Top + (pi->CHeight - knobbox->Height)
399 * pi->VertPot / MAXPOT;
401 if (pi->VertBody)
403 if (pi->VertBody < MAXBODY/2)
404 pi->VPotRes = MAXPOT * 32768 / ((MAXBODY * 32768 / pi->VertBody) - 32768);
405 else
406 pi->VPotRes = MAXPOT;
408 else
409 pi->VPotRes = 1;
411 //dprintf("knob(%d,%d,%d,%d)\n", knobbox->Left, knobbox->Top, knobbox->Width, knobbox->Height);
413 return TRUE;
414 } /* CalcKnobSize */
417 void RefreshPropGadget (struct Gadget * gadget, struct Window * window,
418 struct Requester * req, struct IntuitionBase * IntuitionBase)
420 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
421 struct PropInfo *pi;
422 struct DrawInfo *dri;
423 struct GadgetInfo gi;
424 struct RastPort *rp = 0;
425 struct BBox bbox, kbox;
426 BOOL onborder;
428 D(bug("RefreshPropGadget(gad=%p, win=%s, req=%p)\n", gadget, window->Title, req));
430 onborder = (IS_BORDER_GADGET(gadget) || isonborder(gadget,window));
432 if ((dri = GetScreenDrawInfo(window->WScreen)))
435 SetupGInfo(&gi, window, req, gadget, IntuitionBase);
437 if ((rp = ObtainGIRPort(&gi)))
439 for (;;)
441 CalcBBox (window, req, gadget, &bbox);
442 kbox = bbox;
444 if (bbox.Width <= 0 || bbox.Height <= 0)
445 break;
447 if (CalcKnobSize (gadget, &kbox))
449 pi = (struct PropInfo *)gadget->SpecialInfo;
451 if (!pi)
452 break;
454 SetDrMd (rp, JAM2);
456 if (!(pi->Flags & PROPBORDERLESS))
458 SetAPen(rp,dri->dri_Pens[SHADOWPEN]);
459 drawrect(rp,bbox.Left,
460 bbox.Top,
461 bbox.Left + bbox.Width - 1,
462 bbox.Top + bbox.Height - 1,
463 IntuitionBase);
465 bbox.Left ++; bbox.Top ++;
466 bbox.Width -= 2; bbox.Height -= 2;
469 RefreshPropGadgetKnob (gadget, &bbox, &kbox, window, req, IntuitionBase);
471 else
474 pi = (struct PropInfo *)gadget->SpecialInfo;
476 if (!pi)
477 break;
479 SetDrMd (rp, JAM2);
481 if (!(pi->Flags & PROPBORDERLESS))
483 SetAPen(rp,dri->dri_Pens[SHADOWPEN]);
484 drawrect(rp,bbox.Left,
485 bbox.Top,
486 bbox.Left + bbox.Width - 1,
487 bbox.Top + bbox.Height - 1,
488 IntuitionBase);
490 bbox.Left ++; bbox.Top ++;
491 bbox.Width -= 2; bbox.Height -= 2;
496 struct Rectangle tmprect;
498 tmprect.MinX = bbox.Left;
499 tmprect.MaxX = bbox.Left + bbox.Width - 1;
500 tmprect.MinY = bbox.Top;
501 tmprect.MaxY = bbox.Top + bbox.Height - 1;
503 RenderPropBackground(gadget, window, dri, &tmprect, &tmprect, NULL,
504 pi, rp, onborder, IntuitionBase);
506 } // if (CalcKnob
507 break;
510 } /* if ((rp = ObtainGIRPort(&gi))) */
512 if (rp && gadget->Flags & GFLG_DISABLED)
514 CalcBBox (window, req, gadget, &bbox);
516 RenderDisabledPattern(rp, (struct DrawInfo *)dri, bbox.Left,
517 bbox.Top,
518 bbox.Left + bbox.Width - 1,
519 bbox.Top + bbox.Height - 1,
520 IntuitionBase);
523 if (rp) ReleaseGIRPort(rp);
525 FreeScreenDrawInfo(window->WScreen, (struct DrawInfo *)dri);
527 } /* if ((dri = GetScreenDrawInfo(window->WScreen))) */
529 ReturnVoid("RefreshPropGadget");
530 } /* RefreshPropGadget */
533 void RefreshPropGadgetKnob (struct Gadget * gadget, struct BBox * clear,
534 struct BBox * knob, struct Window * window, struct Requester * req,
535 struct IntuitionBase * IntuitionBase)
537 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
538 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
539 struct DrawInfo *dri;
540 struct RastPort *rp;
541 struct PropInfo *pi;
542 struct GadgetInfo gi;
543 UWORD flags;
544 BOOL onborder;
546 D(bug("RefresPropGadgetKnob(flags=%d, clear=%p, knob = %p, win=%s)\n",
547 flags, clear, knob, window->Title));
549 if ((knob->Width < 1) || (knob->Height < 1)) return;
551 onborder = (IS_BORDER_GADGET(gadget) || isonborder(gadget,window));
553 pi = (struct PropInfo *)gadget->SpecialInfo;
554 flags = pi->Flags;
556 if ((dri = GetScreenDrawInfo(window->WScreen)))
558 SetupGInfo(&gi, window, req, gadget, IntuitionBase);
560 if ((rp = ObtainGIRPort(&gi)))
562 struct BBox bbox;
563 struct Rectangle brect;
564 struct Rectangle krect;
566 CalcBBox (window, req, gadget, &bbox);
568 if ((bbox.Width < 1) || (bbox.Height < 1))
570 ReleaseGIRPort(rp);
571 FreeScreenDrawInfo(window->WScreen, (struct DrawInfo *)dri);
573 return;
576 brect.MinX = bbox.Left;
577 brect.MinY = bbox.Top;
578 brect.MaxX = bbox.Left + bbox.Width - 1;
579 brect.MaxY = bbox.Top + bbox.Height - 1;
581 krect.MinX = knob->Left;
582 krect.MinY = knob->Top;
583 krect.MaxX = knob->Left + knob->Width - 1;
584 krect.MaxY = knob->Top + knob->Height - 1;
586 SetDrMd (rp, JAM2);
588 if (clear)
590 struct Rectangle a, b, clearrects[4];
591 WORD i, nrects;
593 #if (!(PROP_RENDER_OPTIMIZATION))
594 if (!(flags & PROPBORDERLESS))
596 clear->Left ++; clear->Top ++;
597 clear->Width -= 2; clear->Height -= 2;
599 #endif
601 #if 0
602 D(bug("RefresPropGadgetKnob: clear Left %d Top %d Width %d Height %d\n",
603 clear->Left,
604 clear->Top,
605 clear->Width,
606 clear->Height));
608 D(bug("RefresPropGadgetKnob: knob Left %d Top %d Width %d Height %d\n",
609 knob->Left,
610 knob->Top,
611 knob->Width,
612 knob->Height));
613 #endif
615 a.MinX = clear->Left;
616 a.MinY = clear->Top;
617 a.MaxX = clear->Left + clear->Width - 1;
618 a.MaxY = clear->Top + clear->Height - 1;
620 b.MinX = knob->Left;
621 b.MinY = knob->Top;
622 b.MaxX = knob->Left + knob->Width - 1;
623 b.MaxY = knob->Top + knob->Height - 1;
625 #if 0
626 D(bug("RefresPropGadgetKnob: a MinX %d MinY %d MaxX %d MaxY %d\n",
627 a.MinX,
628 a.MinY,
629 a.MaxX,
630 a.MaxY));
632 D(bug("RefresPropGadgetKnob: a MinX %d MinY %d MaxX %d MaxY %d\n",
633 b.MinX,
634 b.MinY,
635 b.MaxX,
636 b.MaxY));
637 #endif
639 nrects = SubtractRectFromRect(&a, &b, clearrects);
641 D(bug("RefresPropGadgetKnob: nrects %d\n",
642 nrects));
643 #if 0
644 D(bug("RefresPropGadgetKnob: clearrects[0] MinX %d MinY %d MaxX %d MaxY %d\n",
645 clearrects[0].MinX,
646 clearrects[0].MinY,
647 clearrects[0].MaxX,
648 clearrects[0].MaxY));
650 D(bug("RefresPropGadgetKnob: clearrects[1] MinX %d MinY %d MaxX %d MaxY %d\n",
651 clearrects[1].MinX,
652 clearrects[1].MinY,
653 clearrects[1].MaxX,
654 clearrects[1].MaxY));
656 D(bug("RefresPropGadgetKnob: clearrects[2] MinX %d MinY %d MaxX %d MaxY %d\n",
657 clearrects[2].MinX,
658 clearrects[2].MinY,
659 clearrects[2].MaxX,
660 clearrects[2].MaxY));
662 D(bug("RefresPropGadgetKnob: clearrects[3] MinX %d MinY %d MaxX %d MaxY %d\n",
663 clearrects[3].MinX,
664 clearrects[3].MinY,
665 clearrects[3].MaxX,
666 clearrects[3].MaxY));
667 #endif
669 /*kprintf("\n=== oldknob = %d,%d-%d,%d newknob = %d,%d-%d,%d\n",
670 a.MinX,
671 a.MinY,
672 a.MaxX,
673 a.MaxY,
674 b.MinX,
675 b.MinY,
676 b.MaxX,
677 b.MaxY);*/
679 for(i = 0; i < nrects; i++)
681 RenderPropBackground(gadget, window, dri, &clearrects[i], &brect, &krect,
682 pi, rp, onborder, IntuitionBase);
685 } /* if (clear) */
687 if (flags & AUTOKNOB)
689 int hit = ((flags & KNOBHIT) != 0);
691 D(bug("RefresPropGadgetKnob: draw knob Left %d Top %d Width %d Height %d\n",
692 knob->Left,
693 knob->Top,
694 knob->Width,
695 knob->Height));
697 if (onborder)
699 struct wdpDrawBorderPropKnob msg;
700 struct Rectangle knobrect;
701 knobrect.MinX = knob->Left;
702 knobrect.MinY = knob->Top;
703 knobrect.MaxX = knob->Left + knob->Width - 1;
704 knobrect.MaxY = knob->Top + knob->Height - 1;
706 msg.MethodID = WDM_DRAW_BORDERPROPKNOB;
707 msg.wdp_TrueColor = (((struct IntScreen *)window->WScreen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
708 msg.wdp_UserBuffer = ((struct IntWindow *)window)->DecorUserBuffer;
709 msg.wdp_Window = window;
710 msg.wdp_RPort = rp;
711 msg.wdp_Gadget = gadget;
712 msg.wdp_RenderRect = &knobrect;
713 msg.wdp_PropRect = &brect;
714 msg.wdp_Flags = hit ? WDF_DBPK_HIT : 0;
715 msg.wdp_Dri = dri;
717 DoMethodA(((struct IntScreen *)(window->WScreen))->WinDecorObj, (Msg)&msg);
719 } /* gadget inside window border */
720 else
722 struct Hook *dhook = NULL;
724 if ((gadget->Flags & GFLG_EXTENDED) != 0)
726 if ((((struct ExtGadget *) gadget)->MoreFlags & GMORE_BOOPSIGADGET) != 0)
728 GetAttr(PGA_DisplayHook, (Object *) gadget, (IPTR *)&dhook);
731 if (dhook) {
732 struct wdpDrawBorderPropKnob msg;
733 struct Rectangle knobrect;
734 knobrect.MinX = knob->Left;
735 knobrect.MinY = knob->Top;
736 knobrect.MaxX = knob->Left + knob->Width - 1;
737 knobrect.MaxY = knob->Top + knob->Height - 1;
738 msg.MethodID = WDM_DRAW_BORDERPROPKNOB;
739 msg.wdp_TrueColor = (((struct IntScreen *)window->WScreen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
740 msg.wdp_Window = window;
741 msg.wdp_RPort = rp;
742 msg.wdp_Gadget = gadget;
743 msg.wdp_RenderRect = &knobrect;
744 msg.wdp_PropRect = &brect;
745 msg.wdp_Flags = hit ? WDF_DBPK_HIT : 0;
746 msg.wdp_Dri = dri;
748 CallHookPkt(dhook, (Object *) gadget, (Msg)&msg);
750 else
753 BOOL stdlook = TRUE;
755 #ifdef SKINS
756 stdlook = RenderPropKnob(window,dri,rp,pi,knob,hit,IntuitionBase);
757 #endif
759 if (stdlook)
761 if (flags & PROPBORDERLESS)
763 SetAPen(rp,dri->dri_Pens[SHADOWPEN]);
765 /* paint black right and bottom edges */
767 RectFill(rp,knob->Left + knob->Width - 1,
768 knob->Top,
769 knob->Left + knob->Width - 1,
770 knob->Top + knob->Height - 1);
772 RectFill(rp,knob->Left,
773 knob->Top + knob->Height - 1,
774 knob->Left + knob->Width - 2,
775 knob->Top + knob->Height - 1);
777 knob->Width--;
778 knob->Height--;
780 } /* propborderless */
781 else
783 SetAPen(rp,dri->dri_Pens[SHADOWPEN]);
785 if (flags & FREEHORIZ)
787 /* black line at the left and at the right */
789 RectFill(rp,knob->Left,
790 knob->Top,
791 knob->Left,
792 knob->Top + knob->Height - 1);
794 RectFill(rp,knob->Left + knob->Width - 1,
795 knob->Top,
796 knob->Left + knob->Width - 1,
797 knob->Top + knob->Height - 1);
799 knob->Left++,
800 knob->Width -= 2;
802 if (flags & FREEVERT)
804 /* black line at the top and at the bottom */
806 RectFill(rp,knob->Left,
807 knob->Top,
808 knob->Left + knob->Width - 1,
809 knob->Top);
811 RectFill(rp,knob->Left,
812 knob->Top + knob->Height - 1,
813 knob->Left + knob->Width - 1,
814 knob->Top + knob->Height - 1);
816 knob->Top++;
817 knob->Height -= 2;
820 } /* not propborderless */
823 SetAPen(rp, dri->dri_Pens[SHINEPEN]);
825 /* interior */
826 RectFill(rp,knob->Left,
827 knob->Top,
828 knob->Left + knob->Width - 1,
829 knob->Top + knob->Height - 1);
830 } /* stdlook */
831 } /* gadget has no display (render) hook */
832 } /* gadget not inside window border */
834 } /* if (flags & AUTOKNOB) */
835 else
837 struct Image *image = (struct Image *)gadget->GadgetRender;
839 #if 0 /* CHECKME */
840 if (knob->Top + image->Height <= bbox.Top + bbox.Height &&
841 knob->Left + image->Width <= bbox.Left + bbox.Width)
842 #endif
844 #if 1
845 image->LeftEdge = knob->Left - bbox.Left;
846 image->TopEdge = knob->Top - bbox.Top;
847 // image->Width = knob->Width;
848 // image->Height = knob->Height;
850 DrawImageState(rp,
851 image,
852 bbox.Left,
853 bbox.Top,
854 IDS_NORMAL,
855 (struct DrawInfo *)dri);
856 #else
857 image->LeftEdge = 0;
858 image->TopEdge = 0;
860 DrawImageState(rp,
861 image,
862 knob->Left,
863 knob->Top,
864 IDS_NORMAL,
865 (struct DrawInfo *)dri);
866 #endif
870 if (gadget->Flags & GFLG_DISABLED)
872 RenderDisabledPattern(rp, (struct DrawInfo *)dri,
873 brect.MinX, brect.MinY,
874 brect.MaxX, brect.MaxY, IntuitionBase);
877 ReleaseGIRPort(rp);
879 } /* if ((rp = ObtainGIRPort(&gi))) */
881 FreeScreenDrawInfo(window->WScreen, (struct DrawInfo *)dri);
883 } /* if ((dri = GetScreenDrawInfo(window->WScreen))) */
885 ReturnVoid("RefreshPropGadgetKnob");
887 } /* RefreshPropGadgetKnob */
889 BOOL isonborder(struct Gadget *gadget, struct Window *window)
891 if ((window->BorderBottom > 2) && (gadget->Flags & GFLG_RELBOTTOM))
892 if (window->Height + gadget->TopEdge >= window->Height - window->BorderBottom) return TRUE;
894 if ((window->BorderRight > 2) && (gadget->Flags & GFLG_RELRIGHT))
895 if (window->Width + gadget->LeftEdge >= window->Width - window->BorderRight) return TRUE;
897 return FALSE;