From 9746a2ba50fdfa914e0476cb31710f9ccb5cc3cc Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 28 Jul 1998 22:08:36 +0000 Subject: [PATCH] Fixed bug in wxListCtrl Made wxMDIDocView work git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@391 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/docview.h | 3 +++ include/wx/gtk/mdi.h | 1 + include/wx/gtk1/mdi.h | 1 + samples/docvwmdi/docview.cpp | 2 +- samples/docvwmdi/docview.h | 2 +- samples/docvwmdi/view.cpp | 2 +- src/Makefile.in | 1 + src/common/docview.cpp | 30 +++++++++++++++++++----------- src/generic/listctrl.cpp | 1 + src/gtk/mdi.cpp | 6 ++++++ src/gtk1/mdi.cpp | 6 ++++++ 11 files changed, 41 insertions(+), 14 deletions(-) diff --git a/include/wx/docview.h b/include/wx/docview.h index add8ef0e19..563e12a3d6 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -157,6 +157,9 @@ class WXDLLEXPORT wxView: public wxEvtHandler inline wxFrame *GetFrame(void) const { return m_viewFrame ; } inline void SetFrame(wxFrame *frame) { m_viewFrame = frame; } +#ifdef __WXGTK__ + inline void SetFrame(wxMDIChildFrame *frame) { m_viewFrame = (wxFrame*)frame; } +#endif virtual void OnActivateView(bool activate, wxView *activeView, wxView *deactiveView); virtual void OnDraw(wxDC *dc) = 0; diff --git a/include/wx/gtk/mdi.h b/include/wx/gtk/mdi.h index b53e87c26f..e56d71cdf4 100644 --- a/include/wx/gtk/mdi.h +++ b/include/wx/gtk/mdi.h @@ -130,6 +130,7 @@ class wxMDIChildFrame: public wxPanel bool Destroy(void); void OnCloseWindow( wxCloseEvent& event ); void OnSize( wxSizeEvent &event ); + void OnActivate( wxActivateEvent &event ); public: diff --git a/include/wx/gtk1/mdi.h b/include/wx/gtk1/mdi.h index b53e87c26f..e56d71cdf4 100644 --- a/include/wx/gtk1/mdi.h +++ b/include/wx/gtk1/mdi.h @@ -130,6 +130,7 @@ class wxMDIChildFrame: public wxPanel bool Destroy(void); void OnCloseWindow( wxCloseEvent& event ); void OnSize( wxSizeEvent &event ); + void OnActivate( wxActivateEvent &event ); public: diff --git a/samples/docvwmdi/docview.cpp b/samples/docvwmdi/docview.cpp index b33ae584f7..90edcf6154 100644 --- a/samples/docvwmdi/docview.cpp +++ b/samples/docvwmdi/docview.cpp @@ -114,7 +114,7 @@ int MyApp::OnExit(void) * Called from view.cpp, when a view is created. */ -wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas) +wxMDIChildFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas) { //// Make a child frame wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame(doc, view, GetMainFrame(), -1, "Child Frame", diff --git a/samples/docvwmdi/docview.h b/samples/docvwmdi/docview.h index 30bc59fcff..9f9b695300 100644 --- a/samples/docvwmdi/docview.h +++ b/samples/docvwmdi/docview.h @@ -28,7 +28,7 @@ class MyApp: public wxApp bool OnInit(void); int OnExit(void); - wxFrame *CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas); + wxMDIChildFrame *CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas); protected: wxDocManager* m_docManager; diff --git a/samples/docvwmdi/view.cpp b/samples/docvwmdi/view.cpp index ea8b46df06..d943bb082b 100644 --- a/samples/docvwmdi/view.cpp +++ b/samples/docvwmdi/view.cpp @@ -113,7 +113,7 @@ bool DrawingView::OnClose(bool deleteWindow) if (frame) frame->SetTitle(s); - SetFrame(NULL); + SetFrame((wxFrame*)NULL); Activate(FALSE); diff --git a/src/Makefile.in b/src/Makefile.in index 2a0ce6cd7d..2f5985ebe5 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -30,6 +30,7 @@ LIB_CPP_SRC=\ common/cmndata.cpp \ common/config.cpp \ common/date.cpp \ + common/docmdi.cpp \ common/docview.cpp \ common/dynarray.cpp \ common/event.cpp \ diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 851c909b21..36f36611c0 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -34,6 +34,7 @@ #include "wx/menu.h" #include "wx/list.h" #include "wx/filedlg.h" +#include "wx/mdi.h" #endif #include "wx/msgdlg.h" @@ -482,27 +483,34 @@ void wxView::OnChangeFilename(void) wxString name; GetDocument()->GetPrintableName(name); - // If the frame is an MDI child, just set the title - // to the name. + // If the frame is an MDI child, just set the title to the name. // Otherwise, append the document name to the name of the application -#ifdef __WXMSW__ + // I have to do an illegal cast because in wxGTK, wxMDIChildFrame + // doesn't inherited from wxFrame, Robert Roebling + + wxFrame *frame = NULL; + wxMDIChildFrame *mdi_frame = NULL; if (GetFrame()->IsKindOf(CLASSINFO(wxMDIChildFrame))) -#else - if (FALSE) -#endif - { - GetFrame()->SetTitle(name); - } + mdi_frame = (wxMDIChildFrame*)GetFrame(); else + frame = GetFrame(); + + if (frame) + { + frame->SetTitle(name); + return; + } + + if (mdi_frame) { if (wxTheApp->GetAppName() != "") { char buf[400]; sprintf(buf, "%s - %s", (const char *)wxTheApp->GetAppName(), (const char *)name); - GetFrame()->SetTitle(buf); + mdi_frame->SetTitle(buf); } else - GetFrame()->SetTitle(name); + mdi_frame->SetTitle(name); } } } diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 8e158cfaed..03ffc62dd6 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -1755,6 +1755,7 @@ void wxListMainWindow::DeleteItem( long index ) if (node) { wxListLineData *line = (wxListLineData*)node->Data(); + if (m_current == line) m_current = NULL; DeleteLine( line ); m_lines.DeleteNode( node ); }; diff --git a/src/gtk/mdi.cpp b/src/gtk/mdi.cpp index ba49975d89..cf1408acdf 100644 --- a/src/gtk/mdi.cpp +++ b/src/gtk/mdi.cpp @@ -176,6 +176,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxPanel) BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel) EVT_CLOSE(wxMDIChildFrame::OnCloseWindow) EVT_SIZE(wxMDIChildFrame::OnSize) + EVT_ACTIVATE(wxMDIChildFrame::OnActivate) END_EVENT_TABLE() wxMDIChildFrame::wxMDIChildFrame(void) @@ -254,6 +255,7 @@ void wxMDIChildFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) child->SetSize( 1, 1, client_x-2, client_y); } }; + bool wxMDIChildFrame::Destroy(void) { if (!wxPendingDelete.Member(this)) @@ -306,6 +308,10 @@ void wxMDIChildFrame::Activate(void) { }; +void wxMDIChildFrame::OnActivate( wxActivateEvent &WXUNUSED(event) ) +{ +}; + //----------------------------------------------------------------------------- // wxMDIClientWindow //----------------------------------------------------------------------------- diff --git a/src/gtk1/mdi.cpp b/src/gtk1/mdi.cpp index ba49975d89..cf1408acdf 100644 --- a/src/gtk1/mdi.cpp +++ b/src/gtk1/mdi.cpp @@ -176,6 +176,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxPanel) BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel) EVT_CLOSE(wxMDIChildFrame::OnCloseWindow) EVT_SIZE(wxMDIChildFrame::OnSize) + EVT_ACTIVATE(wxMDIChildFrame::OnActivate) END_EVENT_TABLE() wxMDIChildFrame::wxMDIChildFrame(void) @@ -254,6 +255,7 @@ void wxMDIChildFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) child->SetSize( 1, 1, client_x-2, client_y); } }; + bool wxMDIChildFrame::Destroy(void) { if (!wxPendingDelete.Member(this)) @@ -306,6 +308,10 @@ void wxMDIChildFrame::Activate(void) { }; +void wxMDIChildFrame::OnActivate( wxActivateEvent &WXUNUSED(event) ) +{ +}; + //----------------------------------------------------------------------------- // wxMDIClientWindow //-----------------------------------------------------------------------------