From 58385af01650f2218cff7d64b58140a8aafdf8e0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 7 Mar 2005 23:41:07 +0000 Subject: [PATCH] fix top margin for static box sizer when wxDIALOG_UNIT_COMPATIBILITY == 0 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32655 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/statbox.h | 5 ++-- src/msw/statbox.cpp | 55 +++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/include/wx/msw/statbox.h b/include/wx/msw/statbox.h index da34503f2c..1f89b27e53 100644 --- a/include/wx/msw/statbox.h +++ b/include/wx/msw/statbox.h @@ -39,13 +39,14 @@ public: long style = 0, const wxString& name = wxStaticBoxNameStr); - /// Implementation - virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); + /// Implementation only + virtual void GetBordersForSizer(int *borderTop, int *borderOther) const; protected: virtual wxSize DoGetBestSize() const; virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; + virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); DECLARE_DYNAMIC_CLASS_NO_COPY(wxStaticBox) diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index 5ceea43341..cd21abe857 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -155,35 +155,44 @@ wxSize wxStaticBox::DoGetBestSize() const WXLRESULT wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { #ifndef __WXWINCE__ - switch ( nMsg ) + if ( nMsg == WM_NCHITTEST ) { - case WM_NCHITTEST: - { - // This code breaks some other processing such as enter/leave tracking - // so it's off by default. - - static int s_useHTClient = -1; - if (s_useHTClient == -1) - s_useHTClient = wxSystemOptions::GetOptionInt(wxT("msw.staticbox.htclient")); - if (s_useHTClient == 1) - { - int xPos = LOWORD(lParam); // horizontal position of cursor - int yPos = HIWORD(lParam); // vertical position of cursor - - ScreenToClient(&xPos, &yPos); - - // Make sure you can drag by the top of the groupbox, but let - // other (enclosed) controls get mouse events also - if ( yPos < 10 ) - return (long)HTCLIENT; - } - } - break; + // This code breaks some other processing such as enter/leave tracking + // so it's off by default. + + static int s_useHTClient = -1; + if (s_useHTClient == -1) + s_useHTClient = wxSystemOptions::GetOptionInt(wxT("msw.staticbox.htclient")); + if (s_useHTClient == 1) + { + int xPos = LOWORD(lParam); // horizontal position of cursor + int yPos = HIWORD(lParam); // vertical position of cursor + + ScreenToClient(&xPos, &yPos); + + // Make sure you can drag by the top of the groupbox, but let + // other (enclosed) controls get mouse events also + if ( yPos < 10 ) + return (long)HTCLIENT; + } } #endif // !__WXWINCE__ return wxControl::MSWWindowProc(nMsg, wParam, lParam); } +void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const +{ + wxStaticBoxBase::GetBordersForSizer(borderTop, borderOther); + + // if not using correct (but backwards cojmpatible) text metrics + // calculations, we need to add some extra margin or otherwise static box + // title is clipped +#if !wxDIALOG_UNIT_COMPATIBILITY + if ( !GetLabel().empty() ) + *borderTop += GetCharHeight()/3; +#endif // !wxDIALOG_UNIT_COMPATIBILITY +} + #endif // wxUSE_STATBOX -- 2.45.2