X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/31582e4e11d504a28461d62b05411202d3a906d0..119a78753d60ee80d2a95323d66bb1c7f2cc0b6b:/src/msw/stattext.cpp diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index cc4b995d2d..20ae8b9c92 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -9,10 +9,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "stattext.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -22,6 +18,8 @@ #if wxUSE_STATTEXT +#include "wx/stattext.h" + #ifndef WX_PRECOMP #include "wx/event.h" #include "wx/app.h" @@ -30,7 +28,6 @@ #include "wx/settings.h" #endif -#include "wx/stattext.h" #include "wx/msw/private.h" #if wxUSE_EXTENDED_RTTI @@ -123,6 +120,9 @@ WXDWORD wxStaticText::MSWGetStyle(long style, WXDWORD *exstyle) const else msStyle |= SS_LEFT; + // this style is necessary to receive mouse events + msStyle |= SS_NOTIFY; + return msStyle; } @@ -132,17 +132,48 @@ wxSize wxStaticText::DoGetBestSize() const wxFont font(GetFont()); if (!font.Ok()) font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - + dc.SetFont(font); wxCoord widthTextMax, heightTextTotal; - dc.GetMultiLineTextExtent(GetLabel(), &widthTextMax, &heightTextTotal); + dc.GetMultiLineTextExtent(GetLabelText(), &widthTextMax, &heightTextTotal); #ifdef __WXWINCE__ if ( widthTextMax ) widthTextMax += 2; #endif // __WXWINCE__ + // border takes extra space + // + // TODO: this is probably not wxStaticText-specific and should be moved + wxCoord border; + switch ( GetBorder() ) + { + case wxBORDER_STATIC: + case wxBORDER_SIMPLE: + border = 1; + break; + + case wxBORDER_SUNKEN: + border = 2; + break; + + case wxBORDER_RAISED: + case wxBORDER_DOUBLE: + border = 3; + break; + + default: + wxFAIL_MSG( _T("unknown border style") ); + // fall through + + case wxBORDER_NONE: + border = 0; + } + + widthTextMax += 2*border; + heightTextTotal += 2*border; + wxSize best(widthTextMax, heightTextTotal); CacheBestSize(best); return best;