1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XRC resource for unknown widget
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2000 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "xh_unkwn.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
22 #include "wx/xrc/xh_unkwn.h"
23 #include "wx/window.h"
29 class wxUnknownControlContainer
: public wxPanel
32 wxUnknownControlContainer(wxWindow
*parent
,
33 const wxString
& controlName
,
35 const wxPoint
& pos
= wxDefaultPosition
,
36 const wxSize
& size
= wxDefaultSize
)
37 : wxPanel(parent
, id
, pos
, size
, wxTAB_TRAVERSAL
| wxNO_BORDER
,
38 controlName
+ wxT("_container")),
39 m_controlName(controlName
), m_controlAdded(FALSE
)
41 m_bg
= GetBackgroundColour();
42 SetBackgroundColour(wxColour(255, 0, 255));
45 virtual void AddChild(wxWindowBase
*child
);
48 wxString m_controlName
;
53 void wxUnknownControlContainer::AddChild(wxWindowBase
*child
)
55 wxASSERT_MSG( !m_controlAdded
, wxT("Couldn't add two unknown controls to the same container!") );
57 wxPanel::AddChild(child
);
59 SetBackgroundColour(m_bg
);
60 child
->SetName(m_controlName
);
61 child
->SetId(wxXmlResource::GetXRCID(m_controlName
));
62 m_controlAdded
= TRUE
;
64 wxSizer
*sizer
= new wxBoxSizer(wxHORIZONTAL
);
65 sizer
->Add((wxWindow
*)child
, 1, wxEXPAND
);
73 wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler()
74 : wxXmlResourceHandler()
78 wxObject
*wxUnknownWidgetXmlHandler::DoCreateResource()
81 new wxUnknownControlContainer(m_parentAsWindow
,
83 GetPosition(), GetSize());
88 bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode
*node
)
90 return IsOfClass(node
, wxT("unknown"));