X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8907154c1a8a6882c6797d1f16393ddfb23e7f3a..f5590243955d800aaeee4e2c3b8c4aec14919181:/src/mac/classic/stattext.cpp diff --git a/src/mac/classic/stattext.cpp b/src/mac/classic/stattext.cpp index bdda2c708f..3038c7733f 100644 --- a/src/mac/classic/stattext.cpp +++ b/src/mac/classic/stattext.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: stattext.cpp +// Name: src/mac/classic/stattext.cpp // Purpose: wxStaticText // Author: Stefan Csomor // Modified by: @@ -9,13 +9,19 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#include "wx/app.h" +#include "wx/wxprec.h" + #include "wx/stattext.h" + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/utils.h" + #include "wx/dc.h" + #include "wx/dcclient.h" +#endif + #include "wx/notebook.h" #include "wx/tabctrl.h" -#include "wx/dc.h" -#include "wx/dcclient.h" -#include "wx/utils.h" #include "wx/settings.h" #include @@ -53,33 +59,33 @@ const wxString punct = wxT(" ,.-;:!?"); void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) { long width, height ; - - if (paragraph.Length() == 0) + + if (paragraph.length() == 0) { // empty line dc.GetTextExtent( wxT("H"), &width, &height ); y += height; - + return; } int x = 0 ; bool linedrawn = true; - while( paragraph.Length() > 0 ) + while( paragraph.length() > 0 ) { dc.GetTextExtent( paragraph , &width , &height ) ; - + if ( width > m_width ) { - for ( size_t p = paragraph.Length() - 1 ; p > 0 ; --p ) + for ( size_t p = paragraph.length() - 1 ; p > 0 ; --p ) { if ((punct.Find(paragraph[p]) != wxNOT_FOUND) || !linedrawn) { int blank = (paragraph[p] == ' ') ? 0 : 1; - + dc.GetTextExtent( paragraph.Left(p + blank) , &width , &height ) ; - + if ( width <= m_width ) { int pos = x ; @@ -91,7 +97,7 @@ void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) { pos += ( m_width - width ) ; } - + dc.DrawText( paragraph.Left(p + blank), pos , y) ; y += height ; paragraph = paragraph.Mid(p+1) ; @@ -100,7 +106,7 @@ void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) } } } - + linedrawn = false; } else @@ -114,7 +120,7 @@ void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) { pos += ( m_width - width ) ; } - + dc.DrawText( paragraph, pos , y) ; paragraph=wxEmptyString; y += height ; @@ -130,7 +136,7 @@ void wxStaticText::OnDraw( wxDC &dc ) dc.Clear() ; wxRect rect(0,0,m_width,m_height) ; dc.SetFont(*wxSMALL_FONT) ; - + dc.DrawRectangle(rect) ; */ if ( !IsWindowHilited( (WindowRef) MacGetRootWindow() ) && @@ -143,14 +149,14 @@ void wxStaticText::OnDraw( wxDC &dc ) { dc.SetTextForeground( GetForegroundColour() ) ; } - + wxString paragraph; size_t i = 0 ; wxString text = m_label; int y = 0 ; - while (i < text.Length()) + while (i < text.length()) { - + if (text[i] == 13 || text[i] == 10) { DrawParagraph(dc, paragraph,y); @@ -162,7 +168,7 @@ void wxStaticText::OnDraw( wxDC &dc ) } ++i; } - if (paragraph.Length() > 0) + if (paragraph.length() > 0) DrawParagraph(dc, paragraph,y); } @@ -224,7 +230,7 @@ wxSize wxStaticText::DoGetBestSize() const void wxStaticText::SetLabel(const wxString& st ) { - SetTitle( st ) ; + wxStaticTextBase::SetLabel( st ) ; m_label = st ; if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) { @@ -241,18 +247,18 @@ bool wxStaticText::SetFont(const wxFont& font) { bool ret = wxControl::SetFont(font); - if ( ret ) - { - // adjust the size of the window to fit to the label unless autoresizing is - // disabled - if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) - { - // temporary fix until layout measurement and drawing are in synch again - Refresh() ; - InvalidateBestSize(); - SetSize( GetBestSize() ); - } - } + if ( ret ) + { + // adjust the size of the window to fit to the label unless autoresizing is + // disabled + if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) + { + // temporary fix until layout measurement and drawing are in synch again + Refresh() ; + InvalidateBestSize(); + SetSize( GetBestSize() ); + } + } return ret; }