Add wxListBox::GetTopItem() and GetCountPerPage()

Implement these methods for all the major ports, add them to the widgets
sample and documentation.

Closes #17189.
This commit is contained in:
Andreas Falkenhahn
2016-02-06 18:32:13 +01:00
committed by Vadim Zeitlin
parent 256f644861
commit 6a01623a80
13 changed files with 135 additions and 2 deletions

View File

@@ -33,6 +33,15 @@
#include "wx/log.h"
#endif
// the spacing between the lines (in report mode)
static const int LINE_SPACING = 0;
#ifdef __WXGTK__
static const int EXTRA_HEIGHT = 6;
#else
static const int EXTRA_HEIGHT = 4;
#endif
extern WXDLLEXPORT_DATA(const char) wxListBoxNameStr[] = "listBox";
// ============================================================================
@@ -340,4 +349,23 @@ void wxListBoxBase::EnsureVisible(int WXUNUSED(n))
// call SetFirstItem() but this is probably even more stupid)
}
wxCoord wxListBoxBase::GetLineHeight() const
{
wxListBoxBase *self = wxConstCast(this, wxListBoxBase);
wxClientDC dc( self );
dc.SetFont( GetFont() );
wxCoord y;
dc.GetTextExtent(wxT("H"), NULL, &y);
y += EXTRA_HEIGHT;
return y + LINE_SPACING;
}
int wxListBoxBase::GetCountPerPage() const
{
return GetClientSize().y / GetLineHeight();
}
#endif // wxUSE_LISTBOX