XRC's unknown widget container handles removal of the widget now

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19909 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2003-03-31 22:02:15 +00:00
parent 973ac5bbb2
commit 5c451707f3
2 changed files with 20 additions and 6 deletions

View File

@ -36,13 +36,14 @@ public:
const wxSize& size = wxDefaultSize) const wxSize& size = wxDefaultSize)
: wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL | wxNO_BORDER, : wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL | wxNO_BORDER,
controlName + wxT("_container")), controlName + wxT("_container")),
m_controlName(controlName), m_controlAdded(FALSE) m_controlName(controlName), m_controlAdded(false)
{ {
m_bg = GetBackgroundColour(); m_bg = GetBackgroundColour();
SetBackgroundColour(wxColour(255, 0, 255)); SetBackgroundColour(wxColour(255, 0, 255));
} }
virtual void AddChild(wxWindowBase *child); virtual void AddChild(wxWindowBase *child);
virtual void RemoveChild(wxWindowBase *child);
protected: protected:
wxString m_controlName; wxString m_controlName;
@ -59,15 +60,21 @@ void wxUnknownControlContainer::AddChild(wxWindowBase *child)
SetBackgroundColour(m_bg); SetBackgroundColour(m_bg);
child->SetName(m_controlName); child->SetName(m_controlName);
child->SetId(wxXmlResource::GetXRCID(m_controlName)); child->SetId(wxXmlResource::GetXRCID(m_controlName));
m_controlAdded = TRUE; m_controlAdded = true;
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add((wxWindow*)child, 1, wxEXPAND); sizer->Add((wxWindow*)child, 1, wxEXPAND);
SetSizer(sizer); SetSizer(sizer);
SetAutoLayout(TRUE); SetAutoLayout(true);
Layout(); Layout();
} }
void wxUnknownControlContainer::RemoveChild(wxWindowBase *child)
{
wxPanel::RemoveChild(child);
m_controlAdded = false;
GetSizer()->Detach((wxWindow*)child);
}
wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler() wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler()

View File

@ -36,13 +36,14 @@ public:
const wxSize& size = wxDefaultSize) const wxSize& size = wxDefaultSize)
: wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL | wxNO_BORDER, : wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL | wxNO_BORDER,
controlName + wxT("_container")), controlName + wxT("_container")),
m_controlName(controlName), m_controlAdded(FALSE) m_controlName(controlName), m_controlAdded(false)
{ {
m_bg = GetBackgroundColour(); m_bg = GetBackgroundColour();
SetBackgroundColour(wxColour(255, 0, 255)); SetBackgroundColour(wxColour(255, 0, 255));
} }
virtual void AddChild(wxWindowBase *child); virtual void AddChild(wxWindowBase *child);
virtual void RemoveChild(wxWindowBase *child);
protected: protected:
wxString m_controlName; wxString m_controlName;
@ -59,15 +60,21 @@ void wxUnknownControlContainer::AddChild(wxWindowBase *child)
SetBackgroundColour(m_bg); SetBackgroundColour(m_bg);
child->SetName(m_controlName); child->SetName(m_controlName);
child->SetId(wxXmlResource::GetXRCID(m_controlName)); child->SetId(wxXmlResource::GetXRCID(m_controlName));
m_controlAdded = TRUE; m_controlAdded = true;
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add((wxWindow*)child, 1, wxEXPAND); sizer->Add((wxWindow*)child, 1, wxEXPAND);
SetSizer(sizer); SetSizer(sizer);
SetAutoLayout(TRUE); SetAutoLayout(true);
Layout(); Layout();
} }
void wxUnknownControlContainer::RemoveChild(wxWindowBase *child)
{
wxPanel::RemoveChild(child);
m_controlAdded = false;
GetSizer()->Detach((wxWindow*)child);
}
wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler() wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler()