added wxTLW for MSW

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11685 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-09-24 00:34:14 +00:00
parent c2fd78b10f
commit 82c9f85ce5
20 changed files with 592 additions and 509 deletions

View File

@@ -30,10 +30,10 @@ class WXDLLEXPORT wxDialogBase : public wxTopLevelWindow
{ {
public: public:
wxDialogBase() { Init(); } wxDialogBase() { Init(); }
~wxDialogBase() {} virtual ~wxDialogBase() { }
void Init(); void Init();
// the modal dialogs have a return code - usually the id of the last // the modal dialogs have a return code - usually the id of the last
// pressed button // pressed button
void SetReturnCode(int returnCode) { m_returnCode = returnCode; } void SetReturnCode(int returnCode) { m_returnCode = returnCode; }
@@ -44,7 +44,7 @@ public:
// lines into a vertical wxBoxSizer // lines into a vertical wxBoxSizer
wxSizer *CreateTextSizer( const wxString &message ); wxSizer *CreateTextSizer( const wxString &message );
#endif // wxUSE_STATTEXT && wxUSE_TEXTCTRL #endif // wxUSE_STATTEXT && wxUSE_TEXTCTRL
#if wxUSE_BUTTON #if wxUSE_BUTTON
// places buttons into a horizontal wxBoxSizer // places buttons into a horizontal wxBoxSizer
wxSizer *CreateButtonSizer( long flags ); wxSizer *CreateButtonSizer( long flags );
@@ -55,10 +55,10 @@ protected:
int m_returnCode; int m_returnCode;
// FIXME - temporary hack in absence of wxTLW !! // FIXME - temporary hack in absence of wxTLW !!
#ifdef wxTopLevelWindowNative #ifdef wxTopLevelWindowNative
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
WX_DECLARE_CONTROL_CONTAINER(); WX_DECLARE_CONTROL_CONTAINER();
#endif #endif
}; };

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: dialog.h // Name: wx/msw/dialog.h
// Purpose: wxDialog class // Purpose: wxDialog class
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
@@ -56,15 +56,7 @@ public:
long style = wxDEFAULT_DIALOG_STYLE, long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxDialogNameStr); const wxString& name = wxDialogNameStr);
~wxDialog(); virtual ~wxDialog();
// override some base class virtuals
virtual bool Destroy();
virtual bool Show(bool show);
virtual void Iconize(bool iconize);
virtual bool IsIconized() const;
virtual bool IsTopLevel() const { return TRUE; }
void SetModal(bool flag); void SetModal(bool flag);
virtual bool IsModal() const; virtual bool IsModal() const;
@@ -78,16 +70,15 @@ public:
// returns TRUE if we're in a modal loop // returns TRUE if we're in a modal loop
bool IsModalShowing() const; bool IsModalShowing() const;
#if WXWIN_COMPATIBILITY
bool Iconized() const { return IsIconized(); };
#endif
// wxMSW only: remove the "Close" button from the dialog // wxMSW only: remove the "Close" button from the dialog
bool EnableCloseButton(bool enable = TRUE); bool EnableCloseButton(bool enable = TRUE);
// implementation only from now on // implementation only from now on
// ------------------------------- // -------------------------------
// override some base class virtuals
virtual bool Show(bool show);
// event handlers // event handlers
bool OnClose(); bool OnClose();
void OnCharHook(wxKeyEvent& event); void OnCharHook(wxKeyEvent& event);
@@ -110,10 +101,6 @@ public:
#endif // wxUSE_CTL3D #endif // wxUSE_CTL3D
protected: protected:
// override more base class virtuals
virtual void DoSetClientSize(int width, int height);
virtual void DoGetPosition(int *x, int *y) const;
// show modal dialog and enter modal loop // show modal dialog and enter modal loop
void DoShowModal(); void DoShowModal();

View File

@@ -45,22 +45,13 @@ public:
virtual ~wxFrameMSW(); virtual ~wxFrameMSW();
// implement base class pure virtuals // implement base class pure virtuals
virtual void Raise();
virtual void Maximize(bool maximize = TRUE);
virtual bool IsMaximized() const;
virtual void Iconize(bool iconize = TRUE);
virtual bool IsIconized() const;
virtual void Restore();
virtual void SetIcon(const wxIcon& icon);
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
virtual bool IsFullScreen() const { return m_fsIsShowing; }; virtual bool IsFullScreen() const { return m_fsIsShowing; };
virtual void Raise();
// implementation only from now on // implementation only from now on
// ------------------------------- // -------------------------------
// override some more virtuals
virtual bool Show(bool show = TRUE);
// event handlers // event handlers
void OnActivate(wxActivateEvent& event); void OnActivate(wxActivateEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& event);
@@ -124,14 +115,8 @@ protected:
// common part of all ctors // common part of all ctors
void Init(); void Init();
// common part of Iconize(), Maximize() and Restore()
void DoShowWindow(int nShowCmd);
// override base class virtuals // override base class virtuals
virtual void DoGetClientSize(int *width, int *height) const; virtual void DoGetClientSize(int *width, int *height) const;
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetPosition(int *x, int *y) const;
virtual void DoSetClientSize(int width, int height); virtual void DoSetClientSize(int width, int height);
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
@@ -154,14 +139,8 @@ protected:
virtual bool IsMDIChild() const { return FALSE; } virtual bool IsMDIChild() const { return FALSE; }
// is the frame currently iconized? // get default (wxWindows) icon for the frame
bool m_iconized; virtual WXHICON GetDefaultIcon() const;
// should the frame be maximized when it will be shown? set by Maximize()
// when it is called while the frame is hidden
bool m_maximizeOnShow;
WXHICON m_defaultIcon;
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
static bool m_useNativeStatusBar; static bool m_useNativeStatusBar;

View File

@@ -30,8 +30,6 @@ class WXDLLEXPORT wxMDIChildFrame;
class WXDLLEXPORT wxMDIParentFrame : public wxFrame class WXDLLEXPORT wxMDIParentFrame : public wxFrame
{ {
DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
public: public:
wxMDIParentFrame(); wxMDIParentFrame();
wxMDIParentFrame(wxWindow *parent, wxMDIParentFrame(wxWindow *parent,
@@ -102,6 +100,8 @@ protected:
virtual void InternalSetMenuBar(); virtual void InternalSetMenuBar();
#endif // wxUSE_MENUS_NATIVE #endif // wxUSE_MENUS_NATIVE
virtual WXHICON GetDefaultIcon() const;
wxMDIClientWindow * m_clientWindow; wxMDIClientWindow * m_clientWindow;
wxMDIChildFrame * m_currentChild; wxMDIChildFrame * m_currentChild;
wxMenu* m_windowMenu; wxMenu* m_windowMenu;
@@ -113,6 +113,7 @@ private:
friend class WXDLLEXPORT wxMDIChildFrame; friend class WXDLLEXPORT wxMDIChildFrame;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -178,6 +179,8 @@ protected:
virtual void InternalSetMenuBar(); virtual void InternalSetMenuBar();
virtual bool IsMDIChild() const { return TRUE; } virtual bool IsMDIChild() const { return TRUE; }
virtual WXHICON GetDefaultIcon() const;
// common part of all ctors // common part of all ctors
void Init(); void Init();

View File

@@ -248,6 +248,38 @@ inline bool wxIsCtrlDown()
return (::GetKeyState(VK_CONTROL) & 0x100) != 0; return (::GetKeyState(VK_CONTROL) & 0x100) != 0;
} }
// wrapper around GetWindowRect() and GetClientRect() APIs doing error checking
// for Win32
inline RECT wxGetWindowRect(HWND hwnd)
{
RECT rect;
#ifdef __WIN16__
::GetWindowRect(hwnd, &rect);
#else // Win32
if ( !::GetWindowRect(hwnd, &rect) )
{
wxLogLastError(_T("GetWindowRect"));
}
#endif // Win16/32
return rect;
}
inline RECT wxGetClientRect(HWND hwnd)
{
RECT rect;
#ifdef __WIN16__
::GetClientRect(hwnd, &rect);
#else // Win32
if ( !::GetClientRect(hwnd, &rect) )
{
wxLogLastError(_T("GetClientRect"));
}
#endif // Win16/32
return rect;
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// small helper classes // small helper classes
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -357,8 +389,8 @@ WXDLLEXPORT extern WXWORD wxGetWindowId(WXHWND hWnd);
// Does this window style specify any border? // Does this window style specify any border?
inline bool wxStyleHasBorder(long style) inline bool wxStyleHasBorder(long style)
{ {
return (style & (wxSIMPLE_BORDER | wxRAISED_BORDER | return (style & (wxSIMPLE_BORDER | wxRAISED_BORDER |
wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0; wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0;
} }
// find the window for HWND which is part of some wxWindow, returns just the // find the window for HWND which is part of some wxWindow, returns just the

87
include/wx/msw/toplevel.h Normal file
View File

@@ -0,0 +1,87 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/toplevel.h
// Purpose: wxTopLevelWindowMSW is the MSW implementation of wxTLW
// Author: Vadim Zeitlin
// Modified by:
// Created: 20.09.01
// RCS-ID: $Id$
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_TOPLEVEL_H_
#define _WX_MSW_TOPLEVEL_H_
#ifdef __GNUG__
#pragma interface "toplevel.h"
#endif
// ----------------------------------------------------------------------------
// wxTopLevelWindowMSW
// ----------------------------------------------------------------------------
class wxTopLevelWindowMSW : public wxTopLevelWindowBase
{
public:
// constructors and such
wxTopLevelWindowMSW() { Init(); }
wxTopLevelWindowMSW(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();
(void)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 ~wxTopLevelWindowMSW();
// 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 Show(bool show = TRUE);
// implementation from now on
// --------------------------
protected:
// common part of all ctors
void Init();
// common part of Iconize(), Maximize() and Restore()
void DoShowWindow(int nShowCmd);
// implement the geometry-related methods for a top level window
virtual void DoSetClientSize(int width, int height);
// is the frame currently iconized?
bool m_iconized;
// should the frame be maximized when it will be shown? set by Maximize()
// when it is called while the frame is hidden
bool m_maximizeOnShow;
};
// list of all frames and modeless dialogs
extern WXDLLEXPORT_DATA(wxWindowList) wxModelessWindows;
#endif // _WX_MSW_TOPLEVEL_H_

View File

@@ -52,10 +52,7 @@ class WXDLLEXPORT wxTopLevelWindowBase : public wxWindow
public: public:
// construction // construction
wxTopLevelWindowBase(); wxTopLevelWindowBase();
#ifdef __DARWIN__
virtual ~wxTopLevelWindowBase() {}
#endif
// top level wnd state // top level wnd state
// -------------------- // --------------------
@@ -108,6 +105,10 @@ public:
// so should be there for all platforms // so should be there for all platforms
void OnActivate(wxActivateEvent &WXUNUSED(event)) { } void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
#ifdef __DARWIN__
virtual ~wxTopLevelWindowBase() {}
#endif
protected: protected:
// the frame client to screen translation should take account of the // the frame client to screen translation should take account of the
// toolbar which may shift the origin of the client area // toolbar which may shift the origin of the client area
@@ -129,7 +130,10 @@ protected:
// include the real class declaration // include the real class declaration
#if defined(__WXGTK__) #if defined(__WXMSW__)
#include "wx/msw/toplevel.h"
#define wxTopLevelWindowNative wxTopLevelWindowMSW
#elif defined(__WXGTK__)
#include "wx/gtk/toplevel.h" #include "wx/gtk/toplevel.h"
#define wxTopLevelWindowNative wxTopLevelWindowGTK #define wxTopLevelWindowNative wxTopLevelWindowGTK
#elif defined(__WXMGL__) #elif defined(__WXMGL__)

View File

@@ -35,6 +35,10 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#include "wx/dynarray.h"
WX_DEFINE_ARRAY(wxWindow *, wxArrayLboxes);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// resources // resources
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -70,8 +74,13 @@ public:
// event handlers (these functions should _not_ be virtual) // event handlers (these functions should _not_ be virtual)
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event); void OnAbout(wxCommandEvent& event);
void OnCreateLbox(wxCommandEvent& event);
void OnDeleteLbox(wxCommandEvent& event);
private: private:
wxArrayLboxes m_lboxes;
wxCoord m_pos;
// any class wishing to process wxWindows events must use this macro // any class wishing to process wxWindows events must use this macro
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@@ -85,9 +94,14 @@ enum
{ {
// menu items // menu items
Minimal_Quit = 1, Minimal_Quit = 1,
Minimal_About Minimal_About,
Minimal_CreateLbox,
Minimal_DeleteLbox,
}; };
static const size_t NUM_LBOXES = 10;
static const wxCoord POS_STEP = 5;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// event tables and other macros for wxWindows // event tables and other macros for wxWindows
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -98,6 +112,8 @@ enum
BEGIN_EVENT_TABLE(MyFrame, wxFrame) BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(Minimal_Quit, MyFrame::OnQuit) EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
EVT_MENU(Minimal_About, MyFrame::OnAbout) EVT_MENU(Minimal_About, MyFrame::OnAbout)
EVT_MENU(Minimal_CreateLbox, MyFrame::OnCreateLbox)
EVT_MENU(Minimal_DeleteLbox, MyFrame::OnDeleteLbox)
END_EVENT_TABLE() END_EVENT_TABLE()
// Create a new application object: this macro will allow wxWindows to create // Create a new application object: this macro will allow wxWindows to create
@@ -107,7 +123,6 @@ END_EVENT_TABLE()
// not wxApp) // not wxApp)
IMPLEMENT_APP(MyApp) IMPLEMENT_APP(MyApp)
// ============================================================================ // ============================================================================
// implementation // implementation
// ============================================================================ // ============================================================================
@@ -141,6 +156,8 @@ bool MyApp::OnInit()
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size) : wxFrame((wxFrame *)NULL, -1, title, pos, size)
{ {
m_pos = 0;
#ifdef __WXMAC__ #ifdef __WXMAC__
// we need this in order to allow the about menu relocation, since ABOUT is // we need this in order to allow the about menu relocation, since ABOUT is
// not the default id of the about menu // not the default id of the about menu
@@ -157,6 +174,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
// the "About" item should be in the help menu // the "About" item should be in the help menu
wxMenu *helpMenu = new wxMenu; wxMenu *helpMenu = new wxMenu;
helpMenu->Append(Minimal_About, "&About...\tCtrl-A", "Show about dialog"); helpMenu->Append(Minimal_About, "&About...\tCtrl-A", "Show about dialog");
helpMenu->Append(Minimal_CreateLbox, "&Create 10 listboxes\tCtrl-C");
helpMenu->Append(Minimal_DeleteLbox, "&Delete 10 listboxes\tCtrl-D");
menuFile->Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program"); menuFile->Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program");
@@ -193,3 +212,28 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
wxMessageBox(msg, "About Minimal", wxOK | wxICON_INFORMATION, this); wxMessageBox(msg, "About Minimal", wxOK | wxICON_INFORMATION, this);
} }
void MyFrame::OnCreateLbox(wxCommandEvent& WXUNUSED(event))
{
for ( size_t n = 0; n < NUM_LBOXES; n++ )
{
m_lboxes.Add(new wxListBox(this, -1, wxPoint(m_pos, m_pos)));
m_pos += POS_STEP;
}
}
void MyFrame::OnDeleteLbox(wxCommandEvent& WXUNUSED(event))
{
size_t count = m_lboxes.GetCount();
if ( count < NUM_LBOXES )
return;
for ( size_t n = 0; n < NUM_LBOXES; n++ )
{
delete m_lboxes[--count];
m_lboxes.RemoveAt(count);
m_pos -= POS_STEP;
}
}

View File

@@ -45,6 +45,8 @@ END_EVENT_TABLE()
// implementation // implementation
// ============================================================================ // ============================================================================
IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// construction/destruction // construction/destruction
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -64,31 +66,32 @@ bool wxTopLevelWindowBase::Destroy()
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTopLevelWindow size management: we exclude the areas taken by menu/status/toolbars // wxTopLevelWindow size management: we exclude the areas taken by
// from the client area, so the client area is what's really available for the // menu/status/toolbars from the client area, so the client area is what's
// frame contents // really available for the frame contents
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxTopLevelWindowBase::DoScreenToClient(int *x, int *y) const void wxTopLevelWindowBase::DoScreenToClient(int *x, int *y) const
{ {
wxWindow::DoScreenToClient(x, y); wxWindow::DoScreenToClient(x, y);
// We may be faking the client origin. // translate the wxWindow client coords to our client coords
// So a window that's really at (0, 30) may appear
// (to wxWin apps) to be at (0, 0).
wxPoint pt(GetClientAreaOrigin()); wxPoint pt(GetClientAreaOrigin());
*x -= pt.x; if ( x )
*y -= pt.y; *x -= pt.x;
if ( y )
*y -= pt.y;
} }
void wxTopLevelWindowBase::DoClientToScreen(int *x, int *y) const void wxTopLevelWindowBase::DoClientToScreen(int *x, int *y) const
{ {
// We may be faking the client origin. // our client area origin (0, 0) may be really something like (0, 30) for
// So a window that's really at (0, 30) may appear // wxWindow if we have a toolbar, account for it before translating
// (to wxWin apps) to be at (0, 0). wxPoint pt(GetClientAreaOrigin());
wxPoint pt1(GetClientAreaOrigin()); if ( x )
*x += pt1.x; *x += pt.x;
*y += pt1.y; if ( y )
*y += pt.y;
wxWindow::DoClientToScreen(x, y); wxWindow::DoClientToScreen(x, y);
} }

View File

@@ -59,11 +59,8 @@ wxDialog::wxDialog( wxWindow *parent,
long style, const wxString &name ) long style, const wxString &name )
{ {
Init(); Init();
// all dialogs should have tab traversal enabled
style |= wxTAB_TRAVERSAL;
Create( parent, id, title, pos, size, style, name ); (void)Create( parent, id, title, pos, size, style, name );
} }
bool wxDialog::Create( wxWindow *parent, bool wxDialog::Create( wxWindow *parent,
@@ -73,12 +70,16 @@ bool wxDialog::Create( wxWindow *parent,
{ {
SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG); SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG);
// all dialogs should have tab traversal enabled
style |= wxTAB_TRAVERSAL;
return wxTopLevelWindow::Create(parent, id, title, pos, size, style, name); return wxTopLevelWindow::Create(parent, id, title, pos, size, style, name);
} }
void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) )
{ {
if (Validate()) TransferDataFromWindow(); if (Validate())
TransferDataFromWindow();
} }
void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) )

View File

@@ -50,10 +50,6 @@ extern int g_openDialogs;
// event tables // event tables
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef __WXUNIVERSAL__
IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow)
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// data // data
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -190,9 +186,9 @@ gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxTopLevelWindowGTK *
/* All this is for Motif Window Manager "hints" and is supposed to be /* All this is for Motif Window Manager "hints" and is supposed to be
recognized by other WM as well. Not tested. */ recognized by other WM as well. Not tested. */
gdk_window_set_decorations(win->m_widget->window, gdk_window_set_decorations(win->m_widget->window,
(GdkWMDecoration)win->m_gdkDecor); (GdkWMDecoration)win->m_gdkDecor);
gdk_window_set_functions(win->m_widget->window, gdk_window_set_functions(win->m_widget->window,
(GdkWMFunction)win->m_gdkFunc); (GdkWMFunction)win->m_gdkFunc);
/* GTK's shrinking/growing policy */ /* GTK's shrinking/growing policy */
@@ -377,7 +373,7 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
if (style & wxFRAME_TOOL_WINDOW) if (style & wxFRAME_TOOL_WINDOW)
win_type = GTK_WINDOW_POPUP; win_type = GTK_WINDOW_POPUP;
if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
win_type = GTK_WINDOW_DIALOG; win_type = GTK_WINDOW_DIALOG;
@@ -474,9 +470,9 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
{ {
m_gdkDecor = (long) GDK_DECOR_BORDER; m_gdkDecor = (long) GDK_DECOR_BORDER;
m_gdkFunc = (long) GDK_FUNC_MOVE; m_gdkFunc = (long) GDK_FUNC_MOVE;
// All this is for Motif Window Manager "hints" and is supposed to be // All this is for Motif Window Manager "hints" and is supposed to be
// recognized by other WM as well. Not tested. // recognized by other WM as well. Not tested.
if ((style & wxCAPTION) != 0) if ((style & wxCAPTION) != 0)
m_gdkDecor |= GDK_DECOR_TITLE; m_gdkDecor |= GDK_DECOR_TITLE;
if ((style & wxSYSTEM_MENU) != 0) if ((style & wxSYSTEM_MENU) != 0)
@@ -679,12 +675,12 @@ void wxTopLevelWindowGTK::DoSetClientSize( int width, int height )
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
DoSetSize(-1, -1, DoSetSize(-1, -1,
width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0); width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0);
} }
void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
int width, int height ) int width, int height )
{ {
// due to a bug in gtk, x,y are always 0 // due to a bug in gtk, x,y are always 0
// m_x = x; // m_x = x;

View File

@@ -59,11 +59,8 @@ wxDialog::wxDialog( wxWindow *parent,
long style, const wxString &name ) long style, const wxString &name )
{ {
Init(); Init();
// all dialogs should have tab traversal enabled
style |= wxTAB_TRAVERSAL;
Create( parent, id, title, pos, size, style, name ); (void)Create( parent, id, title, pos, size, style, name );
} }
bool wxDialog::Create( wxWindow *parent, bool wxDialog::Create( wxWindow *parent,
@@ -73,12 +70,16 @@ bool wxDialog::Create( wxWindow *parent,
{ {
SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG); SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG);
// all dialogs should have tab traversal enabled
style |= wxTAB_TRAVERSAL;
return wxTopLevelWindow::Create(parent, id, title, pos, size, style, name); return wxTopLevelWindow::Create(parent, id, title, pos, size, style, name);
} }
void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) )
{ {
if (Validate()) TransferDataFromWindow(); if (Validate())
TransferDataFromWindow();
} }
void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) )

View File

@@ -50,10 +50,6 @@ extern int g_openDialogs;
// event tables // event tables
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef __WXUNIVERSAL__
IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow)
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// data // data
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -190,9 +186,9 @@ gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxTopLevelWindowGTK *
/* All this is for Motif Window Manager "hints" and is supposed to be /* All this is for Motif Window Manager "hints" and is supposed to be
recognized by other WM as well. Not tested. */ recognized by other WM as well. Not tested. */
gdk_window_set_decorations(win->m_widget->window, gdk_window_set_decorations(win->m_widget->window,
(GdkWMDecoration)win->m_gdkDecor); (GdkWMDecoration)win->m_gdkDecor);
gdk_window_set_functions(win->m_widget->window, gdk_window_set_functions(win->m_widget->window,
(GdkWMFunction)win->m_gdkFunc); (GdkWMFunction)win->m_gdkFunc);
/* GTK's shrinking/growing policy */ /* GTK's shrinking/growing policy */
@@ -377,7 +373,7 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
if (style & wxFRAME_TOOL_WINDOW) if (style & wxFRAME_TOOL_WINDOW)
win_type = GTK_WINDOW_POPUP; win_type = GTK_WINDOW_POPUP;
if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
win_type = GTK_WINDOW_DIALOG; win_type = GTK_WINDOW_DIALOG;
@@ -474,9 +470,9 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
{ {
m_gdkDecor = (long) GDK_DECOR_BORDER; m_gdkDecor = (long) GDK_DECOR_BORDER;
m_gdkFunc = (long) GDK_FUNC_MOVE; m_gdkFunc = (long) GDK_FUNC_MOVE;
// All this is for Motif Window Manager "hints" and is supposed to be // All this is for Motif Window Manager "hints" and is supposed to be
// recognized by other WM as well. Not tested. // recognized by other WM as well. Not tested.
if ((style & wxCAPTION) != 0) if ((style & wxCAPTION) != 0)
m_gdkDecor |= GDK_DECOR_TITLE; m_gdkDecor |= GDK_DECOR_TITLE;
if ((style & wxSYSTEM_MENU) != 0) if ((style & wxSYSTEM_MENU) != 0)
@@ -679,12 +675,12 @@ void wxTopLevelWindowGTK::DoSetClientSize( int width, int height )
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
DoSetSize(-1, -1, DoSetSize(-1, -1,
width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0); width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0);
} }
void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
int width, int height ) int width, int height )
{ {
// due to a bug in gtk, x,y are always 0 // due to a bug in gtk, x,y are always 0
// m_x = x; // m_x = x;

View File

@@ -61,12 +61,6 @@
// globals // globals
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// all objects to be deleted during next idle processing - from window.cpp
extern wxList WXDLLEXPORT wxPendingDelete;
// all frames and modeless dialogs - not static, used in frame.cpp, mdi.cpp &c
wxWindowList wxModelessWindows;
// all modal dialogs currently shown // all modal dialogs currently shown
static wxWindowList wxModalDialogs; static wxWindowList wxModalDialogs;
@@ -74,9 +68,9 @@ static wxWindowList wxModalDialogs;
// wxWin macros // wxWin macros
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel) IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
BEGIN_EVENT_TABLE(wxDialog, wxPanel) BEGIN_EVENT_TABLE(wxDialog, wxTopLevelWindow)
EVT_BUTTON(wxID_OK, wxDialog::OnOK) EVT_BUTTON(wxID_OK, wxDialog::OnOK)
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply) EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel) EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
@@ -117,20 +111,13 @@ bool wxDialog::Create(wxWindow *parent,
{ {
Init(); Init();
SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG);
if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
return FALSE;
m_oldFocus = FindFocus(); m_oldFocus = FindFocus();
SetName(name);
wxTopLevelWindows.Append(this);
if ( parent )
parent->AddChild(this);
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
int x = pos.x; int x = pos.x;
int y = pos.y; int y = pos.y;
int width = size.x; int width = size.x;
@@ -141,8 +128,6 @@ bool wxDialog::Create(wxWindow *parent,
if (y < 0) if (y < 0)
y = wxDIALOG_DEFAULT_Y; y = wxDIALOG_DEFAULT_Y;
m_windowStyle = style;
if (width < 0) if (width < 0)
width = wxDIALOG_DEFAULT_WIDTH; width = wxDIALOG_DEFAULT_WIDTH;
if (height < 0) if (height < 0)
@@ -173,7 +158,7 @@ bool wxDialog::Create(wxWindow *parent,
#ifdef __WXMICROWIN__ #ifdef __WXMICROWIN__
extern const wxChar *wxFrameClassName; extern const wxChar *wxFrameClassName;
int msflags = WS_OVERLAPPED|WS_POPUP; int msflags = WS_OVERLAPPED|WS_POPUP;
if (style & wxCAPTION) if (style & wxCAPTION)
msflags |= WS_CAPTION; msflags |= WS_CAPTION;
@@ -206,7 +191,7 @@ bool wxDialog::Create(wxWindow *parent,
#ifndef __WXMICROWIN__ #ifndef __WXMICROWIN__
SubclassWin(GetHWND()); SubclassWin(GetHWND());
#endif #endif
SetWindowText(hwnd, title); SetWindowText(hwnd, title);
return TRUE; return TRUE;
@@ -240,7 +225,7 @@ bool wxDialog::EnableCloseButton(bool enable)
wxLogLastError(_T("DrawMenuBar")); wxLogLastError(_T("DrawMenuBar"));
} }
#endif #endif
return TRUE; return TRUE;
} }
@@ -264,24 +249,8 @@ wxDialog::~wxDialog()
{ {
m_isBeingDeleted = TRUE; m_isBeingDeleted = TRUE;
wxTopLevelWindows.DeleteObject(this);
// this will also reenable all the other windows for a modal dialog // this will also reenable all the other windows for a modal dialog
Show(FALSE); Show(FALSE);
if ( !IsModal() )
wxModelessWindows.DeleteObject(this);
// If this is the last top-level window, exit.
if ( wxTheApp && (wxTopLevelWindows.Number() == 0) )
{
wxTheApp->SetTopWindow(NULL);
if ( wxTheApp->GetExitOnFrameDelete() )
{
::PostQuitMessage(0);
}
}
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -313,56 +282,6 @@ void wxDialog::OnCharHook(wxKeyEvent& event)
event.Skip(); event.Skip();
} }
// ----------------------------------------------------------------------------
// Windows dialog boxes can't be iconized
// ----------------------------------------------------------------------------
void wxDialog::Iconize(bool WXUNUSED(iconize))
{
}
bool wxDialog::IsIconized() const
{
return FALSE;
}
// ----------------------------------------------------------------------------
// size/position handling
// ----------------------------------------------------------------------------
void wxDialog::DoSetClientSize(int width, int height)
{
HWND hWnd = (HWND) GetHWND();
RECT rect;
::GetClientRect(hWnd, &rect);
RECT rect2;
GetWindowRect(hWnd, &rect2);
// Find the difference between the entire window (title bar and all)
// and the client area; add this to the new client size to move the
// window
int actual_width = rect2.right - rect2.left - rect.right + width;
int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
MoveWindow(hWnd, rect2.left, rect2.top, actual_width, actual_height, TRUE);
wxSizeEvent event(wxSize(actual_width, actual_height), m_windowId);
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
}
void wxDialog::DoGetPosition(int *x, int *y) const
{
RECT rect;
GetWindowRect(GetHwnd(), &rect);
if ( x )
*x = rect.left;
if ( y )
*y = rect.top;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// showing the dialogs // showing the dialogs
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -579,17 +498,6 @@ void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
closing.DeleteObject(this); closing.DeleteObject(this);
} }
// Destroy the window (delayed, if a managed window)
bool wxDialog::Destroy()
{
wxCHECK_MSG( !wxPendingDelete.Member(this), FALSE,
_T("wxDialog destroyed twice") );
wxPendingDelete.Append(this);
return TRUE;
}
void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
{ {
#if wxUSE_CTL3D #if wxUSE_CTL3D
@@ -672,7 +580,7 @@ long wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
rc = FALSE; rc = FALSE;
} }
break; break;
#endif #endif // __WXMICROWIN__
} }
if ( !processed ) if ( !processed )

View File

@@ -63,7 +63,6 @@
// globals // globals
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
extern wxWindowList wxModelessWindows;
extern const wxChar *wxFrameClassName; extern const wxChar *wxFrameClassName;
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
@@ -105,9 +104,6 @@ END_EVENT_TABLE()
void wxFrameMSW::Init() void wxFrameMSW::Init()
{ {
m_iconized =
m_maximizeOnShow = FALSE;
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
m_hwndToolTip = 0; m_hwndToolTip = 0;
#endif #endif
@@ -136,68 +132,28 @@ bool wxFrameMSW::Create(wxWindow *parent,
long style, long style,
const wxString& name) const wxString& name)
{ {
SetName(name); if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
m_windowStyle = style; return FALSE;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); // the frame must have NULL parent HWND or it would be always on top of its
// parent which is not what we usually want (in fact, we only want it for
// frames with the special wxFRAME_TOOL_WINDOW style handled elsewhere)
if ( !MSWCreate(m_windowId, NULL, wxFrameClassName, this, title,
pos.x, pos.y, size.x, size.y, style) )
return FALSE;
if ( id > -1 ) SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
m_windowId = id;
else
m_windowId = (int)NewControlId();
if (parent) parent->AddChild(this); wxModelessWindows.Append(this);
int x = pos.x; return TRUE;
int y = pos.y;
int width = size.x;
int height = size.y;
m_iconized = FALSE;
wxTopLevelWindows.Append(this);
// the frame must have NULL parent HWND or it would be always on top of its
// parent which is not what we usually want (in fact, we only want it for
// frames with the special wxFRAME_TOOL_WINDOW style handled elsewhere)
MSWCreate(m_windowId, NULL, wxFrameClassName, this, title,
x, y, width, height, style);
wxModelessWindows.Append(this);
return TRUE;
} }
wxFrameMSW::~wxFrameMSW() wxFrameMSW::~wxFrameMSW()
{ {
m_isBeingDeleted = TRUE; m_isBeingDeleted = TRUE;
wxTopLevelWindows.DeleteObject(this);
// the ~wxToolBar() code relies on the previous line to be executed before DeleteAllBars();
// this one, i.e. the frame should remove itself from wxTopLevelWindows
// before destorying its toolbar
DeleteAllBars();
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
{
wxTheApp->SetTopWindow(NULL);
if (wxTheApp->GetExitOnFrameDelete())
{
PostQuitMessage(0);
}
}
wxModelessWindows.DeleteObject(this);
// For some reason, wxWindows can activate another task altogether
// when a frame is destroyed after a modal dialog has been invoked.
// Try to bring the parent to the top.
// MT:Only do this if this frame is currently the active window, else weird
// things start to happen
if ( wxGetActiveWindow() == this )
if (GetParent() && GetParent()->GetHWND())
::BringWindowToTop((HWND) GetParent()->GetHWND());
} }
// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
@@ -225,128 +181,24 @@ void wxFrameMSW::DoGetClientSize(int *x, int *y) const
*y = rect.bottom; *y = rect.bottom;
} }
// Set the client size (i.e. leave the calculation of borders etc.
// to wxWindows)
void wxFrameMSW::DoSetClientSize(int width, int height) void wxFrameMSW::DoSetClientSize(int width, int height)
{ {
HWND hWnd = GetHwnd(); // leave enough space for the status bar if we have (and show) it
RECT rectClient;
::GetClientRect(hWnd, &rectClient);
RECT rectTotal;
::GetWindowRect(hWnd, &rectTotal);
// Find the difference between the entire window (title bar and all)
// and the client area; add this to the new client size to move the
// window
width += rectTotal.right - rectTotal.left - rectClient.right;
height += rectTotal.bottom - rectTotal.top - rectClient.bottom;
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
wxStatusBar *statbar = GetStatusBar(); wxStatusBar *statbar = GetStatusBar();
if ( statbar && statbar->IsShown() ) if ( statbar && statbar->IsShown() )
{ {
// leave enough space for the status bar
height += statbar->GetSize().y; height += statbar->GetSize().y;
} }
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
// note that this takes the toolbar into account wxTopLevelWindow::DoSetClientSize(width, height);
wxPoint pt = GetClientAreaOrigin();
width += pt.x;
height += pt.y;
if ( !::MoveWindow(hWnd, rectTotal.left, rectTotal.top,
width, height, TRUE /* redraw */) )
{
wxLogLastError(_T("MoveWindow"));
}
wxSizeEvent event(wxSize(width, height), m_windowId);
event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
}
void wxFrameMSW::DoGetSize(int *width, int *height) const
{
RECT rect;
::GetWindowRect(GetHwnd(), &rect);
*width = rect.right - rect.left;
*height = rect.bottom - rect.top;
}
void wxFrameMSW::DoGetPosition(int *x, int *y) const
{
RECT rect;
::GetWindowRect(GetHwnd(), &rect);
*x = rect.left;
*y = rect.top;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// variations around ::ShowWindow() // wxFrameMSW: various geometry-related functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxFrameMSW::DoShowWindow(int nShowCmd)
{
::ShowWindow(GetHwnd(), nShowCmd);
m_iconized = nShowCmd == SW_MINIMIZE;
}
bool wxFrameMSW::Show(bool show)
{
// don't use wxWindow version as we want to call DoShowWindow()
if ( !wxWindowBase::Show(show) )
return FALSE;
int nShowCmd;
if ( show )
{
if ( m_maximizeOnShow )
{
// show and maximize
nShowCmd = SW_MAXIMIZE;
m_maximizeOnShow = FALSE;
}
else // just show
{
nShowCmd = SW_SHOW;
}
}
else // hide
{
nShowCmd = SW_HIDE;
}
DoShowWindow(nShowCmd);
if ( show )
{
::BringWindowToTop(GetHwnd());
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_windowId);
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
}
else // hide
{
// Try to highlight the correct window (the parent)
if ( GetParent() )
{
HWND hWndParent = GetHwndOf(GetParent());
if (hWndParent)
::BringWindowToTop(hWndParent);
}
}
return TRUE;
}
void wxFrameMSW::Raise() void wxFrameMSW::Raise()
{ {
#ifdef __WIN16__ #ifdef __WIN16__
@@ -357,81 +209,13 @@ void wxFrameMSW::Raise()
#endif // Win16/32 #endif // Win16/32
} }
void wxFrameMSW::Iconize(bool iconize)
{
DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE);
}
void wxFrameMSW::Maximize(bool maximize)
{
if ( IsShown() )
{
// just maximize it directly
DoShowWindow(maximize ? SW_MAXIMIZE : SW_RESTORE);
}
else // hidden
{
// we can't maximize the hidden frame because it shows it as well, so
// just remember that we should do it later in this case
m_maximizeOnShow = TRUE;
}
}
void wxFrameMSW::Restore()
{
DoShowWindow(SW_RESTORE);
}
bool wxFrameMSW::IsIconized() const
{
#ifdef __WXMICROWIN__
// TODO
return FALSE;
#else
((wxFrameMSW *)this)->m_iconized = (::IsIconic(GetHwnd()) != 0);
return m_iconized;
#endif
}
// Is it maximized?
bool wxFrameMSW::IsMaximized() const
{
#ifdef __WXMICROWIN__
// TODO
return FALSE;
#else
return (::IsZoomed(GetHwnd()) != 0);
#endif
}
void wxFrameMSW::SetIcon(const wxIcon& icon)
{
wxFrameBase::SetIcon(icon);
#if defined(__WIN95__) && !defined(__WXMICROWIN__)
if ( m_icon.Ok() )
{
SendMessage(GetHwnd(), WM_SETICON,
(WPARAM)TRUE, (LPARAM)(HICON) m_icon.GetHICON());
}
#endif // __WIN95__
}
// generate an artificial resize event // generate an artificial resize event
void wxFrameMSW::SendSizeEvent() void wxFrameMSW::SendSizeEvent()
{ {
RECT r;
#ifdef __WIN16__
::GetWindowRect(GetHwnd(), &r);
#else
if ( !::GetWindowRect(GetHwnd(), &r) )
{
wxLogLastError(_T("GetWindowRect"));
}
#endif
if ( !m_iconized ) if ( !m_iconized )
{ {
RECT r = wxGetWindowRect(GetHwnd());
(void)::PostMessage(GetHwnd(), WM_SIZE, (void)::PostMessage(GetHwnd(), WM_SIZE,
IsMaximized() ? SIZE_MAXIMIZED : SIZE_RESTORED, IsMaximized() ? SIZE_MAXIMIZED : SIZE_RESTORED,
MAKELPARAM(r.right - r.left, r.bottom - r.top)); MAKELPARAM(r.right - r.left, r.bottom - r.top));
@@ -622,13 +406,12 @@ bool wxFrameMSW::ShowFullScreen(bool show, long style)
newStyle &= (~offFlags); newStyle &= (~offFlags);
// change our window style to be compatible with full-screen mode // change our window style to be compatible with full-screen mode
SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle); ::SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
// resize to the size of the desktop // resize to the size of the desktop
int width, height; int width, height;
RECT rect; RECT rect = wxGetWindowRect(::GetDesktopWindow());
::GetWindowRect(GetDesktopWindow(), &rect);
width = rect.right - rect.left; width = rect.right - rect.left;
height = rect.bottom - rect.top; height = rect.bottom - rect.top;
@@ -695,8 +478,6 @@ bool wxFrameMSW::MSWCreate(int id, wxWindow *parent, const wxChar *wclass, wxWin
int x, int y, int width, int height, long style) int x, int y, int width, int height, long style)
{ {
m_defaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON);
// If child windows aren't properly drawn initially, WS_CLIPCHILDREN // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
// could be the culprit. But without it, you can get a lot of flicker. // could be the culprit. But without it, you can get a lot of flicker.
@@ -919,6 +700,12 @@ void wxFrameMSW::IconizeChildFrames(bool bIconize)
} }
} }
WXHICON wxFrameMSW::GetDefaultIcon() const
{
return (WXHICON)(wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON);
}
// =========================================================================== // ===========================================================================
// message processing // message processing
// =========================================================================== // ===========================================================================
@@ -958,7 +745,7 @@ bool wxFrameMSW::HandlePaint()
if ( m_iconized ) if ( m_iconized )
{ {
HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon) HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon)
: (HICON)m_defaultIcon; : (HICON)GetDefaultIcon();
// Hold a pointer to the dc so long as the OnPaint() message // Hold a pointer to the dc so long as the OnPaint() message
// is being processed // is being processed
@@ -1171,7 +958,7 @@ long wxFrameMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
case WM_QUERYDRAGICON: case WM_QUERYDRAGICON:
{ {
HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon) HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon)
: (HICON)(m_defaultIcon); : (HICON)GetDefaultIcon();
rc = (long)hIcon; rc = (long)hIcon;
processed = rc != 0; processed = rc != 0;
} }

View File

@@ -163,10 +163,6 @@ bool wxMDIParentFrame::Create(wxWindow *parent,
long style, long style,
const wxString& name) const wxString& name)
{ {
m_defaultIcon = (WXHICON) (wxSTD_MDIPARENTFRAME_ICON
? wxSTD_MDIPARENTFRAME_ICON
: wxDEFAULT_MDIPARENTFRAME_ICON);
m_clientWindow = NULL; m_clientWindow = NULL;
m_currentChild = NULL; m_currentChild = NULL;
@@ -349,6 +345,12 @@ void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
event.Skip(); event.Skip();
} }
WXHICON wxMDIParentFrame::GetDefaultIcon() const
{
return (WXHICON)(wxSTD_MDIPARENTFRAME_ICON ? wxSTD_MDIPARENTFRAME_ICON
: wxDEFAULT_MDIPARENTFRAME_ICON);
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// MDI operations // MDI operations
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -647,9 +649,6 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
long style, long style,
const wxString& name) const wxString& name)
{ {
m_defaultIcon = (WXHICON)(wxSTD_MDICHILDFRAME_ICON ? wxSTD_MDICHILDFRAME_ICON
: wxDEFAULT_MDICHILDFRAME_ICON);
SetName(name); SetName(name);
wxWindowBase::Show(TRUE); // MDI child frame starts off shown wxWindowBase::Show(TRUE); // MDI child frame starts off shown
@@ -814,6 +813,12 @@ void wxMDIChildFrame::InternalSetMenuBar()
parent->m_parentFrameActive = FALSE; parent->m_parentFrameActive = FALSE;
} }
WXHICON wxMDIChildFrame::GetDefaultIcon() const
{
return (WXHICON)(wxSTD_MDICHILDFRAME_ICON ? wxSTD_MDICHILDFRAME_ICON
: wxDEFAULT_MDICHILDFRAME_ICON);
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// MDI operations // MDI operations
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -866,20 +866,24 @@ wxSize wxToolBar::GetToolSize() const
} }
} }
static wxToolBarToolBase *GetItemSkippingDummySpacers( const wxToolBarToolsList& tools, size_t index ) static
wxToolBarToolBase *GetItemSkippingDummySpacers(const wxToolBarToolsList& tools,
size_t index )
{ {
wxToolBarToolsList::Node* current = tools.GetFirst(); wxToolBarToolsList::Node* current = tools.GetFirst();
for( ; current != 0; current = current->GetNext() ) for ( ; current != 0; current = current->GetNext() )
{ {
if( index == 0 ) if ( index == 0 )
return current->GetData(); return current->GetData();
size_t separators = ((wxToolBarTool*)current->GetData())->GetSeparatorsCount();
// if it is a normal button, sepcount == 0, so skip 1 wxToolBarTool *tool = (wxToolBarTool *)current->GetData();
// item ( the button ) size_t separators = tool->GetSeparatorsCount();
// otherwise, skip as many items as the separator count,
// plus the control itself // if it is a normal button, sepcount == 0, so skip 1 item (the button)
index -= separators ? separators + 1: 1; // otherwise, skip as many items as the separator count, plus the
// control itself
index -= separators ? separators + 1 : 1;
} }
return 0; return 0;
@@ -897,20 +901,17 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
return (wxToolBarToolBase *)NULL; return (wxToolBarToolBase *)NULL;
} }
// if comctl32 version < 4.71 // if comctl32 version < 4.71 wxToolBar95 adds dummy spacers
// wxToolBar95 adds dummy spacers
#if defined(_WIN32_IE) && (_WIN32_IE >= 0x400 ) #if defined(_WIN32_IE) && (_WIN32_IE >= 0x400 )
if ( wxTheApp->GetComCtl32Version() >= 471 ) if ( wxTheApp->GetComCtl32Version() >= 471 )
{ {
return m_tools.Item((size_t)index)->GetData(); return m_tools.Item((size_t)index)->GetData();
} }
else else
#endif
{ {
return GetItemSkippingDummySpacers( m_tools, (size_t) index ); return GetItemSkippingDummySpacers( m_tools, (size_t) index );
} }
#else
return GetItemSkippingDummySpacers( m_tools, (size_t) index );
#endif
} }
void wxToolBar::UpdateSize() void wxToolBar::UpdateSize()

270
src/msw/toplevel.cpp Normal file
View File

@@ -0,0 +1,270 @@
///////////////////////////////////////////////////////////////////////////////
// Name: msw/toplevel.cpp
// Purpose: implements wxTopLevelWindow for MSW
// Author: Vadim Zeitlin
// Modified by:
// Created: 24.09.01
// RCS-ID: $Id$
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
// License: wxWindows license
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// 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
#ifndef WX_PRECOMP
#include "wx/string.h"
#include "wx/log.h"
#include "wx/intl.h"
#endif //WX_PRECOMP
#include "wx/msw/private.h"
// ----------------------------------------------------------------------------
// stubs for missing functions under MicroWindows
// ----------------------------------------------------------------------------
#ifdef __WXMICROWIN__
static inline bool IsIconic(HWND WXUNUSED(hwnd)) { return FALSE; }
static inline bool IsZoomed(HWND WXUNUSED(hwnd)) { return FALSE; }
#endif // __WXMICROWIN__
// ----------------------------------------------------------------------------
// globals
// ----------------------------------------------------------------------------
// list of all frames and modeless dialogs
wxWindowList wxModelessWindows;
// ============================================================================
// wxTopLevelWindowMSW implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxTopLevelWindowMSW creation
// ----------------------------------------------------------------------------
void wxTopLevelWindowMSW::Init()
{
m_iconized =
m_maximizeOnShow = FALSE;
}
bool wxTopLevelWindowMSW::Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
// init our fields
Init();
m_windowStyle = style;
SetName(name);
m_windowId = id == -1 ? NewControlId() : id;
wxTopLevelWindows.Append(this);
if ( parent )
parent->AddChild(this);
return TRUE;
}
wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
{
wxTopLevelWindows.DeleteObject(this);
if ( wxModelessWindows.Find(this) )
wxModelessWindows.DeleteObject(this);
// If this is the last top-level window, exit.
if ( wxTheApp && (wxTopLevelWindows.Number() == 0) )
{
wxTheApp->SetTopWindow(NULL);
if ( wxTheApp->GetExitOnFrameDelete() )
{
::PostQuitMessage(0);
}
}
}
// ----------------------------------------------------------------------------
// wxTopLevelWindowMSW geometry
// ----------------------------------------------------------------------------
void wxTopLevelWindowMSW::DoSetClientSize(int width, int height)
{
HWND hWnd = GetHwnd();
RECT rectClient;
::GetClientRect(hWnd, &rectClient);
RECT rectTotal;
::GetWindowRect(hWnd, &rectTotal);
// Find the difference between the entire window (title bar and all)
// and the client area; add this to the new client size to move the
// window
width += rectTotal.right - rectTotal.left - rectClient.right;
height += rectTotal.bottom - rectTotal.top - rectClient.bottom;
// note that calling GetClientAreaOrigin() takes the toolbar into account
wxPoint pt = GetClientAreaOrigin();
width += pt.x;
height += pt.y;
if ( !::MoveWindow(hWnd, rectTotal.left, rectTotal.top,
width, height, TRUE /* redraw */) )
{
wxLogLastError(_T("MoveWindow"));
}
wxSizeEvent event(wxSize(width, height), m_windowId);
event.SetEventObject(this);
(void)GetEventHandler()->ProcessEvent(event);
}
// ----------------------------------------------------------------------------
// wxTopLevelWindowMSW showing
// ----------------------------------------------------------------------------
void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd)
{
::ShowWindow(GetHwnd(), nShowCmd);
m_iconized = nShowCmd == SW_MINIMIZE;
}
bool wxTopLevelWindowMSW::Show(bool show)
{
// don't use wxWindow version as we want to call DoShowWindow() ourselves
if ( !wxWindowBase::Show(show) )
return FALSE;
int nShowCmd;
if ( show )
{
if ( m_maximizeOnShow )
{
// show and maximize
nShowCmd = SW_MAXIMIZE;
m_maximizeOnShow = FALSE;
}
else // just show
{
nShowCmd = SW_SHOW;
}
}
else // hide
{
nShowCmd = SW_HIDE;
}
DoShowWindow(nShowCmd);
if ( show )
{
::BringWindowToTop(GetHwnd());
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_windowId);
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
}
else // hide
{
// Try to highlight the correct window (the parent)
if ( GetParent() )
{
HWND hWndParent = GetHwndOf(GetParent());
if (hWndParent)
::BringWindowToTop(hWndParent);
}
}
return TRUE;
}
// ----------------------------------------------------------------------------
// wxTopLevelWindowMSW maximize/minimize
// ----------------------------------------------------------------------------
void wxTopLevelWindowMSW::Maximize(bool maximize)
{
if ( IsShown() )
{
// just maximize it directly
DoShowWindow(maximize ? SW_MAXIMIZE : SW_RESTORE);
}
else // hidden
{
// we can't maximize the hidden frame because it shows it as well, so
// just remember that we should do it later in this case
m_maximizeOnShow = TRUE;
}
}
bool wxTopLevelWindowMSW::IsMaximized() const
{
return ::IsZoomed(GetHwnd()) != 0;
}
void wxTopLevelWindowMSW::Iconize(bool iconize)
{
DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE);
}
bool wxTopLevelWindowMSW::IsIconized() const
{
// also update the current state
((wxTopLevelWindowMSW *)this)->m_iconized = ::IsIconic(GetHwnd()) != 0;
return m_iconized;
}
void wxTopLevelWindowMSW::Restore()
{
DoShowWindow(SW_RESTORE);
}
// ----------------------------------------------------------------------------
// wxTopLevelWindowMSW misc
// ----------------------------------------------------------------------------
void wxTopLevelWindowMSW::SetIcon(const wxIcon& icon)
{
// this sets m_icon
wxTopLevelWindowBase::SetIcon(icon);
#if defined(__WIN95__) && !defined(__WXMICROWIN__)
if ( m_icon.Ok() )
{
::SendMessage(GetHwnd(), WM_SETICON,
(WPARAM)TRUE, (LPARAM)GetHiconOf(m_icon));
}
#endif // __WIN95__
}

View File

@@ -608,8 +608,7 @@ bool wxWindowMSW::SetCursor(const wxCursor& cursor)
POINT point; POINT point;
::GetCursorPos(&point); ::GetCursorPos(&point);
RECT rect; RECT rect = wxGetWindowRect(hWnd);
::GetWindowRect(hWnd, &rect);
if ( ::PtInRect(&rect, point) && !wxIsBusy() ) if ( ::PtInRect(&rect, point) && !wxIsBusy() )
::SetCursor(GetHcursorOf(m_cursor)); ::SetCursor(GetHcursorOf(m_cursor));
@@ -1184,11 +1183,7 @@ void wxWindowMSW::OnIdle(wxIdleEvent& WXUNUSED(event))
// we need to have client coordinates here for symmetry with // we need to have client coordinates here for symmetry with
// wxEVT_ENTER_WINDOW // wxEVT_ENTER_WINDOW
RECT rect; RECT rect = wxGetWindowRect(GetHwnd());
if ( !::GetWindowRect(GetHwnd(), &rect) )
{
wxLogLastError(_T("GetWindowRect"));
}
pt.x -= rect.left; pt.x -= rect.left;
pt.y -= rect.top; pt.y -= rect.top;
@@ -1329,28 +1324,28 @@ void wxWindowMSW::DoSetToolTip(wxToolTip *tooltip)
// Get total size // Get total size
void wxWindowMSW::DoGetSize(int *x, int *y) const void wxWindowMSW::DoGetSize(int *x, int *y) const
{ {
HWND hWnd = GetHwnd(); RECT rect = wxGetWindowRect(GetHwnd());
RECT rect;
#ifdef __WIN16__
::GetWindowRect(hWnd, &rect);
#else
if ( !::GetWindowRect(hWnd, &rect) )
{
wxLogLastError(_T("GetWindowRect"));
}
#endif
if ( x ) if ( x )
*x = rect.right - rect.left; *x = rect.right - rect.left;
if ( y ) if ( y )
*y = rect.bottom - rect.top; *y = rect.bottom - rect.top;
} }
// Get size *available for subwindows* i.e. excluding menu bar etc.
void wxWindowMSW::DoGetClientSize(int *x, int *y) const
{
RECT rect = wxGetClientRect(GetHwnd());
if ( x )
*x = rect.right;
if ( y )
*y = rect.bottom;
}
void wxWindowMSW::DoGetPosition(int *x, int *y) const void wxWindowMSW::DoGetPosition(int *x, int *y) const
{ {
HWND hWnd = GetHwnd(); RECT rect = wxGetWindowRect(GetHwnd());
RECT rect;
GetWindowRect(hWnd, &rect);
POINT point; POINT point;
point.x = rect.left; point.x = rect.left;
@@ -1396,8 +1391,7 @@ void wxWindowMSW::DoScreenToClient(int *x, int *y) const
if ( y ) if ( y )
pt.y = *y; pt.y = *y;
HWND hWnd = GetHwnd(); ::ScreenToClient(GetHwnd(), &pt);
::ScreenToClient(hWnd, &pt);
if ( x ) if ( x )
*x = pt.x; *x = pt.x;
@@ -1413,8 +1407,7 @@ void wxWindowMSW::DoClientToScreen(int *x, int *y) const
if ( y ) if ( y )
pt.y = *y; pt.y = *y;
HWND hWnd = GetHwnd(); ::ClientToScreen(GetHwnd(), &pt);
::ClientToScreen(hWnd, &pt);
if ( x ) if ( x )
*x = pt.x; *x = pt.x;
@@ -1422,18 +1415,6 @@ void wxWindowMSW::DoClientToScreen(int *x, int *y) const
*y = pt.y; *y = pt.y;
} }
// Get size *available for subwindows* i.e. excluding menu bar etc.
void wxWindowMSW::DoGetClientSize(int *x, int *y) const
{
HWND hWnd = GetHwnd();
RECT rect;
::GetClientRect(hWnd, &rect);
if ( x )
*x = rect.right;
if ( y )
*y = rect.bottom;
}
void wxWindowMSW::DoMoveWindow(int x, int y, int width, int height) void wxWindowMSW::DoMoveWindow(int x, int y, int width, int height)
{ {
if ( !::MoveWindow(GetHwnd(), x, y, width, height, TRUE) ) if ( !::MoveWindow(GetHwnd(), x, y, width, height, TRUE) )

View File

@@ -37,8 +37,6 @@
// event tables // event tables
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow)
BEGIN_EVENT_TABLE(wxTopLevelWindow, wxTopLevelWindowNative) BEGIN_EVENT_TABLE(wxTopLevelWindow, wxTopLevelWindowNative)
EVT_NC_PAINT(wxTopLevelWindow::OnNcPaint) EVT_NC_PAINT(wxTopLevelWindow::OnNcPaint)
END_EVENT_TABLE() END_EVENT_TABLE()