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