1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_split.cpp
3 // Purpose: XRC resource for wxSplitterWindow
4 // Author: panga@freemail.hu, Vaclav Slavik
7 // Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_XRC && wxUSE_SPLITTER
20 #include "wx/xrc/xh_split.h"
26 #include "wx/splitter.h"
28 #include "wx/xml/xml.h"
30 IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindowXmlHandler
, wxXmlResourceHandler
)
32 wxSplitterWindowXmlHandler::wxSplitterWindowXmlHandler() : wxXmlResourceHandler()
34 XRC_ADD_STYLE(wxSP_3D
);
35 XRC_ADD_STYLE(wxSP_3DSASH
);
36 XRC_ADD_STYLE(wxSP_3DBORDER
);
37 #if WXWIN_COMPATIBILITY_2_6
38 XRC_ADD_STYLE(wxSP_FULLSASH
);
39 #endif // WXWIN_COMPATIBILITY_2_6
40 XRC_ADD_STYLE(wxSP_BORDER
);
41 XRC_ADD_STYLE(wxSP_NOBORDER
);
42 XRC_ADD_STYLE(wxSP_PERMIT_UNSPLIT
);
43 XRC_ADD_STYLE(wxSP_LIVE_UPDATE
);
44 XRC_ADD_STYLE(wxSP_NO_XP_THEME
);
48 wxObject
*wxSplitterWindowXmlHandler::DoCreateResource()
50 XRC_MAKE_INSTANCE(splitter
, wxSplitterWindow
);
52 splitter
->Create(m_parentAsWindow
,
54 GetPosition(), GetSize(),
55 GetStyle(wxT("style"), wxSP_3D
),
58 SetupWindow(splitter
);
60 long sashpos
= GetLong(wxT("sashpos"), 0);
61 long minpanesize
= GetLong(wxT("minsize"), -1);
62 float gravity
= GetFloat(wxT("gravity"), 0.0);
63 if (minpanesize
!= -1)
64 splitter
->SetMinimumPaneSize(minpanesize
);
66 splitter
->SetSashGravity(gravity
);
68 wxWindow
*win1
= NULL
, *win2
= NULL
;
69 wxXmlNode
*n
= m_node
->GetChildren();
72 if ((n
->GetType() == wxXML_ELEMENT_NODE
) &&
73 (n
->GetName() == wxT("object") ||
74 n
->GetName() == wxT("object_ref")))
76 wxObject
*created
= CreateResFromNode(n
, splitter
, NULL
);
77 wxWindow
*win
= wxDynamicCast(created
, wxWindow
);
92 ReportError("wxSplitterWindow node must contain at least one window");
94 bool horizontal
= (GetParamValue(wxT("orientation")) != wxT("vertical"));
98 splitter
->SplitHorizontally(win1
, win2
, sashpos
);
100 splitter
->SplitVertically(win1
, win2
, sashpos
);
104 splitter
->Initialize(win1
);
110 bool wxSplitterWindowXmlHandler::CanHandle(wxXmlNode
*node
)
112 return IsOfClass(node
, wxT("wxSplitterWindow"));
115 #endif // wxUSE_XRC && wxUSE_SPLITTER