]>
Commit | Line | Data |
---|---|---|
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 | |
df27f1dc VZ |
28 | #include "wx/xml/xml.h" |
29 | ||
854e189f VS |
30 | IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindowXmlHandler, wxXmlResourceHandler) |
31 | ||
2f5b93fb VS |
32 | wxSplitterWindowXmlHandler::wxSplitterWindowXmlHandler() : wxXmlResourceHandler() |
33 | { | |
34 | XRC_ADD_STYLE(wxSP_3D); | |
35 | XRC_ADD_STYLE(wxSP_3DSASH); | |
36 | XRC_ADD_STYLE(wxSP_3DBORDER); | |
40ff126a | 37 | #if WXWIN_COMPATIBILITY_2_6 |
2f5b93fb | 38 | XRC_ADD_STYLE(wxSP_FULLSASH); |
40ff126a | 39 | #endif // WXWIN_COMPATIBILITY_2_6 |
2f5b93fb VS |
40 | XRC_ADD_STYLE(wxSP_BORDER); |
41 | XRC_ADD_STYLE(wxSP_NOBORDER); | |
42 | XRC_ADD_STYLE(wxSP_PERMIT_UNSPLIT); | |
43 | XRC_ADD_STYLE(wxSP_LIVE_UPDATE); | |
e7a0050f | 44 | XRC_ADD_STYLE(wxSP_NO_XP_THEME); |
2f5b93fb VS |
45 | AddWindowStyles(); |
46 | } | |
47 | ||
48 | wxObject *wxSplitterWindowXmlHandler::DoCreateResource() | |
49 | { | |
50 | XRC_MAKE_INSTANCE(splitter, wxSplitterWindow); | |
51 | ||
52 | splitter->Create(m_parentAsWindow, | |
53 | GetID(), | |
54 | GetPosition(), GetSize(), | |
55 | GetStyle(wxT("style"), wxSP_3D), | |
56 | GetName()); | |
57 | ||
58 | SetupWindow(splitter); | |
59 | ||
60 | long sashpos = GetLong(wxT("sashpos"), 0); | |
61 | long minpanesize = GetLong(wxT("minsize"), -1); | |
cabf4bca | 62 | float gravity = GetFloat(wxT("gravity"), 0.0); |
2f5b93fb | 63 | if (minpanesize != -1) |
cabf4bca JS |
64 | splitter->SetMinimumPaneSize(minpanesize); |
65 | if (gravity != 0.0) | |
66 | splitter->SetSashGravity(gravity); | |
2f5b93fb VS |
67 | |
68 | wxWindow *win1 = NULL, *win2 = NULL; | |
69 | wxXmlNode *n = m_node->GetChildren(); | |
70 | while (n) | |
71 | { | |
f80ea77b | 72 | if ((n->GetType() == wxXML_ELEMENT_NODE) && |
2f5b93fb VS |
73 | (n->GetName() == wxT("object") || |
74 | n->GetName() == wxT("object_ref"))) | |
75 | { | |
76 | wxObject *created = CreateResFromNode(n, splitter, NULL); | |
77 | wxWindow *win = wxDynamicCast(created, wxWindow); | |
78 | if (win1 == NULL) | |
79 | { | |
80 | win1 = win; | |
81 | } | |
82 | else | |
83 | { | |
84 | win2 = win; | |
85 | break; | |
f80ea77b | 86 | } |
2f5b93fb VS |
87 | } |
88 | n = n->GetNext(); | |
89 | } | |
90 | ||
91 | if (win1 == NULL) | |
819559b2 | 92 | ReportError("wxSplitterWindow node must contain at least one window"); |
2f5b93fb VS |
93 | |
94 | bool horizontal = (GetParamValue(wxT("orientation")) != wxT("vertical")); | |
95 | if (win1 && win2) | |
96 | { | |
97 | if (horizontal) | |
98 | splitter->SplitHorizontally(win1, win2, sashpos); | |
99 | else | |
100 | splitter->SplitVertically(win1, win2, sashpos); | |
101 | } | |
102 | else | |
103 | { | |
104 | splitter->Initialize(win1); | |
105 | } | |
106 | ||
107 | return splitter; | |
108 | } | |
109 | ||
110 | bool wxSplitterWindowXmlHandler::CanHandle(wxXmlNode *node) | |
111 | { | |
112 | return IsOfClass(node, wxT("wxSplitterWindow")); | |
113 | } | |
114 | ||
dd47af27 | 115 | #endif // wxUSE_XRC && wxUSE_SPLITTER |