added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / prefs / screenmode / smproperties.c
blobe65b439696236794f1fb13a1e3b0a036c2d195a7
1 /*
2 Copyright © 2003-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define MUIMASTER_YES_INLINE_STDARG
7 #define DEBUG 0
9 #include <libraries/mui.h>
11 #include <proto/exec.h>
12 #include <proto/muimaster.h>
13 #include <proto/intuition.h>
14 #include <proto/graphics.h>
15 #include <proto/utility.h>
17 #include <zune/customclasses.h>
19 #include "locale.h"
21 #include "smproperties.h"
23 struct ScreenModeProperties_DATA
25 Object *width, *height, *depth,
26 *def_width, *def_height;
28 Object *autoscroll;
30 ULONG DisplayID;
33 #define CheckMarkObject \
34 ImageObject, \
35 ImageButtonFrame, \
36 MUIA_InputMode , MUIV_InputMode_Toggle, \
37 MUIA_Image_Spec , MUII_CheckMark, \
38 MUIA_Image_FreeVert , TRUE, \
39 MUIA_Background , MUII_ButtonBack, \
40 MUIA_ShowSelState , FALSE
42 #define HLeft(obj...) \
43 (IPTR)(HGroup, (IPTR)GroupSpacing(0), Child, (IPTR)(obj), Child, (IPTR)HSpace(0), End)
45 #undef HCenter
46 #define HCenter(obj...) \
47 (HGroup, (IPTR)GroupSpacing(0), Child, (IPTR)HSpace(0), Child, (IPTR)(obj), Child, \
48 (IPTR)HSpace(0), End)
50 Object *ScreenModeProperties__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
52 struct ScreenModeProperties_DATA *data;
53 Object *width, *height, *depth,
54 *def_width, *def_height;
56 Object *autoscroll;
58 ULONG id;
60 self = (Object *)DoSuperNewTags
62 CLASS, self, NULL,
63 MUIA_Group_Horiz, TRUE,
64 Child, (IPTR)ColGroup(4),
65 Child, (IPTR)Label1(__(MSG_WIDTH)),
66 Child, HLeft(width = NumericbuttonObject, End),
67 Child, (IPTR)(def_width = CheckMarkObject, End),
68 Child, (IPTR)Label1(__(MSG_DEFAULT)),
70 Child, (IPTR)Label1(__(MSG_HEIGHT)),
71 Child, HLeft(height = NumericbuttonObject, End),
72 Child, (IPTR)(def_height = CheckMarkObject, End),
73 Child, (IPTR)Label1(__(MSG_DEFAULT)),
75 Child, (IPTR)Label1(__(MSG_DEPTH)),
76 Child, HLeft(depth = NumericbuttonObject, End),
77 Child, (IPTR)RectangleObject, End,
78 Child, (IPTR)RectangleObject, End,
79 End,
81 Child, (IPTR)MUI_MakeObject(MUIO_VBar, 20),
83 Child, (IPTR)HCenter(HGroup,
84 Child, (IPTR)Label1(__(MSG_AUTOSCROLL)),
85 Child, (IPTR)(autoscroll = CheckMarkObject, End),
86 End),
88 TAG_MORE, (IPTR)message->ops_AttrList
91 if (!self)
92 goto err;
94 data = INST_DATA(CLASS, self);
96 data->width = width;
97 data->height = height;
98 data->depth = depth;
99 data->def_width = def_width;
100 data->def_height = def_height;
101 data->autoscroll = autoscroll;
103 DoMethod
105 width, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime,
106 (IPTR)self, 3,
107 MUIM_Set, MUIA_ScreenModeProperties_Width, MUIV_TriggerValue
110 DoMethod
112 height, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime,
113 (IPTR)self, 3,
114 MUIM_Set, MUIA_ScreenModeProperties_Height, MUIV_TriggerValue
117 DoMethod
119 depth, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime,
120 (IPTR)self, 3,
121 MUIM_Set, MUIA_ScreenModeProperties_Depth, MUIV_TriggerValue
124 DoMethod
126 def_width, MUIM_Notify, MUIA_Selected, TRUE,
127 (IPTR)width, 1,
128 MUIM_Numeric_SetDefault
131 DoMethod
133 width, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime,
134 (IPTR)def_width, 3,
135 MUIM_Set, MUIA_Selected, FALSE
138 DoMethod
140 def_height, MUIM_Notify, MUIA_Selected, TRUE,
141 (IPTR)height, 1,
142 MUIM_Numeric_SetDefault
145 DoMethod
147 height, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime,
148 (IPTR)def_height, 3,
149 MUIM_Set, MUIA_Selected, FALSE
152 id = GetTagData(MUIA_ScreenModeProperties_DisplayID, INVALID_ID, message->ops_AttrList);
153 set(self, MUIA_ScreenModeProperties_DisplayID, id);
155 return self;
157 err:
158 CoerceMethod(CLASS, self, OM_DISPOSE);
159 return NULL;
162 IPTR ScreenModeProperties__OM_SET(Class *CLASS, Object *self, struct opSet *message)
164 struct ScreenModeProperties_DATA *data = INST_DATA(CLASS, self);
165 const struct TagItem *tags;
166 struct TagItem *tag;
167 struct TagItem noforward_tags[] =
169 {MUIA_Group_Forward , FALSE },
170 {TAG_MORE , (IPTR)message->ops_AttrList }
172 struct opSet noforward_message = *message;
173 noforward_message.ops_AttrList = noforward_tags;
175 ULONG id = INVALID_ID;
176 IPTR no_notify = TAG_IGNORE;
178 for (tags = message->ops_AttrList; (tag = NextTagItem(&tags)); )
180 switch (tag->ti_Tag)
182 case MUIA_NoNotify:
183 no_notify = MUIA_NoNotify;
184 break;
186 case MUIA_ScreenModeProperties_DisplayID:
188 struct TagItem width_tags[] =
190 { no_notify, TRUE },
191 { MUIA_Numeric_Min, 0 },
192 { MUIA_Numeric_Max, 0 },
193 { MUIA_Numeric_Default, 0 },
194 { TAG_DONE, 0 }
196 struct TagItem height_tags[] =
198 { no_notify, TRUE },
199 { MUIA_Numeric_Min, 0 },
200 { MUIA_Numeric_Max, 0 },
201 { MUIA_Numeric_Default, 0 },
202 { TAG_DONE, 0 }
204 struct TagItem depth_tags[] =
206 { no_notify, TRUE },
207 { MUIA_Numeric_Min, 0 },
208 { MUIA_Numeric_Max, 0 },
209 { MUIA_Numeric_Default, 0 },
210 { TAG_DONE, 0 }
213 struct DimensionInfo dim;
215 BOOL autoscroll;
217 if (GetDisplayInfoData(NULL, (UBYTE *)&dim, sizeof(dim), DTAG_DIMS, tag->ti_Data))
219 width_tags[1].ti_Data = dim.MinRasterWidth;
220 height_tags[1].ti_Data = dim.MinRasterHeight;
221 depth_tags[1].ti_Data = 1;
223 width_tags[2].ti_Data = dim.MaxRasterWidth;
224 height_tags[2].ti_Data = dim.MaxRasterHeight;
225 depth_tags[2].ti_Data = dim.MaxDepth;
227 width_tags[3].ti_Data = dim.Nominal.MaxX - dim.Nominal.MinX + 1;
228 height_tags[3].ti_Data = dim.Nominal.MaxY - dim.Nominal.MinY + 1;
229 depth_tags[3].ti_Data = dim.MaxDepth;
231 id = tag->ti_Data;
234 /* Enable autoscroll only if the maximum sizes are bigger than
235 the resolution. */
237 autoscroll = width_tags[2].ti_Data > width_tags[3].ti_Data &&
238 height_tags[2].ti_Data > height_tags[3].ti_Data;
240 data->DisplayID = id;
241 nfset(self, MUIA_Disabled, id == INVALID_ID);
243 SetAttrsA(data->width, width_tags);
244 SetAttrsA(data->height, height_tags);
245 SetAttrsA(data->depth, depth_tags);
247 SetAttrs(data->autoscroll, no_notify, TRUE,
248 MUIA_Disabled, !autoscroll,
249 MUIA_Selected, autoscroll,
250 TAG_DONE);
252 break;
255 case MUIA_ScreenModeProperties_Width:
256 if (id != INVALID_ID)
258 WORD width = tag->ti_Data;
259 if (width != -1)
260 SetAttrs(data->width, no_notify, TRUE, MUIA_Numeric_Value, width, TAG_DONE);
261 else
262 DoMethod(data->width, MUIM_Numeric_SetDefault);
264 nnset(data->def_width, MUIA_Selected, width == -1);
266 break;
268 case MUIA_ScreenModeProperties_Height:
269 if (id != INVALID_ID)
271 WORD height = tag->ti_Data;
272 if (height != -1)
273 SetAttrs(data->height, no_notify, TRUE, MUIA_Numeric_Value, height, TAG_DONE);
274 else
275 DoMethod(data->height, MUIM_Numeric_SetDefault);
277 nnset(data->def_height, MUIA_Selected, height == -1);
279 break;
281 case MUIA_ScreenModeProperties_Depth:
282 if (id != INVALID_ID)
284 WORD depth = tag->ti_Data;
285 if (depth != -1)
286 SetAttrs(data->depth, no_notify, TRUE, MUIA_Numeric_Value, depth, TAG_DONE);
287 else
288 DoMethod(data->depth, MUIM_Numeric_SetDefault);
290 break;
292 case MUIA_ScreenModeProperties_Autoscroll:
293 if (id != INVALID_ID && !XGET(data->autoscroll, MUIA_Disabled))
294 SetAttrs(data->autoscroll, no_notify, TRUE, MUIA_Selected, tag->ti_Data != 0);
295 break;
299 return DoSuperMethodA(CLASS, self, (Msg)&noforward_message);
302 IPTR ScreenModeProperties__OM_GET(Class *CLASS, Object *self, struct opGet *message)
304 struct ScreenModeProperties_DATA *data = INST_DATA(CLASS, self);
306 switch (message->opg_AttrID)
308 case MUIA_ScreenModeProperties_DisplayID:
309 *message->opg_Storage = data->DisplayID;
310 break;
312 case MUIA_ScreenModeProperties_Width:
313 if (XGET(data->def_width, MUIA_Selected) == TRUE)
314 *message->opg_Storage = -1;
315 else
316 *message->opg_Storage = XGET(data->width, MUIA_Numeric_Value);
317 break;
319 case MUIA_ScreenModeProperties_Height:
320 if (XGET(data->def_height, MUIA_Selected) == TRUE)
321 *message->opg_Storage = -1;
322 else
323 *message->opg_Storage = XGET(data->height, MUIA_Numeric_Value);
324 break;
326 case MUIA_ScreenModeProperties_Depth:
327 *message->opg_Storage = XGET(data->depth, MUIA_Numeric_Value);
328 break;
330 case MUIA_ScreenModeProperties_Autoscroll:
331 *message->opg_Storage = XGET(data->autoscroll, MUIA_Selected);
332 break;
334 default:
335 return DoSuperMethodA(CLASS, self, (Msg)message);
338 return TRUE;
341 ZUNE_CUSTOMCLASS_3
343 ScreenModeProperties, NULL, MUIC_Group, NULL,
344 OM_NEW, struct opSet *,
345 OM_GET, struct opGet *,
346 OM_SET, struct opSet *