1
2 #include "studiox_includes.h"
3
4 #ifdef _DEBUG
5 #define new DEBUG_NEW
6 #endif
7
pixelmap_prompt_service_provider()8 pixelmap_prompt_service_provider::pixelmap_prompt_service_provider()
9 {
10 }
11
GetVarDeclaration()12 CString pixelmap_prompt_service_provider::GetVarDeclaration()
13 {
14 return CString("GX_PIXELMAP_PROMPT_MEMBERS_DECLARE");
15 }
16
DeclarePropertiesStructContent()17 CString pixelmap_prompt_service_provider::DeclarePropertiesStructContent()
18 {
19 CString out;
20
21 out.Format(_T("%s\n")
22 _T(" GX_RESOURCE_ID left_map_id;\n")
23 _T(" GX_RESOURCE_ID fill_map_id;\n")
24 _T(" GX_RESOURCE_ID right_map_id;\n")
25 _T(" GX_RESOURCE_ID selected_left_map_id;\n")
26 _T(" GX_RESOURCE_ID selected_fill_map_id;\n")
27 _T(" GX_RESOURCE_ID selected_right_map_id;"),
28 prompt_service_provider::DeclarePropertiesStructContent());
29
30 return out;
31 }
32
DeclarePropertiesStruct()33 CString pixelmap_prompt_service_provider::DeclarePropertiesStruct()
34 {
35 CString out;
36 out.Format(_T("typedef struct\n")
37 _T("{\n")
38 _T("%s\n")
39 _T("} GX_PIXELMAP_PROMPT_PROPERTIES;\n\n"),
40 DeclarePropertiesStructContent());
41
42 return out;
43 }
44
WriteExtendedPropertiesContent(screen_generator * gen,widget_info * info,BOOL add_last_comma)45 CString pixelmap_prompt_service_provider::WriteExtendedPropertiesContent(screen_generator *gen, widget_info *info, BOOL add_last_comma)
46 {
47 CString out;
48 CString last_delimiter;
49
50 if (add_last_comma)
51 {
52 last_delimiter = _T(",");
53 }
54 else
55 {
56 last_delimiter = _T(" ");
57 }
58
59 out.Format(_T("%s\n")
60 _T(" %s, /* left pixelmap id */\n")
61 _T(" %s, /* fill pixelmap id */\n")
62 _T(" %s, /* right pixelmap id*/\n")
63 _T(" %s, /* selected left pixelmap id */\n")
64 _T(" %s, /* selected fill pixelmap id */\n")
65 _T(" %s%s /* selected right pixelmap id*/"),
66 prompt_service_provider::WriteExtendedPropertiesContent(gen, info, TRUE),
67 gen->GetPixelmapIdName(info->pixelmap_id[LEFT_PIXELMAP_INDEX]),
68 gen->GetPixelmapIdName(info->pixelmap_id[FILL_PIXELMAP_INDEX]),
69 gen->GetPixelmapIdName(info->pixelmap_id[RIGHT_PIXELMAP_INDEX]),
70 gen->GetPixelmapIdName(info->pixelmap_id[SELECTED_LEFT_PIXELMAP_INDEX]),
71 gen->GetPixelmapIdName(info->pixelmap_id[SELECTED_FILL_PIXELMAP_INDEX]),
72 gen->GetPixelmapIdName(info->pixelmap_id[SELECTED_RIGHT_PIXELMAP_INDEX]), last_delimiter);
73 return out;
74 }
75
WriteExtendedProperties(screen_generator * gen,CString & prefix,widget_info * info)76 CString pixelmap_prompt_service_provider::WriteExtendedProperties(screen_generator *gen, CString &prefix, widget_info *info)
77 {
78 CString out;
79 CString propname = prefix + info->app_name;
80 out.Format(_T("GX_PIXELMAP_PROMPT_PROPERTIES %s_properties =\n")
81 _T("{\n")
82 _T("%s\n")
83 _T("};\n"),
84 propname,
85 WriteExtendedPropertiesContent(gen, info));
86 return out;
87 }
88
GetCreateFromDefFunctionName()89 CString pixelmap_prompt_service_provider::GetCreateFromDefFunctionName()
90 {
91 return CString("gx_studio_pixelmap_prompt_create");
92 }
93
GetCreateFromDefFunction(int version)94 CString pixelmap_prompt_service_provider::GetCreateFromDefFunction(int version)
95 {
96 CString out;
97 MakeCreatePreamble("pixelmap_prompt", version, out);
98
99 if (version < 51)
100 {
101 out += "{\n"
102 " UINT status;\n"
103 " GX_PIXELMAP_PROMPT *pix_prompt = (GX_PIXELMAP_PROMPT *) control_block;\n"
104 " GX_PROMPT *prompt = (GX_PROMPT *) pix_prompt;\n"
105 " GX_PIXELMAP_PROMPT_PROPERTIES *props = (GX_PIXELMAP_PROMPT_PROPERTIES *) info->properties;\n"
106 " status = gx_pixelmap_prompt_create(pix_prompt, info->widget_name, parent,\n"
107 " props->string_id,\n"
108 " props->left_map_id,\n"
109 " props->fill_map_id,\n"
110 " props->right_map_id,\n"
111 " info->style, info->widget_id, &info->size);\n"
112 "\n"
113 " if (status == GX_SUCCESS)\n"
114 " {\n"
115 " gx_prompt_font_set(prompt, props->font_id);\n"
116 " gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id);\n"
117 " }\n"
118 " return status;\n"
119 "}\n";
120 }
121 else
122 {
123 out += "{\n"
124 " UINT status;\n"
125 " GX_PIXELMAP_PROMPT *pix_prompt = (GX_PIXELMAP_PROMPT *) control_block;\n"
126 " GX_PROMPT *prompt = (GX_PROMPT *) pix_prompt;\n"
127 " GX_PIXELMAP_PROMPT_PROPERTIES *props = (GX_PIXELMAP_PROMPT_PROPERTIES *) info->properties;\n"
128 " status = gx_pixelmap_prompt_create(pix_prompt, info->widget_name, parent,\n"
129 " props->string_id,\n"
130 " props->fill_map_id,\n"
131 " info->style, info->widget_id, &info->size);\n"
132 "\n"
133 " if (status == GX_SUCCESS)\n"
134 " {\n"
135 " gx_pixelmap_prompt_pixelmap_set(pix_prompt,\n"
136 " props->left_map_id,\n"
137 " props->fill_map_id,\n"
138 " props->right_map_id,\n"
139 " props->selected_left_map_id,\n"
140 " props->selected_fill_map_id,\n"
141 " props->selected_right_map_id);\n"
142 " gx_prompt_font_set(prompt, props->font_id);\n";
143 if (version <= 50401)
144 {
145 out += " gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id);\n";
146 }
147 else
148 {
149 out += "#if defined(GUIX_5_4_0_COMPATIBILITY)\n"
150 " gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id);\n"
151 "#else\n"
152 " gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id, props->disabled_text_color_id);\n"
153 "#endif\n";
154 }
155 out += " }\n"
156 " return status;\n"
157 "}\n";
158 }
159 return out;
160 }
161
CreateNewInstance(GX_WIDGET * parent)162 widget_info *pixelmap_prompt_service_provider::CreateNewInstance(GX_WIDGET *parent)
163 {
164 GX_RECTANGLE size;
165 gx_utility_rectangle_define(&size, 0, 0, 79, 23);
166 gx_utility_rectangle_center(&size, &parent->gx_widget_size);
167
168 GX_PIXELMAP_PROMPT *prompt = new GX_PIXELMAP_PROMPT;
169 GX_RESOURCE_ID string_id = GetStringId("prompt");
170
171 gx_pixelmap_prompt_create(prompt, "prompt", parent,
172 string_id, 0,
173 GX_STYLE_ENABLED|GX_STYLE_BORDER_THIN|GX_STYLE_TEXT_CENTER, 0, &size);
174
175 widget_info *info = InitWidgetInfo((GX_WIDGET *) prompt);
176 info->pixelmap_id[FILL_PIXELMAP_INDEX] = 0;
177 info->pixelmap_id[LEFT_PIXELMAP_INDEX] = 0;
178 info->pixelmap_id[RIGHT_PIXELMAP_INDEX] = 0;
179 info->pixelmap_id[SELECTED_FILL_PIXELMAP_INDEX] = 0;
180 info->pixelmap_id[SELECTED_LEFT_PIXELMAP_INDEX] = 0;
181 info->pixelmap_id[SELECTED_RIGHT_PIXELMAP_INDEX] = 0;
182 info->string_id[0] = string_id;
183 info->font_id[0] = prompt->gx_prompt_font_id;
184 info->color_id[NORMAL_TEXT_COLOR_INDEX] = prompt->gx_prompt_normal_text_color;
185 info->color_id[SELECTED_TEXT_COLOR_INDEX] = prompt->gx_prompt_selected_text_color;
186 info->color_id[DISABLED_TEXT_COLOR_INDEX] = prompt->gx_prompt_disabled_text_color;
187 return info;
188 }
189
GenerateFromInfo(GX_WIDGET * parent,widget_info * info)190 GX_WIDGET *pixelmap_prompt_service_provider::GenerateFromInfo(GX_WIDGET *parent, widget_info *info)
191 {
192 GX_PIXELMAP_PROMPT *prompt = new GX_PIXELMAP_PROMPT;
193
194 gx_pixelmap_prompt_create(prompt,
195 (CHAR *) info->app_name.GetString(),
196 parent,
197 info->string_id[0],
198 info->pixelmap_id[FILL_PIXELMAP_INDEX],
199 info->style, 0, &info->size);
200
201 gx_pixelmap_prompt_pixelmap_set(prompt,
202 info->pixelmap_id[LEFT_PIXELMAP_INDEX],
203 info->pixelmap_id[FILL_PIXELMAP_INDEX],
204 info->pixelmap_id[RIGHT_PIXELMAP_INDEX],
205 info->pixelmap_id[SELECTED_LEFT_PIXELMAP_INDEX],
206 info->pixelmap_id[SELECTED_FILL_PIXELMAP_INDEX],
207 info->pixelmap_id[SELECTED_RIGHT_PIXELMAP_INDEX]);
208
209 gx_widget_fill_color_set((GX_PROMPT *) prompt,
210 info->color_id[NORMAL_FILL_COLOR_INDEX],
211 info->color_id[SELECTED_FILL_COLOR_INDEX],
212 info->color_id[DISABLED_FILL_COLOR_INDEX]);
213
214 gx_prompt_text_color_set((GX_PROMPT *) prompt,
215 info->color_id[NORMAL_TEXT_COLOR_INDEX],
216 info->color_id[SELECTED_TEXT_COLOR_INDEX],
217 info->color_id[DISABLED_TEXT_COLOR_INDEX]);
218 gx_prompt_font_set((GX_PROMPT *) prompt, info->font_id[0]);
219
220 return ((GX_WIDGET *) prompt);
221 }
222
SaveToProject(xml_writer & writer,studiox_project * project,int display,widget_info * info)223 void pixelmap_prompt_service_provider::SaveToProject(xml_writer &writer, studiox_project *project, int display, widget_info *info)
224 {
225 prompt_service_provider::SaveToProject(writer, project, display, info);
226 WritePixelmapId(writer, project, display, "left_map_id", info->pixelmap_id[LEFT_PIXELMAP_INDEX]);
227 WritePixelmapId(writer, project, display, "fill_map_id", info->pixelmap_id[FILL_PIXELMAP_INDEX]);
228 WritePixelmapId(writer, project, display, "right_map_id", info->pixelmap_id[RIGHT_PIXELMAP_INDEX]);
229 WritePixelmapId(writer, project, display, "selected_left_map_id", info->pixelmap_id[SELECTED_LEFT_PIXELMAP_INDEX]);
230 WritePixelmapId(writer, project, display, "selected_fill_map_id", info->pixelmap_id[SELECTED_FILL_PIXELMAP_INDEX]);
231 WritePixelmapId(writer, project, display, "selected_right_map_id", info->pixelmap_id[SELECTED_RIGHT_PIXELMAP_INDEX]);
232 }
233
ReadFromProject(xml_reader & reader,studiox_project * project,int display,widget_info * info,ULONG valid_styles)234 void pixelmap_prompt_service_provider::ReadFromProject(xml_reader &reader, studiox_project *project, int display, widget_info *info, ULONG valid_styles)
235 {
236 valid_styles |= GX_PIXELMAP_HALIGN_MASK|GX_PIXELMAP_VALIGN_MASK;
237 prompt_service_provider::ReadFromProject(reader, project, display, info, valid_styles);
238 info->pixelmap_id[LEFT_PIXELMAP_INDEX] = ReadPixelmapId(reader, project, display, "left_map_id");
239 info->pixelmap_id[FILL_PIXELMAP_INDEX] = ReadPixelmapId(reader, project, display, "fill_map_id");
240 info->pixelmap_id[RIGHT_PIXELMAP_INDEX] = ReadPixelmapId(reader, project, display, "right_map_id");
241 info->pixelmap_id[SELECTED_LEFT_PIXELMAP_INDEX] = ReadPixelmapId(reader, project, display, "selected_left_map_id");
242 info->pixelmap_id[SELECTED_FILL_PIXELMAP_INDEX] = ReadPixelmapId(reader, project, display, "selected_fill_map_id");
243 info->pixelmap_id[SELECTED_RIGHT_PIXELMAP_INDEX] = ReadPixelmapId(reader, project, display, "selected_right_map_id");
244 }
245
AssignPixelmap(widget_info * info,int index,GX_RESOURCE_ID pixmap_id)246 void pixelmap_prompt_service_provider::AssignPixelmap(widget_info *info,
247 int index, GX_RESOURCE_ID pixmap_id)
248 {
249 GX_WIDGET *widget = info->widget;
250
251 switch(index)
252 {
253 case LEFT_PIXELMAP_INDEX:
254 info->pixelmap_id[LEFT_PIXELMAP_INDEX] = pixmap_id;
255 break;
256
257 case FILL_PIXELMAP_INDEX:
258 info->pixelmap_id[FILL_PIXELMAP_INDEX] = pixmap_id;
259 break;
260
261 case RIGHT_PIXELMAP_INDEX:
262 info->pixelmap_id[RIGHT_PIXELMAP_INDEX] = pixmap_id;
263 break;
264
265 case SELECTED_LEFT_PIXELMAP_INDEX:
266 info->pixelmap_id[SELECTED_LEFT_PIXELMAP_INDEX] = pixmap_id;
267 break;
268
269 case SELECTED_FILL_PIXELMAP_INDEX:
270 info->pixelmap_id[SELECTED_FILL_PIXELMAP_INDEX] = pixmap_id;
271 break;
272
273 case SELECTED_RIGHT_PIXELMAP_INDEX:
274 info->pixelmap_id[SELECTED_RIGHT_PIXELMAP_INDEX] = pixmap_id;
275 break;
276 }
277
278 if (widget)
279 {
280 GX_PIXELMAP_PROMPT *prompt = (GX_PIXELMAP_PROMPT *)widget;
281
282 gx_pixelmap_prompt_pixelmap_set(prompt,
283 info->pixelmap_id[LEFT_PIXELMAP_INDEX],
284 info->pixelmap_id[FILL_PIXELMAP_INDEX],
285 info->pixelmap_id[RIGHT_PIXELMAP_INDEX],
286 info->pixelmap_id[SELECTED_LEFT_PIXELMAP_INDEX],
287 info->pixelmap_id[SELECTED_FILL_PIXELMAP_INDEX],
288 info->pixelmap_id[SELECTED_RIGHT_PIXELMAP_INDEX]);
289 }
290 }
291
Autosize(widget_info * info)292 void pixelmap_prompt_service_provider::Autosize(widget_info *info)
293 {
294 CheckResizeToPixelmap(info, RESIZE_MODE_HEIGHT);
295 }
296