X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9f8845289521c7f53e95b6dfd8275daab8b05639..637b7e4f3a0fd1c6bdfc21d28e37bcf760e3b364:/src/mac/classic/stattext.cpp diff --git a/src/mac/classic/stattext.cpp b/src/mac/classic/stattext.cpp index 38c4b1041b..c989d56afc 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,10 +9,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "stattext.h" -#endif - #include "wx/app.h" #include "wx/stattext.h" #include "wx/notebook.h" @@ -24,9 +20,7 @@ #include -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) -#endif #include "wx/mac/uma.h" @@ -59,33 +53,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 ; @@ -97,7 +91,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) ; @@ -106,7 +100,7 @@ void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) } } } - + linedrawn = false; } else @@ -120,7 +114,7 @@ void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) { pos += ( m_width - width ) ; } - + dc.DrawText( paragraph, pos , y) ; paragraph=wxEmptyString; y += height ; @@ -136,7 +130,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() ) && @@ -149,14 +143,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); @@ -168,7 +162,7 @@ void wxStaticText::OnDraw( wxDC &dc ) } ++i; } - if (paragraph.Length() > 0) + if (paragraph.length() > 0) DrawParagraph(dc, paragraph,y); } @@ -230,7 +224,7 @@ wxSize wxStaticText::DoGetBestSize() const void wxStaticText::SetLabel(const wxString& st ) { - SetTitle( st ) ; + wxStaticTextBase::SetLabel( st ) ; m_label = st ; if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) { @@ -247,18 +241,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; }