Allow changing alignment styles after wxTextCtrl creation (wxOSX)
Update NSTextView/NSTextField alignment mode when wxTextCtrl alignment styles are changed with SetWindowStyleFlag(). Closes #17952.
This commit is contained in:
committed by
Artur Wieczorek
parent
cd1c3fab0c
commit
ccc513bca9
@@ -241,6 +241,7 @@ wxOSX:
|
|||||||
- Add support for wxTE_CHARWRAP style to wxTextCtrl.
|
- Add support for wxTE_CHARWRAP style to wxTextCtrl.
|
||||||
- Fix selecting RGB bitmaps (with no alpha channel) into wxMemoryDC.
|
- Fix selecting RGB bitmaps (with no alpha channel) into wxMemoryDC.
|
||||||
- Fix updating radio groups when menu item is inserted/removed from wxMenu.
|
- Fix updating radio groups when menu item is inserted/removed from wxMenu.
|
||||||
|
- Allow changing alignment styles after wxTextCtrl creation (Andreas Falkenhahn).
|
||||||
|
|
||||||
Unix:
|
Unix:
|
||||||
|
|
||||||
|
@@ -69,6 +69,7 @@ public :
|
|||||||
virtual void WriteText(const wxString& str) wxOVERRIDE ;
|
virtual void WriteText(const wxString& str) wxOVERRIDE ;
|
||||||
virtual bool HasOwnContextMenu() const wxOVERRIDE { return true; }
|
virtual bool HasOwnContextMenu() const wxOVERRIDE { return true; }
|
||||||
virtual bool SetHint(const wxString& hint) wxOVERRIDE;
|
virtual bool SetHint(const wxString& hint) wxOVERRIDE;
|
||||||
|
virtual void SetJustification() wxOVERRIDE;
|
||||||
|
|
||||||
virtual void controlAction(WXWidget slf, void* _cmd, void *sender) wxOVERRIDE;
|
virtual void controlAction(WXWidget slf, void* _cmd, void *sender) wxOVERRIDE;
|
||||||
virtual bool becomeFirstResponder(WXWidget slf, void *_cmd) wxOVERRIDE;
|
virtual bool becomeFirstResponder(WXWidget slf, void *_cmd) wxOVERRIDE;
|
||||||
@@ -125,6 +126,7 @@ public:
|
|||||||
virtual void EnableAutomaticDashSubstitution(bool enable) wxOVERRIDE;
|
virtual void EnableAutomaticDashSubstitution(bool enable) wxOVERRIDE;
|
||||||
|
|
||||||
virtual wxSize GetBestSize() const wxOVERRIDE;
|
virtual wxSize GetBestSize() const wxOVERRIDE;
|
||||||
|
virtual void SetJustification() wxOVERRIDE;
|
||||||
|
|
||||||
virtual void controlTextDidChange() wxOVERRIDE;
|
virtual void controlTextDidChange() wxOVERRIDE;
|
||||||
|
|
||||||
|
@@ -695,6 +695,7 @@ public :
|
|||||||
virtual wxSize GetBestSize() const { return wxDefaultSize; }
|
virtual wxSize GetBestSize() const { return wxDefaultSize; }
|
||||||
|
|
||||||
virtual bool SetHint(const wxString& WXUNUSED(hint)) { return false; }
|
virtual bool SetHint(const wxString& WXUNUSED(hint)) { return false; }
|
||||||
|
virtual void SetJustification();
|
||||||
private:
|
private:
|
||||||
wxTextEntry * const m_entry;
|
wxTextEntry * const m_entry;
|
||||||
|
|
||||||
|
@@ -100,6 +100,7 @@ public:
|
|||||||
virtual void Command(wxCommandEvent& event) wxOVERRIDE;
|
virtual void Command(wxCommandEvent& event) wxOVERRIDE;
|
||||||
|
|
||||||
virtual bool AcceptsFocus() const wxOVERRIDE;
|
virtual bool AcceptsFocus() const wxOVERRIDE;
|
||||||
|
virtual void SetWindowStyleFlag(long style) wxOVERRIDE;
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
void OnDropFiles(wxDropFilesEvent& event);
|
void OnDropFiles(wxDropFilesEvent& event);
|
||||||
|
@@ -1004,9 +1004,10 @@ public:
|
|||||||
@endStyleTable
|
@endStyleTable
|
||||||
|
|
||||||
Note that alignment styles (wxTE_LEFT, wxTE_CENTRE and wxTE_RIGHT) can be
|
Note that alignment styles (wxTE_LEFT, wxTE_CENTRE and wxTE_RIGHT) can be
|
||||||
changed dynamically after control creation on wxMSW and wxGTK. wxTE_READONLY,
|
changed dynamically after control creation on wxMSW, wxGTK and wxOSX.
|
||||||
wxTE_PASSWORD and wrapping styles can be dynamically changed under wxGTK but
|
wxTE_READONLY, wxTE_PASSWORD and wrapping styles can be dynamically changed
|
||||||
not wxMSW. The other styles can be only set during control creation.
|
under wxGTK but not wxMSW. The other styles can be only set during control
|
||||||
|
creation.
|
||||||
|
|
||||||
|
|
||||||
@section textctrl_text_format wxTextCtrl Text Format
|
@section textctrl_text_format wxTextCtrl Text Format
|
||||||
|
@@ -1142,6 +1142,23 @@ wxSize wxNSTextViewControl::GetBestSize() const
|
|||||||
return wxSize(0,0);
|
return wxSize(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxNSTextViewControl::SetJustification()
|
||||||
|
{
|
||||||
|
if ( !m_textView )
|
||||||
|
return;
|
||||||
|
|
||||||
|
NSTextAlignment align;
|
||||||
|
|
||||||
|
if ( m_wxPeer->HasFlag(wxTE_RIGHT) )
|
||||||
|
align = NSRightTextAlignment;
|
||||||
|
else if ( m_wxPeer->HasFlag(wxTE_CENTRE) )
|
||||||
|
align = NSCenterTextAlignment;
|
||||||
|
else // wxTE_LEFT == 0
|
||||||
|
align = NSLeftTextAlignment;
|
||||||
|
|
||||||
|
[m_textView setAlignment:align];
|
||||||
|
}
|
||||||
|
|
||||||
// wxNSTextFieldControl
|
// wxNSTextFieldControl
|
||||||
|
|
||||||
wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *text, WXWidget w )
|
wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *text, WXWidget w )
|
||||||
@@ -1425,6 +1442,23 @@ bool wxNSTextFieldControl::SetHint(const wxString& hint)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxNSTextFieldControl::SetJustification()
|
||||||
|
{
|
||||||
|
if ( !m_textField )
|
||||||
|
return;
|
||||||
|
|
||||||
|
NSTextAlignment align;
|
||||||
|
|
||||||
|
if ( m_wxPeer->HasFlag(wxTE_RIGHT) )
|
||||||
|
align = NSRightTextAlignment;
|
||||||
|
else if ( m_wxPeer->HasFlag(wxTE_CENTRE) )
|
||||||
|
align = NSCenterTextAlignment;
|
||||||
|
else // wxTE_LEFT == 0
|
||||||
|
align = NSLeftTextAlignment;
|
||||||
|
|
||||||
|
[m_textField setAlignment:align];
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@@ -482,6 +482,17 @@ void wxTextCtrl::Command(wxCommandEvent & event)
|
|||||||
ProcessCommand(event);
|
ProcessCommand(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxTextCtrl::SetWindowStyleFlag(long style)
|
||||||
|
{
|
||||||
|
long styleOld = GetWindowStyleFlag();
|
||||||
|
|
||||||
|
wxTextCtrlBase::SetWindowStyleFlag(style);
|
||||||
|
|
||||||
|
static const long flagsAlign = wxTE_LEFT | wxTE_CENTRE | wxTE_RIGHT;
|
||||||
|
if ( (style & flagsAlign) != (styleOld & flagsAlign) )
|
||||||
|
GetTextPeer()->SetJustification();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// standard handlers for standard edit menu events
|
// standard handlers for standard edit menu events
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -774,4 +785,7 @@ int wxTextWidgetImpl::GetLineLength(long lineNo) const
|
|||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxTextWidgetImpl::SetJustification()
|
||||||
|
{
|
||||||
|
}
|
||||||
#endif // wxUSE_TEXTCTRL
|
#endif // wxUSE_TEXTCTRL
|
||||||
|
Reference in New Issue
Block a user