]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_split.cpp
no changes, just de TABified
[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
6// RCS-ID: $Id$
7// Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
f80ea77b 10
2f5b93fb
VS
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
dd47af27 18#if wxUSE_XRC && wxUSE_SPLITTER
a1e4ec87 19
2f5b93fb 20#include "wx/xrc/xh_split.h"
e4db172a
WS
21
22#ifndef WX_PRECOMP
23 #include "wx/log.h"
24#endif
25
2f5b93fb 26#include "wx/splitter.h"
2f5b93fb 27
854e189f
VS
28IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindowXmlHandler, wxXmlResourceHandler)
29
2f5b93fb
VS
30wxSplitterWindowXmlHandler::wxSplitterWindowXmlHandler() : wxXmlResourceHandler()
31{
32 XRC_ADD_STYLE(wxSP_3D);
33 XRC_ADD_STYLE(wxSP_3DSASH);
34 XRC_ADD_STYLE(wxSP_3DBORDER);
40ff126a 35#if WXWIN_COMPATIBILITY_2_6
2f5b93fb 36 XRC_ADD_STYLE(wxSP_FULLSASH);
40ff126a 37#endif // WXWIN_COMPATIBILITY_2_6
2f5b93fb
VS
38 XRC_ADD_STYLE(wxSP_BORDER);
39 XRC_ADD_STYLE(wxSP_NOBORDER);
40 XRC_ADD_STYLE(wxSP_PERMIT_UNSPLIT);
41 XRC_ADD_STYLE(wxSP_LIVE_UPDATE);
e7a0050f 42 XRC_ADD_STYLE(wxSP_NO_XP_THEME);
2f5b93fb
VS
43 AddWindowStyles();
44}
45
46wxObject *wxSplitterWindowXmlHandler::DoCreateResource()
47{
48 XRC_MAKE_INSTANCE(splitter, wxSplitterWindow);
49
50 splitter->Create(m_parentAsWindow,
51 GetID(),
52 GetPosition(), GetSize(),
53 GetStyle(wxT("style"), wxSP_3D),
54 GetName());
55
56 SetupWindow(splitter);
57
58 long sashpos = GetLong(wxT("sashpos"), 0);
59 long minpanesize = GetLong(wxT("minsize"), -1);
60 if (minpanesize != -1)
61 splitter->SetMinimumPaneSize(minpanesize);
62
63 wxWindow *win1 = NULL, *win2 = NULL;
64 wxXmlNode *n = m_node->GetChildren();
65 while (n)
66 {
f80ea77b 67 if ((n->GetType() == wxXML_ELEMENT_NODE) &&
2f5b93fb
VS
68 (n->GetName() == wxT("object") ||
69 n->GetName() == wxT("object_ref")))
70 {
71 wxObject *created = CreateResFromNode(n, splitter, NULL);
72 wxWindow *win = wxDynamicCast(created, wxWindow);
73 if (win1 == NULL)
74 {
75 win1 = win;
76 }
77 else
78 {
79 win2 = win;
80 break;
f80ea77b 81 }
2f5b93fb
VS
82 }
83 n = n->GetNext();
84 }
85
86 if (win1 == NULL)
87 wxLogError(wxT("wxSplitterWindow node must contain at least one window."));
88
89 bool horizontal = (GetParamValue(wxT("orientation")) != wxT("vertical"));
90 if (win1 && win2)
91 {
92 if (horizontal)
93 splitter->SplitHorizontally(win1, win2, sashpos);
94 else
95 splitter->SplitVertically(win1, win2, sashpos);
96 }
97 else
98 {
99 splitter->Initialize(win1);
100 }
101
102 return splitter;
103}
104
105bool wxSplitterWindowXmlHandler::CanHandle(wxXmlNode *node)
106{
107 return IsOfClass(node, wxT("wxSplitterWindow"));
108}
109
dd47af27 110#endif // wxUSE_XRC && wxUSE_SPLITTER