2 ** $Id: FrPropGClass.c,v 1.1 1999/02/07 14:24:42 bernie Exp $
4 ** Copyright (C) 1999,2000 Bernardo Innocenti
5 ** All rights reserved.
7 ** Use 4 chars wide TABs to read this file
9 ** A simple subclass of the propgclass which can be surrounded
10 ** by a boopsi frame image specified through the GA_LabelImage tag.
13 #define USE_BUILTIN_MATH
14 #define INTUI_V36_NAMES_ONLY
16 #define CLIB_ALIB_PROTOS_H /* Avoid dupe defs of boopsi funcs */
19 #include <intuition/gadgetclass.h>
20 #include <intuition/imageclass.h>
21 #include <proto/intuition.h>
27 #include "CompilerSpecific.h"
28 #include "DebugMacros.h"
29 #include "BoopsiStubs.h"
31 #include "FrPropGClass.h"
36 /* Per object instance data */
45 /* ScrollButton Class Dispatcher entrypoint.
46 * Handle boopsi messages.
48 static ULONG HOOKCALL FrPropDispatcher (
50 REG(a2, struct Gadget * g),
53 struct FrPropData *fpd;
55 switch (msg->MethodID)
58 DB2(DBPRINTF("FrPropGClass: OM_NEW\n");)
60 if (g = (struct Gadget *)DoSuperMethodA (cl, (Object *)g, (Msg)msg))
62 fpd = (struct FrPropData *) INST_DATA(cl, g);
64 /* HACK: the gadgetclass copies the contents
65 * of the GA_LabelImage tag into the Gadget structure.
66 * We steal the frame from there and then clear it,
67 * otherwise the gadgetclass will try to draw the frame
70 fpd->Frame = (Object *) g->GadgetText;
72 g->Flags &= ~GFLG_LABELIMAGE;
74 /* Ask Intuition to send us GM_LAYOUT messages */
75 g->Flags |= GFLG_RELSPECIAL;
80 DB2(DBPRINTF("FrPropGClass: GM_LAYOUT\n");)
82 fpd = (struct FrPropData *) INST_DATA(cl, g);
88 /* Compute current gadget size */
89 GetGadgetBox(((struct gpLayout *)msg)->gpl_GInfo, g, &gbox);
91 DB2(DBPRINTF("FrPropGClass: GBox :%ld t:%ld w:%ld h:%ld\n",
92 fpd->FrameBox.Left, fpd->FrameBox.Top,
93 fpd->FrameBox.Width, fpd->FrameBox.Height);)
95 /* Calculate dimensions of our framing image */
96 DoMethod(fpd->Frame, IM_FRAMEBOX, &gbox, &fpd->FrameBox,
97 ((struct gpLayout *)msg)->gpl_GInfo->gi_DrInfo, 0);
99 break; /* go to DoSuperMethod() below */
102 if (((struct gpRender *)msg)->gpr_Redraw == GREDRAW_REDRAW)
104 fpd = (struct FrPropData *) INST_DATA(cl, g);
105 DB2(DBPRINTF("FrPropGClass: GM_RENDER - GREDRAW_REDRAW\n");)
106 ASSERT_VALID_PTR(fpd)
110 ASSERT_VALID_PTR(fpd->Frame)
111 DB2(DBPRINTF("FrPropGClass: Frame l:%ld t:%ld w:%ld h:%ld\n",
112 fpd->FrameBox.Left, fpd->FrameBox.Top,
113 fpd->FrameBox.Width, fpd->FrameBox.Height);)
115 DoMethod(fpd->Frame, IM_DRAWFRAME,
116 ((struct gpRender *)msg)->gpr_RPort, /* imp_RPort */
117 (fpd->FrameBox.Left << 16) | (fpd->FrameBox.Top), /* imp_Offset */
118 IDS_NORMAL, /* imp_State */
119 ((struct gpRender *)msg)->gpr_GInfo->gi_DrInfo, /* imp_DrInfo */
120 (fpd->FrameBox.Width << 16) | (fpd->FrameBox.Height)); /* imp_Dimensions */
123 break; /* go to DoSuperMethod() below */
130 /* This is a dirty workaround for a bug in the propgclass.
132 * It appears that the dispatcher of the propgclass detects
133 * when an object is made from a subclass. In this case,
134 * it stops sending itself the GM_REDRAW message when the
135 * PGA_#? attributes are updated. The result is that the
136 * prop does not update its visual when the attributes are
139 * The workaround we use here is to temporarly switch the
140 * object true class to propgclass before passing the
141 * OM_UPDATE method to our superclass.
143 oldclass = OCLASS(g);
144 OCLASS(g) = cl->cl_Super;
145 result = CoerceMethodA (cl->cl_Super, (Object *)g, msg);
146 OCLASS(g) = oldclass;
151 break; /* go to DoSuperMethod() below */
154 /* Super class handles everything */
155 return (DoSuperMethodA (cl, (Object *)g, msg));
160 Class * MakeFrPropGClass(void)
164 if (class = MakeClass (NULL, PROPGCLASS, NULL, sizeof(struct FrPropData), 0))
165 class->cl_Dispatcher.h_Entry = (ULONG (*)()) FrPropDispatcher;
172 BOOL FreeFrPropGClass(Class *cl)
174 return (FreeClass(cl));