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