// Author: Stefan Csomor
// Modified by: Ryan Norton (MLTE GetLineLength and GetLineText)
// Created: 1998-01-01
-// RCS-ID: $Id: textctrl.cpp 54820 2008-07-29 20:04:11Z SC $
+// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/osx/private.h"
-IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
-
BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
EVT_CHAR(wxTextCtrl::OnChar)
m_dirty = false;
m_privateContextMenu = NULL;
- m_triggerUpdateEvents = true ;
}
wxTextCtrl::~wxTextCtrl()
const wxValidator& validator,
const wxString& name )
{
- m_macIsUserPane = false ;
+ DontCreatePeer();
m_editable = true ;
if ( ! (style & wxNO_BORDER) )
}
- 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) ;
-
+
#if wxOSX_USE_COCOA
// under carbon everything can already be set before the MacPostControlCreate embedding takes place
// but under cocoa for single line textfields this only works after everything has been set up
GetTextPeer()->SetStringValue(str);
#endif
-
+
// only now the embedding is correct and we can do a positioning update
MacSuperChangedPosition() ;
return true;
}
-wxTextWidgetImpl* wxTextCtrl::GetTextPeer() const
-{
- return dynamic_cast<wxTextWidgetImpl*> (m_peer);
-}
-
void wxTextCtrl::MacSuperChangedPosition()
{
wxWindow::MacSuperChangedPosition() ;
if (size.x > 0 && size.y > 0)
return size;
}
-
+
int wText, hText;
// these are the numbers from the HIG:
return GetTextPeer()->GetLineText(lineNo) ;
}
-void wxTextCtrl::Remove(long from, long to)
+void wxTextCtrl::Copy()
{
- wxTextEntry::Remove(from, to);
- if ( m_triggerUpdateEvents )
- SendTextUpdatedEvent();
-}
-
-void wxTextCtrl::WriteText(const wxString& str)
-{
- wxTextEntry::WriteText( str ) ;
- if ( m_triggerUpdateEvents )
- SendTextUpdatedEvent();
-}
-
-void wxTextCtrl::Clear()
-{
- wxTextEntry::Clear() ;
- SendTextUpdatedEvent();
+ if (CanCopy())
+ {
+ wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_COPY, GetId());
+ evt.SetEventObject(this);
+ if (!GetEventHandler()->ProcessEvent(evt))
+ {
+ wxTextEntry::Copy();
+ }
+ }
}
void wxTextCtrl::Cut()
{
if (CanCut())
{
- wxTextEntry::Cut() ;
+ wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_CUT, GetId());
+ evt.SetEventObject(this);
+ if (!GetEventHandler()->ProcessEvent(evt))
+ {
+ wxTextEntry::Cut();
- SendTextUpdatedEvent();
+ SendTextUpdatedEvent();
+ }
}
}
{
if (CanPaste())
{
- wxTextEntry::Paste();
+ wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_PASTE, GetId());
+ evt.SetEventObject(this);
+ if (!GetEventHandler()->ProcessEvent(evt))
+ {
+ wxTextEntry::Paste();
- // TODO: eventually we should add setting the default style again
- SendTextUpdatedEvent();
+ // TODO: eventually we should add setting the default style again
+ SendTextUpdatedEvent();
+ }
}
}
void wxTextCtrl::OnKeyDown(wxKeyEvent& event)
{
- if ( event.GetModifiers() == wxMOD_CMD )
+ if ( event.GetModifiers() == wxMOD_CONTROL )
{
switch( event.GetKeyCode() )
{
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
// ----------------------------------------------------------------------------
count = 0;
for (size_t j = i; j < content.length(); j++)
{
- count++;
if (content[j] == '\n')
return count;
+
+ count++;
}
return count;