| 1 |
#include "myxh_simplebook.h" |
| 2 |
#include "wxgui_helpers.h" |
| 3 |
#include <wx/log.h> |
| 4 |
#include <wx/simplebook.h> |
| 5 |
#include <wx/sizer.h> |
| 6 |
|
| 7 |
MyWxSimplebookXmlHandler::MyWxSimplebookXmlHandler() |
| 8 |
: wxXmlResourceHandler() |
| 9 |
, m_isInside(false) |
| 10 |
, m_notebook(NULL) |
| 11 |
{ |
| 12 |
AddWindowStyles(); |
| 13 |
} |
| 14 |
|
| 15 |
wxObject* MyWxSimplebookXmlHandler::DoCreateResource() |
| 16 |
{ |
| 17 |
if(m_class == wxT("simplebookpage")) { |
| 18 |
wxXmlNode* n = GetParamNode(wxT("object")); |
| 19 |
|
| 20 |
if(!n) n = GetParamNode(wxT("object_ref")); |
| 21 |
|
| 22 |
if(n) { |
| 23 |
bool old_ins = m_isInside; |
| 24 |
m_isInside = false; |
| 25 |
wxObject* item = CreateResFromNode(n, m_notebook, NULL); |
| 26 |
m_isInside = old_ins; |
| 27 |
wxWindow* wnd = wxDynamicCast(item, wxWindow); |
| 28 |
|
| 29 |
if(wnd) { |
| 30 |
m_notebook->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")), wxNOT_FOUND); |
| 31 |
|
| 32 |
} else |
| 33 |
wxLogError(wxT("Error in resource.")); |
| 34 |
|
| 35 |
return wnd; |
| 36 |
} else { |
| 37 |
wxLogError(wxT("Error in resource: no control within notebook's <page> tag.")); |
| 38 |
return NULL; |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
else { |
| 43 |
wxSimplebook* nb = |
| 44 |
new wxSimplebook(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style"))); |
| 45 |
wxString showEffect = GetText("effect", false); |
| 46 |
nb->SetEffect(wxCrafter::ShowEffectFromString(showEffect)); |
| 47 |
nb->SetName(GetName()); |
| 48 |
SetupWindow(nb); |
| 49 |
|
| 50 |
wxSimplebook* old_par = m_notebook; |
| 51 |
m_notebook = nb; |
| 52 |
bool old_ins = m_isInside; |
| 53 |
m_isInside = true; |
| 54 |
CreateChildren(m_notebook, true /*only this handler*/); |
| 55 |
m_isInside = old_ins; |
| 56 |
m_notebook = old_par; |
| 57 |
return nb; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
bool MyWxSimplebookXmlHandler::CanHandle(wxXmlNode* node) |
| 62 |
{ |
| 63 |
return ((!m_isInside && IsOfClass(node, wxT("wxSimplebook"))) || |
| 64 |
(m_isInside && IsOfClass(node, wxT("simplebookpage")))); |
| 65 |
} |