X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/61fef19b852d426f5b00b60de083539b9ba0f76c..d896a793a01cf7dc02ed04dcadb51591438eb32f:/src/univ/textctrl.cpp?ds=sidebyside diff --git a/src/univ/textctrl.cpp b/src/univ/textctrl.cpp index f209017f86..0765852720 100644 --- a/src/univ/textctrl.cpp +++ b/src/univ/textctrl.cpp @@ -117,7 +117,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "univtextctrl.h" #endif @@ -129,6 +129,8 @@ #if wxUSE_TEXTCTRL +#include + #ifndef WX_PRECOMP #include "wx/log.h" @@ -526,6 +528,8 @@ public: 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: @@ -549,6 +553,8 @@ public: 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: @@ -616,6 +622,25 @@ IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) // creation // ---------------------------------------------------------------------------- +wxTextCtrl::wxTextCtrl() +{ + Init(); +} + +wxTextCtrl::wxTextCtrl(wxWindow *parent, + wxWindowID id, + const wxString& value, + const wxPoint& pos, + const wxSize& size, + long style, + const wxValidator& validator, + const wxString& name) +{ + Init(); + + Create(parent, id, value, pos, size, style, validator, name); +} + void wxTextCtrl::Init() { m_selAnchor = @@ -735,6 +760,9 @@ bool wxTextCtrl::Create(wxWindow *parent, CreateInputHandler(wxINP_HANDLER_TEXTCTRL); + wxSizeEvent sizeEvent(GetSize(), GetId()); + GetEventHandler()->ProcessEvent(sizeEvent); + return TRUE; } @@ -1576,6 +1604,11 @@ bool wxTextCtrl::IsEditable() const return m_isEditable && IsEnabled(); } +void wxTextCtrl::MarkDirty() +{ + m_isModified = TRUE; +} + void wxTextCtrl::DiscardEdits() { m_isModified = FALSE; @@ -1864,7 +1897,9 @@ wxPoint wxTextCtrl::GetCaretPosition() const // 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() ) { @@ -1984,7 +2019,8 @@ void wxTextCtrl::ShowPosition(wxTextPos pos) } //else: multiline but no scrollbars, hence nothing to do - ShowCaret(); + if (showCaret) + ShowCaret(); } // ---------------------------------------------------------------------------- @@ -2328,7 +2364,7 @@ wxSize wxTextCtrl::DoGetBestClientSize() const lines = 5; else if ( lines > 10 ) lines = 10; - h *= 10; + h *= lines; } wxRect rectText; @@ -2443,7 +2479,7 @@ void wxTextCtrl::UpdateLastVisible() 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) @@ -3577,6 +3613,7 @@ void wxTextCtrl::OnInternalIdle() { UpdateScrollbars(); } + wxControl::OnInternalIdle(); } bool wxTextCtrl::SendAutoScrollEvents(wxScrollWinEvent& event) const @@ -4178,7 +4215,7 @@ void wxTextCtrl::DoDraw(wxControlRenderer *renderer) // 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(); @@ -4221,7 +4258,10 @@ bool wxTextCtrl::Enable(bool enable) if ( !wxTextCtrlBase::Enable(enable) ) return FALSE; - ShowCaret(enable); + if (FindFocus() == this && GetCaret() && + ((enable && !GetCaret()->IsVisible()) || + (!enable && GetCaret()->IsVisible()))) + ShowCaret(enable); return TRUE; } @@ -4257,7 +4297,9 @@ void wxTextCtrl::ShowCaret(bool show) caret->Move(GetCaretPosition()); // and show it there - caret->Show(show); + if ((show && !caret->IsVisible()) || + (!show && caret->IsVisible())) + caret->Show(show); } } @@ -4901,13 +4943,24 @@ bool wxStdTextCtrlInputHandler::HandleMouseMove(wxInputConsumer *consumer, bool wxStdTextCtrlInputHandler::HandleFocus(wxInputConsumer *consumer, - const wxFocusEvent& WXUNUSED(event)) + 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; }