Remove obsolete VisualAge-related files.
[wxWidgets.git] / src / xrc / xh_collpane.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_collpane.cpp
3 // Purpose: XML resource handler for wxCollapsiblePane
4 // Author: Francesco Montorsi
5 // Created: 2006-10-27
6 // Copyright: (c) 2006 Francesco Montorsi
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #if wxUSE_XRC && wxUSE_COLLPANE
18
19 #ifndef WX_PRECOMP
20 #include "wx/log.h"
21 #endif
22
23 #include "wx/collpane.h"
24 #include "wx/xrc/xh_collpane.h"
25
26 IMPLEMENT_DYNAMIC_CLASS(wxCollapsiblePaneXmlHandler, wxXmlResourceHandler)
27
28 wxCollapsiblePaneXmlHandler::wxCollapsiblePaneXmlHandler()
29 : wxXmlResourceHandler(), m_isInside(false)
30 {
31 XRC_ADD_STYLE(wxCP_NO_TLW_RESIZE);
32 XRC_ADD_STYLE(wxCP_DEFAULT_STYLE);
33 AddWindowStyles();
34 }
35
36 wxObject *wxCollapsiblePaneXmlHandler::DoCreateResource()
37 {
38 if (m_class == wxT("panewindow")) // read the XRC for the pane window
39 {
40 wxXmlNode *n = GetParamNode(wxT("object"));
41
42 if ( !n )
43 n = GetParamNode(wxT("object_ref"));
44
45 if (n)
46 {
47 bool old_ins = m_isInside;
48 m_isInside = false;
49 wxObject *item = CreateResFromNode(n, m_collpane->GetPane(), NULL);
50 m_isInside = old_ins;
51
52 return item;
53 }
54 else
55 {
56 ReportError("no control within panewindow");
57 return NULL;
58 }
59 }
60 else
61 {
62 XRC_MAKE_INSTANCE(ctrl, wxCollapsiblePane)
63
64 wxString label = GetParamValue(wxT("label"));
65 if (label.empty())
66 {
67 ReportParamError("label", "label cannot be empty");
68 return NULL;
69 }
70
71 ctrl->Create(m_parentAsWindow,
72 GetID(),
73 label,
74 GetPosition(), GetSize(),
75 GetStyle(wxT("style"), wxCP_DEFAULT_STYLE),
76 wxDefaultValidator,
77 GetName());
78
79 ctrl->Collapse(GetBool(wxT("collapsed")));
80 SetupWindow(ctrl);
81
82 wxCollapsiblePane *old_par = m_collpane;
83 m_collpane = ctrl;
84 bool old_ins = m_isInside;
85 m_isInside = true;
86 CreateChildren(m_collpane, true/*only this handler*/);
87 m_isInside = old_ins;
88 m_collpane = old_par;
89
90 return ctrl;
91 }
92 }
93
94 bool wxCollapsiblePaneXmlHandler::CanHandle(wxXmlNode *node)
95 {
96 return IsOfClass(node, wxT("wxCollapsiblePane")) ||
97 (m_isInside && IsOfClass(node, wxT("panewindow")));
98 }
99
100 #endif // wxUSE_XRC && wxUSE_COLLPANE