Debian Codegraph @

wxcrafter/controls/dir_picker_ctrl_wrapper.cpp

raw
1 #include "dir_picker_ctrl_wrapper.h"
2 #include "allocator_mgr.h"
3 #include "wxgui_defs.h"
4 #include "wxgui_helpers.h"
5 #include "xmlutils.h"
6 #include <wx/filepicker.h>
7
8 DirPickerCtrlWrapper::DirPickerCtrlWrapper()
9 : wxcWidget(ID_WXDIRPICKER)
10 {
11 SetPropertyString(_("Common Settings"), "wxDirPickerCtrl");
12 AddProperty(new StringProperty(PROP_VALUE, wxT(""), _("Value")));
13 AddProperty(new StringProperty(PROP_MESSAGE, _("Select a folder"), _("Message to show to the user")));
14
15 PREPEND_STYLE(wxDIRP_CHANGE_DIR, false);
16 PREPEND_STYLE(wxDIRP_DIR_MUST_EXIST, false);
17 PREPEND_STYLE(wxDIRP_USE_TEXTCTRL, false);
18 PREPEND_STYLE(wxDIRP_DEFAULT_STYLE, true);
19 PREPEND_STYLE(wxDIRP_SMALL, true);
20
21 RegisterEvent(wxT("wxEVT_COMMAND_DIRPICKER_CHANGED"), wxT("wxFileDirPickerEvent"),
22 _("The user changed the directory selected in the control either using the button or using text "
23 "control\n(see wxDIRP_USE_TEXTCTRL; note that in this case the event is fired only if the user's "
24 "input is valid, e.g. an existing directory path)."));
25 m_namePattern = wxT("m_dirPicker");
26 SetName(GenerateName());
27 }
28
29 DirPickerCtrlWrapper::~DirPickerCtrlWrapper() {}
30
31 wxcWidget* DirPickerCtrlWrapper::Clone() const { return new DirPickerCtrlWrapper(); }
32
33 wxString DirPickerCtrlWrapper::CppCtorCode() const
34 {
35 // wxDirPickerCtrl(wxWindow *parent, wxWindowID id, const wxString& path = wxEmptyString, const wxString& message =
36 // "Select a folder", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style =
37 // wxDIRP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = "dirpickerctrl")
38 wxString cpp;
39 cpp << GetName() << wxT(" = new ") << GetRealClassName() << wxT("(") << GetWindowParent() << wxT(", ") << WindowID()
40 << wxT(", ") << wxT("wxEmptyString, ") << wxCrafter::UNDERSCORE(PropertyString(PROP_MESSAGE)) << wxT(", ")
41 << wxT("wxDefaultPosition, ") << SizeAsString() << wxT(", ") << StyleFlags(wxT("wxDIRP_DEFAULT_STYLE"))
42 << wxT(");\n");
43 cpp << CPPCommonAttributes();
44 return cpp;
45 }
46
47 void DirPickerCtrlWrapper::GetIncludeFile(wxArrayString& headers) const
48 {
49 headers.Add(wxT("#include <wx/filepicker.h>"));
50 }
51
52 wxString DirPickerCtrlWrapper::GetWxClassName() const { return wxT("wxDirPickerCtrl"); }
53
54 void DirPickerCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const
55 {
56 text << XRCPrefix() << XRCStyle() << XRCCommonAttributes() << XRCSize() << wxT("<message>")
57 << wxCrafter::XMLEncode(PropertyString(PROP_MESSAGE)) << wxT("</message>") << wxT("<value>")
58 << wxCrafter::XMLEncode(PropertyString(PROP_VALUE)) << wxT("</value>") << XRCSuffix();
59 }
60
61 void DirPickerCtrlWrapper::LoadPropertiesFromXRC(const wxXmlNode* node)
62 {
63 // First call the base-class for the standard things
64 wxcWidget::LoadPropertiesFromXRC(node);
65
66 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("value"));
67 if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); }
68
69 propertynode = XmlUtils::FindFirstByTagName(node, "message");
70 if(propertynode) { SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); }
71 }
72
73 void DirPickerCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node)
74 {
75 // First call the base-class for the standard things
76 wxcWidget::LoadPropertiesFromwxSmith(node);
77
78 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("path"));
79 if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); }
80
81 propertynode = XmlUtils::FindFirstByTagName(node, "message");
82 if(propertynode) { SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); }
83 }
84
85 void DirPickerCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node)
86 {
87 // First call the base-class for the standard things
88 wxcWidget::LoadPropertiesFromwxFB(node);
89
90 wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "value");
91 if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); }
92
93 propertynode = XmlUtils::FindNodeByName(node, "property", "message");
94 if(propertynode) { SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); }
95 }