X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7d8268a1d64de58aab194e4d8ae800c755990aad..3f4a2351e4c677c88c18ea812b609477adee7380:/src/mac/classic/textctrl.cpp?ds=sidebyside diff --git a/src/mac/classic/textctrl.cpp b/src/mac/classic/textctrl.cpp index 5713099316..633d379688 100644 --- a/src/mac/classic/textctrl.cpp +++ b/src/mac/classic/textctrl.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: textctrl.cpp +// Name: src/mac/classic/textctrl.cpp // Purpose: wxTextCtrl // Author: Stefan Csomor // Modified by: @@ -9,23 +9,33 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "textctrl.h" -#endif +#include "wx/wxprec.h" -#include "wx/defs.h" +#ifdef __BORLANDC__ + #pragma hdrstop +#endif #if wxUSE_TEXTCTRL +#include "wx/textctrl.h" + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/utils.h" + #include "wx/dc.h" + #include "wx/button.h" + #include "wx/settings.h" + #include "wx/msgdlg.h" + #include "wx/toplevel.h" +#endif + #ifdef __DARWIN__ - #include - #include + #include + #include #else - #include + #include #endif -#include "wx/msgdlg.h" - #if wxUSE_STD_IOSTREAM #if wxUSE_IOSTREAMH #include @@ -34,21 +44,14 @@ #endif #endif -#include "wx/app.h" -#include "wx/dc.h" -#include "wx/button.h" -#include "wx/toplevel.h" -#include "wx/textctrl.h" #include "wx/notebook.h" #include "wx/tabctrl.h" -#include "wx/settings.h" #include "wx/filefn.h" -#include "wx/utils.h" #if defined(__BORLANDC__) && !defined(__WIN32__) - #include + #include #elif !defined(__MWERKS__) && !defined(__GNUWIN32) && !defined(__DARWIN__) - #include + #include #endif #ifndef __DARWIN__ @@ -637,10 +640,9 @@ OSStatus mUPOpenControl(ControlHandle theControl, long wxStyle ) -#if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) +IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase) -BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) +BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase) EVT_DROP_FILES(wxTextCtrl::OnDropFiles) EVT_CHAR(wxTextCtrl::OnChar) EVT_MENU(wxID_CUT, wxTextCtrl::OnCut) @@ -655,13 +657,12 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo) EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo) END_EVENT_TABLE() -#endif static void SetTXNData( TXNObject txn , const wxString& st , TXNOffset start , TXNOffset end ) { #if wxUSE_UNICODE #if SIZEOF_WCHAR_T == 2 - size_t len = st.Len() ; + size_t len = st.length() ; TXNSetData( txn , kTXNUnicodeTextData, (void*)st.wc_str(), len * 2, start, end); #else @@ -1198,7 +1199,7 @@ void wxTextCtrl::Replace(long from, long to, const wxString& str) ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; TESetSelect( from , to , ((TEHandle) m_macTE) ) ; TEDelete( ((TEHandle) m_macTE) ) ; - TEInsert( value , value.Length() , ((TEHandle) m_macTE) ) ; + TEInsert( value , value.length() , ((TEHandle) m_macTE) ) ; } else { @@ -1274,16 +1275,6 @@ void wxTextCtrl::SetSelection(long from, long to) } } -bool wxTextCtrl::LoadFile(const wxString& file) -{ - if ( wxTextCtrlBase::LoadFile(file) ) - { - return true; - } - - return false; -} - void wxTextCtrl::WriteText(const wxString& str) { wxString st = str ; @@ -1454,7 +1445,7 @@ int wxTextCtrl::GetNumberOfLines() const wxString content = GetValue() ; int count = 1; - for (size_t i = 0; i < content.Length() ; i++) + for (size_t i = 0; i < content.length() ; i++) { if (content[i] == '\r') count++; } @@ -1505,13 +1496,13 @@ int wxTextCtrl::GetLineLength(long lineNo) const // Find line first int count = 0; - for (size_t i = 0; i < content.Length() ; i++) + for (size_t i = 0; i < content.length() ; i++) { if (count == lineNo) { // Count chars in line then count = 0; - for (size_t j = i; j < content.Length(); j++) + for (size_t j = i; j < content.length(); j++) { count++; if (content[j] == '\n') return count; @@ -1531,14 +1522,14 @@ wxString wxTextCtrl::GetLineText(long lineNo) const // Find line first int count = 0; - for (size_t i = 0; i < content.Length() ; i++) + for (size_t i = 0; i < content.length() ; i++) { if (count == lineNo) { // Add chars in line then wxString tmp; - for (size_t j = i; j < content.Length(); j++) + for (size_t j = i; j < content.length(); j++) { if (content[j] == '\n') return tmp; @@ -1585,8 +1576,8 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) } if ( !IsEditable() && key != WXK_LEFT && key != WXK_RIGHT && key != WXK_DOWN && key != WXK_UP && key != WXK_TAB && - !( key == WXK_RETURN && ( (m_windowStyle & wxPROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) ) -/* && key != WXK_PRIOR && key != WXK_NEXT && key != WXK_HOME && key != WXK_END */ + !( key == WXK_RETURN && ( (m_windowStyle & wxTE_PROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) ) +/* && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END */ ) { // eat it @@ -1611,7 +1602,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) switch ( key ) { case WXK_RETURN: - if (m_windowStyle & wxPROCESS_ENTER) + if (m_windowStyle & wxTE_PROCESS_ENTER) { wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); event.SetEventObject( this ); @@ -1621,14 +1612,10 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) } if ( !(m_windowStyle & wxTE_MULTILINE) ) { - wxWindow *parent = GetParent(); - while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) { - parent = parent->GetParent() ; - } - if ( parent && parent->GetDefaultItem() ) + wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); + if ( tlw && tlw->GetDefaultItem() ) { - wxButton *def = wxDynamicCast(parent->GetDefaultItem(), - wxButton); + wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton); if ( def && def->IsEnabled() ) { wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );