#include <lib/actions/action.h>
eListbox::eListbox(eWidget *parent)
- :eWidget(parent), m_prev_scrollbar_page(-1), m_content_changed(false), m_scrollbar(NULL)
+ :eWidget(parent), m_prev_scrollbar_page(-1), m_content_changed(false)
+ , m_scrollbar_mode(showNever), m_scrollbar(NULL)
{
setContent(new eListboxStringContent());
/* refuse to do anything without a valid list. */
if (!m_content)
return;
+
+ /* if our list does not have one entry, don't do anything. */
+ if (!m_items_per_page)
+ return;
/* we need the old top/sel to see what we have to redraw */
int oldtop = m_top;
/* current selection invisible? */
if (m_top + m_items_per_page <= m_content->cursorGet())
{
- m_top = m_content->cursorGet() - m_items_per_page + 1;
+ int rest = m_content->size() % m_items_per_page;
+ if ( rest )
+ m_top = m_content->cursorGet() - rest + 1;
+ else
+ m_top = m_content->cursorGet() - m_items_per_page + 1;
if (m_top < 0)
m_top = 0;
}
invalidate(inv);
}
+
+ if (m_scrollbar_mode != showNever)
+ updateScrollBar();
}
void eListbox::moveSelectionTo(int index)
void eListbox::updateScrollBar()
{
- if (!m_scrollbar)
- return;
int entries = m_content->size();
if ( m_content_changed )
{
gPainter &painter = *(gPainter*)data2;
- if (m_scrollbar_mode != showNever)
- updateScrollBar();
-
m_content->cursorSave();
m_content->cursorMove(m_top - m_selected);
m_content->cursorHome();
m_top = 0;
m_selected = 0;
+ moveSelection(justCheck);
invalidate();
}