]> git.saurik.com Git - wxWidgets.git/blob - contrib/src/xml/xh_unkwn.cpp
changed version number
[wxWidgets.git] / contrib / src / xml / 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/xml/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 m_controlAdded = TRUE;
61
62 wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
63 sizer->Add((wxWindow*)child, 1, wxEXPAND);
64 SetSizer(sizer);
65 SetAutoLayout(TRUE);
66 Layout();
67 }
68
69
70
71 wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler()
72 : wxXmlResourceHandler()
73 {
74 }
75
76 wxObject *wxUnknownWidgetXmlHandler::DoCreateResource()
77 {
78 wxPanel *panel =
79 new wxUnknownControlContainer(m_parentAsWindow,
80 GetName(), GetID(),
81 GetPosition(), GetSize());
82 SetupWindow(panel);
83 return panel;
84 }
85
86 bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode *node)
87 {
88 return IsOfClass(node, wxT("unknown"));
89 }
90