]>
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, | |
36 | const wxSize& size = wxDefaultSize) | |
37 | : wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL | wxNO_BORDER, | |
38 | controlName + wxT("_container")), | |
cefd71d7 | 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); | |
cefd71d7 | 46 | |
78d14f80 VS |
47 | protected: |
48 | wxString m_controlName; | |
49 | bool m_controlAdded; | |
50 | wxColour m_bg; | |
51 | }; | |
52 | ||
53 | void wxUnknownControlContainer::AddChild(wxWindowBase *child) | |
54 | { | |
63fd5f0b | 55 | wxASSERT_MSG( !m_controlAdded, wxT("Couldn't add two unknown controls to the same container!") ); |
78d14f80 VS |
56 | |
57 | wxPanel::AddChild(child); | |
cefd71d7 | 58 | |
78d14f80 VS |
59 | SetBackgroundColour(m_bg); |
60 | child->SetName(m_controlName); | |
5ed345b7 | 61 | child->SetId(wxXmlResource::GetXRCID(m_controlName)); |
78d14f80 | 62 | m_controlAdded = TRUE; |
cefd71d7 | 63 | |
78d14f80 VS |
64 | wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); |
65 | sizer->Add((wxWindow*)child, 1, wxEXPAND); | |
66 | SetSizer(sizer); | |
67 | SetAutoLayout(TRUE); | |
68 | Layout(); | |
69 | } | |
70 | ||
71 | ||
72 | ||
cefd71d7 RD |
73 | wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler() |
74 | : wxXmlResourceHandler() | |
78d14f80 VS |
75 | { |
76 | } | |
77 | ||
78 | wxObject *wxUnknownWidgetXmlHandler::DoCreateResource() | |
cefd71d7 RD |
79 | { |
80 | wxPanel *panel = | |
78d14f80 VS |
81 | new wxUnknownControlContainer(m_parentAsWindow, |
82 | GetName(), -1, | |
83 | GetPosition(), GetSize()); | |
84 | SetupWindow(panel); | |
85 | return panel; | |
86 | } | |
87 | ||
88 | bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode *node) | |
89 | { | |
90 | return IsOfClass(node, wxT("unknown")); | |
91 | } | |
92 |