1
2 #include "studiox_includes.h"
3
4 #ifdef _DEBUG
5 #define new DEBUG_NEW
6 #endif
7
horizontal_list_service_provider()8 horizontal_list_service_provider::horizontal_list_service_provider()
9 {
10 }
11
GetVarDeclaration()12 CString horizontal_list_service_provider::GetVarDeclaration()
13 {
14 return CString("GX_HORIZONTAL_LIST_MEMBERS_DECLARE");
15 }
16
DeclarePropertiesStruct()17 CString horizontal_list_service_provider::DeclarePropertiesStruct()
18 {
19 CString out(""
20 "typedef struct\n"
21 "{\n"
22 " GX_RESOURCE_ID wallpaper_id;\n"
23 " VOID (*callback)(GX_HORIZONTAL_LIST *, GX_WIDGET *, INT);\n"
24 " int total_rows;\n"
25 "} GX_HORIZONTAL_LIST_PROPERTIES;\n\n");
26 return out;
27 }
28
WriteExtendedProperties(screen_generator * gen,CString & prefix,widget_info * info)29 CString horizontal_list_service_provider::WriteExtendedProperties(screen_generator *gen, CString &prefix, widget_info *info)
30 {
31 CString out;
32 CString propname = prefix + info->app_name;
33 CString callback;
34
35 if (info->callback_func.IsEmpty())
36 {
37 callback = "GX_NULL";
38 }
39 else
40 {
41 callback = info->callback_func;
42 }
43 out.Format(_T("GX_HORIZONTAL_LIST_PROPERTIES %s_properties =\n")
44 _T("{\n")
45 _T(" %s, /* wallpaper id */\n")
46 _T(" %s, /* callback function */\n")
47 _T(" %d /* total columns */\n};\n"),
48 propname,
49 gen->GetPixelmapIdName(info->pixelmap_id[WALLPAPER_PIXELMAP_INDEX]),
50 callback,
51 info->ewi.vlist.total_rows);
52 return out;
53 }
54
55
GetCreateFromDefFunctionName()56 CString horizontal_list_service_provider::GetCreateFromDefFunctionName()
57 {
58 return CString("gx_studio_horizontal_list_create");
59 }
60
GetCreateFromDefFunction(int version)61 CString horizontal_list_service_provider::GetCreateFromDefFunction(int version)
62 {
63 CString out;
64 MakeCreatePreamble("horizontal_list", version, out);
65
66 out += "{\n"
67 " UINT status;\n"
68 " GX_HORIZONTAL_LIST *list = (GX_HORIZONTAL_LIST *) control_block;\n"
69 " GX_HORIZONTAL_LIST_PROPERTIES *props = (GX_HORIZONTAL_LIST_PROPERTIES *) info->properties;\n"
70 " status = gx_horizontal_list_create(list, info->widget_name, parent, props->total_rows,\n"
71 " props->callback, info->style, info->widget_id, &info->size);\n"
72 " if (status == GX_SUCCESS)\n"
73 " {\n"
74 " if (props->wallpaper_id)\n"
75 " {\n"
76 " gx_window_wallpaper_set((GX_WINDOW *) list, props->wallpaper_id, info->style & GX_STYLE_TILE_WALLPAPER);\n"
77 " }\n"
78 " }\n"
79 " return status;\n"
80 "}\n";
81 return out;
82 }
83
84
CreateNewInstance(GX_WIDGET * parent)85 widget_info *horizontal_list_service_provider::CreateNewInstance(GX_WIDGET *parent)
86 {
87 int parent_size;
88
89 GX_RECTANGLE size = parent->gx_widget_size;
90 gx_utility_rectangle_define(&size, 0, 0, 79, 23);
91 parent_size = (parent->gx_widget_size.gx_rectangle_right -
92 parent->gx_widget_size.gx_rectangle_left) / 2;
93 size.gx_rectangle_right = size.gx_rectangle_left + parent_size;
94
95 parent_size = (parent->gx_widget_size.gx_rectangle_bottom -
96 parent->gx_widget_size.gx_rectangle_top) / 2;
97 size.gx_rectangle_bottom = size.gx_rectangle_top + parent_size;
98
99 gx_utility_rectangle_center(&size, &parent->gx_widget_size);
100
101 GX_HORIZONTAL_LIST *list = new GX_HORIZONTAL_LIST;
102 gx_horizontal_list_create(list, "horizontal_list", parent,
103 10, NULL, GX_STYLE_ENABLED | GX_STYLE_BORDER_THIN, 0, &size);
104 widget_info *info = InitWidgetInfo((GX_WIDGET *) list);
105 info->pixelmap_id[WALLPAPER_PIXELMAP_INDEX] = 0;
106 info->callback_func = CString("callback_name");
107 info->ewi.vlist.total_rows = 10;
108
109 return info;
110 }
111
GenerateFromInfo(GX_WIDGET * parent,widget_info * info)112 GX_WIDGET *horizontal_list_service_provider::GenerateFromInfo(GX_WIDGET *parent, widget_info *info)
113 {
114 GX_HORIZONTAL_LIST *list = new GX_HORIZONTAL_LIST;
115 gx_horizontal_list_create(list,
116 (CHAR *) info->app_name.GetString(),
117 parent,
118 info->ewi.vlist.total_rows, NULL,
119 info->style,
120 0,
121 &info->size);
122
123 gx_widget_fill_color_set(list,
124 info->color_id[NORMAL_FILL_COLOR_INDEX],
125 info->color_id[SELECTED_FILL_COLOR_INDEX],
126 info->color_id[DISABLED_FILL_COLOR_INDEX]);
127
128 if (info->pixelmap_id[WALLPAPER_PIXELMAP_INDEX] > 0)
129 {
130 BOOL tile = FALSE;
131
132 if (info->style & GX_STYLE_TILE_WALLPAPER)
133 {
134 tile = TRUE;
135 }
136 gx_window_wallpaper_set((GX_WINDOW *) list, info->pixelmap_id[WALLPAPER_PIXELMAP_INDEX], tile);
137 }
138 return ((GX_WIDGET *) list);
139 }
140
SaveToProject(xml_writer & writer,studiox_project * project,int display,widget_info * info)141 void horizontal_list_service_provider::SaveToProject(xml_writer &writer, studiox_project *project, int display, widget_info *info)
142 {
143 window_service_provider::SaveToProject(writer, project, display, info);
144 writer.WriteInt("seperation", info->ewi.vlist.seperation);
145 writer.WriteInt("total_rows", info->ewi.vlist.total_rows);
146 writer.WriteString("callback", info->callback_func);
147 }
148
ReadFromProject(xml_reader & reader,studiox_project * project,int display,widget_info * info,ULONG valid_styles)149 void horizontal_list_service_provider::ReadFromProject(xml_reader &reader, studiox_project *project, int display, widget_info *info, ULONG valid_styles)
150 {
151 valid_styles |= GX_STYLE_CENTER_SELECTED|GX_STYLE_WRAP|GX_STYLE_FLICKABLE|GX_STYLE_REPEAT_SELECT;
152 window_service_provider::ReadFromProject(reader, project, display, info, valid_styles);
153 reader.ReadInt("seperation", info->ewi.vlist.seperation, 0);
154 reader.ReadInt("total_rows", info->ewi.vlist.total_rows, 10);
155 reader.ReadString("callback", info->callback_func);
156 }
157
158
159