added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / prefs / Zune / stringsp.c
blob4d77ca410460d0c5ed0441790baf07f723ddb232
1 /*
2 Copyright © 2003-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <graphics/gfx.h>
7 #include <graphics/view.h>
8 #include <clib/alib_protos.h>
9 #include <libraries/asl.h>
10 #include <libraries/mui.h>
11 #include <proto/exec.h>
12 #include <proto/graphics.h>
13 #include <proto/utility.h>
14 #include <proto/intuition.h>
15 #include <proto/muimaster.h>
17 #ifdef __AROS__
18 #include <proto/alib.h>
19 #endif
21 #include "zunestuff.h"
22 #include <string.h>
24 /* #define DEBUG 1 */
25 /* #include <aros/debug.h> */
27 extern struct Library *MUIMasterBase;
29 struct MUI_StringsPData
31 Object *string_popframe;
32 Object *popup_popimage;
33 Object *popfile_popimage;
34 Object *popdrawer_popimage;
35 Object *inactive_bg_popimage;
36 Object *inactive_text_poppen;
37 Object *active_bg_popimage;
38 Object *active_text_poppen;
39 Object *cursor_poppen;
40 Object *marked_bg_poppen;
41 Object *marked_text_poppen;
44 Object *MakePopupPopimage(CONST_STRPTR title)
46 return MUI_NewObject
48 MUIC_Popimage,
49 MUIA_Imageadjust_Type, MUIV_Imageadjust_Type_Image,
50 MUIA_CycleChain, 1,
51 MUIA_FixWidth, 28,
52 MUIA_MaxHeight, 28,
53 MUIA_Imagedisplay_FreeHoriz, FALSE,
54 MUIA_Imagedisplay_FreeVert, FALSE,
55 MUIA_Window_Title, (IPTR)title,
56 TAG_DONE
60 static IPTR StringsP_New(struct IClass *cl, Object *obj, struct opSet *msg)
62 struct MUI_StringsPData *data;
63 struct MUI_StringsPData d;
65 obj = (Object *) DoSuperNewTags
67 cl, obj, NULL,
68 MUIA_Group_Horiz, FALSE,
69 Child, (IPTR) HGroup,
70 Child, (IPTR) VGroup,
71 Child, (IPTR) HGroup,
72 GroupFrameT(_(MSG_STRING_FRAME)),
73 Child, (IPTR) (d.string_popframe = MakePopframe()),
74 End, // String Frame
75 Child, HGroup,
76 GroupFrameT(_(MSG_SPECIAL_POPUP_BUTTONS)),
77 MUIA_Group_SameWidth, TRUE,
78 Child, (IPTR) VGroup,
79 MUIA_Group_VertSpacing, 1,
80 Child, (IPTR) (d.popup_popimage = MakePopupPopimage(_(MSG_POPUP))),
81 Child, (IPTR) CLabel(_(MSG_DEFAULT)),
82 End,
83 Child, (IPTR) VGroup,
84 MUIA_Group_VertSpacing, 1,
85 Child, (IPTR) (d.popfile_popimage = MakePopupPopimage(_(MSG_POPUP_FILE))),
86 Child, (IPTR) CLabel(_(MSG_FILE)),
87 End,
88 Child, (IPTR) VGroup,
89 MUIA_Group_VertSpacing, 1,
90 Child, (IPTR) (d.popdrawer_popimage = MakePopupPopimage(_(MSG_POPUP_DRAWER))),
91 Child, (IPTR) CLabel(_(MSG_DRAWER)),
92 End,
93 End, // Special Popup Buttons
94 End, // VGroup Left
95 Child, VGroup,
96 Child, HGroup,
97 GroupFrameT(_(MSG_INACTIVE_STRING_COLORS)),
98 MUIA_Group_SameWidth, TRUE,
99 Child, (IPTR) VGroup,
100 MUIA_Group_VertSpacing, 1,
101 Child, (IPTR) (d.inactive_bg_popimage = MakeBackgroundPopimage()),
102 Child, (IPTR) CLabel(_(MSG_BACKGROUND)),
103 End,
104 Child, (IPTR) VGroup,
105 MUIA_Group_VertSpacing, 1,
106 Child, (IPTR) (d.inactive_text_poppen = MakePoppen()),
107 Child, (IPTR) CLabel(_(MSG_TEXT)),
108 End,
109 End, // Inactive String Colors
110 Child, HGroup,
111 GroupFrameT(_(MSG_ACTIVE_STRING_COLORS)),
112 MUIA_Group_SameWidth, TRUE,
113 Child, (IPTR) VGroup,
114 MUIA_Group_VertSpacing, 1,
115 Child, (IPTR) (d.active_bg_popimage = MakeBackgroundPopimage()),
116 Child, (IPTR) CLabel(_(MSG_BACKGROUND)),
117 End,
118 Child, (IPTR) VGroup,
119 MUIA_Group_VertSpacing, 1,
120 Child, (IPTR) (d.active_text_poppen = MakePoppen()),
121 Child, (IPTR) CLabel(_(MSG_TEXT)),
122 End,
123 End, // Inactive String Colors
124 Child, HGroup,
125 Child, HGroup,
126 GroupFrameT(_(MSG_CURSOR)),
127 Child, (IPTR) (d.cursor_poppen = MakePoppen()),
128 End, // Cursor
129 Child, HGroup,
130 GroupFrameT(_(MSG_MARKED_STRING_COLORS)),
131 MUIA_Group_SameWidth, TRUE,
132 Child, (IPTR) VGroup,
133 MUIA_Group_VertSpacing, 1,
134 Child, (IPTR) (d.marked_bg_poppen = MakePoppen()),
135 Child, (IPTR) CLabel(_(MSG_BACKGROUND)),
136 End,
137 Child, (IPTR) VGroup,
138 MUIA_Group_VertSpacing, 1,
139 Child, (IPTR) (d.marked_text_poppen = MakePoppen()),
140 Child, (IPTR) CLabel(_(MSG_TEXT)),
141 End,
142 End, // Marked String Colors
143 End, // Cursor + Marked
145 End,
146 End,
147 Child, (IPTR) StringObject,
148 StringFrame,
149 MUIA_CycleChain, 1,
150 MUIA_String_Contents, _(MSG_EXAMPLE_STRING_GADGET),
151 MUIA_String_Format, MUIV_String_Format_Center,
152 End,
153 TAG_MORE, (IPTR) msg->ops_AttrList);
155 if (!obj) return FALSE;
157 data = INST_DATA(cl, obj);
158 *data = d;
160 return (IPTR)obj;
165 * MUIM_Settingsgroup_ConfigToGadgets
167 static IPTR StringsP_ConfigToGadgets(struct IClass *cl, Object *obj,
168 struct MUIP_Settingsgroup_ConfigToGadgets *msg)
170 struct MUI_StringsPData *data = INST_DATA(cl, obj);
171 STRPTR spec;
173 /* Frames */
174 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
175 MUICFG_Frame_String);
176 set(data->string_popframe, MUIA_Framedisplay_Spec, (IPTR)spec);
178 /* Looks */
179 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
180 MUICFG_Image_PopUp);
181 set(data->popup_popimage, MUIA_Imagedisplay_Spec, (IPTR)spec);
182 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
183 MUICFG_Image_PopFile);
184 set(data->popfile_popimage, MUIA_Imagedisplay_Spec, (IPTR)spec);
185 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
186 MUICFG_Image_PopDrawer);
187 set(data->popdrawer_popimage, MUIA_Imagedisplay_Spec, (IPTR)spec);
189 /* pens & images */
190 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
191 MUICFG_String_Background);
192 set(data->inactive_bg_popimage, MUIA_Imagedisplay_Spec, (IPTR)spec);
193 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
194 MUICFG_String_Text);
195 set(data->inactive_text_poppen, MUIA_Pendisplay_Spec, (IPTR)spec);
197 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
198 MUICFG_String_ActiveBackground);
199 set(data->active_bg_popimage, MUIA_Imagedisplay_Spec, (IPTR)spec);
200 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
201 MUICFG_String_ActiveText);
202 set(data->active_text_poppen, MUIA_Pendisplay_Spec, (IPTR)spec);
204 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
205 MUICFG_String_Cursor);
206 set(data->cursor_poppen, MUIA_Pendisplay_Spec, (IPTR)spec);
208 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
209 MUICFG_String_MarkedText);
210 set(data->marked_text_poppen, MUIA_Pendisplay_Spec, (IPTR)spec);
212 spec = (STRPTR)DoMethod(msg->configdata, MUIM_Configdata_GetString,
213 MUICFG_String_MarkedBackground);
214 set(data->marked_bg_poppen, MUIA_Pendisplay_Spec, (IPTR)spec);
215 return 1;
220 * MUIM_Settingsgroup_ConfigToGadgets
222 static IPTR StringsP_GadgetsToConfig(struct IClass *cl, Object *obj,
223 struct MUIP_Settingsgroup_GadgetsToConfig *msg)
225 struct MUI_StringsPData *data = INST_DATA(cl, obj);
226 STRPTR str;
228 /* Frames */
229 str = (STRPTR)XGET(data->string_popframe, MUIA_Framedisplay_Spec);
230 DoMethod(msg->configdata, MUIM_Configdata_SetFramespec, MUICFG_Frame_String,
231 (IPTR)str);
233 /* Looks */
234 str = (STRPTR)XGET(data->popup_popimage, MUIA_Imagedisplay_Spec);
235 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_PopUp,
236 (IPTR)str);
237 str = (STRPTR)XGET(data->popfile_popimage, MUIA_Imagedisplay_Spec);
238 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_PopFile,
239 (IPTR)str);
240 str = (STRPTR)XGET(data->popdrawer_popimage, MUIA_Imagedisplay_Spec);
241 DoMethod(msg->configdata, MUIM_Configdata_SetImspec, MUICFG_Image_PopDrawer,
242 (IPTR)str);
244 /* pens & images */
245 str = (STRPTR)XGET(data->inactive_bg_popimage, MUIA_Imagedisplay_Spec);
246 DoMethod(msg->configdata, MUIM_Configdata_SetPenspec,
247 MUICFG_String_Background, (IPTR)str);
248 str = (STRPTR)XGET(data->inactive_text_poppen, MUIA_Pendisplay_Spec);
249 DoMethod(msg->configdata, MUIM_Configdata_SetPenspec,
250 MUICFG_String_Text, (IPTR)str);
252 str = (STRPTR)XGET(data->active_bg_popimage, MUIA_Imagedisplay_Spec);
253 DoMethod(msg->configdata, MUIM_Configdata_SetPenspec,
254 MUICFG_String_ActiveBackground, (IPTR)str);
255 str = (STRPTR)XGET(data->active_text_poppen, MUIA_Pendisplay_Spec);
256 DoMethod(msg->configdata, MUIM_Configdata_SetPenspec,
257 MUICFG_String_ActiveText, (IPTR)str);
259 str = (STRPTR)XGET(data->cursor_poppen, MUIA_Pendisplay_Spec);
260 DoMethod(msg->configdata, MUIM_Configdata_SetPenspec,
261 MUICFG_String_Cursor, (IPTR)str);
263 str = (STRPTR)XGET(data->marked_text_poppen, MUIA_Pendisplay_Spec);
264 DoMethod(msg->configdata, MUIM_Configdata_SetPenspec,
265 MUICFG_String_MarkedText, (IPTR)str);
267 str = (STRPTR)XGET(data->marked_bg_poppen, MUIA_Pendisplay_Spec);
268 DoMethod(msg->configdata, MUIM_Configdata_SetPenspec,
269 MUICFG_String_MarkedBackground, (IPTR)str);
271 return TRUE;
275 BOOPSI_DISPATCHER(IPTR, StringsP_Dispatcher, cl, obj, msg)
277 switch (msg->MethodID)
279 case OM_NEW: return StringsP_New(cl, obj, (struct opSet *)msg);
280 case MUIM_Settingsgroup_ConfigToGadgets: return StringsP_ConfigToGadgets(cl,obj,(APTR)msg);break;
281 case MUIM_Settingsgroup_GadgetsToConfig: return StringsP_GadgetsToConfig(cl,obj,(APTR)msg);break;
284 return DoSuperMethodA(cl, obj, msg);
286 BOOPSI_DISPATCHER_END
289 * Class descriptor.
291 const struct __MUIBuiltinClass _MUIP_Strings_desc = {
292 "Strings",
293 MUIC_Group,
294 sizeof(struct MUI_StringsPData),
295 (void*)StringsP_Dispatcher