]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_collpane.cpp
Work around missing mode_t definition with ICC.
[wxWidgets.git] / src / xrc / xh_collpane.cpp
CommitLineData
912c3932
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/xrc/xh_collpane.cpp
3// Purpose: XML resource handler for wxCollapsiblePane
4// Author: Francesco Montorsi
5// Created: 2006-10-27
912c3932
VZ
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
d34ad9ea
VZ
19#ifndef WX_PRECOMP
20 #include "wx/log.h"
21#endif
22
23#include "wx/collpane.h"
912c3932 24#include "wx/xrc/xh_collpane.h"
912c3932
VZ
25
26IMPLEMENT_DYNAMIC_CLASS(wxCollapsiblePaneXmlHandler, wxXmlResourceHandler)
27
03647350 28wxCollapsiblePaneXmlHandler::wxCollapsiblePaneXmlHandler()
68d89837 29: wxXmlResourceHandler(), m_isInside(false)
912c3932
VZ
30{
31 XRC_ADD_STYLE(wxCP_NO_TLW_RESIZE);
32 XRC_ADD_STYLE(wxCP_DEFAULT_STYLE);
33 AddWindowStyles();
34}
35
36wxObject *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 {
819559b2 56 ReportError("no control within panewindow");
912c3932
VZ
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 {
819559b2 67 ReportParamError("label", "label cannot be empty");
912c3932
VZ
68 return NULL;
69 }
70
71 ctrl->Create(m_parentAsWindow,
72 GetID(),
73 label,
74 GetPosition(), GetSize(),
9a83f860 75 GetStyle(wxT("style"), wxCP_DEFAULT_STYLE),
912c3932
VZ
76 wxDefaultValidator,
77 GetName());
78
9a83f860 79 ctrl->Collapse(GetBool(wxT("collapsed")));
912c3932
VZ
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
94bool 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