]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_unkwn.cpp
removed static methods from wxAppTraitsBase, this doesn't work well in non-monolithic...
[wxWidgets.git] / src / xrc / xh_unkwn.cpp
CommitLineData
78d14f80
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: xh_unkwn.cpp
b5d6954b 3// Purpose: XRC resource for unknown widget
78d14f80
VS
4// Author: Vaclav Slavik
5// Created: 2000/09/09
6// RCS-ID: $Id$
7// Copyright: (c) 2000 Vaclav Slavik
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
cefd71d7 10
78d14f80
VS
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"
cefd71d7 26#include "wx/panel.h"
78d14f80
VS
27
28
29class wxUnknownControlContainer : public wxPanel
30{
31public:
32 wxUnknownControlContainer(wxWindow *parent,
33 const wxString& controlName,
34 wxWindowID id = -1,
35 const wxPoint& pos = wxDefaultPosition,
36 const wxSize& size = wxDefaultSize)
37 : wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL | wxNO_BORDER,
38 controlName + wxT("_container")),
5c451707 39 m_controlName(controlName), m_controlAdded(false)
78d14f80
VS
40 {
41 m_bg = GetBackgroundColour();
42 SetBackgroundColour(wxColour(255, 0, 255));
43 }
44
45 virtual void AddChild(wxWindowBase *child);
5c451707 46 virtual void RemoveChild(wxWindowBase *child);
cefd71d7 47
78d14f80
VS
48protected:
49 wxString m_controlName;
50 bool m_controlAdded;
51 wxColour m_bg;
52};
53
54void wxUnknownControlContainer::AddChild(wxWindowBase *child)
55{
63fd5f0b 56 wxASSERT_MSG( !m_controlAdded, wxT("Couldn't add two unknown controls to the same container!") );
78d14f80
VS
57
58 wxPanel::AddChild(child);
cefd71d7 59
78d14f80
VS
60 SetBackgroundColour(m_bg);
61 child->SetName(m_controlName);
5ed345b7 62 child->SetId(wxXmlResource::GetXRCID(m_controlName));
5c451707 63 m_controlAdded = true;
cefd71d7 64
78d14f80
VS
65 wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
66 sizer->Add((wxWindow*)child, 1, wxEXPAND);
67 SetSizer(sizer);
5c451707 68 SetAutoLayout(true);
78d14f80
VS
69 Layout();
70}
71
5c451707
VS
72void wxUnknownControlContainer::RemoveChild(wxWindowBase *child)
73{
74 wxPanel::RemoveChild(child);
75 m_controlAdded = false;
76 GetSizer()->Detach((wxWindow*)child);
77}
78d14f80
VS
78
79
854e189f
VS
80IMPLEMENT_DYNAMIC_CLASS(wxUnknownWidgetXmlHandler, wxXmlResourceHandler)
81
cefd71d7
RD
82wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler()
83: wxXmlResourceHandler()
78d14f80
VS
84{
85}
86
87wxObject *wxUnknownWidgetXmlHandler::DoCreateResource()
cefd71d7
RD
88{
89 wxPanel *panel =
78d14f80
VS
90 new wxUnknownControlContainer(m_parentAsWindow,
91 GetName(), -1,
92 GetPosition(), GetSize());
93 SetupWindow(panel);
94 return panel;
95}
96
97bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode *node)
98{
99 return IsOfClass(node, wxT("unknown"));
100}
101