| 1 |
#include "wizard_page_wrapper.h" |
| 2 |
#include "allocator_mgr.h" |
| 3 |
#include "file_ficker_property.h" |
| 4 |
#include "import_from_wxFB.h" |
| 5 |
#include "import_from_xrc.h" |
| 6 |
#include "wizard_wrapper.h" |
| 7 |
#include "wxc_bitmap_code_generator.h" |
| 8 |
#include "wxgui_defs.h" |
| 9 |
#include "wxgui_helpers.h" |
| 10 |
#include "wxguicraft_main_view.h" |
| 11 |
#include "xmlutils.h" |
| 12 |
|
| 13 |
WizardPageWrapper::WizardPageWrapper() |
| 14 |
{ |
| 15 |
SetPropertyString(_("Common Settings"), "wxWizardPage"); |
| 16 |
m_type = ID_WXWIZARDPAGE; |
| 17 |
m_namePattern = wxT("m_wizardPage"); |
| 18 |
AddProperty(new BitmapPickerProperty(PROP_BITMAP_PATH, wxT(""), |
| 19 |
_("The page-specific bitmap if different from the global one"))); |
| 20 |
DoSetPropertyStringValue(PROP_SIZE, wxT("500,300")); |
| 21 |
SetName(GenerateName()); |
| 22 |
} |
| 23 |
|
| 24 |
WizardPageWrapper::~WizardPageWrapper() {} |
| 25 |
|
| 26 |
wxcWidget* WizardPageWrapper::Clone() const { return new WizardPageWrapper(); } |
| 27 |
|
| 28 |
wxString WizardPageWrapper::CppCtorCode() const |
| 29 |
{ |
| 30 |
wxcCodeGeneratorHelper::Get().AddBitmap(PropertyFile(PROP_BITMAP_PATH)); |
| 31 |
|
| 32 |
wxString code; |
| 33 |
code << GetName() << wxT(" = new ") << GetRealClassName() << wxT("(") << GetWindowParent() << wxT(", ") |
| 34 |
<< wxT("NULL, ") << wxT("NULL, ") << wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)) |
| 35 |
<< wxT(");\n"); |
| 36 |
code << wxT("m_pages.push_back(") << GetName() << wxT(");\n"); |
| 37 |
|
| 38 |
WizardWrapper* wizard = dynamic_cast<WizardWrapper*>(GetParent()); |
| 39 |
if(!wizard) { return code; } |
| 40 |
|
| 41 |
// If this is the last page, perform the 'Chain' call |
| 42 |
// We use |@@| as a sepcial delimiter here (to avoid indenting this code) |
| 43 |
// it will be replaced later by the TopLevelWindowWrapper to an empty string |
| 44 |
const wxcWidget::List_t& siblings = wizard->GetChildren(); |
| 45 |
const wxcWidget* lastChild = siblings.back(); |
| 46 |
if(lastChild == this) { |
| 47 |
code << wxT("|@@|if (m_pages.size() > 1) {\n") << wxT("|@@| for(size_t i=1; i<m_pages.size(); i++) {\n") |
| 48 |
<< wxT("|@@| wxWizardPageSimple::Chain(m_pages.at(i-1), m_pages.at(i));\n") << wxT("|@@| }\n") |
| 49 |
<< wxT("|@@|}\n"); |
| 50 |
code << wxT("GetPageAreaSizer()->Add(m_pages.at(0));\n"); |
| 51 |
} |
| 52 |
return code; |
| 53 |
} |
| 54 |
|
| 55 |
wxString WizardPageWrapper::GetWxClassName() const { return wxT("wxWizardPageSimple"); } |
| 56 |
|
| 57 |
void WizardPageWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 58 |
{ |
| 59 |
bool isFirstPage = (GetParent()->GetChildren().front() == this); |
| 60 |
|
| 61 |
if(type == XRC_DESIGNER) { |
| 62 |
// HACK: Only display the active page |
| 63 |
if(GUICraftMainPanel::m_MainPanel->GetActiveWizardPage() != this) return; |
| 64 |
|
| 65 |
text << XRCCommonAttributes() << XRCSize() << XRCStyle() << XRCBitmap(); |
| 66 |
|
| 67 |
text << wxT("<object class=\"wxBoxSizer\">"); |
| 68 |
text << wxT("<object class=\"sizeritem\">"); |
| 69 |
text << wxT(" <flag>wxEXPAND</flag>"); |
| 70 |
text << wxT(" <border>5</border>"); |
| 71 |
text << wxT(" <option>1</option>"); |
| 72 |
|
| 73 |
ChildrenXRC(text, type); |
| 74 |
|
| 75 |
text << wxT("</object>"); |
| 76 |
text << wxT("</object>"); |
| 77 |
|
| 78 |
} else if(type == XRC_PREVIEW) { |
| 79 |
if(isFirstPage) { |
| 80 |
text << wxT("<object class=\"") << GetWxClassName() << wxT("\" name=\"WIZARD_PAGE_ONE\">"); |
| 81 |
} else { |
| 82 |
text << XRCPrefix(); |
| 83 |
} |
| 84 |
|
| 85 |
text << XRCCommonAttributes() << XRCSize() << XRCStyle() << XRCBitmap(); |
| 86 |
ChildrenXRC(text, type); |
| 87 |
text << XRCSuffix(); |
| 88 |
} else if(type == XRC_LIVE) { |
| 89 |
text << "<object class=\"" << GetWxClassName() << "\" name=\"" << GetName() << "\">"; |
| 90 |
text << XRCCommonAttributes() << XRCSize() << XRCStyle() << XRCBitmap(); |
| 91 |
ChildrenXRC(text, type); |
| 92 |
text << XRCSuffix(); |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
void WizardPageWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) |
| 97 |
{ |
| 98 |
// First call the base-class for the standard things |
| 99 |
wxcWidget::LoadPropertiesFromXRC(node); |
| 100 |
|
| 101 |
wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmap")); |
| 102 |
if(propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_OTHER"); } |
| 103 |
} |
| 104 |
|
| 105 |
void WizardPageWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) |
| 106 |
{ |
| 107 |
// First call the base-class for the standard things |
| 108 |
wxcWidget::LoadPropertiesFromwxFB(node); |
| 109 |
|
| 110 |
wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "bitmap"); |
| 111 |
if(propertynode) { |
| 112 |
ImportFromwxFB::ProcessBitmapProperty(propertynode->GetNodeContent(), this, PROP_BITMAP_PATH, "wxART_OTHER"); |
| 113 |
} |
| 114 |
} |