X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e9576ca53db96b462ed4c0b4bdf47d64c40203e4..53faea431638ee5c0013a2c888215c751fa6437b:/src/mac/stattext.cpp diff --git a/src/mac/stattext.cpp b/src/mac/stattext.cpp index 3b19c7184d..b249fc0e11 100644 --- a/src/mac/stattext.cpp +++ b/src/mac/stattext.cpp @@ -18,9 +18,13 @@ #include -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) -#endif + +#include + +BEGIN_EVENT_TABLE(wxStaticText, wxControl) + EVT_PAINT(wxStaticText::OnPaint) +END_EVENT_TABLE() bool wxStaticText::Create(wxWindow *parent, wxWindowID id, const wxString& label, @@ -29,32 +33,87 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - SetName(name); - if (parent) parent->AddChild(this); + SetName(name); + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; - SetBackgroundColour(parent->GetBackgroundColour()) ; - SetForegroundColour(parent->GetForegroundColour()) ; + if ( id == -1 ) + m_windowId = (int)NewControlId(); + else + m_windowId = id; - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; + m_windowStyle = style; + m_label = label ; - m_windowStyle = style; + bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name ); + SetSizeOrDefault( size ) ; + + return ret; +} - SetFont(parent->GetFont()); +void wxStaticText::OnPaint( wxPaintEvent &event ) +{ + wxPaintDC dc(this); + PrepareDC(dc); + dc.Clear() ; + dc.DrawText( m_label , 0 , 0 ) ; +} - // TODO - return FALSE; +wxSize wxStaticText::DoGetBestSize() const +{ + int x , y ; + GetTextExtent( m_label , &x , &y ) ; + return wxSize( x , y ) ; } +void wxStaticText::SetLabel(const wxString& st , bool resize ) +{ + SetTitle( st ) ; + m_label = st ; + if ( resize ) + SetSizeOrDefault() ; + else + Refresh() ; +} +/* void wxStaticText::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + wxControl::SetSize( x , y , width , height , sizeFlags ) ; +} + +bool wxStaticText::Create(wxWindow *parent, wxWindowID id, + const wxString& label, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, + kControlStaticTextProc , (long) this ) ; + ::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) title[0] , (char*) &title[1] ) ; + + MacPostControlCreate() ; + + return TRUE; } -void wxStaticText::SetLabel(const wxString& label) +void wxStaticText::SetLabel(const wxString& st , bool resize ) { - // TODO + SetTitle( st ) ; + wxString label ; + + if( wxApp::s_macDefaultEncodingIsPC ) + label = wxMacMakeMacStringFromPC( st ) ; + else + label = st ; + + ::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) label.Length() , (char*)(const char*) label ) ; + Refresh() ; } +*/