wxFrameBase class for wxMSW and wxGTK

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4595 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-11-16 21:31:40 +00:00
parent 40779a03e7
commit 7c0ea335c7
22 changed files with 1153 additions and 1120 deletions

View File

@@ -552,18 +552,7 @@ case "${host}" in
DEFAULT_DEFAULT_wxUSE_MOTIF=1 DEFAULT_DEFAULT_wxUSE_MOTIF=1
;; ;;
*-*-cygwin32* ) *-*-cygwin32* | *-*-mingw32* )
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* )
USE_UNIX=0 USE_UNIX=0
USE_WIN32=1 USE_WIN32=1
AC_DEFINE(__WIN32__) AC_DEFINE(__WIN32__)

View File

@@ -9,6 +9,11 @@ all:
- wxStopWatch class, timer functions have more chances to return correct - wxStopWatch class, timer functions have more chances to return correct
results for your platform (use ANSI function where available) 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: wxMSW:
- arbitrary controls (and not only buttons) can be put into a toolbar - arbitrary controls (and not only buttons) can be put into a toolbar
@@ -16,6 +21,7 @@ wxMSW:
wxGTK: wxGTK:
- wxFontMapper endless recursion bug (on some systems) fixed - wxFontMapper endless recursion bug (on some systems) fixed
- wxGTK synthesizes wxActivateEvents
- you can use UpdateUI handlers with wxTextCtrl - you can use UpdateUI handlers with wxTextCtrl
NOTE: for changes after wxWindows 2.1.0 b4, please see the CVS NOTE: for changes after wxWindows 2.1.0 b4, please see the CVS

View File

@@ -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 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 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 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. } use relative instead of absolute paths. }
\wxheading{Remarks} \wxheading{Remarks}

View File

@@ -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_ #ifndef _WX_FRAME_H_BASE_
#define _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__) #if defined(__WXMSW__)
#include "wx/msw/frame.h" #include "wx/msw/frame.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#include "wx/motif/frame.h" #include "wx/motif/frame.h"
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk/frame.h" #include "wx/gtk/frame.h"
#elif defined(__WXQT__) #elif defined(__WXQT__)
#include "wx/qt/frame.h" #include "wx/qt/frame.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/mac/frame.h" #include "wx/mac/frame.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#include "wx/os2/frame.h" #include "wx/os2/frame.h"
#elif defined(__WXSTUBS__) #elif defined(__WXSTUBS__)
#include "wx/stubs/frame.h" #include "wx/stubs/frame.h"
#endif #endif
#endif #endif

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: frame.h // Name: wx/gtk/frame.h
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -12,14 +12,9 @@
#define __GTKFRAMEH__ #define __GTKFRAMEH__
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface "frame.h"
#endif #endif
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/window.h"
#include "wx/icon.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -33,98 +28,78 @@ class wxStatusBar;
class wxFrame; class wxFrame;
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
extern const wxChar *wxFrameNameStr;
extern const wxChar *wxToolBarNameStr;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxFrame // wxFrame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxFrame: public wxWindow class wxFrame : public wxFrameBase
{ {
DECLARE_DYNAMIC_CLASS(wxFrame)
public: public:
// construction
wxFrame() { Init(); } wxFrame() { Init(); }
wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, wxFrame(wxWindow *parent,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, wxWindowID id,
long style = wxDEFAULT_FRAME_STYLE, const wxString &name = wxFrameNameStr ); const wxString& title,
bool Create( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint& pos = wxDefaultPosition,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE, const wxString &name = wxFrameNameStr ); long style = wxDEFAULT_FRAME_STYLE,
~wxFrame(); const wxString& name = wxFrameNameStr)
bool Destroy(); {
Init();
virtual bool Show( bool show ); Create(parent, id, title, pos, size, style, name);
virtual void Centre( int direction = wxBOTH ); }
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 #if wxUSE_STATUSBAR
virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, virtual wxStatusBar* CreateStatusBar(int number = 1,
const wxString& name = wxT("statusBar")); long style = wxST_SIZEGRIP,
virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id, wxWindowID id = 0,
const wxString& name ); const wxString& name = wxStatusLineNameStr);
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[] );
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
virtual wxToolBar* CreateToolBar( long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT,
wxWindowID id = -1,
const wxString& name = wxToolBarNameStr); const wxString& name = wxToolBarNameStr);
virtual wxToolBar *OnCreateToolBar( long style, wxWindowID id, const wxString& name );
virtual wxToolBar *GetToolBar() const;
void SetToolBar(wxToolBar *toolbar); void SetToolBar(wxToolBar *toolbar);
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
virtual void SetMenuBar( wxMenuBar *menuBar ); virtual bool Show(bool show);
virtual wxMenuBar *GetMenuBar() const;
virtual void SetTitle( const wxString &title ); virtual void SetTitle( const wxString &title );
virtual wxString GetTitle() const { return m_title; } virtual wxString GetTitle() const { return m_title; }
// make the window modal (all other windows unresponsive) // implementation from now on
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
// GTK callbacks
virtual void GtkOnSize( int x, int y, int width, int height ); virtual void GtkOnSize( int x, int y, int width, int height );
void DoMenuUpdates();
void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
virtual void OnInternalIdle(); virtual void OnInternalIdle();
wxMenuBar *m_frameMenuBar;
#if wxUSE_STATUSBAR
wxStatusBar *m_frameStatusBar;
#endif
#if wxUSE_TOOLBAR
wxToolBar *m_frameToolBar;
#endif
wxString m_title; wxString m_title;
wxIcon m_icon; int m_miniEdge,
int m_miniEdge,m_miniTitle; m_miniTitle;
GtkWidget *m_mainWidget; GtkWidget *m_mainWidget;
bool m_menuBarDetached; bool m_menuBarDetached;
bool m_toolBarDetached; bool m_toolBarDetached;
@@ -134,6 +109,7 @@ protected:
// common part of all ctors // common part of all ctors
void Init(); void Init();
// override wxWindow methods to take into account tool/menu/statusbars
virtual void DoSetSize(int x, int y, virtual void DoSetSize(int x, int y,
int width, int height, int width, int height,
int sizeFlags = wxSIZE_AUTO); int sizeFlags = wxSIZE_AUTO);
@@ -142,7 +118,7 @@ protected:
virtual void DoGetClientSize( int *width, int *height ) const; virtual void DoGetClientSize( int *width, int *height ) const;
private: private:
DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxFrame)
}; };
#endif // __GTKFRAMEH__ #endif // __GTKFRAMEH__

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: frame.h // Name: wx/gtk/frame.h
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -12,14 +12,9 @@
#define __GTKFRAMEH__ #define __GTKFRAMEH__
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface "frame.h"
#endif #endif
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/window.h"
#include "wx/icon.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -33,98 +28,78 @@ class wxStatusBar;
class wxFrame; class wxFrame;
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
extern const wxChar *wxFrameNameStr;
extern const wxChar *wxToolBarNameStr;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxFrame // wxFrame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxFrame: public wxWindow class wxFrame : public wxFrameBase
{ {
DECLARE_DYNAMIC_CLASS(wxFrame)
public: public:
// construction
wxFrame() { Init(); } wxFrame() { Init(); }
wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, wxFrame(wxWindow *parent,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, wxWindowID id,
long style = wxDEFAULT_FRAME_STYLE, const wxString &name = wxFrameNameStr ); const wxString& title,
bool Create( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint& pos = wxDefaultPosition,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE, const wxString &name = wxFrameNameStr ); long style = wxDEFAULT_FRAME_STYLE,
~wxFrame(); const wxString& name = wxFrameNameStr)
bool Destroy(); {
Init();
virtual bool Show( bool show ); Create(parent, id, title, pos, size, style, name);
virtual void Centre( int direction = wxBOTH ); }
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 #if wxUSE_STATUSBAR
virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, virtual wxStatusBar* CreateStatusBar(int number = 1,
const wxString& name = wxT("statusBar")); long style = wxST_SIZEGRIP,
virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id, wxWindowID id = 0,
const wxString& name ); const wxString& name = wxStatusLineNameStr);
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[] );
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
virtual wxToolBar* CreateToolBar( long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT,
wxWindowID id = -1,
const wxString& name = wxToolBarNameStr); const wxString& name = wxToolBarNameStr);
virtual wxToolBar *OnCreateToolBar( long style, wxWindowID id, const wxString& name );
virtual wxToolBar *GetToolBar() const;
void SetToolBar(wxToolBar *toolbar); void SetToolBar(wxToolBar *toolbar);
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
virtual void SetMenuBar( wxMenuBar *menuBar ); virtual bool Show(bool show);
virtual wxMenuBar *GetMenuBar() const;
virtual void SetTitle( const wxString &title ); virtual void SetTitle( const wxString &title );
virtual wxString GetTitle() const { return m_title; } virtual wxString GetTitle() const { return m_title; }
// make the window modal (all other windows unresponsive) // implementation from now on
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
// GTK callbacks
virtual void GtkOnSize( int x, int y, int width, int height ); virtual void GtkOnSize( int x, int y, int width, int height );
void DoMenuUpdates();
void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
virtual void OnInternalIdle(); virtual void OnInternalIdle();
wxMenuBar *m_frameMenuBar;
#if wxUSE_STATUSBAR
wxStatusBar *m_frameStatusBar;
#endif
#if wxUSE_TOOLBAR
wxToolBar *m_frameToolBar;
#endif
wxString m_title; wxString m_title;
wxIcon m_icon; int m_miniEdge,
int m_miniEdge,m_miniTitle; m_miniTitle;
GtkWidget *m_mainWidget; GtkWidget *m_mainWidget;
bool m_menuBarDetached; bool m_menuBarDetached;
bool m_toolBarDetached; bool m_toolBarDetached;
@@ -134,6 +109,7 @@ protected:
// common part of all ctors // common part of all ctors
void Init(); void Init();
// override wxWindow methods to take into account tool/menu/statusbars
virtual void DoSetSize(int x, int y, virtual void DoSetSize(int x, int y,
int width, int height, int width, int height,
int sizeFlags = wxSIZE_AUTO); int sizeFlags = wxSIZE_AUTO);
@@ -142,7 +118,7 @@ protected:
virtual void DoGetClientSize( int *width, int *height ) const; virtual void DoGetClientSize( int *width, int *height ) const;
private: private:
DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxFrame)
}; };
#endif // __GTKFRAMEH__ #endif // __GTKFRAMEH__

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: frame.h // Name: wx/msw/frame.h
// Purpose: wxFrame class // Purpose: wxFrame class
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
@@ -16,24 +16,11 @@
#pragma interface "frame.h" #pragma interface "frame.h"
#endif #endif
#include "wx/window.h" class WXDLLEXPORT wxFrame : public wxFrameBase
#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
{ {
DECLARE_DYNAMIC_CLASS(wxFrame)
public: public:
wxFrame(); // construction
wxFrame() { Init(); }
wxFrame(wxWindow *parent, wxFrame(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxString& title, const wxString& title,
@@ -42,11 +29,11 @@ public:
long style = wxDEFAULT_FRAME_STYLE, long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr) const wxString& name = wxFrameNameStr)
{ {
Init();
Create(parent, id, title, pos, size, style, name); Create(parent, id, title, pos, size, style, name);
} }
~wxFrame();
bool Create(wxWindow *parent, bool Create(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxString& title, const wxString& title,
@@ -55,105 +42,62 @@ public:
long style = wxDEFAULT_FRAME_STYLE, long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr); const wxString& name = wxFrameNameStr);
virtual bool Destroy(); virtual ~wxFrame();
void OnSize(wxSizeEvent& event); // implement base class pure virtuals
void OnMenuHighlight(wxMenuEvent& event); virtual void Maximize(bool maximize = TRUE);
void OnActivate(wxActivateEvent& event); virtual bool IsMaximized() const;
void OnIdle(wxIdleEvent& event); virtual void Iconize(bool iconize = TRUE);
void OnCloseWindow(wxCloseEvent& event); virtual bool IsIconized() const;
virtual void Restore();
bool Show(bool show); virtual void SetMenuBar(wxMenuBar *menubar);
void DetachMenuBar();
// Set menu bar
void SetMenuBar(wxMenuBar *menu_bar);
virtual wxMenuBar *GetMenuBar() const;
// 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);
// make the window modal (all other windows unresponsive)
virtual void MakeModal(bool modal = TRUE);
// Set icon
virtual void SetIcon(const wxIcon& icon); virtual void SetIcon(const wxIcon& icon);
// implementation only from now on
// -------------------------------
// override some more virtuals
virtual bool Show(bool show = TRUE);
// event handlers
void OnActivate(wxActivateEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
// Toolbar // Toolbar
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT, virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT,
wxWindowID id = -1, wxWindowID id = -1,
const wxString& name = wxToolBarNameStr); 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(); virtual void PositionToolBar();
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
#if wxUSE_STATUSBAR
// Status bar // Status bar
virtual wxStatusBar* CreateStatusBar(int number = 1, #if wxUSE_STATUSBAR
virtual wxStatusBar* OnCreateStatusBar(int number = 1,
long style = wxST_SIZEGRIP, long style = wxST_SIZEGRIP,
wxWindowID id = 0, wxWindowID id = 0,
const wxString& name = wxStatusLineNameStr); const wxString& name = wxStatusLineNameStr);
wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
void SetStatusBar(wxStatusBar *statusBar) { m_frameStatusBar = statusBar; }
virtual void PositionStatusBar(); virtual void PositionStatusBar();
virtual wxStatusBar *OnCreateStatusBar(int number,
long style,
wxWindowID id,
const wxString& name);
// Set status line text // Hint to tell framework which status bar to use: the default is to use
virtual void SetStatusText(const wxString& text, int number = 0); // native one for the platforms which support it (Win32), the generic one
// otherwise
// Set status line widths
virtual void SetStatusWidths(int n, const int widths_field[]);
// Hint to tell framework which status bar to use
// TODO: should this go into a wxFrameworkSettings class perhaps? // TODO: should this go into a wxFrameworkSettings class perhaps?
static void UseNativeStatusBar(bool useNative) { m_useNativeStatusBar = useNative; }; static void UseNativeStatusBar(bool useNative)
static bool UsesNativeStatusBar() { return m_useNativeStatusBar; }; { m_useNativeStatusBar = useNative; };
static bool UsesNativeStatusBar()
{ return m_useNativeStatusBar; };
#endif // wxUSE_STATUSBAR #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; } WXHMENU GetWinMenu() const { return m_hMenu; }
// Returns the origin of client area (may be different from (0,0) if the // Returns the origin of client area (may be different from (0,0) if the
// frame has a toolbar) // frame has a toolbar)
virtual wxPoint GetClientAreaOrigin() const; virtual wxPoint GetClientAreaOrigin() const;
// Implementation only from here
// event handlers // event handlers
bool HandlePaint(); bool HandlePaint();
bool HandleSize(int x, int y, WXUINT flag); bool HandleSize(int x, int y, WXUINT flag);
@@ -171,6 +115,12 @@ public:
#endif // tooltips #endif // tooltips
protected: protected:
// common part of all ctors
void Init();
// common part of Iconize(), Maximize() and Restore()
void DoShowWindow(int nShowCmd);
// override base class virtuals // override base class virtuals
virtual void DoGetClientSize(int *width, int *height) const; virtual void DoGetClientSize(int *width, int *height) const;
virtual void DoGetSize(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 DoClientToScreen(int *x, int *y) const;
virtual void DoScreenToClient(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 // a plug in for MDI frame classes which need to do something special when
// the menubar is set // the menubar is set
virtual void InternalSetMenuBar(); virtual void InternalSetMenuBar();
@@ -194,27 +147,20 @@ protected:
// window proc for the frames // window proc for the frames
long MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); long MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
wxMenuBar * m_frameMenuBar;
wxIcon m_icon;
bool m_iconized; bool m_iconized;
WXHICON m_defaultIcon; WXHICON m_defaultIcon;
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
wxStatusBar * m_frameStatusBar;
static bool m_useNativeStatusBar; static bool m_useNativeStatusBar;
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
#if wxUSE_TOOLBAR
wxToolBar * m_frameToolBar;
#endif // wxUSE_TOOLBAR
private: private:
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
WXHWND m_hwndToolTip; WXHWND m_hwndToolTip;
#endif // tooltips #endif // tooltips
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxFrame)
}; };
#endif #endif

View File

@@ -19,9 +19,8 @@
// headers // headers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef _DYNARRAY_H #include "wx/control.h"
#include <wx/dynarray.h> #include "wx/dynarray.h"
#endif //_DYNARRAY_H
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// types // types

View File

@@ -88,7 +88,25 @@ protected:
WXHBITMAP m_hBitmap; WXHBITMAP m_hBitmap;
DECLARE_EVENT_TABLE() 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 #endif // wxUSE_TOOLBAR

View File

@@ -119,6 +119,26 @@ DECLARE_EVENT_TABLE()
#define wxTBSTATE_HIDDEN 0x08 // button is hidden #define wxTBSTATE_HIDDEN 0x08 // button is hidden
#define wxTBSTATE_INDETERMINATE 0x10 // button is indeterminate #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 // wxUSE_TOOL/BUTTONBAR
#endif #endif
// _WX_TBARMSW_H_ // _WX_TBARMSW_H_

View File

@@ -1,16 +1,10 @@
#ifndef _TOOLBAR_H_BASE_ #ifndef _TOOLBAR_H_BASE_
#define _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__) #if defined(__WXMSW__) && defined(__WIN95__)
# include "wx/msw/tbar95.h" # include "wx/msw/tbar95.h"
# define wxToolBar wxToolBar95
# define sm_classwxToolBar sm_classwxToolBar95
#elif defined(__WXMSW__) #elif defined(__WXMSW__)
# include "wx/msw/tbarmsw.h" # include "wx/msw/tbarmsw.h"
# define wxToolBar wxToolBarMSW
# define sm_classwxToolBar sm_classwxToolBarMSW
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
# include "wx/motif/toolbar.h" # include "wx/motif/toolbar.h"
#elif defined(__WXGTK__) #elif defined(__WXGTK__)

View File

@@ -94,6 +94,11 @@
#undef STRICT #undef STRICT
#undef WINVER #undef WINVER
/* enable native status bar under Win32 */
#ifdef __WIN95__
#define wxUSE_NATIVE_STATUSBAR 1
#endif
/* /*
* Supports bool type * Supports bool type
*/ */

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: framecmn.cpp // Name: common/framecmn.cpp
// Purpose: common (for all platforms) wxFrame functions // Purpose: common (for all platforms) wxFrame functions
// Author: Julian Smart, Vadim Zeitlin // Author: Julian Smart, Vadim Zeitlin
// Created: 01/02/97 // Created: 01/02/97
@@ -8,24 +8,365 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma implementation "framebase.h"
#endif
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
#endif #endif
#include "wx/frame.h" #include "wx/frame.h"
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/menuitem.h" #include "wx/menuitem.h"
#include "wx/dcclient.h"
void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) ) #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;
}
}
// 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(); DoMenuUpdates();
} }
// update all menus // update all menus
void wxFrame::DoMenuUpdates() void wxFrameBase::DoMenuUpdates()
{ {
wxMenuBar* bar = GetMenuBar(); wxMenuBar* bar = GetMenuBar();
@@ -38,7 +379,7 @@ void wxFrame::DoMenuUpdates()
} }
// update a menu and all submenus recursively // update a menu and all submenus recursively
void wxFrame::DoMenuUpdates(wxMenu* menu, wxWindow* WXUNUSED(focusWin)) void wxFrameBase::DoMenuUpdates(wxMenu* menu, wxWindow* WXUNUSED(focusWin))
{ {
wxEvtHandler* evtHandler = GetEventHandler(); wxEvtHandler* evtHandler = GetEventHandler();
wxMenuItemList::Node* node = menu->GetMenuItems().GetFirst(); wxMenuItemList::Node* node = menu->GetMenuItems().GetFirst();

View File

@@ -2164,8 +2164,8 @@ void wxListMainWindow::CalculatePositions()
int y = 1; int y = 1;
int entireHeight = m_lines.Number() * lineSpacing + 2; int entireHeight = m_lines.Number() * lineSpacing + 2;
int scroll_pos = GetScrollPos( wxVERTICAL ); int scroll_pos = GetScrollPos( wxVERTICAL );
int x_scroll_pos = GetScrollPos( wxHORIZONTAL );
#if wxUSE_GENERIC_LIST_EXTENSIONS #if wxUSE_GENERIC_LIST_EXTENSIONS
int x_scroll_pos = GetScrollPos( wxHORIZONTAL );
#else #else
SetScrollbars( m_xScroll, m_yScroll, 0, (entireHeight+15) / m_yScroll, 0, scroll_pos, TRUE ); SetScrollbars( m_xScroll, m_yScroll, 0, (entireHeight+15) / m_yScroll, 0, scroll_pos, TRUE );
#endif #endif
@@ -2312,18 +2312,22 @@ void wxListMainWindow::DeleteAllItems( void )
{ {
m_dirty = TRUE; m_dirty = TRUE;
m_current = (wxListLineData *) NULL; 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(); wxNode *node = m_lines.First();
while (node) while (node)
{ {
wxListLineData *line = (wxListLineData*)node->Data(); wxListLineData *line = (wxListLineData*)node->Data();
// to make the deletion of all items faster, we don't send the DeleteLine( line );
// notifications in this case: this is compatible with wxMSW and
// documented in DeleteAllItems() description
//DeleteLine( line );
node = node->Next(); node = node->Next();
} }
#endif // 0
m_lines.Clear(); m_lines.Clear();
} }

View File

@@ -7,6 +7,14 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "frame.h" #pragma implementation "frame.h"
#endif #endif
@@ -17,10 +25,10 @@
#include "wx/app.h" #include "wx/app.h"
#include "wx/menu.h" #include "wx/menu.h"
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
#include "wx/toolbar.h" #include "wx/toolbar.h"
#endif #endif
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
#include "wx/statusbr.h" #include "wx/statusbr.h"
#endif #endif
#include "wx/dcclient.h" #include "wx/dcclient.h"
@@ -31,31 +39,37 @@
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include "gdk/gdkx.h" #include "gdk/gdkx.h"
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
const int wxMENU_HEIGHT = 27; const int wxMENU_HEIGHT = 27;
const int wxSTATUS_HEIGHT = 25; const int wxSTATUS_HEIGHT = 25;
const int wxPLACE_HOLDER = 0; const int wxPLACE_HOLDER = 0;
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// idle system // idle system
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
extern void wxapp_install_idle_handler(); extern void wxapp_install_idle_handler();
extern bool g_isIdle; extern bool g_isIdle;
extern int g_openDialogs; extern int g_openDialogs;
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// event tables
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
// ----------------------------------------------------------------------------
// data // data
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// debug // debug
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
@@ -63,6 +77,14 @@ extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar
#endif #endif
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// GTK callbacks
// ----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "focus" from m_window // "focus" from m_window
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -280,10 +302,11 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
} }
/* reset the icon */ /* reset the icon */
if (win->m_icon != wxNullIcon) wxIcon iconOld = win->GetIcon();
if ( iconOld != wxNullIcon )
{ {
wxIcon icon( win->m_icon ); wxIcon icon( iconOld );
win->m_icon = wxNullIcon; win->SetIcon( wxNullIcon );
win->SetIcon( icon ); win->SetIcon( icon );
} }
@@ -305,6 +328,10 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
return FALSE; return FALSE;
} }
// ----------------------------------------------------------------------------
// wxFrame itself
// ----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// InsertChild for wxFrame // InsertChild for wxFrame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -361,28 +388,12 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
parent->UpdateSize(); parent->UpdateSize();
} }
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxFrame // wxFrame creation
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
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)
void wxFrame::Init() 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_sizeSet = FALSE;
m_miniEdge = 0; m_miniEdge = 0;
m_miniTitle = 0; m_miniTitle = 0;
@@ -393,18 +404,13 @@ void wxFrame::Init()
m_isFrame = TRUE; m_isFrame = TRUE;
} }
wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, bool wxFrame::Create( wxWindow *parent,
const wxPoint &pos, const wxSize &size, wxWindowID id,
long style, const wxString &name ) const wxString &title,
{ const wxPoint &pos,
Init(); const wxSize &size,
long style,
Create( parent, id, title, pos, size, style, name ); 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 ); wxTopLevelWindows.Append( this );
@@ -490,18 +496,7 @@ wxFrame::~wxFrame()
{ {
m_isBeingDeleted = TRUE; m_isBeingDeleted = TRUE;
if (m_frameMenuBar) delete m_frameMenuBar; DeleteAllBars();
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
wxTopLevelWindows.DeleteObject( this ); wxTopLevelWindows.DeleteObject( this );
@@ -512,6 +507,10 @@ wxFrame::~wxFrame()
wxTheApp->ExitMainLoop(); wxTheApp->ExitMainLoop();
} }
// ----------------------------------------------------------------------------
// overridden wxWindow methods
// ----------------------------------------------------------------------------
bool wxFrame::Show( bool show ) bool wxFrame::Show( bool show )
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
@@ -529,15 +528,6 @@ bool wxFrame::Show( bool show )
return wxWindow::Show( 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 ) void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); 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") ); wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
/* avoid recursions */ /* avoid recursions */
if (m_resizing) return; if (m_resizing)
return;
m_resizing = TRUE; m_resizing = TRUE;
int old_x = m_x; 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; 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 void wxFrame::DoGetClientSize( int *width, int *height ) const
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); 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 ); 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 // due to a bug in gtk, x,y are always 0
// m_x = x; // m_x = x;
@@ -818,7 +797,6 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
/* we actually set the size of a frame here and no-where else */ /* we actually set the size of a frame here and no-where else */
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
m_sizeSet = TRUE; m_sizeSet = TRUE;
// send size event to frame // send size event to frame
@@ -868,50 +846,9 @@ void wxFrame::OnInternalIdle()
wxWindow::OnInternalIdle(); wxWindow::OnInternalIdle();
} }
void wxFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) ) // ----------------------------------------------------------------------------
{ // menu/tool/status bar stuff
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 );
}
}
}
void wxFrame::SetMenuBar( wxMenuBar *menuBar ) void wxFrame::SetMenuBar( wxMenuBar *menuBar )
{ {
@@ -951,50 +888,17 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar )
m_sizeSet = FALSE; 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 #if wxUSE_TOOLBAR
wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name ) wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name )
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
wxCHECK_MSG( m_frameToolBar == NULL, FALSE, wxT("recreating toolbar in wxFrame") );
m_insertInClientArea = FALSE; 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; m_insertInClientArea = TRUE;
@@ -1003,14 +907,10 @@ wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& na
return m_frameToolBar; 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) void wxFrame::SetToolBar(wxToolBar *toolbar)
{ {
m_frameToolBar = toolbar; wxFrameBase::SetToolBar(toolbar);
if (m_frameToolBar) if (m_frameToolBar)
{ {
/* insert into toolbar area if not already there */ /* 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 #endif // wxUSE_TOOLBAR
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name )
wxStatusBar* wxFrame::CreateStatusBar(int number,
long style,
wxWindowID id,
const wxString& name)
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, wxT("recreating status bar in wxFrame") ); // because it will change when toolbar is added
m_frameStatusBar = OnCreateStatusBar( number, style, id, name );
m_sizeSet = FALSE; m_sizeSet = FALSE;
return m_frameStatusBar; return wxFrameBase::CreateStatusBar( number, style, id, name );
} }
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)
{
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 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 #endif // wxUSE_STATUSBAR
void wxFrame::Command( int id ) // ----------------------------------------------------------------------------
{ // frame title/icon
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);
}
void wxFrame::SetTitle( const wxString &title ) void wxFrame::SetTitle( const wxString &title )
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
m_title = title; m_title = title;
if (m_title.IsNull()) m_title = wxT("");
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); 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") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
m_icon = icon; wxFrameBase::SetIcon(icon);
if (!icon.Ok()) return;
if (!m_widget->window) return; if ( !m_icon.Ok() )
return;
if (!m_widget->window)
return;
wxMask *mask = icon.GetMask(); wxMask *mask = icon.GetMask();
GdkBitmap *bm = (GdkBitmap *) NULL; 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 ); gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
} }
// ----------------------------------------------------------------------------
// frame state: maximized/iconized/normal (TODO)
// ----------------------------------------------------------------------------
void wxFrame::Maximize(bool WXUNUSED(maximize)) void wxFrame::Maximize(bool WXUNUSED(maximize))
{ {
} }
bool wxFrame::IsMaximized() const
{
return FALSE;
}
void wxFrame::Restore() void wxFrame::Restore()
{ {
} }

View File

@@ -185,7 +185,7 @@ extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll; extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor; extern wxCursor g_globalCursor;
static wxWindow *g_captureWindow = (wxWindow*) NULL; 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 // 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 // either TRUE or FALSE and an activate event will be sent during the next

View File

@@ -7,6 +7,14 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "frame.h" #pragma implementation "frame.h"
#endif #endif
@@ -17,10 +25,10 @@
#include "wx/app.h" #include "wx/app.h"
#include "wx/menu.h" #include "wx/menu.h"
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
#include "wx/toolbar.h" #include "wx/toolbar.h"
#endif #endif
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
#include "wx/statusbr.h" #include "wx/statusbr.h"
#endif #endif
#include "wx/dcclient.h" #include "wx/dcclient.h"
@@ -31,31 +39,37 @@
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include "gdk/gdkx.h" #include "gdk/gdkx.h"
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
const int wxMENU_HEIGHT = 27; const int wxMENU_HEIGHT = 27;
const int wxSTATUS_HEIGHT = 25; const int wxSTATUS_HEIGHT = 25;
const int wxPLACE_HOLDER = 0; const int wxPLACE_HOLDER = 0;
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// idle system // idle system
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
extern void wxapp_install_idle_handler(); extern void wxapp_install_idle_handler();
extern bool g_isIdle; extern bool g_isIdle;
extern int g_openDialogs; extern int g_openDialogs;
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// event tables
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
// ----------------------------------------------------------------------------
// data // data
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// debug // debug
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
@@ -63,6 +77,14 @@ extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar
#endif #endif
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// GTK callbacks
// ----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "focus" from m_window // "focus" from m_window
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -280,10 +302,11 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
} }
/* reset the icon */ /* reset the icon */
if (win->m_icon != wxNullIcon) wxIcon iconOld = win->GetIcon();
if ( iconOld != wxNullIcon )
{ {
wxIcon icon( win->m_icon ); wxIcon icon( iconOld );
win->m_icon = wxNullIcon; win->SetIcon( wxNullIcon );
win->SetIcon( icon ); win->SetIcon( icon );
} }
@@ -305,6 +328,10 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
return FALSE; return FALSE;
} }
// ----------------------------------------------------------------------------
// wxFrame itself
// ----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// InsertChild for wxFrame // InsertChild for wxFrame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -361,28 +388,12 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
parent->UpdateSize(); parent->UpdateSize();
} }
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxFrame // wxFrame creation
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
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)
void wxFrame::Init() 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_sizeSet = FALSE;
m_miniEdge = 0; m_miniEdge = 0;
m_miniTitle = 0; m_miniTitle = 0;
@@ -393,18 +404,13 @@ void wxFrame::Init()
m_isFrame = TRUE; m_isFrame = TRUE;
} }
wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, bool wxFrame::Create( wxWindow *parent,
const wxPoint &pos, const wxSize &size, wxWindowID id,
long style, const wxString &name ) const wxString &title,
{ const wxPoint &pos,
Init(); const wxSize &size,
long style,
Create( parent, id, title, pos, size, style, name ); 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 ); wxTopLevelWindows.Append( this );
@@ -490,18 +496,7 @@ wxFrame::~wxFrame()
{ {
m_isBeingDeleted = TRUE; m_isBeingDeleted = TRUE;
if (m_frameMenuBar) delete m_frameMenuBar; DeleteAllBars();
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
wxTopLevelWindows.DeleteObject( this ); wxTopLevelWindows.DeleteObject( this );
@@ -512,6 +507,10 @@ wxFrame::~wxFrame()
wxTheApp->ExitMainLoop(); wxTheApp->ExitMainLoop();
} }
// ----------------------------------------------------------------------------
// overridden wxWindow methods
// ----------------------------------------------------------------------------
bool wxFrame::Show( bool show ) bool wxFrame::Show( bool show )
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
@@ -529,15 +528,6 @@ bool wxFrame::Show( bool show )
return wxWindow::Show( 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 ) void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); 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") ); wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
/* avoid recursions */ /* avoid recursions */
if (m_resizing) return; if (m_resizing)
return;
m_resizing = TRUE; m_resizing = TRUE;
int old_x = m_x; 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; 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 void wxFrame::DoGetClientSize( int *width, int *height ) const
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); 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 ); 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 // due to a bug in gtk, x,y are always 0
// m_x = x; // m_x = x;
@@ -818,7 +797,6 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
/* we actually set the size of a frame here and no-where else */ /* we actually set the size of a frame here and no-where else */
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
m_sizeSet = TRUE; m_sizeSet = TRUE;
// send size event to frame // send size event to frame
@@ -868,50 +846,9 @@ void wxFrame::OnInternalIdle()
wxWindow::OnInternalIdle(); wxWindow::OnInternalIdle();
} }
void wxFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) ) // ----------------------------------------------------------------------------
{ // menu/tool/status bar stuff
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 );
}
}
}
void wxFrame::SetMenuBar( wxMenuBar *menuBar ) void wxFrame::SetMenuBar( wxMenuBar *menuBar )
{ {
@@ -951,50 +888,17 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar )
m_sizeSet = FALSE; 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 #if wxUSE_TOOLBAR
wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name ) wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name )
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
wxCHECK_MSG( m_frameToolBar == NULL, FALSE, wxT("recreating toolbar in wxFrame") );
m_insertInClientArea = FALSE; 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; m_insertInClientArea = TRUE;
@@ -1003,14 +907,10 @@ wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& na
return m_frameToolBar; 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) void wxFrame::SetToolBar(wxToolBar *toolbar)
{ {
m_frameToolBar = toolbar; wxFrameBase::SetToolBar(toolbar);
if (m_frameToolBar) if (m_frameToolBar)
{ {
/* insert into toolbar area if not already there */ /* 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 #endif // wxUSE_TOOLBAR
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name )
wxStatusBar* wxFrame::CreateStatusBar(int number,
long style,
wxWindowID id,
const wxString& name)
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, wxT("recreating status bar in wxFrame") ); // because it will change when toolbar is added
m_frameStatusBar = OnCreateStatusBar( number, style, id, name );
m_sizeSet = FALSE; m_sizeSet = FALSE;
return m_frameStatusBar; return wxFrameBase::CreateStatusBar( number, style, id, name );
} }
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)
{
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 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 #endif // wxUSE_STATUSBAR
void wxFrame::Command( int id ) // ----------------------------------------------------------------------------
{ // frame title/icon
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);
}
void wxFrame::SetTitle( const wxString &title ) void wxFrame::SetTitle( const wxString &title )
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
m_title = title; m_title = title;
if (m_title.IsNull()) m_title = wxT("");
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); 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") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
m_icon = icon; wxFrameBase::SetIcon(icon);
if (!icon.Ok()) return;
if (!m_widget->window) return; if ( !m_icon.Ok() )
return;
if (!m_widget->window)
return;
wxMask *mask = icon.GetMask(); wxMask *mask = icon.GetMask();
GdkBitmap *bm = (GdkBitmap *) NULL; 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 ); gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
} }
// ----------------------------------------------------------------------------
// frame state: maximized/iconized/normal (TODO)
// ----------------------------------------------------------------------------
void wxFrame::Maximize(bool WXUNUSED(maximize)) void wxFrame::Maximize(bool WXUNUSED(maximize))
{ {
} }
bool wxFrame::IsMaximized() const
{
return FALSE;
}
void wxFrame::Restore() void wxFrame::Restore()
{ {
} }

View File

@@ -185,7 +185,7 @@ extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll; extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor; extern wxCursor g_globalCursor;
static wxWindow *g_captureWindow = (wxWindow*) NULL; 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 // 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 // either TRUE or FALSE and an activate event will be sent during the next

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: frame.cpp // Name: msw/frame.cpp
// Purpose: wxFrame // Purpose: wxFrame
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
@@ -9,8 +9,16 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "frame.h" #pragma implementation "frame.h"
#endif #endif
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
@@ -32,46 +40,69 @@
#endif // WX_PRECOMP #endif // WX_PRECOMP
#include "wx/msw/private.h" #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/menuitem.h"
#include "wx/log.h" #include "wx/log.h"
#if wxUSE_NATIVE_STATUSBAR // ----------------------------------------------------------------------------
#include "wx/msw/statbr95.h" // globals
#endif // ----------------------------------------------------------------------------
extern wxWindowList wxModelessWindows; extern wxWindowList wxModelessWindows;
extern wxList WXDLLEXPORT wxPendingDelete; extern wxList WXDLLEXPORT wxPendingDelete;
extern wxChar wxFrameClassName[]; extern wxChar wxFrameClassName[];
extern wxMenu *wxCurrentPopupMenu; extern wxMenu *wxCurrentPopupMenu;
// ----------------------------------------------------------------------------
// event tables
// ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxFrame, wxWindow) BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
EVT_SIZE(wxFrame::OnSize)
EVT_ACTIVATE(wxFrame::OnActivate) EVT_ACTIVATE(wxFrame::OnActivate)
EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
EVT_IDLE(wxFrame::OnIdle)
EVT_CLOSE(wxFrame::OnCloseWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
#endif #endif
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// static class members
// ----------------------------------------------------------------------------
#if wxUSE_NATIVE_STATUSBAR #if wxUSE_NATIVE_STATUSBAR
bool wxFrame::m_useNativeStatusBar = TRUE; bool wxFrame::m_useNativeStatusBar = TRUE;
#else #else
bool wxFrame::m_useNativeStatusBar = FALSE; bool wxFrame::m_useNativeStatusBar = FALSE;
#endif #endif
wxFrame::wxFrame() // ----------------------------------------------------------------------------
{ // creation/destruction
m_frameToolBar = NULL ; // ----------------------------------------------------------------------------
m_frameMenuBar = NULL;
m_frameStatusBar = NULL;
void wxFrame::Init()
{
m_iconized = FALSE; m_iconized = FALSE;
#if wxUSE_TOOLTIPS
m_hwndToolTip = 0;
#endif
} }
bool wxFrame::Create(wxWindow *parent, bool wxFrame::Create(wxWindow *parent,
@@ -82,19 +113,14 @@ bool wxFrame::Create(wxWindow *parent,
long style, long style,
const wxString& name) const wxString& name)
{ {
#if wxUSE_TOOLTIPS
m_hwndToolTip = 0;
#endif
SetName(name); SetName(name);
m_windowStyle = style; m_windowStyle = style;
m_frameMenuBar = NULL; m_frameMenuBar = NULL;
m_frameToolBar = NULL ; m_frameToolBar = NULL;
m_frameStatusBar = NULL; m_frameStatusBar = NULL;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
// m_icon = NULL;
if ( id > -1 ) if ( id > -1 )
m_windowId = id; m_windowId = id;
else else
@@ -131,13 +157,7 @@ wxFrame::~wxFrame()
m_isBeingDeleted = TRUE; m_isBeingDeleted = TRUE;
wxTopLevelWindows.DeleteObject(this); wxTopLevelWindows.DeleteObject(this);
if (m_frameStatusBar) DeleteAllBars();
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()))
if (wxTheApp && (wxTopLevelWindows.Number() == 0)) if (wxTheApp && (wxTopLevelWindows.Number() == 0))
{ {
@@ -167,12 +187,14 @@ void wxFrame::DoGetClientSize(int *x, int *y) const
RECT rect; RECT rect;
::GetClientRect(GetHwnd(), &rect); ::GetClientRect(GetHwnd(), &rect);
#if wxUSE_STATUSBAR
if ( GetStatusBar() ) if ( GetStatusBar() )
{ {
int statusX, statusY; int statusX, statusY;
GetStatusBar()->GetClientSize(&statusX, &statusY); GetStatusBar()->GetClientSize(&statusX, &statusY);
rect.bottom -= statusY; rect.bottom -= statusY;
} }
#endif // wxUSE_STATUSBAR
wxPoint pt(GetClientAreaOrigin()); wxPoint pt(GetClientAreaOrigin());
rect.bottom -= pt.y; 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_width = rect2.right - rect2.left - rect.right + width;
int actual_height = rect2.bottom - rect2.top - rect.bottom + height; int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
#if wxUSE_STATUSBAR
if ( GetStatusBar() ) if ( GetStatusBar() )
{ {
int statusX, statusY; int statusX, statusY;
GetStatusBar()->GetClientSize(&statusX, &statusY); GetStatusBar()->GetClientSize(&statusX, &statusY);
actual_height += statusY; actual_height += statusY;
} }
#endif // wxUSE_STATUSBAR
wxPoint pt(GetClientAreaOrigin()); wxPoint pt(GetClientAreaOrigin());
actual_width += pt.y; actual_width += pt.y;
@@ -244,63 +268,56 @@ void wxFrame::DoGetPosition(int *x, int *y) const
*y = point.y; *y = point.y;
} }
// ----------------------------------------------------------------------------
// variations around ::ShowWindow()
// ----------------------------------------------------------------------------
void wxFrame::DoShowWindow(int nShowCmd)
{
::ShowWindow(GetHwnd(), nShowCmd);
m_iconized = nShowCmd == SW_MINIMIZE;
}
bool wxFrame::Show(bool show) bool wxFrame::Show(bool show)
{ {
int cshow; DoShowWindow(show ? SW_SHOW : SW_HIDE);
if (show)
cshow = SW_SHOW;
else
cshow = SW_HIDE;
if (!show) if ( show )
{ {
// Try to highlight the correct window (the parent) ::BringWindowToTop(GetHwnd());
HWND hWndParent = 0;
if (GetParent())
{
hWndParent = (HWND) GetParent()->GetHWND();
if (hWndParent)
::BringWindowToTop(hWndParent);
}
}
ShowWindow(GetHwnd(), (BOOL)cshow);
if (show)
{
BringWindowToTop(GetHwnd());
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_windowId); wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_windowId);
event.SetEventObject( this ); event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
} }
else
{
// Try to highlight the correct window (the parent)
if ( GetParent() )
{
HWND hWndParent = GetHwndOf(GetParent());
if (hWndParent)
::BringWindowToTop(hWndParent);
}
}
return TRUE; return TRUE;
} }
void wxFrame::Iconize(bool iconize) void wxFrame::Iconize(bool iconize)
{ {
if (!iconize) DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE);
Show(TRUE);
int cshow;
if (iconize)
cshow = SW_MINIMIZE;
else
cshow = SW_RESTORE;
ShowWindow(GetHwnd(), (BOOL)cshow);
m_iconized = iconize;
} }
// Equivalent to maximize/restore in Windows
void wxFrame::Maximize(bool maximize) void wxFrame::Maximize(bool maximize)
{ {
Show(TRUE); DoShowWindow(maximize ? SW_MAXIMIZE : SW_RESTORE);
int cshow; }
if (maximize)
cshow = SW_MAXIMIZE; void wxFrame::Restore()
else {
cshow = SW_RESTORE; DoShowWindow(SW_RESTORE);
ShowWindow(GetHwnd(), cshow);
m_iconized = FALSE;
} }
bool wxFrame::IsIconized() const bool wxFrame::IsIconized() const
@@ -312,89 +329,48 @@ bool wxFrame::IsIconized() const
// Is it maximized? // Is it maximized?
bool wxFrame::IsMaximized() const bool wxFrame::IsMaximized() const
{ {
return (::IsZoomed(GetHwnd()) != 0) ; return (::IsZoomed(GetHwnd()) != 0);
} }
void wxFrame::SetIcon(const wxIcon& icon) void wxFrame::SetIcon(const wxIcon& icon)
{ {
m_icon = icon; wxFrameBase::SetIcon(icon);
#if defined(__WIN95__) #if defined(__WIN95__)
if ( m_icon.Ok() ) if ( m_icon.Ok() )
{
SendMessage(GetHwnd(), WM_SETICON, SendMessage(GetHwnd(), WM_SETICON,
(WPARAM)TRUE, (LPARAM)(HICON) m_icon.GetHICON()); (WPARAM)TRUE, (LPARAM)(HICON) m_icon.GetHICON());
#endif }
#endif // __WIN95__
} }
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id, wxStatusBar *wxFrame::OnCreateStatusBar(int number,
long style,
wxWindowID id,
const wxString& name) const wxString& name)
{ {
wxStatusBar *statusBar = NULL; wxStatusBar *statusBar = NULL;
#if wxUSE_NATIVE_STATUSBAR #if wxUSE_NATIVE_STATUSBAR
if (UsesNativeStatusBar()) if ( UsesNativeStatusBar() )
{ {
statusBar = new wxStatusBar95(this, id, style); statusBar = new wxStatusBar95(this, id, style);
} }
else else
#endif #endif
{ {
statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20), statusBar = wxFrameBase::OnCreateStatusBar(number, style, id, name);
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; 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();
}
void wxFrame::PositionStatusBar() void wxFrame::PositionStatusBar()
{ {
// native status bar positions itself // native status bar positions itself
if (m_frameStatusBar if ( m_frameStatusBar
#if wxUSE_NATIVE_STATUSBAR #if wxUSE_NATIVE_STATUSBAR
&& !m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)) && !m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95))
#endif #endif
@@ -546,53 +522,6 @@ bool wxFrame::MSWCreate(int id, wxWindow *parent, const wxChar *wclass, wxWindow
return TRUE; 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 // Default activation behaviour - set the focus for the first child
// subwindow found. // subwindow found.
void wxFrame::OnActivate(wxActivateEvent& event) 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) // 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
Destroy(); // frame contents
} // ----------------------------------------------------------------------------
// 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);
}
// Checks if there is a toolbar, and returns the first free client position // Checks if there is a toolbar, and returns the first free client position
wxPoint wxFrame::GetClientAreaOrigin() const wxPoint wxFrame::GetClientAreaOrigin() const
@@ -728,28 +602,20 @@ void wxFrame::DoClientToScreen(int *x, int *y) const
wxWindow::DoClientToScreen(x, y); wxWindow::DoClientToScreen(x, y);
} }
// ----------------------------------------------------------------------------
// tool/status bar stuff
// ----------------------------------------------------------------------------
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
{ {
wxCHECK_MSG( m_frameToolBar == NULL, FALSE, if ( wxFrameBase::CreateToolBar(style, id, name) )
wxT("recreating toolbar in wxFrame") );
wxToolBar* toolBar = OnCreateToolBar(style, id, name);
if (toolBar)
{ {
SetToolBar(toolBar);
PositionToolBar(); PositionToolBar();
return toolBar;
} }
else
{
return NULL;
}
}
wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name) return m_frameToolBar;
{
return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name);
} }
void wxFrame::PositionToolBar() void wxFrame::PositionToolBar()
@@ -757,32 +623,39 @@ void wxFrame::PositionToolBar()
RECT rect; RECT rect;
::GetClientRect(GetHwnd(), &rect); ::GetClientRect(GetHwnd(), &rect);
#if wxUSE_STATUSBAR
if ( GetStatusBar() ) if ( GetStatusBar() )
{ {
int statusX, statusY; int statusX, statusY;
GetStatusBar()->GetClientSize(&statusX, &statusY); GetStatusBar()->GetClientSize(&statusX, &statusY);
rect.bottom -= statusY; rect.bottom -= statusY;
} }
#endif // wxUSE_STATUSBAR
if (GetToolBar()) if ( GetToolBar() )
{ {
int tw, th; 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 th = rect.bottom;
GetToolBar()->SetSize(0, 0, tw, rect.bottom, wxSIZE_NO_ADJUSTMENTS);
} }
else else
{ {
// Use the 'real' MSW position tw = rect.right;
GetToolBar()->SetSize(0, 0, rect.right, th, wxSIZE_NO_ADJUSTMENTS);
} }
// Use the 'real' MSW position here
GetToolBar()->SetSize(0, 0, tw, th, wxSIZE_NO_ADJUSTMENTS);
} }
} }
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
// ----------------------------------------------------------------------------
// frame state (iconized/maximized/...)
// ----------------------------------------------------------------------------
// propagate our state change to all child frames: this allows us to emulate X // 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 // Windows behaviour where child frames float independently of the parent one
// on the desktop, but are iconized/restored with it // 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 // message processing
// =========================================================================== // ===========================================================================

View File

@@ -35,7 +35,9 @@
#include "wx/app.h" #include "wx/app.h"
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/dialog.h" #include "wx/dialog.h"
#if wxUSE_STATUSBAR
#include "wx/statusbr.h" #include "wx/statusbr.h"
#endif
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/log.h" #include "wx/log.h"
@@ -44,10 +46,14 @@
#include "wx/mdi.h" #include "wx/mdi.h"
#include "wx/msw/private.h" #include "wx/msw/private.h"
#if wxUSE_NATIVE_STATUSBAR #if wxUSE_STATUSBAR && wxUSE_NATIVE_STATUSBAR
#include "wx/msw/statbr95.h" #include "wx/msw/statbr95.h"
#endif #endif
#if wxUSE_TOOLBAR
#include "wx/toolbar.h"
#endif // wxUSE_TOOLBAR
#include <string.h> #include <string.h>
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -95,7 +95,7 @@ static void wxMapBitmap(HBITMAP hBitmap, int width, int height);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxToolBar95, wxToolBarBase) IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
#endif #endif
BEGIN_EVENT_TABLE(wxToolBar95, wxToolBarBase) BEGIN_EVENT_TABLE(wxToolBar95, wxToolBarBase)

View File

@@ -56,7 +56,7 @@
#endif #endif
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxToolBarMSW, wxToolBarBase) IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
BEGIN_EVENT_TABLE(wxToolBarMSW, wxToolBarBase) BEGIN_EVENT_TABLE(wxToolBarMSW, wxToolBarBase)
EVT_SIZE(wxToolBarMSW::OnSize) EVT_SIZE(wxToolBarMSW::OnSize)