+void eListbox::moveSelectionTo(int index)
+{
+ if (m_content)
+ {
+ m_content->cursorHome();
+ m_content->cursorMove(index);
+ moveSelection(justCheck);
+ }
+}
+
+int eListbox::getCurrentIndex()
+{
+ if (m_content && m_content->cursorValid())
+ return m_content->cursorGet();
+ return 0;
+}
+
+void eListbox::updateScrollBar()
+{
+ if (!m_content || m_scrollbar_mode == showNever )
+ return;
+ int entries = m_content->size();
+ if (m_content_changed)
+ {
+ int width = size().width();
+ int height = size().height();
+ m_content_changed = false;
+ if (entries > m_items_per_page || m_scrollbar_mode == showAlways)
+ {
+ int sbarwidth=width/16;
+ if (sbarwidth < 18)
+ sbarwidth = 18;
+ if (sbarwidth > 22)
+ sbarwidth = 22;
+ m_scrollbar->move(ePoint(width-sbarwidth, 0));
+ m_scrollbar->resize(eSize(sbarwidth, height));
+ m_content->setSize(eSize(width-sbarwidth-5, m_itemheight));
+ m_scrollbar->show();
+ }
+ else
+ {
+ m_content->setSize(eSize(width, m_itemheight));
+ m_scrollbar->hide();
+ }
+ }
+ if (m_items_per_page && entries)
+ {
+ int curVisiblePage = m_top / m_items_per_page;
+ if (m_prev_scrollbar_page != curVisiblePage)
+ {
+ m_prev_scrollbar_page = curVisiblePage;
+ int pages = entries / m_items_per_page;
+ if ((pages*m_items_per_page) < entries)
+ ++pages;
+ int start=(m_top*100)/(pages*m_items_per_page);
+ int vis=(m_items_per_page*100)/(pages*m_items_per_page);
+ if (vis < 3)
+ vis=3;
+ m_scrollbar->setStartEnd(start,start+vis);
+ }
+ }
+}
+