]> git.saurik.com Git - wxWidgets.git/commitdiff
wxCaretSuspender only shows the caret if it was visible previously
authorJulian Smart <julian@anthemion.co.uk>
Mon, 11 Aug 2003 16:33:56 +0000 (16:33 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Mon, 11 Aug 2003 16:33:56 +0000 (16:33 +0000)
Improved caret handling in wxTextCtrl
Restored scrollbar painting in wxUniv

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22773 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/caret.h
src/univ/listbox.cpp
src/univ/scrolbar.cpp
src/univ/textctrl.cpp

index 266f6d278d0318713281b25ab351a35d4946167b..f8e547bc38fd5102e21309ed8ca99198f0063559 100644 (file)
@@ -212,18 +212,23 @@ public:
     wxCaretSuspend(wxWindow *win)
     {
         m_caret = win->GetCaret();
-        if ( m_caret )
+        m_show = FALSE;        
+        if ( m_caret && m_caret->IsVisible() )
+        {
             m_caret->Hide();
+            m_show = TRUE;
+        }
     }
 
     ~wxCaretSuspend()
     {
-        if ( m_caret )
+        if ( m_caret && m_show )
             m_caret->Show();
     }
 
 private:
     wxCaret *m_caret;
+    bool     m_show;
 
     DECLARE_NO_COPY_CLASS(wxCaretSuspend)
 };
index 84cd3a79a14d3e570f7fb557beafb6fa5eafd952..2b2ec463e3f3c447a7efa48b2a94cbf640491153 100644 (file)
@@ -622,6 +622,7 @@ void wxListBox::OnInternalIdle()
 
         m_updateCount = 0;
     }
+    OnInternalIdle();
 }
 
 // ----------------------------------------------------------------------------
index 3873aed615202a2d54fa0e3889e3dc00214e6374..8626070f0deed332be11204b4b15adc64e906942 100644 (file)
@@ -324,6 +324,7 @@ wxScrollArrows::Arrow wxScrollBar::HitTest(const wxPoint& pt) const
 void wxScrollBar::OnInternalIdle()
 {
     UpdateThumb();
+    wxControl::OnInternalIdle();
 }
 
 void wxScrollBar::UpdateThumb()
index 6e28cbd26c98dd08eba07abf8a4d5c3cf17bf8a6..1ac457b9440564afa8ecfaa6a9741098a35f844d 100644 (file)
@@ -735,6 +735,9 @@ bool wxTextCtrl::Create(wxWindow *parent,
 
     CreateInputHandler(wxINP_HANDLER_TEXTCTRL);
 
+    wxSizeEvent sizeEvent(GetSize(), GetId());
+    GetEventHandler()->ProcessEvent(sizeEvent);
+
     return TRUE;
 }
 
@@ -1864,7 +1867,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 +1989,8 @@ void wxTextCtrl::ShowPosition(wxTextPos pos)
     }
     //else: multiline but no scrollbars, hence nothing to do
 
-    ShowCaret();
+    if (showCaret)
+        ShowCaret();
 }
 
 // ----------------------------------------------------------------------------
@@ -4179,7 +4185,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();
 
@@ -4222,7 +4228,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;
 }
@@ -4258,7 +4267,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);
     }
 }
 
@@ -4902,13 +4913,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;
 }