2 Copyright © 2003-2006, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
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>
21 #include "smproperties.h"
23 struct ScreenModeProperties_DATA
25 Object
*width
, *height
, *depth
,
26 *def_width
, *def_height
;
33 #define CheckMarkObject \
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)
46 #define HCenter(obj...) \
47 (HGroup, (IPTR)GroupSpacing(0), Child, (IPTR)HSpace(0), Child, (IPTR)(obj), Child, \
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
;
60 self
= (Object
*)DoSuperNewTags
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
,
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
),
88 TAG_MORE
, (IPTR
)message
->ops_AttrList
94 data
= INST_DATA(CLASS
, self
);
97 data
->height
= height
;
99 data
->def_width
= def_width
;
100 data
->def_height
= def_height
;
101 data
->autoscroll
= autoscroll
;
105 width
, MUIM_Notify
, MUIA_Numeric_Value
, MUIV_EveryTime
,
107 MUIM_Set
, MUIA_ScreenModeProperties_Width
, MUIV_TriggerValue
112 height
, MUIM_Notify
, MUIA_Numeric_Value
, MUIV_EveryTime
,
114 MUIM_Set
, MUIA_ScreenModeProperties_Height
, MUIV_TriggerValue
119 depth
, MUIM_Notify
, MUIA_Numeric_Value
, MUIV_EveryTime
,
121 MUIM_Set
, MUIA_ScreenModeProperties_Depth
, MUIV_TriggerValue
126 def_width
, MUIM_Notify
, MUIA_Selected
, TRUE
,
128 MUIM_Numeric_SetDefault
133 width
, MUIM_Notify
, MUIA_Numeric_Value
, MUIV_EveryTime
,
135 MUIM_Set
, MUIA_Selected
, FALSE
140 def_height
, MUIM_Notify
, MUIA_Selected
, TRUE
,
142 MUIM_Numeric_SetDefault
147 height
, MUIM_Notify
, MUIA_Numeric_Value
, MUIV_EveryTime
,
149 MUIM_Set
, MUIA_Selected
, FALSE
152 id
= GetTagData(MUIA_ScreenModeProperties_DisplayID
, INVALID_ID
, message
->ops_AttrList
);
153 set(self
, MUIA_ScreenModeProperties_DisplayID
, id
);
158 CoerceMethod(CLASS
, self
, OM_DISPOSE
);
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
;
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
)); )
183 no_notify
= MUIA_NoNotify
;
186 case MUIA_ScreenModeProperties_DisplayID
:
188 struct TagItem width_tags
[] =
191 { MUIA_Numeric_Min
, 0 },
192 { MUIA_Numeric_Max
, 0 },
193 { MUIA_Numeric_Default
, 0 },
196 struct TagItem height_tags
[] =
199 { MUIA_Numeric_Min
, 0 },
200 { MUIA_Numeric_Max
, 0 },
201 { MUIA_Numeric_Default
, 0 },
204 struct TagItem depth_tags
[] =
207 { MUIA_Numeric_Min
, 0 },
208 { MUIA_Numeric_Max
, 0 },
209 { MUIA_Numeric_Default
, 0 },
213 struct DimensionInfo dim
;
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
;
234 /* Enable autoscroll only if the maximum sizes are bigger than
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
,
255 case MUIA_ScreenModeProperties_Width
:
256 if (id
!= INVALID_ID
)
258 WORD width
= tag
->ti_Data
;
260 SetAttrs(data
->width
, no_notify
, TRUE
, MUIA_Numeric_Value
, width
, TAG_DONE
);
262 DoMethod(data
->width
, MUIM_Numeric_SetDefault
);
264 nnset(data
->def_width
, MUIA_Selected
, width
== -1);
268 case MUIA_ScreenModeProperties_Height
:
269 if (id
!= INVALID_ID
)
271 WORD height
= tag
->ti_Data
;
273 SetAttrs(data
->height
, no_notify
, TRUE
, MUIA_Numeric_Value
, height
, TAG_DONE
);
275 DoMethod(data
->height
, MUIM_Numeric_SetDefault
);
277 nnset(data
->def_height
, MUIA_Selected
, height
== -1);
281 case MUIA_ScreenModeProperties_Depth
:
282 if (id
!= INVALID_ID
)
284 WORD depth
= tag
->ti_Data
;
286 SetAttrs(data
->depth
, no_notify
, TRUE
, MUIA_Numeric_Value
, depth
, TAG_DONE
);
288 DoMethod(data
->depth
, MUIM_Numeric_SetDefault
);
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);
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
;
312 case MUIA_ScreenModeProperties_Width
:
313 if (XGET(data
->def_width
, MUIA_Selected
) == TRUE
)
314 *message
->opg_Storage
= -1;
316 *message
->opg_Storage
= XGET(data
->width
, MUIA_Numeric_Value
);
319 case MUIA_ScreenModeProperties_Height
:
320 if (XGET(data
->def_height
, MUIA_Selected
) == TRUE
)
321 *message
->opg_Storage
= -1;
323 *message
->opg_Storage
= XGET(data
->height
, MUIA_Numeric_Value
);
326 case MUIA_ScreenModeProperties_Depth
:
327 *message
->opg_Storage
= XGET(data
->depth
, MUIA_Numeric_Value
);
330 case MUIA_ScreenModeProperties_Autoscroll
:
331 *message
->opg_Storage
= XGET(data
->autoscroll
, MUIA_Selected
);
335 return DoSuperMethodA(CLASS
, self
, (Msg
)message
);
343 ScreenModeProperties
, NULL
, MUIC_Group
, NULL
,
344 OM_NEW
, struct opSet
*,
345 OM_GET
, struct opGet
*,
346 OM_SET
, struct opSet
*