/************************************************************************* display required integrated scroll bars according to current state of the list box and update their values. *************************************************************************/ void Listbox::configureScrollbars(void) { Scrollbar* vertScrollbar; Scrollbar* horzScrollbar; try { vertScrollbar = static_cast<Scrollbar*>(WindowManager::getSingleton().getWindow(getName() + "__auto_vscrollbar__")); horzScrollbar = static_cast<Scrollbar*>(WindowManager::getSingleton().getWindow(getName() + "__auto_hscrollbar__")); } catch (UnknownObjectException) { // no scrollbars? Can't configure then! return; } float totalHeight = getTotalItemsHeight(); float widestItem = getWidestItemWidth(); // // First show or hide the scroll bars as needed (or requested) // // show or hide vertical scroll bar as required (or as specified by option) if ((totalHeight > getListRenderArea().getHeight()) || d_forceVertScroll) { vertScrollbar->show(); // show or hide horizontal scroll bar as required (or as specified by option) if ((widestItem > getListRenderArea().getWidth()) || d_forceHorzScroll) { horzScrollbar->show(); } else { horzScrollbar->hide(); } } else { // show or hide horizontal scroll bar as required (or as specified by option) if ((widestItem > getListRenderArea().getWidth()) || d_forceHorzScroll) { horzScrollbar->show(); // show or hide vertical scroll bar as required (or as specified by option) if ((totalHeight > getListRenderArea().getHeight()) || d_forceVertScroll) { vertScrollbar->show(); } else { vertScrollbar->hide(); } } else { vertScrollbar->hide(); horzScrollbar->hide(); } } // // Set up scroll bar values // Rect renderArea(getListRenderArea()); vertScrollbar->setDocumentSize(totalHeight); vertScrollbar->setPageSize(renderArea.getHeight()); vertScrollbar->setStepSize(ceguimax(1.0f, renderArea.getHeight() / 10.0f)); vertScrollbar->setScrollPosition(vertScrollbar->getScrollPosition()); horzScrollbar->setDocumentSize(widestItem); horzScrollbar->setPageSize(renderArea.getWidth()); horzScrollbar->setStepSize(ceguimax(1.0f, renderArea.getWidth() / 10.0f)); horzScrollbar->setScrollPosition(horzScrollbar->getScrollPosition()); }
/************************************************************************* display required integrated scroll bars according to current state of the list box and update their values. *************************************************************************/ void Listbox::configureScrollbars(void) { Scrollbar* vertScrollbar = getVertScrollbar(); Scrollbar* horzScrollbar = getHorzScrollbar(); float totalHeight = getTotalItemsHeight(); float widestItem = getWidestItemWidth(); // // First show or hide the scroll bars as needed (or requested) // // show or hide vertical scroll bar as required (or as specified by option) if ((totalHeight > getListRenderArea().getHeight()) || d_forceVertScroll) { vertScrollbar->show(); // show or hide horizontal scroll bar as required (or as specified by option) if ((widestItem > getListRenderArea().getWidth()) || d_forceHorzScroll) { horzScrollbar->show(); } else { horzScrollbar->hide(); } } else { // show or hide horizontal scroll bar as required (or as specified by option) if ((widestItem > getListRenderArea().getWidth()) || d_forceHorzScroll) { horzScrollbar->show(); // show or hide vertical scroll bar as required (or as specified by option) if ((totalHeight > getListRenderArea().getHeight()) || d_forceVertScroll) { vertScrollbar->show(); } else { vertScrollbar->hide(); } } else { vertScrollbar->hide(); horzScrollbar->hide(); } } // // Set up scroll bar values // Rect renderArea(getListRenderArea()); vertScrollbar->setDocumentSize(totalHeight); vertScrollbar->setPageSize(renderArea.getHeight()); vertScrollbar->setStepSize(ceguimax(1.0f, renderArea.getHeight() / 10.0f)); vertScrollbar->setScrollPosition(vertScrollbar->getScrollPosition()); horzScrollbar->setDocumentSize(widestItem); horzScrollbar->setPageSize(renderArea.getWidth()); horzScrollbar->setStepSize(ceguimax(1.0f, renderArea.getWidth() / 10.0f)); horzScrollbar->setScrollPosition(horzScrollbar->getScrollPosition()); }
/************************************************************************* display required integrated scroll bars according to current state of the tree and update their values. *************************************************************************/ void Tree::configureScrollbars(void) { Rectf renderArea(getTreeRenderArea()); //This is becuase CEGUI IS GAY! and fires events before the item is initialized if(!d_vertScrollbar) d_vertScrollbar = createVertScrollbar("__auto_vscrollbar__"); if(!d_horzScrollbar) d_horzScrollbar = createHorzScrollbar("__auto_hscrollbar__"); float totalHeight = getTotalItemsHeight(); float widestItem = getWidestItemWidth() + 20; // // First show or hide the scroll bars as needed (or requested) // // show or hide vertical scroll bar as required (or as specified by option) if ((totalHeight > renderArea.getHeight()) || d_forceVertScroll) { d_vertScrollbar->show(); renderArea.d_max.d_x -= d_vertScrollbar->getWidth().d_offset + d_vertScrollbar->getXPosition().d_offset; // show or hide horizontal scroll bar as required (or as specified by option) if ((widestItem > renderArea.getWidth()) || d_forceHorzScroll) { d_horzScrollbar->show(); renderArea.d_max.d_y -= d_horzScrollbar->getHeight().d_offset; } else { d_horzScrollbar->hide(); d_horzScrollbar->setScrollPosition(0); } } else { // show or hide horizontal scroll bar as required (or as specified by option) if ((widestItem > renderArea.getWidth()) || d_forceHorzScroll) { d_horzScrollbar->show(); renderArea.d_max.d_y -= d_vertScrollbar->getHeight().d_offset; // show or hide vertical scroll bar as required (or as specified by option) if ((totalHeight > renderArea.getHeight()) || d_forceVertScroll) { d_vertScrollbar->show(); // renderArea.d_right -= d_vertScrollbar->getAbsoluteWidth(); renderArea.d_max.d_x -= d_vertScrollbar->getWidth().d_offset; } else { d_vertScrollbar->hide(); d_vertScrollbar->setScrollPosition(0); } } else { d_vertScrollbar->hide(); d_vertScrollbar->setScrollPosition(0); d_horzScrollbar->hide(); d_horzScrollbar->setScrollPosition(0); } } // // Set up scroll bar values // float itemHeight; if (!d_listItems.empty()) itemHeight = d_listItems[0]->getPixelSize().d_height; else itemHeight = 10; d_vertScrollbar->setDocumentSize(totalHeight); d_vertScrollbar->setPageSize(renderArea.getHeight()); d_vertScrollbar->setStepSize(ceguimax(1.0f, renderArea.getHeight() / itemHeight)); d_vertScrollbar->setScrollPosition(d_vertScrollbar->getScrollPosition()); d_horzScrollbar->setDocumentSize(widestItem + d_vertScrollbar->getWidth().d_offset); // d_horzScrollbar->setDocumentSize(widestItem + d_vertScrollbar->getAbsoluteWidth()); d_horzScrollbar->setPageSize(renderArea.getWidth()); d_horzScrollbar->setStepSize(ceguimax(1.0f, renderArea.getWidth() / HORIZONTAL_STEP_SIZE_DIVISOR)); d_horzScrollbar->setScrollPosition(d_horzScrollbar->getScrollPosition()); }