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:08:56 mlemos
21 * Bumped to revision 42.0 before handing BGUI to AROS team
23 * Revision 41.11 2000/05/09 19:54:15 mlemos
24 * Merged with the branch Manuel_Lemos_fixes.
26 * Revision 41.10.2.1 1999/08/11 02:30:38 mlemos
27 * Assured that the initial values passed to the font requester match the
28 * defaults of the ASLRequest() call.
30 * Revision 41.10 1998/02/25 21:12:02 mlemos
33 * Revision 1.1 1998/02/25 17:08:16 mlemos
39 #include "include/classdefs.h"
41 /// Class definitions.
43 * Object instance data.
46 struct TextAttr fd_TextAttr
; /* Selected font */
47 UBYTE fd_Name
[MAX_FILE
+ 2]; /* Fontname buffer */
48 UBYTE fd_FrontPen
; /* Selected FrontPen */
49 UBYTE fd_BackPen
; /* Selected BackPen */
50 UBYTE fd_DrawMode
; /* Selected DrawMode */
56 * Create a shiny new object.
58 METHOD(FontReqClassNew
, struct opSet
*, ops
)
63 tags
= DefTagList(BGUI_FONTREQ_OBJECT
, ops
->ops_AttrList
);
66 * First we let the superclass create the object.
68 if ((rc
= NewSuperObject(cl
, obj
, tags
)))
70 FD
*fd
= INST_DATA(cl
, rc
);
73 fd
->fd_TextAttr
.ta_YSize
=8;
74 fd
->fd_TextAttr
.ta_Style
=FS_NORMAL
;
75 fd
->fd_TextAttr
.ta_Flags
=FPF_ROMFONT
;
81 * Setup user attributes.
83 if (AsmCoerceMethod(cl
, (Object
*)rc
, OM_SET
, tags
, NULL
) != ASLREQ_OK
)
88 AsmCoerceMethod(cl
, (Object
*)rc
, OM_DISPOSE
);
102 METHOD(FontReqClassDispose
, Msg
, msg
)
105 * The superclass does the rest.
107 return AsmDoSuperMethodA(cl
, obj
, msg
);
111 /// OM_SET, OM_UPDATE
113 * Change one or more of the object
116 METHOD(FontReqClassSetUpdate
, struct opSet
*, ops
)
118 FD
*fd
= INST_DATA(cl
, obj
);
120 struct TagItem
*tstate
= ops
->ops_AttrList
;
124 * First we let the superclass
127 rc
= AsmDoSuperMethodA(cl
, obj
, (Msg
)ops
);
129 while ((tag
= NextTagItem(&tstate
)))
134 case ASLFO_InitialName
:
137 if (data
) strncpy(fd
->fd_Name
, (char *)data
, MAX_FILE
);
139 case ASLFO_InitialSize
:
141 fd
->fd_TextAttr
.ta_YSize
= data
;
143 case ASLFO_InitialStyle
:
145 fd
->fd_TextAttr
.ta_Style
= data
;
147 case ASLFO_InitialFlags
:
149 fd
->fd_TextAttr
.ta_Flags
= data
;
151 case ASLFO_InitialFrontPen
:
152 case FONTREQ_FrontPen
:
153 fd
->fd_FrontPen
= data
;
155 case ASLFO_InitialBackPen
:
156 case FONTREQ_BackPen
:
157 fd
->fd_BackPen
= data
;
159 case ASLFO_InitialDrawMode
:
160 case FONTREQ_DrawMode
:
161 fd
->fd_DrawMode
= data
;
163 case FONTREQ_TextAttr
:
167 fd
->fd_TextAttr
= *((struct TextAttr
*)data
);
168 if (fd
->fd_TextAttr
.ta_Name
)
169 strncpy(fd
->fd_Name
, fd
->fd_TextAttr
.ta_Name
, MAX_FILE
);
170 fd
->fd_TextAttr
.ta_Name
= fd
->fd_Name
;
181 * Give one of the attributes.
183 METHOD(FontReqClassGet
, struct opGet
*, opg
)
185 FD
*fd
= INST_DATA(cl
, obj
);
187 IPTR
*store
= opg
->opg_Storage
;
188 IPTR attr
= opg
->opg_AttrID
;
192 case ASLFO_InitialName
:
196 case ASLFO_InitialSize
:
198 STORE fd
->fd_TextAttr
.ta_YSize
;
200 case ASLFO_InitialStyle
:
202 STORE fd
->fd_TextAttr
.ta_Style
;
204 case ASLFO_InitialFlags
:
206 STORE fd
->fd_TextAttr
.ta_Flags
;
208 case ASLFO_InitialFrontPen
:
209 case FONTREQ_FrontPen
:
210 STORE fd
->fd_FrontPen
;
212 case ASLFO_InitialBackPen
:
213 case FONTREQ_BackPen
:
214 STORE fd
->fd_BackPen
;
216 case ASLFO_InitialDrawMode
:
217 case FONTREQ_DrawMode
:
218 STORE fd
->fd_DrawMode
;
220 case FONTREQ_TextAttr
:
221 STORE
&fd
->fd_TextAttr
;
224 rc
= AsmDoSuperMethodA(cl
, obj
, (Msg
)opg
);
233 * Pop up the FontRequester.
235 METHOD(FontReqClassDoRequest
, Msg
, msg
)
237 FD
*fd
= INST_DATA(cl
, obj
);
238 struct FontRequester
*fo
;
239 ULONG rc
= ASLREQ_OK
;
241 DoSuperSetMethodNG(cl
, obj
, ASLFO_InitialName
, fd
->fd_Name
,
242 ASLFO_InitialSize
, fd
->fd_TextAttr
.ta_YSize
,
243 ASLFO_InitialStyle
, fd
->fd_TextAttr
.ta_Style
,
244 ASLFO_InitialFlags
, fd
->fd_TextAttr
.ta_Flags
,
245 ASLFO_InitialFrontPen
, fd
->fd_FrontPen
,
246 ASLFO_InitialBackPen
, fd
->fd_BackPen
,
247 ASLFO_InitialDrawMode
, fd
->fd_DrawMode
, TAG_DONE
);
250 * Allocate FontRequester structure.
252 if ((fo
= (struct FontRequester
*)AsmDoSuperMethod(cl
, obj
, ASLM_ALLOCREQUEST
)))
255 * Put up the requester.
257 if (AsmDoSuperMethod(cl
, obj
, ASLM_REQUEST
))
260 * Copy font information.
262 DoSetMethodNG(obj
, FONTREQ_TextAttr
, &fo
->fo_Attr
,
263 FONTREQ_FrontPen
, fo
->fo_FrontPen
,
264 FONTREQ_BackPen
, fo
->fo_BackPen
,
265 FONTREQ_DrawMode
, fo
->fo_DrawMode
, TAG_DONE
);
269 * Remember these even if the requester was cancelled.
271 DoSuperSetMethodNG(cl
, obj
, ASLREQ_Bounds
, &fo
->fo_LeftEdge
, TAG_DONE
);
274 * Free the requester structure.
276 AsmDoSuperMethod(cl
, obj
, ASLM_FREEREQUEST
);
278 rc
= ASLREQ_ERROR_NO_REQ
;
285 /// Class initialization.
289 STATIC DPFUNC ClassFunc
[] = {
290 { OM_NEW
, FontReqClassNew
, },
291 { OM_SET
, FontReqClassSetUpdate
, },
292 { OM_UPDATE
, FontReqClassSetUpdate
, },
293 { OM_GET
, FontReqClassGet
, },
294 { OM_DISPOSE
, FontReqClassDispose
, },
295 { ASLM_DOREQUEST
, FontReqClassDoRequest
, },
300 * Simple class initialization.
302 makeproto Class
*InitFontReqClass(void)
304 return BGUI_MakeClass(CLASS_SuperClassBGUI
, BGUI_ASLREQ_OBJECT
,
305 CLASS_ObjectSize
, sizeof(FD
),
306 CLASS_DFTable
, ClassFunc
,