X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6dd16e4f26490f1f4f2be1204840cbf4ecf74a35..cb73e6001f891ae46b12a1e4ca39b93649cb6099:/src/msw/stattext.cpp diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 6a2056e2af..83b4a28188 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -5,11 +5,11 @@ // Modified by: // Created: 04/01/98 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Copyright: (c) Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "stattext.h" #endif @@ -32,7 +32,20 @@ #include "wx/msw/private.h" #include +#if wxUSE_EXTENDED_RTTI +IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticText, wxControl,"wx/stattext.h") + +WX_BEGIN_PROPERTIES_TABLE(wxStaticText) + WX_PROPERTY( Label,wxString, SetLabel, GetLabel, wxEmptyString ) +WX_END_PROPERTIES_TABLE() + +WX_BEGIN_HANDLERS_TABLE(wxStaticText) +WX_END_HANDLERS_TABLE() + +WX_CONSTRUCTOR_6( wxStaticText , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle ) +#else IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) +#endif bool wxStaticText::Create(wxWindow *parent, wxWindowID id, @@ -51,6 +64,11 @@ bool wxStaticText::Create(wxWindow *parent, return TRUE; } +wxBorder wxStaticText::GetDefaultBorder() const +{ + return wxBORDER_NONE; +} + WXDWORD wxStaticText::MSWGetStyle(long style, WXDWORD *exstyle) const { WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle); @@ -76,10 +94,15 @@ wxSize wxStaticText::DoGetBestSize() const int widthTextMax = 0, widthLine, heightTextTotal = 0, heightLineDefault = 0, heightLine = 0; + bool lastWasAmpersand = FALSE; + wxString curLine; - for ( const wxChar *pc = text; ; pc++ ) { - if ( *pc == wxT('\n') || *pc == wxT('\0') ) { - if ( !curLine ) { + for ( const wxChar *pc = text; ; pc++ ) + { + if ( *pc == wxT('\n') || *pc == wxT('\0') ) + { + if ( !curLine ) + { // we can't use GetTextExtent - it will return 0 for both width // and height and an empty line should count in height // calculation @@ -90,22 +113,44 @@ wxSize wxStaticText::DoGetBestSize() const heightTextTotal += heightLineDefault; } - else { + else + { GetTextExtent(curLine, &widthLine, &heightLine); if ( widthLine > widthTextMax ) widthTextMax = widthLine; heightTextTotal += heightLine; } - if ( *pc == wxT('\n') ) { + if ( *pc == wxT('\n') ) + { curLine.Empty(); } - else { + else + { // the end of string break; } } - else { + else + { + // we shouldn't take into account the '&' which just introduces the + // mnemonic characters and so are not shown on the screen -- except + // when it is preceded by another '&' in which case it stands for a + // literal ampersand + if ( *pc == _T('&') ) + { + if ( !lastWasAmpersand ) + { + lastWasAmpersand = TRUE; + + // skip the statement adding pc to curLine below + continue; + } + + // it is a literal ampersand + lastWasAmpersand = FALSE; + } + curLine += *pc; } }