X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fb896a322a2ed53d393ee738765ddd3f72cee004..0425151023593cb31da0ee0a652da173ca9abfde:/src/cocoa/stattext.mm diff --git a/src/cocoa/stattext.mm b/src/cocoa/stattext.mm index 521ae120e0..ff30c7cb2f 100644 --- a/src/cocoa/stattext.mm +++ b/src/cocoa/stattext.mm @@ -12,8 +12,11 @@ #include "wx/app.h" #include "wx/stattext.h" +#include "wx/cocoa/autorelease.h" + #import #import +#include IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) BEGIN_EVENT_TABLE(wxStaticText, wxControl) @@ -27,6 +30,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID winid, long style, const wxString& name) { + wxAutoNSAutoreleasePool pool; if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) return false; m_cocoaNSView = NULL; @@ -37,7 +41,13 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID winid, [GetNSTextField() setBezeled: NO]; [GetNSTextField() setEditable: NO]; [GetNSTextField() setDrawsBackground: NO]; + [GetNSControl() sizeToFit]; + // Round-up to next integer size + NSRect nsrect = [m_cocoaNSView frame]; + nsrect.size.width = ceil(nsrect.size.width); + [m_cocoaNSView setFrameSize: nsrect.size]; + if(m_parent) m_parent->CocoaAddChild(this); return true; @@ -45,8 +55,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID winid, wxStaticText::~wxStaticText() { - CocoaRemoveFromParent(); - SetNSTextField(NULL); + DisassociateNSTextField(m_cocoaNSView); } void wxStaticText::SetLabel(const wxString& label)