wxCaretSuspender only shows the caret if it was visible previously

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
This commit is contained in:
Julian Smart
2003-08-11 16:33:56 +00:00
parent f07c570112
commit e28c2d151b
4 changed files with 37 additions and 8 deletions

View File

@@ -212,18 +212,23 @@ public:
wxCaretSuspend(wxWindow *win) wxCaretSuspend(wxWindow *win)
{ {
m_caret = win->GetCaret(); m_caret = win->GetCaret();
if ( m_caret ) m_show = FALSE;
if ( m_caret && m_caret->IsVisible() )
{
m_caret->Hide(); m_caret->Hide();
m_show = TRUE;
}
} }
~wxCaretSuspend() ~wxCaretSuspend()
{ {
if ( m_caret ) if ( m_caret && m_show )
m_caret->Show(); m_caret->Show();
} }
private: private:
wxCaret *m_caret; wxCaret *m_caret;
bool m_show;
DECLARE_NO_COPY_CLASS(wxCaretSuspend) DECLARE_NO_COPY_CLASS(wxCaretSuspend)
}; };

View File

@@ -622,6 +622,7 @@ void wxListBox::OnInternalIdle()
m_updateCount = 0; m_updateCount = 0;
} }
OnInternalIdle();
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -324,6 +324,7 @@ wxScrollArrows::Arrow wxScrollBar::HitTest(const wxPoint& pt) const
void wxScrollBar::OnInternalIdle() void wxScrollBar::OnInternalIdle()
{ {
UpdateThumb(); UpdateThumb();
wxControl::OnInternalIdle();
} }
void wxScrollBar::UpdateThumb() void wxScrollBar::UpdateThumb()

View File

@@ -735,6 +735,9 @@ bool wxTextCtrl::Create(wxWindow *parent,
CreateInputHandler(wxINP_HANDLER_TEXTCTRL); CreateInputHandler(wxINP_HANDLER_TEXTCTRL);
wxSizeEvent sizeEvent(GetSize(), GetId());
GetEventHandler()->ProcessEvent(sizeEvent);
return TRUE; return TRUE;
} }
@@ -1864,7 +1867,9 @@ wxPoint wxTextCtrl::GetCaretPosition() const
// pos may be -1 to show the current position // pos may be -1 to show the current position
void wxTextCtrl::ShowPosition(wxTextPos pos) void wxTextCtrl::ShowPosition(wxTextPos pos)
{ {
HideCaret(); bool showCaret = GetCaret() && GetCaret()->IsVisible();
if (showCaret)
HideCaret();
if ( IsSingleLine() ) if ( IsSingleLine() )
{ {
@@ -1984,7 +1989,8 @@ void wxTextCtrl::ShowPosition(wxTextPos pos)
} }
//else: multiline but no scrollbars, hence nothing to do //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 // show caret first time only: we must show it after drawing the text or
// the display can be corrupted when it's hidden // the display can be corrupted when it's hidden
if ( !m_hasCaret && GetCaret() ) if ( !m_hasCaret && GetCaret() && (FindFocus() == this) )
{ {
ShowCaret(); ShowCaret();
@@ -4222,7 +4228,10 @@ bool wxTextCtrl::Enable(bool enable)
if ( !wxTextCtrlBase::Enable(enable) ) if ( !wxTextCtrlBase::Enable(enable) )
return FALSE; return FALSE;
ShowCaret(enable); if (FindFocus() == this && GetCaret() &&
((enable && !GetCaret()->IsVisible()) ||
(!enable && GetCaret()->IsVisible())))
ShowCaret(enable);
return TRUE; return TRUE;
} }
@@ -4258,7 +4267,9 @@ void wxTextCtrl::ShowCaret(bool show)
caret->Move(GetCaretPosition()); caret->Move(GetCaretPosition());
// and show it there // 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 bool
wxStdTextCtrlInputHandler::HandleFocus(wxInputConsumer *consumer, wxStdTextCtrlInputHandler::HandleFocus(wxInputConsumer *consumer,
const wxFocusEvent& WXUNUSED(event)) const wxFocusEvent& event)
{ {
wxTextCtrl *text = wxStaticCast(consumer->GetInputWindow(), wxTextCtrl); wxTextCtrl *text = wxStaticCast(consumer->GetInputWindow(), wxTextCtrl);
// the selection appearance changes depending on whether we have the focus // the selection appearance changes depending on whether we have the focus
text->RefreshSelection(); 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 // never refresh entirely
return FALSE; return FALSE;
} }