From e49d97e66a1c4d01413face83788d77e1d187fe6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 7 May 2002 23:27:59 +0000 Subject: [PATCH] fixed Windows style of wxPopupWindow git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15415 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/popupwin.h | 24 +++++-------- src/msw/popupwin.cpp | 76 +++++++++++++++++++++++++++++++++++++++ src/msw/window.cpp | 13 +++---- 3 files changed, 91 insertions(+), 22 deletions(-) create mode 100644 src/msw/popupwin.cpp diff --git a/include/wx/msw/popupwin.h b/include/wx/msw/popupwin.h index 239ee04212..3ec588a476 100644 --- a/include/wx/msw/popupwin.h +++ b/include/wx/msw/popupwin.h @@ -12,6 +12,10 @@ #ifndef _WX_MSW_POPUPWIN_H_ #define _WX_MSW_POPUPWIN_H_ +#ifdef __GNUG__ + #pragma interface "popup.h" +#endif + // ---------------------------------------------------------------------------- // wxPopupWindow // ---------------------------------------------------------------------------- @@ -24,24 +28,12 @@ public: wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE) { (void)Create(parent, flags); } - bool Create(wxWindow *parent, int flags = wxBORDER_NONE) - { - return wxPopupWindowBase::Create(parent) && - wxWindow::Create(parent, -1, - wxDefaultPosition, wxDefaultSize, - (flags & wxBORDER_MASK) | wxPOPUP_WINDOW); - } + bool Create(wxWindow *parent, int flags = wxBORDER_NONE); protected: - virtual void DoGetPosition(int *x, int *y) const - { - // the position of a "top level" window such as this should be in - // screen coordinates, not in the client ones which MSW gives us - // (because we are a child window) - wxPopupWindowBase::DoGetPosition(x, y); - - GetParent()->ClientToScreen(x, y); - } + virtual void DoGetPosition(int *x, int *y) const; + + virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle) const; DECLARE_DYNAMIC_CLASS(wxPopupWindow) }; diff --git a/src/msw/popupwin.cpp b/src/msw/popupwin.cpp new file mode 100644 index 0000000000..15e5b9ac5d --- /dev/null +++ b/src/msw/popupwin.cpp @@ -0,0 +1,76 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: msw/popupwin.cpp +// Purpose: implements wxPopupWindow for MSW +// Author: Vadim Zeitlin +// Modified by: +// Created: 08.05.02 +// RCS-ID: $Id$ +// Copyright: (c) 2002 Vadim Zeitlin +// License: wxWindows license +/////////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "popup.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#endif //WX_PRECOMP + +#include "wx/popupwin.h" + +// ============================================================================ +// implementation +// ============================================================================ + +bool wxPopupWindow::Create(wxWindow *parent, int flags) +{ + return wxPopupWindowBase::Create(parent) && + wxWindow::Create(parent, -1, + wxDefaultPosition, wxDefaultSize, + flags | wxPOPUP_WINDOW); +} + +void wxPopupWindow::DoGetPosition(int *x, int *y) const +{ + // the position of a "top level" window such as this should be in + // screen coordinates, not in the client ones which MSW gives us + // (because we are a child window) + wxPopupWindowBase::DoGetPosition(x, y); + + GetParent()->ClientToScreen(x, y); +} + +WXDWORD wxPopupWindow::MSWGetStyle(long flags, WXDWORD *exstyle) const +{ + // we only hnour the border flags + WXDWORD style = wxWindow::MSWGetStyle(flags & wxBORDER_MASK, exstyle); + + // and we mustn't have WS_CHILD style or we would be limited to the parents + // client area + style &= ~WS_CHILD; + style |= WS_POPUP; + + if ( exstyle ) + { + // a popup window floats on top of everything + *exstyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW; + } + + return style; +} + diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 3b06d5adcf..bae64cf403 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -405,9 +405,8 @@ bool wxWindowMSW::Create(wxWindow *parent, parent->AddChild(this); - // note that all windows are created visible by default WXDWORD exstyle; - DWORD msflags = WS_VISIBLE | MSWGetCreateWindowFlags(&exstyle); + DWORD msflags = MSWGetCreateWindowFlags(&exstyle); #ifdef __WXUNIVERSAL__ // no borders, we draw them ourselves @@ -415,15 +414,17 @@ bool wxWindowMSW::Create(wxWindow *parent, msflags &= ~WS_BORDER; #endif // wxUniversal + // all windows are created visible by default except popup ones (which are + // like the wxTopLevelWindows in this aspect) if ( style & wxPOPUP_WINDOW ) { - // a popup window floats on top of everything - exstyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW; - - // it is also created hidden as other top level windows msflags &= ~WS_VISIBLE; m_isShown = FALSE; } + else + { + msflags |= WS_VISIBLE; + } return MSWCreate(wxCanvasClassName, NULL, pos, size, msflags, exstyle); } -- 2.45.2