#include "wx/cmdproc.h"
-// turn extra wxTextCtrl-specific debugging on/off
-#define WXDEBUG_TEXT
+#if wxDEBUG_LEVEL >= 2
+ // turn extra wxTextCtrl-specific debugging on/off
+ #define WXDEBUG_TEXT
-// turn wxTextCtrl::Replace() debugging on (slows down code a *lot*!)
-#define WXDEBUG_TEXT_REPLACE
-
-#ifndef __WXDEBUG__
- #undef WXDEBUG_TEXT
- #undef WXDEBUG_TEXT_REPLACE
-#endif
+ // turn wxTextCtrl::Replace() debugging on (slows down code a *lot*!)
+ #define WXDEBUG_TEXT_REPLACE
+#endif // wxDEBUG_LEVEL >= 2
// wxStringTokenize only needed for debug checks
#ifdef WXDEBUG_TEXT_REPLACE
void wxTextCtrl::DoSetValue(const wxString& value, int flags)
{
- if ( IsSingleLine() && (value == GetValue()) )
+ if ( value != GetValue() )
{
- // nothing changed
- return;
- }
+ EventsSuppressor noeventsIf(this, !(flags & SetValue_SendEvent));
- Replace(0, GetLastPosition(), value);
+ Replace(0, GetLastPosition(), value);
- if ( IsSingleLine() )
+ if ( IsSingleLine() )
+ {
+ SetInsertionPoint(0);
+ }
+ }
+ else // nothing changed
{
- SetInsertionPoint(0);
+ // still send event for consistency
+ if ( flags & SetValue_SendEvent )
+ SendTextUpdatedEvent();
}
-
- if ( flags & SetValue_SendEvent )
- SendTextUpdatedEvent();
}
const wxArrayString& wxTextCtrl::GetLines() const
return MData().m_lines.GetCount();
}
-wxString wxTextCtrl::GetValue() const
+wxString wxTextCtrl::DoGetValue() const
{
// for multiline controls we don't always store the total value but only
// recompute it when asked - and to invalidate it we just empty it in
// now call it to do the rest (not related to refreshing)
ClearSelection();
+
+ if ( EventsAllowed() )
+ SendTextUpdatedEvent();
}
void wxTextCtrl::Remove(wxTextPos from, wxTextPos to)
{
// finding the last line is easy if each line has exactly
// one row
- yEnd = yStart + rectText.height / GetLineHeight() - 1;
+ yEnd = yStart + rectText.height / GetLineHeight();
}
if ( yEnd < y )
WData().m_rowFirstInvalid = 0;
// increase timestamp: this means that the lines which had been
- // laid out before will be relayd out the next time LayoutLines()
+ // laid out before will be relaid out the next time LayoutLines()
// is called because their timestamp will be smaller than the
// current one
WData().m_timestamp++;
if ( scrollRangeXOld )
{
- x *= scrollRangeX - m_rectText.width / charWidth;
- x /= scrollRangeXOld - m_rectText.width / charWidth;
+ const int w = m_rectText.width / charWidth;
+ if ( w != scrollRangeXOld )
+ {
+ x *= scrollRangeX - w;
+ x /= scrollRangeXOld - w;
+ }
Scroll(x, y);
}
// FIXME: is this really a bug in wxMSW?
rectTextArea.width--;
#endif // __WXMSW__
+ dc.DestroyClippingRegion();
dc.SetClippingRegion(rectTextArea);
// adjust for scrolling
else
{
// read only controls don't have the caret
- caret = (wxCaret *)NULL;
+ caret = NULL;
}
// SetCaret() will delete the old caret if any
// the command this action corresponds to or NULL if this action doesn't
// change text at all or can't be undone
- wxTextCtrlCommand *command = (wxTextCtrlCommand *)NULL;
+ wxTextCtrlCommand *command = NULL;
wxString action;
bool del = false,
}
#endif
}
-#ifdef __WXDEBUG__
+#if wxDEBUG_LEVEL >= 2
// Ctrl-R refreshes the control in debug mode
else if ( event.ControlDown() && event.GetKeyCode() == 'r' )
Refresh();
-#endif // __WXDEBUG__
+#endif // wxDEBUG_LEVEL >= 2
event.Skip();
}
wxStdTextCtrlInputHandler::wxStdTextCtrlInputHandler(wxInputHandler *inphand)
: wxStdInputHandler(inphand)
{
- m_winCapture = (wxTextCtrl *)NULL;
+ m_winCapture = NULL;
}
/* static */
m_winCapture->ShowCaret();
m_winCapture->ReleaseMouse();
- m_winCapture = (wxTextCtrl *)NULL;
+ m_winCapture = NULL;
}
}