revert 213 commits (to 56092) from the last month. 10 still need work to resolve...
[AROS.git] / workbench / prefs / screenmode / smattributes.c
blob10ec3c04b27656ba4211516b6dd3d8388b2fad86
1 /*
2 Copyright © 2011, 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>
10 #include <exec/rawfmt.h>
12 #include <proto/alib.h>
13 #include <proto/exec.h>
14 #include <proto/graphics.h>
15 #include <proto/utility.h>
16 #include <proto/intuition.h>
17 #include <zune/customclasses.h>
19 #include "locale.h"
21 #include "smattributes.h"
23 struct ScreenModeAttributes_DATA
25 Object * objVisibleW;
26 Object * objVisibleH;
27 Object * objMinimumW;
28 Object * objMinimumH;
29 Object * objMaximumW;
30 Object * objMaximumH;
31 Object * objMaximumColors;
32 ULONG DisplayID;
35 Object *ScreenModeAttributes__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
37 struct ScreenModeAttributes_DATA *data;
38 Object * objVisibleW, * objVisibleH, * objMinimumW, * objMinimumH,
39 * objMaximumW, * objMaximumH, * objMaximumColors;
42 ULONG id;
44 self = (Object *)DoSuperNewTags
46 CLASS, self, NULL,
47 MUIA_Group_Horiz, TRUE,
48 Child, (IPTR)VGroup,
49 Child, (IPTR)ColGroup(4),
50 Child, (IPTR)LLabel1(_(MSG_VISIBLE_SIZE)),
51 Child, (IPTR)(objVisibleW = (Object *)Label1("16368")),
52 Child, (IPTR)Label1("x"),
53 Child, (IPTR)(objVisibleH = (Object *)Label1("16384")),
55 Child, (IPTR)LLabel1(_(MSG_MINIMUM_SIZE)),
56 Child, (IPTR)(objMinimumW = (Object *)Label1("16368")),
57 Child, (IPTR)Label1("x"),
58 Child, (IPTR)(objMinimumH = (Object *)Label1("16368")),
60 Child, (IPTR)LLabel1(_(MSG_MAXIMUM_SIZE)),
61 Child, (IPTR)(objMaximumW = (Object *)Label1("16368")),
62 Child, (IPTR)Label1("x"),
63 Child, (IPTR)(objMaximumH = (Object *)Label1("16368")),
65 Child, (IPTR)LLabel1(_(MSG_MAXIMUM_COLORS)),
66 Child, (IPTR)(objMaximumColors = (Object *)LLabel1("16777216")),
67 Child, (IPTR)RectangleObject, End,
68 Child, (IPTR)RectangleObject, End,
70 End,
72 Child, (IPTR)RectangleObject, End,
74 End,
76 TAG_MORE, (IPTR)message->ops_AttrList
79 if (!self)
80 goto err;
82 D(bug("[smattributes] Created ScreenModeAttributes object 0x%p\n", self));
83 data = INST_DATA(CLASS, self);
85 data->objVisibleW = objVisibleW;
86 data->objVisibleH = objVisibleH;
87 data->objMinimumW = objMinimumW;
88 data->objMinimumH = objMinimumH;
89 data->objMaximumW = objMaximumW;
90 data->objMaximumH = objMaximumH;
91 data->objMaximumColors = objMaximumColors;
93 id = GetTagData(MUIA_ScreenModeAttributes_DisplayID, INVALID_ID, message->ops_AttrList);
94 D(bug("[smattributes] Setting initial ModeID 0x%08lX\n", id));
95 set(self, MUIA_ScreenModeAttributes_DisplayID, id);
97 return self;
99 err:
100 CoerceMethod(CLASS, self, OM_DISPOSE);
101 return NULL;
104 IPTR ScreenModeAttributes__OM_SET(Class *CLASS, Object *self, struct opSet *message)
106 struct ScreenModeAttributes_DATA *data = INST_DATA(CLASS, self);
107 struct TagItem *tags;
108 struct TagItem *tag;
109 IPTR ret;
111 DB2(bug("[smattributes] OM_SET called\n"));
112 for (tags = message->ops_AttrList; (tag = NextTagItem(&tags)); )
114 switch (tag->ti_Tag)
116 case MUIA_ScreenModeAttributes_DisplayID:
118 struct DimensionInfo dim;
120 D(bug("[smattributes] Set DisplayID = 0x%08lx\n", tag->ti_Data));
122 if (GetDisplayInfoData(NULL, (UBYTE *)&dim, sizeof(dim), DTAG_DIMS, tag->ti_Data))
124 TEXT buffer[128];
125 ULONG val;
127 val = dim.Nominal.MaxX - dim.Nominal.MinX + 1;
128 RawDoFmt("%ld", (RAWARG)&val, RAWFMTFUNC_STRING, buffer);
129 set(data->objVisibleW, MUIA_Text_Contents, buffer);
130 val = dim.Nominal.MaxY - dim.Nominal.MinY + 1;
131 RawDoFmt("%ld", (RAWARG)&val, RAWFMTFUNC_STRING, buffer);
132 set(data->objVisibleH, MUIA_Text_Contents, buffer);
134 RawDoFmt("%d", (RAWARG)&dim.MinRasterWidth, RAWFMTFUNC_STRING, buffer);
135 set(data->objMinimumW, MUIA_Text_Contents, buffer);
136 RawDoFmt("%d", (RAWARG)&dim.MinRasterHeight, RAWFMTFUNC_STRING, buffer);
137 set(data->objMinimumH, MUIA_Text_Contents, buffer);
139 RawDoFmt("%d", (RAWARG)&dim.MaxRasterWidth, RAWFMTFUNC_STRING, buffer);
140 set(data->objMaximumW, MUIA_Text_Contents, buffer);
141 RawDoFmt("%d", (RAWARG)&dim.MaxRasterHeight, RAWFMTFUNC_STRING, buffer);
142 set(data->objMaximumH, MUIA_Text_Contents, buffer);
144 val = 1 << (dim.MaxDepth > 24 ? 24 : dim.MaxDepth);
145 RawDoFmt("%ld", (RAWARG)&val, RAWFMTFUNC_STRING, buffer);
146 set(data->objMaximumColors, MUIA_Text_Contents, buffer);
149 SetAttrs(self, MUIA_Disabled, tag->ti_Data == INVALID_ID, TAG_DONE);
151 break;
156 DB2(bug("[smattributes] Calling OM_SET() on superclass\n"));
157 ret = DoSuperMethodA(CLASS, self, (Msg)message);
158 DB2(bug("[smattributes] OM_SET() on superclass returned %ld\n", ret));
159 return ret;
162 ZUNE_CUSTOMCLASS_2
164 ScreenModeAttributes, NULL, MUIC_Group, NULL,
165 OM_NEW, struct opSet *,
166 OM_SET, struct opSet *