]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_split.cpp
Update copyright year in ctrl+alt+mclick dialog
[wxWidgets.git] / src / xrc / xh_split.cpp
CommitLineData
2f5b93fb
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: xh_split.cpp
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
621be1ec 18#if wxUSE_XRC
a1e4ec87 19
2f5b93fb
VS
20#include "wx/xrc/xh_split.h"
21#include "wx/splitter.h"
22#include "wx/log.h"
23
854e189f
VS
24IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindowXmlHandler, wxXmlResourceHandler)
25
2f5b93fb
VS
26wxSplitterWindowXmlHandler::wxSplitterWindowXmlHandler() : wxXmlResourceHandler()
27{
28 XRC_ADD_STYLE(wxSP_3D);
29 XRC_ADD_STYLE(wxSP_3DSASH);
30 XRC_ADD_STYLE(wxSP_3DBORDER);
31 XRC_ADD_STYLE(wxSP_FULLSASH);
32 XRC_ADD_STYLE(wxSP_BORDER);
33 XRC_ADD_STYLE(wxSP_NOBORDER);
34 XRC_ADD_STYLE(wxSP_PERMIT_UNSPLIT);
35 XRC_ADD_STYLE(wxSP_LIVE_UPDATE);
e7a0050f 36 XRC_ADD_STYLE(wxSP_NO_XP_THEME);
2f5b93fb
VS
37 AddWindowStyles();
38}
39
40wxObject *wxSplitterWindowXmlHandler::DoCreateResource()
41{
42 XRC_MAKE_INSTANCE(splitter, wxSplitterWindow);
43
44 splitter->Create(m_parentAsWindow,
45 GetID(),
46 GetPosition(), GetSize(),
47 GetStyle(wxT("style"), wxSP_3D),
48 GetName());
49
50 SetupWindow(splitter);
51
52 long sashpos = GetLong(wxT("sashpos"), 0);
53 long minpanesize = GetLong(wxT("minsize"), -1);
54 if (minpanesize != -1)
55 splitter->SetMinimumPaneSize(minpanesize);
56
57 wxWindow *win1 = NULL, *win2 = NULL;
58 wxXmlNode *n = m_node->GetChildren();
59 while (n)
60 {
f80ea77b 61 if ((n->GetType() == wxXML_ELEMENT_NODE) &&
2f5b93fb
VS
62 (n->GetName() == wxT("object") ||
63 n->GetName() == wxT("object_ref")))
64 {
65 wxObject *created = CreateResFromNode(n, splitter, NULL);
66 wxWindow *win = wxDynamicCast(created, wxWindow);
67 if (win1 == NULL)
68 {
69 win1 = win;
70 }
71 else
72 {
73 win2 = win;
74 break;
f80ea77b 75 }
2f5b93fb
VS
76 }
77 n = n->GetNext();
78 }
79
80 if (win1 == NULL)
81 wxLogError(wxT("wxSplitterWindow node must contain at least one window."));
82
83 bool horizontal = (GetParamValue(wxT("orientation")) != wxT("vertical"));
84 if (win1 && win2)
85 {
86 if (horizontal)
87 splitter->SplitHorizontally(win1, win2, sashpos);
88 else
89 splitter->SplitVertically(win1, win2, sashpos);
90 }
91 else
92 {
93 splitter->Initialize(win1);
94 }
95
96 return splitter;
97}
98
99bool wxSplitterWindowXmlHandler::CanHandle(wxXmlNode *node)
100{
101 return IsOfClass(node, wxT("wxSplitterWindow"));
102}
103
621be1ec 104#endif // wxUSE_XRC