| 1 |
#include "std_dialog_button_sizer_wrapper.h" |
| 2 |
#include "allocator_mgr.h" |
| 3 |
#include "bool_property.h" |
| 4 |
#include "button_wrapper.h" |
| 5 |
#include "wxgui_defs.h" |
| 6 |
#include "xmlutils.h" |
| 7 |
#include <map> |
| 8 |
|
| 9 |
StdDialogButtonSizerWrapper::StdDialogButtonSizerWrapper() |
| 10 |
: wxcWidget(ID_WXSTDDLGBUTTONSIZER) |
| 11 |
{ |
| 12 |
m_namePattern = "m_stdBtnSizer"; |
| 13 |
SetName(GenerateName()); |
| 14 |
} |
| 15 |
|
| 16 |
StdDialogButtonSizerWrapper::~StdDialogButtonSizerWrapper() {} |
| 17 |
|
| 18 |
wxcWidget* StdDialogButtonSizerWrapper::Clone() const { return new StdDialogButtonSizerWrapper(); } |
| 19 |
|
| 20 |
wxString StdDialogButtonSizerWrapper::CppCtorCode() const |
| 21 |
{ |
| 22 |
wxString cppCode; |
| 23 |
cppCode << GetName() << " = new " << GetRealClassName() << "();\n"; |
| 24 |
return cppCode; |
| 25 |
} |
| 26 |
|
| 27 |
void StdDialogButtonSizerWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add("#include <wx/sizer.h>"); } |
| 28 |
|
| 29 |
wxString StdDialogButtonSizerWrapper::GetWxClassName() const { return "wxStdDialogButtonSizer"; } |
| 30 |
|
| 31 |
void StdDialogButtonSizerWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 32 |
{ |
| 33 |
text << XRCPrefix(); |
| 34 |
ChildrenXRC(text, type); |
| 35 |
text << XRCSuffix(); |
| 36 |
} |
| 37 |
|
| 38 |
void StdDialogButtonSizerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) |
| 39 |
{ |
| 40 |
// First call the base-class for the standard things |
| 41 |
wxcWidget::LoadPropertiesFromwxFB(node); |
| 42 |
|
| 43 |
// There aren't any extras needed for the sdbsizer itself but, unlike XRC, wxFB stores the button info here |
| 44 |
// They aren't treated as real buttons as does wxC; they're just nodes containing 0 or 1 |
| 45 |
typedef std::pair<wxString, wxString> Pair_t; |
| 46 |
typedef std::vector<Pair_t> Vector_t; |
| 47 |
static Vector_t s_buttons; |
| 48 |
if(s_buttons.empty()) { |
| 49 |
s_buttons.push_back(Pair_t("OK", "wxID_OK")); |
| 50 |
s_buttons.push_back(Pair_t("Cancel", "wxID_CANCEL")); |
| 51 |
s_buttons.push_back(Pair_t("Apply", "wxID_APPLY")); |
| 52 |
s_buttons.push_back(Pair_t("Help", "wxID_HELP")); |
| 53 |
s_buttons.push_back(Pair_t("ContextHelp", "wxID_CONTEXT_HELP")); |
| 54 |
s_buttons.push_back(Pair_t("Yes", "wxID_YES")); |
| 55 |
s_buttons.push_back(Pair_t("No", "wxID_NO")); |
| 56 |
s_buttons.push_back(Pair_t("Save", "wxID_SAVE")); |
| 57 |
s_buttons.push_back(Pair_t("Close", "wxID_CLOSE")); |
| 58 |
} |
| 59 |
|
| 60 |
for(Vector_t::iterator iter = s_buttons.begin(); iter != s_buttons.end(); ++iter) { |
| 61 |
wxString value, buttonname = (*iter).first; |
| 62 |
wxXmlNode* child = node->GetChildren(); |
| 63 |
while(child) { |
| 64 |
wxString childname(child->GetName()); |
| 65 |
if(childname == wxT("property")) { |
| 66 |
wxString attr(XmlUtils::ReadString(child, wxT("name"))); |
| 67 |
|
| 68 |
if(attr == buttonname) { |
| 69 |
value = child->GetNodeContent(); |
| 70 |
if(value == "1") { |
| 71 |
wxcWidget* sbwrapper = Allocator::Instance()->Create(ID_WXSTDBUTTON); |
| 72 |
wxCHECK_RET(sbwrapper, wxT("Failed to create a stdbtnwrapper")); |
| 73 |
// We've created a button; afaict there're no styles/properties to add to it. Just set its ID |
| 74 |
sbwrapper->SetId((*iter).second); |
| 75 |
AddChild(sbwrapper); |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
child = child->GetNext(); |
| 80 |
} |
| 81 |
} |
| 82 |
} |