X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..b4446c244775324631b8dd2b588ea35f32e71728:/src/mac/classic/stattext.cpp diff --git a/src/mac/classic/stattext.cpp b/src/mac/classic/stattext.cpp index c1ba821386..a249f3bd58 100644 --- a/src/mac/classic/stattext.cpp +++ b/src/mac/classic/stattext.cpp @@ -1,32 +1,32 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: stattext.cpp +// Name: src/mac/classic/stattext.cpp // Purpose: wxStaticText // Author: Stefan Csomor // Modified by: // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "stattext.h" -#endif +#include "wx/wxprec.h" -#include "wx/app.h" #include "wx/stattext.h" + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/utils.h" + #include "wx/dc.h" + #include "wx/dcclient.h" + #include "wx/settings.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 -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) -#endif #include "wx/mac/uma.h" @@ -59,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 ; @@ -97,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) ; @@ -106,7 +106,7 @@ void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y) } } } - + linedrawn = false; } else @@ -120,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 ; @@ -136,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() ) && @@ -149,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); @@ -168,7 +168,7 @@ void wxStaticText::OnDraw( wxDC &dc ) } ++i; } - if (paragraph.Length() > 0) + if (paragraph.length() > 0) DrawParagraph(dc, paragraph,y); } @@ -230,12 +230,13 @@ wxSize wxStaticText::DoGetBestSize() const void wxStaticText::SetLabel(const wxString& st ) { - SetTitle( st ) ; + wxStaticTextBase::SetLabel( st ) ; m_label = st ; if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) { // temporary fix until layout measurement and drawing are in synch again Refresh() ; + InvalidateBestSize(); SetSize( GetBestSize() ) ; } Refresh() ; @@ -246,17 +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 + 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() ; - SetSize( GetBestSize() ); - } - } + InvalidateBestSize(); + SetSize( GetBestSize() ); + } + } return ret; }