]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_split.cpp
XRC spec: document wxRibbon* XRC handler.
[wxWidgets.git] / src / xrc / xh_split.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_split.cpp
3 // Purpose: XRC resource for wxSplitterWindow
4 // Author: panga@freemail.hu, Vaclav Slavik
5 // Created: 2003/01/26
6 // Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik
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_SPLITTER
18
19 #include "wx/xrc/xh_split.h"
20
21 #ifndef WX_PRECOMP
22 #include "wx/log.h"
23 #endif
24
25 #include "wx/splitter.h"
26
27 #include "wx/xml/xml.h"
28
29 IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindowXmlHandler, wxXmlResourceHandler)
30
31 wxSplitterWindowXmlHandler::wxSplitterWindowXmlHandler() : wxXmlResourceHandler()
32 {
33 XRC_ADD_STYLE(wxSP_3D);
34 XRC_ADD_STYLE(wxSP_3DSASH);
35 XRC_ADD_STYLE(wxSP_3DBORDER);
36 #if WXWIN_COMPATIBILITY_2_6
37 XRC_ADD_STYLE(wxSP_FULLSASH);
38 #endif // WXWIN_COMPATIBILITY_2_6
39 XRC_ADD_STYLE(wxSP_BORDER);
40 XRC_ADD_STYLE(wxSP_NOBORDER);
41 XRC_ADD_STYLE(wxSP_PERMIT_UNSPLIT);
42 XRC_ADD_STYLE(wxSP_LIVE_UPDATE);
43 XRC_ADD_STYLE(wxSP_NO_XP_THEME);
44 AddWindowStyles();
45 }
46
47 wxObject *wxSplitterWindowXmlHandler::DoCreateResource()
48 {
49 XRC_MAKE_INSTANCE(splitter, wxSplitterWindow);
50
51 splitter->Create(m_parentAsWindow,
52 GetID(),
53 GetPosition(), GetSize(),
54 GetStyle(wxT("style"), wxSP_3D),
55 GetName());
56
57 SetupWindow(splitter);
58
59 long sashpos = GetDimension(wxT("sashpos"), 0);
60 long minpanesize = GetDimension(wxT("minsize"), -1);
61 float gravity = GetFloat(wxT("gravity"), 0.0);
62 if (minpanesize != -1)
63 splitter->SetMinimumPaneSize(minpanesize);
64 if (gravity != 0.0)
65 splitter->SetSashGravity(gravity);
66
67 wxWindow *win1 = NULL, *win2 = NULL;
68 wxXmlNode *n = m_node->GetChildren();
69 while (n)
70 {
71 if ((n->GetType() == wxXML_ELEMENT_NODE) &&
72 (n->GetName() == wxT("object") ||
73 n->GetName() == wxT("object_ref")))
74 {
75 wxObject *created = CreateResFromNode(n, splitter, NULL);
76 wxWindow *win = wxDynamicCast(created, wxWindow);
77 if (win1 == NULL)
78 {
79 win1 = win;
80 }
81 else
82 {
83 win2 = win;
84 break;
85 }
86 }
87 n = n->GetNext();
88 }
89
90 if (win1 == NULL)
91 ReportError("wxSplitterWindow node must contain at least one window");
92
93 bool horizontal = (GetParamValue(wxT("orientation")) != wxT("vertical"));
94 if (win1 && win2)
95 {
96 if (horizontal)
97 splitter->SplitHorizontally(win1, win2, sashpos);
98 else
99 splitter->SplitVertically(win1, win2, sashpos);
100 }
101 else
102 {
103 splitter->Initialize(win1);
104 }
105
106 return splitter;
107 }
108
109 bool wxSplitterWindowXmlHandler::CanHandle(wxXmlNode *node)
110 {
111 return IsOfClass(node, wxT("wxSplitterWindow"));
112 }
113
114 #endif // wxUSE_XRC && wxUSE_SPLITTER