From 7c0ea335c7b1aa4ebd8b3a79dfb4be9fb20eefdb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 16 Nov 1999 21:31:40 +0000 Subject: [PATCH] wxFrameBase class for wxMSW and wxGTK git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4595 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- configure.in | 13 +- docs/changes.txt | 6 + docs/latex/wx/config.tex | 2 +- include/wx/frame.h | 210 +++++++++++++++++- include/wx/gtk/frame.h | 130 +++++------ include/wx/gtk1/frame.h | 130 +++++------ include/wx/msw/frame.h | 158 +++++-------- include/wx/msw/notebook.h | 5 +- include/wx/msw/tbar95.h | 20 +- include/wx/msw/tbarmsw.h | 20 ++ include/wx/toolbar.h | 6 - setup.h.in | 5 + src/common/framecmn.cpp | 403 ++++++++++++++++++++++++++++++--- src/generic/listctrl.cpp | 14 +- src/gtk/frame.cpp | 343 ++++++++-------------------- src/gtk/window.cpp | 2 +- src/gtk1/frame.cpp | 343 ++++++++-------------------- src/gtk1/window.cpp | 2 +- src/msw/frame.cpp | 455 +++++++++++++------------------------- src/msw/mdi.cpp | 10 +- src/msw/tbar95.cpp | 2 +- src/msw/tbarmsw.cpp | 2 +- 22 files changed, 1157 insertions(+), 1124 deletions(-) diff --git a/configure.in b/configure.in index 8bfa92bbae..a8f003d553 100644 --- a/configure.in +++ b/configure.in @@ -552,18 +552,7 @@ case "${host}" in DEFAULT_DEFAULT_wxUSE_MOTIF=1 ;; - *-*-cygwin32* ) - USE_UNIX=0 - USE_WIN32=1 - AC_DEFINE(__WIN32__) - AC_DEFINE(__WIN95__) - AC_DEFINE(__WINDOWS__) - AC_DEFINE(__GNUWIN32__) - AC_DEFINE(STRICT) - AC_DEFINE(WINVER, 0x0400) - DEFAULT_DEFAULT_wxUSE_MSW=1 - ;; - *-*-mingw32* ) + *-*-cygwin32* | *-*-mingw32* ) USE_UNIX=0 USE_WIN32=1 AC_DEFINE(__WIN32__) diff --git a/docs/changes.txt b/docs/changes.txt index 03c39362d1..79e3fb5937 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -9,6 +9,11 @@ all: - wxStopWatch class, timer functions have more chances to return correct results for your platform (use ANSI function where available) +- buffer overflows in wxString and wxLog classes fixed (if snprintf() function + is available) + +- wxArray::RemoveAt() replaces deprectaed wxArray::Remove(index) + wxMSW: - arbitrary controls (and not only buttons) can be put into a toolbar @@ -16,6 +21,7 @@ wxMSW: wxGTK: - wxFontMapper endless recursion bug (on some systems) fixed +- wxGTK synthesizes wxActivateEvents - you can use UpdateUI handlers with wxTextCtrl NOTE: for changes after wxWindows 2.1.0 b4, please see the CVS diff --git a/docs/latex/wx/config.tex b/docs/latex/wx/config.tex index 8275f459be..4f6b45925e 100644 --- a/docs/latex/wx/config.tex +++ b/docs/latex/wx/config.tex @@ -359,7 +359,7 @@ a local or global config file is created or used. If the flag is present but the parameter is empty, the parameter will be set to a default. If the parameter is present but the style flag not, the relevant flag will be added to the style. For wxFileConfig you can also add wxCONFIG\_USE\_RELATIVE\_PATH -by logicaly or'ing it to either of the _FILE options to tell wxFileConfig to +by logicaly or'ing it to either of the \_FILE options to tell wxFileConfig to use relative instead of absolute paths. } \wxheading{Remarks} diff --git a/include/wx/frame.h b/include/wx/frame.h index 89171ced45..831e122705 100644 --- a/include/wx/frame.h +++ b/include/wx/frame.h @@ -1,20 +1,216 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/frame.h +// Purpose: wxFrame class interface +// Author: Vadim Zeitlin +// Modified by: +// Created: 15.11.99 +// RCS-ID: $Id$ +// Copyright: (c) wxWindows team +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + #ifndef _WX_FRAME_H_BASE_ #define _WX_FRAME_H_BASE_ +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma interface "framebase.h" +#endif + +#include "wx/window.h" // the base class +#include "wx/icon.h" // for m_icon + +// the default names for various classs +WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr; + +class WXDLLEXPORT wxMenuBar; +class WXDLLEXPORT wxStatusBar; +class WXDLLEXPORT wxToolBar; + +// ---------------------------------------------------------------------------- +// wxFrame is a top-level window with optional menubar, statusbar and toolbar +// +// For each of *bars, a frame may have several of them, but only one is +// managed by the frame, i.e. resized/moved when the frame is and whose size +// is accounted for in client size calculations - all others should be taken +// care of manually. The CreateXXXBar() functions create this, main, XXXBar, +// but the actual creation is done in OnCreateXXXBar() functions which may be +// overridden to create custom objects instead of standard ones when +// CreateXXXBar() is called. +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxFrameBase : public wxWindow +{ +public: + // construction + wxFrameBase(); + + wxFrame *New(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr); + + // frame state + // ----------- + + // maximize = TRUE => maximize, otherwise - restore + virtual void Maximize(bool maximize = TRUE) = 0; + + // undo Maximize() or Iconize() + virtual void Restore() = 0; + + // iconize = TRUE => iconize, otherwise - restore + virtual void Iconize(bool iconize = TRUE) = 0; + + // return TRUE if the frame is maximized + virtual bool IsMaximized() const = 0; + + // return TRUE if the frame is iconized + virtual bool IsIconized() const = 0; + + // get the frame icon + const wxIcon& GetIcon() const { return m_icon; } + + // set the frame icon + virtual void SetIcon(const wxIcon& icon) { m_icon = icon; } + + // make the window modal (all other windows unresponsive) + virtual void MakeModal(bool modal = TRUE); + + // menu bar functions + // ------------------ + + virtual void SetMenuBar(wxMenuBar *menubar) = 0; + virtual wxMenuBar *GetMenuBar() const { return m_frameMenuBar; } + + // call this to simulate a menu command + bool Command(int id) { return ProcessCommand(id); } + + // process menu command: returns TRUE if processed + bool ProcessCommand(int id); + + // status bar functions + // -------------------- +#if wxUSE_STATUSBAR + // create the main status bar by calling OnCreateStatusBar() + virtual wxStatusBar* CreateStatusBar(int number = 1, + long style = wxST_SIZEGRIP, + wxWindowID id = 0, + const wxString& name = + wxStatusLineNameStr); + // return a new status bar + virtual wxStatusBar *OnCreateStatusBar(int number, + long style, + wxWindowID id, + const wxString& name); + // get the main status bar + virtual wxStatusBar *GetStatusBar() const { return m_frameStatusBar; } + + // sets the main status bar + void SetStatusBar(wxStatusBar *statBar) { m_frameStatusBar = statBar; } + + // forward these to status bar + virtual void SetStatusText(const wxString &text, int number = 0); + virtual void SetStatusWidths(int n, const int widths_field[]); +#endif // wxUSE_STATUSBAR + + // toolbar functions + // ----------------- +#if wxUSE_TOOLBAR + // create main toolbar bycalling OnCreateToolBar() + virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL, + wxWindowID id = -1, + const wxString& name = wxToolBarNameStr); + // return a new toolbar + virtual wxToolBar *OnCreateToolBar(long style, + wxWindowID id, + const wxString& name ); + + // get/set the main toolbar + virtual wxToolBar *GetToolBar() const { return m_frameToolBar; } + virtual void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; } +#endif // wxUSE_TOOLBAR + + // old functions, use the new ones instead! +#if WXWIN_COMPATIBILITY_2 + bool Iconized() const { return IsIconized(); } +#endif // WXWIN_COMPATIBILITY_2 + + // implementation only from now on + // ------------------------------- + + // override some base class virtuals + virtual bool Destroy(); + virtual bool IsTopLevel() const { return TRUE; } + + // event handlers + void OnIdle(wxIdleEvent& event); + void OnCloseWindow(wxCloseEvent& event); + void OnMenuHighlight(wxMenuEvent& event); + void OnSize(wxSizeEvent& event); + // this should go away, but for now it's called from docview.cpp, + // so should be there for all platforms + void OnActivate(wxActivateEvent &WXUNUSED(event)) { } + + // send wxUpdateUIEvents for all menu items (called from OnIdle()) + void DoMenuUpdates(); + void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin); + +protected: + // the frame main menu/status/tool bars + // ------------------------------------ + + // this (non virtual!) function should be called from dtor to delete the + // main menubar, statusbar and toolbar (if any) + void DeleteAllBars(); + + wxMenuBar *m_frameMenuBar; + +#if wxUSE_STATUSBAR + // override to update status bar position (or anything else) when + // something changes + virtual void PositionStatusBar() { } + + wxStatusBar *m_frameStatusBar; +#endif // wxUSE_STATUSBAR + +#if wxUSE_TOOLBAR + // override to update status bar position (or anything else) when + // something changes + virtual void PositionToolBar() { } + + wxToolBar *m_frameToolBar; +#endif // wxUSE_TOOLBAR + + // the frame icon + wxIcon m_icon; + + DECLARE_EVENT_TABLE() +}; + +// include the real class declaration #if defined(__WXMSW__) -#include "wx/msw/frame.h" + #include "wx/msw/frame.h" #elif defined(__WXMOTIF__) -#include "wx/motif/frame.h" + #include "wx/motif/frame.h" #elif defined(__WXGTK__) -#include "wx/gtk/frame.h" + #include "wx/gtk/frame.h" #elif defined(__WXQT__) -#include "wx/qt/frame.h" + #include "wx/qt/frame.h" #elif defined(__WXMAC__) -#include "wx/mac/frame.h" + #include "wx/mac/frame.h" #elif defined(__WXPM__) -#include "wx/os2/frame.h" + #include "wx/os2/frame.h" #elif defined(__WXSTUBS__) -#include "wx/stubs/frame.h" + #include "wx/stubs/frame.h" #endif #endif diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h index 1a3edac959..97cec7f13b 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: frame.h +// Name: wx/gtk/frame.h // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -12,14 +12,9 @@ #define __GTKFRAMEH__ #ifdef __GNUG__ -#pragma interface + #pragma interface "frame.h" #endif -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/window.h" -#include "wx/icon.h" - //----------------------------------------------------------------------------- // classes //----------------------------------------------------------------------------- @@ -33,98 +28,78 @@ class wxStatusBar; class wxFrame; -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -extern const wxChar *wxFrameNameStr; -extern const wxChar *wxToolBarNameStr; - //----------------------------------------------------------------------------- // wxFrame //----------------------------------------------------------------------------- -class wxFrame: public wxWindow +class wxFrame : public wxFrameBase { -DECLARE_DYNAMIC_CLASS(wxFrame) - public: + // construction wxFrame() { Init(); } - wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, const wxString &name = wxFrameNameStr ); - bool Create( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, const wxString &name = wxFrameNameStr ); - ~wxFrame(); - bool Destroy(); - - virtual bool Show( bool show ); - virtual void Centre( int direction = wxBOTH ); + wxFrame(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr) + { + Init(); + + Create(parent, id, title, pos, size, style, name); + } + + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr); + + virtual ~wxFrame(); + + // implement base class pure virtuals + virtual void Maximize(bool maximize = TRUE); + virtual bool IsMaximized() const; + virtual void Iconize(bool iconize = TRUE); + virtual bool IsIconized() const; + virtual void SetIcon(const wxIcon& icon); + virtual void MakeModal(bool modal = TRUE); + virtual void Restore(); + + virtual void SetMenuBar( wxMenuBar *menuBar ); #if wxUSE_STATUSBAR - virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, - const wxString& name = wxT("statusBar")); - virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id, - const wxString& name ); - virtual wxStatusBar *GetStatusBar() const; - inline void SetStatusBar(wxStatusBar *statusBar) { m_frameStatusBar = statusBar; } - virtual void SetStatusText( const wxString &text, int number = 0 ); - virtual void SetStatusWidths( int n, const int widths_field[] ); + virtual wxStatusBar* CreateStatusBar(int number = 1, + long style = wxST_SIZEGRIP, + wxWindowID id = 0, + const wxString& name = wxStatusLineNameStr); #endif // wxUSE_STATUSBAR #if wxUSE_TOOLBAR - virtual wxToolBar* CreateToolBar( long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, - const wxString& name = wxToolBarNameStr); - virtual wxToolBar *OnCreateToolBar( long style, wxWindowID id, const wxString& name ); - virtual wxToolBar *GetToolBar() const; + virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT, + wxWindowID id = -1, + const wxString& name = wxToolBarNameStr); void SetToolBar(wxToolBar *toolbar); #endif // wxUSE_TOOLBAR - virtual void SetMenuBar( wxMenuBar *menuBar ); - virtual wxMenuBar *GetMenuBar() const; + virtual bool Show(bool show); virtual void SetTitle( const wxString &title ); virtual wxString GetTitle() const { return m_title; } - // make the window modal (all other windows unresponsive) - virtual void MakeModal(bool modal = TRUE); - - virtual void SetIcon( const wxIcon &icon ); - bool Iconized() const { return IsIconized(); } - virtual void Maximize( bool maximize ); - virtual void Restore(); - virtual void Iconize( bool iconize ); - virtual bool IsIconized() const; - - virtual bool IsTopLevel() const { return TRUE; } - - virtual void Command( int id ); - - void OnCloseWindow( wxCloseEvent& event ); - void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp - void OnSize( wxSizeEvent &event ); - void OnIdle( wxIdleEvent &event ); - - void OnMenuHighlight( wxMenuEvent& event ); - - // implementation + // implementation from now on + // -------------------------- + // GTK callbacks virtual void GtkOnSize( int x, int y, int width, int height ); - void DoMenuUpdates(); - void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin); virtual void OnInternalIdle(); - wxMenuBar *m_frameMenuBar; -#if wxUSE_STATUSBAR - wxStatusBar *m_frameStatusBar; -#endif -#if wxUSE_TOOLBAR - wxToolBar *m_frameToolBar; -#endif wxString m_title; - wxIcon m_icon; - int m_miniEdge,m_miniTitle; + int m_miniEdge, + m_miniTitle; GtkWidget *m_mainWidget; bool m_menuBarDetached; bool m_toolBarDetached; @@ -133,7 +108,8 @@ public: protected: // common part of all ctors void Init(); - + + // override wxWindow methods to take into account tool/menu/statusbars virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); @@ -142,7 +118,7 @@ protected: virtual void DoGetClientSize( int *width, int *height ) const; private: - DECLARE_EVENT_TABLE() + DECLARE_DYNAMIC_CLASS(wxFrame) }; #endif // __GTKFRAMEH__ diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h index 1a3edac959..97cec7f13b 100644 --- a/include/wx/gtk1/frame.h +++ b/include/wx/gtk1/frame.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: frame.h +// Name: wx/gtk/frame.h // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -12,14 +12,9 @@ #define __GTKFRAMEH__ #ifdef __GNUG__ -#pragma interface + #pragma interface "frame.h" #endif -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/window.h" -#include "wx/icon.h" - //----------------------------------------------------------------------------- // classes //----------------------------------------------------------------------------- @@ -33,98 +28,78 @@ class wxStatusBar; class wxFrame; -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -extern const wxChar *wxFrameNameStr; -extern const wxChar *wxToolBarNameStr; - //----------------------------------------------------------------------------- // wxFrame //----------------------------------------------------------------------------- -class wxFrame: public wxWindow +class wxFrame : public wxFrameBase { -DECLARE_DYNAMIC_CLASS(wxFrame) - public: + // construction wxFrame() { Init(); } - wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, const wxString &name = wxFrameNameStr ); - bool Create( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, const wxString &name = wxFrameNameStr ); - ~wxFrame(); - bool Destroy(); - - virtual bool Show( bool show ); - virtual void Centre( int direction = wxBOTH ); + wxFrame(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr) + { + Init(); + + Create(parent, id, title, pos, size, style, name); + } + + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr); + + virtual ~wxFrame(); + + // implement base class pure virtuals + virtual void Maximize(bool maximize = TRUE); + virtual bool IsMaximized() const; + virtual void Iconize(bool iconize = TRUE); + virtual bool IsIconized() const; + virtual void SetIcon(const wxIcon& icon); + virtual void MakeModal(bool modal = TRUE); + virtual void Restore(); + + virtual void SetMenuBar( wxMenuBar *menuBar ); #if wxUSE_STATUSBAR - virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, - const wxString& name = wxT("statusBar")); - virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id, - const wxString& name ); - virtual wxStatusBar *GetStatusBar() const; - inline void SetStatusBar(wxStatusBar *statusBar) { m_frameStatusBar = statusBar; } - virtual void SetStatusText( const wxString &text, int number = 0 ); - virtual void SetStatusWidths( int n, const int widths_field[] ); + virtual wxStatusBar* CreateStatusBar(int number = 1, + long style = wxST_SIZEGRIP, + wxWindowID id = 0, + const wxString& name = wxStatusLineNameStr); #endif // wxUSE_STATUSBAR #if wxUSE_TOOLBAR - virtual wxToolBar* CreateToolBar( long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, - const wxString& name = wxToolBarNameStr); - virtual wxToolBar *OnCreateToolBar( long style, wxWindowID id, const wxString& name ); - virtual wxToolBar *GetToolBar() const; + virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT, + wxWindowID id = -1, + const wxString& name = wxToolBarNameStr); void SetToolBar(wxToolBar *toolbar); #endif // wxUSE_TOOLBAR - virtual void SetMenuBar( wxMenuBar *menuBar ); - virtual wxMenuBar *GetMenuBar() const; + virtual bool Show(bool show); virtual void SetTitle( const wxString &title ); virtual wxString GetTitle() const { return m_title; } - // make the window modal (all other windows unresponsive) - virtual void MakeModal(bool modal = TRUE); - - virtual void SetIcon( const wxIcon &icon ); - bool Iconized() const { return IsIconized(); } - virtual void Maximize( bool maximize ); - virtual void Restore(); - virtual void Iconize( bool iconize ); - virtual bool IsIconized() const; - - virtual bool IsTopLevel() const { return TRUE; } - - virtual void Command( int id ); - - void OnCloseWindow( wxCloseEvent& event ); - void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp - void OnSize( wxSizeEvent &event ); - void OnIdle( wxIdleEvent &event ); - - void OnMenuHighlight( wxMenuEvent& event ); - - // implementation + // implementation from now on + // -------------------------- + // GTK callbacks virtual void GtkOnSize( int x, int y, int width, int height ); - void DoMenuUpdates(); - void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin); virtual void OnInternalIdle(); - wxMenuBar *m_frameMenuBar; -#if wxUSE_STATUSBAR - wxStatusBar *m_frameStatusBar; -#endif -#if wxUSE_TOOLBAR - wxToolBar *m_frameToolBar; -#endif wxString m_title; - wxIcon m_icon; - int m_miniEdge,m_miniTitle; + int m_miniEdge, + m_miniTitle; GtkWidget *m_mainWidget; bool m_menuBarDetached; bool m_toolBarDetached; @@ -133,7 +108,8 @@ public: protected: // common part of all ctors void Init(); - + + // override wxWindow methods to take into account tool/menu/statusbars virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); @@ -142,7 +118,7 @@ protected: virtual void DoGetClientSize( int *width, int *height ) const; private: - DECLARE_EVENT_TABLE() + DECLARE_DYNAMIC_CLASS(wxFrame) }; #endif // __GTKFRAMEH__ diff --git a/include/wx/msw/frame.h b/include/wx/msw/frame.h index 0a328f9440..81f12ec2bc 100644 --- a/include/wx/msw/frame.h +++ b/include/wx/msw/frame.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: frame.h +// Name: wx/msw/frame.h // Purpose: wxFrame class // Author: Julian Smart // Modified by: @@ -16,37 +16,24 @@ #pragma interface "frame.h" #endif -#include "wx/window.h" -#include "wx/toolbar.h" -#include "wx/msw/accel.h" -#include "wx/icon.h" - -WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr; -WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr; -WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr; - -class WXDLLEXPORT wxMenuBar; -class WXDLLEXPORT wxStatusBar; - -class WXDLLEXPORT wxFrame : public wxWindow +class WXDLLEXPORT wxFrame : public wxFrameBase { - DECLARE_DYNAMIC_CLASS(wxFrame) - public: - wxFrame(); + // construction + wxFrame() { Init(); } wxFrame(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr) { + Init(); + Create(parent, id, title, pos, size, style, name); } - ~wxFrame(); - bool Create(wxWindow *parent, wxWindowID id, const wxString& title, @@ -55,32 +42,26 @@ public: long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr); - virtual bool Destroy(); - - void OnSize(wxSizeEvent& event); - void OnMenuHighlight(wxMenuEvent& event); - void OnActivate(wxActivateEvent& event); - void OnIdle(wxIdleEvent& event); - void OnCloseWindow(wxCloseEvent& event); - - bool Show(bool show); - - void DetachMenuBar(); - // Set menu bar - void SetMenuBar(wxMenuBar *menu_bar); - virtual wxMenuBar *GetMenuBar() const; + virtual ~wxFrame(); - // Call this to simulate a menu command - bool Command(int id) { return ProcessCommand(id); } + // implement base class pure virtuals + virtual void Maximize(bool maximize = TRUE); + virtual bool IsMaximized() const; + virtual void Iconize(bool iconize = TRUE); + virtual bool IsIconized() const; + virtual void Restore(); + virtual void SetMenuBar(wxMenuBar *menubar); + virtual void SetIcon(const wxIcon& icon); - // process menu command: returns TRUE if processed - bool ProcessCommand(int id); + // implementation only from now on + // ------------------------------- - // make the window modal (all other windows unresponsive) - virtual void MakeModal(bool modal = TRUE); + // override some more virtuals + virtual bool Show(bool show = TRUE); - // Set icon - virtual void SetIcon(const wxIcon& icon); + // event handlers + void OnActivate(wxActivateEvent& event); + void OnSysColourChanged(wxSysColourChangedEvent& event); // Toolbar #if wxUSE_TOOLBAR @@ -88,73 +69,36 @@ public: wxWindowID id = -1, const wxString& name = wxToolBarNameStr); - virtual wxToolBar *OnCreateToolBar(long style, wxWindowID id, const wxString& name); - - virtual void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; } - virtual wxToolBar *GetToolBar() const { return m_frameToolBar; } - virtual void PositionToolBar(); #endif // wxUSE_TOOLBAR -#if wxUSE_STATUSBAR // Status bar - virtual wxStatusBar* CreateStatusBar(int number = 1, - long style = wxST_SIZEGRIP, - wxWindowID id = 0, - const wxString& name = wxStatusLineNameStr); - - wxStatusBar *GetStatusBar() const { return m_frameStatusBar; } - void SetStatusBar(wxStatusBar *statusBar) { m_frameStatusBar = statusBar; } +#if wxUSE_STATUSBAR + virtual wxStatusBar* OnCreateStatusBar(int number = 1, + long style = wxST_SIZEGRIP, + wxWindowID id = 0, + const wxString& name = wxStatusLineNameStr); virtual void PositionStatusBar(); - virtual wxStatusBar *OnCreateStatusBar(int number, - long style, - wxWindowID id, - const wxString& name); - - // Set status line text - virtual void SetStatusText(const wxString& text, int number = 0); - // Set status line widths - virtual void SetStatusWidths(int n, const int widths_field[]); + // Hint to tell framework which status bar to use: the default is to use + // native one for the platforms which support it (Win32), the generic one + // otherwise - // Hint to tell framework which status bar to use // TODO: should this go into a wxFrameworkSettings class perhaps? - static void UseNativeStatusBar(bool useNative) { m_useNativeStatusBar = useNative; }; - static bool UsesNativeStatusBar() { return m_useNativeStatusBar; }; + static void UseNativeStatusBar(bool useNative) + { m_useNativeStatusBar = useNative; }; + static bool UsesNativeStatusBar() + { return m_useNativeStatusBar; }; #endif // wxUSE_STATUSBAR - // Iconize - virtual void Iconize(bool iconize); - - virtual bool IsIconized() const; - - // Is it maximized? - virtual bool IsMaximized() const; - - // Compatibility - bool Iconized() const { return IsIconized(); } - - virtual bool IsTopLevel() const { return TRUE; } - - virtual void Maximize(bool maximize); - // virtual bool LoadAccelerators(const wxString& table); - - // Responds to colour changes - void OnSysColourChanged(wxSysColourChangedEvent& event); - - // Query app for menu item updates (called from OnIdle) - void DoMenuUpdates(); - void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin); - WXHMENU GetWinMenu() const { return m_hMenu; } // Returns the origin of client area (may be different from (0,0) if the // frame has a toolbar) virtual wxPoint GetClientAreaOrigin() const; - // Implementation only from here - // event handlers + // event handlers bool HandlePaint(); bool HandleSize(int x, int y, WXUINT flag); bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); @@ -164,13 +108,19 @@ public: wxWindow *wx_win, const wxChar *title, int x, int y, int width, int height, long style); - // tooltip management + // tooltip management #if wxUSE_TOOLTIPS WXHWND GetToolTipCtrl() const { return m_hwndToolTip; } void SetToolTipCtrl(WXHWND hwndTT) { m_hwndToolTip = hwndTT; } #endif // tooltips protected: + // common part of all ctors + void Init(); + + // common part of Iconize(), Maximize() and Restore() + void DoShowWindow(int nShowCmd); + // override base class virtuals virtual void DoGetClientSize(int *width, int *height) const; virtual void DoGetSize(int *width, int *height) const; @@ -181,6 +131,9 @@ protected: virtual void DoClientToScreen(int *x, int *y) const; virtual void DoScreenToClient(int *x, int *y) const; + // helper + void DetachMenuBar(); + // a plug in for MDI frame classes which need to do something special when // the menubar is set virtual void InternalSetMenuBar(); @@ -194,27 +147,20 @@ protected: // window proc for the frames long MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); - wxMenuBar * m_frameMenuBar; - wxIcon m_icon; bool m_iconized; WXHICON m_defaultIcon; #if wxUSE_STATUSBAR - wxStatusBar * m_frameStatusBar; - static bool m_useNativeStatusBar; #endif // wxUSE_STATUSBAR -#if wxUSE_TOOLBAR - wxToolBar * m_frameToolBar; -#endif // wxUSE_TOOLBAR - private: #if wxUSE_TOOLTIPS WXHWND m_hwndToolTip; #endif // tooltips DECLARE_EVENT_TABLE() + DECLARE_DYNAMIC_CLASS(wxFrame) }; #endif diff --git a/include/wx/msw/notebook.h b/include/wx/msw/notebook.h index 8b94e5ce8f..7ac0e7945b 100644 --- a/include/wx/msw/notebook.h +++ b/include/wx/msw/notebook.h @@ -19,9 +19,8 @@ // headers // ---------------------------------------------------------------------------- -#ifndef _DYNARRAY_H - #include -#endif //_DYNARRAY_H +#include "wx/control.h" +#include "wx/dynarray.h" // ---------------------------------------------------------------------------- // types diff --git a/include/wx/msw/tbar95.h b/include/wx/msw/tbar95.h index 19d1093b3c..d137c39693 100644 --- a/include/wx/msw/tbar95.h +++ b/include/wx/msw/tbar95.h @@ -88,7 +88,25 @@ protected: WXHBITMAP m_hBitmap; DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxToolBar95) +}; + +class WXDLLEXPORT wxToolBar : public wxToolBar95 +{ +public: + wxToolBar() { } + + wxToolBar(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxNO_BORDER | wxTB_HORIZONTAL, + const wxString& name = wxToolBarNameStr) + : wxToolBar95(parent, id, pos, size, style, name) + { + } + +private: + DECLARE_DYNAMIC_CLASS(wxToolBar) }; #endif // wxUSE_TOOLBAR diff --git a/include/wx/msw/tbarmsw.h b/include/wx/msw/tbarmsw.h index accd6148a7..75fe842966 100644 --- a/include/wx/msw/tbarmsw.h +++ b/include/wx/msw/tbarmsw.h @@ -119,6 +119,26 @@ DECLARE_EVENT_TABLE() #define wxTBSTATE_HIDDEN 0x08 // button is hidden #define wxTBSTATE_INDETERMINATE 0x10 // button is indeterminate +class WXDLLEXPORT wxToolBar : public wxToolBarMSW +{ +public: + wxToolBar() { } + + wxToolBar(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxNO_BORDER | wxTB_HORIZONTAL, + const wxString& name = wxToolBarNameStr) + : wxToolBarMSW(parent, id, pos, size, style, name) + { + } + +private: + DECLARE_DYNAMIC_CLASS(wxToolBar) +}; + #endif // wxUSE_TOOL/BUTTONBAR + #endif // _WX_TBARMSW_H_ diff --git a/include/wx/toolbar.h b/include/wx/toolbar.h index 7dad6add56..47911912d2 100644 --- a/include/wx/toolbar.h +++ b/include/wx/toolbar.h @@ -1,16 +1,10 @@ #ifndef _TOOLBAR_H_BASE_ #define _TOOLBAR_H_BASE_ -// the application code should use only wxToolBar which is #define'd to be the -// native implementation for each platform #if defined(__WXMSW__) && defined(__WIN95__) # include "wx/msw/tbar95.h" -# define wxToolBar wxToolBar95 -# define sm_classwxToolBar sm_classwxToolBar95 #elif defined(__WXMSW__) # include "wx/msw/tbarmsw.h" -# define wxToolBar wxToolBarMSW -# define sm_classwxToolBar sm_classwxToolBarMSW #elif defined(__WXMOTIF__) # include "wx/motif/toolbar.h" #elif defined(__WXGTK__) diff --git a/setup.h.in b/setup.h.in index c939e24c0f..6436ddd2d1 100644 --- a/setup.h.in +++ b/setup.h.in @@ -94,6 +94,11 @@ #undef STRICT #undef WINVER +/* enable native status bar under Win32 */ +#ifdef __WIN95__ +#define wxUSE_NATIVE_STATUSBAR 1 +#endif + /* * Supports bool type */ diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index af39670bd7..a1c9575cfa 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: framecmn.cpp +// Name: common/framecmn.cpp // Purpose: common (for all platforms) wxFrame functions // Author: Julian Smart, Vadim Zeitlin // Created: 01/02/97 @@ -8,28 +8,369 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "framebase.h" +#endif + // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif #include "wx/frame.h" #include "wx/menu.h" #include "wx/menuitem.h" +#include "wx/dcclient.h" + +#if wxUSE_TOOLBAR + #include "wx/toolbar.h" +#endif +#if wxUSE_STATUSBAR + #include "wx/statusbr.h" +#endif + +// ---------------------------------------------------------------------------- +// event table +// ---------------------------------------------------------------------------- + +BEGIN_EVENT_TABLE(wxFrameBase, wxWindow) + EVT_IDLE(wxFrameBase::OnIdle) + EVT_CLOSE(wxFrameBase::OnCloseWindow) + EVT_MENU_HIGHLIGHT_ALL(wxFrameBase::OnMenuHighlight) + EVT_SIZE(wxFrameBase::OnSize) +END_EVENT_TABLE() + +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// construction/destruction +// ---------------------------------------------------------------------------- + +wxFrameBase::wxFrameBase() +{ + m_frameMenuBar = NULL; + +#if wxUSE_TOOLBAR + m_frameToolBar = NULL; +#endif // wxUSE_TOOLBAR + +#if wxUSE_STATUSBAR + m_frameStatusBar = NULL; +#endif // wxUSE_STATUSBAR +} + +bool wxFrameBase::Destroy() +{ + // delayed destruction: the frame will be deleted during the next idle + // loop iteration + if ( !wxPendingDelete.Member(this) ) + wxPendingDelete.Append(this); + + return TRUE; +} + +wxFrame *wxFrameBase::New(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + return new wxFrame(parent, id, title, pos, size, style, name); +} + +void wxFrameBase::DeleteAllBars() +{ + if ( m_frameMenuBar ) + { + delete m_frameMenuBar; + m_frameMenuBar = (wxMenuBar *) NULL; + } + +#if wxUSE_STATUSBAR + if ( m_frameStatusBar ) + { + delete m_frameStatusBar; + m_frameStatusBar = (wxStatusBar *) NULL; + } +#endif // wxUSE_STATUSBAR + +#if wxUSE_TOOLBAR + if ( m_frameToolBar ) + { + delete m_frameToolBar; + m_frameToolBar = (wxToolBar *) NULL; + } +#endif // wxUSE_TOOLBAR +} + +// ---------------------------------------------------------------------------- +// misc +// ---------------------------------------------------------------------------- + +// make the window modal (all other windows unresponsive) +void wxFrameBase::MakeModal(bool modal) +{ + if ( modal ) + { + wxEnableTopLevelWindows(FALSE); + Enable(TRUE); // keep this window enabled + } + else + { + wxEnableTopLevelWindows(TRUE); + } +} + +bool wxFrameBase::ProcessCommand(int id) +{ + wxMenuBar *bar = GetMenuBar(); + if ( !bar ) + return FALSE; + + wxMenuItem *item = bar->FindItem(id); + if ( item && item->IsCheckable() ) + { + item->Toggle(); + } + + wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id); + commandEvent.SetInt(id); + commandEvent.SetEventObject(this); + + return GetEventHandler()->ProcessEvent(commandEvent); +} + +// ---------------------------------------------------------------------------- +// event handlers +// ---------------------------------------------------------------------------- + +// default resizing behaviour - if only ONE subwindow, resize to fill the +// whole client area +void wxFrameBase::OnSize(wxSizeEvent& event) +{ + // if we're using constraints - do use them +#if wxUSE_CONSTRAINTS + if ( GetAutoLayout() ) + { + Layout(); + } + else +#endif + { + // do we have _exactly_ one child? + wxWindow *child = (wxWindow *)NULL; + for ( wxWindowList::Node *node = GetChildren().GetFirst(); + node; + node = node->GetNext() ) + { + wxWindow *win = node->GetData(); + + // exclude top level and managed windows (status bar isn't + // currently in the children list except under wxMac anyhow, but + // it makes no harm to test for it) + if ( !win->IsTopLevel() +#if wxUSE_STATUSBAR + && (win != GetStatusBar()) +#endif // wxUSE_STATUSBAR +#if wxUSE_TOOLBAR + && (win != GetToolBar()) +#endif // wxUSE_TOOLBAR + ) + { + if ( child ) + { + return; // it's our second subwindow - nothing to do + } + + child = win; + } + } -void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) ) + // do we have any children at all? + if ( child ) + { + // exactly one child - set it's size to fill the whole frame + int clientW, clientH; + DoGetClientSize(&clientW, &clientH); + + // for whatever reasons, wxGTK wants to have a small offset - it + // probably looks better with it? +#ifdef __WXGTK__ + static const int ofs = 0; +#else + static const int ofs = 1; +#endif + + child->SetSize(ofs, ofs, clientW - 2*ofs, clientH - 2*ofs); + } + } +} + +// The default implementation for the close window event. +void wxFrameBase::OnCloseWindow(wxCloseEvent& event) +{ + Destroy(); +} + +void wxFrameBase::OnMenuHighlight(wxMenuEvent& event) +{ +#if wxUSE_STATUSBAR + if ( GetStatusBar() ) + { + // if no help string found, we will clear the status bar text + wxString helpString; + + int menuId = event.GetMenuId(); + if ( menuId != wxID_SEPARATOR && menuId != -2 /* wxID_TITLE */ ) + { + wxMenuBar *menuBar = GetMenuBar(); + if ( menuBar ) + { + // it's ok if we don't find the item because it might belong + // to the popup menu + wxMenuItem *item = menuBar->FindItem(menuId); + if ( item ) + helpString = item->GetHelp(); + } + } + + // set status text even if the string is empty - this will at least + // remove the string from the item which was previously selected + SetStatusText(helpString); + } +#endif // wxUSE_STATUSBAR +} + +// ---------------------------------------------------------------------------- +// status bar stuff +// ---------------------------------------------------------------------------- + +#if wxUSE_STATUSBAR + +wxStatusBar* wxFrameBase::CreateStatusBar(int number, + long style, + wxWindowID id, + const wxString& name) +{ + // the main status bar can only be created once (or else it should be + // deleted before calling CreateStatusBar() again) + wxCHECK_MSG( !m_frameStatusBar, (wxStatusBar *)NULL, + wxT("recreating status bar in wxFrame") ); + + m_frameStatusBar = OnCreateStatusBar( number, style, id, name ); + if ( m_frameStatusBar ) + PositionStatusBar(); + + return m_frameStatusBar; +} + +wxStatusBar *wxFrameBase::OnCreateStatusBar(int number, + long style, + wxWindowID id, + const wxString& name) +{ + wxStatusBar *statusBar = new wxStatusBar(this, id, + wxPoint(0, 0), wxSize(100, 20), + style, name); + + // Set the height according to the font and the border size + wxClientDC dc(statusBar); + dc.SetFont(statusBar->GetFont()); + + long y; + dc.GetTextExtent( "X", NULL, &y ); + + int height = (int)( (11*y)/10 + 2*statusBar->GetBorderY()); + + statusBar->SetSize( -1, -1, 100, height ); + + statusBar->SetFieldsCount(number); + + return statusBar; +} + +void wxFrameBase::SetStatusText(const wxString& text, int number) +{ + wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); + + wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") ); + + m_frameStatusBar->SetStatusText(text, number); +} + +void wxFrameBase::SetStatusWidths(int n, const int widths_field[] ) +{ + wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); + + wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set widths for") ); + + m_frameStatusBar->SetStatusWidths(n, widths_field); + + PositionStatusBar(); +} + +#endif // wxUSE_STATUSBAR + +// ---------------------------------------------------------------------------- +// toolbar stuff +// ---------------------------------------------------------------------------- + +#if wxUSE_TOOLBAR + +wxToolBar* wxFrameBase::CreateToolBar(long style, + wxWindowID id, + const wxString& name) +{ + // the main toolbar can't be recreated (unless it was explicitly deeleted + // before) + wxCHECK_MSG( !m_frameToolBar, (wxToolBar *)NULL, + wxT("recreating toolbar in wxFrame") ); + + m_frameToolBar = OnCreateToolBar(style, id, name); + + return m_frameToolBar; +} + +wxToolBar* wxFrameBase::OnCreateToolBar(long style, + wxWindowID id, + const wxString& name) +{ + return new wxToolBar(this, id, + wxDefaultPosition, wxDefaultSize, + style, name); +} + +#endif // wxUSE_TOOLBAR + +// ---------------------------------------------------------------------------- +// Menu UI updating +// ---------------------------------------------------------------------------- + +void wxFrameBase::OnIdle(wxIdleEvent& WXUNUSED(event) ) { DoMenuUpdates(); } // update all menus -void wxFrame::DoMenuUpdates() +void wxFrameBase::DoMenuUpdates() { wxMenuBar* bar = GetMenuBar(); - if ( bar != NULL ) + if ( bar != NULL ) { int nCount = bar->GetMenuCount(); for (int n = 0; n < nCount; n++) @@ -38,32 +379,32 @@ void wxFrame::DoMenuUpdates() } // update a menu and all submenus recursively -void wxFrame::DoMenuUpdates(wxMenu* menu, wxWindow* WXUNUSED(focusWin)) -{ - wxEvtHandler* evtHandler = GetEventHandler(); - wxMenuItemList::Node* node = menu->GetMenuItems().GetFirst(); - while (node) - { - wxMenuItem* item = node->GetData(); - if ( !item->IsSeparator() ) +void wxFrameBase::DoMenuUpdates(wxMenu* menu, wxWindow* WXUNUSED(focusWin)) +{ + wxEvtHandler* evtHandler = GetEventHandler(); + wxMenuItemList::Node* node = menu->GetMenuItems().GetFirst(); + while (node) { - wxWindowID id = item->GetId(); - wxUpdateUIEvent event(id); - event.SetEventObject( this ); - - if (evtHandler->ProcessEvent(event)) - { - if (event.GetSetText()) - menu->SetLabel(id, event.GetText()); - if (event.GetSetChecked()) - menu->Check(id, event.GetChecked()); - if (event.GetSetEnabled()) - menu->Enable(id, event.GetEnabled()); - } - - if (item->GetSubMenu()) - DoMenuUpdates(item->GetSubMenu(), (wxWindow*) NULL); + wxMenuItem* item = node->GetData(); + if ( !item->IsSeparator() ) + { + wxWindowID id = item->GetId(); + wxUpdateUIEvent event(id); + event.SetEventObject( this ); + + if (evtHandler->ProcessEvent(event)) + { + if (event.GetSetText()) + menu->SetLabel(id, event.GetText()); + if (event.GetSetChecked()) + menu->Check(id, event.GetChecked()); + if (event.GetSetEnabled()) + menu->Enable(id, event.GetEnabled()); + } + + if (item->GetSubMenu()) + DoMenuUpdates(item->GetSubMenu(), (wxWindow*) NULL); + } + node = node->GetNext(); } - node = node->GetNext(); - } } diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index a23b73b1c3..03d8c7f610 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -2164,8 +2164,8 @@ void wxListMainWindow::CalculatePositions() int y = 1; int entireHeight = m_lines.Number() * lineSpacing + 2; int scroll_pos = GetScrollPos( wxVERTICAL ); - int x_scroll_pos = GetScrollPos( wxHORIZONTAL ); #if wxUSE_GENERIC_LIST_EXTENSIONS + int x_scroll_pos = GetScrollPos( wxHORIZONTAL ); #else SetScrollbars( m_xScroll, m_yScroll, 0, (entireHeight+15) / m_yScroll, 0, scroll_pos, TRUE ); #endif @@ -2312,18 +2312,22 @@ void wxListMainWindow::DeleteAllItems( void ) { m_dirty = TRUE; m_current = (wxListLineData *) NULL; + + // to make the deletion of all items faster, we don't send the + // notifications in this case: this is compatible with wxMSW and + // documented in DeleteAllItems() description +#if 0 wxNode *node = m_lines.First(); while (node) { wxListLineData *line = (wxListLineData*)node->Data(); - // to make the deletion of all items faster, we don't send the - // notifications in this case: this is compatible with wxMSW and - // documented in DeleteAllItems() description - //DeleteLine( line ); + DeleteLine( line ); node = node->Next(); } +#endif // 0 + m_lines.Clear(); } diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 6d2f51781d..751e7631cb 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -7,6 +7,14 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + #ifdef __GNUG__ #pragma implementation "frame.h" #endif @@ -17,10 +25,10 @@ #include "wx/app.h" #include "wx/menu.h" #if wxUSE_TOOLBAR -#include "wx/toolbar.h" + #include "wx/toolbar.h" #endif #if wxUSE_STATUSBAR -#include "wx/statusbr.h" + #include "wx/statusbr.h" #endif #include "wx/dcclient.h" @@ -31,31 +39,37 @@ #include "gdk/gdkkeysyms.h" #include "gdk/gdkx.h" -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- // constants -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- const int wxMENU_HEIGHT = 27; const int wxSTATUS_HEIGHT = 25; const int wxPLACE_HOLDER = 0; -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- // idle system -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- extern void wxapp_install_idle_handler(); extern bool g_isIdle; extern int g_openDialogs; -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- +// event tables +// ---------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow) + +// ---------------------------------------------------------------------------- // data -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- extern wxList wxPendingDelete; -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- // debug -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- #ifdef __WXDEBUG__ @@ -63,6 +77,14 @@ extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar #endif +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// GTK callbacks +// ---------------------------------------------------------------------------- + //----------------------------------------------------------------------------- // "focus" from m_window //----------------------------------------------------------------------------- @@ -190,9 +212,9 @@ gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *ev if (g_isIdle) wxapp_install_idle_handler(); - if (!win->m_hasVMT) + if (!win->m_hasVMT) return FALSE; - + #if (GTK_MINOR_VERSION > 0) int x = 0; int y = 0; @@ -280,10 +302,11 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) } /* reset the icon */ - if (win->m_icon != wxNullIcon) + wxIcon iconOld = win->GetIcon(); + if ( iconOld != wxNullIcon ) { - wxIcon icon( win->m_icon ); - win->m_icon = wxNullIcon; + wxIcon icon( iconOld ); + win->SetIcon( wxNullIcon ); win->SetIcon( icon ); } @@ -305,6 +328,10 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) return FALSE; } +// ---------------------------------------------------------------------------- +// wxFrame itself +// ---------------------------------------------------------------------------- + //----------------------------------------------------------------------------- // InsertChild for wxFrame //----------------------------------------------------------------------------- @@ -361,28 +388,12 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) parent->UpdateSize(); } -//----------------------------------------------------------------------------- -// wxFrame -//----------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxFrame, wxWindow) - EVT_SIZE(wxFrame::OnSize) - EVT_IDLE(wxFrame::OnIdle) - EVT_CLOSE(wxFrame::OnCloseWindow) - EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) -END_EVENT_TABLE() - -IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow) +// ---------------------------------------------------------------------------- +// wxFrame creation +// ---------------------------------------------------------------------------- void wxFrame::Init() { - m_frameMenuBar = (wxMenuBar *) NULL; -#if wxUSE_STATUSBAR - m_frameStatusBar = (wxStatusBar *) NULL; -#endif // wxUSE_STATUSBAR -#if wxUSE_TOOLBAR - m_frameToolBar = (wxToolBar *) NULL; -#endif // wxUSE_TOOLBAR m_sizeSet = FALSE; m_miniEdge = 0; m_miniTitle = 0; @@ -393,18 +404,13 @@ void wxFrame::Init() m_isFrame = TRUE; } -wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) -{ - Init(); - - Create( parent, id, title, pos, size, style, name ); -} - -bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) +bool wxFrame::Create( wxWindow *parent, + wxWindowID id, + const wxString &title, + const wxPoint &pos, + const wxSize &size, + long style, + const wxString &name ) { wxTopLevelWindows.Append( this ); @@ -490,18 +496,7 @@ wxFrame::~wxFrame() { m_isBeingDeleted = TRUE; - if (m_frameMenuBar) delete m_frameMenuBar; - m_frameMenuBar = (wxMenuBar *) NULL; - -#if wxUSE_STATUSBAR - if (m_frameStatusBar) delete m_frameStatusBar; - m_frameStatusBar = (wxStatusBar *) NULL; -#endif // wxUSE_STATUSBAR - -#if wxUSE_TOOLBAR - if (m_frameToolBar) delete m_frameToolBar; - m_frameToolBar = (wxToolBar *) NULL; -#endif // wxUSE_TOOLBAR + DeleteAllBars(); wxTopLevelWindows.DeleteObject( this ); @@ -512,6 +507,10 @@ wxFrame::~wxFrame() wxTheApp->ExitMainLoop(); } +// ---------------------------------------------------------------------------- +// overridden wxWindow methods +// ---------------------------------------------------------------------------- + bool wxFrame::Show( bool show ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); @@ -529,15 +528,6 @@ bool wxFrame::Show( bool show ) return wxWindow::Show( show ); } -bool wxFrame::Destroy() -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); - - return TRUE; -} - void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); @@ -546,7 +536,8 @@ void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags ) wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); /* avoid recursions */ - if (m_resizing) return; + if (m_resizing) + return; m_resizing = TRUE; int old_x = m_x; @@ -606,19 +597,6 @@ void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags ) m_resizing = FALSE; } -void wxFrame::Centre( int direction ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - int x = 0; - int y = 0; - - if ((direction & wxHORIZONTAL) == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2; - if ((direction & wxVERTICAL) == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2; - - Move( x, y ); -} - void wxFrame::DoGetClientSize( int *width, int *height ) const { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); @@ -700,7 +678,8 @@ void wxFrame::DoSetClientSize( int width, int height ) DoSetSize( -1, -1, width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0 ); } -void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) +void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), + int width, int height ) { // due to a bug in gtk, x,y are always 0 // m_x = x; @@ -810,15 +789,14 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height m_frameStatusBar->m_width = ww; m_frameStatusBar->m_height = hh; gtk_pizza_set_size( GTK_PIZZA(m_wxwindow), - m_frameStatusBar->m_widget, - xx, yy, ww, hh ); + m_frameStatusBar->m_widget, + xx, yy, ww, hh ); } #endif /* we actually set the size of a frame here and no-where else */ gtk_widget_set_usize( m_widget, m_width, m_height ); - m_sizeSet = TRUE; // send size event to frame @@ -868,50 +846,9 @@ void wxFrame::OnInternalIdle() wxWindow::OnInternalIdle(); } -void wxFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) ) -{ - Destroy(); -} - -void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - -#if wxUSE_CONSTRAINTS - if (GetAutoLayout()) - { - Layout(); - } - else -#endif // wxUSE_CONSTRAINTS - { - /* do we have exactly one child? */ - wxWindow *child = (wxWindow *)NULL; - for ( wxNode *node = GetChildren().First(); node; node = node->Next() ) - { - wxWindow *win = (wxWindow *)node->Data(); - if ( !wxIS_KIND_OF(win,wxFrame) && !wxIS_KIND_OF(win,wxDialog) ) - { - if (child) - { - /* it's the second one: do nothing */ - return; - } - - child = win; - } - } - - /* no children at all? */ - if (child) - { - /* yes: set it's size to fill all the frame */ - int client_x, client_y; - DoGetClientSize( &client_x, &client_y ); - child->SetSize( 1, 1, client_x-2, client_y-2 ); - } - } -} +// ---------------------------------------------------------------------------- +// menu/tool/status bar stuff +// ---------------------------------------------------------------------------- void wxFrame::SetMenuBar( wxMenuBar *menuBar ) { @@ -951,50 +888,17 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar ) m_sizeSet = FALSE; } -wxMenuBar *wxFrame::GetMenuBar() const -{ - return m_frameMenuBar; -} - -void wxFrame::OnMenuHighlight(wxMenuEvent& event) -{ -#if wxUSE_STATUSBAR - if (GetStatusBar()) - { - // if no help string found, we will clear the status bar text - wxString helpString; - - int menuId = event.GetMenuId(); - if ( menuId != wxID_SEPARATOR && menuId != -2 /* wxID_TITLE */ ) - { - wxMenuBar *menuBar = GetMenuBar(); - if ( menuBar ) - { - // it's ok if we don't find the item because it might belong to - // the popup menu - wxMenuItem *item = menuBar->FindItem(menuId); - if ( item ) - helpString = item->GetHelp(); - } - } - - SetStatusText(helpString); - } -#endif // wxUSE_STATUSBAR -} - #if wxUSE_TOOLBAR wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - wxCHECK_MSG( m_frameToolBar == NULL, FALSE, wxT("recreating toolbar in wxFrame") ); - m_insertInClientArea = FALSE; - m_frameToolBar = OnCreateToolBar( style, id, name ); + m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name ); - if (m_frameToolBar) GetChildren().DeleteObject( m_frameToolBar ); + if (m_frameToolBar) + GetChildren().DeleteObject( m_frameToolBar ); m_insertInClientArea = TRUE; @@ -1003,14 +907,10 @@ wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& na return m_frameToolBar; } -wxToolBar* wxFrame::OnCreateToolBar( long style, wxWindowID id, const wxString& name ) -{ - return new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name ); -} - void wxFrame::SetToolBar(wxToolBar *toolbar) { - m_frameToolBar = toolbar; + wxFrameBase::SetToolBar(toolbar); + if (m_frameToolBar) { /* insert into toolbar area if not already there */ @@ -1025,97 +925,34 @@ void wxFrame::SetToolBar(wxToolBar *toolbar) } } -wxToolBar *wxFrame::GetToolBar() const -{ - return m_frameToolBar; -} #endif // wxUSE_TOOLBAR #if wxUSE_STATUSBAR -wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, wxT("recreating status bar in wxFrame") ); - - m_frameStatusBar = OnCreateStatusBar( number, style, id, name ); - - m_sizeSet = FALSE; - return m_frameStatusBar; -} - -wxStatusBar *wxFrame::OnCreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) -{ - wxStatusBar *statusBar = (wxStatusBar *) NULL; - - statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20), style, name); - - // Set the height according to the font and the border size - wxClientDC dc(statusBar); - dc.SetFont( statusBar->GetFont() ); - - long x, y; - dc.GetTextExtent( "X", &x, &y ); - - int height = (int)( (y * 1.1) + 2* statusBar->GetBorderY()); - - statusBar->SetSize( -1, -1, 100, height ); - - statusBar->SetFieldsCount( number ); - return statusBar; -} - -wxStatusBar *wxFrame::GetStatusBar() const -{ - return m_frameStatusBar; -} - -void wxFrame::SetStatusText(const wxString& text, int number) +wxStatusBar* wxFrame::CreateStatusBar(int number, + long style, + wxWindowID id, + const wxString& name) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") ); + // because it will change when toolbar is added + m_sizeSet = FALSE; - m_frameStatusBar->SetStatusText(text, number); + return wxFrameBase::CreateStatusBar( number, style, id, name ); } -void wxFrame::SetStatusWidths(int n, const int widths_field[] ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set widths for") ); - - m_frameStatusBar->SetStatusWidths(n, widths_field); -} #endif // wxUSE_STATUSBAR -void wxFrame::Command( int id ) -{ - wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id); - commandEvent.SetInt( id ); - commandEvent.SetEventObject( this ); - - wxMenuBar *bar = GetMenuBar(); - if (!bar) return; - - wxMenuItem *item = bar->FindItem(id) ; - if (item && item->IsCheckable()) - { - bar->Check(id, !bar->IsChecked(id)) ; - } - - wxEvtHandler* evtHandler = GetEventHandler(); - - evtHandler->ProcessEvent(commandEvent); -} +// ---------------------------------------------------------------------------- +// frame title/icon +// ---------------------------------------------------------------------------- void wxFrame::SetTitle( const wxString &title ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); m_title = title; - if (m_title.IsNull()) m_title = wxT(""); gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); } @@ -1123,10 +960,13 @@ void wxFrame::SetIcon( const wxIcon &icon ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - m_icon = icon; - if (!icon.Ok()) return; + wxFrameBase::SetIcon(icon); - if (!m_widget->window) return; + if ( !m_icon.Ok() ) + return; + + if (!m_widget->window) + return; wxMask *mask = icon.GetMask(); GdkBitmap *bm = (GdkBitmap *) NULL; @@ -1135,10 +975,19 @@ void wxFrame::SetIcon( const wxIcon &icon ) gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); } +// ---------------------------------------------------------------------------- +// frame state: maximized/iconized/normal (TODO) +// ---------------------------------------------------------------------------- + void wxFrame::Maximize(bool WXUNUSED(maximize)) { } +bool wxFrame::IsMaximized() const +{ + return FALSE; +} + void wxFrame::Restore() { } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 312ecb5854..57b5dfc22d 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -185,7 +185,7 @@ extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnScroll; extern wxCursor g_globalCursor; static wxWindow *g_captureWindow = (wxWindow*) NULL; -static wxWindow *g_focusWindow = (wxWindow*) NULL; +extern wxWindow *g_focusWindow = (wxWindow*) NULL; // if we detect that the app has got/lost the focus, we set this variable to // either TRUE or FALSE and an activate event will be sent during the next diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 6d2f51781d..751e7631cb 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -7,6 +7,14 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + #ifdef __GNUG__ #pragma implementation "frame.h" #endif @@ -17,10 +25,10 @@ #include "wx/app.h" #include "wx/menu.h" #if wxUSE_TOOLBAR -#include "wx/toolbar.h" + #include "wx/toolbar.h" #endif #if wxUSE_STATUSBAR -#include "wx/statusbr.h" + #include "wx/statusbr.h" #endif #include "wx/dcclient.h" @@ -31,31 +39,37 @@ #include "gdk/gdkkeysyms.h" #include "gdk/gdkx.h" -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- // constants -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- const int wxMENU_HEIGHT = 27; const int wxSTATUS_HEIGHT = 25; const int wxPLACE_HOLDER = 0; -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- // idle system -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- extern void wxapp_install_idle_handler(); extern bool g_isIdle; extern int g_openDialogs; -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- +// event tables +// ---------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow) + +// ---------------------------------------------------------------------------- // data -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- extern wxList wxPendingDelete; -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- // debug -//----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- #ifdef __WXDEBUG__ @@ -63,6 +77,14 @@ extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar #endif +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// GTK callbacks +// ---------------------------------------------------------------------------- + //----------------------------------------------------------------------------- // "focus" from m_window //----------------------------------------------------------------------------- @@ -190,9 +212,9 @@ gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *ev if (g_isIdle) wxapp_install_idle_handler(); - if (!win->m_hasVMT) + if (!win->m_hasVMT) return FALSE; - + #if (GTK_MINOR_VERSION > 0) int x = 0; int y = 0; @@ -280,10 +302,11 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) } /* reset the icon */ - if (win->m_icon != wxNullIcon) + wxIcon iconOld = win->GetIcon(); + if ( iconOld != wxNullIcon ) { - wxIcon icon( win->m_icon ); - win->m_icon = wxNullIcon; + wxIcon icon( iconOld ); + win->SetIcon( wxNullIcon ); win->SetIcon( icon ); } @@ -305,6 +328,10 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) return FALSE; } +// ---------------------------------------------------------------------------- +// wxFrame itself +// ---------------------------------------------------------------------------- + //----------------------------------------------------------------------------- // InsertChild for wxFrame //----------------------------------------------------------------------------- @@ -361,28 +388,12 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) parent->UpdateSize(); } -//----------------------------------------------------------------------------- -// wxFrame -//----------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxFrame, wxWindow) - EVT_SIZE(wxFrame::OnSize) - EVT_IDLE(wxFrame::OnIdle) - EVT_CLOSE(wxFrame::OnCloseWindow) - EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) -END_EVENT_TABLE() - -IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow) +// ---------------------------------------------------------------------------- +// wxFrame creation +// ---------------------------------------------------------------------------- void wxFrame::Init() { - m_frameMenuBar = (wxMenuBar *) NULL; -#if wxUSE_STATUSBAR - m_frameStatusBar = (wxStatusBar *) NULL; -#endif // wxUSE_STATUSBAR -#if wxUSE_TOOLBAR - m_frameToolBar = (wxToolBar *) NULL; -#endif // wxUSE_TOOLBAR m_sizeSet = FALSE; m_miniEdge = 0; m_miniTitle = 0; @@ -393,18 +404,13 @@ void wxFrame::Init() m_isFrame = TRUE; } -wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) -{ - Init(); - - Create( parent, id, title, pos, size, style, name ); -} - -bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) +bool wxFrame::Create( wxWindow *parent, + wxWindowID id, + const wxString &title, + const wxPoint &pos, + const wxSize &size, + long style, + const wxString &name ) { wxTopLevelWindows.Append( this ); @@ -490,18 +496,7 @@ wxFrame::~wxFrame() { m_isBeingDeleted = TRUE; - if (m_frameMenuBar) delete m_frameMenuBar; - m_frameMenuBar = (wxMenuBar *) NULL; - -#if wxUSE_STATUSBAR - if (m_frameStatusBar) delete m_frameStatusBar; - m_frameStatusBar = (wxStatusBar *) NULL; -#endif // wxUSE_STATUSBAR - -#if wxUSE_TOOLBAR - if (m_frameToolBar) delete m_frameToolBar; - m_frameToolBar = (wxToolBar *) NULL; -#endif // wxUSE_TOOLBAR + DeleteAllBars(); wxTopLevelWindows.DeleteObject( this ); @@ -512,6 +507,10 @@ wxFrame::~wxFrame() wxTheApp->ExitMainLoop(); } +// ---------------------------------------------------------------------------- +// overridden wxWindow methods +// ---------------------------------------------------------------------------- + bool wxFrame::Show( bool show ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); @@ -529,15 +528,6 @@ bool wxFrame::Show( bool show ) return wxWindow::Show( show ); } -bool wxFrame::Destroy() -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); - - return TRUE; -} - void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); @@ -546,7 +536,8 @@ void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags ) wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); /* avoid recursions */ - if (m_resizing) return; + if (m_resizing) + return; m_resizing = TRUE; int old_x = m_x; @@ -606,19 +597,6 @@ void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags ) m_resizing = FALSE; } -void wxFrame::Centre( int direction ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - int x = 0; - int y = 0; - - if ((direction & wxHORIZONTAL) == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2; - if ((direction & wxVERTICAL) == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2; - - Move( x, y ); -} - void wxFrame::DoGetClientSize( int *width, int *height ) const { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); @@ -700,7 +678,8 @@ void wxFrame::DoSetClientSize( int width, int height ) DoSetSize( -1, -1, width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0 ); } -void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) +void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), + int width, int height ) { // due to a bug in gtk, x,y are always 0 // m_x = x; @@ -810,15 +789,14 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height m_frameStatusBar->m_width = ww; m_frameStatusBar->m_height = hh; gtk_pizza_set_size( GTK_PIZZA(m_wxwindow), - m_frameStatusBar->m_widget, - xx, yy, ww, hh ); + m_frameStatusBar->m_widget, + xx, yy, ww, hh ); } #endif /* we actually set the size of a frame here and no-where else */ gtk_widget_set_usize( m_widget, m_width, m_height ); - m_sizeSet = TRUE; // send size event to frame @@ -868,50 +846,9 @@ void wxFrame::OnInternalIdle() wxWindow::OnInternalIdle(); } -void wxFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) ) -{ - Destroy(); -} - -void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - -#if wxUSE_CONSTRAINTS - if (GetAutoLayout()) - { - Layout(); - } - else -#endif // wxUSE_CONSTRAINTS - { - /* do we have exactly one child? */ - wxWindow *child = (wxWindow *)NULL; - for ( wxNode *node = GetChildren().First(); node; node = node->Next() ) - { - wxWindow *win = (wxWindow *)node->Data(); - if ( !wxIS_KIND_OF(win,wxFrame) && !wxIS_KIND_OF(win,wxDialog) ) - { - if (child) - { - /* it's the second one: do nothing */ - return; - } - - child = win; - } - } - - /* no children at all? */ - if (child) - { - /* yes: set it's size to fill all the frame */ - int client_x, client_y; - DoGetClientSize( &client_x, &client_y ); - child->SetSize( 1, 1, client_x-2, client_y-2 ); - } - } -} +// ---------------------------------------------------------------------------- +// menu/tool/status bar stuff +// ---------------------------------------------------------------------------- void wxFrame::SetMenuBar( wxMenuBar *menuBar ) { @@ -951,50 +888,17 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar ) m_sizeSet = FALSE; } -wxMenuBar *wxFrame::GetMenuBar() const -{ - return m_frameMenuBar; -} - -void wxFrame::OnMenuHighlight(wxMenuEvent& event) -{ -#if wxUSE_STATUSBAR - if (GetStatusBar()) - { - // if no help string found, we will clear the status bar text - wxString helpString; - - int menuId = event.GetMenuId(); - if ( menuId != wxID_SEPARATOR && menuId != -2 /* wxID_TITLE */ ) - { - wxMenuBar *menuBar = GetMenuBar(); - if ( menuBar ) - { - // it's ok if we don't find the item because it might belong to - // the popup menu - wxMenuItem *item = menuBar->FindItem(menuId); - if ( item ) - helpString = item->GetHelp(); - } - } - - SetStatusText(helpString); - } -#endif // wxUSE_STATUSBAR -} - #if wxUSE_TOOLBAR wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - wxCHECK_MSG( m_frameToolBar == NULL, FALSE, wxT("recreating toolbar in wxFrame") ); - m_insertInClientArea = FALSE; - m_frameToolBar = OnCreateToolBar( style, id, name ); + m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name ); - if (m_frameToolBar) GetChildren().DeleteObject( m_frameToolBar ); + if (m_frameToolBar) + GetChildren().DeleteObject( m_frameToolBar ); m_insertInClientArea = TRUE; @@ -1003,14 +907,10 @@ wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& na return m_frameToolBar; } -wxToolBar* wxFrame::OnCreateToolBar( long style, wxWindowID id, const wxString& name ) -{ - return new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name ); -} - void wxFrame::SetToolBar(wxToolBar *toolbar) { - m_frameToolBar = toolbar; + wxFrameBase::SetToolBar(toolbar); + if (m_frameToolBar) { /* insert into toolbar area if not already there */ @@ -1025,97 +925,34 @@ void wxFrame::SetToolBar(wxToolBar *toolbar) } } -wxToolBar *wxFrame::GetToolBar() const -{ - return m_frameToolBar; -} #endif // wxUSE_TOOLBAR #if wxUSE_STATUSBAR -wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, wxT("recreating status bar in wxFrame") ); - - m_frameStatusBar = OnCreateStatusBar( number, style, id, name ); - - m_sizeSet = FALSE; - return m_frameStatusBar; -} - -wxStatusBar *wxFrame::OnCreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) -{ - wxStatusBar *statusBar = (wxStatusBar *) NULL; - - statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20), style, name); - - // Set the height according to the font and the border size - wxClientDC dc(statusBar); - dc.SetFont( statusBar->GetFont() ); - - long x, y; - dc.GetTextExtent( "X", &x, &y ); - - int height = (int)( (y * 1.1) + 2* statusBar->GetBorderY()); - - statusBar->SetSize( -1, -1, 100, height ); - - statusBar->SetFieldsCount( number ); - return statusBar; -} - -wxStatusBar *wxFrame::GetStatusBar() const -{ - return m_frameStatusBar; -} - -void wxFrame::SetStatusText(const wxString& text, int number) +wxStatusBar* wxFrame::CreateStatusBar(int number, + long style, + wxWindowID id, + const wxString& name) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") ); + // because it will change when toolbar is added + m_sizeSet = FALSE; - m_frameStatusBar->SetStatusText(text, number); + return wxFrameBase::CreateStatusBar( number, style, id, name ); } -void wxFrame::SetStatusWidths(int n, const int widths_field[] ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set widths for") ); - - m_frameStatusBar->SetStatusWidths(n, widths_field); -} #endif // wxUSE_STATUSBAR -void wxFrame::Command( int id ) -{ - wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id); - commandEvent.SetInt( id ); - commandEvent.SetEventObject( this ); - - wxMenuBar *bar = GetMenuBar(); - if (!bar) return; - - wxMenuItem *item = bar->FindItem(id) ; - if (item && item->IsCheckable()) - { - bar->Check(id, !bar->IsChecked(id)) ; - } - - wxEvtHandler* evtHandler = GetEventHandler(); - - evtHandler->ProcessEvent(commandEvent); -} +// ---------------------------------------------------------------------------- +// frame title/icon +// ---------------------------------------------------------------------------- void wxFrame::SetTitle( const wxString &title ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); m_title = title; - if (m_title.IsNull()) m_title = wxT(""); gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); } @@ -1123,10 +960,13 @@ void wxFrame::SetIcon( const wxIcon &icon ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - m_icon = icon; - if (!icon.Ok()) return; + wxFrameBase::SetIcon(icon); - if (!m_widget->window) return; + if ( !m_icon.Ok() ) + return; + + if (!m_widget->window) + return; wxMask *mask = icon.GetMask(); GdkBitmap *bm = (GdkBitmap *) NULL; @@ -1135,10 +975,19 @@ void wxFrame::SetIcon( const wxIcon &icon ) gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); } +// ---------------------------------------------------------------------------- +// frame state: maximized/iconized/normal (TODO) +// ---------------------------------------------------------------------------- + void wxFrame::Maximize(bool WXUNUSED(maximize)) { } +bool wxFrame::IsMaximized() const +{ + return FALSE; +} + void wxFrame::Restore() { } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 312ecb5854..57b5dfc22d 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -185,7 +185,7 @@ extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnScroll; extern wxCursor g_globalCursor; static wxWindow *g_captureWindow = (wxWindow*) NULL; -static wxWindow *g_focusWindow = (wxWindow*) NULL; +extern wxWindow *g_focusWindow = (wxWindow*) NULL; // if we detect that the app has got/lost the focus, we set this variable to // either TRUE or FALSE and an activate event will be sent during the next diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index b6d4bd5ccc..45df30ead7 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: frame.cpp +// Name: msw/frame.cpp // Purpose: wxFrame // Author: Julian Smart // Modified by: @@ -9,8 +9,16 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + #ifdef __GNUG__ -#pragma implementation "frame.h" + #pragma implementation "frame.h" #endif // For compilers that support precompilation, includes "wx.h". @@ -32,69 +40,87 @@ #endif // WX_PRECOMP #include "wx/msw/private.h" -#include "wx/statusbr.h" -#include "wx/toolbar.h" + +#if wxUSE_STATUSBAR + #include "wx/statusbr.h" + + #if wxUSE_NATIVE_STATUSBAR + #include "wx/msw/statbr95.h" + #endif +#endif // wxUSE_STATUSBAR + +#if wxUSE_TOOLBAR + #include "wx/toolbar.h" +#endif // wxUSE_TOOLBAR + #include "wx/menuitem.h" #include "wx/log.h" -#if wxUSE_NATIVE_STATUSBAR - #include "wx/msw/statbr95.h" -#endif +// ---------------------------------------------------------------------------- +// globals +// ---------------------------------------------------------------------------- extern wxWindowList wxModelessWindows; extern wxList WXDLLEXPORT wxPendingDelete; extern wxChar wxFrameClassName[]; extern wxMenu *wxCurrentPopupMenu; +// ---------------------------------------------------------------------------- +// event tables +// ---------------------------------------------------------------------------- + #if !USE_SHARED_LIBRARY -BEGIN_EVENT_TABLE(wxFrame, wxWindow) - EVT_SIZE(wxFrame::OnSize) - EVT_ACTIVATE(wxFrame::OnActivate) - EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) - EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) - EVT_IDLE(wxFrame::OnIdle) - EVT_CLOSE(wxFrame::OnCloseWindow) +BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) + EVT_ACTIVATE(wxFrame::OnActivate) + EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) #endif +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// static class members +// ---------------------------------------------------------------------------- + #if wxUSE_NATIVE_STATUSBAR bool wxFrame::m_useNativeStatusBar = TRUE; #else bool wxFrame::m_useNativeStatusBar = FALSE; #endif -wxFrame::wxFrame() -{ - m_frameToolBar = NULL ; - m_frameMenuBar = NULL; - m_frameStatusBar = NULL; - - m_iconized = FALSE; -} +// ---------------------------------------------------------------------------- +// creation/destruction +// ---------------------------------------------------------------------------- -bool wxFrame::Create(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) +void wxFrame::Init() { + m_iconized = FALSE; + #if wxUSE_TOOLTIPS m_hwndToolTip = 0; #endif +} +bool wxFrame::Create(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ SetName(name); m_windowStyle = style; m_frameMenuBar = NULL; - m_frameToolBar = NULL ; + m_frameToolBar = NULL; m_frameStatusBar = NULL; SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); -// m_icon = NULL; if ( id > -1 ) m_windowId = id; else @@ -131,13 +157,7 @@ wxFrame::~wxFrame() m_isBeingDeleted = TRUE; wxTopLevelWindows.DeleteObject(this); - if (m_frameStatusBar) - delete m_frameStatusBar; - if (m_frameMenuBar) - delete m_frameMenuBar; - -/* New behaviour March 1998: check if it's the last top-level window */ -// if (wxTheApp && (this == wxTheApp->GetTopWindow())) + DeleteAllBars(); if (wxTheApp && (wxTopLevelWindows.Number() == 0)) { @@ -167,12 +187,14 @@ void wxFrame::DoGetClientSize(int *x, int *y) const RECT rect; ::GetClientRect(GetHwnd(), &rect); +#if wxUSE_STATUSBAR if ( GetStatusBar() ) { int statusX, statusY; GetStatusBar()->GetClientSize(&statusX, &statusY); rect.bottom -= statusY; } +#endif // wxUSE_STATUSBAR wxPoint pt(GetClientAreaOrigin()); rect.bottom -= pt.y; @@ -202,12 +224,14 @@ void wxFrame::DoSetClientSize(int width, int height) int actual_width = rect2.right - rect2.left - rect.right + width; int actual_height = rect2.bottom - rect2.top - rect.bottom + height; +#if wxUSE_STATUSBAR if ( GetStatusBar() ) { int statusX, statusY; GetStatusBar()->GetClientSize(&statusX, &statusY); actual_height += statusY; } +#endif // wxUSE_STATUSBAR wxPoint pt(GetClientAreaOrigin()); actual_width += pt.y; @@ -244,63 +268,56 @@ void wxFrame::DoGetPosition(int *x, int *y) const *y = point.y; } +// ---------------------------------------------------------------------------- +// variations around ::ShowWindow() +// ---------------------------------------------------------------------------- + +void wxFrame::DoShowWindow(int nShowCmd) +{ + ::ShowWindow(GetHwnd(), nShowCmd); + + m_iconized = nShowCmd == SW_MINIMIZE; +} + bool wxFrame::Show(bool show) { - int cshow; - if (show) - cshow = SW_SHOW; - else - cshow = SW_HIDE; + DoShowWindow(show ? SW_SHOW : SW_HIDE); - if (!show) - { - // Try to highlight the correct window (the parent) - HWND hWndParent = 0; - if (GetParent()) + if ( show ) { - hWndParent = (HWND) GetParent()->GetHWND(); - if (hWndParent) - ::BringWindowToTop(hWndParent); - } - } + ::BringWindowToTop(GetHwnd()); - ShowWindow(GetHwnd(), (BOOL)cshow); - if (show) - { - BringWindowToTop(GetHwnd()); + wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_windowId); + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event); + } + else + { + // Try to highlight the correct window (the parent) + if ( GetParent() ) + { + HWND hWndParent = GetHwndOf(GetParent()); + if (hWndParent) + ::BringWindowToTop(hWndParent); + } + } - wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_windowId); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent(event); - } - return TRUE; + return TRUE; } void wxFrame::Iconize(bool iconize) { - if (!iconize) - Show(TRUE); - - int cshow; - if (iconize) - cshow = SW_MINIMIZE; - else - cshow = SW_RESTORE; - ShowWindow(GetHwnd(), (BOOL)cshow); - m_iconized = iconize; + DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE); } -// Equivalent to maximize/restore in Windows void wxFrame::Maximize(bool maximize) { - Show(TRUE); - int cshow; - if (maximize) - cshow = SW_MAXIMIZE; - else - cshow = SW_RESTORE; - ShowWindow(GetHwnd(), cshow); - m_iconized = FALSE; + DoShowWindow(maximize ? SW_MAXIMIZE : SW_RESTORE); +} + +void wxFrame::Restore() +{ + DoShowWindow(SW_RESTORE); } bool wxFrame::IsIconized() const @@ -312,103 +329,62 @@ bool wxFrame::IsIconized() const // Is it maximized? bool wxFrame::IsMaximized() const { - return (::IsZoomed(GetHwnd()) != 0) ; + return (::IsZoomed(GetHwnd()) != 0); } void wxFrame::SetIcon(const wxIcon& icon) { - m_icon = icon; + wxFrameBase::SetIcon(icon); + #if defined(__WIN95__) - if ( m_icon.Ok() ) - SendMessage(GetHwnd(), WM_SETICON, - (WPARAM)TRUE, (LPARAM)(HICON) m_icon.GetHICON()); -#endif + if ( m_icon.Ok() ) + { + SendMessage(GetHwnd(), WM_SETICON, + (WPARAM)TRUE, (LPARAM)(HICON) m_icon.GetHICON()); + } +#endif // __WIN95__ } #if wxUSE_STATUSBAR -wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id, - const wxString& name) +wxStatusBar *wxFrame::OnCreateStatusBar(int number, + long style, + wxWindowID id, + const wxString& name) { wxStatusBar *statusBar = NULL; #if wxUSE_NATIVE_STATUSBAR - if (UsesNativeStatusBar()) + if ( UsesNativeStatusBar() ) { statusBar = new wxStatusBar95(this, id, style); } else #endif { - statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20), - style, name); - - // Set the height according to the font and the border size - wxClientDC dc(statusBar); - dc.SetFont(statusBar->GetFont()); - - long x, y; - dc.GetTextExtent("X", &x, &y); - - int height = (int)( (y * 1.1) + 2* statusBar->GetBorderY()); - - statusBar->SetSize(-1, -1, 100, height); + statusBar = wxFrameBase::OnCreateStatusBar(number, style, id, name); } - statusBar->SetFieldsCount(number); - return statusBar; -} - -wxStatusBar* wxFrame::CreateStatusBar(int number, long style, wxWindowID id, - const wxString& name) -{ - // VZ: calling CreateStatusBar twice is an error - why anyone would do it? - wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, - wxT("recreating status bar in wxFrame") ); - - m_frameStatusBar = OnCreateStatusBar(number, style, id, - name); - if ( m_frameStatusBar ) - { - PositionStatusBar(); - return m_frameStatusBar; - } - else - return NULL; -} - -void wxFrame::SetStatusText(const wxString& text, int number) -{ - wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") ); - - m_frameStatusBar->SetStatusText(text, number); -} - -void wxFrame::SetStatusWidths(int n, const int widths_field[]) -{ - wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set widths for") ); - - m_frameStatusBar->SetStatusWidths(n, widths_field); - PositionStatusBar(); + return statusBar; } void wxFrame::PositionStatusBar() { - // native status bar positions itself - if (m_frameStatusBar + // native status bar positions itself + if ( m_frameStatusBar #if wxUSE_NATIVE_STATUSBAR - && !m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)) + && !m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)) #endif - ) - { - int w, h; - GetClientSize(&w, &h); - int sw, sh; - m_frameStatusBar->GetSize(&sw, &sh); - - // Since we wish the status bar to be directly under the client area, - // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. - m_frameStatusBar->SetSize(0, h, w, sh); - } + ) + { + int w, h; + GetClientSize(&w, &h); + int sw, sh; + m_frameStatusBar->GetSize(&sw, &sh); + + // Since we wish the status bar to be directly under the client area, + // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. + m_frameStatusBar->SetSize(0, h, w, sh); + } } #endif // wxUSE_STATUSBAR @@ -546,53 +522,6 @@ bool wxFrame::MSWCreate(int id, wxWindow *parent, const wxChar *wclass, wxWindow return TRUE; } -// Default resizing behaviour - if only ONE subwindow, resize to client -// rectangle size -void wxFrame::OnSize(wxSizeEvent& event) -{ - // if we're using constraints - do use them -#if wxUSE_CONSTRAINTS - if ( GetAutoLayout() ) - { - Layout(); - return; - } -#endif - - // do we have _exactly_ one child? - wxWindow *child = NULL; - for ( wxWindowList::Node *node = GetChildren().GetFirst(); - node; - node = node->GetNext() ) - { - wxWindow *win = node->GetData(); - if ( !win->IsTopLevel() -#if wxUSE_STATUSBAR - && (win != GetStatusBar()) -#endif // wxUSE_STATUSBAR -#if wxUSE_TOOLBAR - && (win != GetToolBar()) -#endif // wxUSE_TOOLBAR - ) - { - if ( child ) - return; // it's our second subwindow - nothing to do - child = win; - } - } - - if ( child ) { - // we have exactly one child - set it's size to fill the whole frame - int clientW, clientH; - GetClientSize(&clientW, &clientH); - - int x = 0; - int y = 0; - - child->SetSize(x, y, clientW, clientH); - } -} - // Default activation behaviour - set the focus for the first child // subwindow found. void wxFrame::OnActivate(wxActivateEvent& event) @@ -622,66 +551,11 @@ void wxFrame::OnActivate(wxActivateEvent& event) } } -// The default implementation for the close window event. -void wxFrame::OnCloseWindow(wxCloseEvent& event) -{ - Destroy(); -} - -// Destroy the window (delayed, if a managed window) -bool wxFrame::Destroy() -{ - if (!wxPendingDelete.Member(this)) - wxPendingDelete.Append(this); - return TRUE; -} - -// Default menu selection behaviour - display a help string -void wxFrame::OnMenuHighlight(wxMenuEvent& event) -{ - if (GetStatusBar()) - { - wxString help; - int menuId = event.GetMenuId(); - if ( menuId != -1 ) - { - wxMenuBar *menuBar = GetMenuBar(); - if (menuBar && menuBar->FindItem(menuId)) - { - help = menuBar->GetHelpString(menuId); - } - } - - // set status text even if the string is empty - this will at - // least remove the string from the item which was previously - // selected - SetStatusText(help); - } -} - -wxMenuBar *wxFrame::GetMenuBar() const -{ - return m_frameMenuBar; -} - -bool wxFrame::ProcessCommand(int id) -{ - wxMenuBar *bar = GetMenuBar() ; - if ( !bar ) - return FALSE; - - wxMenuItem *item = bar->FindItem(id); - if ( item && item->IsCheckable() ) - { - item->Toggle(); - } - - wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id); - commandEvent.SetInt( id ); - commandEvent.SetEventObject( this ); - - return GetEventHandler()->ProcessEvent(commandEvent); -} +// ---------------------------------------------------------------------------- +// wxFrame size management: we exclude the areas taken by menu/status/toolbars +// from the client area, so the client area is what's really available for the +// frame contents +// ---------------------------------------------------------------------------- // Checks if there is a toolbar, and returns the first free client position wxPoint wxFrame::GetClientAreaOrigin() const @@ -728,28 +602,20 @@ void wxFrame::DoClientToScreen(int *x, int *y) const wxWindow::DoClientToScreen(x, y); } +// ---------------------------------------------------------------------------- +// tool/status bar stuff +// ---------------------------------------------------------------------------- + #if wxUSE_TOOLBAR + wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) { - wxCHECK_MSG( m_frameToolBar == NULL, FALSE, - wxT("recreating toolbar in wxFrame") ); - - wxToolBar* toolBar = OnCreateToolBar(style, id, name); - if (toolBar) + if ( wxFrameBase::CreateToolBar(style, id, name) ) { - SetToolBar(toolBar); PositionToolBar(); - return toolBar; } - else - { - return NULL; - } -} -wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name) -{ - return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name); + return m_frameToolBar; } void wxFrame::PositionToolBar() @@ -757,32 +623,39 @@ void wxFrame::PositionToolBar() RECT rect; ::GetClientRect(GetHwnd(), &rect); +#if wxUSE_STATUSBAR if ( GetStatusBar() ) { - int statusX, statusY; - GetStatusBar()->GetClientSize(&statusX, &statusY); - rect.bottom -= statusY; + int statusX, statusY; + GetStatusBar()->GetClientSize(&statusX, &statusY); + rect.bottom -= statusY; } +#endif // wxUSE_STATUSBAR - if (GetToolBar()) + if ( GetToolBar() ) { int tw, th; - GetToolBar()->GetSize(& tw, & th); + GetToolBar()->GetSize(&tw, &th); - if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) + if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL ) { - // Use the 'real' MSW position - GetToolBar()->SetSize(0, 0, tw, rect.bottom, wxSIZE_NO_ADJUSTMENTS); + th = rect.bottom; } else { - // Use the 'real' MSW position - GetToolBar()->SetSize(0, 0, rect.right, th, wxSIZE_NO_ADJUSTMENTS); + tw = rect.right; } + + // Use the 'real' MSW position here + GetToolBar()->SetSize(0, 0, tw, th, wxSIZE_NO_ADJUSTMENTS); } } #endif // wxUSE_TOOLBAR +// ---------------------------------------------------------------------------- +// frame state (iconized/maximized/...) +// ---------------------------------------------------------------------------- + // propagate our state change to all child frames: this allows us to emulate X // Windows behaviour where child frames float independently of the parent one // on the desktop, but are iconized/restored with it @@ -801,20 +674,6 @@ void wxFrame::IconizeChildFrames(bool bIconize) } } - -// make the window modal (all other windows unresponsive) -void wxFrame::MakeModal(bool modal) -{ - if (modal) { - wxEnableTopLevelWindows(FALSE); - Enable(TRUE); // keep this window enabled - } - else { - wxEnableTopLevelWindows(TRUE); - } -} - - // =========================================================================== // message processing // =========================================================================== diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index d59e323f81..fe708c0538 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -35,7 +35,9 @@ #include "wx/app.h" #include "wx/utils.h" #include "wx/dialog.h" - #include "wx/statusbr.h" + #if wxUSE_STATUSBAR + #include "wx/statusbr.h" + #endif #include "wx/settings.h" #include "wx/intl.h" #include "wx/log.h" @@ -44,10 +46,14 @@ #include "wx/mdi.h" #include "wx/msw/private.h" -#if wxUSE_NATIVE_STATUSBAR +#if wxUSE_STATUSBAR && wxUSE_NATIVE_STATUSBAR #include "wx/msw/statbr95.h" #endif +#if wxUSE_TOOLBAR + #include "wx/toolbar.h" +#endif // wxUSE_TOOLBAR + #include // --------------------------------------------------------------------------- diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 4fa77ae7cb..aa23d55899 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -95,7 +95,7 @@ static void wxMapBitmap(HBITMAP hBitmap, int width, int height); // ---------------------------------------------------------------------------- #if !USE_SHARED_LIBRARY - IMPLEMENT_DYNAMIC_CLASS(wxToolBar95, wxToolBarBase) + IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase) #endif BEGIN_EVENT_TABLE(wxToolBar95, wxToolBarBase) diff --git a/src/msw/tbarmsw.cpp b/src/msw/tbarmsw.cpp index 7062f14c3f..7f23bf7f63 100644 --- a/src/msw/tbarmsw.cpp +++ b/src/msw/tbarmsw.cpp @@ -56,7 +56,7 @@ #endif #if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxToolBarMSW, wxToolBarBase) +IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase) BEGIN_EVENT_TABLE(wxToolBarMSW, wxToolBarBase) EVT_SIZE(wxToolBarMSW::OnSize) -- 2.45.2