/////////////////////////////////////////////////////////////////////////////
-// Name: textctrl.cpp
+// Name: src/mac/carbon/textctrl.cpp
// Purpose: wxTextCtrl
// Author: Stefan Csomor
// Modified by: Ryan Norton (MLTE GetLineLength and GetLineText)
#if wxUSE_TEXTCTRL
+#include "wx/textctrl.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/intl.h"
+ #include "wx/app.h"
+ #include "wx/utils.h"
+#endif
#ifdef __DARWIN__
- #include <sys/types.h>
- #include <sys/stat.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
#else
- #include <stat.h>
+ #include <stat.h>
#endif
#include "wx/msgdlg.h"
#endif
#endif
-#include "wx/app.h"
#include "wx/dc.h"
#include "wx/button.h"
#include "wx/toplevel.h"
-#include "wx/textctrl.h"
#include "wx/settings.h"
#include "wx/filefn.h"
-#include "wx/utils.h"
#include "wx/sysopt.h"
#include "wx/menu.h"
-#include "wx/intl.h"
#if defined(__BORLANDC__) && !defined(__WIN32__)
- #include <alloc.h>
+ #include <alloc.h>
#elif !defined(__MWERKS__) && !defined(__GNUWIN32) && !defined(__DARWIN__)
- #include <malloc.h>
+ #include <malloc.h>
#endif
#ifndef __DARWIN__
m_maxLength = 0;
m_privateContextMenu = NULL;
+ m_triggerOnSetValue = true ;
}
wxTextCtrl::~wxTextCtrl()
GetPeer()->SetStringValue( str ) ;
- wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
- event.SetString( GetValue() );
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
+ if ( m_triggerOnSetValue )
+ {
+ wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
+ event.SetString( GetValue() );
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( event );
+ }
}
void wxTextCtrl::SetMaxLength(unsigned long len)
int key = event.GetKeyCode() ;
bool eat_key = false ;
+ if ( key == 'a' && event.MetaDown() )
+ {
+ SelectAll() ;
+
+ return ;
+ }
+
if ( key == 'c' && event.MetaDown() )
{
if ( CanCopy() )
}
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
// Check if we have reached the max # of chars (if it is set), but still
// allow navigation and deletion
- if ( !IsMultiLine() && m_maxLength && GetValue().Length() >= m_maxLength &&
+ if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength &&
key != WXK_LEFT && key != WXK_RIGHT && key != WXK_TAB &&
- key != WXK_BACK && !( key == WXK_RETURN && (m_windowStyle & wxPROCESS_ENTER) )
+ key != WXK_BACK && !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) )
)
{
// eat it, we don't want to add more than allowed # of characters
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 );
wxTextPos wxMacTextControl::GetLastPosition() const
{
- return GetStringValue().Length() ;
+ return GetStringValue().length() ;
}
void wxMacTextControl::Replace( long from , long to , const wxString &val )
wxString content = GetStringValue() ;
lines = 1;
- for (size_t i = 0; i < content.Length() ; i++)
+ for (size_t i = 0; i < content.length() ; i++)
{
if (content[i] == '\r')
lines++;
// 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;
// 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')
void wxMacUnicodeTextControl::SetEditable(bool editable)
{
- SetData<Boolean>( 0 , kControlEditTextLockedTag , (Boolean) !editable ) ;
+#if 0 // leads to problem because text cannot be selected anymore
+ SetData<Boolean>( kControlEditTextPart , kControlEditTextLockedTag , (Boolean) !editable ) ;
+#endif
}
void wxMacUnicodeTextControl::GetSelection( long* from, long* to ) const
val.Remove( start , end - start ) ;
val.insert( start , str ) ;
SetStringValue( val ) ;
- SetSelection( start + str.Length() , start + str.Length() ) ;
+ SetSelection( start + str.length() , start + str.length() ) ;
#endif
}
(((UniChar*)*theText)[actualSize]) = 0 ;
wxMBConvUTF16 converter ;
size_t noChars = converter.MB2WC( NULL , (const char*)*theText , 0 ) ;
+ wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Unable to count the number of characters in this string!") );
ptr = new wxChar[noChars + 1] ;
- noChars = converter.MB2WC( ptr , (const char*)*theText , noChars ) ;
+ noChars = converter.MB2WC( ptr , (const char*)*theText , noChars + 1 ) ;
+ wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Conversion of string failed!") );
ptr[noChars] = 0 ;
HUnlock( theText ) ;
#endif