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:
@@ -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)
|
||||
};
|
||||
|
@@ -622,6 +622,7 @@ void wxListBox::OnInternalIdle()
|
||||
|
||||
m_updateCount = 0;
|
||||
}
|
||||
OnInternalIdle();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -324,6 +324,7 @@ wxScrollArrows::Arrow wxScrollBar::HitTest(const wxPoint& pt) const
|
||||
void wxScrollBar::OnInternalIdle()
|
||||
{
|
||||
UpdateThumb();
|
||||
wxControl::OnInternalIdle();
|
||||
}
|
||||
|
||||
void wxScrollBar::UpdateThumb()
|
||||
|
@@ -735,6 +735,9 @@ bool wxTextCtrl::Create(wxWindow *parent,
|
||||
|
||||
CreateInputHandler(wxINP_HANDLER_TEXTCTRL);
|
||||
|
||||
wxSizeEvent sizeEvent(GetSize(), GetId());
|
||||
GetEventHandler()->ProcessEvent(sizeEvent);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1864,6 +1867,8 @@ wxPoint wxTextCtrl::GetCaretPosition() const
|
||||
// pos may be -1 to show the current position
|
||||
void wxTextCtrl::ShowPosition(wxTextPos pos)
|
||||
{
|
||||
bool showCaret = GetCaret() && GetCaret()->IsVisible();
|
||||
if (showCaret)
|
||||
HideCaret();
|
||||
|
||||
if ( IsSingleLine() )
|
||||
@@ -1984,6 +1989,7 @@ void wxTextCtrl::ShowPosition(wxTextPos pos)
|
||||
}
|
||||
//else: multiline but no scrollbars, hence nothing to do
|
||||
|
||||
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,6 +4228,9 @@ bool wxTextCtrl::Enable(bool enable)
|
||||
if ( !wxTextCtrlBase::Enable(enable) )
|
||||
return FALSE;
|
||||
|
||||
if (FindFocus() == this && GetCaret() &&
|
||||
((enable && !GetCaret()->IsVisible()) ||
|
||||
(!enable && GetCaret()->IsVisible())))
|
||||
ShowCaret(enable);
|
||||
|
||||
return TRUE;
|
||||
@@ -4258,6 +4267,8 @@ void wxTextCtrl::ShowCaret(bool show)
|
||||
caret->Move(GetCaretPosition());
|
||||
|
||||
// and show it there
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user