/************************************************************************* Recaculate all sub window size. *************************************************************************/ void FalagardChatHistory::performWindowLayout(void) { Rect absarea(getTextRenderArea()); std::list< FalagardChatBoard* >::iterator it; float fHeightNow = 0.0f; for(it=m_listChatBoard.begin(); it!=m_listChatBoard.end(); it++) { FalagardChatBoard& child = *(*it); if(child.getText().empty()) continue; float childHeight = child.resizeSelf(absarea.getWidth()); child.setSize(Absolute, Size(absarea.getWidth(), childHeight)); child.setPosition(Absolute, Point(0.0f, fHeightNow-d_vertScrollbar->getScrollPosition())); child.requestRedraw(); fHeightNow += childHeight; //char dbgmsg[128] = {0}; //_snprintf(dbgmsg, 127, "FalagardChatHistory performWindowLayout fHeightNow:%f ScrollPos:%f, child YPos:%f\n", // fHeightNow,d_vertScrollbar->getScrollPosition(),child.getAbsoluteYPosition()); //::OutputDebugString(dbgmsg); } d_totalHeight = fHeightNow + d_extendHeight; configureScrollbars(); }
//----------------------------------------------------------------------------// bool ScrollablePane::handleContentAreaChange(const EventArgs&) { // get updated extents of the content const Rectf contentArea(getScrolledContainer()->getContentArea()); // calculate any change on the top and left edges. const float xChange = contentArea.d_min.d_x - d_contentRect.d_min.d_x; const float yChange = contentArea.d_min.d_y - d_contentRect.d_min.d_y; // store new content extents information d_contentRect = contentArea; configureScrollbars(); // update scrollbar positions (which causes container pane to be moved as needed). Scrollbar* const horzScrollbar = getHorzScrollbar(); horzScrollbar->setScrollPosition(horzScrollbar->getScrollPosition() - xChange); Scrollbar* const vertScrollbar = getVertScrollbar(); vertScrollbar->setScrollPosition(vertScrollbar->getScrollPosition() - yChange); // this call may already have been made if the scroll positions changed. The call // is required here for cases where the top/left 'bias' has changed; in which // case the scroll position notification may or may not have been fired. if (xChange || yChange) updateContainerPosition(); // fire event WindowEventArgs args(this); onContentPaneChanged(args); return true; }
//----------------------------------------------------------------------------// void ScrollablePane::onSized(ElementEventArgs& e) { configureScrollbars(); updateContainerPosition(); Window::onSized(e); ++e.handled; }
void ScrollablePane::onSized(WindowEventArgs& e) { Window::onSized(e); configureScrollbars(); updateContainerPosition(); e.handled = true; }
/************************************************************************* Causes the list box to update it's internal state after changes have been made to one or more attached ListboxItem objects. *************************************************************************/ void Listbox::handleUpdatedItemData(void) { if (d_sorted) resortList(); configureScrollbars(); requestRedraw(); }
/************************************************************************* Causes the list box to update it's internal state after changes have been made to one or more attached ListboxItem objects. *************************************************************************/ void Listbox::handleUpdatedItemData(void) { if (d_sorted) resortList(); configureScrollbars(); invalidate(); }
/************************************************************************* Handler for when we are sized *************************************************************************/ void Listbox::onSized(WindowEventArgs& e) { // base class handling Window::onSized(e); configureScrollbars(); ++e.handled; }
/************************************************************************* Handler for when we are sized *************************************************************************/ void Tree::onSized(ElementEventArgs& e) { // base class handling Window::onSized(e); configureScrollbars(); ++e.handled; }
/************************************************************************* Set whether the horizontal scroll bar should always be shown. *************************************************************************/ void Tree::setShowHorzScrollbar(bool setting) { if (d_forceHorzScroll != setting) { d_forceHorzScroll = setting; configureScrollbars(); WindowEventArgs args(this); onHorzScrollbarModeChanged(args); } }
void ScrollablePane::setShowVertScrollbar(bool setting) { if (d_forceVertScroll != setting) { d_forceVertScroll = setting; configureScrollbars(); WindowEventArgs args(this); onVertScrollbarModeChanged(args); } }
/************************************************************************* Initialise the Window based object ready for use. *************************************************************************/ void Listbox::initialiseComponents(void) { // get the component sub-widgets Scrollbar* vertScrollbar = getVertScrollbar(); Scrollbar* horzScrollbar = getHorzScrollbar(); vertScrollbar->subscribeEvent(Scrollbar::EventScrollPositionChanged, Event::Subscriber(&Listbox::handle_scrollChange, this)); horzScrollbar->subscribeEvent(Scrollbar::EventScrollPositionChanged, Event::Subscriber(&Listbox::handle_scrollChange, this)); configureScrollbars(); performChildWindowLayout(); }
void ScrollablePane::initialise(void) { String widgetName; // create horizontal scrollbar widgetName = d_name + "__auto_hscrollbar__"; d_horzScrollbar = createHorizontalScrollbar(widgetName); // perform consistency checks on what we got back assert(d_horzScrollbar != 0); assert(d_horzScrollbar->getName() == widgetName); // create vertical scrollbar widgetName = d_name + "__auto_vscrollbar__"; d_vertScrollbar = createVerticalScrollbar(widgetName); // perform consistency checks on what we got back assert(d_vertScrollbar != 0); assert(d_vertScrollbar->getName() == widgetName); // create scrolled container widget d_container = static_cast<ScrolledContainer*>(WindowManager::getSingleton().createWindow( ScrolledContainer::WidgetTypeName, d_name + "__auto_container__")); // add child controls addChildWindow(d_horzScrollbar); addChildWindow(d_vertScrollbar); addChildWindow(d_container); // do a bit of initialisation d_horzScrollbar->setAlwaysOnTop(true); d_vertScrollbar->setAlwaysOnTop(true); // container pane is always same size as this parent pane, // scrolling is actually implemented via positioning and clipping tricks. d_container->setSize(Relative, Size(1.0f, 1.0f)); // subscribe to events we need to hear about d_vertScrollbar->subscribeEvent( Scrollbar::EventScrollPositionChanged, Event::Subscriber(&ScrollablePane::handleScrollChange, this)); d_horzScrollbar->subscribeEvent( Scrollbar::EventScrollPositionChanged, Event::Subscriber(&ScrollablePane::handleScrollChange, this)); d_container->subscribeEvent( ScrolledContainer::EventContentChanged, Event::Subscriber(&ScrollablePane::handleContentAreaChange, this)); d_container->subscribeEvent( ScrolledContainer::EventAutoSizeSettingChanged, Event::Subscriber(&ScrollablePane::handleAutoSizePaneChanged, this)); // finalise setup configureScrollbars(); }
/************************************************************************* Initialise the Window based object ready for use. *************************************************************************/ void Listbox::initialise(void) { // create the component sub-widgets d_vertScrollbar = createVertScrollbar(getName() + "__auto_vscrollbar__"); d_horzScrollbar = createHorzScrollbar(getName() + "__auto_hscrollbar__"); addChildWindow(d_vertScrollbar); addChildWindow(d_horzScrollbar); d_vertScrollbar->subscribeEvent(Scrollbar::EventScrollPositionChanged, Event::Subscriber(&Listbox::handle_scrollChange, this)); d_horzScrollbar->subscribeEvent(Scrollbar::EventScrollPositionChanged, Event::Subscriber(&Listbox::handle_scrollChange, this)); configureScrollbars(); performChildWindowLayout(); }
/************************************************************************* Initialise the Window based object ready for use. *************************************************************************/ void Tree::initialise(void) { // get WidgetLookFeel for the assigned look. const WidgetLookFeel &wlf = WidgetLookManager::getSingleton().getWidgetLook(d_lookName); const ImagerySection &tempOpenImagery = wlf.getImagerySection("OpenTreeButton"); const ImagerySection &tempCloseImagery = wlf.getImagerySection("CloseTreeButton"); d_openButtonImagery = &tempOpenImagery; d_closeButtonImagery = &tempCloseImagery; // create the component sub-widgets d_vertScrollbar = createVertScrollbar("__auto_vscrollbar__"); d_horzScrollbar = createHorzScrollbar("__auto_hscrollbar__"); addChild(d_vertScrollbar); addChild(d_horzScrollbar); d_vertScrollbar->subscribeEvent(Scrollbar::EventScrollPositionChanged, Event::Subscriber(&Tree::handle_scrollChange, this)); d_horzScrollbar->subscribeEvent(Scrollbar::EventScrollPositionChanged, Event::Subscriber(&Tree::handle_scrollChange, this)); configureScrollbars(); performChildWindowLayout(); }
//----------------------------------------------------------------------------// void ScrollablePane::initialiseComponents(void) { // get horizontal scrollbar Scrollbar* horzScrollbar = getHorzScrollbar(); // get vertical scrollbar Scrollbar* vertScrollbar = getVertScrollbar(); // get scrolled container widget ScrolledContainer* container = getScrolledContainer(); // do a bit of initialisation horzScrollbar->setAlwaysOnTop(true); vertScrollbar->setAlwaysOnTop(true); // container pane is always same size as this parent pane, // scrolling is actually implemented via positioning and clipping tricks. container->setSize(USize(cegui_reldim(1.0f), cegui_reldim(1.0f))); // subscribe to events we need to hear about vertScrollbar->subscribeEvent( Scrollbar::EventScrollPositionChanged, Event::Subscriber(&ScrollablePane::handleScrollChange, this)); horzScrollbar->subscribeEvent( Scrollbar::EventScrollPositionChanged, Event::Subscriber(&ScrollablePane::handleScrollChange, this)); d_contentChangedConn = container->subscribeEvent( ScrolledContainer::EventContentChanged, Event::Subscriber(&ScrollablePane::handleContentAreaChange, this)); d_autoSizeChangedConn = container->subscribeEvent( ScrolledContainer::EventAutoSizeSettingChanged, Event::Subscriber(&ScrollablePane::handleAutoSizePaneChanged, this)); // finalise setup configureScrollbars(); }
bool ScrollablePane::handleContentAreaChange(const EventArgs& e) { assert(d_container != 0); assert(d_horzScrollbar != 0); assert(d_vertScrollbar != 0); // get updated extents of the content Rect contentArea(d_container->getContentArea()); // calculate any change on the top and left edges. float xChange = contentArea.d_left - d_contentRect.d_left; float yChange = contentArea.d_top - d_contentRect.d_top; // store new content extents information d_contentRect = contentArea; configureScrollbars(); // update scrollbar positions (which causes container pane to be moved as needed). d_horzScrollbar->setScrollPosition(d_horzScrollbar->getScrollPosition() - xChange); d_vertScrollbar->setScrollPosition(d_vertScrollbar->getScrollPosition() - yChange); // this call may already have been made if the scroll positions changed. The call // is required here for cases where the top/left 'bias' has changed; in which // case the scroll position notification may or may not have been fired. if (xChange || yChange) { updateContainerPosition(); } // fire event WindowEventArgs args(this); onContentPaneChanged(args); return true; }
void ScrollablePane::setVerticalOverlapSize(float overlap) { d_vertOverlap = overlap; configureScrollbars(); }
/************************************************************************* Handler called internally when the list contents are changed *************************************************************************/ void Listbox::onListContentsChanged(WindowEventArgs& e) { configureScrollbars(); invalidate(); fireEvent(EventListContentsChanged, e, EventNamespace); }
void ScrollablePane::setHorizontalStepSize(float step) { d_horzStep = step; configureScrollbars(); }
void ScrollablePane::setHorizontalOverlapSize(float overlap) { d_horzOverlap = overlap; configureScrollbars(); }
/************************************************************************* Format the text into lines as needed by the current formatting options. *************************************************************************/ void MultiLineEditbox::formatText(void) { // clear old formatting data d_lines.clear(); d_widestExtent = 0.0f; String paraText; const Font* fnt = getFont(); if (fnt != NULL) { float areaWidth = getTextRenderArea().getWidth(); String::size_type currPos = 0; String::size_type paraLen; LineInfo line; while (currPos < d_text.length()) { if ((paraLen = d_text.find_first_of(d_lineBreakChars, currPos)) == String::npos) { paraLen = d_text.length() - currPos; } else { ++paraLen -= currPos; } paraText = d_text.substr(currPos, paraLen); if (!d_wordWrap || (areaWidth <= 0.0f)) { // no word wrapping, so we are just one long line. line.d_startIdx = currPos; line.d_length = paraLen; line.d_extent = fnt->getTextExtent(paraText); d_lines.push_back(line); // update widest, if needed. if (line.d_extent > d_widestExtent) { d_widestExtent = line.d_extent; } } // must word-wrap the paragraph text else { String::size_type lineIndex = 0; // while there is text in the string while (lineIndex < paraLen) { String::size_type lineLen = 0; float lineExtent = 0.0f; // loop while we have not reached the end of the paragraph string while (lineLen < (paraLen - lineIndex)) { // get cp / char count of next token size_t nextTokenSize = getNextTokenLength(paraText, lineIndex + lineLen); // get pixel width of the token float tokenExtent = fnt->getTextExtent(paraText.substr(lineIndex + lineLen, nextTokenSize)); // would adding this token would overflow the available width if ((lineExtent + tokenExtent) > areaWidth) { // Was this the first token? if (lineLen == 0) { // get point at which to break the token lineLen = fnt->getCharAtPixel(paraText.substr(lineIndex, nextTokenSize), areaWidth); } // text wraps, exit loop early with line info up until wrap point break; } // add this token to current line lineLen += nextTokenSize; lineExtent += tokenExtent; } // set up line info and add to collection line.d_startIdx = currPos + lineIndex; line.d_length = lineLen; line.d_extent = lineExtent; d_lines.push_back(line); // update widest, if needed. if (lineExtent > d_widestExtent) { d_widestExtent = lineExtent; } // update position in string lineIndex += lineLen; } } // skip to next 'paragraph' in text currPos += paraLen; } } configureScrollbars(); requestRedraw(); }
/************************************************************************* Causes the tree to update it's internal state after changes have been made to one or more attached TreeItem objects. *************************************************************************/ void Tree::handleUpdatedItemData(void) { configureScrollbars(); invalidate(); }
/************************************************************************* Handler called internally when the list contents are changed *************************************************************************/ void Listbox::onListContentsChanged(WindowEventArgs& e) { configureScrollbars(); requestRedraw(); fireEvent(EventListContentsChanged, e, EventNamespace); }
void ScrollablePane::setVerticalStepSize(float step) { d_vertStep = step; configureScrollbars(); }
/************************************************************************* Handler for when mouse button is pressed *************************************************************************/ void Tree::onMouseButtonDown(MouseEventArgs& e) { // base class processing // populateGeometryBuffer(); Window::onMouseButtonDown(e); if (e.button == LeftButton) { //bool modified = false; Vector2f localPos(CoordConverter::screenToWindow(*this, e.position)); // Point localPos(screenToWindow(e.position)); TreeItem* item = getItemAtPoint(localPos); if (item != 0) { //modified = true; TreeEventArgs args(this); args.treeItem = item; populateGeometryBuffer(); Rectf buttonLocation = item->getButtonLocation(); if ((localPos.d_x >= buttonLocation.left()) && (localPos.d_x <= buttonLocation.right()) && (localPos.d_y >= buttonLocation.top()) && (localPos.d_y <= buttonLocation.bottom())) { item->toggleIsOpen(); if (item->getIsOpen()) { TreeItem *lastItemInList = item->getTreeItemFromIndex(item->getItemCount() - 1); ensureItemIsVisible(lastItemInList); ensureItemIsVisible(item); onBranchOpened(args); } else { onBranchClosed(args); } // Update the item screen locations, needed to update the scrollbars. // populateGeometryBuffer(); // Opened or closed a tree branch, so must update scrollbars. configureScrollbars(); } else { // clear old selections if no control key is pressed or if multi-select is off if (!(e.sysKeys & Control) || !d_multiselect) clearAllSelections_impl(); // select range or item, depending upon keys and last selected item #if 0 // TODO: fix this if (((e.sysKeys & Shift) && (d_lastSelected != 0)) && d_multiselect) selectRange(getItemIndex(item), getItemIndex(d_lastSelected)); else #endif item->setSelected(item->isSelected() ^ true); // update last selected item d_lastSelected = item->isSelected() ? item : 0; onSelectionChanged(args); } } else { // clear old selections if no control key is pressed or if multi-select is off if (!(e.sysKeys & Control) || !d_multiselect) { if (clearAllSelections_impl()) { // Changes to the selections were actually made TreeEventArgs args(this); args.treeItem = item; onSelectionChanged(args); } } } ++e.handled; } }
/************************************************************************* Causes the list box to update it's internal state after changes have been made to one or more attached ListboxItem objects. *************************************************************************/ void Listbox::handleUpdatedItemData(void) { configureScrollbars(); requestRedraw(); }