X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/99b4164c2c8eff4441548f9d93dbdcd7891cfb90..acd32ffcdb319f162633c20e0202db3f8542998a:/src/univ/textctrl.cpp diff --git a/src/univ/textctrl.cpp b/src/univ/textctrl.cpp index 42d6364c2b..9417dc7633 100644 --- a/src/univ/textctrl.cpp +++ b/src/univ/textctrl.cpp @@ -790,21 +790,23 @@ wxTextCtrl::~wxTextCtrl() 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 @@ -1264,6 +1266,9 @@ void wxTextCtrl::Replace(wxTextPos from, wxTextPos to, const wxString& text) // now call it to do the rest (not related to refreshing) ClearSelection(); + + if ( EventsAllowed() ) + SendTextUpdatedEvent(); } void wxTextCtrl::Remove(wxTextPos from, wxTextPos to) @@ -3615,8 +3620,12 @@ void wxTextCtrl::UpdateScrollbars() 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); } @@ -4193,6 +4202,7 @@ void wxTextCtrl::DoDraw(wxControlRenderer *renderer) // FIXME: is this really a bug in wxMSW? rectTextArea.width--; #endif // __WXMSW__ + dc.DestroyClippingRegion(); dc.SetClippingRegion(rectTextArea); // adjust for scrolling @@ -4304,7 +4314,7 @@ void wxTextCtrl::CreateCaret() else { // read only controls don't have the caret - caret = (wxCaret *)NULL; + caret = NULL; } // SetCaret() will delete the old caret if any @@ -4423,7 +4433,7 @@ bool wxTextCtrl::PerformAction(const wxControlAction& actionOrig, // 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, @@ -4779,7 +4789,7 @@ wxInputHandler *wxTextCtrl::GetStdInputHandler(wxInputHandler *handlerDef) wxStdTextCtrlInputHandler::wxStdTextCtrlInputHandler(wxInputHandler *inphand) : wxStdInputHandler(inphand) { - m_winCapture = (wxTextCtrl *)NULL; + m_winCapture = NULL; } /* static */ @@ -4956,7 +4966,7 @@ bool wxStdTextCtrlInputHandler::HandleMouse(wxInputConsumer *consumer, m_winCapture->ShowCaret(); m_winCapture->ReleaseMouse(); - m_winCapture = (wxTextCtrl *)NULL; + m_winCapture = NULL; } }