| 1 |
#include "panel_wrapper_top_level.h" |
| 2 |
#include "allocator_mgr.h" |
| 3 |
#include "xmlutils.h" |
| 4 |
#include <wx/ffile.h> |
| 5 |
#include <wx/filename.h> |
| 6 |
#include <wx/msgdlg.h> |
| 7 |
#include <wx/tokenzr.h> |
| 8 |
|
| 9 |
PanelWrapperTopLevel::PanelWrapperTopLevel() |
| 10 |
: TopLevelWinWrapper(ID_WXPANEL_TOPLEVEL) |
| 11 |
{ |
| 12 |
SetPropertyString(_("Common Settings"), "wxPanel"); |
| 13 |
// Enable the 'wxTAB_TRAVERSAL' style |
| 14 |
EnableStyle(wxT("wxTAB_TRAVERSAL"), true); |
| 15 |
|
| 16 |
REMOVE_STYLE(wxCAPTION); |
| 17 |
REMOVE_STYLE(wxSYSTEM_MENU); |
| 18 |
REMOVE_STYLE(wxMAXIMIZE_BOX); |
| 19 |
REMOVE_STYLE(wxMINIMIZE_BOX); |
| 20 |
REMOVE_STYLE(wxRESIZE_BORDER); |
| 21 |
REMOVE_STYLE(wxSTAY_ON_TOP); |
| 22 |
REMOVE_STYLE(wxCLOSE_BOX); |
| 23 |
|
| 24 |
m_namePattern = wxT("MyPanel"); |
| 25 |
SetName(GenerateName()); |
| 26 |
} |
| 27 |
|
| 28 |
PanelWrapperTopLevel::~PanelWrapperTopLevel() {} |
| 29 |
|
| 30 |
void PanelWrapperTopLevel::GetIncludeFile(wxArrayString& headers) const |
| 31 |
{ |
| 32 |
headers.Add(wxT("#include <wx/panel.h>")); |
| 33 |
headers.Add(wxT("#include <wx/artprov.h>")); |
| 34 |
} |
| 35 |
|
| 36 |
wxString PanelWrapperTopLevel::GetWxClassName() const { return wxT("wxPanel"); } |
| 37 |
|
| 38 |
wxString PanelWrapperTopLevel::CppCtorCode() const { return TopLevelWinWrapper::CppCtorCode(); } |
| 39 |
|
| 40 |
void PanelWrapperTopLevel::ToXRC(wxString& text, XRC_TYPE type) const |
| 41 |
{ |
| 42 |
if(type != wxcWidget::XRC_LIVE) { |
| 43 |
text << wxT("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>") |
| 44 |
<< wxT("<resource xmlns=\"http://www.wxwidgets.org/wxxrc\" >"); |
| 45 |
} |
| 46 |
|
| 47 |
text << XRCPrefix() << XRCSize() << XRCStyle() << XRCCommonAttributes(); |
| 48 |
|
| 49 |
ChildrenXRC(text, type); |
| 50 |
text << wxT("</object>"); |
| 51 |
|
| 52 |
if(type != wxcWidget::XRC_LIVE) { text << wxT("</resource>"); } |
| 53 |
} |
| 54 |
|
| 55 |
wxString PanelWrapperTopLevel::DesignerXRC(bool forPreviewDialog) const |
| 56 |
{ |
| 57 |
wxUnusedVar(forPreviewDialog); |
| 58 |
wxString text; |
| 59 |
text << wxT("<object class=\"wxPanel\" name=\"PreviewPanel\">") << wxT("<hidden>1</hidden>") << XRCSize() |
| 60 |
<< XRCStyle() << XRCCommonAttributes(); |
| 61 |
|
| 62 |
ChildrenXRC(text, XRC_DESIGNER); |
| 63 |
text << wxT("</object>"); |
| 64 |
|
| 65 |
WrapXRC(text); |
| 66 |
return text; |
| 67 |
} |
| 68 |
|
| 69 |
bool PanelWrapperTopLevel::IsTopWindow() const { return GetParent() == NULL; } |
| 70 |
|
| 71 |
wxString PanelWrapperTopLevel::BaseCtorDecl() const |
| 72 |
{ |
| 73 |
wxString code; |
| 74 |
code << wxT(" ") << CreateBaseclassName() << wxT("(wxWindow* parent, wxWindowID id = wxID_ANY, ") |
| 75 |
<< wxT("const wxPoint& pos = wxDefaultPosition, const wxSize& size = ") << SizeAsString() << wxT(", ") |
| 76 |
<< wxT("long style = ") << StyleFlags(wxT("wxTAB_TRAVERSAL")) << wxT(");\n"); |
| 77 |
return code; |
| 78 |
} |
| 79 |
|
| 80 |
wxString PanelWrapperTopLevel::BaseCtorImplPrefix() const |
| 81 |
{ |
| 82 |
wxString code; |
| 83 |
code << CreateBaseclassName() << wxT("::") << CreateBaseclassName() |
| 84 |
<< wxT("(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)\n"); |
| 85 |
code << " : " << GetRealClassName() << "(parent, id, pos, size, style)\n"; |
| 86 |
return code; |
| 87 |
} |
| 88 |
|
| 89 |
void PanelWrapperTopLevel::LoadPropertiesFromXRC(const wxXmlNode* node) |
| 90 |
{ |
| 91 |
// First call the base-class for the standard things |
| 92 |
wxcWidget::LoadPropertiesFromXRC(node); |
| 93 |
|
| 94 |
// We've already done 'size' in the baseclass, but do it again for TLWindows |
| 95 |
// That's because if no size was specified, wxC inflicts 500,300. This isn't what the user expected |
| 96 |
// So, if there is *not* a specified size, overwrite the wxC default with wxDefaultSize |
| 97 |
wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("size")); |
| 98 |
if(!propertynode) { SetPropertyString(PROP_SIZE, "-1,-1"); } |
| 99 |
} |
| 100 |
|
| 101 |
void PanelWrapperTopLevel::LoadPropertiesFromwxSmith(const wxXmlNode* node) |
| 102 |
{ |
| 103 |
// First call the base-class for the standard things |
| 104 |
wxcWidget::LoadPropertiesFromwxSmith(node); |
| 105 |
|
| 106 |
// We've already done 'size' in the baseclass, but do it again for TLWindows |
| 107 |
// That's because if no size was specified, wxC inflicts 500,300. This isn't what the user expected |
| 108 |
// So, if there is *not* a specified size, overwrite the wxC default with wxDefaultSize |
| 109 |
wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("size")); |
| 110 |
if(!propertynode) { SetPropertyString(PROP_SIZE, "-1,-1"); } |
| 111 |
} |
| 112 |
|
| 113 |
void PanelWrapperTopLevel::LoadPropertiesFromwxFB(const wxXmlNode* node) |
| 114 |
{ |
| 115 |
// First call the base-class for the standard things |
| 116 |
wxcWidget::LoadPropertiesFromwxFB(node); |
| 117 |
|
| 118 |
// See the comment in LoadPropertiesFromXRC() |
| 119 |
wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", wxT("size")); |
| 120 |
if(!propertynode) { SetPropertyString(PROP_SIZE, "-1,-1"); } |
| 121 |
} |