Allow OS X Cocoa (or any OS X port) to override GetBestSize and provide a native OS X Cocoa impl. Also, fix the line ending check under OS X Cocoa, and a sanity check for SetStyle.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62725 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -62,6 +62,7 @@ public:
|
||||
virtual void SetStyle(long start, long end, const wxTextAttr& style);
|
||||
|
||||
virtual void CheckSpelling(bool check);
|
||||
virtual wxSize GetBestSize() const;
|
||||
|
||||
protected:
|
||||
NSScrollView* m_scrollView;
|
||||
|
@@ -586,6 +586,8 @@ public :
|
||||
virtual int GetLineLength(long lineNo) const ;
|
||||
virtual wxString GetLineText(long lineNo) const ;
|
||||
virtual void CheckSpelling(bool WXUNUSED(check)) { }
|
||||
|
||||
virtual wxSize GetBestSize() const { return wxDefaultSize; }
|
||||
};
|
||||
|
||||
//
|
||||
|
@@ -514,6 +514,18 @@ void wxNSTextViewControl::CheckSpelling(bool check)
|
||||
[m_textView setContinuousSpellCheckingEnabled: check];
|
||||
}
|
||||
|
||||
wxSize wxNSTextViewControl::GetBestSize() const
|
||||
{
|
||||
if (m_textView && [m_textView layoutManager])
|
||||
{
|
||||
NSRect rect = [[m_textView layoutManager] usedRectForTextContainer: [m_textView textContainer]];
|
||||
wxSize size = wxSize(rect.size.width, rect.size.height);
|
||||
size.x += [m_textView textContainerInset].width;
|
||||
size.y += [m_textView textContainerInset].height;
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
// wxNSTextFieldControl
|
||||
|
||||
wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w)
|
||||
|
@@ -190,6 +190,7 @@ bool wxTextCtrl::SetFont( const wxFont& font )
|
||||
|
||||
bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
|
||||
{
|
||||
if (GetTextPeer())
|
||||
GetTextPeer()->SetStyle( start , end , style ) ;
|
||||
|
||||
return true ;
|
||||
@@ -337,6 +338,13 @@ bool wxTextCtrl::AcceptsFocus() const
|
||||
|
||||
wxSize wxTextCtrl::DoGetBestSize() const
|
||||
{
|
||||
if (GetTextPeer())
|
||||
{
|
||||
wxSize size = GetTextPeer()->GetBestSize();
|
||||
if (size.x > 0 && size.y > 0)
|
||||
return size;
|
||||
}
|
||||
|
||||
int wText, hText;
|
||||
|
||||
// these are the numbers from the HIG:
|
||||
@@ -826,7 +834,11 @@ int wxTextWidgetImpl::GetNumberOfLines() const
|
||||
|
||||
for (size_t i = 0; i < content.length() ; i++)
|
||||
{
|
||||
#if wxOSX_USE_COCOA
|
||||
if (content[i] == '\n')
|
||||
#else
|
||||
if (content[i] == '\r')
|
||||
#endif
|
||||
lines++;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user