2 Copyright © 2003-2006, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
9 #include <libraries/mui.h>
10 #include <utility/hooks.h>
12 #include <proto/exec.h>
13 #include <proto/muimaster.h>
14 #include <proto/intuition.h>
15 #include <proto/graphics.h>
16 #include <proto/dos.h>
17 #include <proto/utility.h>
19 #include <zune/customclasses.h>
25 #include "smselector.h"
27 struct ScreenModeSelector_DATA
36 #define HOOKFUNC(name) IPTR name ## Func(struct Hook *hook, APTR obj, APTR msg)
38 AROS_UFH3(IPTR
, SelectFunc
,
39 AROS_UFHA(struct Hook
*, hook
, A0
),
40 AROS_UFHA(APTR
, obj
, A2
),
41 AROS_UFHA(APTR
, msg
, A1
))
45 struct ScreenModeSelector_DATA
*data
= INST_DATA(OCLASS(obj
), obj
);
47 return set(obj
, MUIA_ScreenModeSelector_Active
, data
->ids_array
[*(IPTR
*)msg
]);
51 static struct Hook SelectHook
= { .h_Entry
= SelectFunc
};
53 Object
*ScreenModeSelector__OM_NEW(Class
*CLASS
, Object
*self
, struct opSet
*message
)
57 ULONG id
, num_modes
, cur_mode
;
59 struct DisplayInfo DisplayInfo
;
60 struct DimensionInfo DimensionInfo
;
61 struct NameInfo NameInfo
;
64 struct ScreenModeSelector_DATA
*data
;
66 num_modes
= 0; id
= INVALID_ID
;
67 while ((id
= NextDisplayInfo(id
)) != INVALID_ID
) num_modes
++;
69 modes_array
= AllocVec(sizeof(STRPTR
) * (1 + num_modes
+ 1), MEMF_CLEAR
);
73 ids_array
= AllocVec(sizeof(ULONG
) * (1 + num_modes
+ 1), MEMF_ANY
);
77 modes_array
[0] = __(MSG_SELECT
);
78 ids_array
[0] = INVALID_ID
;
79 ids_array
[num_modes
+ 1] = INVALID_ID
;
82 while ((id
= NextDisplayInfo(id
)) != INVALID_ID
)
84 if ((id
& MONITOR_ID_MASK
) == DEFAULT_MONITOR_ID
)
87 if (!(handle
= FindDisplayInfo(id
)))
90 if (!GetDisplayInfoData(handle
, (UBYTE
*)&NameInfo
, sizeof(struct NameInfo
), DTAG_NAME
, 0))
93 if (!GetDisplayInfoData(handle
, (UBYTE
*)&DisplayInfo
, sizeof(struct DisplayInfo
), DTAG_DISP
, 0))
96 if (!(DisplayInfo
.PropertyFlags
& DIPF_IS_WB
) || DisplayInfo
.NotAvailable
)
99 if (!GetDisplayInfoData(handle
, (UBYTE
*)&DimensionInfo
, sizeof(struct DimensionInfo
), DTAG_DIMS
, 0))
102 modes_array
[cur_mode
] = AllocVec(sizeof(NameInfo
.Name
), MEMF_ANY
);
103 if (!modes_array
[cur_mode
])
106 CopyMem(NameInfo
.Name
, modes_array
[cur_mode
], sizeof(NameInfo
.Name
));
107 ids_array
[cur_mode
] = id
;
112 self
= (Object
*)DoSuperNewTags
115 MUIA_Cycle_Entries
, (IPTR
)modes_array
,
116 TAG_MORE
, (IPTR
)message
->ops_AttrList
122 DoMethod(self
, MUIM_Notify
, MUIA_Cycle_Active
, MUIV_EveryTime
,
123 (IPTR
)self
, 3, MUIM_CallHook
, (IPTR
)&SelectHook
, MUIV_TriggerValue
);
125 data
= INST_DATA(CLASS
, self
);
126 data
->modes_array
= modes_array
;
127 data
->ids_array
= ids_array
;
132 CoerceMethod(CLASS
, self
, OM_DISPOSE
);
136 IPTR
ScreenModeSelector__OM_DISPOSE(Class
*CLASS
, Object
*self
, Msg message
)
138 struct ScreenModeSelector_DATA
*data
;
141 data
= INST_DATA(CLASS
, self
);
143 if (data
->modes_array
)
145 for (cur_mode
= 1; data
->modes_array
[cur_mode
]; cur_mode
++)
146 FreeVec(data
->modes_array
[cur_mode
]);
148 FreeVec(data
->modes_array
);
151 FreeVec(data
->ids_array
);
153 return DoSuperMethodA(CLASS
, self
, message
);
157 IPTR
ScreenModeSelector__OM_SET(Class
*CLASS
, Object
*self
, struct opSet
*message
)
159 struct ScreenModeSelector_DATA
*data
= INST_DATA(CLASS
, self
);
160 const struct TagItem
*tags
;
162 struct TagItem noforward_tags
[] =
164 {MUIA_Group_Forward
, FALSE
},
165 {TAG_MORE
, (IPTR
)message
->ops_AttrList
}
167 struct opSet noforward_message
= *message
;
168 noforward_message
.ops_AttrList
= noforward_tags
;
170 for (tags
= message
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
174 case MUIA_ScreenModeSelector_Active
:
181 data
->ids_array
[i
] != tag
->ti_Data
&& data
->ids_array
[i
] != INVALID_ID
;
185 if (data
->ids_array
[i
] == INVALID_ID
)
186 tag
->ti_Data
= INVALID_ID
;
188 if (XGET(self
, MUIA_Cycle_Active
) != i
)
189 NFSET(self
, MUIA_Cycle_Active
, i
);
196 return DoSuperMethodA(CLASS
, self
, (Msg
)&noforward_message
);
199 IPTR
ScreenModeSelector__OM_GET(Class
*CLASS
, Object
*self
, struct opGet
*message
)
201 struct ScreenModeSelector_DATA
*data
= INST_DATA(CLASS
, self
);
203 switch (message
->opg_AttrID
)
205 case MUIA_ScreenModeSelector_Active
:
206 *message
->opg_Storage
= data
->ids_array
[XGET(self
, MUIA_Cycle_Active
)];
209 return DoSuperMethodA(CLASS
, self
, (Msg
)message
);
218 ScreenModeSelector
, NULL
, MUIC_Cycle
, NULL
,
219 OM_NEW
, struct opSet
*,
221 OM_GET
, struct opGet
*,
222 OM_SET
, struct opSet
*