Start on Get/SetStyle support for OS X Cocoa wxTextCtrl.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62531 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -58,6 +58,9 @@ public:
|
|||||||
virtual void WriteText(const wxString& str) ;
|
virtual void WriteText(const wxString& str) ;
|
||||||
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
|
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
|
||||||
|
|
||||||
|
virtual bool GetStyle(long position, wxTextAttr& style);
|
||||||
|
virtual void SetStyle(long start, long end, const wxTextAttr& style);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NSScrollView* m_scrollView;
|
NSScrollView* m_scrollView;
|
||||||
NSTextView* m_textView;
|
NSTextView* m_textView;
|
||||||
|
@@ -556,6 +556,7 @@ public :
|
|||||||
virtual void GetSelection( long* from, long* to ) const = 0 ;
|
virtual void GetSelection( long* from, long* to ) const = 0 ;
|
||||||
virtual void WriteText( const wxString& str ) = 0 ;
|
virtual void WriteText( const wxString& str ) = 0 ;
|
||||||
|
|
||||||
|
virtual bool GetStyle( long position, wxTextAttr& style);
|
||||||
virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
|
virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
|
||||||
virtual void Copy() ;
|
virtual void Copy() ;
|
||||||
virtual void Cut() ;
|
virtual void Cut() ;
|
||||||
|
@@ -93,6 +93,7 @@ public:
|
|||||||
// methods apply the given text style to the given selection or to
|
// methods apply the given text style to the given selection or to
|
||||||
// set/get the style which will be used for all appended text
|
// set/get the style which will be used for all appended text
|
||||||
virtual bool SetFont( const wxFont &font );
|
virtual bool SetFont( const wxFont &font );
|
||||||
|
virtual bool GetStyle(long position, wxTextAttr& style);
|
||||||
virtual bool SetStyle(long start, long end, const wxTextAttr& style);
|
virtual bool SetStyle(long start, long end, const wxTextAttr& style);
|
||||||
virtual bool SetDefaultStyle(const wxTextAttr& style);
|
virtual bool SetDefaultStyle(const wxTextAttr& style);
|
||||||
|
|
||||||
|
@@ -429,6 +429,45 @@ void wxNSTextViewControl::SetFont( const wxFont & font , const wxColour& WXUNUSE
|
|||||||
[m_textView setFont: font.OSXGetNSFont()];
|
[m_textView setFont: font.OSXGetNSFont()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxNSTextViewControl::GetStyle(long position, wxTextAttr& style)
|
||||||
|
{
|
||||||
|
if (m_textView) {
|
||||||
|
NSTextStorage* storage = [m_textView textStorage];
|
||||||
|
NSFont* font = [storage attribute:NSFontAttributeName atIndex:position effectiveRange:NULL];
|
||||||
|
if (font)
|
||||||
|
style.SetFont(wxFont(font));
|
||||||
|
NSColor* bgcolor = [storage attribute:NSBackgroundColorAttributeName atIndex:position effectiveRange:NULL];
|
||||||
|
if (bgcolor)
|
||||||
|
style.SetBackgroundColour(wxColour(bgcolor));
|
||||||
|
NSColor* fgcolor = [storage attribute:NSForegroundColorAttributeName atIndex:position effectiveRange:NULL];
|
||||||
|
style.SetTextColour(wxColour(fgcolor));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxNSTextViewControl::SetStyle(long start,
|
||||||
|
long end,
|
||||||
|
const wxTextAttr& style)
|
||||||
|
{
|
||||||
|
if (m_textView) {
|
||||||
|
NSRange range = NSMakeRange(start, end-start);
|
||||||
|
NSTextStorage* storage = [m_textView textStorage];
|
||||||
|
|
||||||
|
wxFont font = style.GetFont();
|
||||||
|
if (font.IsOk())
|
||||||
|
[storage addAttribute:NSFontAttributeName value:style.GetFont().OSXGetNSFont() range:range];
|
||||||
|
|
||||||
|
wxColour bgcolor = style.GetBackgroundColour();
|
||||||
|
if (bgcolor.IsOk())
|
||||||
|
[storage addAttribute:NSBackgroundColorAttributeName value:bgcolor.OSXGetNSColor() range:range];
|
||||||
|
|
||||||
|
wxColour fgcolor = style.GetTextColour();
|
||||||
|
if (fgcolor.IsOk())
|
||||||
|
[storage addAttribute:NSForegroundColorAttributeName value:fgcolor.OSXGetNSColor() range:range];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// wxNSTextFieldControl
|
// wxNSTextFieldControl
|
||||||
|
|
||||||
|
@@ -373,6 +373,11 @@ wxSize wxTextCtrl::DoGetBestSize() const
|
|||||||
return wxSize(wText, hText);
|
return wxSize(wText, hText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
|
||||||
|
{
|
||||||
|
return GetTextPeer()->GetStyle(position, style);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Undo/redo
|
// Undo/redo
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -724,6 +729,12 @@ bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
|
|||||||
// implementation base class
|
// implementation base class
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxTextWidgetImpl::GetStyle(long WXUNUSED(position),
|
||||||
|
wxTextAttr& WXUNUSED(style))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void wxTextWidgetImpl::SetStyle(long WXUNUSED(start),
|
void wxTextWidgetImpl::SetStyle(long WXUNUSED(start),
|
||||||
long WXUNUSED(end),
|
long WXUNUSED(end),
|
||||||
const wxTextAttr& WXUNUSED(style))
|
const wxTextAttr& WXUNUSED(style))
|
||||||
|
Reference in New Issue
Block a user