void ScrollPane::setSize( const Dimension &size ) { Widget::setSize(size); updateScrollBars(); pChildContent->setSize(Dimension(getContentWidth(),getContentHeight())); }
void ScrollPane::add( Widget *widget ) { pChildContent->add(widget); pChildContent->setSize(Dimension(getContentWidth(),getContentHeight())); updateScrollBars(); }
void ItemHttpMsg::resizeEvent(QResizeEvent *e) { ItemMsgBase::resizeEvent(e); int h = getContentHeight(width()); if (h > height()) ((QListWidgetItem*)_userData)->setSizeHint(QSize(e->size().width(), h)); }
void ScrollPane::sizeChanged( Widget* source, const Dimension &size ) { (void)source; (void)size; updateScrollBars(); if(source != pChildContent) pChildContent->setSize(Dimension(getContentWidth(),getContentHeight())); }
void ScrollPane::locationChanged( Widget* source, const Point &location ) { (void)source; (void)location; if(source != pChildContent) updateScrollBars(); if(source != pChildContent) pChildContent->setSize(Dimension(getContentWidth(),getContentHeight())); }
bool ScrollPane::isVScrollNeeded() const { if(getVScrollPolicy() == SHOW_NEVER) { return false; } if(getContentHeight() > getSize().getHeight()) { return true; } else if(getHScrollPolicy() != SHOW_NEVER && (getContentWidth() > getSize().getWidth() && getContentHeight() > (getSize().getHeight() - pChildHScroll->getHeight() ))) { return true; } return false; }
void ScrollPane::remove( Widget *widget ) { if(widget) { widget->removeMouseListener(this); widget->removeKeyboardListener(this); widget->removeWidgetListener(this); } pChildContent->remove(widget); pChildContent->setSize(Dimension(getContentWidth(),getContentHeight())); updateScrollBars(); }
void ScrollPane::resizeHeightToContents() { int hscroll = 0; if(getHScrollPolicy() == SHOW_ALWAYS) { hscroll = pChildHScroll->getWidth(); } setSize(getWidth(), getMargin(SIDE_TOP) + getMargin(SIDE_BOTTOM) + getContentHeight() + hscroll ); }
void ItemImageMsg::resizeEvent(QResizeEvent *e) { ItemMsgBase::resizeEvent(e); int h = getContentHeight(width()); if (h > height()) ((QListWidgetItem*)_userData)->setSizeHint(QSize(e->size().width(), h)); if (_move) { if (_bImageError) { delete _move; _move = nullptr; } else { _move->start(); anim::start(this); } } }
void ScrollPane::adjustSBRanges() { int extraH = 0; int extraV = 0; if(pChildHScroll->isVisible()) { extraH += pChildHScroll->getHeight(); } if(pChildVScroll->isVisible()) { extraV += pChildVScroll->getWidth(); } //set vertical value pChildVScroll->setRangeFromPage(getInnerSize().getHeight() - extraH,getContentHeight()); //set horizontal value pChildHScroll->setRangeFromPage(getInnerSize().getWidth() - extraV,getContentWidth()); }
void WidgetContainer::render() { auto offsetTop = getOffsetTop() + getCoordY(style.margin.top); auto offsetLeft = getOffsetLeft() + getCoordX(style.margin.left); // Preparing vertex input auto x1 = -1.0 + 2 * (offsetLeft); auto x2 = -1.0 + 2 * (offsetLeft + getPaddingWidth()); auto y1 = +1.0 - 2 * (offsetTop + getPaddingHeight()); auto y2 = +1.0 - 2 * (offsetTop); auto& V0 = input.vertex[0]; auto& V1 = input.vertex[1]; auto& V2 = input.vertex[2]; auto& V3 = input.vertex[3]; V0.position[0] = V1.position[0] = x1; V2.position[0] = V3.position[0] = x2; V0.position[1] = V2.position[1] = y1; V1.position[1] = V3.position[1] = y2; V0.position[2] = V1.position[2] = V2.position[2] = V3.position[2] = 0.0; V0.position[3] = V1.position[3] = V2.position[3] = V3.position[3] = 1.0; V0.background = style.background; V1.background = style.background; V2.background = style.background; V3.background = style.background; manager->pushWidgetContainer(input); auto childOffsetTop = offsetTop + getCoordY(style.padding.top); auto childOffsetLeft = offsetLeft + getCoordX(style.padding.left); // Render children widgets vertically if (layout == LAYOUT_VERTICAL) { if (style.alignV == ALIGN_VERTICAL_CENTER) { childOffsetTop += (vertHeight - compHeight) / 2.0; } if (style.alignV == ALIGN_VERTICAL_BOTTOM) { childOffsetTop += (vertHeight - compHeight); } for (auto& child : children) { // Correct horizontal alignment switch (style.alignH) { case ALIGN_HORIZONTAL_LEFT: child->setOffsetLeft(childOffsetLeft); break; case ALIGN_HORIZONTAL_CENTER: child->setOffsetLeft(childOffsetLeft + (getContentWidth() - child->getBorderWidth()) / 2.0); break; case ALIGN_HORIZONTAL_RIGHT: child->setOffsetLeft(childOffsetLeft + (getContentWidth() - child->getBorderWidth())); break; } child->setOffsetTop(childOffsetTop); child->render(); childOffsetTop += child->getMarginHeight(); } } // Render children widgets horizontally if (layout == LAYOUT_HORIZONTAL) { if (style.alignH == ALIGN_HORIZONTAL_CENTER) { childOffsetLeft += (vertWidth - compWidth) / 2.0; } if (style.alignH == ALIGN_HORIZONTAL_RIGHT) { childOffsetLeft += (vertWidth - compWidth); } for (auto& child : children) { // Correct vertical alignment switch (style.alignV) { case ALIGN_VERTICAL_TOP: child->setOffsetTop(childOffsetTop); break; case ALIGN_VERTICAL_CENTER: child->setOffsetTop(childOffsetTop + (getContentHeight() - child->getBorderHeight()) / 2.0); break; case ALIGN_VERTICAL_BOTTOM: child->setOffsetTop(childOffsetTop + (getContentHeight() - child->getBorderHeight())); break; } child->setOffsetLeft(childOffsetLeft); child->render(); childOffsetLeft += child->getMarginWidth(); } } }
float Widget::getPaddingHeight() { auto paddingTop = getCoordY(style.padding.top); auto paddingBottom = getCoordY(style.padding.bottom); return getContentHeight() + paddingTop + paddingBottom; }