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
wxCaretSuspend(wxWindow *win)
{
m_caret = win->GetCaret();
wxCaretSuspend(wxWindow *win)
{
m_caret = win->GetCaret();
+ m_show = FALSE;
+ if ( m_caret && m_caret->IsVisible() )
+ {
+ if ( m_caret && m_show )
m_caret->Show();
}
private:
wxCaret *m_caret;
m_caret->Show();
}
private:
wxCaret *m_caret;
DECLARE_NO_COPY_CLASS(wxCaretSuspend)
};
DECLARE_NO_COPY_CLASS(wxCaretSuspend)
};
}
// ----------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
void wxScrollBar::OnInternalIdle()
{
UpdateThumb();
void wxScrollBar::OnInternalIdle()
{
UpdateThumb();
+ wxControl::OnInternalIdle();
}
void wxScrollBar::UpdateThumb()
}
void wxScrollBar::UpdateThumb()
CreateInputHandler(wxINP_HANDLER_TEXTCTRL);
CreateInputHandler(wxINP_HANDLER_TEXTCTRL);
+ wxSizeEvent sizeEvent(GetSize(), GetId());
+ GetEventHandler()->ProcessEvent(sizeEvent);
+
// pos may be -1 to show the current position
void wxTextCtrl::ShowPosition(wxTextPos pos)
{
// pos may be -1 to show the current position
void wxTextCtrl::ShowPosition(wxTextPos pos)
{
+ bool showCaret = GetCaret() && GetCaret()->IsVisible();
+ if (showCaret)
+ HideCaret();
}
//else: multiline but no scrollbars, hence nothing to do
}
//else: multiline but no scrollbars, hence nothing to do
+ if (showCaret)
+ ShowCaret();
}
// ----------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
// show caret first time only: we must show it after drawing the text or
// the display can be corrupted when it's hidden
// 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) )
if ( !wxTextCtrlBase::Enable(enable) )
return FALSE;
if ( !wxTextCtrlBase::Enable(enable) )
return FALSE;
+ if (FindFocus() == this && GetCaret() &&
+ ((enable && !GetCaret()->IsVisible()) ||
+ (!enable && GetCaret()->IsVisible())))
+ ShowCaret(enable);
caret->Move(GetCaretPosition());
// and show it there
caret->Move(GetCaretPosition());
// and show it there
+ if ((show && !caret->IsVisible()) ||
+ (!show && caret->IsVisible()))
+ caret->Show(show);
bool
wxStdTextCtrlInputHandler::HandleFocus(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();
{
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;
}
// never refresh entirely
return FALSE;
}