]>
Commit | Line | Data |
---|---|---|
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 | ||
29 | class wxUnknownControlContainer : public wxPanel | |
30 | { | |
31 | public: | |
32 | wxUnknownControlContainer(wxWindow *parent, | |
33 | const wxString& controlName, | |
34 | wxWindowID id = -1, | |
35 | const wxPoint& pos = wxDefaultPosition, | |
afe06a54 VS |
36 | const wxSize& size = wxDefaultSize, |
37 | long style = wxTAB_TRAVERSAL | wxNO_BORDER) | |
38 | : wxPanel(parent, id, pos, size, style, | |
78d14f80 | 39 | controlName + wxT("_container")), |
5c451707 | 40 | m_controlName(controlName), m_controlAdded(false) |
78d14f80 VS |
41 | { |
42 | m_bg = GetBackgroundColour(); | |
43 | SetBackgroundColour(wxColour(255, 0, 255)); | |
44 | } | |
45 | ||
46 | virtual void AddChild(wxWindowBase *child); | |
5c451707 | 47 | virtual void RemoveChild(wxWindowBase *child); |
cefd71d7 | 48 | |
78d14f80 VS |
49 | protected: |
50 | wxString m_controlName; | |
51 | bool m_controlAdded; | |
52 | wxColour m_bg; | |
53 | }; | |
54 | ||
55 | void wxUnknownControlContainer::AddChild(wxWindowBase *child) | |
56 | { | |
63fd5f0b | 57 | wxASSERT_MSG( !m_controlAdded, wxT("Couldn't add two unknown controls to the same container!") ); |
78d14f80 VS |
58 | |
59 | wxPanel::AddChild(child); | |
cefd71d7 | 60 | |
78d14f80 VS |
61 | SetBackgroundColour(m_bg); |
62 | child->SetName(m_controlName); | |
5ed345b7 | 63 | child->SetId(wxXmlResource::GetXRCID(m_controlName)); |
5c451707 | 64 | m_controlAdded = true; |
cefd71d7 | 65 | |
78d14f80 VS |
66 | wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); |
67 | sizer->Add((wxWindow*)child, 1, wxEXPAND); | |
68 | SetSizer(sizer); | |
5c451707 | 69 | SetAutoLayout(true); |
78d14f80 VS |
70 | Layout(); |
71 | } | |
72 | ||
5c451707 VS |
73 | void wxUnknownControlContainer::RemoveChild(wxWindowBase *child) |
74 | { | |
75 | wxPanel::RemoveChild(child); | |
76 | m_controlAdded = false; | |
77 | GetSizer()->Detach((wxWindow*)child); | |
78 | } | |
78d14f80 VS |
79 | |
80 | ||
854e189f VS |
81 | IMPLEMENT_DYNAMIC_CLASS(wxUnknownWidgetXmlHandler, wxXmlResourceHandler) |
82 | ||
cefd71d7 RD |
83 | wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler() |
84 | : wxXmlResourceHandler() | |
78d14f80 | 85 | { |
afe06a54 | 86 | XRC_ADD_STYLE(wxNO_FULL_REPAINT_ON_RESIZE); |
78d14f80 VS |
87 | } |
88 | ||
89 | wxObject *wxUnknownWidgetXmlHandler::DoCreateResource() | |
cefd71d7 RD |
90 | { |
91 | wxPanel *panel = | |
78d14f80 VS |
92 | new wxUnknownControlContainer(m_parentAsWindow, |
93 | GetName(), -1, | |
afe06a54 VS |
94 | GetPosition(), GetSize(), |
95 | GetStyle(wxT("style"), | |
96 | wxTAB_TRAVERSAL | wxNO_BORDER)); | |
78d14f80 VS |
97 | SetupWindow(panel); |
98 | return panel; | |
99 | } | |
100 | ||
101 | bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode *node) | |
102 | { | |
103 | return IsOfClass(node, wxT("unknown")); | |
104 | } | |
105 |