1. wxMotif::wxFrame derives from wxFrameBase now

2. wxFrame::GetClientAreaOrigin() made common to all ports and documented


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4785 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-12-01 15:23:56 +00:00
parent 7941ba111c
commit 1c4f8f8d18
11 changed files with 214 additions and 585 deletions

View File

@@ -1,12 +1,14 @@
\section{\class{wxFrame}}\label{wxframe} \section{\class{wxFrame}}\label{wxframe}
A frame is a window whose size and position can (usually) be changed by the user. It usually has A frame is a window whose size and position can (usually) be changed by the
thick borders and a title bar, and can optionally contain a menu bar, toolbar and user. It usually has thick borders and a title bar, and can optionally contain
status bar. A frame can contain any window that is not a frame or dialog. a menu bar, toolbar and status bar. A frame can contain any window that is not
a frame or dialog.
A frame that has a status bar and toolbar created via the CreateStatusBar/CreateToolBar functions A frame that has a status bar and toolbar created via the
manages these windows, and adjusts the value returned by GetClientSize to reflect CreateStatusBar/CreateToolBar functions manages these windows, and adjusts the
the remaining size available to application windows. value returned by GetClientSize to reflect the remaining size available to
application windows.
\wxheading{Derived from} \wxheading{Derived from}
@@ -37,7 +39,7 @@ the remaining size available to application windows.
\twocolitem{\windowstyle{wxFRAME\_FLOAT\_ON\_PARENT}}{Causes the frame to be above the parent window in the \twocolitem{\windowstyle{wxFRAME\_FLOAT\_ON\_PARENT}}{Causes the frame to be above the parent window in the
z-order and not shown in the taskbar. Without this style, frames are created as top-level windows that may be obscured by z-order and not shown in the taskbar. Without this style, frames are created as top-level windows that may be obscured by
the parent window, and frame titles are shown in the taskbar. Windows only. } the parent window, and frame titles are shown in the taskbar. Windows only. }
\twocolitem{\windowstyle{wxFRAME\_TOOL\_WINDOW}}Causes a frame with a small titlebar to be created; \twocolitem{\windowstyle{wxFRAME\_TOOL\_WINDOW}}{Causes a frame with a small titlebar to be created;
the frame title does not appear in the taskbar. Windows only. } the frame title does not appear in the taskbar. Windows only. }
\end{twocollist} \end{twocollist}
@@ -214,6 +216,13 @@ reflect the available space for application windows.
\helpref{wxFrame::SetToolBar}{wxframesettoolbar},\rtfsp \helpref{wxFrame::SetToolBar}{wxframesettoolbar},\rtfsp
\helpref{wxFrame::GetToolBar}{wxframegettoolbar} \helpref{wxFrame::GetToolBar}{wxframegettoolbar}
\membersection{wxFrame::GetClientAreaOrigin}\label{wxframegetclientareaorigin}
\constfunc{wxPoint}{GetClientAreaOrigin}{\void}
Returns the origin of the frame client area (in client coordinates). It may be
different from (0, 0) if the frame has a toolbar.
\membersection{wxFrame::GetMenuBar}\label{wxframegetmenubar} \membersection{wxFrame::GetMenuBar}\label{wxframegetmenubar}
\constfunc{wxMenuBar*}{GetMenuBar}{\void} \constfunc{wxMenuBar*}{GetMenuBar}{\void}

View File

@@ -85,6 +85,10 @@ public:
// make the window modal (all other windows unresponsive) // make the window modal (all other windows unresponsive)
virtual void MakeModal(bool modal = TRUE); 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;
// menu bar functions // menu bar functions
// ------------------ // ------------------
@@ -190,6 +194,11 @@ protected:
wxToolBar *m_frameToolBar; wxToolBar *m_frameToolBar;
#endif // wxUSE_TOOLBAR #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;
// the frame icon // the frame icon
wxIcon m_icon; wxIcon m_icon;

View File

@@ -109,7 +109,7 @@ protected:
// common part of all ctors // common part of all ctors
void Init(); void Init();
// override wxWindow methods to take into account tool/menu/statusbars // override wxWindow methods to take into account tool/menu/statusbars
virtual void DoSetSize(int x, int y, virtual void DoSetSize(int x, int y,
int width, int height, int width, int height,
int sizeFlags = wxSIZE_AUTO); int sizeFlags = wxSIZE_AUTO);

View File

@@ -109,7 +109,7 @@ protected:
// common part of all ctors // common part of all ctors
void Init(); void Init();
// override wxWindow methods to take into account tool/menu/statusbars // override wxWindow methods to take into account tool/menu/statusbars
virtual void DoSetSize(int x, int y, virtual void DoSetSize(int x, int y,
int width, int height, int width, int height,
int sizeFlags = wxSIZE_AUTO); int sizeFlags = wxSIZE_AUTO);

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: frame.h // Name: wx/motif/frame.h
// Purpose: wxFrame class // Purpose: wxFrame class
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
@@ -9,30 +9,17 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FRAME_H_ #ifndef _WX_MOTIF_FRAME_H_
#define _WX_FRAME_H_ #define _WX_MOTIF_FRAME_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "frame.h" #pragma interface "frame.h"
#endif #endif
#include "wx/window.h" class WXDLLEXPORT wxFrame : public wxFrameBase
#include "wx/toolbar.h"
#include "wx/accel.h"
#include "wx/icon.h"
WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr;
WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr;
class WXDLLEXPORT wxMenuBar;
class WXDLLEXPORT wxStatusBar;
class WXDLLEXPORT wxFrame : public wxWindow
{ {
DECLARE_DYNAMIC_CLASS(wxFrame)
public: public:
wxFrame(); wxFrame() { Init(); }
wxFrame(wxWindow *parent, wxFrame(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxString& title, const wxString& title,
@@ -41,126 +28,75 @@ public:
long style = wxDEFAULT_FRAME_STYLE, long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr) const wxString& name = wxFrameNameStr)
{ {
Init();
Create(parent, id, title, pos, size, style, name); Create(parent, id, title, pos, size, style, name);
} }
~wxFrame();
bool Create(wxWindow *parent, bool Create(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxString& title, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE, long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr); const wxString& name = wxFrameNameStr);
virtual bool Destroy(); virtual ~wxFrame();
void ClientToScreen(int *x, int *y) const;
wxPoint ClientToScreen(const wxPoint& pt) const { return wxWindow::ClientToScreen(pt); }
void ScreenToClient(int *x, int *y) const;
wxPoint ScreenToClient(const wxPoint& pt) const { return wxWindow::ScreenToClient(pt); }
void OnSize(wxSizeEvent& event);
void OnMenuHighlight(wxMenuEvent& event);
void OnActivate(wxActivateEvent& event);
void OnIdle(wxIdleEvent& event);
void OnCloseWindow(wxCloseEvent& event);
bool Show(bool show); bool Show(bool show);
// Set menu bar // Set menu bar
void SetMenuBar(wxMenuBar *menu_bar); void SetMenuBar(wxMenuBar *menu_bar);
virtual wxMenuBar *GetMenuBar() const ;
// Set title // Set title
void SetTitle(const wxString& title); void SetTitle(const wxString& title);
wxString GetTitle() const { return m_title; } wxString GetTitle() const { return m_title; }
virtual bool IsTopLevel() const { return TRUE; }
void Centre(int direction = wxBOTH);
// Call this to simulate a menu command
virtual void Command(int id);
virtual void ProcessCommand(int id);
// Set icon // Set icon
virtual void SetIcon(const wxIcon& icon); virtual void SetIcon(const wxIcon& icon);
// Create status line #if wxUSE_STATUSBAR
virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
const wxString& name = "statusBar");
wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
virtual void PositionStatusBar(); virtual void PositionStatusBar();
virtual wxStatusBar *OnCreateStatusBar(int number, long style, wxWindowID id, #endif // wxUSE_STATUSBAR
const wxString& name);
// Create toolbar // Create toolbar
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, const wxString& name = wxToolBarNameStr); virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, const wxString& name = wxToolBarNameStr);
virtual wxToolBar *OnCreateToolBar(long style, wxWindowID id, const wxString& name);
// If made known to the frame, the frame will manage it automatically.
virtual void SetToolBar(wxToolBar *toolbar) ;
virtual wxToolBar *GetToolBar() const ;
virtual void PositionToolBar(); virtual void PositionToolBar();
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
// Set status line text
virtual void SetStatusText(const wxString& text, int number = 0);
// Set status line widths
virtual void SetStatusWidths(int n, const int widths_field[]);
// Hint to tell framework which status bar to use
// TODO: should this go into a wxFrameworkSettings class perhaps?
static void UseNativeStatusBar(bool useNative) { m_useNativeStatusBar = useNative; };
static bool UsesNativeStatusBar() { return m_useNativeStatusBar; };
// Fit frame around subwindows
virtual void Fit();
// Iconize // Iconize
virtual void Iconize(bool iconize); virtual void Iconize(bool iconize);
virtual bool IsIconized() const ; virtual bool IsIconized() const;
// Compatibility
bool Iconized() const { return IsIconized(); }
// Is the frame maximized? Returns FALSE under Motif (but TRUE for // Is the frame maximized? Returns FALSE under Motif (but TRUE for
// wxMDIChildFrame due to the tabbed implementation). // wxMDIChildFrame due to the tabbed implementation).
virtual bool IsMaximized(void) const ; virtual bool IsMaximized() const;
virtual void Maximize(bool maximize); virtual void Maximize(bool maximize);
// Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event);
// Query app for menu item updates (called from OnIdle)
void DoMenuUpdates();
void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
// Checks if there is a toolbar, and returns the first free client position
virtual wxPoint GetClientAreaOrigin() const;
virtual void Raise(); virtual void Raise();
virtual void Lower(); virtual void Lower();
virtual void CaptureMouse(); virtual void Restore();
virtual void ReleaseMouse();
// Implementation only from now on
// -------------------------------
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnActivate(wxActivateEvent& event);
// Implementation
virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour(); virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour(); virtual void ChangeForegroundColour();
WXWidget GetMenuBarWidget() const ; WXWidget GetMenuBarWidget() const;
WXWidget GetShellWidget() const { return m_frameShell; } WXWidget GetShellWidget() const { return m_frameShell; }
WXWidget GetWorkAreaWidget() const { return m_workArea; } WXWidget GetWorkAreaWidget() const { return m_workArea; }
WXWidget GetClientAreaWidget() const { return m_clientArea; } WXWidget GetClientAreaWidget() const { return m_clientArea; }
WXWidget GetTopWidget() const { return m_frameShell; } WXWidget GetTopWidget() const { return m_frameShell; }
WXWidget GetMainWindowWidget() const { return m_frameWidget; }
virtual WXWidget GetMainWidget() const { return m_frameWidget; }
// The widget that can have children on it // The widget that can have children on it
WXWidget GetClientWidget() const; WXWidget GetClientWidget() const;
@@ -169,40 +105,30 @@ public:
bool PreResize(); bool PreResize();
protected: protected:
void DoGetClientSize(int *width, int *height) const; // common part of all ctors
void DoGetSize(int *width, int *height) const ; void Init();
void DoGetPosition(int *x, int *y) const ;
protected:
wxMenuBar * m_frameMenuBar;
wxStatusBar * m_frameStatusBar;
wxIcon m_icon;
bool m_iconized;
static bool m_useNativeStatusBar;
#if wxUSE_TOOLBAR
wxToolBar * m_frameToolBar ;
#endif // wxUSE_TOOLBAR
//// Motif-specific //// Motif-specific
WXWidget m_frameShell; WXWidget m_frameShell;
WXWidget m_frameWidget; WXWidget m_frameWidget;
WXWidget m_workArea; WXWidget m_workArea;
WXWidget m_clientArea; WXWidget m_clientArea;
// WXWidget m_menuBarWidget;
bool m_visibleStatus;
wxString m_title; wxString m_title;
bool m_visibleStatus;
bool m_iconized;
virtual void DoGetClientSize(int *width, int *height) const;
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetPosition(int *x, int *y) const;
virtual void DoSetSize(int x, int y, virtual void DoSetSize(int x, int y,
int width, int height, int width, int height,
int sizeFlags = wxSIZE_AUTO); int sizeFlags = wxSIZE_AUTO);
virtual void DoSetClientSize(int width, int height); virtual void DoSetClientSize(int width, int height);
private: private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxFrame)
}; };
#endif #endif
// _WX_FRAME_H_ // _WX_MOTIF_FRAME_H_

View File

@@ -94,10 +94,6 @@ public:
WXHMENU GetWinMenu() const { return m_hMenu; } WXHMENU GetWinMenu() const { return m_hMenu; }
// Returns the origin of client area (may be different from (0,0) if the
// frame has a toolbar)
virtual wxPoint GetClientAreaOrigin() const;
// event handlers // event handlers
bool HandlePaint(); bool HandlePaint();
bool HandleSize(int x, int y, WXUINT flag); bool HandleSize(int x, int y, WXUINT flag);
@@ -128,9 +124,6 @@ protected:
virtual void DoSetClientSize(int width, int height); virtual void DoSetClientSize(int width, int height);
virtual void DoClientToScreen(int *x, int *y) const;
virtual void DoScreenToClient(int *x, int *y) const;
// helper // helper
void DetachMenuBar(); void DetachMenuBar();

View File

@@ -349,7 +349,7 @@ void MyFrame::OnToolLeftClick(wxCommandEvent& event)
{ {
DoToggleHelp(); DoToggleHelp();
} }
if (event.GetId() == wxID_PRINT) if (event.GetId() == wxID_PRINT)
{ {
DoDeletePrint(); DoDeletePrint();
@@ -373,8 +373,9 @@ void MyFrame::DoEnablePrint()
void MyFrame::DoDeletePrint() void MyFrame::DoDeletePrint()
{ {
wxToolBar *tb = GetToolBar(); wxToolBar *tb = GetToolBar();
// Not implemented in MSW
#ifdef __WXMSW__ // only implemented in wxGTK for now
#ifndef __WXGTK__
wxMessageBox("Sorry, wxToolBar::DeleteTool is not implemented under Windows."); wxMessageBox("Sorry, wxToolBar::DeleteTool is not implemented under Windows.");
#else #else
tb->DeleteTool( wxID_PRINT ); tb->DeleteTool( wxID_PRINT );

View File

@@ -117,6 +117,61 @@ void wxFrameBase::DeleteAllBars()
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
} }
// ----------------------------------------------------------------------------
// wxFrame size management: we exclude the areas taken by menu/status/toolbars
// from the client area, so the client area is what's really available for the
// frame contents
// ----------------------------------------------------------------------------
// get the origin of the client area in the client coordinates
wxPoint wxFrameBase::GetClientAreaOrigin() const
{
wxPoint pt(0, 0);
#if wxUSE_TOOLBAR
if ( GetToolBar() )
{
int w, h;
GetToolBar()->GetSize(& w, & h);
if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
{
pt.x += w;
}
else
{
pt.y += h;
}
}
#endif // wxUSE_TOOLBAR
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 // misc
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: frame.cpp // Name: motif/frame.cpp
// Purpose: wxFrame // Purpose: wxFrame
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
@@ -9,8 +9,16 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "frame.h" #pragma implementation "frame.h"
#endif #endif
#include "wx/frame.h" #include "wx/frame.h"
@@ -25,18 +33,19 @@
#include "wx/utils.h" #include "wx/utils.h"
#ifdef __VMS__ #ifdef __VMS__
#pragma message disable nosimpint #pragma message disable nosimpint
#endif #endif
#if defined(__ultrix) || defined(__sgi) #if defined(__ultrix) || defined(__sgi)
#include <Xm/Frame.h> #include <Xm/Frame.h>
#endif #endif
#include <Xm/Xm.h> #include <Xm/Xm.h>
#include <X11/Shell.h> #include <X11/Shell.h>
#if XmVersion >= 1002 #if XmVersion >= 1002
#include <Xm/XmAll.h> #include <Xm/XmAll.h>
#else #else
#include <Xm/Frame.h> #include <Xm/Frame.h>
#endif #endif
#include <Xm/MwmUtil.h> #include <Xm/MwmUtil.h>
#include <Xm/BulletinB.h> #include <Xm/BulletinB.h>
@@ -48,20 +57,29 @@
#include <Xm/LabelG.h> #include <Xm/LabelG.h>
#include <Xm/Frame.h> #include <Xm/Frame.h>
#if XmVersion > 1000 #if XmVersion > 1000
#include <Xm/Protocols.h> #include <Xm/Protocols.h>
#endif #endif
#ifdef __VMS__ #ifdef __VMS__
#pragma message enable nosimpint #pragma message enable nosimpint
#endif #endif
#include "wx/motif/private.h" #include "wx/motif/private.h"
void wxCloseFrameCallback(Widget, XtPointer, XmAnyCallbackStruct *cbs); // ----------------------------------------------------------------------------
void wxFrameFocusProc(Widget workArea, XtPointer clientData, // private functions
XmAnyCallbackStruct *cbs); // ----------------------------------------------------------------------------
static void wxCloseFrameCallback(Widget, XtPointer, XmAnyCallbackStruct *cbs);
static void wxFrameFocusProc(Widget workArea, XtPointer clientData,
XmAnyCallbackStruct *cbs);
static void wxFrameMapProc(Widget frameShell, XtPointer clientData, static void wxFrameMapProc(Widget frameShell, XtPointer clientData,
XCrossingEvent * event); XCrossingEvent * event);
// ----------------------------------------------------------------------------
// globals
// ----------------------------------------------------------------------------
extern wxList wxModelessWindows; extern wxList wxModelessWindows;
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
@@ -69,35 +87,29 @@ extern wxList wxPendingDelete;
// top frame // top frame
static bool wxTopLevelUsed = FALSE; static bool wxTopLevelUsed = FALSE;
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxFrame, wxWindow) BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
EVT_SIZE(wxFrame::OnSize) EVT_ACTIVATE(wxFrame::OnActivate)
EVT_ACTIVATE(wxFrame::OnActivate) EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
EVT_IDLE(wxFrame::OnIdle)
EVT_CLOSE(wxFrame::OnCloseWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
#endif #endif
#if wxUSE_NATIVE_STATUSBAR // ============================================================================
bool wxFrame::m_useNativeStatusBar = TRUE; // implementation
#else // ============================================================================
bool wxFrame::m_useNativeStatusBar = FALSE;
#endif
wxFrame::wxFrame() // ----------------------------------------------------------------------------
// frame construction
// ----------------------------------------------------------------------------
void wxFrame::Init()
{ {
#if wxUSE_TOOLBAR
m_frameToolBar = NULL ;
#endif // wxUSE_TOOLBAR
m_frameMenuBar = NULL;
m_frameStatusBar = NULL;
m_parent = NULL;
m_iconized = FALSE; m_iconized = FALSE;
//// Motif-specific //// Motif-specific
@@ -106,7 +118,6 @@ wxFrame::wxFrame()
m_workArea = (WXWidget) NULL;; m_workArea = (WXWidget) NULL;;
m_clientArea = (WXWidget) NULL;; m_clientArea = (WXWidget) NULL;;
m_visibleStatus = TRUE; m_visibleStatus = TRUE;
m_title = "";
} }
bool wxFrame::Create(wxWindow *parent, bool wxFrame::Create(wxWindow *parent,
@@ -117,25 +128,16 @@ bool wxFrame::Create(wxWindow *parent,
long style, long style,
const wxString& name) const wxString& name)
{ {
if (!parent) if ( parent )
AddChild(this);
else
wxTopLevelWindows.Append(this); wxTopLevelWindows.Append(this);
wxModelessWindows.Append(this);
SetName(name); SetName(name);
m_windowStyle = style; m_windowStyle = style;
m_frameMenuBar = NULL;
#if wxUSE_TOOLBAR
m_frameToolBar = NULL ;
#endif // wxUSE_TOOLBAR
m_frameStatusBar = NULL;
//// Motif-specific
m_frameShell = (WXWidget) NULL;
m_frameWidget = (WXWidget) NULL;;
m_workArea = (WXWidget) NULL;;
m_clientArea = (WXWidget) NULL;;
m_visibleStatus = TRUE;
m_title = "";
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE); m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
m_foregroundColour = *wxBLACK; m_foregroundColour = *wxBLACK;
@@ -146,10 +148,6 @@ bool wxFrame::Create(wxWindow *parent,
else else
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
if (parent) parent->AddChild(this);
wxModelessWindows.Append(this);
int x = pos.x, y = pos.y; int x = pos.x, y = pos.y;
int width = size.x, height = size.y; int width = size.x, height = size.y;
@@ -177,6 +175,7 @@ bool wxFrame::Create(wxWindow *parent,
if (y < 10) y = 10; if (y < 10) y = 10;
} }
// VZ: what does this do??
if (wxTopLevelUsed) if (wxTopLevelUsed)
{ {
// Change suggested by Matthew Flatt // Change suggested by Matthew Flatt
@@ -204,9 +203,9 @@ bool wxFrame::Create(wxWindow *parent,
XmNiconic, (style & wxICONIZE) ? TRUE : FALSE, XmNiconic, (style & wxICONIZE) ? TRUE : FALSE,
NULL); NULL);
if (!title.IsNull()) if (!title.IsEmpty())
XtVaSetValues((Widget) m_frameShell, XtVaSetValues((Widget) m_frameShell,
XmNtitle, (const char*) title, XmNtitle, title.c_str(),
NULL); NULL);
m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window", m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
@@ -230,7 +229,8 @@ bool wxFrame::Create(wxWindow *parent,
// XmNresizePolicy, XmRESIZE_ANY, // XmNresizePolicy, XmRESIZE_ANY,
NULL); NULL);
wxLogDebug("Created frame (0x%08x) with work area 0x%08x and client " wxLogTrace(wxTRACE_Messages,
"Created frame (0x%08x) with work area 0x%08x and client "
"area 0x%08x", m_frameWidget, m_workArea, m_clientArea); "area 0x%08x", m_frameWidget, m_workArea, m_clientArea);
XtAddEventHandler((Widget) m_clientArea, ExposureMask,FALSE, XtAddEventHandler((Widget) m_clientArea, ExposureMask,FALSE,
@@ -245,7 +245,7 @@ bool wxFrame::Create(wxWindow *parent,
wxAddWindowToTable((Widget) m_workArea, this); wxAddWindowToTable((Widget) m_workArea, this);
XtTranslations ptr ; XtTranslations ptr;
XtOverrideTranslations((Widget) m_workArea, XtOverrideTranslations((Widget) m_workArea,
ptr = XtParseTranslationTable("<Configure>: resize()")); ptr = XtParseTranslationTable("<Configure>: resize()"));
@@ -276,9 +276,9 @@ bool wxFrame::Create(wxWindow *parent,
// This patch comes from Torsten Liermann lier@lier1.muc.de // This patch comes from Torsten Liermann lier@lier1.muc.de
if (XmIsMotifWMRunning( (Widget) m_frameShell )) if (XmIsMotifWMRunning( (Widget) m_frameShell ))
{ {
int decor = 0 ; int decor = 0;
if (style & wxRESIZE_BORDER) if (style & wxRESIZE_BORDER)
decor |= MWM_DECOR_RESIZEH ; decor |= MWM_DECOR_RESIZEH;
if (style & wxSYSTEM_MENU) if (style & wxSYSTEM_MENU)
decor |= MWM_DECOR_MENU; decor |= MWM_DECOR_MENU;
if ((style & wxCAPTION) || if ((style & wxCAPTION) ||
@@ -293,7 +293,7 @@ bool wxFrame::Create(wxWindow *parent,
decor |= MWM_DECOR_MINIMIZE; decor |= MWM_DECOR_MINIMIZE;
if (style & wxMAXIMIZE_BOX) if (style & wxMAXIMIZE_BOX)
decor |= MWM_DECOR_MAXIMIZE; decor |= MWM_DECOR_MAXIMIZE;
XtVaSetValues((Widget) m_frameShell,XmNmwmDecorations,decor,NULL) ; XtVaSetValues((Widget) m_frameShell,XmNmwmDecorations,decor,NULL);
} }
// This allows non-Motif window managers to support at least the // This allows non-Motif window managers to support at least the
// no-decorations case. // no-decorations case.
@@ -355,23 +355,13 @@ wxFrame::~wxFrame()
wxModelessWindows.DeleteObject(this); wxModelessWindows.DeleteObject(this);
if (m_frameStatusBar) if (m_frameStatusBar)
{
delete m_frameStatusBar; delete m_frameStatusBar;
m_frameStatusBar = NULL;
}
DestroyChildren(); DestroyChildren();
/*
int i;
for (i = 0; i < wxMAX_STATUS; i++)
if (statusTextWidget[i])
XtDestroyWidget (statusTextWidget[i]);
if (statusLineForm)
XtDestroyWidget (statusLineForm);
if (statusLineWidget)
XtDestroyWidget (statusLineWidget);
*/
if (m_workArea) if (m_workArea)
{ {
wxDeleteWindowFromTable((Widget) m_workArea); wxDeleteWindowFromTable((Widget) m_workArea);
@@ -402,7 +392,6 @@ wxFrame::~wxFrame()
wxTheApp->ExitMainLoop(); wxTheApp->ExitMainLoop();
} }
} }
} }
// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
@@ -572,13 +561,18 @@ void wxFrame::Iconize(bool iconize)
XtVaSetValues((Widget) m_frameShell, XmNiconic, (Boolean)iconize, NULL); XtVaSetValues((Widget) m_frameShell, XmNiconic, (Boolean)iconize, NULL);
} }
// Equivalent to maximize/restore in Windows void wxFrame::Restore()
{
if ( m_frameShell )
XtVaSetValues((Widget) m_frameShell, XmNiconic, FALSE, NULL);
}
void wxFrame::Maximize(bool maximize) void wxFrame::Maximize(bool maximize)
{ {
Show(TRUE); Show(TRUE);
if (maximize && m_frameShell) if ( maximize )
XtVaSetValues((Widget) m_frameShell, XmNiconic, FALSE, NULL); Restore();
} }
bool wxFrame::IsIconized() const bool wxFrame::IsIconized() const
@@ -592,7 +586,7 @@ bool wxFrame::IsIconized() const
} }
// Is it maximized? // Is it maximized?
bool wxFrame::IsMaximized(void) const bool wxFrame::IsMaximized() const
{ {
// No maximizing in Motif (?) // No maximizing in Motif (?)
return FALSE; return FALSE;
@@ -607,8 +601,8 @@ void wxFrame::SetTitle(const wxString& title)
if (!title.IsNull()) if (!title.IsNull())
XtVaSetValues((Widget) m_frameShell, XtVaSetValues((Widget) m_frameShell,
XmNtitle, (const char*) title, XmNtitle, title.c_str(),
XmNiconName, (const char*) title, XmNiconName, title.c_str(),
NULL); NULL);
} }
@@ -625,62 +619,6 @@ void wxFrame::SetIcon(const wxIcon& icon)
XtVaSetValues((Widget) m_frameShell, XtNiconPixmap, icon.GetPixmap(), NULL); XtVaSetValues((Widget) m_frameShell, XtNiconPixmap, icon.GetPixmap(), NULL);
} }
wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
const wxString& name)
{
wxStatusBar *statusBar = NULL;
statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20),
style, name);
// Set the height according to the font and the border size
wxClientDC dc(statusBar);
dc.SetFont(statusBar->GetFont());
long x, y;
dc.GetTextExtent("X", &x, &y);
int height = (int)( (y * 1.1) + 2* statusBar->GetBorderY());
statusBar->SetSize(-1, -1, 100, height);
statusBar->SetFieldsCount(number);
return statusBar;
}
wxStatusBar* wxFrame::CreateStatusBar(int number, long style, wxWindowID id,
const wxString& name)
{
// Calling CreateStatusBar twice is an error.
wxCHECK_MSG( m_frameStatusBar == NULL, FALSE,
"recreating status bar in wxFrame" );
m_frameStatusBar = OnCreateStatusBar(number, style, id,
name);
if ( m_frameStatusBar )
{
PositionStatusBar();
return m_frameStatusBar;
}
else
return NULL;
}
void wxFrame::SetStatusText(const wxString& text, int number)
{
wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" );
m_frameStatusBar->SetStatusText(text, number);
}
void wxFrame::SetStatusWidths(int n, const int widths_field[])
{
wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" );
m_frameStatusBar->SetStatusWidths(n, widths_field);
PositionStatusBar();
}
void wxFrame::PositionStatusBar() void wxFrame::PositionStatusBar()
{ {
if (!m_frameStatusBar) if (!m_frameStatusBar)
@@ -725,35 +663,6 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar)
m_frameMenuBar->CreateMenuBar(this); m_frameMenuBar->CreateMenuBar(this);
} }
void wxFrame::Fit()
{
// Work out max. size
wxNode *node = GetChildren().First();
int max_width = 0;
int max_height = 0;
while (node)
{
// Find a child that's a subwindow, but not a dialog box.
wxWindow *win = (wxWindow *)node->Data();
if (!win->IsKindOf(CLASSINFO(wxFrame)) &&
!win->IsKindOf(CLASSINFO(wxDialog)))
{
int width, height;
int x, y;
win->GetSize(&width, &height);
win->GetPosition(&x, &y);
if ((x + width) > max_width)
max_width = x + width;
if ((y + height) > max_height)
max_height = y + height;
}
node = node->Next();
}
SetClientSize(max_width, max_height);
}
// Responds to colour changes, and passes event on to children. // Responds to colour changes, and passes event on to children.
void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
{ {
@@ -771,49 +680,6 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
wxWindow::OnSysColourChanged(event); wxWindow::OnSysColourChanged(event);
} }
// Default resizing behaviour - if only ONE subwindow,
// resize to client rectangle size
void wxFrame::OnSize(wxSizeEvent& WXUNUSED(event))
{
// if we're using constraints - do use them
#if wxUSE_CONSTRAINTS
if ( GetAutoLayout() ) {
Layout();
return;
}
#endif
// do we have _exactly_ one child?
wxWindow *child = NULL;
for ( wxNode *node = GetChildren().First(); node; node = node->Next() )
{
wxWindow *win = (wxWindow *)node->Data();
if ( !win->IsKindOf(CLASSINFO(wxFrame)) &&
!win->IsKindOf(CLASSINFO(wxDialog)) &&
(win != GetStatusBar())
#if wxUSE_TOOLBAR
&& (win != GetToolBar())
#endif // wxUSE_TOOLBAR
)
{
if ( child )
return; // it's our second subwindow - nothing to do
child = win;
}
}
if ( child ) {
// we have exactly one child - set it's size to fill the whole frame
int clientW, clientH;
GetClientSize(&clientW, &clientH);
int x = 0;
int y = 0;
child->SetSize(x, y, clientW, clientH);
}
}
// Default activation behaviour - set the focus for the first child // Default activation behaviour - set the focus for the first child
// subwindow found. // subwindow found.
void wxFrame::OnActivate(wxActivateEvent& event) void wxFrame::OnActivate(wxActivateEvent& event)
@@ -834,190 +700,27 @@ void wxFrame::OnActivate(wxActivateEvent& event)
} }
} }
// The default implementation for the close window event.
// OnClose for backward compatibility.
void wxFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{
this->Destroy();
}
#ifdef __VMS__
// I added this function because I got missing symbols when linking
// Maybe it should be included on all platforms. But what should it do?
void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event))
{
}
#endif
// Destroy the window (delayed, if a managed window)
bool wxFrame::Destroy()
{
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
return TRUE;
}
// Default menu selection behaviour - display a help string
void wxFrame::OnMenuHighlight(wxMenuEvent& event)
{
if (GetStatusBar())
{
if (event.GetMenuId() == -1)
SetStatusText("");
else
{
wxMenuBar *menuBar = GetMenuBar();
if (menuBar)
{
wxString helpString(menuBar->GetHelpString(event.GetMenuId()));
if (helpString != "")
SetStatusText(helpString);
}
}
}
}
wxMenuBar *wxFrame::GetMenuBar() const
{
return m_frameMenuBar;
}
void wxFrame::Centre(int direction)
{
int display_width, display_height, width, height, x, y;
wxDisplaySize(&display_width, &display_height);
GetSize(&width, &height);
GetPosition(&x, &y);
if (direction & wxHORIZONTAL)
x = (int)((display_width - width)/2);
if (direction & wxVERTICAL)
y = (int)((display_height - height)/2);
SetSize(x, y, width, height);
}
// Call this to simulate a menu command
void wxFrame::Command(int id)
{
ProcessCommand(id);
}
void wxFrame::ProcessCommand(int id)
{
wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id);
commandEvent.SetInt( id );
commandEvent.SetEventObject( this );
wxMenuBar *bar = GetMenuBar() ;
if (!bar)
return;
/* TODO: check the menu item if required
wxMenuItem *item = bar->FindItemForId(id) ;
if (item && item->IsCheckable())
{
bar->Check(id,!bar->Checked(id)) ;
}
*/
wxEvtHandler* evtHandler = GetEventHandler();
evtHandler->ProcessEvent(commandEvent);
}
// Checks if there is a toolbar, and returns the first free client position
wxPoint wxFrame::GetClientAreaOrigin() const
{
wxPoint pt(0, 0);
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
if (GetToolBar())
wxToolBar* wxFrame::CreateToolBar(long style,
wxWindowID id,
const wxString& name)
{
if ( wxFrameBase::CreateToolBar(style, id, name) )
{ {
int w, h;
GetToolBar()->GetSize(& w, & h);
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
{
pt.x += w;
}
else
{
pt.y += h;
}
}
#endif // wxUSE_TOOLBAR
return pt;
}
void wxFrame::ScreenToClient(int *x, int *y) const
{
wxWindow::ScreenToClient(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 wxFrame::ClientToScreen(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::ClientToScreen(x, y);
}
#if wxUSE_TOOLBAR
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
{
wxCHECK_MSG( m_frameToolBar == NULL, FALSE,
"recreating toolbar in wxFrame" );
wxToolBar* toolBar = OnCreateToolBar(style, id, name);
if (toolBar)
{
SetToolBar(toolBar);
PositionToolBar(); PositionToolBar();
return toolBar;
} }
else
{
return NULL;
}
}
wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name)
{
return new wxToolBar(this, id, wxPoint(0, 0), wxSize(100, 24), style, name);
}
void wxFrame::SetToolBar(wxToolBar *toolbar)
{
m_frameToolBar = toolbar;
}
wxToolBar *wxFrame::GetToolBar() const
{
return m_frameToolBar; return m_frameToolBar;
} }
void wxFrame::PositionToolBar() void wxFrame::PositionToolBar()
{ {
int cw, ch;
GetClientSize(& cw, &ch);
if (GetToolBar()) if (GetToolBar())
{ {
int cw, ch;
GetClientSize(& cw, &ch);
int tw, th; int tw, th;
GetToolBar()->GetSize(& tw, & th); GetToolBar()->GetSize(& tw, & th);
@@ -1037,27 +740,7 @@ void wxFrame::PositionToolBar()
} }
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
void wxFrame::CaptureMouse() void wxFrame::Raise()
{
if (m_winCaptured)
return;
if (GetMainWidget())
XtAddGrab((Widget) m_frameShell, TRUE, FALSE);
m_winCaptured = TRUE;
}
void wxFrame::ReleaseMouse()
{
if (!m_winCaptured)
return;
if (GetMainWidget())
XtRemoveGrab((Widget) m_frameShell);
m_winCaptured = FALSE;
}
void wxFrame::Raise(void)
{ {
Window parent_window = XtWindow((Widget) m_frameShell), Window parent_window = XtWindow((Widget) m_frameShell),
next_parent = XtWindow((Widget) m_frameShell), next_parent = XtWindow((Widget) m_frameShell),
@@ -1074,7 +757,7 @@ void wxFrame::Raise(void)
XRaiseWindow(XtDisplay((Widget) m_frameShell), parent_window); XRaiseWindow(XtDisplay((Widget) m_frameShell), parent_window);
} }
void wxFrame::Lower(void) void wxFrame::Lower()
{ {
Window parent_window = XtWindow((Widget) m_frameShell), Window parent_window = XtWindow((Widget) m_frameShell),
next_parent = XtWindow((Widget) m_frameShell), next_parent = XtWindow((Widget) m_frameShell),
@@ -1131,7 +814,11 @@ bool wxFrame::PreResize()
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
PositionToolBar(); PositionToolBar();
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
#if wxUSE_STATUSBAR
PositionStatusBar(); PositionStatusBar();
#endif // wxUSE_STATUSBAR
return TRUE; return TRUE;
} }

View File

@@ -363,7 +363,7 @@ bool wxMenuBar::CreateMenuBar(wxFrame* parent)
{ {
if (m_mainWidget) if (m_mainWidget)
{ {
XtVaSetValues((Widget) parent->GetMainWindowWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL); XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL);
/* /*
if (!XtIsManaged((Widget) m_mainWidget)) if (!XtIsManaged((Widget) m_mainWidget))
XtManageChild((Widget) m_mainWidget); XtManageChild((Widget) m_mainWidget);
@@ -372,7 +372,7 @@ bool wxMenuBar::CreateMenuBar(wxFrame* parent)
return TRUE; return TRUE;
} }
Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWindowWidget(), "MenuBar", NULL, 0); Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWidget(), "MenuBar", NULL, 0);
m_mainWidget = (WXWidget) menuBarW; m_mainWidget = (WXWidget) menuBarW;
size_t menuCount = GetMenuCount(); size_t menuCount = GetMenuCount();
@@ -403,7 +403,7 @@ bool wxMenuBar::CreateMenuBar(wxFrame* parent)
SetForegroundColour(m_foregroundColour); SetForegroundColour(m_foregroundColour);
SetFont(m_font); SetFont(m_font);
XtVaSetValues((Widget) parent->GetMainWindowWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL); XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL);
XtRealizeWidget ((Widget) menuBarW); XtRealizeWidget ((Widget) menuBarW);
XtManageChild ((Widget) menuBarW); XtManageChild ((Widget) menuBarW);
SetMenuBarFrame(parent); SetMenuBarFrame(parent);

View File

@@ -586,57 +586,6 @@ void wxFrame::OnActivate(wxActivateEvent& event)
} }
} }
// ----------------------------------------------------------------------------
// wxFrame size management: we exclude the areas taken by menu/status/toolbars
// from the client area, so the client area is what's really available for the
// frame contents
// ----------------------------------------------------------------------------
// Checks if there is a toolbar, and returns the first free client position
wxPoint wxFrame::GetClientAreaOrigin() const
{
wxPoint pt(0, 0);
if (GetToolBar())
{
int w, h;
GetToolBar()->GetSize(& w, & h);
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
{
pt.x += w;
}
else
{
pt.y += h;
}
}
return pt;
}
void wxFrame::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 wxFrame::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);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// tool/status bar stuff // tool/status bar stuff
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------