void TextField::paintComponent( const PaintEvent &paintEvent ) { int caretLoc = getCaretLocation(); int textLoc = getTextOffset(); Rectangle sideclip = getInnerRectangle(); sideclip = Rectangle(sideclip.getX() + getLeftPadding() , sideclip.getY() + 2,sideclip.getSize().getWidth() - getLeftPadding() - getRightPadding() + 1, sideclip.getHeight() - 4); if(isReadOnly()) { paintEvent.graphics()->drawFilledRectangle( getSizeRectangle(),frameColor); } else { paintEvent.graphics()->drawFilledRectangle( getSizeRectangle(),getBackColor()); } paintEvent.graphics()->pushClippingRect(sideclip); if(getSelectionStart() != getSelectionEnd() && (isFocused() || !isHidingSelection()) ) { Rectangle selRect = Rectangle( getSelectionLocation(), (getInnerHeight() / 2) - (getFont()->getLineHeight() / 2), getSelectionWidth(), getFont()->getLineHeight()); paintEvent.graphics()->drawFilledRectangle( selRect,getSelectionBackColor()); } paintEvent.graphics()->drawText(Point(textLoc, + ((getInnerSize().getHeight() - getFont()->getLineHeight()) / 2)),getText().c_str(), getFontColor(),getFont()); if(isFocused()) { if(isBlinking()) paintEvent.graphics()->drawLine(Point(caretLoc + 1, ((getInnerSize().getHeight() / 2) + (getFont()->getLineHeight() / 2))), Point(caretLoc + 1, ((getInnerSize().getHeight() / 2) - (getFont()->getLineHeight() / 2))), Color(0,0,0)); } paintEvent.graphics()->popClippingRect(); }
void cVerticalScrollbar::setHandleId(ushort id) { if (handle) { handle->setId(id); handle->update(); handle->setY(getTrackerYFromPos(pos_)); pixelPerStep = qMax<float>(0, (float)getInnerHeight() / (float)getValues()); } }
unsigned int cVerticalScrollbar::getTrackerYFromPos(int pos) { if (pos == (int)min_) { return btnUp->height(); } else if (pos == (int)max_) { return height_ - btnDown->height() - handle->height(); } else { return btnUp->height() + getInnerHeight() * ((pos_ - min_) / qMax<float>(1, max_ - min_)); //return btnUp->height() + (int)ceil(pos * pixelPerStep); } }
/* * * @수정자 : codertimo * @요약 : 블럭이 움직이기 위해서 필요한 좌표 변환 등 * @params : void * @return : void * */ void HugBlock::move(Vec2 position) { //HugBlock 이동 this->setPosition(position); //InnerBlock 이동 this->innerArrange(); //Sidebar 이동 Vec2 sidebar_p; sidebar_p.x = this->getBoundingBox().getMinX() + sideBar->getBoundingBox().size.width/2; sidebar_p.y = this->getBoundingBox().getMinY() - getInnerHeight()/2; CCLOG("%f - %f",this->getBoundingBox().getMinY(),getInnerHeight()/2); this->sideBar->setPosition(sidebar_p); //BottomBar 이동 Vec2 bottombar_p; bottombar_p.x = this->getBoundingBox().getMinX() + bottomBar->getContentSize().width/2; bottombar_p.y = this->getBoundingBox().getMaxY() - this->getheight() + bottombar_height/2; this->bottomBar->setPosition(bottombar_p); }
void cVerticalScrollbar::setUpButtonIds(ushort unpressed, ushort pressed, ushort hover) { if (btnUp) { btnUp->setStateGump(BS_UNPRESSED, unpressed); btnUp->setStateGump(BS_PRESSED, pressed); btnUp->setStateGump(BS_HOVER, hover); setBounds(x_, y_, btnUp->width(), height_); // Set Width before adding another button // Reposition background background->setBounds(0, btnUp->height(), btnUp->width(), height_ - btnUp->height() - btnDown->height()); handle->setY(getTrackerYFromPos(pos_)); pixelPerStep = qMax<float>(0, (float)getInnerHeight() / (float)getValues()); } }
void HugBlock::sidebarRendering() { float height = getInnerHeight(); this->sideBar = DrawNode::create(); Vec2 rectangle[4]; rectangle[0] = Vec2(0, 0); rectangle[1] = Vec2(sidebar_width,0); rectangle[2] = Vec2(sidebar_width,height); rectangle[3] = Vec2(0,height); Color4F white(1, 1, 1, 1); sideBar->drawPolygon(rectangle, 4, white, 1, white); sideBar->setAnchorPoint(Vec2(0.5f, 0.5f)); }
bool ScrollPane::intersectionWithPoint( const Point &p ) const { return Rectangle(getMargin(SIDE_LEFT), getMargin(SIDE_TOP),getInnerWidth(),getInnerHeight()).pointInside(p); }
void FlowLayout::layoutChildren() { int curX = 0; int curY = 0; int highestWidget = 0; int numWidgets = 0; int rlOffset = 0; int btOffset = 0; int numRows = 1; int numOnRow = 0; std::vector<Widget*> curRow; Widget* firstWidget = NULL; int lowestPoint = 0; for(WidgetArray::iterator it = getChildBegin(); it != getChildEnd(); ++it) { if(!(*it)->isVisible() && isFilteringVisibility()) { continue; } if(!firstWidget) { firstWidget = (*it); } if(isResizingRowToWidth()) { (*it)->setSize(getInnerWidth(),(*it)->getHeight()); } if((maxOnRow > 0 && numOnRow >= maxOnRow) || isResizingRowToWidth() || (curX + (*it)->getWidth() > getInnerWidth() && numWidgets > 0 && !singleRow)) { numRows++; numOnRow = 0; curX = 0; curY += highestWidget + getVerticalSpacing(); highestWidget = 0; if(center && !curRow.empty()) { int x1 = curRow[0]->getLocation().getX(); int x2 = curRow.back()->getLocation().getX() + curRow.back()->getWidth(); int w = x2 - x1; int centerOffset = (getInnerWidth() - w) / 2; for(size_t i = 0; i < curRow.size(); ++i) { curRow[i]->setLocation( curRow[i]->getLocation().getX() + centerOffset, curRow[i]->getLocation().getY()); } } curRow.clear(); } numOnRow++; if(!topToBottom) { btOffset = getInnerHeight() - (*it)->getHeight() - (curY + curY); } if(!leftToRight && !center) { rlOffset = getInnerWidth() - (*it)->getWidth() - (curX + curX); } (*it)->setLocation(curX + rlOffset,curY + btOffset); curX += (*it)->getWidth() + getHorizontalSpacing(); numWidgets++; if((*it)->getHeight() > highestWidget) { highestWidget = (*it)->getHeight(); } curRow.push_back((*it)); //find the content height int l = (*it)->getLocation().getY() + (*it)->getHeight(); if(l > lowestPoint) { lowestPoint = l; } } //code duplication, I know :( if(center && !curRow.empty()) { if(alignLastRow && numRows > 1 && firstWidget) { int x1 = curRow[0]->getLocation().getX(); int x2 = firstWidget->getLocation().getX(); int diff = x2 - x1; for(size_t i = 0; i < curRow.size(); ++i) { curRow[i]->setLocation( curRow[i]->getLocation().getX() + diff, curRow[i]->getLocation().getY()); } } else { int x1 = curRow[0]->getLocation().getX(); int x2 = curRow.back()->getLocation().getX() + curRow.back()->getWidth(); int w = x2 - x1; int centerOffset = (getInnerWidth() - w) / 2; for(size_t i = 0; i < curRow.size(); ++i) { curRow[i]->setLocation( curRow[i]->getLocation().getX() + centerOffset, curRow[i]->getLocation().getY()); } } } //set content height contentHSz = lowestPoint + getMargin(SIDE_TOP) + getMargin(SIDE_BOTTOM); }
void cVerticalScrollbar::onChangeBounds(int oldx, int oldy, int oldwidth, int oldheight) { pixelPerStep = qMax<float>(0, (float)getInnerHeight() / (float)getValues()); cContainer::onChangeBounds(oldx, oldy, oldwidth, oldheight); }