wxTopLevelWindow (only for wxGTK for now)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11612 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
280df08533
commit
7d9f12f3b9
@ -17,14 +17,23 @@
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/panel.h"
|
||||
#include "wx/containr.h"
|
||||
#include "wx/toplevel.h"
|
||||
|
||||
// FIXME - temporary hack in absence of wxTLW !!
|
||||
#ifndef wxTopLevelWindowNative
|
||||
#include "wx/panel.h"
|
||||
class WXDLLEXPORT wxDialogBase : public wxPanel
|
||||
#else
|
||||
class WXDLLEXPORT wxDialogBase : public wxTopLevelWindow
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
#ifdef __DARWIN__
|
||||
~wxDialogBase() { }
|
||||
#endif
|
||||
wxDialogBase() { Init(); }
|
||||
~wxDialogBase() {}
|
||||
|
||||
void Init();
|
||||
|
||||
// the modal dialogs have a return code - usually the id of the last
|
||||
// pressed button
|
||||
void SetReturnCode(int returnCode) { m_returnCode = returnCode; }
|
||||
@ -44,17 +53,22 @@ public:
|
||||
protected:
|
||||
// the return code from modal dialog
|
||||
int m_returnCode;
|
||||
|
||||
// FIXME - temporary hack in absence of wxTLW !!
|
||||
#ifdef wxTopLevelWindowNative
|
||||
DECLARE_EVENT_TABLE()
|
||||
WX_DECLARE_CONTROL_CONTAINER();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/dialog.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/dialog.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/dialog.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/dialog.h"
|
||||
// FIXME_MGL -- belongs to wxUniv
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/dialog.h"
|
||||
#elif defined(__WXPM__)
|
||||
|
@ -20,8 +20,7 @@
|
||||
#pragma interface "framebase.h"
|
||||
#endif
|
||||
|
||||
#include "wx/window.h" // the base class
|
||||
#include "wx/icon.h" // for m_icon
|
||||
#include "wx/toplevel.h" // the base class
|
||||
|
||||
// the default names for various classs
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
|
||||
@ -33,14 +32,6 @@ class WXDLLEXPORT wxMenuBar;
|
||||
class WXDLLEXPORT wxStatusBar;
|
||||
class WXDLLEXPORT wxToolBar;
|
||||
|
||||
// Styles for ShowFullScreen
|
||||
#define wxFULLSCREEN_NOMENUBAR 0x01
|
||||
#define wxFULLSCREEN_NOTOOLBAR 0x02
|
||||
#define wxFULLSCREEN_NOSTATUSBAR 0x04
|
||||
#define wxFULLSCREEN_NOBORDER 0x08
|
||||
#define wxFULLSCREEN_NOCAPTION 0x10
|
||||
#define wxFULLSCREEN_ALL (wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR | wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFrame is a top-level window with optional menubar, statusbar and toolbar
|
||||
//
|
||||
@ -53,7 +44,12 @@ class WXDLLEXPORT wxToolBar;
|
||||
// CreateXXXBar() is called.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFrameBase : public wxWindow
|
||||
// FIXME - temporary hack in absence of wxTLW !!
|
||||
#ifndef wxTopLevelWindowNative
|
||||
class WXDLLEXPORT wxFrameBase : public wxTopLevelWindowBase
|
||||
#else
|
||||
class WXDLLEXPORT wxFrameBase : public wxTopLevelWindow
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
// construction
|
||||
@ -73,30 +69,6 @@ public:
|
||||
// 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);
|
||||
|
||||
// get the origin of the client area (which may be different from (0, 0)
|
||||
// if the frame has a toolbar) in client coordinates
|
||||
virtual wxPoint GetClientAreaOrigin() const;
|
||||
@ -157,27 +129,12 @@ public:
|
||||
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)) { }
|
||||
|
||||
#if wxUSE_MENUS
|
||||
// send wxUpdateUIEvents for all menu items (called from OnIdle())
|
||||
@ -231,17 +188,6 @@ protected:
|
||||
wxToolBar *m_frameToolBar;
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
// the frame client to screen translation should take account of the
|
||||
// toolbar which may shift the origin of the client area
|
||||
virtual void DoClientToScreen(int *x, int *y) const;
|
||||
virtual void DoScreenToClient(int *x, int *y) const;
|
||||
|
||||
// send the iconize event, return TRUE if processed
|
||||
bool SendIconizeEvent(bool iconized = TRUE);
|
||||
|
||||
// the frame icon
|
||||
wxIcon m_icon;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
@ -16,8 +16,6 @@
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/panel.h"
|
||||
#include "wx/icon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// classes
|
||||
@ -51,63 +49,32 @@ public:
|
||||
const wxSize &size = wxDefaultSize,
|
||||
long style = wxDEFAULT_DIALOG_STYLE,
|
||||
const wxString &name = wxDialogNameStr );
|
||||
~wxDialog();
|
||||
|
||||
void SetTitle(const wxString& title);
|
||||
wxString GetTitle() const;
|
||||
~wxDialog() {}
|
||||
|
||||
void OnApply( wxCommandEvent &event );
|
||||
void OnCancel( wxCommandEvent &event );
|
||||
void OnOK( wxCommandEvent &event );
|
||||
void OnPaint( wxPaintEvent& event );
|
||||
void OnSize( wxSizeEvent &event );
|
||||
void OnCloseWindow( wxCloseEvent& event );
|
||||
/*
|
||||
void OnCharHook( wxKeyEvent& event );
|
||||
*/
|
||||
|
||||
bool Destroy();
|
||||
|
||||
virtual bool Show( bool show = TRUE );
|
||||
virtual int ShowModal();
|
||||
virtual void EndModal( int retCode );
|
||||
virtual bool IsModal() const;
|
||||
void SetModal( bool modal );
|
||||
|
||||
virtual void SetIcon( const wxIcon &icon );
|
||||
virtual void Iconize( bool WXUNUSED(iconize)) { }
|
||||
virtual bool IsIconized() const { return FALSE; }
|
||||
bool Iconized() const { return IsIconized(); }
|
||||
virtual void Maximize() { }
|
||||
virtual void Restore() { }
|
||||
|
||||
virtual bool IsTopLevel() const { return TRUE; }
|
||||
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
// move the window to the specified location and resize it: this is called
|
||||
// from both DoSetSize() and DoSetClientSize()
|
||||
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||
|
||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||
virtual void OnInternalIdle();
|
||||
|
||||
bool m_modalShowing;
|
||||
wxString m_title;
|
||||
wxIcon m_icon;
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// common part of Destroy() and ~wxDialog
|
||||
void CleanUp();
|
||||
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxDialog)
|
||||
|
@ -58,18 +58,6 @@ public:
|
||||
|
||||
virtual ~wxFrameGTK();
|
||||
|
||||
// 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 bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
|
||||
virtual bool IsFullScreen() const { return m_fsIsShowing; };
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
virtual void PositionStatusBar();
|
||||
|
||||
@ -86,47 +74,21 @@ public:
|
||||
void SetToolBar(wxToolBar *toolbar);
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
virtual bool Show(bool show = TRUE);
|
||||
|
||||
virtual void SetTitle( const wxString &title );
|
||||
virtual wxString GetTitle() const { return m_title; }
|
||||
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
// move the window to the specified location and resize it: this is called
|
||||
// from both DoSetSize() and DoSetClientSize()
|
||||
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||
|
||||
// GTK callbacks
|
||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||
virtual void OnInternalIdle();
|
||||
|
||||
// do *not* call this to iconize the frame, this is a private function!
|
||||
void SetIconizeState(bool iconic);
|
||||
|
||||
wxString m_title;
|
||||
int m_miniEdge,
|
||||
m_miniTitle;
|
||||
GtkWidget *m_mainWidget;
|
||||
bool m_menuBarDetached;
|
||||
bool m_toolBarDetached;
|
||||
bool m_insertInClientArea; /* not from within OnCreateXXX */
|
||||
|
||||
bool m_fsIsShowing; /* full screen */
|
||||
long m_fsSaveStyle;
|
||||
long m_fsSaveFlag;
|
||||
wxRect m_fsSaveFrame;
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// override wxWindow methods to take into account tool/menu/statusbars
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
|
||||
virtual void DoSetClientSize(int width, int height);
|
||||
virtual void DoGetClientSize( int *width, int *height ) const;
|
||||
|
||||
@ -134,9 +96,6 @@ protected:
|
||||
virtual void DetachMenuBar();
|
||||
virtual void AttachMenuBar(wxMenuBar *menubar);
|
||||
#endif // wxUSE_MENUS_NATIVE
|
||||
|
||||
// is the frame currently iconized?
|
||||
bool m_isIconized;
|
||||
};
|
||||
|
||||
#endif // __GTKFRAMEH__
|
||||
|
108
include/wx/gtk/toplevel.h
Normal file
108
include/wx/gtk/toplevel.h
Normal file
@ -0,0 +1,108 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/gtk/toplevel.h
|
||||
// Purpose:
|
||||
// Author: Robert Roebling
|
||||
// Id: $Id$
|
||||
// Copyright: (c) 1998 Robert Roebling, Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef __GTKTOPLEVELH__
|
||||
#define __GTKTOPLEVELH__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "toplevel.h"
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxTopLevelWindowGTK
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxTopLevelWindowGTK : public wxTopLevelWindowBase
|
||||
{
|
||||
public:
|
||||
// construction
|
||||
wxTopLevelWindowGTK() { Init(); }
|
||||
wxTopLevelWindowGTK(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_FRAME_STYLE,
|
||||
const wxString& name = wxFrameNameStr)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(parent, id, title, pos, size, style, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_FRAME_STYLE,
|
||||
const wxString& name = wxFrameNameStr);
|
||||
|
||||
virtual ~wxTopLevelWindowGTK();
|
||||
|
||||
// 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 Restore();
|
||||
|
||||
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
|
||||
virtual bool IsFullScreen() const { return m_fsIsShowing; };
|
||||
|
||||
virtual bool Show(bool show = TRUE);
|
||||
|
||||
virtual void SetTitle( const wxString &title );
|
||||
virtual wxString GetTitle() const { return m_title; }
|
||||
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
// move the window to the specified location and resize it: this is called
|
||||
// from both DoSetSize() and DoSetClientSize()
|
||||
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||
|
||||
// GTK callbacks
|
||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||
virtual void OnInternalIdle();
|
||||
|
||||
// do *not* call this to iconize the frame, this is a private function!
|
||||
void SetIconizeState(bool iconic);
|
||||
|
||||
wxString m_title;
|
||||
int m_miniEdge,
|
||||
m_miniTitle;
|
||||
GtkWidget *m_mainWidget;
|
||||
bool m_insertInClientArea; /* not from within OnCreateXXX */
|
||||
|
||||
bool m_fsIsShowing; /* full screen */
|
||||
long m_fsSaveStyle;
|
||||
long m_fsSaveFlag;
|
||||
wxRect m_fsSaveFrame;
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// override wxWindow methods to take into account tool/menu/statusbars
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
|
||||
virtual void DoSetClientSize(int width, int height);
|
||||
virtual void DoGetClientSize( int *width, int *height ) const;
|
||||
|
||||
// is the frame currently iconized?
|
||||
bool m_isIconized;
|
||||
};
|
||||
|
||||
#endif // __GTKTOPLEVELH__
|
@ -16,8 +16,6 @@
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/panel.h"
|
||||
#include "wx/icon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// classes
|
||||
@ -51,63 +49,32 @@ public:
|
||||
const wxSize &size = wxDefaultSize,
|
||||
long style = wxDEFAULT_DIALOG_STYLE,
|
||||
const wxString &name = wxDialogNameStr );
|
||||
~wxDialog();
|
||||
|
||||
void SetTitle(const wxString& title);
|
||||
wxString GetTitle() const;
|
||||
~wxDialog() {}
|
||||
|
||||
void OnApply( wxCommandEvent &event );
|
||||
void OnCancel( wxCommandEvent &event );
|
||||
void OnOK( wxCommandEvent &event );
|
||||
void OnPaint( wxPaintEvent& event );
|
||||
void OnSize( wxSizeEvent &event );
|
||||
void OnCloseWindow( wxCloseEvent& event );
|
||||
/*
|
||||
void OnCharHook( wxKeyEvent& event );
|
||||
*/
|
||||
|
||||
bool Destroy();
|
||||
|
||||
virtual bool Show( bool show = TRUE );
|
||||
virtual int ShowModal();
|
||||
virtual void EndModal( int retCode );
|
||||
virtual bool IsModal() const;
|
||||
void SetModal( bool modal );
|
||||
|
||||
virtual void SetIcon( const wxIcon &icon );
|
||||
virtual void Iconize( bool WXUNUSED(iconize)) { }
|
||||
virtual bool IsIconized() const { return FALSE; }
|
||||
bool Iconized() const { return IsIconized(); }
|
||||
virtual void Maximize() { }
|
||||
virtual void Restore() { }
|
||||
|
||||
virtual bool IsTopLevel() const { return TRUE; }
|
||||
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
// move the window to the specified location and resize it: this is called
|
||||
// from both DoSetSize() and DoSetClientSize()
|
||||
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||
|
||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||
virtual void OnInternalIdle();
|
||||
|
||||
bool m_modalShowing;
|
||||
wxString m_title;
|
||||
wxIcon m_icon;
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// common part of Destroy() and ~wxDialog
|
||||
void CleanUp();
|
||||
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxDialog)
|
||||
|
@ -58,18 +58,6 @@ public:
|
||||
|
||||
virtual ~wxFrameGTK();
|
||||
|
||||
// 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 bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
|
||||
virtual bool IsFullScreen() const { return m_fsIsShowing; };
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
virtual void PositionStatusBar();
|
||||
|
||||
@ -86,47 +74,21 @@ public:
|
||||
void SetToolBar(wxToolBar *toolbar);
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
virtual bool Show(bool show = TRUE);
|
||||
|
||||
virtual void SetTitle( const wxString &title );
|
||||
virtual wxString GetTitle() const { return m_title; }
|
||||
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
// move the window to the specified location and resize it: this is called
|
||||
// from both DoSetSize() and DoSetClientSize()
|
||||
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||
|
||||
// GTK callbacks
|
||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||
virtual void OnInternalIdle();
|
||||
|
||||
// do *not* call this to iconize the frame, this is a private function!
|
||||
void SetIconizeState(bool iconic);
|
||||
|
||||
wxString m_title;
|
||||
int m_miniEdge,
|
||||
m_miniTitle;
|
||||
GtkWidget *m_mainWidget;
|
||||
bool m_menuBarDetached;
|
||||
bool m_toolBarDetached;
|
||||
bool m_insertInClientArea; /* not from within OnCreateXXX */
|
||||
|
||||
bool m_fsIsShowing; /* full screen */
|
||||
long m_fsSaveStyle;
|
||||
long m_fsSaveFlag;
|
||||
wxRect m_fsSaveFrame;
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// override wxWindow methods to take into account tool/menu/statusbars
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
|
||||
virtual void DoSetClientSize(int width, int height);
|
||||
virtual void DoGetClientSize( int *width, int *height ) const;
|
||||
|
||||
@ -134,9 +96,6 @@ protected:
|
||||
virtual void DetachMenuBar();
|
||||
virtual void AttachMenuBar(wxMenuBar *menubar);
|
||||
#endif // wxUSE_MENUS_NATIVE
|
||||
|
||||
// is the frame currently iconized?
|
||||
bool m_isIconized;
|
||||
};
|
||||
|
||||
#endif // __GTKFRAMEH__
|
||||
|
108
include/wx/gtk1/toplevel.h
Normal file
108
include/wx/gtk1/toplevel.h
Normal file
@ -0,0 +1,108 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/gtk/toplevel.h
|
||||
// Purpose:
|
||||
// Author: Robert Roebling
|
||||
// Id: $Id$
|
||||
// Copyright: (c) 1998 Robert Roebling, Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef __GTKTOPLEVELH__
|
||||
#define __GTKTOPLEVELH__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "toplevel.h"
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxTopLevelWindowGTK
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxTopLevelWindowGTK : public wxTopLevelWindowBase
|
||||
{
|
||||
public:
|
||||
// construction
|
||||
wxTopLevelWindowGTK() { Init(); }
|
||||
wxTopLevelWindowGTK(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_FRAME_STYLE,
|
||||
const wxString& name = wxFrameNameStr)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(parent, id, title, pos, size, style, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_FRAME_STYLE,
|
||||
const wxString& name = wxFrameNameStr);
|
||||
|
||||
virtual ~wxTopLevelWindowGTK();
|
||||
|
||||
// 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 Restore();
|
||||
|
||||
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
|
||||
virtual bool IsFullScreen() const { return m_fsIsShowing; };
|
||||
|
||||
virtual bool Show(bool show = TRUE);
|
||||
|
||||
virtual void SetTitle( const wxString &title );
|
||||
virtual wxString GetTitle() const { return m_title; }
|
||||
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
// move the window to the specified location and resize it: this is called
|
||||
// from both DoSetSize() and DoSetClientSize()
|
||||
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||
|
||||
// GTK callbacks
|
||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||
virtual void OnInternalIdle();
|
||||
|
||||
// do *not* call this to iconize the frame, this is a private function!
|
||||
void SetIconizeState(bool iconic);
|
||||
|
||||
wxString m_title;
|
||||
int m_miniEdge,
|
||||
m_miniTitle;
|
||||
GtkWidget *m_mainWidget;
|
||||
bool m_insertInClientArea; /* not from within OnCreateXXX */
|
||||
|
||||
bool m_fsIsShowing; /* full screen */
|
||||
long m_fsSaveStyle;
|
||||
long m_fsSaveFlag;
|
||||
wxRect m_fsSaveFrame;
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// override wxWindow methods to take into account tool/menu/statusbars
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
|
||||
virtual void DoSetClientSize(int width, int height);
|
||||
virtual void DoGetClientSize( int *width, int *height ) const;
|
||||
|
||||
// is the frame currently iconized?
|
||||
bool m_isIconized;
|
||||
};
|
||||
|
||||
#endif // __GTKTOPLEVELH__
|
84
include/wx/mgl/toplevel.h
Normal file
84
include/wx/mgl/toplevel.h
Normal file
@ -0,0 +1,84 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/mgl/toplevel.h
|
||||
// Purpose: Top level window, abstraction of wxFrame and wxDialog
|
||||
// Author: Vaclav Slavik
|
||||
// Id: $Id$
|
||||
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef __WX_TOPLEVEL_H__
|
||||
#define __WX_TOPLEVEL_H__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "toplevel.h"
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxTopLevelWindowMGL
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxTopLevelWindowMGL : public wxTopLevelWindowBase
|
||||
{
|
||||
public:
|
||||
// construction
|
||||
wxTopLevelWindowMGL() { Init(); }
|
||||
wxTopLevelWindowMGL(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_FRAME_STYLE,
|
||||
const wxString& name = wxFrameNameStr)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(parent, id, title, pos, size, style, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_FRAME_STYLE,
|
||||
const wxString& name = wxFrameNameStr);
|
||||
|
||||
virtual ~wxTopLevelWindowMGL();
|
||||
|
||||
// implement base class pure virtuals
|
||||
virtual void Maximize(bool maximize = TRUE);
|
||||
virtual bool IsMaximized() const;
|
||||
virtual void Iconize(bool iconize = TRUE);
|
||||
virtual bool IsIconized() const;
|
||||
virtual void Restore();
|
||||
|
||||
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
|
||||
virtual bool IsFullScreen() const { return m_fsIsShowing; }
|
||||
|
||||
virtual void SetTitle(const wxString &title) { m_title = title; }
|
||||
virtual wxString GetTitle() const { return m_title; }
|
||||
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
wxString m_title;
|
||||
bool m_fsIsShowing; /* full screen */
|
||||
long m_fsSaveStyle;
|
||||
long m_fsSaveFlag;
|
||||
wxRect m_fsSaveFrame;
|
||||
|
||||
// is the frame currently iconized?
|
||||
bool m_isIconized;
|
||||
// and maximized?
|
||||
bool m_isMaximized;
|
||||
wxRect m_savedFrame;
|
||||
};
|
||||
|
||||
#endif // __WX_TOPLEVEL_H__
|
@ -2,33 +2,163 @@
|
||||
// Name: wx/toplevel.h
|
||||
// Purpose: declares wxTopLevelWindow class, the base class for all
|
||||
// top level windows (such as frames and dialogs)
|
||||
// Author: Vadim Zeitlin
|
||||
// Author: Vadim Zeitlin, Vaclav Slavik
|
||||
// Modified by:
|
||||
// Created: 06.08.01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Vaclav Slavik <vaclav@wxwindows.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TOPLEVEL_H_
|
||||
#define _WX_TOPLEVEL_H_
|
||||
#ifndef _WX_TOPLEVEL_BASE_H_
|
||||
#define _WX_TOPLEVEL_BASE_H_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "toplevelbase.h"
|
||||
#endif
|
||||
|
||||
#include "wx/window.h"
|
||||
#include "wx/icon.h"
|
||||
|
||||
// the default names for various classs
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
|
||||
|
||||
class WXDLLEXPORT wxTopLevelWindowBase;
|
||||
|
||||
// Dialogs are created in a special way
|
||||
#define wxTLW_EX_DIALOG 0x00000008
|
||||
|
||||
// Styles for ShowFullScreen
|
||||
// (note that wxTopLevelWindow only handles wxFULLSCREEN_NOBORDER and
|
||||
// wxFULLSCREEN_NOCAPTION; the rest is handled by wxTopLevelWindow)
|
||||
#define wxFULLSCREEN_NOMENUBAR 0x01
|
||||
#define wxFULLSCREEN_NOTOOLBAR 0x02
|
||||
#define wxFULLSCREEN_NOSTATUSBAR 0x04
|
||||
#define wxFULLSCREEN_NOBORDER 0x08
|
||||
#define wxFULLSCREEN_NOCAPTION 0x10
|
||||
#define wxFULLSCREEN_ALL (wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR | wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTopLevelWindow: a top level (as opposed to child) window
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxTopLevelWindow : public wxWindow
|
||||
class WXDLLEXPORT wxTopLevelWindowBase : public wxWindow
|
||||
{
|
||||
public:
|
||||
// construction
|
||||
wxTopLevelWindowBase();
|
||||
|
||||
// top level wnd 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; }
|
||||
|
||||
/*
|
||||
for now we already have them in wxWindow, but this is wrong: these
|
||||
methods really only make sense for wxTopLevelWindow!
|
||||
|
||||
virtual void SetTitle( const wxString& title) = 0;
|
||||
virtual void SetTitle(const wxString& title) = 0;
|
||||
virtual wxString GetTitle() const = 0;
|
||||
*/
|
||||
|
||||
// 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 OnCloseWindow(wxCloseEvent& 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)) { }
|
||||
|
||||
protected:
|
||||
// the frame client to screen translation should take account of the
|
||||
// toolbar which may shift the origin of the client area
|
||||
virtual void DoClientToScreen(int *x, int *y) const;
|
||||
virtual void DoScreenToClient(int *x, int *y) const;
|
||||
|
||||
// send the iconize event, return TRUE if processed
|
||||
bool SendIconizeEvent(bool iconized = TRUE);
|
||||
|
||||
// the frame icon
|
||||
wxIcon m_icon;
|
||||
|
||||
// test whether this window makes part of the frame
|
||||
// (menubar, toolbar and statusbar are excluded from automatic layout)
|
||||
virtual bool IsOneOfBars(const wxWindow *WXUNUSED(win)) const { return FALSE; }
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif // _WX_TOPLEVEL_H_
|
||||
|
||||
// include the real class declaration
|
||||
#if defined(__WXGTK__)
|
||||
#include "wx/gtk/toplevel.h"
|
||||
#define wxTopLevelWindowNative wxTopLevelWindowGTK
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/toplevel.h"
|
||||
#define wxTopLevelWindowNative wxTopLevelWindowMGL
|
||||
#endif
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
#include "wx/univ/toplevel.h"
|
||||
#else // !__WXUNIVERSAL__
|
||||
#ifdef wxTopLevelWindowNative
|
||||
class WXDLLEXPORT wxTopLevelWindow : public wxTopLevelWindowNative
|
||||
{
|
||||
public:
|
||||
// construction
|
||||
wxTopLevelWindow() { Init(); }
|
||||
wxTopLevelWindow(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_FRAME_STYLE,
|
||||
const wxString& name = wxFrameNameStr)
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, title, pos, size, style, name);
|
||||
}
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxTopLevelWindow)
|
||||
};
|
||||
#endif // wxTopLevelWindowNative
|
||||
#endif // __WXUNIVERSAL__/!__WXUNIVERSAL__
|
||||
|
||||
|
||||
#endif // _WX_TOPLEVEL_BASE_H_
|
||||
|
0
include/wx/univ/toplevel.h
Normal file
0
include/wx/univ/toplevel.h
Normal file
@ -37,12 +37,31 @@
|
||||
#include "wx/stattext.h"
|
||||
#include "wx/sizer.h"
|
||||
#include "wx/button.h"
|
||||
#include "wx/containr.h"
|
||||
#endif
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// wxDialogBase
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
// FIXME - temporary hack in absence of wxtopLevelWindow, should be always used
|
||||
#ifdef wxTopLevelWindowNative
|
||||
BEGIN_EVENT_TABLE(wxDialogBase, wxTopLevelWindow)
|
||||
WX_EVENT_TABLE_CONTROL_CONTAINER(wxDialogBase)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
WX_DELEGATE_TO_CONTROL_CONTAINER(wxDialogBase)
|
||||
#endif
|
||||
|
||||
void wxDialogBase::Init()
|
||||
{
|
||||
m_returnCode = 0;
|
||||
#ifdef wxTopLevelWindowNative // FIXME - temporary hack, should be always used!
|
||||
m_container.SetContainerWindow(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if wxUSE_STATTEXT && wxUSE_TEXTCTRL
|
||||
|
||||
wxSizer *wxDialogBase::CreateTextSizer( const wxString &message )
|
||||
|
@ -41,15 +41,18 @@
|
||||
#include "wx/statusbr.h"
|
||||
#endif
|
||||
|
||||
// FIXME - temporary hack in absence of wxTLW in all ports!
|
||||
#ifndef wxTopLevelWindowNative
|
||||
#define wxTopLevelWindow wxTopLevelWindowBase
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event table
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_EVENT_TABLE(wxFrameBase, wxWindow)
|
||||
BEGIN_EVENT_TABLE(wxFrameBase, wxTopLevelWindow)
|
||||
EVT_IDLE(wxFrameBase::OnIdle)
|
||||
EVT_CLOSE(wxFrameBase::OnCloseWindow)
|
||||
EVT_MENU_HIGHLIGHT_ALL(wxFrameBase::OnMenuHighlight)
|
||||
EVT_SIZE(wxFrameBase::OnSize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// ============================================================================
|
||||
@ -75,16 +78,6 @@ wxFrameBase::wxFrameBase()
|
||||
#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,
|
||||
@ -152,7 +145,7 @@ bool wxFrameBase::IsOneOfBars(const wxWindow *win) const
|
||||
// get the origin of the client area in the client coordinates
|
||||
wxPoint wxFrameBase::GetClientAreaOrigin() const
|
||||
{
|
||||
wxPoint pt(0, 0);
|
||||
wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin();
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
if ( GetToolBar() && GetToolBar()->IsShown() )
|
||||
@ -174,48 +167,10 @@ wxPoint wxFrameBase::GetClientAreaOrigin() const
|
||||
return pt;
|
||||
}
|
||||
|
||||
void wxFrameBase::DoScreenToClient(int *x, int *y) const
|
||||
{
|
||||
wxWindow::DoScreenToClient(x, y);
|
||||
|
||||
// We may be faking the client origin.
|
||||
// So a window that's really at (0, 30) may appear
|
||||
// (to wxWin apps) to be at (0, 0).
|
||||
wxPoint pt(GetClientAreaOrigin());
|
||||
*x -= pt.x;
|
||||
*y -= pt.y;
|
||||
}
|
||||
|
||||
void wxFrameBase::DoClientToScreen(int *x, int *y) const
|
||||
{
|
||||
// We may be faking the client origin.
|
||||
// So a window that's really at (0, 30) may appear
|
||||
// (to wxWin apps) to be at (0, 0).
|
||||
wxPoint pt1(GetClientAreaOrigin());
|
||||
*x += pt1.x;
|
||||
*y += pt1.y;
|
||||
|
||||
wxWindow::DoClientToScreen(x, y);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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)
|
||||
{
|
||||
#if wxUSE_MENUS
|
||||
@ -245,67 +200,6 @@ bool wxFrameBase::ProcessCommand(int id)
|
||||
// event handlers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// default resizing behaviour - if only ONE subwindow, resize to fill the
|
||||
// whole client area
|
||||
void wxFrameBase::OnSize(wxSizeEvent& WXUNUSED(event))
|
||||
{
|
||||
// if we're using constraints - do use them
|
||||
#if wxUSE_CONSTRAINTS
|
||||
if ( GetAutoLayout() )
|
||||
{
|
||||
Layout();
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_CONSTRAINTS
|
||||
{
|
||||
// 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() && !IsOneOfBars(win) )
|
||||
{
|
||||
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 = 1;
|
||||
#else
|
||||
static const int ofs = 0;
|
||||
#endif
|
||||
|
||||
child->SetSize(ofs, ofs, clientW - 2*ofs, clientH - 2*ofs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The default implementation for the close window event.
|
||||
void wxFrameBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void wxFrameBase::OnMenuHighlight(wxMenuEvent& event)
|
||||
{
|
||||
#if wxUSE_STATUSBAR
|
||||
@ -313,14 +207,6 @@ void wxFrameBase::OnMenuHighlight(wxMenuEvent& event)
|
||||
#endif // wxUSE_STATUSBAR
|
||||
}
|
||||
|
||||
bool wxFrameBase::SendIconizeEvent(bool iconized)
|
||||
{
|
||||
wxIconizeEvent event(GetId(), iconized);
|
||||
event.SetEventObject(this);
|
||||
|
||||
return GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
void wxFrameBase::OnIdle(wxIdleEvent& WXUNUSED(event) )
|
||||
{
|
||||
#if wxUSE_MENUS
|
||||
|
169
src/common/toplvcmn.cpp
Normal file
169
src/common/toplvcmn.cpp
Normal file
@ -0,0 +1,169 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: common/toplvcmn.cpp
|
||||
// Purpose: common (for all platforms) wxTopLevelWindow functions
|
||||
// Author: Julian Smart, Vadim Zeitlin
|
||||
// Created: 01/02/97
|
||||
// Id: $Id$
|
||||
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "toplevelbase.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/toplevel.h"
|
||||
#include "wx/dcclient.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event table
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTopLevelWindowBase, wxWindow)
|
||||
EVT_CLOSE(wxTopLevelWindowBase::OnCloseWindow)
|
||||
EVT_SIZE(wxTopLevelWindowBase::OnSize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// construction/destruction
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxTopLevelWindowBase::wxTopLevelWindowBase()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowBase::Destroy()
|
||||
{
|
||||
// delayed destruction: the frame will be deleted during the next idle
|
||||
// loop iteration
|
||||
if ( !wxPendingDelete.Member(this) )
|
||||
wxPendingDelete.Append(this);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTopLevelWindow size management: we exclude the areas taken by menu/status/toolbars
|
||||
// from the client area, so the client area is what's really available for the
|
||||
// frame contents
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowBase::DoScreenToClient(int *x, int *y) const
|
||||
{
|
||||
wxWindow::DoScreenToClient(x, y);
|
||||
|
||||
// We may be faking the client origin.
|
||||
// So a window that's really at (0, 30) may appear
|
||||
// (to wxWin apps) to be at (0, 0).
|
||||
wxPoint pt(GetClientAreaOrigin());
|
||||
*x -= pt.x;
|
||||
*y -= pt.y;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowBase::DoClientToScreen(int *x, int *y) const
|
||||
{
|
||||
// We may be faking the client origin.
|
||||
// So a window that's really at (0, 30) may appear
|
||||
// (to wxWin apps) to be at (0, 0).
|
||||
wxPoint pt1(GetClientAreaOrigin());
|
||||
*x += pt1.x;
|
||||
*y += pt1.y;
|
||||
|
||||
wxWindow::DoClientToScreen(x, y);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event handlers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// default resizing behaviour - if only ONE subwindow, resize to fill the
|
||||
// whole client area
|
||||
void wxTopLevelWindowBase::OnSize(wxSizeEvent& WXUNUSED(event))
|
||||
{
|
||||
// if we're using constraints - do use them
|
||||
#if wxUSE_CONSTRAINTS
|
||||
if ( GetAutoLayout() )
|
||||
{
|
||||
Layout();
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_CONSTRAINTS
|
||||
{
|
||||
// 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() && !IsOneOfBars(win) )
|
||||
{
|
||||
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 = 1;
|
||||
#else
|
||||
static const int ofs = 0;
|
||||
#endif
|
||||
|
||||
child->SetSize(ofs, ofs, clientW - 2*ofs, clientH - 2*ofs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The default implementation for the close window event.
|
||||
void wxTopLevelWindowBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowBase::SendIconizeEvent(bool iconized)
|
||||
{
|
||||
wxIconizeEvent event(GetId(), iconized);
|
||||
event.SetEventObject(this);
|
||||
|
||||
return GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
@ -30,201 +30,20 @@ extern void wxapp_install_idle_handler();
|
||||
extern bool g_isIdle;
|
||||
extern int g_openDialogs;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "focus" from m_window
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint gtk_dialog_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
// This disables GTK's tab traversal
|
||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus" );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "delete_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (win->IsEnabled())
|
||||
win->Close();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "size_allocate"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxDialog *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT) return;
|
||||
|
||||
if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
|
||||
{
|
||||
win->m_width = alloc->width;
|
||||
win->m_height = alloc->height;
|
||||
win->GtkUpdateSize();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "configure_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDialog *win )
|
||||
#else
|
||||
gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxDialog *win )
|
||||
#endif
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT) return FALSE;
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
gdk_window_get_root_origin( win->m_widget->window, &x, &y );
|
||||
win->m_x = x;
|
||||
win->m_y = y;
|
||||
#else
|
||||
win->m_x = event->x;
|
||||
win->m_y = event->y;
|
||||
#endif
|
||||
|
||||
wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
|
||||
mevent.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( mevent );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "realize" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* we cannot MWM hints and icons before the widget has been realized,
|
||||
so we do this directly after realization */
|
||||
|
||||
static gint
|
||||
gtk_dialog_realized_callback( GtkWidget * WXUNUSED(widget), wxDialog *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
/* all this is for Motif Window Manager "hints" and is supposed to be
|
||||
recognized by other WM as well. not tested. */
|
||||
long decor = (long) GDK_DECOR_BORDER;
|
||||
long func = (long) GDK_FUNC_MOVE ;
|
||||
|
||||
/* Some WM don't display any border around the frame contents if
|
||||
used with these hints, so we add a resize border around it,
|
||||
without automatically allowinng it to be resized though.
|
||||
|
||||
This avoids the problem, but looks odd. What shall we do?
|
||||
*/
|
||||
decor |= GDK_DECOR_RESIZEH;
|
||||
|
||||
if ((win->GetWindowStyle() & wxCAPTION) != 0)
|
||||
decor |= GDK_DECOR_TITLE;
|
||||
if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
|
||||
{
|
||||
decor |= GDK_DECOR_MENU;
|
||||
func |= GDK_FUNC_CLOSE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_MINIMIZE;
|
||||
decor |= GDK_DECOR_MINIMIZE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
|
||||
{
|
||||
decor |= GDK_DECOR_MAXIMIZE;
|
||||
func |= GDK_FUNC_MAXIMIZE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_RESIZE;
|
||||
decor |= GDK_DECOR_RESIZEH;
|
||||
}
|
||||
gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
|
||||
gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
|
||||
|
||||
/* GTK's shrinking/growing policy */
|
||||
if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
|
||||
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
|
||||
else
|
||||
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
|
||||
|
||||
/* reset the icon */
|
||||
if (win->m_icon != wxNullIcon)
|
||||
{
|
||||
wxIcon icon( win->m_icon );
|
||||
win->m_icon = wxNullIcon;
|
||||
win->SetIcon( icon );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InsertChild for wxDialog
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* Callback for wxFrame. This very strange beast has to be used because
|
||||
* C++ has no virtual methods in a constructor. We have to emulate a
|
||||
* virtual function here as wxWindows requires different ways to insert
|
||||
* a child in container classes. */
|
||||
|
||||
static void wxInsertChildInDialog( wxDialog* parent, wxWindow* child )
|
||||
{
|
||||
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
|
||||
GTK_WIDGET(child->m_widget),
|
||||
child->m_x,
|
||||
child->m_y,
|
||||
child->m_width,
|
||||
child->m_height );
|
||||
|
||||
if (parent->HasFlag(wxTAB_TRAVERSAL))
|
||||
{
|
||||
/* we now allow a window to get the focus as long as it
|
||||
doesn't have any children. */
|
||||
GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDialog
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog,wxPanel)
|
||||
BEGIN_EVENT_TABLE(wxDialog,wxDialogBase)
|
||||
EVT_BUTTON (wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_BUTTON (wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_SIZE (wxDialog::OnSize)
|
||||
EVT_CLOSE (wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxTopLevelWindow)
|
||||
|
||||
void wxDialog::Init()
|
||||
{
|
||||
@ -240,6 +59,9 @@ wxDialog::wxDialog( wxWindow *parent,
|
||||
long style, const wxString &name )
|
||||
{
|
||||
Init();
|
||||
|
||||
// all dialogs should have tab traversal enabled
|
||||
style |= wxTAB_TRAVERSAL;
|
||||
|
||||
Create( parent, id, title, pos, size, style, name );
|
||||
}
|
||||
@ -249,90 +71,9 @@ bool wxDialog::Create( wxWindow *parent,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
long style, const wxString &name )
|
||||
{
|
||||
wxTopLevelWindows.Append( this );
|
||||
SetExtraStyle(GetExtraStyle() | wxTLW_EX_DIALOG);
|
||||
|
||||
m_needParent = FALSE;
|
||||
|
||||
if (!PreCreation( parent, pos, size ) ||
|
||||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
|
||||
{
|
||||
wxFAIL_MSG( wxT("wxDialog creation failed") );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// All dialogs should really have this style
|
||||
m_windowStyle |= wxTAB_TRAVERSAL;
|
||||
|
||||
m_insertCallback = (wxInsertChildFunction) wxInsertChildInDialog;
|
||||
|
||||
m_widget = gtk_window_new( GTK_WINDOW_DIALOG );
|
||||
|
||||
if ((m_parent) && (GTK_IS_WINDOW(m_parent->m_widget)))
|
||||
gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) );
|
||||
|
||||
if (!name.IsEmpty())
|
||||
gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() );
|
||||
|
||||
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
|
||||
GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this );
|
||||
|
||||
m_wxwindow = gtk_pizza_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
|
||||
|
||||
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
|
||||
|
||||
SetTitle( title );
|
||||
|
||||
if (m_parent) m_parent->AddChild( this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
|
||||
/* we cannot set MWM hints before the widget has
|
||||
been realized, so we do this directly after realization */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
|
||||
GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
|
||||
|
||||
/* the user resized the frame by dragging etc. */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
|
||||
GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
GTK_SIGNAL_FUNC(gtk_dialog_configure_callback), (gpointer)this );
|
||||
|
||||
/* disable native tab traversal */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "focus",
|
||||
GTK_SIGNAL_FUNC(gtk_dialog_focus_callback), (gpointer)this );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
{
|
||||
CleanUp();
|
||||
|
||||
if ((wxTopLevelWindows.Number() == 0) &&
|
||||
(wxTheApp->GetExitOnFrameDelete()))
|
||||
{
|
||||
wxTheApp->ExitMainLoop();
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::SetTitle( const wxString& title )
|
||||
{
|
||||
m_title = title;
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), m_title.mbc_str() );
|
||||
}
|
||||
|
||||
wxString wxDialog::GetTitle() const
|
||||
{
|
||||
return m_title;
|
||||
return wxTopLevelWindow::Create(parent, id, title, pos, size, style, name);
|
||||
}
|
||||
|
||||
void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) )
|
||||
@ -403,187 +144,6 @@ void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
|
||||
s_closing.DeleteObject(this);
|
||||
}
|
||||
|
||||
bool wxDialog::Destroy()
|
||||
{
|
||||
// schedule the dialog for the deletion
|
||||
if ( !wxPendingDelete.Member(this) )
|
||||
{
|
||||
wxPendingDelete.Append(this);
|
||||
}
|
||||
|
||||
// don't leave a dangling pointer as the app top window, we can be deleted
|
||||
// any moment at all now!
|
||||
CleanUp();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxDialog::CleanUp()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
|
||||
if ( wxTheApp->GetTopWindow() == this )
|
||||
{
|
||||
wxTheApp->SetTopWindow( (wxWindow*) NULL );
|
||||
}
|
||||
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
}
|
||||
|
||||
void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid dialog") );
|
||||
|
||||
#if wxUSE_CONSTRAINTS
|
||||
if (GetAutoLayout())
|
||||
{
|
||||
Layout();
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_CONSTRAINTS
|
||||
{
|
||||
/* no child: go out ! */
|
||||
if (!GetChildren().First()) return;
|
||||
|
||||
/* 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))
|
||||
{
|
||||
/* it's the second one: do nothing */
|
||||
if (child) return;
|
||||
child = win;
|
||||
}
|
||||
}
|
||||
|
||||
/* yes: set it's size to fill all the frame */
|
||||
int client_x, client_y;
|
||||
GetClientSize( &client_x, &client_y );
|
||||
child->SetSize( 1, 1, client_x-2, client_y);
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
|
||||
{
|
||||
wxFAIL_MSG( wxT("DoMoveWindow called for wxDialog") );
|
||||
}
|
||||
|
||||
void wxDialog::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid dialog") );
|
||||
wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid dialog") );
|
||||
|
||||
if (m_resizing) return; /* I don't like recursions */
|
||||
m_resizing = TRUE;
|
||||
|
||||
int old_x = m_x;
|
||||
int old_y = m_y;
|
||||
|
||||
int old_width = m_width;
|
||||
int old_height = m_height;
|
||||
|
||||
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
|
||||
{
|
||||
if (x != -1) m_x = x;
|
||||
if (y != -1) m_y = y;
|
||||
if (width != -1) m_width = width;
|
||||
if (height != -1) m_height = height;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
}
|
||||
|
||||
/*
|
||||
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
|
||||
{
|
||||
if (width == -1) m_width = 80;
|
||||
}
|
||||
|
||||
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
|
||||
{
|
||||
if (height == -1) m_height = 26;
|
||||
}
|
||||
*/
|
||||
|
||||
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
|
||||
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
|
||||
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
|
||||
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
|
||||
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
{
|
||||
if ((m_x != old_x) || (m_y != old_y))
|
||||
{
|
||||
/* we set the position here and when showing the dialog
|
||||
for the first time in idle time */
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_width != old_width) || (m_height != old_height))
|
||||
{
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
|
||||
/* actual resizing is deferred to GtkOnSize in idle time and
|
||||
when showing the dialog */
|
||||
m_sizeSet = FALSE;
|
||||
}
|
||||
|
||||
m_resizing = FALSE;
|
||||
}
|
||||
|
||||
void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height )
|
||||
{
|
||||
// due to a bug in gtk, x,y are always 0
|
||||
// m_x = x;
|
||||
// m_y = y;
|
||||
|
||||
if ((m_height == height) && (m_width == width) && (m_sizeSet)) return;
|
||||
if (!m_wxwindow) return;
|
||||
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
|
||||
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
|
||||
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
|
||||
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
|
||||
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
|
||||
|
||||
/* set size hints */
|
||||
gint flag = 0; // GDK_HINT_POS;
|
||||
if ((m_minWidth != -1) || (m_minHeight != -1)) flag |= GDK_HINT_MIN_SIZE;
|
||||
if ((m_maxWidth != -1) || (m_maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE;
|
||||
GdkGeometry geom;
|
||||
geom.min_width = m_minWidth;
|
||||
geom.min_height = m_minHeight;
|
||||
geom.max_width = m_maxWidth;
|
||||
geom.max_height = m_maxHeight;
|
||||
gtk_window_set_geometry_hints( GTK_WINDOW(m_widget),
|
||||
(GtkWidget*) NULL,
|
||||
&geom,
|
||||
(GdkWindowHints) flag );
|
||||
|
||||
m_sizeSet = TRUE;
|
||||
|
||||
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
|
||||
event.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent( event );
|
||||
}
|
||||
|
||||
void wxDialog::OnInternalIdle()
|
||||
{
|
||||
if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow))
|
||||
GtkOnSize( m_x, m_y, m_width, m_height );
|
||||
|
||||
wxWindow::OnInternalIdle();
|
||||
}
|
||||
|
||||
bool wxDialog::Show( bool show )
|
||||
{
|
||||
if (!show && IsModal())
|
||||
@ -677,17 +237,3 @@ void wxDialog::EndModal( int retCode )
|
||||
|
||||
Show( FALSE );
|
||||
}
|
||||
|
||||
void wxDialog::SetIcon( const wxIcon &icon )
|
||||
{
|
||||
m_icon = icon;
|
||||
if (!icon.Ok()) return;
|
||||
|
||||
if (!m_widget->window) return;
|
||||
|
||||
wxMask *mask = icon.GetMask();
|
||||
GdkBitmap *bm = (GdkBitmap *) NULL;
|
||||
if (mask) bm = mask->GetBitmap();
|
||||
|
||||
gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
|
||||
}
|
||||
|
@ -19,10 +19,6 @@
|
||||
#pragma implementation "frame.h"
|
||||
#endif
|
||||
|
||||
#ifdef __VMS
|
||||
#define XIconifyWindow XICONIFYWINDOW
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#include "wx/dialog.h"
|
||||
@ -66,23 +62,7 @@ extern int g_openDialogs;
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// data
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// debug
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
@ -93,66 +73,6 @@ extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar
|
||||
// GTK callbacks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "focus" from m_window
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint gtk_frame_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
// This disables GTK's tab traversal
|
||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus" );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "size_allocate"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrameGTK *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT)
|
||||
return;
|
||||
|
||||
if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
|
||||
{
|
||||
/*
|
||||
wxPrintf( "OnSize from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
wxPrintf( win->GetClassInfo()->GetClassName() );
|
||||
wxPrintf( " %d %d %d %d\n", (int)alloc->x,
|
||||
(int)alloc->y,
|
||||
(int)alloc->width,
|
||||
(int)alloc->height );
|
||||
*/
|
||||
|
||||
win->m_width = alloc->width;
|
||||
win->m_height = alloc->height;
|
||||
win->m_queuedFullRedraw = TRUE;
|
||||
win->GtkUpdateSize();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "delete_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrameGTK *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if ((g_openDialogs == 0) && (win->IsEnabled()))
|
||||
win->Close();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if wxUSE_MENUS_NATIVE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -211,175 +131,6 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
|
||||
}
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "configure_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxFrameGTK *win )
|
||||
#else
|
||||
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrameGTK *win )
|
||||
#endif
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT)
|
||||
return FALSE;
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
gdk_window_get_root_origin( win->m_widget->window, &x, &y );
|
||||
win->m_x = x;
|
||||
win->m_y = y;
|
||||
#else
|
||||
win->m_x = event->x;
|
||||
win->m_y = event->y;
|
||||
#endif
|
||||
|
||||
wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
|
||||
mevent.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( mevent );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "realize" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* we cannot MWM hints and icons before the widget has been realized,
|
||||
so we do this directly after realization */
|
||||
|
||||
static void
|
||||
gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxFrameGTK *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if ((win->m_miniEdge > 0) || (win->HasFlag(wxSIMPLE_BORDER)) || (win->HasFlag(wxNO_BORDER)))
|
||||
{
|
||||
/* This is a mini-frame or a borderless frame. */
|
||||
gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)0 );
|
||||
gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* All this is for Motif Window Manager "hints" and is supposed to be
|
||||
recognized by other WM as well. Not tested. */
|
||||
long decor = (long) GDK_DECOR_BORDER;
|
||||
long func = (long) GDK_FUNC_MOVE;
|
||||
|
||||
if ((win->GetWindowStyle() & wxCAPTION) != 0)
|
||||
decor |= GDK_DECOR_TITLE;
|
||||
if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
|
||||
{
|
||||
decor |= GDK_DECOR_MENU;
|
||||
func |= GDK_FUNC_CLOSE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_MINIMIZE;
|
||||
decor |= GDK_DECOR_MINIMIZE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_MAXIMIZE;
|
||||
decor |= GDK_DECOR_MAXIMIZE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_RESIZE;
|
||||
decor |= GDK_DECOR_RESIZEH;
|
||||
}
|
||||
|
||||
gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
|
||||
gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
|
||||
}
|
||||
|
||||
/* GTK's shrinking/growing policy */
|
||||
if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
|
||||
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
|
||||
else
|
||||
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
|
||||
|
||||
/* reset the icon */
|
||||
wxIcon iconOld = win->GetIcon();
|
||||
if ( iconOld != wxNullIcon )
|
||||
{
|
||||
wxIcon icon( iconOld );
|
||||
win->SetIcon( wxNullIcon );
|
||||
win->SetIcon( icon );
|
||||
}
|
||||
|
||||
/* we set the focus to the child that accepts the focus. this
|
||||
doesn't really have to be done in "realize" but why not? */
|
||||
wxWindowList::Node *node = win->GetChildren().GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxWindow *child = node->GetData();
|
||||
if (child->AcceptsFocus())
|
||||
{
|
||||
child->SetFocus();
|
||||
break;
|
||||
}
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "map_event" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
gtk_frame_map_callback( GtkWidget * WXUNUSED(widget),
|
||||
GdkEvent * WXUNUSED(event),
|
||||
wxFrame *win )
|
||||
{
|
||||
win->SetIconizeState(FALSE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "unmap_event" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
gtk_frame_unmap_callback( GtkWidget * WXUNUSED(widget),
|
||||
GdkEvent * WXUNUSED(event),
|
||||
wxFrame *win )
|
||||
{
|
||||
win->SetIconizeState(TRUE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "expose_event" of m_client
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win )
|
||||
{
|
||||
GtkPizza *pizza = GTK_PIZZA(widget);
|
||||
|
||||
gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_NONE, &gdk_event->area, win->m_widget, "base", 0, 0, -1, -1);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "draw" of m_client
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win )
|
||||
{
|
||||
GtkPizza *pizza = GTK_PIZZA(widget);
|
||||
|
||||
gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_NONE, rect, win->m_widget, "base", 0, 0, -1, -1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFrameGTK itself
|
||||
@ -447,17 +198,8 @@ static void wxInsertChildInFrame( wxFrameGTK* parent, wxWindow* child )
|
||||
|
||||
void wxFrameGTK::Init()
|
||||
{
|
||||
m_sizeSet = FALSE;
|
||||
m_miniEdge = 0;
|
||||
m_miniTitle = 0;
|
||||
m_mainWidget = (GtkWidget*) NULL;
|
||||
m_menuBarDetached = FALSE;
|
||||
m_toolBarDetached = FALSE;
|
||||
m_insertInClientArea = TRUE;
|
||||
m_isFrame = TRUE;
|
||||
m_isIconized = FALSE;
|
||||
m_fsIsShowing = FALSE;
|
||||
m_themeEnabled = TRUE;
|
||||
}
|
||||
|
||||
bool wxFrameGTK::Create( wxWindow *parent,
|
||||
@ -468,285 +210,28 @@ bool wxFrameGTK::Create( wxWindow *parent,
|
||||
long style,
|
||||
const wxString &name )
|
||||
{
|
||||
// always create a frame of some reasonable, even if arbitrary, size (at
|
||||
// least for MSW compatibility)
|
||||
wxSize size = sizeOrig;
|
||||
if ( size.x == -1 || size.y == -1 )
|
||||
{
|
||||
wxSize sizeDpy = wxGetDisplaySize();
|
||||
if ( size.x == -1 )
|
||||
size.x = sizeDpy.x / 3;
|
||||
if ( size.y == -1 )
|
||||
size.y = sizeDpy.y / 5;
|
||||
}
|
||||
|
||||
wxTopLevelWindows.Append( this );
|
||||
|
||||
m_needParent = FALSE;
|
||||
|
||||
if (!PreCreation( parent, pos, size ) ||
|
||||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
|
||||
{
|
||||
wxFAIL_MSG( wxT("wxFrameGTK creation failed") );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_title = title;
|
||||
|
||||
bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig,
|
||||
style, name);
|
||||
m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
|
||||
|
||||
GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
|
||||
|
||||
if (style & wxFRAME_TOOL_WINDOW)
|
||||
win_type = GTK_WINDOW_POPUP;
|
||||
|
||||
m_widget = gtk_window_new( win_type );
|
||||
|
||||
if ((m_parent) && (HasFlag(wxFRAME_FLOAT_ON_PARENT)) && (GTK_IS_WINDOW(m_parent->m_widget)))
|
||||
gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) );
|
||||
|
||||
if (!name.IsEmpty())
|
||||
gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
debug_focus_in( m_widget, wxT("wxFrameGTK::m_widget"), name );
|
||||
#endif
|
||||
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
|
||||
|
||||
/* m_mainWidget holds the toolbar, the menubar and the client area */
|
||||
m_mainWidget = gtk_pizza_new();
|
||||
gtk_widget_show( m_mainWidget );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
|
||||
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
|
||||
|
||||
/* for m_mainWidget themes */
|
||||
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event",
|
||||
GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw",
|
||||
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
debug_focus_in( m_mainWidget, wxT("wxFrameGTK::m_mainWidget"), name );
|
||||
#endif
|
||||
|
||||
/* m_wxwindow only represents the client area without toolbar and menubar */
|
||||
m_wxwindow = gtk_pizza_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
debug_focus_in( m_wxwindow, wxT("wxFrameGTK::m_wxwindow"), name );
|
||||
#endif
|
||||
|
||||
/* we donm't allow the frame to get the focus as otherwise
|
||||
the frame will grab it at arbitrary focus changes. */
|
||||
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
|
||||
|
||||
if (m_parent) m_parent->AddChild( this );
|
||||
|
||||
/* the user resized the frame by dragging etc. */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
|
||||
/* we cannot set MWM hints and icons before the widget has
|
||||
been realized, so we do this directly after realization */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
|
||||
|
||||
/* the only way to get the window size is to connect to this event */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
|
||||
|
||||
/* map and unmap for iconized state */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "map_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_map_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "unmap_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_unmap_callback), (gpointer)this );
|
||||
|
||||
/* the only way to get the window size is to connect to this event */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
|
||||
|
||||
/* disable native tab traversal */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "focus",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_focus_callback), (gpointer)this );
|
||||
|
||||
return TRUE;
|
||||
return rt;
|
||||
}
|
||||
|
||||
wxFrameGTK::~wxFrameGTK()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
|
||||
DeleteAllBars();
|
||||
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
|
||||
if (wxTheApp->GetTopWindow() == this)
|
||||
wxTheApp->SetTopWindow( (wxWindow*) NULL );
|
||||
|
||||
if ((wxTopLevelWindows.Number() == 0) &&
|
||||
(wxTheApp->GetExitOnFrameDelete()))
|
||||
{
|
||||
wxTheApp->ExitMainLoop();
|
||||
}
|
||||
}
|
||||
|
||||
bool wxFrameGTK::ShowFullScreen(bool show, long style )
|
||||
{
|
||||
if (show == m_fsIsShowing) return FALSE; // return what?
|
||||
|
||||
m_fsIsShowing = show;
|
||||
|
||||
if (show)
|
||||
{
|
||||
m_fsSaveStyle = m_windowStyle;
|
||||
m_fsSaveFlag = style;
|
||||
GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
|
||||
GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );
|
||||
|
||||
gtk_widget_hide( m_widget );
|
||||
gtk_widget_unrealize( m_widget );
|
||||
|
||||
m_windowStyle = wxSIMPLE_BORDER;
|
||||
|
||||
int x;
|
||||
int y;
|
||||
wxDisplaySize( &x, &y );
|
||||
SetSize( 0, 0, x, y );
|
||||
|
||||
gtk_widget_realize( m_widget );
|
||||
gtk_widget_show( m_widget );
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide( m_widget );
|
||||
gtk_widget_unrealize( m_widget );
|
||||
|
||||
m_windowStyle = m_fsSaveStyle;
|
||||
|
||||
SetSize( m_fsSaveFrame.x, m_fsSaveFrame.y, m_fsSaveFrame.width, m_fsSaveFrame.height );
|
||||
|
||||
gtk_widget_realize( m_widget );
|
||||
gtk_widget_show( m_widget );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// overridden wxWindow methods
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxFrameGTK::Show( bool show )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
if (show && !m_sizeSet)
|
||||
{
|
||||
/* by calling GtkOnSize here, we don't have to call
|
||||
either after showing the frame, which would entail
|
||||
much ugly flicker or from within the size_allocate
|
||||
handler, because GTK 1.1.X forbids that. */
|
||||
|
||||
GtkOnSize( m_x, m_y, m_width, m_height );
|
||||
}
|
||||
|
||||
return wxWindow::Show( show );
|
||||
}
|
||||
|
||||
void wxFrameGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
|
||||
{
|
||||
wxFAIL_MSG( wxT("DoMoveWindow called for wxFrameGTK") );
|
||||
}
|
||||
|
||||
void wxFrameGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
/* this shouldn't happen: wxFrameGTK, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
|
||||
wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
|
||||
|
||||
/* avoid recursions */
|
||||
if (m_resizing)
|
||||
return;
|
||||
m_resizing = TRUE;
|
||||
|
||||
int old_x = m_x;
|
||||
int old_y = m_y;
|
||||
|
||||
int old_width = m_width;
|
||||
int old_height = m_height;
|
||||
|
||||
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
|
||||
{
|
||||
if (x != -1) m_x = x;
|
||||
if (y != -1) m_y = y;
|
||||
if (width != -1) m_width = width;
|
||||
if (height != -1) m_height = height;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
}
|
||||
|
||||
/*
|
||||
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
|
||||
{
|
||||
if (width == -1) m_width = 80;
|
||||
}
|
||||
|
||||
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
|
||||
{
|
||||
if (height == -1) m_height = 26;
|
||||
}
|
||||
*/
|
||||
|
||||
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
|
||||
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
|
||||
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
|
||||
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
|
||||
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
{
|
||||
if ((m_x != old_x) || (m_y != old_y))
|
||||
{
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_width != old_width) || (m_height != old_height))
|
||||
{
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
|
||||
/* we set the size in GtkOnSize, i.e. mostly the actual resizing is
|
||||
done either directly before the frame is shown or in idle time
|
||||
so that different calls to SetSize() don't lead to flicker. */
|
||||
m_sizeSet = FALSE;
|
||||
}
|
||||
|
||||
m_resizing = FALSE;
|
||||
}
|
||||
|
||||
void wxFrameGTK::DoGetClientSize( int *width, int *height ) const
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
wxTopLevelWindow::DoGetClientSize( width, height );
|
||||
|
||||
wxWindow::DoGetClientSize( width, height );
|
||||
if (height)
|
||||
{
|
||||
#if wxUSE_MENUS_NATIVE
|
||||
@ -762,7 +247,8 @@ void wxFrameGTK::DoGetClientSize( int *width, int *height ) const
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
/* status bar */
|
||||
if (m_frameStatusBar && m_frameStatusBar->IsShown()) (*height) -= wxSTATUS_HEIGHT;
|
||||
if (m_frameStatusBar && m_frameStatusBar->IsShown())
|
||||
(*height) -= wxSTATUS_HEIGHT;
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
@ -788,13 +274,6 @@ void wxFrameGTK::DoGetClientSize( int *width, int *height ) const
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
/* mini edge */
|
||||
*height -= m_miniEdge*2 + m_miniTitle;
|
||||
}
|
||||
if (width)
|
||||
{
|
||||
*width -= m_miniEdge*2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -842,7 +321,7 @@ void wxFrameGTK::DoSetClientSize( int width, int height )
|
||||
}
|
||||
#endif
|
||||
|
||||
DoSetSize( -1, -1, width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0 );
|
||||
wxTopLevelWindow::DoSetClientSize( width, height );
|
||||
}
|
||||
|
||||
void wxFrameGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
|
||||
@ -1015,25 +494,9 @@ void wxFrameGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
|
||||
m_resizing = FALSE;
|
||||
}
|
||||
|
||||
void wxFrameGTK::MakeModal( bool modal )
|
||||
{
|
||||
if (modal)
|
||||
gtk_grab_add( m_widget );
|
||||
else
|
||||
gtk_grab_remove( m_widget );
|
||||
}
|
||||
|
||||
void wxFrameGTK::OnInternalIdle()
|
||||
{
|
||||
if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow))
|
||||
{
|
||||
GtkOnSize( m_x, m_y, m_width, m_height );
|
||||
|
||||
// we'll come back later
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
return;
|
||||
}
|
||||
wxTopLevelWindow::OnInternalIdle();
|
||||
|
||||
#if wxUSE_MENUS_NATIVE
|
||||
if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
|
||||
@ -1044,8 +507,6 @@ void wxFrameGTK::OnInternalIdle()
|
||||
#if wxUSE_STATUSBAR
|
||||
if (m_frameStatusBar) m_frameStatusBar->OnInternalIdle();
|
||||
#endif
|
||||
|
||||
wxWindow::OnInternalIdle();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1175,85 +636,3 @@ void wxFrameGTK::PositionStatusBar()
|
||||
}
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// frame title/icon
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFrameGTK::SetTitle( const wxString &title )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
m_title = title;
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
|
||||
}
|
||||
|
||||
void wxFrameGTK::SetIcon( const wxIcon &icon )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
wxFrameBase::SetIcon(icon);
|
||||
|
||||
if ( !m_icon.Ok() )
|
||||
return;
|
||||
|
||||
if (!m_widget->window)
|
||||
return;
|
||||
|
||||
wxMask *mask = icon.GetMask();
|
||||
GdkBitmap *bm = (GdkBitmap *) NULL;
|
||||
if (mask) bm = mask->GetBitmap();
|
||||
|
||||
gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// frame state: maximized/iconized/normal
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFrameGTK::Maximize(bool WXUNUSED(maximize))
|
||||
{
|
||||
wxFAIL_MSG( _T("not implemented") );
|
||||
}
|
||||
|
||||
bool wxFrameGTK::IsMaximized() const
|
||||
{
|
||||
// wxFAIL_MSG( _T("not implemented") );
|
||||
|
||||
// This is an approximation
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxFrameGTK::Restore()
|
||||
{
|
||||
wxFAIL_MSG( _T("not implemented") );
|
||||
}
|
||||
|
||||
void wxFrameGTK::Iconize( bool iconize )
|
||||
{
|
||||
if (iconize)
|
||||
{
|
||||
GdkWindow *window = m_widget->window;
|
||||
|
||||
// you should do it later, for example from OnCreate() handler
|
||||
wxCHECK_RET( window, _T("frame not created yet - can't iconize") );
|
||||
|
||||
XIconifyWindow( GDK_WINDOW_XDISPLAY( window ),
|
||||
GDK_WINDOW_XWINDOW( window ),
|
||||
DefaultScreen( GDK_DISPLAY() ) );
|
||||
}
|
||||
}
|
||||
|
||||
bool wxFrameGTK::IsIconized() const
|
||||
{
|
||||
return m_isIconized;
|
||||
}
|
||||
|
||||
void wxFrameGTK::SetIconizeState(bool iconize)
|
||||
{
|
||||
if ( iconize != m_isIconized )
|
||||
{
|
||||
m_isIconized = iconize;
|
||||
(void)SendIconizeEvent(iconize);
|
||||
}
|
||||
}
|
||||
|
||||
|
851
src/gtk/toplevel.cpp
Normal file
851
src/gtk/toplevel.cpp
Normal file
@ -0,0 +1,851 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: toplevel.cpp
|
||||
// Purpose:
|
||||
// Author: Robert Roebling
|
||||
// Id: $Id$
|
||||
// Copyright: (c) 1998 Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "toplevel.h"
|
||||
#endif
|
||||
|
||||
#ifdef __VMS
|
||||
#define XIconifyWindow XICONIFYWINDOW
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/control.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/dcclient.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#include "wx/gtk/win_gtk.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// idle system
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern void wxapp_install_idle_handler();
|
||||
extern bool g_isIdle;
|
||||
extern int g_openDialogs;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event tables
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// data
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// debug
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
|
||||
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// GTK callbacks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "focus" from m_window
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint gtk_frame_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
// This disables GTK's tab traversal
|
||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus" );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "size_allocate"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxTopLevelWindowGTK *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT)
|
||||
return;
|
||||
|
||||
if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
|
||||
{
|
||||
/*
|
||||
wxPrintf( "OnSize from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
wxPrintf( win->GetClassInfo()->GetClassName() );
|
||||
wxPrintf( " %d %d %d %d\n", (int)alloc->x,
|
||||
(int)alloc->y,
|
||||
(int)alloc->width,
|
||||
(int)alloc->height );
|
||||
*/
|
||||
|
||||
win->m_width = alloc->width;
|
||||
win->m_height = alloc->height;
|
||||
win->m_queuedFullRedraw = TRUE;
|
||||
win->GtkUpdateSize();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "delete_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxTopLevelWindowGTK *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (win->IsEnabled() &&
|
||||
(g_openDialogs == 0 || (win->GetExtraStyle() & wxTLW_EX_DIALOG)))
|
||||
win->Close();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "configure_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxTopLevelWindowGTK *win )
|
||||
#else
|
||||
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxTopLevelWindowGTK *win )
|
||||
#endif
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT)
|
||||
return FALSE;
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
gdk_window_get_root_origin( win->m_widget->window, &x, &y );
|
||||
win->m_x = x;
|
||||
win->m_y = y;
|
||||
#else
|
||||
win->m_x = event->x;
|
||||
win->m_y = event->y;
|
||||
#endif
|
||||
|
||||
wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
|
||||
mevent.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( mevent );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "realize" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* we cannot MWM hints and icons before the widget has been realized,
|
||||
so we do this directly after realization */
|
||||
|
||||
static void
|
||||
gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxTopLevelWindowGTK *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if ((win->m_miniEdge > 0) || (win->HasFlag(wxSIMPLE_BORDER)) || (win->HasFlag(wxNO_BORDER)))
|
||||
{
|
||||
/* This is a mini-frame or a borderless frame. */
|
||||
gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)0 );
|
||||
gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* All this is for Motif Window Manager "hints" and is supposed to be
|
||||
recognized by other WM as well. Not tested. */
|
||||
long decor = (long) GDK_DECOR_BORDER;
|
||||
long func = (long) GDK_FUNC_MOVE;
|
||||
|
||||
if ((win->GetWindowStyle() & wxCAPTION) != 0)
|
||||
decor |= GDK_DECOR_TITLE;
|
||||
if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
|
||||
{
|
||||
decor |= GDK_DECOR_MENU;
|
||||
func |= GDK_FUNC_CLOSE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_MINIMIZE;
|
||||
decor |= GDK_DECOR_MINIMIZE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_MAXIMIZE;
|
||||
decor |= GDK_DECOR_MAXIMIZE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_RESIZE;
|
||||
decor |= GDK_DECOR_RESIZEH;
|
||||
}
|
||||
|
||||
gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
|
||||
gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
|
||||
}
|
||||
|
||||
/* GTK's shrinking/growing policy */
|
||||
if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
|
||||
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
|
||||
else
|
||||
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
|
||||
|
||||
/* reset the icon */
|
||||
wxIcon iconOld = win->GetIcon();
|
||||
if ( iconOld != wxNullIcon )
|
||||
{
|
||||
wxIcon icon( iconOld );
|
||||
win->SetIcon( wxNullIcon );
|
||||
win->SetIcon( icon );
|
||||
}
|
||||
|
||||
/* we set the focus to the child that accepts the focus. this
|
||||
doesn't really have to be done in "realize" but why not? */
|
||||
wxWindowList::Node *node = win->GetChildren().GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxWindow *child = node->GetData();
|
||||
if (child->AcceptsFocus())
|
||||
{
|
||||
child->SetFocus();
|
||||
break;
|
||||
}
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "map_event" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
gtk_frame_map_callback( GtkWidget * WXUNUSED(widget),
|
||||
GdkEvent * WXUNUSED(event),
|
||||
wxTopLevelWindow *win )
|
||||
{
|
||||
win->SetIconizeState(FALSE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "unmap_event" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
gtk_frame_unmap_callback( GtkWidget * WXUNUSED(widget),
|
||||
GdkEvent * WXUNUSED(event),
|
||||
wxTopLevelWindow *win )
|
||||
{
|
||||
win->SetIconizeState(TRUE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "expose_event" of m_client
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win )
|
||||
{
|
||||
GtkPizza *pizza = GTK_PIZZA(widget);
|
||||
|
||||
gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_NONE, &gdk_event->area, win->m_widget, "base", 0, 0, -1, -1);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "draw" of m_client
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win )
|
||||
{
|
||||
GtkPizza *pizza = GTK_PIZZA(widget);
|
||||
|
||||
gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_NONE, rect, win->m_widget, "base", 0, 0, -1, -1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTopLevelWindowGTK itself
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InsertChild for wxTopLevelWindowGTK
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* Callback for wxTopLevelWindowGTK. This very strange beast has to be used because
|
||||
* C++ has no virtual methods in a constructor. We have to emulate a
|
||||
* virtual function here as wxWindows requires different ways to insert
|
||||
* a child in container classes. */
|
||||
|
||||
static void wxInsertChildInTopLevelWindow( wxTopLevelWindowGTK* parent, wxWindow* child )
|
||||
{
|
||||
wxASSERT( GTK_IS_WIDGET(child->m_widget) );
|
||||
|
||||
if (!parent->m_insertInClientArea)
|
||||
{
|
||||
/* these are outside the client area */
|
||||
wxTopLevelWindowGTK* frame = (wxTopLevelWindowGTK*) parent;
|
||||
gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
|
||||
GTK_WIDGET(child->m_widget),
|
||||
child->m_x,
|
||||
child->m_y,
|
||||
child->m_width,
|
||||
child->m_height );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* these are inside the client area */
|
||||
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
|
||||
GTK_WIDGET(child->m_widget),
|
||||
child->m_x,
|
||||
child->m_y,
|
||||
child->m_width,
|
||||
child->m_height );
|
||||
}
|
||||
|
||||
/* resize on OnInternalIdle */
|
||||
parent->GtkUpdateSize();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTopLevelWindowGTK creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowGTK::Init()
|
||||
{
|
||||
m_sizeSet = FALSE;
|
||||
m_miniEdge = 0;
|
||||
m_miniTitle = 0;
|
||||
m_mainWidget = (GtkWidget*) NULL;
|
||||
m_insertInClientArea = TRUE;
|
||||
m_isFrame = TRUE;
|
||||
m_isIconized = FALSE;
|
||||
m_fsIsShowing = FALSE;
|
||||
m_themeEnabled = TRUE;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowGTK::Create( wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& sizeOrig,
|
||||
long style,
|
||||
const wxString &name )
|
||||
{
|
||||
// always create a frame of some reasonable, even if arbitrary, size (at
|
||||
// least for MSW compatibility)
|
||||
wxSize size = sizeOrig;
|
||||
if ( size.x == -1 || size.y == -1 )
|
||||
{
|
||||
wxSize sizeDpy = wxGetDisplaySize();
|
||||
if ( size.x == -1 )
|
||||
size.x = sizeDpy.x / 3;
|
||||
if ( size.y == -1 )
|
||||
size.y = sizeDpy.y / 5;
|
||||
}
|
||||
|
||||
wxTopLevelWindows.Append( this );
|
||||
|
||||
m_needParent = FALSE;
|
||||
|
||||
if (!PreCreation( parent, pos, size ) ||
|
||||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
|
||||
{
|
||||
wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_title = title;
|
||||
|
||||
m_insertCallback = (wxInsertChildFunction) wxInsertChildInTopLevelWindow;
|
||||
|
||||
GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
|
||||
|
||||
if (style & wxFRAME_TOOL_WINDOW)
|
||||
win_type = GTK_WINDOW_POPUP;
|
||||
|
||||
if (GetExtraStyle() & wxTLW_EX_DIALOG)
|
||||
win_type = GTK_WINDOW_DIALOG;
|
||||
|
||||
m_widget = gtk_window_new( win_type );
|
||||
|
||||
if ((m_parent) && (HasFlag(wxFRAME_FLOAT_ON_PARENT)) && (GTK_IS_WINDOW(m_parent->m_widget)))
|
||||
gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) );
|
||||
|
||||
if (!name.IsEmpty())
|
||||
gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
debug_focus_in( m_widget, wxT("wxTopLevelWindowGTK::m_widget"), name );
|
||||
#endif
|
||||
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
|
||||
|
||||
/* m_mainWidget holds the toolbar, the menubar and the client area */
|
||||
m_mainWidget = gtk_pizza_new();
|
||||
gtk_widget_show( m_mainWidget );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
|
||||
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
|
||||
|
||||
/* for m_mainWidget themes */
|
||||
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event",
|
||||
GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw",
|
||||
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
debug_focus_in( m_mainWidget, wxT("wxTopLevelWindowGTK::m_mainWidget"), name );
|
||||
#endif
|
||||
|
||||
/* m_wxwindow only represents the client area without toolbar and menubar */
|
||||
m_wxwindow = gtk_pizza_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
debug_focus_in( m_wxwindow, wxT("wxTopLevelWindowGTK::m_wxwindow"), name );
|
||||
#endif
|
||||
|
||||
/* we donm't allow the frame to get the focus as otherwise
|
||||
the frame will grab it at arbitrary focus changes. */
|
||||
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
|
||||
|
||||
if (m_parent) m_parent->AddChild( this );
|
||||
|
||||
/* the user resized the frame by dragging etc. */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
|
||||
/* we cannot set MWM hints and icons before the widget has
|
||||
been realized, so we do this directly after realization */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
|
||||
|
||||
/* the only way to get the window size is to connect to this event */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
|
||||
|
||||
/* map and unmap for iconized state */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "map_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_map_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "unmap_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_unmap_callback), (gpointer)this );
|
||||
|
||||
/* the only way to get the window size is to connect to this event */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
|
||||
|
||||
/* disable native tab traversal */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "focus",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_focus_callback), (gpointer)this );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
|
||||
if (wxTheApp->GetTopWindow() == this)
|
||||
wxTheApp->SetTopWindow( (wxWindow*) NULL );
|
||||
|
||||
if ((wxTopLevelWindows.Number() == 0) &&
|
||||
(wxTheApp->GetExitOnFrameDelete()))
|
||||
{
|
||||
wxTheApp->ExitMainLoop();
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long style )
|
||||
{
|
||||
if (show == m_fsIsShowing) return FALSE; // return what?
|
||||
|
||||
m_fsIsShowing = show;
|
||||
|
||||
if (show)
|
||||
{
|
||||
m_fsSaveStyle = m_windowStyle;
|
||||
m_fsSaveFlag = style;
|
||||
GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
|
||||
GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );
|
||||
|
||||
gtk_widget_hide( m_widget );
|
||||
gtk_widget_unrealize( m_widget );
|
||||
|
||||
m_windowStyle = wxSIMPLE_BORDER;
|
||||
|
||||
int x;
|
||||
int y;
|
||||
wxDisplaySize( &x, &y );
|
||||
SetSize( 0, 0, x, y );
|
||||
|
||||
gtk_widget_realize( m_widget );
|
||||
gtk_widget_show( m_widget );
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide( m_widget );
|
||||
gtk_widget_unrealize( m_widget );
|
||||
|
||||
m_windowStyle = m_fsSaveStyle;
|
||||
|
||||
SetSize( m_fsSaveFrame.x, m_fsSaveFrame.y, m_fsSaveFrame.width, m_fsSaveFrame.height );
|
||||
|
||||
gtk_widget_realize( m_widget );
|
||||
gtk_widget_show( m_widget );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// overridden wxWindow methods
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxTopLevelWindowGTK::Show( bool show )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
if (show && !m_sizeSet)
|
||||
{
|
||||
/* by calling GtkOnSize here, we don't have to call
|
||||
either after showing the frame, which would entail
|
||||
much ugly flicker or from within the size_allocate
|
||||
handler, because GTK 1.1.X forbids that. */
|
||||
|
||||
GtkOnSize( m_x, m_y, m_width, m_height );
|
||||
}
|
||||
|
||||
return wxWindow::Show( show );
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
|
||||
{
|
||||
wxFAIL_MSG( wxT("DoMoveWindow called for wxTopLevelWindowGTK") );
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
/* this shouldn't happen: wxFrameGTK, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
|
||||
wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
|
||||
|
||||
/* avoid recursions */
|
||||
if (m_resizing)
|
||||
return;
|
||||
m_resizing = TRUE;
|
||||
|
||||
int old_x = m_x;
|
||||
int old_y = m_y;
|
||||
|
||||
int old_width = m_width;
|
||||
int old_height = m_height;
|
||||
|
||||
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
|
||||
{
|
||||
if (x != -1) m_x = x;
|
||||
if (y != -1) m_y = y;
|
||||
if (width != -1) m_width = width;
|
||||
if (height != -1) m_height = height;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
}
|
||||
|
||||
/*
|
||||
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
|
||||
{
|
||||
if (width == -1) m_width = 80;
|
||||
}
|
||||
|
||||
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
|
||||
{
|
||||
if (height == -1) m_height = 26;
|
||||
}
|
||||
*/
|
||||
|
||||
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
|
||||
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
|
||||
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
|
||||
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
|
||||
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
{
|
||||
if ((m_x != old_x) || (m_y != old_y))
|
||||
{
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_width != old_width) || (m_height != old_height))
|
||||
{
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
|
||||
/* we set the size in GtkOnSize, i.e. mostly the actual resizing is
|
||||
done either directly before the frame is shown or in idle time
|
||||
so that different calls to SetSize() don't lead to flicker. */
|
||||
m_sizeSet = FALSE;
|
||||
}
|
||||
|
||||
m_resizing = FALSE;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::DoGetClientSize( int *width, int *height ) const
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
wxWindow::DoGetClientSize( width, height );
|
||||
if (height)
|
||||
{
|
||||
/* mini edge */
|
||||
*height -= m_miniEdge*2 + m_miniTitle;
|
||||
}
|
||||
if (width)
|
||||
{
|
||||
*width -= m_miniEdge*2;
|
||||
}
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::DoSetClientSize( int width, int height )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
DoSetSize(-1, -1,
|
||||
width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0);
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
|
||||
int width, int height )
|
||||
{
|
||||
// due to a bug in gtk, x,y are always 0
|
||||
// m_x = x;
|
||||
// m_y = y;
|
||||
|
||||
/* avoid recursions */
|
||||
if (m_resizing) return;
|
||||
m_resizing = TRUE;
|
||||
|
||||
if ( m_wxwindow == NULL ) return;
|
||||
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
|
||||
/* wxMDIChildFrame derives from wxFrameGTK but it _is_ a wxWindow as it uses
|
||||
wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
|
||||
set in wxFrameGTK::Create so it is used to check what kind of frame we
|
||||
have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
|
||||
skip the part which handles m_frameMenuBar, m_frameToolBar and (most
|
||||
importantly) m_mainWidget */
|
||||
|
||||
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
|
||||
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
|
||||
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
|
||||
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
|
||||
|
||||
if (m_mainWidget)
|
||||
{
|
||||
/* set size hints */
|
||||
gint flag = 0; // GDK_HINT_POS;
|
||||
if ((m_minWidth != -1) || (m_minHeight != -1)) flag |= GDK_HINT_MIN_SIZE;
|
||||
if ((m_maxWidth != -1) || (m_maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE;
|
||||
GdkGeometry geom;
|
||||
geom.min_width = m_minWidth;
|
||||
geom.min_height = m_minHeight;
|
||||
geom.max_width = m_maxWidth;
|
||||
geom.max_height = m_maxHeight;
|
||||
gtk_window_set_geometry_hints( GTK_WINDOW(m_widget),
|
||||
(GtkWidget*) NULL,
|
||||
&geom,
|
||||
(GdkWindowHints) flag );
|
||||
|
||||
/* I revert back to wxGTK's original behaviour. m_mainWidget holds the
|
||||
* menubar, the toolbar and the client area, which is represented by
|
||||
* m_wxwindow.
|
||||
* this hurts in the eye, but I don't want to call SetSize()
|
||||
* because I don't want to call any non-native functions here. */
|
||||
|
||||
int client_x = m_miniEdge;
|
||||
int client_y = m_miniEdge + m_miniTitle;
|
||||
int client_w = m_width - 2*m_miniEdge;
|
||||
int client_h = m_height - 2*m_miniEdge - m_miniTitle;
|
||||
gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
|
||||
m_wxwindow,
|
||||
client_x, client_y, client_w, client_h );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if there is no m_mainWidget between m_widget and m_wxwindow there
|
||||
is no need to set the size or position of m_wxwindow. */
|
||||
}
|
||||
|
||||
m_sizeSet = TRUE;
|
||||
|
||||
// send size event to frame
|
||||
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
|
||||
event.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent( event );
|
||||
|
||||
m_resizing = FALSE;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::OnInternalIdle()
|
||||
{
|
||||
if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow))
|
||||
{
|
||||
GtkOnSize( m_x, m_y, m_width, m_height );
|
||||
|
||||
// we'll come back later
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
return;
|
||||
}
|
||||
|
||||
wxWindow::OnInternalIdle();
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// frame title/icon
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowGTK::SetTitle( const wxString &title )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
m_title = title;
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
wxTopLevelWindowBase::SetIcon(icon);
|
||||
|
||||
if ( !m_icon.Ok() )
|
||||
return;
|
||||
|
||||
if (!m_widget->window)
|
||||
return;
|
||||
|
||||
wxMask *mask = icon.GetMask();
|
||||
GdkBitmap *bm = (GdkBitmap *) NULL;
|
||||
if (mask) bm = mask->GetBitmap();
|
||||
|
||||
gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// frame state: maximized/iconized/normal
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowGTK::Maximize(bool WXUNUSED(maximize))
|
||||
{
|
||||
wxFAIL_MSG( _T("not implemented") );
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowGTK::IsMaximized() const
|
||||
{
|
||||
// wxFAIL_MSG( _T("not implemented") );
|
||||
|
||||
// This is an approximation
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::Restore()
|
||||
{
|
||||
wxFAIL_MSG( _T("not implemented") );
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::Iconize( bool iconize )
|
||||
{
|
||||
if (iconize)
|
||||
{
|
||||
GdkWindow *window = m_widget->window;
|
||||
|
||||
// you should do it later, for example from OnCreate() handler
|
||||
wxCHECK_RET( window, _T("frame not created yet - can't iconize") );
|
||||
|
||||
XIconifyWindow( GDK_WINDOW_XDISPLAY( window ),
|
||||
GDK_WINDOW_XWINDOW( window ),
|
||||
DefaultScreen( GDK_DISPLAY() ) );
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowGTK::IsIconized() const
|
||||
{
|
||||
return m_isIconized;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::SetIconizeState(bool iconize)
|
||||
{
|
||||
if ( iconize != m_isIconized )
|
||||
{
|
||||
m_isIconized = iconize;
|
||||
(void)SendIconizeEvent(iconize);
|
||||
}
|
||||
}
|
||||
|
@ -30,201 +30,20 @@ extern void wxapp_install_idle_handler();
|
||||
extern bool g_isIdle;
|
||||
extern int g_openDialogs;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "focus" from m_window
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint gtk_dialog_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
// This disables GTK's tab traversal
|
||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus" );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "delete_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (win->IsEnabled())
|
||||
win->Close();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "size_allocate"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxDialog *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT) return;
|
||||
|
||||
if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
|
||||
{
|
||||
win->m_width = alloc->width;
|
||||
win->m_height = alloc->height;
|
||||
win->GtkUpdateSize();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "configure_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDialog *win )
|
||||
#else
|
||||
gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxDialog *win )
|
||||
#endif
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT) return FALSE;
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
gdk_window_get_root_origin( win->m_widget->window, &x, &y );
|
||||
win->m_x = x;
|
||||
win->m_y = y;
|
||||
#else
|
||||
win->m_x = event->x;
|
||||
win->m_y = event->y;
|
||||
#endif
|
||||
|
||||
wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
|
||||
mevent.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( mevent );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "realize" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* we cannot MWM hints and icons before the widget has been realized,
|
||||
so we do this directly after realization */
|
||||
|
||||
static gint
|
||||
gtk_dialog_realized_callback( GtkWidget * WXUNUSED(widget), wxDialog *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
/* all this is for Motif Window Manager "hints" and is supposed to be
|
||||
recognized by other WM as well. not tested. */
|
||||
long decor = (long) GDK_DECOR_BORDER;
|
||||
long func = (long) GDK_FUNC_MOVE ;
|
||||
|
||||
/* Some WM don't display any border around the frame contents if
|
||||
used with these hints, so we add a resize border around it,
|
||||
without automatically allowinng it to be resized though.
|
||||
|
||||
This avoids the problem, but looks odd. What shall we do?
|
||||
*/
|
||||
decor |= GDK_DECOR_RESIZEH;
|
||||
|
||||
if ((win->GetWindowStyle() & wxCAPTION) != 0)
|
||||
decor |= GDK_DECOR_TITLE;
|
||||
if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
|
||||
{
|
||||
decor |= GDK_DECOR_MENU;
|
||||
func |= GDK_FUNC_CLOSE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_MINIMIZE;
|
||||
decor |= GDK_DECOR_MINIMIZE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
|
||||
{
|
||||
decor |= GDK_DECOR_MAXIMIZE;
|
||||
func |= GDK_FUNC_MAXIMIZE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_RESIZE;
|
||||
decor |= GDK_DECOR_RESIZEH;
|
||||
}
|
||||
gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
|
||||
gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
|
||||
|
||||
/* GTK's shrinking/growing policy */
|
||||
if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
|
||||
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
|
||||
else
|
||||
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
|
||||
|
||||
/* reset the icon */
|
||||
if (win->m_icon != wxNullIcon)
|
||||
{
|
||||
wxIcon icon( win->m_icon );
|
||||
win->m_icon = wxNullIcon;
|
||||
win->SetIcon( icon );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InsertChild for wxDialog
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* Callback for wxFrame. This very strange beast has to be used because
|
||||
* C++ has no virtual methods in a constructor. We have to emulate a
|
||||
* virtual function here as wxWindows requires different ways to insert
|
||||
* a child in container classes. */
|
||||
|
||||
static void wxInsertChildInDialog( wxDialog* parent, wxWindow* child )
|
||||
{
|
||||
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
|
||||
GTK_WIDGET(child->m_widget),
|
||||
child->m_x,
|
||||
child->m_y,
|
||||
child->m_width,
|
||||
child->m_height );
|
||||
|
||||
if (parent->HasFlag(wxTAB_TRAVERSAL))
|
||||
{
|
||||
/* we now allow a window to get the focus as long as it
|
||||
doesn't have any children. */
|
||||
GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDialog
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog,wxPanel)
|
||||
BEGIN_EVENT_TABLE(wxDialog,wxDialogBase)
|
||||
EVT_BUTTON (wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_BUTTON (wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_SIZE (wxDialog::OnSize)
|
||||
EVT_CLOSE (wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxTopLevelWindow)
|
||||
|
||||
void wxDialog::Init()
|
||||
{
|
||||
@ -240,6 +59,9 @@ wxDialog::wxDialog( wxWindow *parent,
|
||||
long style, const wxString &name )
|
||||
{
|
||||
Init();
|
||||
|
||||
// all dialogs should have tab traversal enabled
|
||||
style |= wxTAB_TRAVERSAL;
|
||||
|
||||
Create( parent, id, title, pos, size, style, name );
|
||||
}
|
||||
@ -249,90 +71,9 @@ bool wxDialog::Create( wxWindow *parent,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
long style, const wxString &name )
|
||||
{
|
||||
wxTopLevelWindows.Append( this );
|
||||
SetExtraStyle(GetExtraStyle() | wxTLW_EX_DIALOG);
|
||||
|
||||
m_needParent = FALSE;
|
||||
|
||||
if (!PreCreation( parent, pos, size ) ||
|
||||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
|
||||
{
|
||||
wxFAIL_MSG( wxT("wxDialog creation failed") );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// All dialogs should really have this style
|
||||
m_windowStyle |= wxTAB_TRAVERSAL;
|
||||
|
||||
m_insertCallback = (wxInsertChildFunction) wxInsertChildInDialog;
|
||||
|
||||
m_widget = gtk_window_new( GTK_WINDOW_DIALOG );
|
||||
|
||||
if ((m_parent) && (GTK_IS_WINDOW(m_parent->m_widget)))
|
||||
gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) );
|
||||
|
||||
if (!name.IsEmpty())
|
||||
gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() );
|
||||
|
||||
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
|
||||
GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this );
|
||||
|
||||
m_wxwindow = gtk_pizza_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
|
||||
|
||||
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
|
||||
|
||||
SetTitle( title );
|
||||
|
||||
if (m_parent) m_parent->AddChild( this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
|
||||
/* we cannot set MWM hints before the widget has
|
||||
been realized, so we do this directly after realization */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
|
||||
GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
|
||||
|
||||
/* the user resized the frame by dragging etc. */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
|
||||
GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
GTK_SIGNAL_FUNC(gtk_dialog_configure_callback), (gpointer)this );
|
||||
|
||||
/* disable native tab traversal */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "focus",
|
||||
GTK_SIGNAL_FUNC(gtk_dialog_focus_callback), (gpointer)this );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
{
|
||||
CleanUp();
|
||||
|
||||
if ((wxTopLevelWindows.Number() == 0) &&
|
||||
(wxTheApp->GetExitOnFrameDelete()))
|
||||
{
|
||||
wxTheApp->ExitMainLoop();
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::SetTitle( const wxString& title )
|
||||
{
|
||||
m_title = title;
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), m_title.mbc_str() );
|
||||
}
|
||||
|
||||
wxString wxDialog::GetTitle() const
|
||||
{
|
||||
return m_title;
|
||||
return wxTopLevelWindow::Create(parent, id, title, pos, size, style, name);
|
||||
}
|
||||
|
||||
void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) )
|
||||
@ -403,187 +144,6 @@ void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
|
||||
s_closing.DeleteObject(this);
|
||||
}
|
||||
|
||||
bool wxDialog::Destroy()
|
||||
{
|
||||
// schedule the dialog for the deletion
|
||||
if ( !wxPendingDelete.Member(this) )
|
||||
{
|
||||
wxPendingDelete.Append(this);
|
||||
}
|
||||
|
||||
// don't leave a dangling pointer as the app top window, we can be deleted
|
||||
// any moment at all now!
|
||||
CleanUp();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxDialog::CleanUp()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
|
||||
if ( wxTheApp->GetTopWindow() == this )
|
||||
{
|
||||
wxTheApp->SetTopWindow( (wxWindow*) NULL );
|
||||
}
|
||||
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
}
|
||||
|
||||
void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid dialog") );
|
||||
|
||||
#if wxUSE_CONSTRAINTS
|
||||
if (GetAutoLayout())
|
||||
{
|
||||
Layout();
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_CONSTRAINTS
|
||||
{
|
||||
/* no child: go out ! */
|
||||
if (!GetChildren().First()) return;
|
||||
|
||||
/* 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))
|
||||
{
|
||||
/* it's the second one: do nothing */
|
||||
if (child) return;
|
||||
child = win;
|
||||
}
|
||||
}
|
||||
|
||||
/* yes: set it's size to fill all the frame */
|
||||
int client_x, client_y;
|
||||
GetClientSize( &client_x, &client_y );
|
||||
child->SetSize( 1, 1, client_x-2, client_y);
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
|
||||
{
|
||||
wxFAIL_MSG( wxT("DoMoveWindow called for wxDialog") );
|
||||
}
|
||||
|
||||
void wxDialog::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid dialog") );
|
||||
wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid dialog") );
|
||||
|
||||
if (m_resizing) return; /* I don't like recursions */
|
||||
m_resizing = TRUE;
|
||||
|
||||
int old_x = m_x;
|
||||
int old_y = m_y;
|
||||
|
||||
int old_width = m_width;
|
||||
int old_height = m_height;
|
||||
|
||||
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
|
||||
{
|
||||
if (x != -1) m_x = x;
|
||||
if (y != -1) m_y = y;
|
||||
if (width != -1) m_width = width;
|
||||
if (height != -1) m_height = height;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
}
|
||||
|
||||
/*
|
||||
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
|
||||
{
|
||||
if (width == -1) m_width = 80;
|
||||
}
|
||||
|
||||
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
|
||||
{
|
||||
if (height == -1) m_height = 26;
|
||||
}
|
||||
*/
|
||||
|
||||
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
|
||||
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
|
||||
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
|
||||
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
|
||||
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
{
|
||||
if ((m_x != old_x) || (m_y != old_y))
|
||||
{
|
||||
/* we set the position here and when showing the dialog
|
||||
for the first time in idle time */
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_width != old_width) || (m_height != old_height))
|
||||
{
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
|
||||
/* actual resizing is deferred to GtkOnSize in idle time and
|
||||
when showing the dialog */
|
||||
m_sizeSet = FALSE;
|
||||
}
|
||||
|
||||
m_resizing = FALSE;
|
||||
}
|
||||
|
||||
void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height )
|
||||
{
|
||||
// due to a bug in gtk, x,y are always 0
|
||||
// m_x = x;
|
||||
// m_y = y;
|
||||
|
||||
if ((m_height == height) && (m_width == width) && (m_sizeSet)) return;
|
||||
if (!m_wxwindow) return;
|
||||
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
|
||||
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
|
||||
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
|
||||
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
|
||||
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
|
||||
|
||||
/* set size hints */
|
||||
gint flag = 0; // GDK_HINT_POS;
|
||||
if ((m_minWidth != -1) || (m_minHeight != -1)) flag |= GDK_HINT_MIN_SIZE;
|
||||
if ((m_maxWidth != -1) || (m_maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE;
|
||||
GdkGeometry geom;
|
||||
geom.min_width = m_minWidth;
|
||||
geom.min_height = m_minHeight;
|
||||
geom.max_width = m_maxWidth;
|
||||
geom.max_height = m_maxHeight;
|
||||
gtk_window_set_geometry_hints( GTK_WINDOW(m_widget),
|
||||
(GtkWidget*) NULL,
|
||||
&geom,
|
||||
(GdkWindowHints) flag );
|
||||
|
||||
m_sizeSet = TRUE;
|
||||
|
||||
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
|
||||
event.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent( event );
|
||||
}
|
||||
|
||||
void wxDialog::OnInternalIdle()
|
||||
{
|
||||
if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow))
|
||||
GtkOnSize( m_x, m_y, m_width, m_height );
|
||||
|
||||
wxWindow::OnInternalIdle();
|
||||
}
|
||||
|
||||
bool wxDialog::Show( bool show )
|
||||
{
|
||||
if (!show && IsModal())
|
||||
@ -677,17 +237,3 @@ void wxDialog::EndModal( int retCode )
|
||||
|
||||
Show( FALSE );
|
||||
}
|
||||
|
||||
void wxDialog::SetIcon( const wxIcon &icon )
|
||||
{
|
||||
m_icon = icon;
|
||||
if (!icon.Ok()) return;
|
||||
|
||||
if (!m_widget->window) return;
|
||||
|
||||
wxMask *mask = icon.GetMask();
|
||||
GdkBitmap *bm = (GdkBitmap *) NULL;
|
||||
if (mask) bm = mask->GetBitmap();
|
||||
|
||||
gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
|
||||
}
|
||||
|
@ -19,10 +19,6 @@
|
||||
#pragma implementation "frame.h"
|
||||
#endif
|
||||
|
||||
#ifdef __VMS
|
||||
#define XIconifyWindow XICONIFYWINDOW
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#include "wx/dialog.h"
|
||||
@ -66,23 +62,7 @@ extern int g_openDialogs;
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// data
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// debug
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
@ -93,66 +73,6 @@ extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar
|
||||
// GTK callbacks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "focus" from m_window
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint gtk_frame_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
// This disables GTK's tab traversal
|
||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus" );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "size_allocate"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrameGTK *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT)
|
||||
return;
|
||||
|
||||
if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
|
||||
{
|
||||
/*
|
||||
wxPrintf( "OnSize from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
wxPrintf( win->GetClassInfo()->GetClassName() );
|
||||
wxPrintf( " %d %d %d %d\n", (int)alloc->x,
|
||||
(int)alloc->y,
|
||||
(int)alloc->width,
|
||||
(int)alloc->height );
|
||||
*/
|
||||
|
||||
win->m_width = alloc->width;
|
||||
win->m_height = alloc->height;
|
||||
win->m_queuedFullRedraw = TRUE;
|
||||
win->GtkUpdateSize();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "delete_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrameGTK *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if ((g_openDialogs == 0) && (win->IsEnabled()))
|
||||
win->Close();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if wxUSE_MENUS_NATIVE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -211,175 +131,6 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
|
||||
}
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "configure_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxFrameGTK *win )
|
||||
#else
|
||||
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrameGTK *win )
|
||||
#endif
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT)
|
||||
return FALSE;
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
gdk_window_get_root_origin( win->m_widget->window, &x, &y );
|
||||
win->m_x = x;
|
||||
win->m_y = y;
|
||||
#else
|
||||
win->m_x = event->x;
|
||||
win->m_y = event->y;
|
||||
#endif
|
||||
|
||||
wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
|
||||
mevent.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( mevent );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "realize" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* we cannot MWM hints and icons before the widget has been realized,
|
||||
so we do this directly after realization */
|
||||
|
||||
static void
|
||||
gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxFrameGTK *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if ((win->m_miniEdge > 0) || (win->HasFlag(wxSIMPLE_BORDER)) || (win->HasFlag(wxNO_BORDER)))
|
||||
{
|
||||
/* This is a mini-frame or a borderless frame. */
|
||||
gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)0 );
|
||||
gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* All this is for Motif Window Manager "hints" and is supposed to be
|
||||
recognized by other WM as well. Not tested. */
|
||||
long decor = (long) GDK_DECOR_BORDER;
|
||||
long func = (long) GDK_FUNC_MOVE;
|
||||
|
||||
if ((win->GetWindowStyle() & wxCAPTION) != 0)
|
||||
decor |= GDK_DECOR_TITLE;
|
||||
if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
|
||||
{
|
||||
decor |= GDK_DECOR_MENU;
|
||||
func |= GDK_FUNC_CLOSE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_MINIMIZE;
|
||||
decor |= GDK_DECOR_MINIMIZE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_MAXIMIZE;
|
||||
decor |= GDK_DECOR_MAXIMIZE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_RESIZE;
|
||||
decor |= GDK_DECOR_RESIZEH;
|
||||
}
|
||||
|
||||
gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
|
||||
gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
|
||||
}
|
||||
|
||||
/* GTK's shrinking/growing policy */
|
||||
if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
|
||||
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
|
||||
else
|
||||
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
|
||||
|
||||
/* reset the icon */
|
||||
wxIcon iconOld = win->GetIcon();
|
||||
if ( iconOld != wxNullIcon )
|
||||
{
|
||||
wxIcon icon( iconOld );
|
||||
win->SetIcon( wxNullIcon );
|
||||
win->SetIcon( icon );
|
||||
}
|
||||
|
||||
/* we set the focus to the child that accepts the focus. this
|
||||
doesn't really have to be done in "realize" but why not? */
|
||||
wxWindowList::Node *node = win->GetChildren().GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxWindow *child = node->GetData();
|
||||
if (child->AcceptsFocus())
|
||||
{
|
||||
child->SetFocus();
|
||||
break;
|
||||
}
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "map_event" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
gtk_frame_map_callback( GtkWidget * WXUNUSED(widget),
|
||||
GdkEvent * WXUNUSED(event),
|
||||
wxFrame *win )
|
||||
{
|
||||
win->SetIconizeState(FALSE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "unmap_event" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
gtk_frame_unmap_callback( GtkWidget * WXUNUSED(widget),
|
||||
GdkEvent * WXUNUSED(event),
|
||||
wxFrame *win )
|
||||
{
|
||||
win->SetIconizeState(TRUE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "expose_event" of m_client
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win )
|
||||
{
|
||||
GtkPizza *pizza = GTK_PIZZA(widget);
|
||||
|
||||
gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_NONE, &gdk_event->area, win->m_widget, "base", 0, 0, -1, -1);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "draw" of m_client
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win )
|
||||
{
|
||||
GtkPizza *pizza = GTK_PIZZA(widget);
|
||||
|
||||
gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_NONE, rect, win->m_widget, "base", 0, 0, -1, -1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFrameGTK itself
|
||||
@ -447,17 +198,8 @@ static void wxInsertChildInFrame( wxFrameGTK* parent, wxWindow* child )
|
||||
|
||||
void wxFrameGTK::Init()
|
||||
{
|
||||
m_sizeSet = FALSE;
|
||||
m_miniEdge = 0;
|
||||
m_miniTitle = 0;
|
||||
m_mainWidget = (GtkWidget*) NULL;
|
||||
m_menuBarDetached = FALSE;
|
||||
m_toolBarDetached = FALSE;
|
||||
m_insertInClientArea = TRUE;
|
||||
m_isFrame = TRUE;
|
||||
m_isIconized = FALSE;
|
||||
m_fsIsShowing = FALSE;
|
||||
m_themeEnabled = TRUE;
|
||||
}
|
||||
|
||||
bool wxFrameGTK::Create( wxWindow *parent,
|
||||
@ -468,285 +210,28 @@ bool wxFrameGTK::Create( wxWindow *parent,
|
||||
long style,
|
||||
const wxString &name )
|
||||
{
|
||||
// always create a frame of some reasonable, even if arbitrary, size (at
|
||||
// least for MSW compatibility)
|
||||
wxSize size = sizeOrig;
|
||||
if ( size.x == -1 || size.y == -1 )
|
||||
{
|
||||
wxSize sizeDpy = wxGetDisplaySize();
|
||||
if ( size.x == -1 )
|
||||
size.x = sizeDpy.x / 3;
|
||||
if ( size.y == -1 )
|
||||
size.y = sizeDpy.y / 5;
|
||||
}
|
||||
|
||||
wxTopLevelWindows.Append( this );
|
||||
|
||||
m_needParent = FALSE;
|
||||
|
||||
if (!PreCreation( parent, pos, size ) ||
|
||||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
|
||||
{
|
||||
wxFAIL_MSG( wxT("wxFrameGTK creation failed") );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_title = title;
|
||||
|
||||
bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig,
|
||||
style, name);
|
||||
m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
|
||||
|
||||
GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
|
||||
|
||||
if (style & wxFRAME_TOOL_WINDOW)
|
||||
win_type = GTK_WINDOW_POPUP;
|
||||
|
||||
m_widget = gtk_window_new( win_type );
|
||||
|
||||
if ((m_parent) && (HasFlag(wxFRAME_FLOAT_ON_PARENT)) && (GTK_IS_WINDOW(m_parent->m_widget)))
|
||||
gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) );
|
||||
|
||||
if (!name.IsEmpty())
|
||||
gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
debug_focus_in( m_widget, wxT("wxFrameGTK::m_widget"), name );
|
||||
#endif
|
||||
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
|
||||
|
||||
/* m_mainWidget holds the toolbar, the menubar and the client area */
|
||||
m_mainWidget = gtk_pizza_new();
|
||||
gtk_widget_show( m_mainWidget );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
|
||||
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
|
||||
|
||||
/* for m_mainWidget themes */
|
||||
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event",
|
||||
GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw",
|
||||
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
debug_focus_in( m_mainWidget, wxT("wxFrameGTK::m_mainWidget"), name );
|
||||
#endif
|
||||
|
||||
/* m_wxwindow only represents the client area without toolbar and menubar */
|
||||
m_wxwindow = gtk_pizza_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
debug_focus_in( m_wxwindow, wxT("wxFrameGTK::m_wxwindow"), name );
|
||||
#endif
|
||||
|
||||
/* we donm't allow the frame to get the focus as otherwise
|
||||
the frame will grab it at arbitrary focus changes. */
|
||||
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
|
||||
|
||||
if (m_parent) m_parent->AddChild( this );
|
||||
|
||||
/* the user resized the frame by dragging etc. */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
|
||||
/* we cannot set MWM hints and icons before the widget has
|
||||
been realized, so we do this directly after realization */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
|
||||
|
||||
/* the only way to get the window size is to connect to this event */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
|
||||
|
||||
/* map and unmap for iconized state */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "map_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_map_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "unmap_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_unmap_callback), (gpointer)this );
|
||||
|
||||
/* the only way to get the window size is to connect to this event */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
|
||||
|
||||
/* disable native tab traversal */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "focus",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_focus_callback), (gpointer)this );
|
||||
|
||||
return TRUE;
|
||||
return rt;
|
||||
}
|
||||
|
||||
wxFrameGTK::~wxFrameGTK()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
|
||||
DeleteAllBars();
|
||||
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
|
||||
if (wxTheApp->GetTopWindow() == this)
|
||||
wxTheApp->SetTopWindow( (wxWindow*) NULL );
|
||||
|
||||
if ((wxTopLevelWindows.Number() == 0) &&
|
||||
(wxTheApp->GetExitOnFrameDelete()))
|
||||
{
|
||||
wxTheApp->ExitMainLoop();
|
||||
}
|
||||
}
|
||||
|
||||
bool wxFrameGTK::ShowFullScreen(bool show, long style )
|
||||
{
|
||||
if (show == m_fsIsShowing) return FALSE; // return what?
|
||||
|
||||
m_fsIsShowing = show;
|
||||
|
||||
if (show)
|
||||
{
|
||||
m_fsSaveStyle = m_windowStyle;
|
||||
m_fsSaveFlag = style;
|
||||
GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
|
||||
GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );
|
||||
|
||||
gtk_widget_hide( m_widget );
|
||||
gtk_widget_unrealize( m_widget );
|
||||
|
||||
m_windowStyle = wxSIMPLE_BORDER;
|
||||
|
||||
int x;
|
||||
int y;
|
||||
wxDisplaySize( &x, &y );
|
||||
SetSize( 0, 0, x, y );
|
||||
|
||||
gtk_widget_realize( m_widget );
|
||||
gtk_widget_show( m_widget );
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide( m_widget );
|
||||
gtk_widget_unrealize( m_widget );
|
||||
|
||||
m_windowStyle = m_fsSaveStyle;
|
||||
|
||||
SetSize( m_fsSaveFrame.x, m_fsSaveFrame.y, m_fsSaveFrame.width, m_fsSaveFrame.height );
|
||||
|
||||
gtk_widget_realize( m_widget );
|
||||
gtk_widget_show( m_widget );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// overridden wxWindow methods
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxFrameGTK::Show( bool show )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
if (show && !m_sizeSet)
|
||||
{
|
||||
/* by calling GtkOnSize here, we don't have to call
|
||||
either after showing the frame, which would entail
|
||||
much ugly flicker or from within the size_allocate
|
||||
handler, because GTK 1.1.X forbids that. */
|
||||
|
||||
GtkOnSize( m_x, m_y, m_width, m_height );
|
||||
}
|
||||
|
||||
return wxWindow::Show( show );
|
||||
}
|
||||
|
||||
void wxFrameGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
|
||||
{
|
||||
wxFAIL_MSG( wxT("DoMoveWindow called for wxFrameGTK") );
|
||||
}
|
||||
|
||||
void wxFrameGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
/* this shouldn't happen: wxFrameGTK, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
|
||||
wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
|
||||
|
||||
/* avoid recursions */
|
||||
if (m_resizing)
|
||||
return;
|
||||
m_resizing = TRUE;
|
||||
|
||||
int old_x = m_x;
|
||||
int old_y = m_y;
|
||||
|
||||
int old_width = m_width;
|
||||
int old_height = m_height;
|
||||
|
||||
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
|
||||
{
|
||||
if (x != -1) m_x = x;
|
||||
if (y != -1) m_y = y;
|
||||
if (width != -1) m_width = width;
|
||||
if (height != -1) m_height = height;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
}
|
||||
|
||||
/*
|
||||
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
|
||||
{
|
||||
if (width == -1) m_width = 80;
|
||||
}
|
||||
|
||||
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
|
||||
{
|
||||
if (height == -1) m_height = 26;
|
||||
}
|
||||
*/
|
||||
|
||||
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
|
||||
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
|
||||
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
|
||||
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
|
||||
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
{
|
||||
if ((m_x != old_x) || (m_y != old_y))
|
||||
{
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_width != old_width) || (m_height != old_height))
|
||||
{
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
|
||||
/* we set the size in GtkOnSize, i.e. mostly the actual resizing is
|
||||
done either directly before the frame is shown or in idle time
|
||||
so that different calls to SetSize() don't lead to flicker. */
|
||||
m_sizeSet = FALSE;
|
||||
}
|
||||
|
||||
m_resizing = FALSE;
|
||||
}
|
||||
|
||||
void wxFrameGTK::DoGetClientSize( int *width, int *height ) const
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
wxTopLevelWindow::DoGetClientSize( width, height );
|
||||
|
||||
wxWindow::DoGetClientSize( width, height );
|
||||
if (height)
|
||||
{
|
||||
#if wxUSE_MENUS_NATIVE
|
||||
@ -762,7 +247,8 @@ void wxFrameGTK::DoGetClientSize( int *width, int *height ) const
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
/* status bar */
|
||||
if (m_frameStatusBar && m_frameStatusBar->IsShown()) (*height) -= wxSTATUS_HEIGHT;
|
||||
if (m_frameStatusBar && m_frameStatusBar->IsShown())
|
||||
(*height) -= wxSTATUS_HEIGHT;
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
@ -788,13 +274,6 @@ void wxFrameGTK::DoGetClientSize( int *width, int *height ) const
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
/* mini edge */
|
||||
*height -= m_miniEdge*2 + m_miniTitle;
|
||||
}
|
||||
if (width)
|
||||
{
|
||||
*width -= m_miniEdge*2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -842,7 +321,7 @@ void wxFrameGTK::DoSetClientSize( int width, int height )
|
||||
}
|
||||
#endif
|
||||
|
||||
DoSetSize( -1, -1, width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0 );
|
||||
wxTopLevelWindow::DoSetClientSize( width, height );
|
||||
}
|
||||
|
||||
void wxFrameGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
|
||||
@ -1015,25 +494,9 @@ void wxFrameGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
|
||||
m_resizing = FALSE;
|
||||
}
|
||||
|
||||
void wxFrameGTK::MakeModal( bool modal )
|
||||
{
|
||||
if (modal)
|
||||
gtk_grab_add( m_widget );
|
||||
else
|
||||
gtk_grab_remove( m_widget );
|
||||
}
|
||||
|
||||
void wxFrameGTK::OnInternalIdle()
|
||||
{
|
||||
if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow))
|
||||
{
|
||||
GtkOnSize( m_x, m_y, m_width, m_height );
|
||||
|
||||
// we'll come back later
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
return;
|
||||
}
|
||||
wxTopLevelWindow::OnInternalIdle();
|
||||
|
||||
#if wxUSE_MENUS_NATIVE
|
||||
if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
|
||||
@ -1044,8 +507,6 @@ void wxFrameGTK::OnInternalIdle()
|
||||
#if wxUSE_STATUSBAR
|
||||
if (m_frameStatusBar) m_frameStatusBar->OnInternalIdle();
|
||||
#endif
|
||||
|
||||
wxWindow::OnInternalIdle();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1175,85 +636,3 @@ void wxFrameGTK::PositionStatusBar()
|
||||
}
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// frame title/icon
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFrameGTK::SetTitle( const wxString &title )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
m_title = title;
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
|
||||
}
|
||||
|
||||
void wxFrameGTK::SetIcon( const wxIcon &icon )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
wxFrameBase::SetIcon(icon);
|
||||
|
||||
if ( !m_icon.Ok() )
|
||||
return;
|
||||
|
||||
if (!m_widget->window)
|
||||
return;
|
||||
|
||||
wxMask *mask = icon.GetMask();
|
||||
GdkBitmap *bm = (GdkBitmap *) NULL;
|
||||
if (mask) bm = mask->GetBitmap();
|
||||
|
||||
gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// frame state: maximized/iconized/normal
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFrameGTK::Maximize(bool WXUNUSED(maximize))
|
||||
{
|
||||
wxFAIL_MSG( _T("not implemented") );
|
||||
}
|
||||
|
||||
bool wxFrameGTK::IsMaximized() const
|
||||
{
|
||||
// wxFAIL_MSG( _T("not implemented") );
|
||||
|
||||
// This is an approximation
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxFrameGTK::Restore()
|
||||
{
|
||||
wxFAIL_MSG( _T("not implemented") );
|
||||
}
|
||||
|
||||
void wxFrameGTK::Iconize( bool iconize )
|
||||
{
|
||||
if (iconize)
|
||||
{
|
||||
GdkWindow *window = m_widget->window;
|
||||
|
||||
// you should do it later, for example from OnCreate() handler
|
||||
wxCHECK_RET( window, _T("frame not created yet - can't iconize") );
|
||||
|
||||
XIconifyWindow( GDK_WINDOW_XDISPLAY( window ),
|
||||
GDK_WINDOW_XWINDOW( window ),
|
||||
DefaultScreen( GDK_DISPLAY() ) );
|
||||
}
|
||||
}
|
||||
|
||||
bool wxFrameGTK::IsIconized() const
|
||||
{
|
||||
return m_isIconized;
|
||||
}
|
||||
|
||||
void wxFrameGTK::SetIconizeState(bool iconize)
|
||||
{
|
||||
if ( iconize != m_isIconized )
|
||||
{
|
||||
m_isIconized = iconize;
|
||||
(void)SendIconizeEvent(iconize);
|
||||
}
|
||||
}
|
||||
|
||||
|
851
src/gtk1/toplevel.cpp
Normal file
851
src/gtk1/toplevel.cpp
Normal file
@ -0,0 +1,851 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: toplevel.cpp
|
||||
// Purpose:
|
||||
// Author: Robert Roebling
|
||||
// Id: $Id$
|
||||
// Copyright: (c) 1998 Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "toplevel.h"
|
||||
#endif
|
||||
|
||||
#ifdef __VMS
|
||||
#define XIconifyWindow XICONIFYWINDOW
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/control.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/dcclient.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#include "wx/gtk/win_gtk.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// idle system
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern void wxapp_install_idle_handler();
|
||||
extern bool g_isIdle;
|
||||
extern int g_openDialogs;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event tables
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// data
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// debug
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
|
||||
extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
|
||||
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// GTK callbacks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "focus" from m_window
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint gtk_frame_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
// This disables GTK's tab traversal
|
||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus" );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "size_allocate"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxTopLevelWindowGTK *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT)
|
||||
return;
|
||||
|
||||
if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
|
||||
{
|
||||
/*
|
||||
wxPrintf( "OnSize from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
wxPrintf( win->GetClassInfo()->GetClassName() );
|
||||
wxPrintf( " %d %d %d %d\n", (int)alloc->x,
|
||||
(int)alloc->y,
|
||||
(int)alloc->width,
|
||||
(int)alloc->height );
|
||||
*/
|
||||
|
||||
win->m_width = alloc->width;
|
||||
win->m_height = alloc->height;
|
||||
win->m_queuedFullRedraw = TRUE;
|
||||
win->GtkUpdateSize();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "delete_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxTopLevelWindowGTK *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (win->IsEnabled() &&
|
||||
(g_openDialogs == 0 || (win->GetExtraStyle() & wxTLW_EX_DIALOG)))
|
||||
win->Close();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "configure_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gint
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxTopLevelWindowGTK *win )
|
||||
#else
|
||||
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxTopLevelWindowGTK *win )
|
||||
#endif
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!win->m_hasVMT)
|
||||
return FALSE;
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
gdk_window_get_root_origin( win->m_widget->window, &x, &y );
|
||||
win->m_x = x;
|
||||
win->m_y = y;
|
||||
#else
|
||||
win->m_x = event->x;
|
||||
win->m_y = event->y;
|
||||
#endif
|
||||
|
||||
wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
|
||||
mevent.SetEventObject( win );
|
||||
win->GetEventHandler()->ProcessEvent( mevent );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "realize" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* we cannot MWM hints and icons before the widget has been realized,
|
||||
so we do this directly after realization */
|
||||
|
||||
static void
|
||||
gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxTopLevelWindowGTK *win )
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if ((win->m_miniEdge > 0) || (win->HasFlag(wxSIMPLE_BORDER)) || (win->HasFlag(wxNO_BORDER)))
|
||||
{
|
||||
/* This is a mini-frame or a borderless frame. */
|
||||
gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)0 );
|
||||
gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* All this is for Motif Window Manager "hints" and is supposed to be
|
||||
recognized by other WM as well. Not tested. */
|
||||
long decor = (long) GDK_DECOR_BORDER;
|
||||
long func = (long) GDK_FUNC_MOVE;
|
||||
|
||||
if ((win->GetWindowStyle() & wxCAPTION) != 0)
|
||||
decor |= GDK_DECOR_TITLE;
|
||||
if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
|
||||
{
|
||||
decor |= GDK_DECOR_MENU;
|
||||
func |= GDK_FUNC_CLOSE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_MINIMIZE;
|
||||
decor |= GDK_DECOR_MINIMIZE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_MAXIMIZE;
|
||||
decor |= GDK_DECOR_MAXIMIZE;
|
||||
}
|
||||
if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
|
||||
{
|
||||
func |= GDK_FUNC_RESIZE;
|
||||
decor |= GDK_DECOR_RESIZEH;
|
||||
}
|
||||
|
||||
gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
|
||||
gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
|
||||
}
|
||||
|
||||
/* GTK's shrinking/growing policy */
|
||||
if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
|
||||
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
|
||||
else
|
||||
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
|
||||
|
||||
/* reset the icon */
|
||||
wxIcon iconOld = win->GetIcon();
|
||||
if ( iconOld != wxNullIcon )
|
||||
{
|
||||
wxIcon icon( iconOld );
|
||||
win->SetIcon( wxNullIcon );
|
||||
win->SetIcon( icon );
|
||||
}
|
||||
|
||||
/* we set the focus to the child that accepts the focus. this
|
||||
doesn't really have to be done in "realize" but why not? */
|
||||
wxWindowList::Node *node = win->GetChildren().GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxWindow *child = node->GetData();
|
||||
if (child->AcceptsFocus())
|
||||
{
|
||||
child->SetFocus();
|
||||
break;
|
||||
}
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "map_event" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
gtk_frame_map_callback( GtkWidget * WXUNUSED(widget),
|
||||
GdkEvent * WXUNUSED(event),
|
||||
wxTopLevelWindow *win )
|
||||
{
|
||||
win->SetIconizeState(FALSE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "unmap_event" from m_widget
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
gtk_frame_unmap_callback( GtkWidget * WXUNUSED(widget),
|
||||
GdkEvent * WXUNUSED(event),
|
||||
wxTopLevelWindow *win )
|
||||
{
|
||||
win->SetIconizeState(TRUE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "expose_event" of m_client
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win )
|
||||
{
|
||||
GtkPizza *pizza = GTK_PIZZA(widget);
|
||||
|
||||
gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_NONE, &gdk_event->area, win->m_widget, "base", 0, 0, -1, -1);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "draw" of m_client
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win )
|
||||
{
|
||||
GtkPizza *pizza = GTK_PIZZA(widget);
|
||||
|
||||
gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_NONE, rect, win->m_widget, "base", 0, 0, -1, -1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTopLevelWindowGTK itself
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InsertChild for wxTopLevelWindowGTK
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* Callback for wxTopLevelWindowGTK. This very strange beast has to be used because
|
||||
* C++ has no virtual methods in a constructor. We have to emulate a
|
||||
* virtual function here as wxWindows requires different ways to insert
|
||||
* a child in container classes. */
|
||||
|
||||
static void wxInsertChildInTopLevelWindow( wxTopLevelWindowGTK* parent, wxWindow* child )
|
||||
{
|
||||
wxASSERT( GTK_IS_WIDGET(child->m_widget) );
|
||||
|
||||
if (!parent->m_insertInClientArea)
|
||||
{
|
||||
/* these are outside the client area */
|
||||
wxTopLevelWindowGTK* frame = (wxTopLevelWindowGTK*) parent;
|
||||
gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
|
||||
GTK_WIDGET(child->m_widget),
|
||||
child->m_x,
|
||||
child->m_y,
|
||||
child->m_width,
|
||||
child->m_height );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* these are inside the client area */
|
||||
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
|
||||
GTK_WIDGET(child->m_widget),
|
||||
child->m_x,
|
||||
child->m_y,
|
||||
child->m_width,
|
||||
child->m_height );
|
||||
}
|
||||
|
||||
/* resize on OnInternalIdle */
|
||||
parent->GtkUpdateSize();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTopLevelWindowGTK creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowGTK::Init()
|
||||
{
|
||||
m_sizeSet = FALSE;
|
||||
m_miniEdge = 0;
|
||||
m_miniTitle = 0;
|
||||
m_mainWidget = (GtkWidget*) NULL;
|
||||
m_insertInClientArea = TRUE;
|
||||
m_isFrame = TRUE;
|
||||
m_isIconized = FALSE;
|
||||
m_fsIsShowing = FALSE;
|
||||
m_themeEnabled = TRUE;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowGTK::Create( wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& sizeOrig,
|
||||
long style,
|
||||
const wxString &name )
|
||||
{
|
||||
// always create a frame of some reasonable, even if arbitrary, size (at
|
||||
// least for MSW compatibility)
|
||||
wxSize size = sizeOrig;
|
||||
if ( size.x == -1 || size.y == -1 )
|
||||
{
|
||||
wxSize sizeDpy = wxGetDisplaySize();
|
||||
if ( size.x == -1 )
|
||||
size.x = sizeDpy.x / 3;
|
||||
if ( size.y == -1 )
|
||||
size.y = sizeDpy.y / 5;
|
||||
}
|
||||
|
||||
wxTopLevelWindows.Append( this );
|
||||
|
||||
m_needParent = FALSE;
|
||||
|
||||
if (!PreCreation( parent, pos, size ) ||
|
||||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
|
||||
{
|
||||
wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_title = title;
|
||||
|
||||
m_insertCallback = (wxInsertChildFunction) wxInsertChildInTopLevelWindow;
|
||||
|
||||
GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
|
||||
|
||||
if (style & wxFRAME_TOOL_WINDOW)
|
||||
win_type = GTK_WINDOW_POPUP;
|
||||
|
||||
if (GetExtraStyle() & wxTLW_EX_DIALOG)
|
||||
win_type = GTK_WINDOW_DIALOG;
|
||||
|
||||
m_widget = gtk_window_new( win_type );
|
||||
|
||||
if ((m_parent) && (HasFlag(wxFRAME_FLOAT_ON_PARENT)) && (GTK_IS_WINDOW(m_parent->m_widget)))
|
||||
gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) );
|
||||
|
||||
if (!name.IsEmpty())
|
||||
gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
debug_focus_in( m_widget, wxT("wxTopLevelWindowGTK::m_widget"), name );
|
||||
#endif
|
||||
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
|
||||
|
||||
/* m_mainWidget holds the toolbar, the menubar and the client area */
|
||||
m_mainWidget = gtk_pizza_new();
|
||||
gtk_widget_show( m_mainWidget );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
|
||||
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
|
||||
|
||||
/* for m_mainWidget themes */
|
||||
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event",
|
||||
GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw",
|
||||
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
debug_focus_in( m_mainWidget, wxT("wxTopLevelWindowGTK::m_mainWidget"), name );
|
||||
#endif
|
||||
|
||||
/* m_wxwindow only represents the client area without toolbar and menubar */
|
||||
m_wxwindow = gtk_pizza_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
debug_focus_in( m_wxwindow, wxT("wxTopLevelWindowGTK::m_wxwindow"), name );
|
||||
#endif
|
||||
|
||||
/* we donm't allow the frame to get the focus as otherwise
|
||||
the frame will grab it at arbitrary focus changes. */
|
||||
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
|
||||
|
||||
if (m_parent) m_parent->AddChild( this );
|
||||
|
||||
/* the user resized the frame by dragging etc. */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
|
||||
/* we cannot set MWM hints and icons before the widget has
|
||||
been realized, so we do this directly after realization */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
|
||||
|
||||
/* the only way to get the window size is to connect to this event */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
|
||||
|
||||
/* map and unmap for iconized state */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "map_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_map_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "unmap_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_unmap_callback), (gpointer)this );
|
||||
|
||||
/* the only way to get the window size is to connect to this event */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
|
||||
|
||||
/* disable native tab traversal */
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "focus",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_focus_callback), (gpointer)this );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
|
||||
if (wxTheApp->GetTopWindow() == this)
|
||||
wxTheApp->SetTopWindow( (wxWindow*) NULL );
|
||||
|
||||
if ((wxTopLevelWindows.Number() == 0) &&
|
||||
(wxTheApp->GetExitOnFrameDelete()))
|
||||
{
|
||||
wxTheApp->ExitMainLoop();
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long style )
|
||||
{
|
||||
if (show == m_fsIsShowing) return FALSE; // return what?
|
||||
|
||||
m_fsIsShowing = show;
|
||||
|
||||
if (show)
|
||||
{
|
||||
m_fsSaveStyle = m_windowStyle;
|
||||
m_fsSaveFlag = style;
|
||||
GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
|
||||
GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );
|
||||
|
||||
gtk_widget_hide( m_widget );
|
||||
gtk_widget_unrealize( m_widget );
|
||||
|
||||
m_windowStyle = wxSIMPLE_BORDER;
|
||||
|
||||
int x;
|
||||
int y;
|
||||
wxDisplaySize( &x, &y );
|
||||
SetSize( 0, 0, x, y );
|
||||
|
||||
gtk_widget_realize( m_widget );
|
||||
gtk_widget_show( m_widget );
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide( m_widget );
|
||||
gtk_widget_unrealize( m_widget );
|
||||
|
||||
m_windowStyle = m_fsSaveStyle;
|
||||
|
||||
SetSize( m_fsSaveFrame.x, m_fsSaveFrame.y, m_fsSaveFrame.width, m_fsSaveFrame.height );
|
||||
|
||||
gtk_widget_realize( m_widget );
|
||||
gtk_widget_show( m_widget );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// overridden wxWindow methods
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxTopLevelWindowGTK::Show( bool show )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
if (show && !m_sizeSet)
|
||||
{
|
||||
/* by calling GtkOnSize here, we don't have to call
|
||||
either after showing the frame, which would entail
|
||||
much ugly flicker or from within the size_allocate
|
||||
handler, because GTK 1.1.X forbids that. */
|
||||
|
||||
GtkOnSize( m_x, m_y, m_width, m_height );
|
||||
}
|
||||
|
||||
return wxWindow::Show( show );
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
|
||||
{
|
||||
wxFAIL_MSG( wxT("DoMoveWindow called for wxTopLevelWindowGTK") );
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
/* this shouldn't happen: wxFrameGTK, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
|
||||
wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
|
||||
|
||||
/* avoid recursions */
|
||||
if (m_resizing)
|
||||
return;
|
||||
m_resizing = TRUE;
|
||||
|
||||
int old_x = m_x;
|
||||
int old_y = m_y;
|
||||
|
||||
int old_width = m_width;
|
||||
int old_height = m_height;
|
||||
|
||||
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
|
||||
{
|
||||
if (x != -1) m_x = x;
|
||||
if (y != -1) m_y = y;
|
||||
if (width != -1) m_width = width;
|
||||
if (height != -1) m_height = height;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
}
|
||||
|
||||
/*
|
||||
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
|
||||
{
|
||||
if (width == -1) m_width = 80;
|
||||
}
|
||||
|
||||
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
|
||||
{
|
||||
if (height == -1) m_height = 26;
|
||||
}
|
||||
*/
|
||||
|
||||
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
|
||||
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
|
||||
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
|
||||
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
|
||||
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
{
|
||||
if ((m_x != old_x) || (m_y != old_y))
|
||||
{
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_width != old_width) || (m_height != old_height))
|
||||
{
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
|
||||
/* we set the size in GtkOnSize, i.e. mostly the actual resizing is
|
||||
done either directly before the frame is shown or in idle time
|
||||
so that different calls to SetSize() don't lead to flicker. */
|
||||
m_sizeSet = FALSE;
|
||||
}
|
||||
|
||||
m_resizing = FALSE;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::DoGetClientSize( int *width, int *height ) const
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
wxWindow::DoGetClientSize( width, height );
|
||||
if (height)
|
||||
{
|
||||
/* mini edge */
|
||||
*height -= m_miniEdge*2 + m_miniTitle;
|
||||
}
|
||||
if (width)
|
||||
{
|
||||
*width -= m_miniEdge*2;
|
||||
}
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::DoSetClientSize( int width, int height )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
DoSetSize(-1, -1,
|
||||
width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0);
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
|
||||
int width, int height )
|
||||
{
|
||||
// due to a bug in gtk, x,y are always 0
|
||||
// m_x = x;
|
||||
// m_y = y;
|
||||
|
||||
/* avoid recursions */
|
||||
if (m_resizing) return;
|
||||
m_resizing = TRUE;
|
||||
|
||||
if ( m_wxwindow == NULL ) return;
|
||||
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
|
||||
/* wxMDIChildFrame derives from wxFrameGTK but it _is_ a wxWindow as it uses
|
||||
wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
|
||||
set in wxFrameGTK::Create so it is used to check what kind of frame we
|
||||
have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
|
||||
skip the part which handles m_frameMenuBar, m_frameToolBar and (most
|
||||
importantly) m_mainWidget */
|
||||
|
||||
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
|
||||
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
|
||||
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
|
||||
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
|
||||
|
||||
if (m_mainWidget)
|
||||
{
|
||||
/* set size hints */
|
||||
gint flag = 0; // GDK_HINT_POS;
|
||||
if ((m_minWidth != -1) || (m_minHeight != -1)) flag |= GDK_HINT_MIN_SIZE;
|
||||
if ((m_maxWidth != -1) || (m_maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE;
|
||||
GdkGeometry geom;
|
||||
geom.min_width = m_minWidth;
|
||||
geom.min_height = m_minHeight;
|
||||
geom.max_width = m_maxWidth;
|
||||
geom.max_height = m_maxHeight;
|
||||
gtk_window_set_geometry_hints( GTK_WINDOW(m_widget),
|
||||
(GtkWidget*) NULL,
|
||||
&geom,
|
||||
(GdkWindowHints) flag );
|
||||
|
||||
/* I revert back to wxGTK's original behaviour. m_mainWidget holds the
|
||||
* menubar, the toolbar and the client area, which is represented by
|
||||
* m_wxwindow.
|
||||
* this hurts in the eye, but I don't want to call SetSize()
|
||||
* because I don't want to call any non-native functions here. */
|
||||
|
||||
int client_x = m_miniEdge;
|
||||
int client_y = m_miniEdge + m_miniTitle;
|
||||
int client_w = m_width - 2*m_miniEdge;
|
||||
int client_h = m_height - 2*m_miniEdge - m_miniTitle;
|
||||
gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
|
||||
m_wxwindow,
|
||||
client_x, client_y, client_w, client_h );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if there is no m_mainWidget between m_widget and m_wxwindow there
|
||||
is no need to set the size or position of m_wxwindow. */
|
||||
}
|
||||
|
||||
m_sizeSet = TRUE;
|
||||
|
||||
// send size event to frame
|
||||
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
|
||||
event.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent( event );
|
||||
|
||||
m_resizing = FALSE;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::OnInternalIdle()
|
||||
{
|
||||
if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow))
|
||||
{
|
||||
GtkOnSize( m_x, m_y, m_width, m_height );
|
||||
|
||||
// we'll come back later
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
return;
|
||||
}
|
||||
|
||||
wxWindow::OnInternalIdle();
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// frame title/icon
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowGTK::SetTitle( const wxString &title )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
m_title = title;
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
||||
wxTopLevelWindowBase::SetIcon(icon);
|
||||
|
||||
if ( !m_icon.Ok() )
|
||||
return;
|
||||
|
||||
if (!m_widget->window)
|
||||
return;
|
||||
|
||||
wxMask *mask = icon.GetMask();
|
||||
GdkBitmap *bm = (GdkBitmap *) NULL;
|
||||
if (mask) bm = mask->GetBitmap();
|
||||
|
||||
gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// frame state: maximized/iconized/normal
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowGTK::Maximize(bool WXUNUSED(maximize))
|
||||
{
|
||||
wxFAIL_MSG( _T("not implemented") );
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowGTK::IsMaximized() const
|
||||
{
|
||||
// wxFAIL_MSG( _T("not implemented") );
|
||||
|
||||
// This is an approximation
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::Restore()
|
||||
{
|
||||
wxFAIL_MSG( _T("not implemented") );
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::Iconize( bool iconize )
|
||||
{
|
||||
if (iconize)
|
||||
{
|
||||
GdkWindow *window = m_widget->window;
|
||||
|
||||
// you should do it later, for example from OnCreate() handler
|
||||
wxCHECK_RET( window, _T("frame not created yet - can't iconize") );
|
||||
|
||||
XIconifyWindow( GDK_WINDOW_XDISPLAY( window ),
|
||||
GDK_WINDOW_XWINDOW( window ),
|
||||
DefaultScreen( GDK_DISPLAY() ) );
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowGTK::IsIconized() const
|
||||
{
|
||||
return m_isIconized;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::SetIconizeState(bool iconize)
|
||||
{
|
||||
if ( iconize != m_isIconized )
|
||||
{
|
||||
m_isIconized = iconize;
|
||||
(void)SendIconizeEvent(iconize);
|
||||
}
|
||||
}
|
||||
|
191
src/mgl/toplevel.cpp
Normal file
191
src/mgl/toplevel.cpp
Normal file
@ -0,0 +1,191 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: toplevel.cpp
|
||||
// Purpose:
|
||||
// Author: Vaclav Slavik
|
||||
// Id: $Id$
|
||||
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "toplevel.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/toplevel.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// idle system
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern void wxapp_install_idle_handler();
|
||||
extern bool g_isIdle;
|
||||
extern int g_openDialogs;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event tables
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// data
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
void wxTopLevelWindowMGL::Init()
|
||||
{
|
||||
m_isIconized = FALSE;
|
||||
m_isMaximized = FALSE;
|
||||
m_fsIsShowing = FALSE;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowMGL::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& sizeOrig,
|
||||
long style,
|
||||
const wxString &name)
|
||||
{
|
||||
// always create a frame of some reasonable, even if arbitrary, size (at
|
||||
// least for MSW compatibility)
|
||||
wxSize size = sizeOrig;
|
||||
if ( size.x == -1 || size.y == -1 )
|
||||
{
|
||||
wxSize sizeDpy = wxGetDisplaySize();
|
||||
if ( size.x == -1 )
|
||||
size.x = sizeDpy.x / 3;
|
||||
if ( size.y == -1 )
|
||||
size.y = sizeDpy.y / 5;
|
||||
}
|
||||
|
||||
wxTopLevelWindows.Append(this);
|
||||
|
||||
m_title = title;
|
||||
|
||||
|
||||
if (m_parent)
|
||||
m_parent->AddChild(this);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxTopLevelWindowMGL::~wxTopLevelWindowMGL()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
|
||||
wxTopLevelWindows.DeleteObject(this);
|
||||
|
||||
if (wxTheApp->GetTopWindow() == this)
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
|
||||
if ((wxTopLevelWindows.Number() == 0) &&
|
||||
(wxTheApp->GetExitOnFrameDelete()))
|
||||
{
|
||||
wxTheApp->ExitMainLoop();
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowMGL::ShowFullScreen(bool show, long style)
|
||||
{
|
||||
if (show == m_fsIsShowing) return FALSE; // return what?
|
||||
|
||||
m_fsIsShowing = show;
|
||||
|
||||
if (show)
|
||||
{
|
||||
m_fsSaveStyle = m_windowStyle;
|
||||
m_fsSaveFlag = style;
|
||||
GetPosition(&m_fsSaveFrame.x, &m_fsSaveFrame.y);
|
||||
GetSize(&m_fsSaveFrame.width, &m_fsSaveFrame.height);
|
||||
|
||||
if ( style & wxFULLSCREEN_NOCAPTION )
|
||||
m_windowStyle &= !wxCAPTION;
|
||||
if ( style & wxFULLSCREEN_NOBORDER )
|
||||
m_windowStyle = wxSIMPLE_BORDER;
|
||||
|
||||
int x, y;
|
||||
wxDisplaySize(&x, &y);
|
||||
SetSize(0, 0, x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_windowStyle = m_fsSaveStyle;
|
||||
SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
|
||||
m_fsSaveFrame.width, m_fsSaveFrame.height);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowMGL::Maximize(bool maximize)
|
||||
{
|
||||
if ( maximize && !m_isMaximized )
|
||||
{
|
||||
int x, y, w, h;
|
||||
|
||||
GetPosition(&m_savedFrame.x, &m_savedFrame.y);
|
||||
GetSize(&m_savedFrame.width, &m_savedFrame.height);
|
||||
|
||||
wxClientDisplayRect(&x, &y, &w, &h);
|
||||
SetSize(x, y, w, h);
|
||||
m_isMaximized = TRUE;
|
||||
}
|
||||
else if ( !maximize && m_isMaximized )
|
||||
{
|
||||
SetSize(m_savedFrame.x, m_savedFrame.y,
|
||||
m_savedFrame.width, m_savedFrame.height);
|
||||
m_isMaximized = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowMGL::IsMaximized() const
|
||||
{
|
||||
return m_isMaximized;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowMGL::Restore()
|
||||
{
|
||||
if ( m_isIconized )
|
||||
{
|
||||
Iconize(FALSE);
|
||||
}
|
||||
if ( m_isMaximized )
|
||||
{
|
||||
Maximize(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void wxTopLevelWindowMGL::Iconize(bool iconize)
|
||||
{
|
||||
// FIXME_MGL
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowMGL::IsIconized() const
|
||||
{
|
||||
return m_isIconized;
|
||||
}
|
Loading…
Reference in New Issue
Block a user