1
2 #include "studiox_includes.h"
3
4 #ifdef _DEBUG
5 #define new DEBUG_NEW
6 #endif
7
numeric_pixelmap_prompt_service_provider()8 numeric_pixelmap_prompt_service_provider::numeric_pixelmap_prompt_service_provider()
9 {
10 }
11
GetVarDeclaration()12 CString numeric_pixelmap_prompt_service_provider::GetVarDeclaration()
13 {
14 return CString("GX_NUMERIC_PIXELMAP_PROMPT_MEMBERS_DECLARE");
15 }
16
DeclarePropertiesStruct()17 CString numeric_pixelmap_prompt_service_provider::DeclarePropertiesStruct()
18 {
19 CString out;
20
21 out.Format(_T("typedef struct\n")
22 _T("{\n")
23 _T("%s\n")
24 _T(" VOID (*format_func)(GX_NUMERIC_PIXELMAP_PROMPT *, INT);\n")
25 _T(" INT numeric_prompt_value;\n")
26 _T("} GX_NUMERIC_PIXELMAP_PROMPT_PROPERTIES;\n\n"),
27 pixelmap_prompt_service_provider::DeclarePropertiesStructContent());
28 return out;
29 }
30
WriteExtendedProperties(screen_generator * gen,CString & prefix,widget_info * info)31 CString numeric_pixelmap_prompt_service_provider::WriteExtendedProperties(screen_generator *gen, CString &prefix, widget_info *info)
32 {
33 CString out;
34 CString propname = prefix + info->app_name;
35 CString format_func;
36
37 if (info->format_func.IsEmpty())
38 {
39 format_func = "GX_NULL";
40 }
41 else
42 {
43 format_func = info->format_func;
44 }
45
46 out.Format(_T("GX_NUMERIC_PIXELMAP_PROMPT_PROPERTIES %s_properties =\n")
47 _T("{\n")
48 _T("%s\n")
49 _T(" %s, /* format function */\n")
50 _T(" %d /* numeric prompt value */\n};\n"),
51 propname,
52 pixelmap_prompt_service_provider::WriteExtendedPropertiesContent(gen, info, TRUE),
53 format_func,
54 info->ewi.numeric_prompt_value);
55 return out;
56 }
57
GetCreateFromDefFunctionName()58 CString numeric_pixelmap_prompt_service_provider::GetCreateFromDefFunctionName()
59 {
60 return CString("gx_studio_numeric_pixelmap_prompt_create");
61 }
62
GetCreateFromDefFunction(int version)63 CString numeric_pixelmap_prompt_service_provider::GetCreateFromDefFunction(int version)
64 {
65 CString out;
66 MakeCreatePreamble("numeric_pixelmap_prompt", version, out);
67
68 out += "{\n"
69 " UINT status;\n"
70 " GX_NUMERIC_PIXELMAP_PROMPT *pix_prompt = (GX_NUMERIC_PIXELMAP_PROMPT *) control_block;\n"
71 " GX_PROMPT *prompt = (GX_PROMPT *) pix_prompt;\n"
72 " GX_NUMERIC_PIXELMAP_PROMPT_PROPERTIES *props = (GX_NUMERIC_PIXELMAP_PROMPT_PROPERTIES *) info->properties;\n"
73 " status = gx_numeric_pixelmap_prompt_create(pix_prompt, info->widget_name, parent,\n"
74 " props->string_id,\n"
75 " props->fill_map_id,\n"
76 " info->style, info->widget_id, &info->size);\n"
77 "\n"
78 " if (status == GX_SUCCESS)\n"
79 " {\n"
80 " if(!props->string_id)\n"
81 " {\n"
82 " gx_numeric_pixelmap_prompt_value_set(pix_prompt, props->numeric_prompt_value);\n"
83 " }\n"
84 " if(props->format_func)\n"
85 " {\n"
86 " gx_numeric_pixelmap_prompt_format_function_set(pix_prompt, props->format_func);\n"
87 " }\n"
88 " gx_pixelmap_prompt_pixelmap_set((GX_PIXELMAP_PROMPT *)pix_prompt,\n"
89 " props->left_map_id,\n"
90 " props->fill_map_id,\n"
91 " props->right_map_id,\n"
92 " props->selected_left_map_id,\n"
93 " props->selected_fill_map_id,\n"
94 " props->selected_right_map_id);\n"
95 " gx_prompt_font_set(prompt, props->font_id);\n";
96
97 if (version > 50401)
98 {
99 out += "#if defined(GUIX_5_4_0_COMPATIBILITY)\n"
100 " gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id);\n"
101 "#else\n"
102 " gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id, props->disabled_text_color_id);\n"
103 "#endif\n";
104 }
105 else
106 {
107 out += " gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id);\n";
108 }
109 out += " }\n"
110 " return status;\n"
111 "}\n";
112
113 return out;
114 }
115
CreateNewInstance(GX_WIDGET * parent)116 widget_info *numeric_pixelmap_prompt_service_provider::CreateNewInstance(GX_WIDGET *parent)
117 {
118 GX_RECTANGLE size;
119 gx_utility_rectangle_define(&size, 0, 0, 79, 23);
120 gx_utility_rectangle_center(&size, &parent->gx_widget_size);
121
122 GX_NUMERIC_PIXELMAP_PROMPT *prompt = new GX_NUMERIC_PIXELMAP_PROMPT;
123
124 gx_numeric_pixelmap_prompt_create(prompt, "numeric_pixelmap_prompt", parent, 0, 0,
125 GX_STYLE_ENABLED | GX_STYLE_BORDER_THIN | GX_STYLE_TEXT_CENTER, 0, &size);
126
127 widget_info *info = InitWidgetInfo((GX_WIDGET *)prompt);
128 info->pixelmap_id[FILL_PIXELMAP_INDEX] = 0;
129 info->pixelmap_id[LEFT_PIXELMAP_INDEX] = 0;
130 info->pixelmap_id[RIGHT_PIXELMAP_INDEX] = 0;
131 info->pixelmap_id[SELECTED_FILL_PIXELMAP_INDEX] = 0;
132 info->pixelmap_id[SELECTED_LEFT_PIXELMAP_INDEX] = 0;
133 info->pixelmap_id[SELECTED_RIGHT_PIXELMAP_INDEX] = 0;
134 info->string_id[0] = 0;
135 info->font_id[0] = prompt->gx_prompt_font_id;
136 info->color_id[NORMAL_TEXT_COLOR_INDEX] = prompt->gx_prompt_normal_text_color;
137 info->color_id[SELECTED_TEXT_COLOR_INDEX] = prompt->gx_prompt_selected_text_color;
138 info->color_id[DISABLED_TEXT_COLOR_INDEX] = prompt->gx_prompt_disabled_text_color;
139 info->ewi.numeric_prompt_value = 0;
140
141 gx_numeric_pixelmap_prompt_value_set(prompt, info->ewi.numeric_prompt_value);
142 return info;
143 }
144
GenerateFromInfo(GX_WIDGET * parent,widget_info * info)145 GX_WIDGET *numeric_pixelmap_prompt_service_provider::GenerateFromInfo(GX_WIDGET *parent, widget_info *info)
146 {
147 GX_NUMERIC_PIXELMAP_PROMPT *prompt = new GX_NUMERIC_PIXELMAP_PROMPT;
148
149 gx_numeric_pixelmap_prompt_create(prompt,
150 (CHAR *)info->app_name.GetString(),
151 parent,
152 info->string_id[0],
153 info->pixelmap_id[FILL_PIXELMAP_INDEX],
154 info->style, 0, &info->size);
155
156 if (!info->string_id[0])
157 {
158 gx_numeric_pixelmap_prompt_value_set(prompt, info->ewi.numeric_prompt_value);
159 }
160
161 gx_pixelmap_prompt_pixelmap_set((GX_PIXELMAP_PROMPT *)prompt,
162 info->pixelmap_id[LEFT_PIXELMAP_INDEX],
163 info->pixelmap_id[FILL_PIXELMAP_INDEX],
164 info->pixelmap_id[RIGHT_PIXELMAP_INDEX],
165 info->pixelmap_id[SELECTED_LEFT_PIXELMAP_INDEX],
166 info->pixelmap_id[SELECTED_FILL_PIXELMAP_INDEX],
167 info->pixelmap_id[SELECTED_RIGHT_PIXELMAP_INDEX]);
168
169 gx_widget_fill_color_set((GX_PROMPT *)prompt,
170 info->color_id[NORMAL_FILL_COLOR_INDEX],
171 info->color_id[SELECTED_FILL_COLOR_INDEX],
172 info->color_id[DISABLED_FILL_COLOR_INDEX]);
173
174 gx_prompt_text_color_set((GX_PROMPT *)prompt,
175 info->color_id[NORMAL_TEXT_COLOR_INDEX],
176 info->color_id[SELECTED_TEXT_COLOR_INDEX],
177 info->color_id[DISABLED_TEXT_COLOR_INDEX]);
178 gx_prompt_font_set((GX_PROMPT *)prompt, info->font_id[0]);
179
180 return (GX_WIDGET *)prompt;
181 }
182
SaveToProject(xml_writer & writer,studiox_project * project,int display,widget_info * info)183 void numeric_pixelmap_prompt_service_provider::SaveToProject(xml_writer &writer, studiox_project *project, int display, widget_info *info)
184 {
185 pixelmap_prompt_service_provider::SaveToProject(writer, project, display, info);
186
187 /* Write format function. */
188 writer.WriteString("format_func", info->format_func);
189
190 /* Write numeric prompt value. */
191 writer.WriteInt("numeric_prompt_value", info->ewi.numeric_prompt_value);
192 }
193
ReadFromProject(xml_reader & reader,studiox_project * project,int display,widget_info * info,ULONG valid_styles)194 void numeric_pixelmap_prompt_service_provider::ReadFromProject(xml_reader &reader, studiox_project *project, int display, widget_info *info, ULONG valid_styles)
195 {
196 pixelmap_prompt_service_provider::ReadFromProject(reader, project, display, info, valid_styles);
197
198 /* Write format function. */
199 reader.ReadString("format_func", info->format_func);
200
201 /* Read prompt value. */
202 reader.ReadInt("numeric_prompt_value", info->ewi.numeric_prompt_value, 0);
203 }
204
AssignNumericValue(widget_info * info,INT value)205 void numeric_pixelmap_prompt_service_provider::AssignNumericValue(widget_info *info, INT value)
206 {
207 info->ewi.numeric_prompt_value = value;
208 info->string_id[0] = 0;
209
210 /* Set new numeric value. */
211 gx_numeric_pixelmap_prompt_value_set((GX_NUMERIC_PIXELMAP_PROMPT *)info->widget, value);
212 }