]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_split.cpp
Reflect changes in stc.cpp in stc.cpp.in from which it's generated.
[wxWidgets.git] / src / xrc / xh_split.cpp
CommitLineData
2f5b93fb 1/////////////////////////////////////////////////////////////////////////////
40ff126a 2// Name: src/xrc/xh_split.cpp
2f5b93fb
VS
3// Purpose: XRC resource for wxSplitterWindow
4// Author: panga@freemail.hu, Vaclav Slavik
5// Created: 2003/01/26
2f5b93fb
VS
6// Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
f80ea77b 9
2f5b93fb
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
dd47af27 17#if wxUSE_XRC && wxUSE_SPLITTER
a1e4ec87 18
2f5b93fb 19#include "wx/xrc/xh_split.h"
e4db172a
WS
20
21#ifndef WX_PRECOMP
22 #include "wx/log.h"
23#endif
24
2f5b93fb 25#include "wx/splitter.h"
2f5b93fb 26
df27f1dc
VZ
27#include "wx/xml/xml.h"
28
854e189f
VS
29IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindowXmlHandler, wxXmlResourceHandler)
30
2f5b93fb
VS
31wxSplitterWindowXmlHandler::wxSplitterWindowXmlHandler() : wxXmlResourceHandler()
32{
33 XRC_ADD_STYLE(wxSP_3D);
34 XRC_ADD_STYLE(wxSP_3DSASH);
35 XRC_ADD_STYLE(wxSP_3DBORDER);
40ff126a 36#if WXWIN_COMPATIBILITY_2_6
2f5b93fb 37 XRC_ADD_STYLE(wxSP_FULLSASH);
40ff126a 38#endif // WXWIN_COMPATIBILITY_2_6
2f5b93fb
VS
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);
e7a0050f 43 XRC_ADD_STYLE(wxSP_NO_XP_THEME);
2f5b93fb
VS
44 AddWindowStyles();
45}
46
47wxObject *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 = GetLong(wxT("sashpos"), 0);
60 long minpanesize = GetLong(wxT("minsize"), -1);
cabf4bca 61 float gravity = GetFloat(wxT("gravity"), 0.0);
2f5b93fb 62 if (minpanesize != -1)
cabf4bca
JS
63 splitter->SetMinimumPaneSize(minpanesize);
64 if (gravity != 0.0)
65 splitter->SetSashGravity(gravity);
2f5b93fb
VS
66
67 wxWindow *win1 = NULL, *win2 = NULL;
68 wxXmlNode *n = m_node->GetChildren();
69 while (n)
70 {
f80ea77b 71 if ((n->GetType() == wxXML_ELEMENT_NODE) &&
2f5b93fb
VS
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;
f80ea77b 85 }
2f5b93fb
VS
86 }
87 n = n->GetNext();
88 }
89
90 if (win1 == NULL)
819559b2 91 ReportError("wxSplitterWindow node must contain at least one window");
2f5b93fb
VS
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
109bool wxSplitterWindowXmlHandler::CanHandle(wxXmlNode *node)
110{
111 return IsOfClass(node, wxT("wxSplitterWindow"));
112}
113
dd47af27 114#endif // wxUSE_XRC && wxUSE_SPLITTER