Updated to latest source.
[AROS-Contrib.git] / bgui / screenreqclass.c
blobacee3cf35755247db6f717ea6e9191a70ee134db
1 /*
2 * @(#) $Header$
4 * BGUI library
5 * screenreqclass.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:02 stegerg
18 * another hundreds of REG() macro replacements in func headers/protos.
20 * Revision 42.0 2000/05/09 22:10:08 mlemos
21 * Bumped to revision 42.0 before handing BGUI to AROS team
23 * Revision 41.11 2000/05/09 19:55:03 mlemos
24 * Merged with the branch Manuel_Lemos_fixes.
26 * Revision 41.10 1998/02/25 21:13:04 mlemos
27 * Bumping to 41.10
29 * Revision 1.1 1998/02/25 17:09:42 mlemos
30 * Ian sources
35 #include "include/classdefs.h"
37 /// Class definitions.
39 * Object instance data.
41 typedef struct {
42 ULONG sd_DisplayID; /* Display mode ID */
43 ULONG sd_DisplayWidth; /* Width of display in pixels */
44 ULONG sd_DisplayHeight; /* Height of display in pixels */
45 UWORD sd_DisplayDepth; /* Number of bit-planes of display */
46 UWORD sd_OverscanType; /* Type of overscan of display */
47 BOOL sd_AutoScroll; /* Display should auto-scroll? */
49 BOOL sd_InfoOpen; /* Info window opened on exit? */
50 WORD sd_InfoLeft; /* Last coordinates of Info window */
51 WORD sd_InfoTop;
52 WORD sd_InfoWidth;
53 WORD sd_InfoHeight;
54 } SD;
56 ///
58 /// OM_NEW
60 * Create a shiny new object.
62 METHOD(ScreenReqClassNew, struct opSet *, ops)
64 ULONG rc;
65 struct TagItem *tags;
67 tags = DefTagList(BGUI_SCREENREQ_OBJECT, ops->ops_AttrList);
70 * First we let the superclass create the object.
72 if (rc = NewSuperObject(cl, obj, tags))
75 * Setup user attributes.
77 if (AsmCoerceMethod(cl, (Object *)rc, OM_SET, tags, NULL) != ASLREQ_OK)
80 * Failure.
82 AsmCoerceMethod(cl, (Object *)rc, OM_DISPOSE);
83 rc = 0;
86 FreeTagItems(tags);
88 return rc;
90 METHOD_END
91 ///
92 /// OM_DISPOSE
94 * They want us gone.
96 METHOD(ScreenReqClassDispose, Msg, msg)
99 * The superclass does the rest.
101 return AsmDoSuperMethodA(cl, obj, msg);
103 METHOD_END
105 /// OM_SET, OM_UPDATE
107 * Change one or more of the object
108 * it's attributes.
110 METHOD(ScreenReqClassSetUpdate, struct opSet *, ops)
112 SD *sd = INST_DATA(cl, obj);
113 struct TagItem *tstate = ops->ops_AttrList, *tag;
114 ULONG data, rc;
117 * First we let the superclass
118 * have a go at it.
120 rc = AsmDoSuperMethodA(cl, obj, (Msg)ops);
122 while (tag = NextTagItem(&tstate))
124 data = tag->ti_Data;
125 switch (tag->ti_Tag)
127 case ASLSM_InitialDisplayID:
128 case SCREENREQ_DisplayID:
129 sd->sd_DisplayID = data;
130 break;
131 case ASLSM_InitialDisplayWidth:
132 case SCREENREQ_DisplayWidth:
133 sd->sd_DisplayWidth = data;
134 break;
135 case ASLSM_InitialDisplayHeight:
136 case SCREENREQ_DisplayHeight:
137 sd->sd_DisplayHeight = data;
138 break;
139 case ASLSM_InitialDisplayDepth:
140 case SCREENREQ_DisplayDepth:
141 sd->sd_DisplayDepth = data;
142 break;
143 case ASLSM_InitialOverscanType:
144 case SCREENREQ_OverscanType:
145 sd->sd_OverscanType = data;
146 break;
147 case ASLSM_InitialAutoScroll:
148 case SCREENREQ_AutoScroll:
149 sd->sd_AutoScroll = data;
150 break;
153 return rc;
155 METHOD_END
157 /// OM_GET
159 * Give one of the attributes.
161 METHOD(ScreenReqClassGet, struct opGet *, opg)
163 SD *sd = INST_DATA(cl, obj);
164 ULONG rc = 1, *store = opg->opg_Storage, attr = opg->opg_AttrID;
166 switch (attr)
168 case ASLSM_InitialDisplayID:
169 case SCREENREQ_DisplayID:
170 STORE sd->sd_DisplayID;
171 break;
172 case ASLSM_InitialDisplayWidth:
173 case SCREENREQ_DisplayWidth:
174 STORE sd->sd_DisplayWidth;
175 break;
176 case ASLSM_InitialDisplayHeight:
177 case SCREENREQ_DisplayHeight:
178 STORE sd->sd_DisplayHeight;
179 break;
180 case ASLSM_InitialDisplayDepth:
181 case SCREENREQ_DisplayDepth:
182 STORE sd->sd_DisplayDepth;
183 break;
184 case ASLSM_InitialOverscanType:
185 case SCREENREQ_OverscanType:
186 STORE sd->sd_OverscanType;
187 break;
188 case ASLSM_InitialAutoScroll:
189 case SCREENREQ_AutoScroll:
190 STORE sd->sd_AutoScroll;
191 break;
192 default:
193 rc = AsmDoSuperMethodA(cl, obj, (Msg)opg);
194 break;
196 return rc;
198 METHOD_END
200 /// ASLM_DOREQUEST
202 * Pop up the ScreenRequester.
204 METHOD(ScreenReqClassDoRequest, Msg, msg)
206 SD *sd = INST_DATA(cl, obj);
207 struct ScreenModeRequester *sm;
208 ULONG rc = FRQ_OK;
210 DoSetMethodNG(obj, ASLSM_InitialDisplayWidth, sd->sd_DisplayWidth,
211 ASLSM_InitialDisplayHeight, sd->sd_DisplayHeight,
212 ASLSM_InitialDisplayDepth, sd->sd_DisplayDepth,
213 ASLSM_InitialDisplayID, sd->sd_DisplayID,
214 ASLSM_InitialOverscanType, sd->sd_OverscanType,
215 ASLSM_InitialAutoScroll, sd->sd_AutoScroll,
216 TAG_DONE);
218 if (sd->sd_InfoWidth)
220 DoSetMethodNG(obj, ASLSM_InitialInfoLeftEdge, sd->sd_InfoLeft,
221 ASLSM_InitialInfoTopEdge, sd->sd_InfoTop,
222 ASLSM_InitialInfoOpened, sd->sd_InfoOpen,
223 TAG_DONE);
227 * Allocate ScreenRequester structure.
229 if (sm = (struct ScreenModeRequester *)AsmDoSuperMethod(cl, obj, ASLM_ALLOCREQUEST))
232 * Put up the requester.
234 if (AsmDoSuperMethod(cl, obj, ASLM_REQUEST))
237 * Copy relevant info into our structure.
239 DoSetMethodNG(obj, SCREENREQ_DisplayWidth, sm->sm_DisplayWidth,
240 SCREENREQ_DisplayHeight, sm->sm_DisplayHeight,
241 SCREENREQ_DisplayDepth, sm->sm_DisplayDepth,
242 SCREENREQ_DisplayID, sm->sm_DisplayID,
243 SCREENREQ_OverscanType, sm->sm_OverscanType,
244 SCREENREQ_AutoScroll, sm->sm_AutoScroll,
245 TAG_DONE);
246 } else
247 rc = FRQ_CANCEL;
250 * Remember these even if the requester was cancelled.
252 DoSuperSetMethodNG(cl, obj, ASLREQ_Bounds, &sm->sm_LeftEdge, TAG_DONE);
254 sd->sd_InfoOpen = sm->sm_InfoOpened;
255 sd->sd_InfoLeft = sm->sm_InfoLeftEdge;
256 sd->sd_InfoTop = sm->sm_InfoTopEdge;
257 sd->sd_InfoWidth = sm->sm_InfoWidth;
258 sd->sd_InfoHeight = sm->sm_InfoHeight;
261 * Free the requester structure.
263 AsmDoSuperMethod(cl, obj, ASLM_FREEREQUEST);
264 } else
265 rc = ASLREQ_ERROR_NO_REQ;
267 return rc;
269 METHOD_END
272 /// Class initialization.
274 * Function table.
276 STATIC DPFUNC ClassFunc[] = {
277 OM_NEW, (FUNCPTR)ScreenReqClassNew,
278 OM_SET, (FUNCPTR)ScreenReqClassSetUpdate,
279 OM_UPDATE, (FUNCPTR)ScreenReqClassSetUpdate,
280 OM_GET, (FUNCPTR)ScreenReqClassGet,
281 OM_DISPOSE, (FUNCPTR)ScreenReqClassDispose,
282 ASLM_DOREQUEST, (FUNCPTR)ScreenReqClassDoRequest,
283 DF_END, NULL
287 * Simple class initialization.
289 makeproto Class *InitScreenReqClass(void)
291 return BGUI_MakeClass(CLASS_SuperClassBGUI, BGUI_ASLREQ_OBJECT,
292 CLASS_ObjectSize, sizeof(SD),
293 CLASS_DFTable, ClassFunc,
294 TAG_DONE);