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.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:01 stegerg
18 * another hundreds of REG() macro replacements in func headers/protos.
20 * Revision 42.0 2000/05/09 22:09:14 mlemos
21 * Bumped to revision 42.0 before handing BGUI to AROS team
23 * Revision 41.11 2000/05/09 19:54:27 mlemos
24 * Merged with the branch Manuel_Lemos_fixes.
26 * Revision 41.10.2.1 1998/11/29 22:51:52 mlemos
27 * Removed needless code of OM_GET.
29 * Revision 41.10 1998/02/25 21:12:18 mlemos
32 * Revision 1.1 1998/02/25 17:08:37 mlemos
38 /// Class definitions.
39 #include "include/classdefs.h"
42 * Object instance data.
45 ULONG id_Flags
; /* See below. */
46 Object
*id_Text
; /* Text graphic. */
47 UWORD id_MinLines
; /* Minimum Number of lines displayed. */
50 #define IDF_FIXWIDTH (1<<0) /* Width not smaller than the text. */
51 #define IDF_FIXHEIGHT (1<<1) /* Width not smaller than the text. */
56 * Create a shiny new object.
58 METHOD(InfoClassNew
, struct opSet
*, ops
)
65 tags
= DefTagList(BGUI_INFO_GADGET
, ops
->ops_AttrList
);
68 * First we let the superclass setup an object for us.
70 if ((rc
= NewSuperObject(cl
, obj
, tags
)))
72 id
= INST_DATA(cl
, rc
);
74 if ((id
->id_Text
= BGUI_NewObject(BGUI_TEXT_GRAPHIC
, TEXTA_CopyText
, TRUE
, TAG_DONE
)))
77 * Pick up frame offsets.
79 ho
= GetTagData(INFO_HorizOffset
, 8, tags
);
80 vo
= GetTagData(INFO_VertOffset
, 6, tags
);
85 DoSetMethodNG((Object
*)rc
, BT_LeftOffset
, ho
, BT_RightOffset
, ho
, BT_TopOffset
, vo
, BT_BottomOffset
, vo
,
93 AsmCoerceMethod(cl
, (Object
*)rc
, OM_DISPOSE
);
103 /// OM_SET, OM_UPDATE
105 * Change the object attributes.
107 METHOD(InfoClassSetUpdate
, struct opSet
*, ops
)
109 ID
*id
= INST_DATA(cl
, obj
);
110 struct TagItem
*tstate
= ops
->ops_AttrList
;
116 * First we let the superclass have a go at it.
118 AsmDoSuperMethodA(cl
, obj
, (Msg
)ops
);
121 * Change attributes we know.
123 while ((tag
= NextTagItem(&tstate
)))
128 case INFO_TextFormat
:
130 DoSetMethodNG(id
->id_Text
, TEXTA_Text
, data
, TAG_DONE
);
135 DoSetMethodNG(id
->id_Text
, TEXTA_Args
, data
, TAG_DONE
);
139 id
->id_MinLines
= data
;
142 case INFO_FixTextWidth
:
143 if (data
) id
->id_Flags
|= IDF_FIXWIDTH
;
144 else id
->id_Flags
&= ~IDF_FIXWIDTH
;
147 case INFO_FixTextHeight
:
148 if (data
) id
->id_Flags
|= IDF_FIXHEIGHT
;
149 else id
->id_Flags
&= ~IDF_FIXHEIGHT
;
157 if (id
->id_MinLines
< 1) id
->id_MinLines
= 1;
162 if (vc
&& ops
->ops_GInfo
) DoRenderMethod(obj
, ops
->ops_GInfo
, GREDRAW_REDRAW
);
172 METHOD(InfoClassRender
, struct bmRender
*, bmr
)
174 ID
*id
= INST_DATA(cl
, obj
);
175 BC
*bc
= BASE_DATA(obj
);
176 struct BaseInfo
*bi
= bmr
->bmr_BInfo
;
179 * Render the baseclass.
181 AsmDoSuperMethodA(cl
, obj
, (Msg
)bmr
);
186 if (bc
->bc_TextFont
) BSetFont(bi
, bc
->bc_TextFont
);
191 BSetDPenA(bi
, TEXTPEN
);
192 DoMethod(id
->id_Text
, TEXTM_RENDER
, bi
, &bc
->bc_InnerBox
);
200 * We do not respond to clicking.
202 METHOD(InfoClassHitTest
, struct gpHitTest
*, gph
)
210 * Dispose of ourselves.
212 METHOD(InfoClassDispose
, Msg
, msg
)
214 ID
*id
= INST_DATA(cl
, obj
);
217 * Free the text graphic.
219 if (id
->id_Text
) DisposeObject(id
->id_Text
);
221 return AsmDoSuperMethodA(cl
, obj
, msg
);
227 * They want our dimensions.
229 METHOD(InfoClassDimensions
, struct bmDimensions
*, bmd
)
231 ID
*id
= INST_DATA(cl
, obj
);
232 BC
*bc
= BASE_DATA(obj
);
233 struct BaseInfo
*bi
= bmd
->bmd_BInfo
;
239 if (bc
->bc_TextFont
) BSetFont(bi
, bc
->bc_TextFont
);
241 DoMethod(id
->id_Text
, TEXTM_DIMENSIONS
, bi
->bi_RPort
, &mw
, &mh
);
246 if (!(id
->id_Flags
& IDF_FIXWIDTH
)) mw
= 16;
247 if (!(id
->id_Flags
& IDF_FIXHEIGHT
)) mh
= id
->id_MinLines
* bi
->bi_RPort
->TxHeight
;
249 return CalcDimensions(cl
, obj
, bmd
, mw
, mh
);
253 /// Class initialization.
257 STATIC DPFUNC ClassFunc
[] = {
258 { BASE_RENDER
, InfoClassRender
, },
259 { BASE_DIMENSIONS
, InfoClassDimensions
, },
261 { OM_NEW
, InfoClassNew
, },
262 { OM_SET
, InfoClassSetUpdate
, },
263 { OM_UPDATE
, InfoClassSetUpdate
, },
264 { OM_DISPOSE
, InfoClassDispose
, },
265 { GM_HITTEST
, InfoClassHitTest
, },
270 * Simple class initialization.
272 makeproto Class
*InitInfoClass( void )
274 return BGUI_MakeClass(CLASS_SuperClassBGUI
, BGUI_BASE_GADGET
,
275 CLASS_ObjectSize
, sizeof(ID
),
276 CLASS_DFTable
, ClassFunc
,