Merge branch 'vlistbox-current-accessors' of https://github.com/wsu-cb/wxWidgets

wxVListBox: add GetCurrent()/SetCurrent() accessors.

See #24204.
This commit is contained in:
Vadim Zeitlin 2024-01-22 21:40:40 +01:00
commit 1b4dfc292a
9 changed files with 32 additions and 14 deletions

View file

@ -258,11 +258,6 @@ public:
// as a parameter
wxGLContextAttrs& GetGLCTXAttrs() { return m_GLCTXAttrs; }
#ifdef __WXUNIVERSAL__
// resolve the conflict with wxWindowUniv::SetCurrent()
virtual bool SetCurrent(bool doit) { return wxWindow::SetCurrent(doit); }
#endif
protected:
// override this to implement SetColour() in GL_INDEX_MODE
// (currently only implemented in wxX11)

View file

@ -50,7 +50,7 @@ public:
virtual bool Enable(bool enable = true) override;
virtual bool SetCurrent(bool doit = true) override;
virtual bool WXMakeCurrent(bool doit = true) override;
virtual void Press() override;
virtual void Release() override;

View file

@ -126,7 +126,7 @@ public:
int GetStateFlags() const;
// set the "highlighted" flag and return true if it changed
virtual bool SetCurrent(bool doit = true);
virtual bool WXMakeCurrent(bool doit = true);
#if wxUSE_SCROLLBAR
// get the scrollbar (may be null) for the given orientation

View file

@ -95,6 +95,12 @@ public:
bool IsCurrent() const { return wxVScrolledWindow::IsCurrent(); }
#endif
// get current item
int GetCurrent() const { return m_current; }
// set current item
void SetCurrent(int current) { DoSetCurrent(current); }
// is this item selected?
bool IsSelected(size_t item) const;

View file

@ -183,6 +183,23 @@ public:
*/
bool IsCurrent(size_t item) const;
/**
Get the current item or @c wxNOT_FOUND if there is no
current item.
@since 3.3.0
*/
int GetCurrent() const;
/**
Set the specified item as the current item, if it is wxNOT_FOUND
the current item is unset. The current item will be automatically
scrolled into view if it isn't currently visible.
@since 3.3.0
*/
void SetCurrent(int current);
/**
Returns @true if this item is selected, @false otherwise.
*/

View file

@ -249,7 +249,7 @@ bool wxStdAnyButtonInputHandler::HandleMouseMove(wxInputConsumer *consumer,
m_winHasMouse = false;
// we do have a pressed button, so release it
consumer->GetInputWindow()->SetCurrent(false);
consumer->GetInputWindow()->WXMakeCurrent(false);
consumer->PerformAction(wxACTION_BUTTON_RELEASE);
return true;
@ -263,7 +263,7 @@ bool wxStdAnyButtonInputHandler::HandleMouseMove(wxInputConsumer *consumer,
// we did have a pressed button which we released when leaving the
// window, press it again
consumer->GetInputWindow()->SetCurrent(true);
consumer->GetInputWindow()->WXMakeCurrent(true);
consumer->PerformAction(wxACTION_BUTTON_PRESS);
return true;

View file

@ -106,11 +106,11 @@ bool wxBitmapButton::Enable(bool enable)
return true;
}
bool wxBitmapButton::SetCurrent(bool doit)
bool wxBitmapButton::WXMakeCurrent(bool doit)
{
ChangeBitmap(doit ? GetBitmapFocus() : GetBitmapLabel());
return wxButton::SetCurrent(doit);
return wxButton::WXMakeCurrent(doit);
}
void wxBitmapButton::OnSetFocus(wxFocusEvent& event)

View file

@ -2587,11 +2587,11 @@ bool wxGTKInputHandler::HandleMouseMove(wxInputConsumer *control,
{
if ( event.Entering() )
{
control->GetInputWindow()->SetCurrent(true);
control->GetInputWindow()->WXMakeCurrent(true);
}
else if ( event.Leaving() )
{
control->GetInputWindow()->SetCurrent(false);
control->GetInputWindow()->WXMakeCurrent(false);
}
else
{

View file

@ -557,7 +557,7 @@ bool wxWindow::IsCurrent() const
return m_isCurrent;
}
bool wxWindow::SetCurrent(bool doit)
bool wxWindow::WXMakeCurrent(bool doit)
{
if ( doit == m_isCurrent )
return false;