1 
2 #include "studiox_includes.h"
3 
4 #ifdef _DEBUG
5 #define new DEBUG_NEW
6 #endif
7 
mlt_button_service_provider()8 mlt_button_service_provider::mlt_button_service_provider()
9 {
10 }
11 
GetVarDeclaration()12 CString mlt_button_service_provider::GetVarDeclaration()
13 {
14     return CString("GX_MULTI_LINE_TEXT_BUTTON_MEMBERS_DECLARE");
15 }
16 
DeclarePropertiesStruct()17 CString mlt_button_service_provider::DeclarePropertiesStruct()
18 {
19     CString out;
20     out.Format(_T("typedef struct\n")
21     _T("{\n")
22     _T("%s\n")
23     _T("} GX_ML_TEXT_BUTTON_PROPERTIES;\n\n"),
24     text_button_service_provider::DeclaraPropertiesStructContent());
25     return out;
26 }
27 
WriteExtendedProperties(screen_generator * gen,CString & prefix,widget_info * info)28 CString mlt_button_service_provider::WriteExtendedProperties(screen_generator *gen, CString &prefix, widget_info *info)
29 {
30     CString out;
31     CString propname = prefix + info->app_name;
32     out.Format(_T("GX_ML_TEXT_BUTTON_PROPERTIES %s_properties =\n")
33         _T("{\n")
34         _T("%s\n")
35         _T("};\n"),
36         propname,
37         text_button_service_provider::WriteExtendedPropertiesContent(gen, info));
38 
39     return out;
40 }
41 
42 
GetCreateFromDefFunctionName()43 CString mlt_button_service_provider::GetCreateFromDefFunctionName()
44 {
45     return CString("gx_studio_multi_line_text_button_create");
46 }
47 
GetCreateFromDefFunction(int version)48 CString mlt_button_service_provider::GetCreateFromDefFunction(int version)
49 {
50     CString out;
51     MakeCreatePreamble("multi_line_text_button", version, out);
52 
53     out += "{\n"
54         "    UINT status;\n"
55         "    GX_MULTI_LINE_TEXT_BUTTON *button = (GX_MULTI_LINE_TEXT_BUTTON *) control_block;\n"
56         "    GX_ML_TEXT_BUTTON_PROPERTIES *props = (GX_ML_TEXT_BUTTON_PROPERTIES *) info->properties;\n"
57         "    status = gx_multi_line_text_button_create(button, info->widget_name, parent, props->string_id, info->style, info->widget_id, &info->size);\n"
58         "    if (status == GX_SUCCESS)\n"
59         "    {\n"
60         "        gx_text_button_font_set((GX_TEXT_BUTTON *) button, props->font_id);\n";
61 
62     if (project_lib_version() > 50401)
63     {
64         out += "#if defined(GUIX_5_4_0_COMPATIBILITY)\n"
65         "        gx_text_button_text_color_set((GX_TEXT_BUTTON *) button, props->normal_text_color_id, props->selected_text_color_id);\n"
66         "#else\n"
67         "        gx_text_button_text_color_set((GX_TEXT_BUTTON *) button, props->normal_text_color_id, props->selected_text_color_id, props->disabled_text_color_id);\n"
68         "#endif\n";
69     }
70     else
71     {
72         out += "        gx_text_button_text_color_set((GX_TEXT_BUTTON *) button, props->normal_text_color_id, props->selected_text_color_id);\n";
73     }
74 
75     out += "    }\n"
76     "    return status;\n"
77     "}\n";
78     return out;
79 }
80 
CreateNewInstance(GX_WIDGET * parent)81 widget_info *mlt_button_service_provider::CreateNewInstance(GX_WIDGET *parent)
82 {
83     GX_RECTANGLE size;
84     gx_utility_rectangle_define(&size, 0, 0, 79, 63);
85     gx_utility_rectangle_center(&size, &parent->gx_widget_size);
86 
87     GX_MULTI_LINE_TEXT_BUTTON *button = new GX_MULTI_LINE_TEXT_BUTTON;
88     GX_RESOURCE_ID string_id = GetStringId("multi\rline\rbutton");
89 
90     gx_multi_line_text_button_create(button, "multi_line_button", parent,
91         string_id, GX_STYLE_ENABLED|GX_STYLE_TEXT_CENTER|GX_STYLE_BORDER_RAISED, 0, &size);
92 
93     widget_info *info = InitWidgetInfo((GX_WIDGET *) button);
94 
95     info->string_id[0]  = string_id;
96     info->color_id[NORMAL_TEXT_COLOR_INDEX] = button->gx_text_button_normal_text_color;
97     info->color_id[SELECTED_TEXT_COLOR_INDEX] = button->gx_text_button_selected_text_color;
98     info->color_id[DISABLED_TEXT_COLOR_INDEX] = button->gx_text_button_disabled_text_color;
99     info->font_id[0] = button->gx_text_button_font_id;
100 
101     return info;
102 }
103 
GenerateFromInfo(GX_WIDGET * parent,widget_info * info)104 GX_WIDGET *mlt_button_service_provider::GenerateFromInfo(GX_WIDGET *parent, widget_info *info)
105 {
106     GX_MULTI_LINE_TEXT_BUTTON *button = new GX_MULTI_LINE_TEXT_BUTTON;
107     gx_multi_line_text_button_create(button,
108         (CHAR *) info->app_name.GetString(),
109         parent,
110         info->string_id[0],
111         info->style,
112         0,
113         &info->size);
114 
115     gx_widget_fill_color_set((GX_TEXT_BUTTON *)button,
116         info->color_id[NORMAL_FILL_COLOR_INDEX],
117         info->color_id[SELECTED_FILL_COLOR_INDEX],
118         info->color_id[DISABLED_FILL_COLOR_INDEX]);
119     gx_text_button_text_color_set((GX_TEXT_BUTTON *) button,
120         info->color_id[NORMAL_TEXT_COLOR_INDEX],
121         info->color_id[SELECTED_TEXT_COLOR_INDEX],
122         info->color_id[DISABLED_TEXT_COLOR_INDEX]);
123     gx_text_button_font_set((GX_TEXT_BUTTON *) button, info->font_id[0]);
124     return ((GX_WIDGET *) button);
125 }
126 
127 
AssignText(widget_info * info,int index,GX_RESOURCE_ID string_id)128 void mlt_button_service_provider::AssignText(widget_info *info, int index,
129     GX_RESOURCE_ID string_id)
130 {
131     GX_WIDGET *widget = info->widget;
132 
133     if (widget)
134     {
135         GX_MULTI_LINE_TEXT_BUTTON *pb = (GX_MULTI_LINE_TEXT_BUTTON *)widget;
136 
137         gx_multi_line_text_button_text_id_set(pb, string_id);
138     }
139     info->string_id[0] = string_id;
140 }
141 
142