#include "wx/osx/private.h"
-IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
-
BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
EVT_CHAR(wxTextCtrl::OnChar)
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() ;
GetTextPeer()->CheckSpelling(check);
}
-void wxTextCtrl::SetMaxLength(unsigned long len)
-{
- m_maxLength = len ;
-}
-
bool wxTextCtrl::SetFont( const wxFont& font )
{
if ( !wxTextCtrlBase::SetFont( font ) )
if (size.x > 0 && size.y > 0)
return size;
}
-
+
int wText, hText;
// these are the numbers from the HIG:
{
if (CanCopy())
{
- wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_COPY, GetId());
+ wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_COPY, GetId());
evt.SetEventObject(this);
if (!GetEventHandler()->ProcessEvent(evt))
{
{
if (CanCut())
{
- wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_CUT, GetId());
+ wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_CUT, GetId());
evt.SetEventObject(this);
if (!GetEventHandler()->ProcessEvent(evt))
{
{
if (CanPaste())
{
- wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_PASTE, GetId());
+ wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_PASTE, GetId());
evt.SetEventObject(this);
if (!GetEventHandler()->ProcessEvent(evt))
{
void wxTextCtrl::OnKeyDown(wxKeyEvent& event)
{
- if ( event.GetModifiers() == wxMOD_CMD )
+ if ( event.GetModifiers() == wxMOD_CONTROL )
{
switch( event.GetKeyCode() )
{
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
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;