fix remapping behavior. Remapping is only necessary if we are rendering on the workbe...
[AROS-Contrib.git] / bgui / areaclass.c
blob989847492d2fca84fc37ecff807d89bd8bc92b3b
1 /*
2 * @(#) $Header$
4 * BGUI library
5 * areaclass.c
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.
13 * $Log$
14 * Revision 42.2 2004/06/16 20:16:48 verhaegs
15 * Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
17 * Revision 42.1 2000/05/15 19:27:00 stegerg
18 * another hundreds of REG() macro replacements in func headers/protos.
20 * Revision 42.0 2000/05/09 22:08:11 mlemos
21 * Bumped to revision 42.0 before handing BGUI to AROS team
23 * Revision 41.11 2000/05/09 19:53:42 mlemos
24 * Merged with the branch Manuel_Lemos_fixes.
26 * Revision 41.10.2.1 1998/11/23 14:58:28 mlemos
27 * Made the BaseInfo pointer passed to DoNotifyMethod be casted to GadgetInfo
28 * pointer to avoid a compiler warning.
30 * Revision 41.10 1998/02/25 21:11:28 mlemos
31 * Bumping to 41.10
33 * Revision 1.1 1998/02/25 17:07:18 mlemos
34 * Ian sources
39 /// Class definitions.
40 #include "include/classdefs.h"
43 * Instance data.
45 typedef struct {
46 UWORD ad_MinWidth; /* Minimum width of area. */
47 UWORD ad_MinHeight; /* Minimum height of area. */
48 } AD;
49 ///
50 /// OM_NEW
51 METHOD(AreaClassNew, struct opSet *,ops)
53 AD *ad;
54 IPTR rc;
55 struct TagItem *tags, *tag;
56 struct TagItem *tstate;
58 tags = DefTagList(BGUI_AREA_GADGET, ops->ops_AttrList);
60 * Let the superclass create an object.
62 if ((rc = NewSuperObject(cl, obj, tags)))
64 ad = INST_DATA(cl, rc);
66 tstate = tags;
67 while ((tag = NextTagItem(&tstate)))
69 switch (tag->ti_Tag)
71 case AREA_MinWidth:
72 ad->ad_MinWidth = tag->ti_Data;
73 break;
74 case AREA_MinHeight:
75 ad->ad_MinHeight = tag->ti_Data;
76 break;
81 * Minimal width and height required!
83 if (!ad->ad_MinWidth || !ad->ad_MinHeight)
86 * Fail :(
88 AsmCoerceMethod(cl, (Object *)rc, OM_DISPOSE);
89 rc = 0;
92 FreeTagItems(tags);
94 return rc;
96 METHOD_END
97 ///
98 /// OM_GET
99 METHOD(AreaClassGet, struct opGet *,opg)
101 AD *ad = INST_DATA(cl, obj);
102 BC *bc = BASE_DATA(obj);
103 ULONG rc = 1;
104 IPTR *store = opg->opg_Storage;
106 switch (opg->opg_AttrID)
108 case AREA_AreaBox:
110 * Simply return a pointer to the area
111 * which is computed at rendering time.
113 STORE &bc->bc_InnerBox;
114 break;
115 case AREA_MinWidth:
116 STORE ad->ad_MinWidth;
117 break;
118 case AREA_MinHeight:
119 STORE ad->ad_MinHeight;
120 break;
121 default:
122 rc = AsmDoSuperMethodA(cl, obj, (Msg)opg);
123 break;
125 return rc;
127 METHOD_END
129 /// BASE_RENDER
131 METHOD(AreaClassRender, struct bmRender *,bmr)
134 * Render the baseclass.
136 AsmDoSuperMethodA(cl, obj, (Msg)bmr);
139 * Notify the main program.
141 DoNotifyMethod(obj, (struct GadgetInfo *)bmr->bmr_BInfo, 0, GA_ID, GADGET(obj)->GadgetID, TAG_DONE);
143 return 1;
145 METHOD_END
147 /// GM_HITTEST
149 * This object cannot be hit.
151 METHOD(AreaClassHitTest, Msg, msg)
153 return 0;
155 METHOD_END
157 /// BASE_DIMENSIONS
159 * Simple dimensions request.
161 METHOD(AreaClassDimensions, struct bmDimensions *,bmd)
163 AD *ad = INST_DATA(cl, obj);
166 * We simply add the specified minimum width and height
167 * which are passed to us at create time.
169 return CalcDimensions(cl, obj, bmd, ad->ad_MinWidth, ad->ad_MinHeight);
171 METHOD_END
173 /// Class initialization.
175 * Class function table.
177 STATIC DPFUNC ClassFunc[] = {
178 { OM_NEW, (FUNCPTR)AreaClassNew, },
179 { OM_GET, (FUNCPTR)AreaClassGet, },
180 { BASE_RENDER, (FUNCPTR)AreaClassRender, },
181 { BASE_DIMENSIONS, (FUNCPTR)AreaClassDimensions, },
182 { GM_HITTEST, (FUNCPTR)AreaClassHitTest, },
183 { DF_END },
187 * Simple class initialization.
189 makeproto Class *InitAreaClass(void)
191 return BGUI_MakeClass(CLASS_SuperClassBGUI, BGUI_BASE_GADGET,
192 CLASS_ObjectSize, sizeof(AD),
193 CLASS_DFTable, ClassFunc,
194 TAG_DONE);