1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XML 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"
28 class wxUnknownControlContainer
: public wxPanel
31 wxUnknownControlContainer(wxWindow
*parent
,
32 const wxString
& controlName
,
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
)
40 m_bg
= GetBackgroundColour();
41 SetBackgroundColour(wxColour(255, 0, 255));
44 virtual void AddChild(wxWindowBase
*child
);
47 wxString m_controlName
;
52 void wxUnknownControlContainer::AddChild(wxWindowBase
*child
)
54 wxASSERT_MSG( !m_controlAdded
, wxT("Couldn't add two unknown controls to the same container!") )
56 wxPanel::AddChild(child
);
58 SetBackgroundColour(m_bg
);
59 child
->SetName(m_controlName
);
60 child
->SetId(wxXmlResource::GetXMLID(m_controlName
));
61 m_controlAdded
= TRUE
;
63 wxSizer
*sizer
= new wxBoxSizer(wxHORIZONTAL
);
64 sizer
->Add((wxWindow
*)child
, 1, wxEXPAND
);
72 wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler()
73 : wxXmlResourceHandler()
77 wxObject
*wxUnknownWidgetXmlHandler::DoCreateResource()
80 new wxUnknownControlContainer(m_parentAsWindow
,
82 GetPosition(), GetSize());
87 bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode
*node
)
89 return IsOfClass(node
, wxT("unknown"));