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 long style
= wxTAB_TRAVERSAL
| wxNO_BORDER
)
38 : wxPanel(parent
, id
, pos
, size
, style
,
39 controlName
+ wxT("_container")),
40 m_controlName(controlName
), m_controlAdded(false)
42 m_bg
= GetBackgroundColour();
43 SetBackgroundColour(wxColour(255, 0, 255));
46 virtual void AddChild(wxWindowBase
*child
);
47 virtual void RemoveChild(wxWindowBase
*child
);
50 wxString m_controlName
;
55 void wxUnknownControlContainer::AddChild(wxWindowBase
*child
)
57 wxASSERT_MSG( !m_controlAdded
, wxT("Couldn't add two unknown controls to the same container!") );
59 wxPanel::AddChild(child
);
61 SetBackgroundColour(m_bg
);
62 child
->SetName(m_controlName
);
63 child
->SetId(wxXmlResource::GetXRCID(m_controlName
));
64 m_controlAdded
= true;
66 wxSizer
*sizer
= new wxBoxSizer(wxHORIZONTAL
);
67 sizer
->Add((wxWindow
*)child
, 1, wxEXPAND
);
73 void wxUnknownControlContainer::RemoveChild(wxWindowBase
*child
)
75 wxPanel::RemoveChild(child
);
76 m_controlAdded
= false;
77 GetSizer()->Detach((wxWindow
*)child
);
81 IMPLEMENT_DYNAMIC_CLASS(wxUnknownWidgetXmlHandler
, wxXmlResourceHandler
)
83 wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler()
84 : wxXmlResourceHandler()
86 XRC_ADD_STYLE(wxNO_FULL_REPAINT_ON_RESIZE
);
89 wxObject
*wxUnknownWidgetXmlHandler::DoCreateResource()
92 new wxUnknownControlContainer(m_parentAsWindow
,
94 GetPosition(), GetSize(),
95 GetStyle(wxT("style"),
96 wxTAB_TRAVERSAL
| wxNO_BORDER
));
101 bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode
*node
)
103 return IsOfClass(node
, wxT("unknown"));