]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_unkwn.cpp
Updated version to 2.3.2 so apps can test for differences in new merged source
[wxWidgets.git] / src / xrc / xh_unkwn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: xh_unkwn.cpp
3 // Purpose: XML resource for unknown widget
4 // Author: Vaclav Slavik
5 // Created: 2000/09/09
6 // RCS-ID: $Id$
7 // Copyright: (c) 2000 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifdef __GNUG__
12 #pragma implementation "xh_unkwn.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_unkwn.h"
23 #include "wx/window.h"
24 #include "wx/log.h"
25 #include "wx/sizer.h"
26
27
28 class wxUnknownControlContainer : public wxPanel
29 {
30 public:
31 wxUnknownControlContainer(wxWindow *parent,
32 const wxString& controlName,
33 wxWindowID id = -1,
34 const wxPoint& pos = wxDefaultPosition,
35 const wxSize& size = wxDefaultSize)
36 : wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL | wxNO_BORDER,
37 controlName + wxT("_container")),
38 m_controlName(controlName), m_controlAdded(FALSE)
39 {
40 m_bg = GetBackgroundColour();
41 SetBackgroundColour(wxColour(255, 0, 255));
42 }
43
44 virtual void AddChild(wxWindowBase *child);
45
46 protected:
47 wxString m_controlName;
48 bool m_controlAdded;
49 wxColour m_bg;
50 };
51
52 void wxUnknownControlContainer::AddChild(wxWindowBase *child)
53 {
54 wxASSERT_MSG( !m_controlAdded, wxT("Couldn't add two unknown controls to the same container!") )
55
56 wxPanel::AddChild(child);
57
58 SetBackgroundColour(m_bg);
59 child->SetName(m_controlName);
60 child->SetId(XMLID(m_controlName));
61 m_controlAdded = TRUE;
62
63 wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
64 sizer->Add((wxWindow*)child, 1, wxEXPAND);
65 SetSizer(sizer);
66 SetAutoLayout(TRUE);
67 Layout();
68 }
69
70
71
72 wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler()
73 : wxXmlResourceHandler()
74 {
75 }
76
77 wxObject *wxUnknownWidgetXmlHandler::DoCreateResource()
78 {
79 wxPanel *panel =
80 new wxUnknownControlContainer(m_parentAsWindow,
81 GetName(), -1,
82 GetPosition(), GetSize());
83 SetupWindow(panel);
84 return panel;
85 }
86
87 bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode *node)
88 {
89 return IsOfClass(node, wxT("unknown"));
90 }
91