// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "univtextctrl.h"
#endif
#if wxUSE_TEXTCTRL
+#include <ctype.h>
+
#ifndef WX_PRECOMP
#include "wx/log.h"
// ----------------------------------------------------------------------------
/*
- We use custom versions of wxWindows command processor to implement undo/redo
+ We use custom versions of wxWidgets command processor to implement undo/redo
as we want to avoid storing the backpointer to wxTextCtrl in wxCommand
itself: this is a waste of memory as all commands in the given command
processor always have the same associated wxTextCtrl and so it makes sense
virtual bool CanUndo() const;
virtual bool Do(wxTextCtrl *text);
+ virtual bool Do() { return wxTextCtrlCommand::Do(); }
+ virtual bool Undo() { return wxTextCtrlCommand::Undo(); }
virtual bool Undo(wxTextCtrl *text);
private:
virtual bool CanUndo() const;
virtual bool Do(wxTextCtrl *text);
+ virtual bool Do() { return wxTextCtrlCommand::Do(); }
+ virtual bool Undo() { return wxTextCtrlCommand::Undo(); }
virtual bool Undo(wxTextCtrl *text);
private:
EVT_CHAR(wxTextCtrl::OnChar)
EVT_SIZE(wxTextCtrl::OnSize)
-
- EVT_IDLE(wxTextCtrl::OnIdle)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
CreateInputHandler(wxINP_HANDLER_TEXTCTRL);
+ wxSizeEvent sizeEvent(GetSize(), GetId());
+ GetEventHandler()->ProcessEvent(sizeEvent);
+
return TRUE;
}
return m_isEditable && IsEnabled();
}
+void wxTextCtrl::MarkDirty()
+{
+ m_isModified = TRUE;
+}
+
void wxTextCtrl::DiscardEdits()
{
m_isModified = FALSE;
// pos may be -1 to show the current position
void wxTextCtrl::ShowPosition(wxTextPos pos)
{
- HideCaret();
+ bool showCaret = GetCaret() && GetCaret()->IsVisible();
+ if (showCaret)
+ HideCaret();
if ( IsSingleLine() )
{
}
//else: multiline but no scrollbars, hence nothing to do
- ShowCaret();
+ if (showCaret)
+ ShowCaret();
}
// ----------------------------------------------------------------------------
lines = 5;
else if ( lines > 10 )
lines = 10;
- h *= 10;
+ h *= lines;
}
wxRect rectText;
SData().m_colLastVisible += SData().m_colStart;
wxLogTrace(_T("text"), _T("Last visible column/position is %d/%ld"),
- SData().m_colLastVisible, SData().m_posLastVisible);
+ (int) SData().m_colLastVisible, (long) SData().m_posLastVisible);
}
void wxTextCtrl::OnSize(wxSizeEvent& event)
MData().m_updateScrollbarY = FALSE;
}
-void wxTextCtrl::OnIdle(wxIdleEvent& event)
+void wxTextCtrl::OnInternalIdle()
{
// notice that single line text control never has scrollbars
if ( !IsSingleLine() &&
{
UpdateScrollbars();
}
-
- event.Skip();
+ wxControl::OnInternalIdle();
}
bool wxTextCtrl::SendAutoScrollEvents(wxScrollWinEvent& event) const
// show caret first time only: we must show it after drawing the text or
// the display can be corrupted when it's hidden
- if ( !m_hasCaret && GetCaret() )
+ if ( !m_hasCaret && GetCaret() && (FindFocus() == this) )
{
ShowCaret();
if ( !wxTextCtrlBase::Enable(enable) )
return FALSE;
- ShowCaret(enable);
+ if (FindFocus() == this && GetCaret() &&
+ ((enable && !GetCaret()->IsVisible()) ||
+ (!enable && GetCaret()->IsVisible())))
+ ShowCaret(enable);
return TRUE;
}
caret->Move(GetCaretPosition());
// and show it there
- caret->Show(show);
+ if ((show && !caret->IsVisible()) ||
+ (!show && caret->IsVisible()))
+ caret->Show(show);
}
}
return wxStdInputHandler::HandleMouseMove(consumer, event);
}
-bool wxStdTextCtrlInputHandler::HandleFocus(wxInputConsumer *consumer,
- const wxFocusEvent& event)
+bool
+wxStdTextCtrlInputHandler::HandleFocus(wxInputConsumer *consumer,
+ const wxFocusEvent& event)
{
wxTextCtrl *text = wxStaticCast(consumer->GetInputWindow(), wxTextCtrl);
// the selection appearance changes depending on whether we have the focus
text->RefreshSelection();
+ if (event.GetEventType() == wxEVT_SET_FOCUS)
+ {
+ if (text->GetCaret() && !text->GetCaret()->IsVisible())
+ text->ShowCaret();
+ }
+ else
+ {
+ if (text->GetCaret() && text->GetCaret()->IsVisible())
+ text->HideCaret();
+ }
+
// never refresh entirely
return FALSE;
}