1
2 #include "studiox_includes.h"
3
4 #ifdef _DEBUG
5 #define new DEBUG_NEW
6 #endif
7
ml_text_view_service_provider()8 ml_text_view_service_provider::ml_text_view_service_provider()
9 {
10 }
11
GetVarDeclaration()12 CString ml_text_view_service_provider::GetVarDeclaration()
13 {
14 return CString("GX_MULTI_LINE_TEXT_VIEW_MEMBERS_DECLARE");
15 }
16
DeclarePropertiesStruct()17 CString ml_text_view_service_provider::DeclarePropertiesStruct()
18 {
19 CString out;
20
21 if (project_lib_version() >= GX_WHITESPACE_IS_UBYTE)
22 {
23 out = (""
24 "typedef struct\n"
25 "{\n"
26 " GX_RESOURCE_ID string_id;\n"
27 " GX_RESOURCE_ID font_id;\n"
28 " GX_RESOURCE_ID normal_text_color_id;\n"
29 " GX_RESOURCE_ID selected_text_color_id;\n"
30 " GX_RESOURCE_ID disabled_text_color_id;\n"
31 " GX_UBYTE whitespace;\n"
32 " GX_BYTE line_space;\n"
33 "} GX_ML_TEXT_VIEW_PROPERTIES;\n\n");
34 }
35 else if (project_lib_version() > 50401)
36 {
37 out = (""
38 "typedef struct\n"
39 "{\n"
40 " GX_RESOURCE_ID string_id;\n"
41 " GX_RESOURCE_ID font_id;\n"
42 " GX_RESOURCE_ID normal_text_color_id;\n"
43 " GX_RESOURCE_ID selected_text_color_id;\n"
44 " GX_RESOURCE_ID disabled_text_color_id;\n"
45 " GX_BYTE whitespace;\n"
46 " GX_BYTE line_space;\n"
47 "} GX_ML_TEXT_VIEW_PROPERTIES;\n\n");
48 }
49 else if (project_lib_version() >= 50303)
50 {
51 out = (""
52 "typedef struct\n"
53 "{\n"
54 " GX_RESOURCE_ID string_id;\n"
55 " GX_RESOURCE_ID font_id;\n"
56 " GX_RESOURCE_ID normal_text_color_id;\n"
57 " GX_RESOURCE_ID selected_text_color_id;\n"
58 " GX_BYTE whitespace;\n"
59 " GX_BYTE line_space;\n"
60 "} GX_ML_TEXT_VIEW_PROPERTIES;\n\n");
61 }
62 else
63 {
64 out = (""
65 "typedef struct\n"
66 "{\n"
67 " GX_RESOURCE_ID string_id;\n"
68 " GX_RESOURCE_ID font_id;\n"
69 " GX_RESOURCE_ID normal_text_color_id;\n"
70 " GX_RESOURCE_ID selected_text_color_id;\n"
71 "} GX_ML_TEXT_VIEW_PROPERTIES;\n\n");
72 }
73 return out;
74 }
75
WriteExtendedProperties(screen_generator * gen,CString & prefix,widget_info * info)76 CString ml_text_view_service_provider::WriteExtendedProperties(screen_generator *gen, CString &prefix, widget_info *info)
77 {
78 CString out;
79 CString propname = prefix + info->app_name;
80
81 if (project_lib_version() > 50401)
82 {
83 out.Format(_T("GX_ML_TEXT_VIEW_PROPERTIES %s_properties =\n")
84 _T("{\n")
85 _T(" %s, /* string id */\n")
86 _T(" %s, /* font id */\n")
87 _T(" %s, /* normal text color */\n")
88 _T(" %s, /* selected text color */\n")
89 _T(" %s, /* disabled text color */\n")
90 _T(" %d, /* whitespace */\n")
91 _T(" %d /* line_space */\n};\n"),
92 propname,
93 gen->GetStringIdName(info->string_id[0], info),
94 gen->GetFontIdName(info->font_id[0]),
95 gen->GetColorIdName(info->color_id[NORMAL_TEXT_COLOR_INDEX]),
96 gen->GetColorIdName(info->color_id[SELECTED_TEXT_COLOR_INDEX]),
97 gen->GetColorIdName(info->color_id[DISABLED_TEXT_COLOR_INDEX]),
98 info->ewi.text_info.whitespace,
99 info->ewi.text_info.line_space);
100 }
101 else if (project_lib_version() >= 50303)
102 {
103 out.Format(_T("GX_ML_TEXT_VIEW_PROPERTIES %s_properties =\n")
104 _T("{\n")
105 _T(" %s, /* string id */\n")
106 _T(" %s, /* font id */\n")
107 _T(" %s, /* normal text color */\n")
108 _T(" %s, /* selected text color */\n")
109 _T(" %d, /* whitespace */\n")
110 _T(" %d /* line_space */\n};\n"),
111 propname,
112 gen->GetStringIdName(info->string_id[0]),
113 gen->GetFontIdName(info->font_id[0]),
114 gen->GetColorIdName(info->color_id[NORMAL_TEXT_COLOR_INDEX]),
115 gen->GetColorIdName(info->color_id[SELECTED_TEXT_COLOR_INDEX]),
116 info->ewi.text_info.whitespace,
117 info->ewi.text_info.line_space);
118 }
119 else
120 {
121 out.Format(_T("GX_ML_TEXT_VIEW_PROPERTIES %s_properties =\n")
122 _T("{\n")
123 _T(" %s, /* string id */\n")
124 _T(" %s, /* font id */\n")
125 _T(" %s, /* normal text color */\n")
126 _T(" %s /* selected text color */\n};\n"),
127 propname,
128 gen->GetStringIdName(info->string_id[0]),
129 gen->GetFontIdName(info->font_id[0]),
130 gen->GetColorIdName(info->color_id[NORMAL_TEXT_COLOR_INDEX]),
131 gen->GetColorIdName(info->color_id[SELECTED_TEXT_COLOR_INDEX]));
132 }
133 return out;
134 }
135
GetCreateFromDefFunctionName()136 CString ml_text_view_service_provider::GetCreateFromDefFunctionName()
137 {
138 return CString("gx_studio_multi_line_text_view_create");
139 }
140
GetCreateFromDefFunction(int version)141 CString ml_text_view_service_provider::GetCreateFromDefFunction(int version)
142 {
143 CString out;
144 MakeCreatePreamble("multi_line_text_view", version, out);
145
146 if (project_lib_version() > 50401)
147 {
148 out += "{\n"
149 " UINT status;\n"
150 " GX_MULTI_LINE_TEXT_VIEW *view = (GX_MULTI_LINE_TEXT_VIEW *) control_block;\n"
151 " GX_ML_TEXT_VIEW_PROPERTIES *props = (GX_ML_TEXT_VIEW_PROPERTIES *) info->properties;\n"
152 " status = gx_multi_line_text_view_create(view, info->widget_name, parent, props->string_id, info->style, info->widget_id, &info->size);\n"
153 " if (status == GX_SUCCESS)\n"
154 " {\n"
155 " gx_multi_line_text_view_font_set(view, props->font_id);\n"
156 "#if defined(GUIX_5_4_0_COMPATIBILITY)\n"
157 " gx_multi_line_text_view_text_color_set(view, props->normal_text_color_id, props->selected_text_color_id);\n"
158 "#else\n"
159 " gx_multi_line_text_view_text_color_set(view, props->normal_text_color_id, props->selected_text_color_id, props->disabled_text_color_id);\n"
160 "#endif\n"
161 " gx_multi_line_text_view_whitespace_set(view, props->whitespace);\n"
162 " gx_multi_line_text_view_line_space_set(view, props->line_space);\n"
163 " }\n"
164 " return status;\n"
165 "}\n";
166 }
167 else if (project_lib_version() >= 50303)
168 {
169 out += "{\n"
170 " UINT status;\n"
171 " GX_MULTI_LINE_TEXT_VIEW *view = (GX_MULTI_LINE_TEXT_VIEW *) control_block;\n"
172 " GX_ML_TEXT_VIEW_PROPERTIES *props = (GX_ML_TEXT_VIEW_PROPERTIES *) info->properties;\n"
173 " status = gx_multi_line_text_view_create(view, info->widget_name, parent, props->string_id, info->style, info->widget_id, &info->size);\n"
174 " if (status == GX_SUCCESS)\n"
175 " {\n"
176 " gx_multi_line_text_view_font_set(view, props->font_id);\n"
177 " gx_multi_line_text_view_text_color_set(view, props->normal_text_color_id, props->selected_text_color_id);\n"
178 " gx_multi_line_text_view_whitespace_set(view, props->whitespace);\n"
179 " gx_multi_line_text_view_line_space_set(view, props->line_space);\n"
180 " }\n"
181 " return status;\n"
182 "}\n";
183 }
184 else
185 {
186 out += "{\n"
187 " UINT status;\n"
188 " GX_MULTI_LINE_TEXT_VIEW *view = (GX_MULTI_LINE_TEXT_VIEW *) control_block;\n"
189 " GX_ML_TEXT_VIEW_PROPERTIES *props = (GX_ML_TEXT_VIEW_PROPERTIES *) info->properties;\n"
190 " status = gx_multi_line_text_view_create(view, info->widget_name, parent, props->string_id, info->style, info->widget_id, &info->size);\n"
191 " if (status == GX_SUCCESS)\n"
192 " {\n"
193 " gx_multi_line_text_view_font_set(view, props->font_id);\n"
194 " gx_multi_line_text_view_text_color_set(view, props->normal_text_color_id, props->selected_text_color_id);\n"
195 " }\n"
196 " return status;\n"
197 "}\n";
198 }
199
200 return out;
201 }
202
CreateNewInstance(GX_WIDGET * parent)203 widget_info *ml_text_view_service_provider::CreateNewInstance(GX_WIDGET *parent)
204 {
205 int parent_size;
206
207 GX_RECTANGLE size = parent->gx_widget_size;
208 gx_utility_rectangle_define(&size, 0, 0, 79, 23);
209 parent_size = (parent->gx_widget_size.gx_rectangle_right -
210 parent->gx_widget_size.gx_rectangle_left) / 2;
211 size.gx_rectangle_right = size.gx_rectangle_left + parent_size;
212
213 parent_size = (parent->gx_widget_size.gx_rectangle_bottom -
214 parent->gx_widget_size.gx_rectangle_top) / 2;
215 size.gx_rectangle_bottom = size.gx_rectangle_top + parent_size;
216
217 gx_utility_rectangle_center(&size, &parent->gx_widget_size);
218
219 GX_MULTI_LINE_TEXT_VIEW *view = new GX_MULTI_LINE_TEXT_VIEW;
220 GX_RESOURCE_ID string_id = GetStringId("text_view");
221
222 gx_multi_line_text_view_create(view, "text_view", parent, string_id,
223 GX_STYLE_ENABLED|GX_STYLE_BORDER_THIN|GX_STYLE_TEXT_CENTER, 0, &size);
224 gx_widget_style_remove(view, GX_STYLE_DRAW_SELECTED);
225 widget_info *info = InitWidgetInfo((GX_WIDGET *) view);
226
227 info->font_id[0] = view->gx_multi_line_text_view_font_id;
228 info->color_id[NORMAL_TEXT_COLOR_INDEX] = view->gx_multi_line_text_view_normal_text_color;
229 info->color_id[SELECTED_TEXT_COLOR_INDEX] = view->gx_multi_line_text_view_selected_text_color;
230 info->color_id[DISABLED_TEXT_COLOR_INDEX] = view->gx_multi_line_text_view_disabled_text_color;
231 info->string_id[0] = string_id;
232 info->ewi.text_info.whitespace = 0;
233 info->ewi.text_info.line_space = 0;
234 return info;
235 }
GenerateFromInfo(GX_WIDGET * parent,widget_info * info)236 GX_WIDGET *ml_text_view_service_provider::GenerateFromInfo(GX_WIDGET *parent, widget_info *info)
237 {
238 GX_MULTI_LINE_TEXT_VIEW *view = new GX_MULTI_LINE_TEXT_VIEW;
239 gx_multi_line_text_view_create(view,
240 (CHAR *) info->app_name.GetString(),
241 parent,
242 info->string_id[0],
243 info->style, 0,
244 &info->size);
245
246 gx_widget_fill_color_set(view,
247 info->color_id[NORMAL_FILL_COLOR_INDEX],
248 info->color_id[SELECTED_FILL_COLOR_INDEX],
249 info->color_id[DISABLED_FILL_COLOR_INDEX]);
250
251 gx_multi_line_text_view_text_color_set(view,
252 info->color_id[NORMAL_TEXT_COLOR_INDEX],
253 info->color_id[SELECTED_TEXT_COLOR_INDEX],
254 info->color_id[DISABLED_TEXT_COLOR_INDEX]);
255 gx_multi_line_text_view_font_set(view, info->font_id[0]);
256
257 gx_multi_line_text_view_whitespace_set(view, info->ewi.text_info.whitespace);
258 gx_multi_line_text_view_line_space_set(view, info->ewi.text_info.line_space);
259
260 return ((GX_WIDGET *) view);
261 }
262
SaveToProject(xml_writer & writer,studiox_project * project,int display,widget_info * info)263 void ml_text_view_service_provider::SaveToProject(xml_writer &writer, studiox_project *project, int display, widget_info *info)
264 {
265 widget_service_provider::SaveToProject(writer, project, display, info);
266 WriteStringId(writer, project, display, "string_id", info->string_id[0]);
267 WriteFontId(writer, project, display, "font_id", info->font_id[0]);
268 WriteColorId(writer, project, display, "normal_text_color", info->color_id[NORMAL_TEXT_COLOR_INDEX]);
269 WriteColorId(writer, project, display, "selected_text_color", info->color_id[SELECTED_TEXT_COLOR_INDEX]);
270 WriteColorId(writer, project, display, "disabled_fill_color", info->color_id[DISABLED_FILL_COLOR_INDEX]);
271 WriteColorId(writer, project, display, "disabled_text_color", info->color_id[DISABLED_TEXT_COLOR_INDEX]);
272 writer.WriteInt("whitespace", info->ewi.text_info.whitespace);
273 writer.WriteInt("line_space", info->ewi.text_info.line_space);
274 }
275
ReadFromProject(xml_reader & reader,studiox_project * project,int display,widget_info * info,ULONG valid_styles)276 void ml_text_view_service_provider::ReadFromProject(xml_reader &reader, studiox_project *project, int display, widget_info *info, ULONG valid_styles)
277 {
278 valid_styles |= GX_STYLE_TEXT_ALIGNMENT_MASK|GX_STYLE_TEXT_COPY|GX_STYLE_VALIGN_CENTER;
279 widget_service_provider::ReadFromProject(reader, project, display, info, valid_styles);
280 info->string_id[0] = ReadStringId(reader, project, display, "string_id");
281 if (info->string_id[0] < 0 || info->string_id[0] > 100000)
282 {
283 info->string_id[0] = 0;
284 }
285 info->font_id[0] = ReadFontId(reader, project, display, "font_id");
286 info->color_id[NORMAL_TEXT_COLOR_INDEX] = ReadColorId(reader, project, display, "normal_text_color");
287
288 if (project->mHeader.project_version > 54)
289 {
290 info->color_id[SELECTED_TEXT_COLOR_INDEX] = ReadColorId(reader, project, display, "selected_text_color");
291 info->color_id[DISABLED_TEXT_COLOR_INDEX] = ReadColorId(reader, project, display, "disabled_text_color");
292 }
293 else
294 {
295 info->color_id[SELECTED_FILL_COLOR_INDEX] = info->color_id[NORMAL_FILL_COLOR_INDEX];
296 info->color_id[SELECTED_TEXT_COLOR_INDEX] = info->color_id[NORMAL_TEXT_COLOR_INDEX];
297 info->color_id[DISABLED_TEXT_COLOR_INDEX] = info->color_id[NORMAL_TEXT_COLOR_INDEX];
298 }
299 reader.ReadInt("whitespace", info->ewi.text_info.whitespace, 0);
300 reader.ReadInt("line_space", info->ewi.text_info.line_space, 0);
301 }
302
AssignText(widget_info * info,int index,GX_RESOURCE_ID string_id)303 void ml_text_view_service_provider::AssignText(widget_info *info, int index,
304 GX_RESOURCE_ID string_id)
305 {
306 info->string_id[0] = string_id;
307 GX_WIDGET *widget = info->widget;
308
309 if (widget)
310 {
311 GX_MULTI_LINE_TEXT_VIEW *view = (GX_MULTI_LINE_TEXT_VIEW *)widget;
312 gx_multi_line_text_view_text_id_set(view, string_id);
313 }
314 }
315
AssignFont(widget_info * info,int index,GX_RESOURCE_ID font_id)316 void ml_text_view_service_provider::AssignFont(widget_info *info, int index, GX_RESOURCE_ID font_id)
317 {
318 info->font_id[0] = font_id;
319 GX_WIDGET *widget = info->widget;
320
321 if (widget)
322 {
323 GX_MULTI_LINE_TEXT_VIEW *pb = (GX_MULTI_LINE_TEXT_VIEW *)widget;
324 gx_multi_line_text_view_font_set(pb, font_id);
325 }
326 }
327
AssignColor(widget_info * info,int index,GX_RESOURCE_ID color_id)328 void ml_text_view_service_provider::AssignColor(widget_info *info, int index, GX_RESOURCE_ID color_id)
329 {
330 GX_MULTI_LINE_TEXT_VIEW *view = (GX_MULTI_LINE_TEXT_VIEW *) (info->widget);
331
332 switch(index)
333 {
334 case NORMAL_TEXT_COLOR_INDEX:
335 if (view)
336 {
337 gx_multi_line_text_view_text_color_set(view, color_id, view->gx_multi_line_text_view_selected_text_color, view->gx_multi_line_text_view_disabled_text_color);
338 }
339
340 info->color_id[NORMAL_TEXT_COLOR_INDEX] = color_id;
341 break;
342
343 case SELECTED_TEXT_COLOR_INDEX:
344 if (view)
345 {
346 gx_multi_line_text_view_text_color_set(view, view->gx_multi_line_text_view_normal_text_color, color_id, view->gx_multi_line_text_view_disabled_text_color);
347 }
348
349 info->color_id[SELECTED_TEXT_COLOR_INDEX] = color_id;
350 break;
351
352 case DISABLED_TEXT_COLOR_INDEX:
353 if (view)
354 {
355 gx_multi_line_text_view_text_color_set(view, view->gx_multi_line_text_view_normal_text_color, view->gx_multi_line_text_view_selected_text_color, color_id);
356 }
357 info->color_id[DISABLED_TEXT_COLOR_INDEX] = color_id;
358 break;
359
360 default:
361 window_service_provider::AssignColor(info, index, color_id);
362 }
363 }