1
2 #include "studiox_includes.h"
3
4 #ifdef _DEBUG
5 #define new DEBUG_NEW
6 #endif
7
icon_button_service_provider()8 icon_button_service_provider::icon_button_service_provider()
9 {
10 }
11
GetVarDeclaration()12 CString icon_button_service_provider::GetVarDeclaration()
13 {
14 return CString("GX_ICON_BUTTON_MEMBERS_DECLARE");
15 }
16
DeclarePropertiesStruct()17 CString icon_button_service_provider::DeclarePropertiesStruct()
18 {
19 CString out(""
20 "typedef struct\n"
21 "{\n"
22 " GX_RESOURCE_ID pixelmap_id;\n"
23 "} GX_ICON_BUTTON_PROPERTIES;\n\n");
24 return out;
25 }
26
WriteExtendedProperties(screen_generator * gen,CString & prefix,widget_info * info)27 CString icon_button_service_provider::WriteExtendedProperties(screen_generator *gen, CString &prefix, widget_info *info)
28 {
29 CString out;
30 CString propname = prefix + info->app_name;
31 out.Format(_T("GX_ICON_BUTTON_PROPERTIES %s_properties =\n")
32 _T("{\n")
33 _T(" %s /* pixelmap id */\n};\n"),
34 propname,
35 gen->GetPixelmapIdName(info->pixelmap_id[NORMAL_PIXELMAP_INDEX])
36 );
37 return out;
38 }
39
GetCreateFromDefFunctionName()40 CString icon_button_service_provider::GetCreateFromDefFunctionName()
41 {
42 return CString("gx_studio_icon_button_create");
43 }
44
GetCreateFromDefFunction(int version)45 CString icon_button_service_provider::GetCreateFromDefFunction(int version)
46 {
47 CString out;
48 MakeCreatePreamble("icon_button", version, out);
49
50 out += "{\n"
51 " UINT status;\n"
52 " GX_ICON_BUTTON *button = (GX_ICON_BUTTON *) control_block;\n"
53 " GX_ICON_BUTTON_PROPERTIES *props = (GX_ICON_BUTTON_PROPERTIES *) info->properties;\n"
54 " status = gx_icon_button_create(button, info->widget_name, parent, props->pixelmap_id, info->style, info->widget_id, &info->size);\n"
55 " return status;\n"
56 "}\n";
57
58 return out;
59 }
60
CreateNewInstance(GX_WIDGET * parent)61 widget_info *icon_button_service_provider::CreateNewInstance(GX_WIDGET *parent)
62 {
63 GX_RECTANGLE size;
64 gx_utility_rectangle_define(&size, 0, 0, 31, 31);
65 gx_utility_rectangle_center(&size, &parent->gx_widget_size);
66
67 GX_ICON_BUTTON *button = new GX_ICON_BUTTON;
68 gx_icon_button_create(button, "icon_button", parent,
69 0, GX_STYLE_BORDER_RAISED|GX_STYLE_ENABLED|GX_STYLE_HALIGN_CENTER|GX_STYLE_VALIGN_CENTER|GX_STYLE_TRANSPARENT, 0, &size);
70
71 widget_info *info = InitWidgetInfo((GX_WIDGET *) button);
72 return info;
73 }
74
GenerateFromInfo(GX_WIDGET * parent,widget_info * info)75 GX_WIDGET *icon_button_service_provider::GenerateFromInfo(GX_WIDGET *parent, widget_info *info)
76 {
77 GX_ICON_BUTTON *button = new GX_ICON_BUTTON;
78 gx_icon_button_create(button,
79 (CHAR *) info->app_name.GetString(),
80 parent, info->pixelmap_id[0],
81 info->style,
82 0,
83 &info->size);
84 gx_widget_fill_color_set((GX_WIDGET *) button,
85 info->color_id[NORMAL_FILL_COLOR_INDEX], info->color_id[SELECTED_FILL_COLOR_INDEX], info->color_id[DISABLED_FILL_COLOR_INDEX]);
86 return ((GX_WIDGET *) button);
87 }
88
SaveToProject(xml_writer & writer,studiox_project * project,int display,widget_info * info)89 void icon_button_service_provider::SaveToProject(xml_writer &writer, studiox_project *project, int display, widget_info *info)
90 {
91 button_service_provider::SaveToProject(writer, project, display, info);
92 WritePixelmapId(writer, project, display, "pixelmap_id", info->pixelmap_id[NORMAL_PIXELMAP_INDEX]);
93 }
94
ReadFromProject(xml_reader & reader,studiox_project * project,int display,widget_info * info,ULONG valid_styles)95 void icon_button_service_provider::ReadFromProject(xml_reader &reader, studiox_project *project, int display, widget_info *info, ULONG valid_styles)
96 {
97 valid_styles |= GX_PIXELMAP_HALIGN_MASK|GX_PIXELMAP_VALIGN_MASK;
98 button_service_provider::ReadFromProject(reader, project, display, info, valid_styles);
99 info->pixelmap_id[NORMAL_PIXELMAP_INDEX] = ReadPixelmapId(reader, project, display, "pixelmap_id");
100 }
101
102
AssignPixelmap(widget_info * info,int index,GX_RESOURCE_ID pixmap_id)103 void icon_button_service_provider::AssignPixelmap(widget_info *info, int index,
104 GX_RESOURCE_ID pixmap_id)
105 {
106 info->pixelmap_id[index] = pixmap_id;
107 GX_WIDGET *widget = info->widget;
108
109 if (widget)
110 {
111 GX_ICON_BUTTON *button = (GX_ICON_BUTTON *)widget;
112 gx_icon_button_pixelmap_set(button, pixmap_id);
113 }
114 }
115
Autosize(widget_info * info)116 void icon_button_service_provider::Autosize(widget_info *info)
117 {
118 CheckResizeToPixelmap(info, RESIZE_MODE_ALL);
119 }