1
2 #include "studiox_includes.h"
3
4 #ifdef _DEBUG
5 #define new DEBUG_NEW
6 #endif
7
8 ///////////////////////////////////////////////////////////////////////////////
hscroll_service_provider()9 hscroll_service_provider::hscroll_service_provider()
10 {
11 }
12
13 ///////////////////////////////////////////////////////////////////////////////
GetVarDeclaration()14 CString hscroll_service_provider::GetVarDeclaration()
15 {
16 return CString("GX_HSCROLL_MEMBERS_DECLARE");
17 }
18
19 ///////////////////////////////////////////////////////////////////////////////
WriteExtendedProperties(screen_generator * gen,CString & prefix,widget_info * info)20 CString hscroll_service_provider::WriteExtendedProperties(screen_generator *gen, CString &prefix, widget_info *info)
21 {
22 CString out;
23 CString propname = prefix + info->app_name;
24
25 if (project_lib_version() >= 50302)
26 {
27 out.Format(_T("GX_SCROLLBAR_APPEARANCE %s_properties =\n")
28 _T("{\n")
29 _T(" %d, /* scroll width */\n")
30 _T(" %d, /* thumb width */\n")
31 _T(" %d, /* thumb travel min */\n")
32 _T(" %d, /* thumb travel max */\n")
33 _T(" %d, /* thumb border style */\n")
34 _T(" %s, /* scroll fill pixelmap */\n")
35 _T(" %s, /* scroll thumb pixelmap */\n")
36 _T(" %s, /* scroll up pixelmap */\n")
37 _T(" %s, /* scroll down pixelmap */\n")
38 _T(" %s, /* scroll thumb color */\n")
39 _T(" %s, /* scroll thumb border color */\n")
40 _T(" %s, /* scroll button color */\n")
41 _T("};\n"),
42 propname,
43 info->ewi.scroll.gx_scroll_width,
44 info->ewi.scroll.gx_scroll_thumb_width,
45 info->ewi.scroll.gx_scroll_thumb_travel_min,
46 info->ewi.scroll.gx_scroll_thumb_travel_max,
47 info->ewi.scroll.gx_scroll_thumb_border_style,
48 gen->GetPixelmapIdName(info->ewi.scroll.gx_scroll_fill_pixelmap),
49 gen->GetPixelmapIdName(info->ewi.scroll.gx_scroll_thumb_pixelmap),
50 gen->GetPixelmapIdName(info->ewi.scroll.gx_scroll_up_pixelmap),
51 gen->GetPixelmapIdName(info->ewi.scroll.gx_scroll_down_pixelmap),
52 gen->GetColorIdName(info->ewi.scroll.gx_scroll_thumb_color),
53 gen->GetColorIdName(info->ewi.scroll.gx_scroll_thumb_border_color),
54 gen->GetColorIdName(info->ewi.scroll.gx_scroll_button_color));
55 }
56 else
57 {
58 out.Format(_T("GX_SCROLLBAR_APPEARANCE %s_properties =\n")
59 _T("{\n")
60 _T(" %d, /* scroll width */\n")
61 _T(" %d, /* thumb width */\n")
62 _T(" %d, /* thumb travel min */\n")
63 _T(" %d, /* thumb travel max */\n")
64 _T(" %s, /* scroll fill pixelmap */\n")
65 _T(" %s, /* scroll thumb pixelmap */\n")
66 _T(" %s, /* scroll up pixelmap */\n")
67 _T(" %s, /* scroll down pixelmap */\n")
68 _T(" %s, /* scroll fill color */\n")
69 _T(" %s, /* scroll button color */\n")
70 _T("};\n"),
71 propname,
72 info->ewi.scroll.gx_scroll_width,
73 info->ewi.scroll.gx_scroll_thumb_width,
74 info->ewi.scroll.gx_scroll_thumb_travel_min,
75 info->ewi.scroll.gx_scroll_thumb_travel_max,
76 gen->GetPixelmapIdName(info->ewi.scroll.gx_scroll_fill_pixelmap),
77 gen->GetPixelmapIdName(info->ewi.scroll.gx_scroll_thumb_pixelmap),
78 gen->GetPixelmapIdName(info->ewi.scroll.gx_scroll_up_pixelmap),
79 gen->GetPixelmapIdName(info->ewi.scroll.gx_scroll_down_pixelmap),
80 gen->GetColorIdName(info->color_id[NORMAL_FILL_COLOR_INDEX]),
81 gen->GetColorIdName(info->ewi.scroll.gx_scroll_button_color));
82 }
83 return out;
84 }
85
86 ///////////////////////////////////////////////////////////////////////////////
GetCreateFromDefFunctionName()87 CString hscroll_service_provider::GetCreateFromDefFunctionName()
88 {
89 return CString("gx_studio_horizontal_scrollbar_create");
90 }
91
92 ///////////////////////////////////////////////////////////////////////////////
GetCreateFromDefFunction(int version)93 CString hscroll_service_provider::GetCreateFromDefFunction(int version)
94 {
95 CString out;
96 MakeCreatePreamble("horizontal_scrollbar", version, out);
97
98 out += "{\n"
99 " UINT status;\n"
100 " GX_SCROLLBAR *scroll = (GX_SCROLLBAR *) control_block;\n"
101 " GX_SCROLLBAR_APPEARANCE *appearance = (GX_SCROLLBAR_APPEARANCE *) info->properties;\n"
102 " status = gx_horizontal_scrollbar_create(scroll, info->widget_name, parent, appearance, info->style);\n"
103 " return status;\n"
104 "}\n";
105
106 return out;
107 }
108
109 ///////////////////////////////////////////////////////////////////////////////
SaveToProject(xml_writer & writer,studiox_project * project,int display,widget_info * info)110 void hscroll_service_provider::SaveToProject(xml_writer &writer, studiox_project *project, int display, widget_info *info)
111 {
112 widget_service_provider::SaveToProject(writer, project, display, info);
113 vscroll_service_provider::WriteScrollbarAppearance(writer, project, display, info->ewi.scroll);
114 }
115
116 ///////////////////////////////////////////////////////////////////////////////
ReadFromProject(xml_reader & reader,studiox_project * project,int display,widget_info * info,ULONG valid_styles)117 void hscroll_service_provider::ReadFromProject(xml_reader &reader, studiox_project *project, int display, widget_info *info, ULONG valid_styles)
118 {
119 valid_styles |= GX_STYLE_TILE_BACKGROUND|GX_SCROLLBAR_RELATIVE_THUMB|GX_SCROLLBAR_END_BUTTONS|GX_SCROLLBAR_VERTICAL|GX_SCROLLBAR_HORIZONTAL|GX_STYLE_TILE_BACKGROUND;
120 widget_service_provider::ReadFromProject(reader, project, display, info, valid_styles);
121 vscroll_service_provider::ReadScrollbarAppearance(reader, project, display, info->ewi.scroll);
122
123 // copy the scroll appearance pixlemap ids into the normal slots so that the
124 // properties win can correctly detect changes.
125 info->pixelmap_id[SCROLL_FILL_PIXELMAP_INDEX] = info->ewi.scroll.gx_scroll_fill_pixelmap;
126 info->pixelmap_id[SCROLL_THUMB_PIXELMAP_INDEX] = info->ewi.scroll.gx_scroll_thumb_pixelmap;
127 info->pixelmap_id[SCROLL_UP_PIXELMAP_INDEX] = info->ewi.scroll.gx_scroll_up_pixelmap;
128 info->pixelmap_id[SCROLL_DOWN_PIXELMAP_INDEX] = info->ewi.scroll.gx_scroll_down_pixelmap;
129
130 if (project->mHeader.project_version < 54)
131 {
132 //selected fill color of scrollbar is start been used after project version 5.4.0
133 //set selected fill color to normal fill color incase broken old projects
134 info->color_id[SELECTED_FILL_COLOR_INDEX] = info->color_id[NORMAL_FILL_COLOR_INDEX];
135 }
136 }
137
138 ///////////////////////////////////////////////////////////////////////////////
CreateNewInstance(GX_WIDGET * parent)139 widget_info *hscroll_service_provider::CreateNewInstance(GX_WIDGET *parent)
140 {
141 GX_RECTANGLE size;
142 if (parent->gx_widget_type >= GX_TYPE_WINDOW)
143 {
144 gx_utility_rectangle_define(&size, 0, 0, 79, 23);
145 gx_utility_rectangle_center(&size, &parent->gx_widget_size);
146
147 GX_SCROLLBAR *scroll = new GX_SCROLLBAR;
148 gx_horizontal_scrollbar_create(scroll, "hscroll", parent, NULL,
149 GX_SCROLLBAR_HORIZONTAL | GX_SCROLLBAR_RELATIVE_THUMB | GX_SCROLLBAR_END_BUTTONS | GX_STYLE_ENABLED);
150
151 widget_info *info = InitWidgetInfo((GX_WIDGET *) scroll);
152 gx_system_scroll_appearance_get(GX_SCROLLBAR_HORIZONTAL, &info->ewi.scroll);
153
154 return info;
155 }
156 return NULL;
157 }
158
159 ///////////////////////////////////////////////////////////////////////////////
GenerateFromInfo(GX_WIDGET * parent,widget_info * info)160 GX_WIDGET *hscroll_service_provider::GenerateFromInfo(GX_WIDGET *parent, widget_info *info)
161 {
162 if (parent->gx_widget_type >= GX_TYPE_WINDOW)
163 {
164 GX_SCROLLBAR *scroll = new GX_SCROLLBAR;
165 gx_horizontal_scrollbar_create(scroll,
166 (CHAR *) info->app_name.GetString(),
167 parent, &info->ewi.scroll, info->style);
168 gx_widget_fill_color_set((GX_WIDGET *) scroll,
169 info->color_id[NORMAL_FILL_COLOR_INDEX], info->color_id[SELECTED_FILL_COLOR_INDEX], info->color_id[DISABLED_FILL_COLOR_INDEX]);
170
171 return ((GX_WIDGET *) scroll);
172 }
173 return NULL;
174 }
175
176
177 ///////////////////////////////////////////////////////////////////////////////
AssignPixelmap(widget_info * info,int index,GX_RESOURCE_ID pixmap_id)178 void hscroll_service_provider::AssignPixelmap(widget_info *info, int index,
179 GX_RESOURCE_ID pixmap_id)
180 {
181 GX_SCROLLBAR_APPEARANCE appearance = info->ewi.scroll;
182
183 switch(index)
184 {
185 case SCROLL_FILL_PIXELMAP_INDEX:
186 appearance.gx_scroll_fill_pixelmap = pixmap_id;
187 break;
188
189 case SCROLL_THUMB_PIXELMAP_INDEX:
190 appearance.gx_scroll_thumb_pixelmap = pixmap_id;
191 break;
192
193 case SCROLL_UP_PIXELMAP_INDEX:
194 appearance.gx_scroll_up_pixelmap = pixmap_id;
195 break;
196
197 case SCROLL_DOWN_PIXELMAP_INDEX:
198 appearance.gx_scroll_down_pixelmap = pixmap_id;
199 break;
200 }
201 // Even though the scrollbar keeps the pixelmap ids in it's own
202 // appearance structure, we need to save the pixelmap ID into the standard
203 // widget_info slot so that we can detect assignment changes
204 // correctly
205
206 info->pixelmap_id[index] = pixmap_id;
207 widget_factory::ReplaceScrollbar(info, &appearance);
208 }
209
210 ///////////////////////////////////////////////////////////////////////////////
Autosize(widget_info * info)211 void hscroll_service_provider::Autosize(widget_info *info)
212 {
213 CheckResizeToPixelmap(info, RESIZE_MODE_HEIGHT);
214 }