7 * (C) Copyright 1998 Manuel Lemos.
8 * (C) Copyright 1996-1997 Ian J. Einman.
9 * (C) Copyright 1993-1996 Jaba Development.
10 * (C) Copyright 1993-1996 Jan van den Baard.
11 * All Rights Reserved.
14 * Revision 42.6 2004/06/16 20:16:48 verhaegs
15 * Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
17 * Revision 42.5 2003/01/18 19:09:56 chodorowski
18 * Instead of using the _AROS or __AROS preprocessor symbols, use __AROS__.
20 * Revision 42.4 2000/08/09 11:45:57 chodorowski
21 * Removed a lot of #ifdefs that disabled the AROS_LIB* macros when not building on AROS. This is now handled in contrib/bgui/include/bgui_compilerspecific.h.
23 * Revision 42.3 2000/05/29 00:40:23 bergers
24 * Update to compile with AROS now. Should also still compile with SASC etc since I only made changes that test the define __AROS__. The compilation is still very noisy but it does the trick for the main directory. Maybe members of the BGUI team should also have a look at the compiler warnings because some could also cause problems on other systems... (Comparison always TRUE due to datatype (or something like that)). And please compile it on an Amiga to see whether it still works... Thanks.
26 * Revision 42.2 2000/05/15 19:27:01 stegerg
27 * another hundreds of REG() macro replacements in func headers/protos.
29 * Revision 42.1 2000/05/14 23:32:47 stegerg
30 * changed over 200 function headers which all use register
31 * parameters (oh boy ...), because the simple REG() macro
32 * doesn't work with AROS. And there are still hundreds
33 * of headers left to be fixed :(
35 * Many of these functions would also work with stack
36 * params, but since i have fixed every single one
37 * I encountered up to now, I guess will have to do
38 * the same for the rest.
40 * Revision 42.0 2000/05/09 22:08:48 mlemos
41 * Bumped to revision 42.0 before handing BGUI to AROS team
43 * Revision 41.11 2000/05/09 19:54:10 mlemos
44 * Merged with the branch Manuel_Lemos_fixes.
46 * Revision 41.10 1998/02/25 21:11:55 mlemos
49 * Revision 1.1 1998/02/25 17:08:03 mlemos
55 /// Class definitions.
56 #include "include/classdefs.h"
59 Object
*dd_Target
; /* Target object. */
60 struct Window
*dd_Window
; /* Target window. */
65 METHOD(DGMClassSet
, struct opSet
*, ops
)
67 DD
*dd
= INST_DATA(cl
, obj
);
69 struct TagItem
*tstate
= ops
->ops_AttrList
;
70 struct IntuiMessage
*imsg
;
73 BOOL domethod
= FALSE
;
78 while ((tag
= NextTagItem(&tstate
)))
84 * Pickup result storage. We return the result
85 * in a pointer passed to us to avoid the system
86 * glitch (or is it a real bug?).
88 res
= ( IPTR
* )tag
->ti_Data
;
93 * Pickup target object.
95 dd
->dd_Target
= (Object
*)tag
->ti_Data
;
99 if ((imsg
= (struct IntuiMessage
*)(tag
->ti_Data
)))
101 dd
->dd_Window
= imsg
->IDCMPWindow
;
103 dd
->ie
.ie_NextEvent
= NULL
;
104 dd
->ie
.ie_Class
= IECLASS_RAWMOUSE
;
105 dd
->ie
.ie_Code
= imsg
->Code
;
106 dd
->ie
.ie_Qualifier
= imsg
->Qualifier
;
107 dd
->ie
.ie_X
= imsg
->MouseX
;
108 dd
->ie
.ie_Y
= imsg
->MouseY
;
116 * Get a pointer to the message.
118 ptr
= (IPTR
*)tag
->ti_Data
;
121 * What kind of method?
130 * These get the GadgetInfo as the
133 ptr
[2] = (IPTR
)ops
->ops_GInfo
;
138 * All the rest get it at the
141 ptr
[1] = (IPTR
)ops
->ops_GInfo
;
155 *res
= AsmDoMethodA(dd
->dd_Target
, (Msg
)ptr
);
157 * Return result for compatibility reasons.
166 /// BGUI_DoGadgetMethod(obj, win, req)
168 * Emulate the OS 3.0 DoGadgetMethod call.
170 makeproto ULONG
myDoGadgetMethod(Object
*obj
, struct Window
*win
, struct Requester
*req
, IPTR methodid
, ... )
172 AROS_SLOWSTACKMETHODS_PRE(methodid
)
173 retval
= BGUI_DoGadgetMethodA(obj
, win
, req
, AROS_SLOWSTACKMETHODS_ARG(methodid
));
174 AROS_SLOWSTACKMETHODS_POST
178 * Emulate the intuition DoGadgetMethod() call.
182 AROS_LH4(ULONG
, BGUI_DoGadgetMethodA
,
183 AROS_LHA(Object
*, obj
, A0
),
184 AROS_LHA(struct Window
*, win
, A1
),
185 AROS_LHA(struct Requester
*, req
, A2
),
186 AROS_LHA(Msg
, msg
, A3
),
187 struct Library
*, BGUIBase
, 11, BGUI
)
189 makeproto SAVEDS ASM ULONG
BGUI_DoGadgetMethodA( REG(a0
) Object
*obj
, REG(a1
) struct Window
*win
, REG(a2
) struct Requester
*req
, REG(a3
) Msg msg
)
203 * Create DGMClass object.
205 if ((dgm
= BGUI_NewObjectA(BGUI_DGM_OBJECT
, NULL
)))
208 * Send of method to the target. We simple pass the DGMClass
209 * a pointer to the result storage, the target object and the
210 * method to send and the class takes care of the rest :)
212 SetGadgetAttrs((struct Gadget
*)dgm
, win
, req
, DGM_Result
, &rc
, DGM_Object
, obj
, DGM_DoMethod
, msg
, TAG_END
);
215 * Dispose of the object.
217 AsmDoMethod(dgm
, OM_DISPOSE
);
227 * Fall back to the AsmDoMethod() call if
228 * an important argument is missing.
230 return (ULONG
)AsmDoMethodA(obj
, msg
);
235 /// GM_GOACTIVE, GM_HANDLEINPUT
236 METHOD(DGMClassGoActive
, struct gpInput
*, gpi2
)
238 DD
*dd
= INST_DATA(cl
, obj
);
239 struct gpInput gpi
= *gpi2
;
240 struct IBox
*bounds
= NULL
;
242 Object
*target
= dd
->dd_Target
;
246 if (gpi
.MethodID
== GM_GOACTIVE
)
247 gpi
.gpi_IEvent
= &dd
->ie
;
249 Get_Attr(target
, BT_HitBox
, (IPTR
*)&bounds
);
252 gpi
.gpi_Mouse
.X
= gpi
.gpi_GInfo
->gi_Window
->MouseX
- bounds
->Left
;
253 gpi
.gpi_Mouse
.Y
= gpi
.gpi_GInfo
->gi_Window
->MouseY
- bounds
->Top
;
257 * Forward the message to the target.
259 SetGadgetAttrs((struct Gadget
*)obj
, dd
->dd_Window
, NULL
,
260 DGM_Result
, &rc
, DGM_Object
, target
, DGM_DoMethod
, &gpi
, TAG_END
);
267 METHOD(DGMClassGoInactive
, Msg
, msg
)
269 DD
*dd
= INST_DATA(cl
, obj
);
272 IPTR mouseact
= 0, report
= FALSE
;
273 Object
*win
= NULL
, *target
;
275 if ((target
= dd
->dd_Target
))
277 Get_Attr(target
, BT_ReportID
, &report
);
278 Get_Attr(target
, BT_ParentWindow
, (IPTR
*)&win
);
279 Get_Attr(target
, BT_MouseActivation
, &mouseact
);
281 * Forward the message to the target.
283 SetGadgetAttrs((struct Gadget
*)obj
, dd
->dd_Window
, NULL
,
284 DGM_Result
, &rc
, DGM_Object
, target
, DGM_DoMethod
, msg
, TAG_END
);
288 id
= GADGET(target
)->GadgetID
;
289 if (dd
->ie
.ie_Code
== IECODE_RBUTTON
)
291 AsmDoMethod(win
, WM_REPORT_ID
, id
| WMHI_RMB
, 0);
293 if (dd
->ie
.ie_Code
== IECODE_MBUTTON
)
295 AsmDoMethod(win
, WM_REPORT_ID
, id
| WMHI_MMB
, 0);
303 /// Class initialization.
305 * Class function table.
307 STATIC DPFUNC ClassFunc
[] = {
308 { OM_SET
, DGMClassSet
},
309 { GM_GOACTIVE
, DGMClassGoActive
},
310 { GM_HANDLEINPUT
, DGMClassGoActive
},
311 { GM_GOINACTIVE
, DGMClassGoInactive
},
316 * Simple class initialization.
318 makeproto Class
*InitDGMClass(void)
320 return BGUI_MakeClass(CLASS_SuperClassID
, GadgetClass
,
321 CLASS_ObjectSize
, sizeof(DD
),
322 CLASS_DFTable
, ClassFunc
,
328 * I have created this class for two main reasons:
330 * 1) OS 2.04 compatibility. This way we _always_ get a system build
331 * GadgetInfo structure no matter what OS we run on since the
332 * SetGadgetAttrs() call has been available since V36 (OS 2.0)
335 * 2) I am having trouble with the OS 3.0 DoGadgetMethod() call which
336 * does not always returns the result of the called method. Don't
337 * ask why, it just doesn't.
339 * With the aid of this class I get compatibility from OS 2.04 and up
340 * and I work around what seems to be an OS bug while doing it. The only
341 * bad thing may be the (slight) overhead.