X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ce00f59b5b169752d2f05ce3bb1a88ddc1b38b4c..cd0f218cdd3114dc6770bc9f6703225aabb5a2de:/src/osx/textctrl_osx.cpp diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index ff1a28f48d..e513b16b7e 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -48,8 +48,6 @@ #include "wx/osx/private.h" -IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase) - BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase) EVT_DROP_FILES(wxTextCtrl::OnDropFiles) EVT_CHAR(wxTextCtrl::OnChar) @@ -97,7 +95,7 @@ bool wxTextCtrl::Create( wxWindow *parent, const wxValidator& validator, const wxString& name ) { - m_macIsUserPane = false ; + DontCreatePeer(); m_editable = true ; if ( ! (style & wxNO_BORDER) ) @@ -114,7 +112,7 @@ bool wxTextCtrl::Create( wxWindow *parent, } - m_peer = wxWidgetImpl::CreateTextControl( this, GetParent(), GetId(), str, pos, size, style, GetExtraStyle() ); + SetPeer(wxWidgetImpl::CreateTextControl( this, GetParent(), GetId(), str, pos, size, style, GetExtraStyle() )); MacPostControlCreate(pos, size) ; @@ -156,11 +154,6 @@ void wxTextCtrl::MacCheckSpelling(bool check) GetTextPeer()->CheckSpelling(check); } -void wxTextCtrl::SetMaxLength(unsigned long len) -{ - m_maxLength = len ; -} - bool wxTextCtrl::SetFont( const wxFont& font ) { if ( !wxTextCtrlBase::SetFont( font ) ) @@ -292,7 +285,7 @@ void wxTextCtrl::Copy() { if (CanCopy()) { - wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_COPY, GetId()); + wxClipboardTextEvent evt(wxEVT_TEXT_COPY, GetId()); evt.SetEventObject(this); if (!GetEventHandler()->ProcessEvent(evt)) { @@ -305,7 +298,7 @@ void wxTextCtrl::Cut() { if (CanCut()) { - wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_CUT, GetId()); + wxClipboardTextEvent evt(wxEVT_TEXT_CUT, GetId()); evt.SetEventObject(this); if (!GetEventHandler()->ProcessEvent(evt)) { @@ -320,7 +313,7 @@ void wxTextCtrl::Paste() { if (CanPaste()) { - wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_PASTE, GetId()); + wxClipboardTextEvent evt(wxEVT_TEXT_PASTE, GetId()); evt.SetEventObject(this); if (!GetEventHandler()->ProcessEvent(evt)) { @@ -341,7 +334,7 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event) void wxTextCtrl::OnKeyDown(wxKeyEvent& event) { - if ( event.GetModifiers() == wxMOD_CMD ) + if ( event.GetModifiers() == wxMOD_CONTROL ) { switch( event.GetKeyCode() ) { @@ -383,18 +376,21 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) return ; } - // Check if we have reached the max # of chars (if it is set), but still - // allow navigation and deletion - GetSelection( &from, &to ); - if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength && - !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB | WXK_CATEGORY_CUT) && - !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) ) && - from == to ) + if ( !GetTextPeer()->CanClipMaxLength() ) { - // eat it, we don't want to add more than allowed # of characters + // Check if we have reached the max # of chars (if it is set), but still + // allow navigation and deletion + GetSelection( &from, &to ); + if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength && + !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB | WXK_CATEGORY_CUT) && + !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) ) && + from == to ) + { + // eat it, we don't want to add more than allowed # of characters - // TODO: generate EVT_TEXT_MAXLEN() - return; + // TODO: generate EVT_TEXT_MAXLEN() + return; + } } // assume that any key not processed yet is going to modify the control @@ -405,7 +401,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) case WXK_RETURN: if (m_windowStyle & wxTE_PROCESS_ENTER) { - wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); + wxCommandEvent event(wxEVT_TEXT_ENTER, m_windowId); event.SetEventObject( this ); event.SetString( GetValue() ); if ( HandleWindowEvent(event) ) @@ -420,7 +416,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton); if ( def && def->IsEnabled() ) { - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() ); + wxCommandEvent event(wxEVT_BUTTON, def->GetId() ); event.SetEventObject(def); def->Command(event); @@ -473,7 +469,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) key == WXK_DELETE || key == WXK_BACK) { - wxCommandEvent event1(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); + wxCommandEvent event1(wxEVT_TEXT, m_windowId); event1.SetEventObject( this ); wxPostEvent( GetEventHandler(), event1 ); } @@ -604,6 +600,21 @@ bool wxTextCtrl::MacSetupCursor( const wxPoint& pt ) return true ; } +bool wxTextCtrl::SetHint(const wxString& hint) +{ + m_hintString = hint; + + if ( GetTextPeer() && GetTextPeer()->SetHint(hint) ) + return true; + + return false; +} + +wxString wxTextCtrl::GetHint() const +{ + return m_hintString; +} + // ---------------------------------------------------------------------------- // implementation base class // ---------------------------------------------------------------------------- @@ -762,9 +773,10 @@ int wxTextWidgetImpl::GetLineLength(long lineNo) const count = 0; for (size_t j = i; j < content.length(); j++) { - count++; if (content[j] == '\n') return count; + + count++; } return count;