From cf4219e77adb387bd514b83e0c841f563b4016c6 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Wed, 29 Jul 1998 13:21:22 +0000 Subject: [PATCH] wxMDIChildFrame inherits from wxFrame toolbar work mini menubar change compile fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@399 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/docview.h | 3 -- include/wx/gtk/frame.h | 17 ++++++----- include/wx/gtk/mdi.h | 47 +++++++++++++++++++++-------- include/wx/gtk/tbargtk.h | 1 - include/wx/gtk1/frame.h | 17 ++++++----- include/wx/gtk1/mdi.h | 47 +++++++++++++++++++++-------- include/wx/gtk1/tbargtk.h | 1 - src/common/docview.cpp | 33 +------------------- src/common/log.cpp | 1 + src/gtk/frame.cpp | 13 ++++---- src/gtk/mdi.cpp | 62 ++++++++++---------------------------- src/gtk/menu.cpp | 2 +- src/gtk/tbargtk.cpp | 63 ++++++++++++++++++++++++++++----------- src/gtk1/frame.cpp | 13 ++++---- src/gtk1/mdi.cpp | 62 ++++++++++---------------------------- src/gtk1/menu.cpp | 2 +- src/gtk1/tbargtk.cpp | 63 ++++++++++++++++++++++++++++----------- 17 files changed, 226 insertions(+), 221 deletions(-) diff --git a/include/wx/docview.h b/include/wx/docview.h index 563e12a3d6..add8ef0e19 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -157,9 +157,6 @@ 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/frame.h b/include/wx/gtk/frame.h index 788761d769..2c64cb50ff 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -19,15 +19,17 @@ #include "wx/defs.h" #include "wx/object.h" #include "wx/window.h" -#include "wx/menu.h" -#include "wx/statusbr.h" -#include "wx/toolbar.h" //----------------------------------------------------------------------------- // classes //----------------------------------------------------------------------------- class wxMDIChildFrame; +class wxMDIClientWindow; +class wxMenu; +class wxMenuBar; +class wxToolBar; +class wxStatusBar; class wxFrame; @@ -36,6 +38,7 @@ class wxFrame; //----------------------------------------------------------------------------- extern const char *wxFrameNameStr; +extern const char *wxToolBarNameStr; //----------------------------------------------------------------------------- // wxFrame @@ -77,10 +80,10 @@ public: virtual void SetMenuBar( wxMenuBar *menuBar ); virtual wxMenuBar *GetMenuBar(); - void SetTitle( const wxString &title ); - wxString GetTitle() const { return m_title; } + virtual void SetTitle( const wxString &title ); + virtual wxString GetTitle() const { return m_title; } - void SetIcon( const wxIcon &icon ); + virtual void SetIcon( const wxIcon &icon ); void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp void OnSize( wxSizeEvent &event ); @@ -93,6 +96,7 @@ public: private: friend wxWindow; friend wxMDIChildFrame; + friend wxMDIClientWindow; // update frame's menus (called from OnIdle) void DoMenuUpdates(); @@ -103,7 +107,6 @@ private: wxStatusBar *m_frameStatusBar; wxToolBar *m_frameToolBar; int m_toolBarHeight; - bool m_doingOnSize; bool m_addPrivateChild; // for toolbar (and maybe menubar) wxString m_title; wxIcon m_icon; diff --git a/include/wx/gtk/mdi.h b/include/wx/gtk/mdi.h index e56d71cdf4..497f302e60 100644 --- a/include/wx/gtk/mdi.h +++ b/include/wx/gtk/mdi.h @@ -100,7 +100,7 @@ class wxMDIParentFrame: public wxFrame // wxMDIChildFrame //----------------------------------------------------------------------------- -class wxMDIChildFrame: public wxPanel +class wxMDIChildFrame: public wxFrame { DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) @@ -116,25 +116,46 @@ class wxMDIChildFrame: public wxPanel wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr ); - void SetMenuBar( wxMenuBar *menu_bar ); + + virtual void SetMenuBar( wxMenuBar *menu_bar ); + virtual wxMenuBar *GetMenuBar(); - // no status bars in wxGTK - virtual bool CreateStatusBar( int WXUNUSED(number) = 1 ) { return FALSE; }; - virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number) ) {}; - virtual void SetStatusWidths( int WXUNUSED(n), int *WXUNUSED(width) ) {}; + virtual void GetClientSize( int *width, int *height ) const; + virtual void AddChild( wxWindow *child ); - virtual void Maximize(void) {}; - virtual void Restore(void) {}; - virtual void Activate(void); + virtual void Activate(void); + + // no status bars + virtual wxStatusBar* CreateStatusBar( int WXUNUSED(number), long WXUNUSED(style), + wxWindowID WXUNUSED(id), const wxString& WXUNUSED(name) ) {return (wxStatusBar*)NULL; } + virtual wxStatusBar *GetStatusBar() { return (wxStatusBar*)NULL; } + virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number) ) {} + virtual void SetStatusWidths( int WXUNUSED(n), int *WXUNUSED(width) ) {} + + // no size hints + virtual void SetSizeHints( int WXUNUSED(minW), int WXUNUSED(minH), int WXUNUSED(maxW), + int WXUNUSED(maxH), int WXUNUSED(incW) ) {} + + // no toolbar bars + virtual wxToolBar* CreateToolBar( long WXUNUSED(style), wxWindowID WXUNUSED(id), + const wxString& WXUNUSED(name) ) { return (wxToolBar*)NULL; } + virtual wxToolBar *GetToolBar() { return (wxToolBar*)NULL; } + + // no icon + void SetIcon( const wxIcon &icon ) { m_icon = icon; } + + // no title + void SetTitle( const wxString &title ) { m_title = title; } + wxString GetTitle() const { return m_title; } + + // no maximize etc + virtual void Maximize(void) {} + virtual void Restore(void) {} - bool Destroy(void); - void OnCloseWindow( wxCloseEvent& event ); - void OnSize( wxSizeEvent &event ); void OnActivate( wxActivateEvent &event ); public: - wxString m_title; wxMenuBar *m_menuBar; // private: diff --git a/include/wx/gtk/tbargtk.h b/include/wx/gtk/tbargtk.h index 0c33e408b9..b398eb4520 100644 --- a/include/wx/gtk/tbargtk.h +++ b/include/wx/gtk/tbargtk.h @@ -117,7 +117,6 @@ class wxToolBar: public wxControl virtual void EnableTool(int toolIndex, bool enable); virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on - virtual void SetToggle(int toolIndex, bool toggle); // Set this to be togglable (or not) virtual wxObject *GetToolClientData(int index) const; virtual bool GetToolState(int toolIndex) const; diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h index 788761d769..2c64cb50ff 100644 --- a/include/wx/gtk1/frame.h +++ b/include/wx/gtk1/frame.h @@ -19,15 +19,17 @@ #include "wx/defs.h" #include "wx/object.h" #include "wx/window.h" -#include "wx/menu.h" -#include "wx/statusbr.h" -#include "wx/toolbar.h" //----------------------------------------------------------------------------- // classes //----------------------------------------------------------------------------- class wxMDIChildFrame; +class wxMDIClientWindow; +class wxMenu; +class wxMenuBar; +class wxToolBar; +class wxStatusBar; class wxFrame; @@ -36,6 +38,7 @@ class wxFrame; //----------------------------------------------------------------------------- extern const char *wxFrameNameStr; +extern const char *wxToolBarNameStr; //----------------------------------------------------------------------------- // wxFrame @@ -77,10 +80,10 @@ public: virtual void SetMenuBar( wxMenuBar *menuBar ); virtual wxMenuBar *GetMenuBar(); - void SetTitle( const wxString &title ); - wxString GetTitle() const { return m_title; } + virtual void SetTitle( const wxString &title ); + virtual wxString GetTitle() const { return m_title; } - void SetIcon( const wxIcon &icon ); + virtual void SetIcon( const wxIcon &icon ); void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp void OnSize( wxSizeEvent &event ); @@ -93,6 +96,7 @@ public: private: friend wxWindow; friend wxMDIChildFrame; + friend wxMDIClientWindow; // update frame's menus (called from OnIdle) void DoMenuUpdates(); @@ -103,7 +107,6 @@ private: wxStatusBar *m_frameStatusBar; wxToolBar *m_frameToolBar; int m_toolBarHeight; - bool m_doingOnSize; bool m_addPrivateChild; // for toolbar (and maybe menubar) wxString m_title; wxIcon m_icon; diff --git a/include/wx/gtk1/mdi.h b/include/wx/gtk1/mdi.h index e56d71cdf4..497f302e60 100644 --- a/include/wx/gtk1/mdi.h +++ b/include/wx/gtk1/mdi.h @@ -100,7 +100,7 @@ class wxMDIParentFrame: public wxFrame // wxMDIChildFrame //----------------------------------------------------------------------------- -class wxMDIChildFrame: public wxPanel +class wxMDIChildFrame: public wxFrame { DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) @@ -116,25 +116,46 @@ class wxMDIChildFrame: public wxPanel wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr ); - void SetMenuBar( wxMenuBar *menu_bar ); + + virtual void SetMenuBar( wxMenuBar *menu_bar ); + virtual wxMenuBar *GetMenuBar(); - // no status bars in wxGTK - virtual bool CreateStatusBar( int WXUNUSED(number) = 1 ) { return FALSE; }; - virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number) ) {}; - virtual void SetStatusWidths( int WXUNUSED(n), int *WXUNUSED(width) ) {}; + virtual void GetClientSize( int *width, int *height ) const; + virtual void AddChild( wxWindow *child ); - virtual void Maximize(void) {}; - virtual void Restore(void) {}; - virtual void Activate(void); + virtual void Activate(void); + + // no status bars + virtual wxStatusBar* CreateStatusBar( int WXUNUSED(number), long WXUNUSED(style), + wxWindowID WXUNUSED(id), const wxString& WXUNUSED(name) ) {return (wxStatusBar*)NULL; } + virtual wxStatusBar *GetStatusBar() { return (wxStatusBar*)NULL; } + virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number) ) {} + virtual void SetStatusWidths( int WXUNUSED(n), int *WXUNUSED(width) ) {} + + // no size hints + virtual void SetSizeHints( int WXUNUSED(minW), int WXUNUSED(minH), int WXUNUSED(maxW), + int WXUNUSED(maxH), int WXUNUSED(incW) ) {} + + // no toolbar bars + virtual wxToolBar* CreateToolBar( long WXUNUSED(style), wxWindowID WXUNUSED(id), + const wxString& WXUNUSED(name) ) { return (wxToolBar*)NULL; } + virtual wxToolBar *GetToolBar() { return (wxToolBar*)NULL; } + + // no icon + void SetIcon( const wxIcon &icon ) { m_icon = icon; } + + // no title + void SetTitle( const wxString &title ) { m_title = title; } + wxString GetTitle() const { return m_title; } + + // no maximize etc + virtual void Maximize(void) {} + virtual void Restore(void) {} - bool Destroy(void); - void OnCloseWindow( wxCloseEvent& event ); - void OnSize( wxSizeEvent &event ); void OnActivate( wxActivateEvent &event ); public: - wxString m_title; wxMenuBar *m_menuBar; // private: diff --git a/include/wx/gtk1/tbargtk.h b/include/wx/gtk1/tbargtk.h index 0c33e408b9..b398eb4520 100644 --- a/include/wx/gtk1/tbargtk.h +++ b/include/wx/gtk1/tbargtk.h @@ -117,7 +117,6 @@ class wxToolBar: public wxControl virtual void EnableTool(int toolIndex, bool enable); virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on - virtual void SetToggle(int toolIndex, bool toggle); // Set this to be togglable (or not) virtual wxObject *GetToolClientData(int index) const; virtual bool GetToolState(int toolIndex) const; diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 204c77fbb5..6f5aac75d9 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -486,38 +486,7 @@ void wxView::OnChangeFilename(void) wxString name; GetDocument()->GetPrintableName(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 - // 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; -#ifdef __WXGTK__ - if (GetFrame()->IsKindOf(CLASSINFO(wxMDIChildFrame))) - mdi_frame = (wxMDIChildFrame*)GetFrame(); - else -#endif - frame = GetFrame(); - - if (frame) - { - frame->SetTitle(name); - return; - } -#ifdef __WXGTK__ - if (mdi_frame) - { - if (wxTheApp->GetAppName() != "") - { - char buf[400]; - sprintf(buf, "%s - %s", (const char *)wxTheApp->GetAppName(), (const char *)name); - mdi_frame->SetTitle(buf); - } - else - mdi_frame->SetTitle(name); - } -#endif + GetFrame()->SetTitle(name); } } diff --git a/src/common/log.cpp b/src/common/log.cpp index 7c2552317c..447f2feda9 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -32,6 +32,7 @@ #include #include #include + #include #include #include diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 704c2e6500..5a39066f38 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -16,6 +16,9 @@ #include "wx/dialog.h" #include "wx/control.h" #include "wx/app.h" +#include "wx/menu.h" +#include "wx/toolbar.h" +#include "wx/statusbr.h" #include "wx/gtk/win_gtk.h" const wxMENU_HEIGHT = 28; @@ -74,12 +77,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow) wxFrame::wxFrame() { - m_doingOnSize = FALSE; m_frameMenuBar = NULL; m_frameStatusBar = NULL; m_frameToolBar = NULL; m_sizeSet = FALSE; m_addPrivateChild = FALSE; + m_wxwindow = NULL; + m_mainWindow = NULL; wxTopLevelWindows.Insert( this ); }; @@ -87,12 +91,13 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { - m_doingOnSize = FALSE; m_frameMenuBar = NULL; m_frameStatusBar = NULL; m_frameToolBar = NULL; m_sizeSet = FALSE; m_addPrivateChild = FALSE; + m_wxwindow = NULL; + m_mainWindow = NULL; Create( parent, id, title, pos, size, style, name ); wxTopLevelWindows.Insert( this ); }; @@ -102,13 +107,9 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, long style, const wxString &name ) { m_needParent = FALSE; - m_mainWindow = NULL; - m_wxwindow = NULL; PreCreation( parent, id, pos, size, style, name ); - m_doingOnSize = FALSE; - m_title = title; m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL ); diff --git a/src/gtk/mdi.cpp b/src/gtk/mdi.cpp index cf1408acdf..1d8c9ffb62 100644 --- a/src/gtk/mdi.cpp +++ b/src/gtk/mdi.cpp @@ -14,6 +14,7 @@ #include "wx/mdi.h" #include "wx/dialog.h" +#include "wx/menu.h" #include "wx/gtk/win_gtk.h" //----------------------------------------------------------------------------- @@ -171,11 +172,9 @@ void wxMDIParentFrame::OnSysColourChanged( wxSysColourChangedEvent& WXUNUSED(eve // wxMDIChildFrame //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxPanel) +IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxFrame) -BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel) - EVT_CLOSE(wxMDIChildFrame::OnCloseWindow) - EVT_SIZE(wxMDIChildFrame::OnSize) +BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame) EVT_ACTIVATE(wxMDIChildFrame::OnActivate) END_EVENT_TABLE() @@ -215,55 +214,19 @@ bool wxMDIChildFrame::Create( wxMDIParentFrame *parent, long style, const wxString& name ) { m_title = title; - return wxPanel::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name ); + return wxWindow::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name ); }; -void wxMDIChildFrame::OnCloseWindow( wxCloseEvent &event ) +void wxMDIChildFrame::GetClientSize( int *width, int *height ) const { - if ( GetEventHandler()->OnClose() || event.GetForce()) - { - this->Destroy(); - } -}; - -void wxMDIChildFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) -{ - if ( GetAutoLayout() ) - Layout(); - else { - // no child: go out ! - if (!GetChildren()->First()) - return; - - // do we have exactly one child? - wxWindow *child = NULL; - for(wxNode *node = GetChildren()->First(); node; node = node->Next()) - { - wxWindow *win = (wxWindow *)node->Data(); - if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)) - { - if ( child ) // it's the second one: do nothing - return; - - child = win; - }; - }; - - // yes: set it's size to fill all the frame - int client_x, client_y; - GetClientSize(&client_x, &client_y); - child->SetSize( 1, 1, client_x-2, client_y); - } -}; + wxWindow::GetClientSize( width, height ); +} -bool wxMDIChildFrame::Destroy(void) +void wxMDIChildFrame::AddChild( wxWindow *child ) { - if (!wxPendingDelete.Member(this)) - wxPendingDelete.Append(this); - - return TRUE; + wxWindow::AddChild( child ); } - + static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) { menu->SetInvokingWindow( win ); @@ -304,6 +267,11 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar ) } }; +wxMenuBar *wxMDIChildFrame::GetMenuBar() +{ + return m_menuBar; +}; + void wxMDIChildFrame::Activate(void) { }; diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 6b44b2f271..752968ab3f 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -154,7 +154,7 @@ void gtk_menu_clicked_callback( GtkWidget *widget, gpointer data ) event.SetEventObject( menu ); event.SetInt(id ); wxWindow *win = menu->GetInvokingWindow(); - if (win) win->ProcessEvent( event ); + if (win) win->GetEventHandler()->ProcessEvent( event ); }; IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject) diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index d33ae7d3ed..12dd7b66a7 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -106,17 +106,10 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id, bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown ) { - wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex ); - event.SetEventObject( this ); - event.SetInt( toolIndex ); - event.SetExtraLong( (long) toggleDown); - -/* - wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, toolIndex); + wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, toolIndex ); event.SetEventObject(this); event.SetInt( toolIndex ); event.SetExtraLong((long) toggleDown); -*/ GetEventHandler()->ProcessEvent(event); @@ -125,7 +118,7 @@ bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown ) void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) ) { - wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex ); + wxCommandEvent event( wxEVT_COMMAND_TOOL_RCLICKED, toolIndex ); event.SetEventObject( this ); event.SetInt( toolIndex ); @@ -134,7 +127,7 @@ void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y void wxToolBar::OnMouseEnter( int toolIndex ) { - wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, toolIndex); + wxCommandEvent event( wxEVT_COMMAND_TOOL_ENTER, toolIndex ); event.SetEventObject(this); event.SetInt( toolIndex ); @@ -177,6 +170,7 @@ void wxToolBar::AddSeparator(void) void wxToolBar::ClearTools(void) { + wxFAIL_MSG("wxToolBar::ClearTools not implemented"); }; void wxToolBar::Realize(void) @@ -204,37 +198,70 @@ void wxToolBar::Realize(void) void wxToolBar::EnableTool(int toolIndex, bool enable) { + wxNode *node = m_tools.First(); + while (node) + { + wxToolBarTool *tool = (wxToolBarTool*)node->Data(); + if (tool->m_index == toolIndex) + { + tool->m_enabled = enable; + return; + } + node = node->Next(); + }; }; -void wxToolBar::ToggleTool(int toolIndex, bool toggle) -{ -}; - -void wxToolBar::SetToggle(int toolIndex, bool toggle) +void wxToolBar::ToggleTool(int WXUNUSED(toolIndex), bool WXUNUSED(toggle) ) { + wxFAIL_MSG("wxToolBar::ToggleTool not implemented"); }; wxObject *wxToolBar::GetToolClientData(int index) const { + wxNode *node = m_tools.First(); + while (node) + { + wxToolBarTool *tool = (wxToolBarTool*)node->Data(); + if (tool->m_index == index) return tool->m_clientData;; + node = node->Next(); + }; + return (wxObject*)NULL; }; bool wxToolBar::GetToolState(int toolIndex) const { + wxNode *node = m_tools.First(); + while (node) + { + wxToolBarTool *tool = (wxToolBarTool*)node->Data(); + if (tool->m_index == toolIndex) return tool->m_toggleState; + node = node->Next(); + }; + return FALSE; }; bool wxToolBar::GetToolEnabled(int toolIndex) const { + wxNode *node = m_tools.First(); + while (node) + { + wxToolBarTool *tool = (wxToolBarTool*)node->Data(); + if (tool->m_index == toolIndex) return tool->m_enabled; + node = node->Next(); + }; + return FALSE; }; -void wxToolBar::SetMargins(int x, int y) +void wxToolBar::SetMargins( int WXUNUSED(x), int WXUNUSED(y) ) { }; -void wxToolBar::SetToolPacking(int packing) +void wxToolBar::SetToolPacking( int WXUNUSED(packing) ) { }; -void wxToolBar::SetToolSeparation(int separation) +void wxToolBar::SetToolSeparation( int separation ) { + gtk_toolbar_set_space_size( m_toolbar, separation ); }; diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 704c2e6500..5a39066f38 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -16,6 +16,9 @@ #include "wx/dialog.h" #include "wx/control.h" #include "wx/app.h" +#include "wx/menu.h" +#include "wx/toolbar.h" +#include "wx/statusbr.h" #include "wx/gtk/win_gtk.h" const wxMENU_HEIGHT = 28; @@ -74,12 +77,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow) wxFrame::wxFrame() { - m_doingOnSize = FALSE; m_frameMenuBar = NULL; m_frameStatusBar = NULL; m_frameToolBar = NULL; m_sizeSet = FALSE; m_addPrivateChild = FALSE; + m_wxwindow = NULL; + m_mainWindow = NULL; wxTopLevelWindows.Insert( this ); }; @@ -87,12 +91,13 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { - m_doingOnSize = FALSE; m_frameMenuBar = NULL; m_frameStatusBar = NULL; m_frameToolBar = NULL; m_sizeSet = FALSE; m_addPrivateChild = FALSE; + m_wxwindow = NULL; + m_mainWindow = NULL; Create( parent, id, title, pos, size, style, name ); wxTopLevelWindows.Insert( this ); }; @@ -102,13 +107,9 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, long style, const wxString &name ) { m_needParent = FALSE; - m_mainWindow = NULL; - m_wxwindow = NULL; PreCreation( parent, id, pos, size, style, name ); - m_doingOnSize = FALSE; - m_title = title; m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL ); diff --git a/src/gtk1/mdi.cpp b/src/gtk1/mdi.cpp index cf1408acdf..1d8c9ffb62 100644 --- a/src/gtk1/mdi.cpp +++ b/src/gtk1/mdi.cpp @@ -14,6 +14,7 @@ #include "wx/mdi.h" #include "wx/dialog.h" +#include "wx/menu.h" #include "wx/gtk/win_gtk.h" //----------------------------------------------------------------------------- @@ -171,11 +172,9 @@ void wxMDIParentFrame::OnSysColourChanged( wxSysColourChangedEvent& WXUNUSED(eve // wxMDIChildFrame //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxPanel) +IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxFrame) -BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel) - EVT_CLOSE(wxMDIChildFrame::OnCloseWindow) - EVT_SIZE(wxMDIChildFrame::OnSize) +BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame) EVT_ACTIVATE(wxMDIChildFrame::OnActivate) END_EVENT_TABLE() @@ -215,55 +214,19 @@ bool wxMDIChildFrame::Create( wxMDIParentFrame *parent, long style, const wxString& name ) { m_title = title; - return wxPanel::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name ); + return wxWindow::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name ); }; -void wxMDIChildFrame::OnCloseWindow( wxCloseEvent &event ) +void wxMDIChildFrame::GetClientSize( int *width, int *height ) const { - if ( GetEventHandler()->OnClose() || event.GetForce()) - { - this->Destroy(); - } -}; - -void wxMDIChildFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) -{ - if ( GetAutoLayout() ) - Layout(); - else { - // no child: go out ! - if (!GetChildren()->First()) - return; - - // do we have exactly one child? - wxWindow *child = NULL; - for(wxNode *node = GetChildren()->First(); node; node = node->Next()) - { - wxWindow *win = (wxWindow *)node->Data(); - if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)) - { - if ( child ) // it's the second one: do nothing - return; - - child = win; - }; - }; - - // yes: set it's size to fill all the frame - int client_x, client_y; - GetClientSize(&client_x, &client_y); - child->SetSize( 1, 1, client_x-2, client_y); - } -}; + wxWindow::GetClientSize( width, height ); +} -bool wxMDIChildFrame::Destroy(void) +void wxMDIChildFrame::AddChild( wxWindow *child ) { - if (!wxPendingDelete.Member(this)) - wxPendingDelete.Append(this); - - return TRUE; + wxWindow::AddChild( child ); } - + static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) { menu->SetInvokingWindow( win ); @@ -304,6 +267,11 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar ) } }; +wxMenuBar *wxMDIChildFrame::GetMenuBar() +{ + return m_menuBar; +}; + void wxMDIChildFrame::Activate(void) { }; diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 6b44b2f271..752968ab3f 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -154,7 +154,7 @@ void gtk_menu_clicked_callback( GtkWidget *widget, gpointer data ) event.SetEventObject( menu ); event.SetInt(id ); wxWindow *win = menu->GetInvokingWindow(); - if (win) win->ProcessEvent( event ); + if (win) win->GetEventHandler()->ProcessEvent( event ); }; IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject) diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp index d33ae7d3ed..12dd7b66a7 100644 --- a/src/gtk1/tbargtk.cpp +++ b/src/gtk1/tbargtk.cpp @@ -106,17 +106,10 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id, bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown ) { - wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex ); - event.SetEventObject( this ); - event.SetInt( toolIndex ); - event.SetExtraLong( (long) toggleDown); - -/* - wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, toolIndex); + wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, toolIndex ); event.SetEventObject(this); event.SetInt( toolIndex ); event.SetExtraLong((long) toggleDown); -*/ GetEventHandler()->ProcessEvent(event); @@ -125,7 +118,7 @@ bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown ) void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) ) { - wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex ); + wxCommandEvent event( wxEVT_COMMAND_TOOL_RCLICKED, toolIndex ); event.SetEventObject( this ); event.SetInt( toolIndex ); @@ -134,7 +127,7 @@ void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y void wxToolBar::OnMouseEnter( int toolIndex ) { - wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, toolIndex); + wxCommandEvent event( wxEVT_COMMAND_TOOL_ENTER, toolIndex ); event.SetEventObject(this); event.SetInt( toolIndex ); @@ -177,6 +170,7 @@ void wxToolBar::AddSeparator(void) void wxToolBar::ClearTools(void) { + wxFAIL_MSG("wxToolBar::ClearTools not implemented"); }; void wxToolBar::Realize(void) @@ -204,37 +198,70 @@ void wxToolBar::Realize(void) void wxToolBar::EnableTool(int toolIndex, bool enable) { + wxNode *node = m_tools.First(); + while (node) + { + wxToolBarTool *tool = (wxToolBarTool*)node->Data(); + if (tool->m_index == toolIndex) + { + tool->m_enabled = enable; + return; + } + node = node->Next(); + }; }; -void wxToolBar::ToggleTool(int toolIndex, bool toggle) -{ -}; - -void wxToolBar::SetToggle(int toolIndex, bool toggle) +void wxToolBar::ToggleTool(int WXUNUSED(toolIndex), bool WXUNUSED(toggle) ) { + wxFAIL_MSG("wxToolBar::ToggleTool not implemented"); }; wxObject *wxToolBar::GetToolClientData(int index) const { + wxNode *node = m_tools.First(); + while (node) + { + wxToolBarTool *tool = (wxToolBarTool*)node->Data(); + if (tool->m_index == index) return tool->m_clientData;; + node = node->Next(); + }; + return (wxObject*)NULL; }; bool wxToolBar::GetToolState(int toolIndex) const { + wxNode *node = m_tools.First(); + while (node) + { + wxToolBarTool *tool = (wxToolBarTool*)node->Data(); + if (tool->m_index == toolIndex) return tool->m_toggleState; + node = node->Next(); + }; + return FALSE; }; bool wxToolBar::GetToolEnabled(int toolIndex) const { + wxNode *node = m_tools.First(); + while (node) + { + wxToolBarTool *tool = (wxToolBarTool*)node->Data(); + if (tool->m_index == toolIndex) return tool->m_enabled; + node = node->Next(); + }; + return FALSE; }; -void wxToolBar::SetMargins(int x, int y) +void wxToolBar::SetMargins( int WXUNUSED(x), int WXUNUSED(y) ) { }; -void wxToolBar::SetToolPacking(int packing) +void wxToolBar::SetToolPacking( int WXUNUSED(packing) ) { }; -void wxToolBar::SetToolSeparation(int separation) +void wxToolBar::SetToolSeparation( int separation ) { + gtk_toolbar_set_space_size( m_toolbar, separation ); }; -- 2.45.2