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