1
2 #include "studiox_includes.h"
3
4 #ifdef _DEBUG
5 #define new DEBUG_NEW
6 #endif
7
8 ///////////////////////////////////////////////////////////////////////////////
numeric_scroll_wheel_service_provider()9 numeric_scroll_wheel_service_provider::numeric_scroll_wheel_service_provider()
10 {
11 }
12
13
14 ///////////////////////////////////////////////////////////////////////////////
GetVarDeclaration()15 CString numeric_scroll_wheel_service_provider::GetVarDeclaration()
16 {
17 return CString("GX_STRING_SCROLL_WHEEL_MEMBERS_DECLARE");
18 }
19
20 ///////////////////////////////////////////////////////////////////////////////
DeclarePropertiesStruct()21 CString numeric_scroll_wheel_service_provider::DeclarePropertiesStruct()
22 {
23 CString out;
24 CString callback;
25
26 if (project_lib_version() >= GX_VERSION_STRING_LENGTH_FIX)
27 {
28 callback = "UINT (*callback)(struct GX_NUMERIC_SCROLL_WHEEL_STRUCT *, INT, GX_STRING *)";
29 }
30 else
31 {
32 callback = "GX_CONST GX_CHAR * (*callback)(struct GX_NUMERIC_SCROLL_WHEEL_STRUCT *, INT)";
33 }
34
35 out.Format(
36 _T("typedef struct\n")
37 _T("{\n")
38 _T("%s\n")
39 _T(" %s;\n")
40 _T(" int start_val;\n")
41 _T(" int end_val;\n")
42 _T("} GX_NUMERIC_SCROLL_WHEEL_PROPERTIES;\n\n"),
43 text_scroll_wheel_service_provider::DeclarePropertiesStructContent(),
44 callback);
45
46 return out;
47 }
48
49 ///////////////////////////////////////////////////////////////////////////////
WriteExtendedProperties(screen_generator * gen,CString & prefix,widget_info * info)50 CString numeric_scroll_wheel_service_provider::WriteExtendedProperties(screen_generator *gen, CString &prefix, widget_info *info)
51 {
52 CString out;
53 CString propname = prefix + info->app_name;
54 CString callback;
55
56 if (info->callback_func.IsEmpty())
57 {
58 callback = "GX_NULL";
59 }
60 else
61 {
62 callback = info->callback_func;
63 }
64
65 out.Format(_T("GX_NUMERIC_SCROLL_WHEEL_PROPERTIES %s_properties =\n")
66 _T("{\n")
67 _T("%s\n")
68 _T(" %s, /* format callback */\n")
69 _T(" %d, /* start val */\n")
70 _T(" %d, /* end val */\n")
71 _T("};\n"),
72 propname,
73 text_scroll_wheel_service_provider::WriteExtendedPropertiesContent(gen, info, TRUE),
74 callback,
75 info->ewi.numeric_scroll_wheel.start_val,
76 info->ewi.numeric_scroll_wheel.end_val);
77
78 return out;
79 }
80
81
82 ///////////////////////////////////////////////////////////////////////////////
GetCreateFromDefFunctionName()83 CString numeric_scroll_wheel_service_provider::GetCreateFromDefFunctionName()
84 {
85 return CString("gx_studio_numeric_scroll_wheel_create");
86 }
87
88 ///////////////////////////////////////////////////////////////////////////////
GetCreateFromDefFunction(int version)89 CString numeric_scroll_wheel_service_provider::GetCreateFromDefFunction(int version)
90 {
91 CString out;
92 MakeCreatePreamble("numeric_scroll_wheel", version, out);
93
94 out += "{\n"
95 " UINT status;\n"
96 " GX_NUMERIC_SCROLL_WHEEL *wheel = (GX_NUMERIC_SCROLL_WHEEL *) control_block;\n"
97 " GX_NUMERIC_SCROLL_WHEEL_PROPERTIES *props = (GX_NUMERIC_SCROLL_WHEEL_PROPERTIES *) info->properties;\n"
98 " status = gx_numeric_scroll_wheel_create(wheel, info->widget_name, parent, props->start_val, props->end_val, \n"
99 " info->style, info->widget_id, &info->size);\n"
100 " if (status == GX_SUCCESS)\n"
101 " {\n"
102 " if (props->wallpaper_id)\n"
103 " {\n"
104 " gx_window_wallpaper_set((GX_WINDOW *) wheel, props->wallpaper_id, info->style & GX_STYLE_TILE_WALLPAPER);\n"
105 " }\n"
106 " if(props->selected_background)\n"
107 " {\n"
108 " gx_scroll_wheel_selected_background_set((GX_SCROLL_WHEEL *)wheel, props->selected_background);\n"
109 " }\n\n"
110 " if (props->total_rows)\n"
111 " {\n"
112 " gx_scroll_wheel_total_rows_set((GX_SCROLL_WHEEL *)wheel, props->total_rows);\n"
113 " }\n\n"
114 " gx_scroll_wheel_selected_set((GX_SCROLL_WHEEL *)wheel, props->selected_row);\n"
115 " gx_scroll_wheel_gradient_alpha_set((GX_SCROLL_WHEEL *)wheel, props->start_alpha, props->end_alpha);\n"
116 " gx_scroll_wheel_row_height_set((GX_SCROLL_WHEEL *)wheel, props->row_height);\n"
117 " gx_text_scroll_wheel_font_set((GX_TEXT_SCROLL_WHEEL *)wheel, props->normal_font, props->selected_font);\n";
118
119 if (project_lib_version() > 50401)
120 {
121 out += "#if defined(GUIX_5_4_0_COMPATIBILITY)\n"
122 " gx_text_scroll_wheel_text_color_set((GX_TEXT_SCROLL_WHEEL *)wheel, props->normal_text_color, props->selected_text_color);\n"
123 "#else\n"
124 " gx_text_scroll_wheel_text_color_set((GX_TEXT_SCROLL_WHEEL *)wheel, props->normal_text_color, props->selected_text_color, props->disabled_text_color);\n"
125 "#endif\n";
126 }
127 else
128 {
129 out += " gx_text_scroll_wheel_text_color_set((GX_TEXT_SCROLL_WHEEL *)wheel, props->normal_text_color, props->selected_text_color);\n";
130 }
131
132
133 out += " if(props->callback)\n"
134 " {\n";
135 if (project_lib_version() >= GX_VERSION_STRING_LENGTH_FIX)
136 {
137 out += " gx_text_scroll_wheel_callback_set_ext((GX_TEXT_SCROLL_WHEEL *)wheel, (UINT (*)(GX_TEXT_SCROLL_WHEEL*, INT, GX_STRING *))props->callback);\n";
138 }
139 else
140 {
141 out += " gx_text_scroll_wheel_callback_set((GX_TEXT_SCROLL_WHEEL *)wheel, (GX_CONST GX_CHAR *(*)(GX_TEXT_SCROLL_WHEEL*, INT))props->callback);\n";
142 }
143
144 out += " }\n"
145 " }\n"
146 " return status;\n"
147 "}\n";
148
149 return out;
150 }
151
152
153 ///////////////////////////////////////////////////////////////////////////////
CreateNewInstance(GX_WIDGET * parent)154 widget_info *numeric_scroll_wheel_service_provider::CreateNewInstance(GX_WIDGET *parent)
155 {
156 int parent_size;
157
158 GX_RECTANGLE size = parent->gx_widget_size;
159 gx_utility_rectangle_define(&size, 0, 0, 79, 23);
160 parent_size = (parent->gx_widget_size.gx_rectangle_right -
161 parent->gx_widget_size.gx_rectangle_left) / 4;
162 size.gx_rectangle_right = size.gx_rectangle_left + parent_size;
163
164 parent_size = (parent->gx_widget_size.gx_rectangle_bottom -
165 parent->gx_widget_size.gx_rectangle_top) / 2;
166 size.gx_rectangle_bottom = size.gx_rectangle_top + parent_size;
167
168 gx_utility_rectangle_center(&size, &parent->gx_widget_size);
169
170 GX_NUMERIC_SCROLL_WHEEL *wheel = new GX_NUMERIC_SCROLL_WHEEL;
171 gx_numeric_scroll_wheel_create(wheel, "numeric_scroll_wheel", parent, 0, 10,
172 GX_STYLE_ENABLED | GX_STYLE_BORDER_THIN | GX_STYLE_TEXT_CENTER | GX_STYLE_WRAP, 0, &size);
173
174 gx_widget_style_remove((GX_WIDGET *)wheel, GX_STYLE_DRAW_SELECTED);
175
176 widget_info *info = InitWidgetInfo((GX_WIDGET *)wheel);
177 info->pixelmap_id[WALLPAPER_PIXELMAP_INDEX] = 0;
178 info->ewi.numeric_scroll_wheel.base.start_alpha = wheel->gx_scroll_wheel_gradient.gx_gradient_alpha_start;
179 info->ewi.numeric_scroll_wheel.base.end_alpha = wheel->gx_scroll_wheel_gradient.gx_gradient_alpha_end;
180 info->ewi.numeric_scroll_wheel.base.row_height = wheel->gx_scroll_wheel_row_height;
181 info->ewi.numeric_scroll_wheel.base.selected_row = wheel->gx_scroll_wheel_selected_row;
182 info->ewi.numeric_scroll_wheel.base.total_rows = wheel->gx_scroll_wheel_total_rows;
183 info->ewi.numeric_scroll_wheel.start_val = wheel->gx_numeric_scroll_wheel_start_val;
184 info->ewi.numeric_scroll_wheel.end_val = wheel->gx_numeric_scroll_wheel_end_val;
185 info->color_id[NORMAL_TEXT_COLOR_INDEX] = wheel->gx_text_scroll_wheel_normal_text_color;
186 info->color_id[SELECTED_TEXT_COLOR_INDEX] = wheel->gx_text_scroll_wheel_selected_text_color;
187 info->color_id[DISABLED_TEXT_COLOR_INDEX] = wheel->gx_text_scroll_wheel_disabled_text_color;
188 info->font_id[NORMAL_FONT_INDEX] = wheel->gx_text_scroll_wheel_normal_font;
189 info->font_id[SELECTED_FONT_INDEX] = wheel->gx_text_scroll_wheel_selected_font;
190
191 return info;
192 }
193
194 ///////////////////////////////////////////////////////////////////////////////
GenerateFromInfo(GX_WIDGET * parent,widget_info * info)195 GX_WIDGET *numeric_scroll_wheel_service_provider::GenerateFromInfo(GX_WIDGET *parent, widget_info *info)
196 {
197 GX_NUMERIC_SCROLL_WHEEL *wheel = new GX_NUMERIC_SCROLL_WHEEL;
198
199 // Create scroll wheel widget.
200 gx_numeric_scroll_wheel_create(wheel,
201 (CHAR *)info->app_name.GetString(),
202 parent,
203 info->ewi.numeric_scroll_wheel.start_val,
204 info->ewi.numeric_scroll_wheel.end_val,
205 info->style,
206 0,
207 &info->size);
208
209 // Set fill color.
210 gx_widget_fill_color_set(wheel,
211 info->color_id[NORMAL_FILL_COLOR_INDEX],
212 info->color_id[SELECTED_FILL_COLOR_INDEX], info->color_id[DISABLED_FILL_COLOR_INDEX]);
213
214 // Set wallpaper.
215 if (info->pixelmap_id[WALLPAPER_PIXELMAP_INDEX] > 0)
216 {
217 BOOL tile = FALSE;
218
219 if (info->style & GX_STYLE_TILE_WALLPAPER)
220 {
221 tile = TRUE;
222 }
223 gx_window_wallpaper_set((GX_WINDOW *)wheel, info->pixelmap_id[WALLPAPER_PIXELMAP_INDEX], tile);
224 }
225
226 // Set selected row background.
227 if (info->pixelmap_id[SCROLL_WHEEL_PIXELMAP_INDEX] > 0)
228 {
229 gx_scroll_wheel_selected_background_set((GX_SCROLL_WHEEL *)wheel, info->pixelmap_id[SCROLL_WHEEL_PIXELMAP_INDEX]);
230 }
231
232 // Set scroll wheel properties.
233 gx_text_scroll_wheel_font_set((GX_TEXT_SCROLL_WHEEL *)wheel, info->font_id[0], info->font_id[1]);
234 gx_text_scroll_wheel_text_color_set((GX_TEXT_SCROLL_WHEEL *)wheel, info->color_id[NORMAL_TEXT_COLOR_INDEX],
235 info->color_id[SELECTED_TEXT_COLOR_INDEX], info->color_id[DISABLED_TEXT_COLOR_INDEX]);
236 gx_scroll_wheel_gradient_alpha_set((GX_SCROLL_WHEEL *)wheel, info->ewi.numeric_scroll_wheel.base.start_alpha, info->ewi.numeric_scroll_wheel.base.end_alpha);
237 gx_scroll_wheel_row_height_set((GX_SCROLL_WHEEL *) wheel, info->ewi.numeric_scroll_wheel.base.row_height);
238 gx_scroll_wheel_selected_set((GX_SCROLL_WHEEL *)wheel, info->ewi.numeric_scroll_wheel.base.selected_row);
239
240 if (info->ewi.numeric_scroll_wheel.base.total_rows > 0)
241 {
242 gx_scroll_wheel_total_rows_set((GX_SCROLL_WHEEL *)wheel, info->ewi.numeric_scroll_wheel.base.total_rows);
243 }
244
245 return (GX_WIDGET *)wheel;
246 }
247
248 ///////////////////////////////////////////////////////////////////////////////
SaveToProject(xml_writer & writer,studiox_project * project,int display,widget_info * info)249 void numeric_scroll_wheel_service_provider::SaveToProject(xml_writer &writer, studiox_project *project, int display, widget_info *info)
250 {
251 text_scroll_wheel_service_provider::SaveToProject(writer, project, display, info);
252
253 writer.WriteInt("start_val", info->ewi.numeric_scroll_wheel.start_val);
254 writer.WriteInt("end_val", info->ewi.numeric_scroll_wheel.end_val);
255 }
256
257 ///////////////////////////////////////////////////////////////////////////////
ReadFromProject(xml_reader & reader,studiox_project * project,int display,widget_info * info,ULONG valid_styles)258 void numeric_scroll_wheel_service_provider::ReadFromProject(xml_reader &reader, studiox_project *project, int display, widget_info *info, ULONG valid_styles)
259 {
260 text_scroll_wheel_service_provider::ReadFromProject(reader, project, display, info, valid_styles);
261
262 reader.ReadInt("start_val", info->ewi.numeric_scroll_wheel.start_val);
263 reader.ReadInt("end_val", info->ewi.numeric_scroll_wheel.end_val);
264 }
265
266 ///////////////////////////////////////////////////////////////////////////////
AssignValueRange(widget_info * info,int start_val,int end_val)267 void numeric_scroll_wheel_service_provider::AssignValueRange(widget_info *info, int start_val, int end_val)
268 {
269 info->ewi.numeric_scroll_wheel.start_val = start_val;
270 info->ewi.numeric_scroll_wheel.end_val = end_val;
271
272 GX_NUMERIC_SCROLL_WHEEL *wheel = (GX_NUMERIC_SCROLL_WHEEL *) (info->widget);
273
274 if (wheel)
275 {
276 gx_numeric_scroll_wheel_range_set(wheel, start_val, end_val);
277 }
278 }
279