void TextPopup::show(const int x, const int y, const std::string &str1, const std::string &str2, const std::string &str3) { mText[0]->setCaption(str1); mText[1]->setCaption(str2); mText[2]->setCaption(str3); int minWidth = 0; for (int f = 0; f < TEXTPOPUPCOUNT; f ++) { Label *const label = mText[f]; label->adjustSize(); const int width = label->getWidth(); if (width > minWidth) minWidth = width; } const int pad2 = 2 * mPadding; minWidth += pad2; setWidth(minWidth); int cnt = 1; if (!str2.empty()) cnt ++; if (!str3.empty()) cnt ++; setHeight(pad2 + mText[0]->getFont()->getHeight() * cnt); const int distance = 20; const Rect &rect = mDimension; int posX = std::max(0, x - rect.width / 2); int posY = y + distance; if (posX + rect.width > mainGraphics->mWidth) posX = mainGraphics->mWidth - rect.width; if (posY + rect.height > mainGraphics->mHeight) posY = y - rect.height - distance; setPosition(posX, posY); setVisible(true); requestMoveToTop(); }
void CreatureImplementation::loadTemplateDataForBaby(CreatureTemplate* templateData) { loadTemplateData(templateData); setCustomObjectName(getDisplayedName() + " (baby)", false); setHeight(templateData->getScale() * 0.46, false); int newLevel = level / 10; if (newLevel < 1) newLevel = 1; setLevel(newLevel, false); setBaby(true); clearPvpStatusBit(CreatureFlag::AGGRESSIVE, false); clearPvpStatusBit(CreatureFlag::ENEMY, false); setCreatureBitmask(getCreatureBitmask() + CreatureFlag::BABY); }
VOID JCDisplayObject::setTexture(IDirect3DTexture9* texture) { m_lpTexture = texture; initVertexBuffer(); if(m_lpTexture != NULL) { D3DSURFACE_DESC dest; m_lpTexture->GetLevelDesc(0, &dest); m_widthOriginal = (FLOAT)dest.Width; m_heightOriginal = (FLOAT)dest.Height; } else { m_widthOriginal = 0.0f; m_heightOriginal = 0.0f; setWidth(0.0f); setHeight(0.0f); } }
void CurrentRecord::setRecord(QStringList header, QStringList record) { clearList(); // Make listView generic control function. QStandardItemModel *headModel = new QStandardItemModel(0); for (int i = 0; i < header.size(); ++i) { QStandardItem *item; item = new QStandardItem(header.at(i)); headModel->appendRow(item); } ui->headerView->setModel(headModel); ui->listWidget->insertItems(0,record); ui->hbox->setAlignment(Qt::AlignLeft); ui->vbox->setAlignment(Qt::AlignLeft); setWidth(header,record); setHeight(header.size(),record.size()); this->layout()->setAlignment(this,Qt::AlignLeft); this->adjustSize(); }
void RenderReplaced::layout() { StackStats::LayoutCheckPoint layoutCheckPoint; ASSERT(needsLayout()); LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); setHeight(minimumReplacedHeight()); updateLogicalWidth(); updateLogicalHeight(); m_overflow.clear(); addVisualEffectOverflow(); updateLayerTransform(); repainter.repaintAfterLayout(); setNeedsLayout(false); }
void Document::init() { if (m_doc) { delete m_doc; } QList<BackendPage *> backends; m_doc = m_loader->releaseBackend(backends); if (!m_doc) { return; } qreal width = 0; qreal height = 0; int pages = backends.size(); for (int x = 0; x < pages; x++) { BackendPage *backend = backends[x]; DocumentPage *page = new DocumentPage(backend, x, QPointF(0, height), this); m_pages << page; QSizeF size = page->size(); qreal rectWidth = size.width(); qreal rectHeight = size.height(); width = qMax(width, rectWidth); height += rectHeight; } backends.clear(); qDebug() << "width" << width << "height" << height; setWidth(width); setHeight(height); setState(Document::Loaded); stopLoader(); emit pageCountChanged(); }
void GeometryTerrain::loadHeightmapFromFile(const std::string& filename) { std::fstream terrain_file (filename.c_str(), std::ios::in | std::ios::binary); data t_data; for(int z = 0; z < GetLength(); z++) { for(int x = 0; x < GetWidth(); x++) { terrain_file.read((char*)&t_data, sizeof (data)); setHeight(x, z, t_data.height); } } terrain_file.close(); m_pVertices = new flx_Vertex[m_nVertexCount]; m_pTexCoords = new flx_TexCoord[m_nVertexCount]; m_pNormals = new flx_Normal[m_nVertexCount]; for(int z = 0; z <= GetLength(); z++) { for(int x = 0; x <= GetWidth(); x++) { //fill Vertex array with data m_pVertices[x + z * (GetWidth()+1)].x = (float)x; m_pVertices[x + z * (GetWidth()+1)].y = getHeight(x, z); m_pVertices[x + z * (GetWidth()+1)].z = (float)z; //fill TexCoord array with data m_pTexCoords[x + z * (GetWidth()+1)].u = (float)((float)x/(GetWidth()+1)); m_pTexCoords[x + z * (GetWidth()+1)].v = (float)((float)z/(GetWidth()+1)); } } //Let's compute the normals for each vertex computeNormals(); buildPatches(1); }
void TextLabel::calculateTextSize() { int tmp; prepareGeometryChange(); QFontMetrics fm(font); lineHeight = fm.height(); textSize.setWidth(0); textSize.setHeight(lineHeight * value.count()); QStringList::Iterator it = value.begin(); while (it != value.end()) { tmp = fm.width(*it); if (tmp > textSize.width()) textSize.setWidth(tmp); ++it; } if ((getWidth() <= 0) || !m_sizeGiven) { setWidth(textSize.width()); } if ((getHeight() <= 0) || !m_sizeGiven) { setHeight(textSize.height()); } if (!m_sizeGiven) { if (alignment == Qt::AlignLeft) { setX(origPoint.x()); } else if (alignment == Qt::AlignRight) { setX(origPoint.x() - textSize.width()); } else if (alignment == Qt::AlignHCenter) { setX(origPoint.x() - textSize.width() / 2); } } update(); }
FindBar::FindBar() : UIElement() { barBg = new UIRect(30,30); barBg->setAnchorPoint(-1.0, -1.0, 0.0); barBg->color.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiHeaderBgColor")); addChild(barBg); setHeight(30); UILabel *findLabel = new UILabel("FIND", 18, "section"); addChild(findLabel); findLabel->setColor(1.0, 1.0, 1.0, 0.6); findLabel->setPosition(10,3); UILabel *replaceLabel = new UILabel("REPLACE", 18, "section"); addChild(replaceLabel); replaceLabel->setColor(1.0, 1.0, 1.0, 0.6); replaceLabel->setPosition(200,3); processInputEvents = true; findInput = new UITextInput(false, 120, 12); addFocusChild(findInput); findInput->setPosition(60, 4); replaceInput = new UITextInput(false, 120, 12); addFocusChild(replaceInput); replaceInput->setPosition(280, 4); replaceAllButton = new UIButton("Replace All", 100); addFocusChild(replaceAllButton); replaceAllButton->setPosition(420, 3); UIImage *functionIcon = new UIImage("main/function_icon.png", 11, 17); addChild(functionIcon); functionIcon->setPosition(540, 6); functionList = new UIComboBox(globalMenu, 200); addChild(functionList); functionList->setPosition(560, 4); closeButton = new UIImageButton("main/barClose.png", 1.0, 17, 17); addChild(closeButton); }
void Object::load(xml::Xml &xml) { clear(); /* Set attribute defaults */ xml.setDefaultString(""); xml.setDefaultInteger(0); xml.setDefaultFloat(0); /* Attributes ('type' is not forced to be set) */ if(xml.isInteger("x") && xml.isInteger("y")) { name = xml.getString("name"); type = xml.getString("type"); setX(xml.getInteger("x")); setY(xml.getInteger("y")); setWidth(xml.getInteger("width")); setHeight(xml.getInteger("height")); } else { /* Throw */ throw Exception() << "Missing or wrong typed attribute"; } /* Properties */ if(xml.toSubBlock("properties")) { try { properties.load(xml); } catch(Exception &exception) { xml.toBaseBlock(); throw Exception() << "Error whilst loading properties: " << exception.getDescription(); } xml.toBaseBlock(); } }
Label::Label(string lText, int x_, int y_, int width_, int height_, const Font *font_, bool animation_, float animationSpeed_, int indent_, bool align_) { // Coords setX(x_); setY(y_); // Width / Height setWidth(width_); setHeight(height_); // Texts setText(lText); // Indent setIndent(indent_); // Animation setAnimation(animation_); // Invisible setAnimatonValue(0.0f); if(animation_) { // Speed setAnimationSpeed(animationSpeed_); } else { // Speed setAnimationSpeed(0.0f); } // Align setAlign(align_); // Font Id font = (Font*)font_; // Timer animationTimer = new Timer(animationSpeed_); }
pxError pxOffscreen::init(int32_t width, int32_t height) { term(); pxError e = PX_FAIL; data = (char*) new unsigned char[width * height * 4]; if (data) { setBase(data); setWidth(width); setHeight(height); setStride(width*4); setUpsideDown(false); e = PX_OK; } return e; }
void CComponentType::resize() { int attribsCount = this->getNoOfAttribs(); int newWidth = COMPONENTTYPE_WIDTH; int newHeight = COMPONENTTYPE_HEIGHT; if( attribsCount >= 1 ) { newWidth++; } newHeight += (attribsCount+1)/2; if( getHeight() < newHeight ) setY( getY()-1 ); else if( getHeight() > newHeight ) setY( getY()+1 ); setWidth( newWidth ); setHeight( newHeight ); }
/** * Update the robot values from the blob * * @param b The blob to update our object from. */ void VisualRobot::updateRobot(Blob b) { setLeftTopX(b.getLeftTopX()); setLeftTopY(b.getLeftTopY()); setLeftBottomX(b.getLeftBottomX()); setLeftBottomY(b.getLeftBottomY()); setRightTopX(b.getRightTopX()); setRightTopY(b.getRightTopY()); setRightBottomX(b.getRightBottomX()); setRightBottomY(b.getRightBottomY()); setX(b.getLeftTopX()); setY(b.getLeftTopY()); setWidth(dist(b.getRightTopX(), b.getRightTopY(), b.getLeftTopX(), b.getLeftTopY())); setHeight(dist(b.getLeftTopX(), b.getLeftTopY(), b.getLeftBottomX(), b.getLeftBottomY())); setCenterX(getLeftTopX() + ROUND2(getWidth() / 2)); setCenterY(getRightTopY() + ROUND2(getHeight() / 2)); setDistance(1); }
/** * Applies a rotation in an angle which is specified as the pAngle parameter. Returns 0 if there is no image loaded or if the rotation fails. * Rotation occurs around the center of the image area. Rotated image * retains size and aspect ratio of source image (destination image size is usually bigger), so * that this function should be used when rotating an image by 90°, 180° or 270°. * @param pAngle Rotation angle. */ bool IND_Image::rotate(double pAngle) { //TODO: MAY NEED ACCESS TO FILLCOLOR WHEN ANGLE IS NOT MULTIPLE OF 90 (BIGGER IMAGE AND BACKGROUND FILLED WITH BLACK COLOR, OPAQUE, BY DEFAULT) // No image loaded if (!isImageLoaded()) return false; FIBITMAP *rotated = FreeImage_Rotate(getFreeImageHandle(), pAngle); // rotation can in some rare circumstances return a NULL value (1-bit images, rotation is limited to angles whose value is an integer multiple of 90°) if (rotated == NULL) return false; //Reset image parameters to new freeimage modified one FreeImage_Unload(getFreeImageHandle()); setFreeImageHandle(rotated); setPointer(FreeImage_GetBits(rotated)); setWidth(FreeImage_GetWidth(rotated)); setHeight(FreeImage_GetHeight(rotated)); return true; }
void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) { if (!m_datasource.isEmpty() && !m_field.isEmpty() && m_picture.isNull()){ IDataSource* ds = dataManager->dataSource(m_datasource); if (ds) { QVariant data = ds->data(m_field); if (data.isValid()){ if (data.type()==QVariant::Image){ m_picture = data.value<QImage>(); } else m_picture.loadFromData(data.toByteArray()); } } } if (m_autoSize){ setWidth(m_picture.width()); setHeight(m_picture.height()); } BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight); }
void RenderReplaced::layout() { StackStats::LayoutCheckPoint layoutCheckPoint; ASSERT(needsLayout()); LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); setHeight(minimumReplacedHeight()); updateLogicalWidth(); updateLogicalHeight(); clearOverflow(); addVisualEffectOverflow(); updateLayerTransform(); invalidateBackgroundObscurationStatus(); repainter.repaintAfterLayout(); clearNeedsLayout(); }
AVL* Balance(AVL* root){ if (root != NULL){ if (getHeight(root->lchild) - 1 > getHeight(root->rchild)){ if (getHeight(root->lchild->lchild) > getHeight(root->lchild->rchild)){ root = LL_Rotate(root); } else { root = LR_Rotate(root); } } else if (getHeight(root->rchild) - 1 > getHeight(root->lchild)){ if (getHeight(root->rchild->rchild) > getHeight(root->rchild->lchild)){ root = RR_Rotate(root); } else { root = RL_Rotate(root); } } else { root->height = setHeight(root); } } return root; }
PainterBezier::PainterBezier(QQuickItem *parent) :QQuickPaintedItem (parent) ,m_p1(QPointF(0.f,0.f)) ,m_p2(QPointF(0.f,0.f)) ,m_p3(QPointF(0.f,0.f)) ,m_p4(QPointF(0.f,0.f)) ,m_OutlineColor(Qt::black) ,m_FillColor(QColor(177,189,180)) ,m_OutlineWidth(1.f) ,m_FillWidth(3.f) { setX(0); setY(0); setWidth(1); setHeight(1); setFlag(ItemHasContents, true); //setAntialiasing(true); setRenderTarget(QQuickPaintedItem::FramebufferObject); setSmooth(true); }
void FlowContainer::widgetResized(const gcn::Event &event) { if (getWidth() < mBoxWidth) { setWidth(mBoxWidth); return; } int itemCount = mWidgets.size(); mGridWidth = getWidth() / mBoxWidth; if (mGridWidth < 1) mGridWidth = 1; mGridHeight = itemCount / mGridWidth; if (itemCount % mGridWidth != 0 || mGridHeight < 1) ++mGridHeight; int height = mGridHeight * mBoxHeight; if (getHeight() != height) { setHeight(height); return; } int i = 0; height = 0; for (WidgetList::iterator it = mWidgets.begin(); it != mWidgets.end(); it++) { int x = i % mGridWidth * mBoxWidth; (*it)->setPosition(x, height); i++; if (i % mGridWidth == 0) height += mBoxHeight; } }
void TableRowElement::layout( const AttributeManager* am ) { Q_UNUSED( am ) // Get the parent table to query width/ height values TableElement* parentTable = static_cast<TableElement*>( parentElement() ); setHeight( parentTable->rowHeight( this ) ); // Get alignment for every table data QList<Align> verticalAlign = alignments( Qt::Vertical ); QList<Align> horizontalAlign = alignments( Qt::Horizontal ); // align the row's entries QPointF origin; qreal hOffset = 0.0; for ( int i = 0; i < m_data.count(); i++ ) { // origin = QPointF(); hOffset = 0.0; if( verticalAlign[ i ] == Bottom ) origin.setY( height() - m_data[ i ]->height() ); else if( verticalAlign[ i ] == Center || verticalAlign[ i ] == BaseLine ) origin.setY( ( height() - m_data[ i ]->height() ) / 2 ); // Baseline is treated like Center for the moment until someone also refines // TableElement::determineDimensions so that it pays attention to baseline. // Axis as alignment option is ignored as it is tought to be an option for // the table itsself. // kDebug() << horizontalAlign[ i ]<<","<<Axis; if( horizontalAlign[ i ] == Center ) { hOffset = ( parentTable->columnWidth( i ) - m_data[ i ]->width() ) / 2; } else if( horizontalAlign[ i ] == Right ) { hOffset = parentTable->columnWidth( i ) - m_data[ i ]->width(); } m_data[ i ]->setOrigin( origin + QPointF( hOffset, 0.0 ) ); origin += QPointF( parentTable->columnWidth( i ), 0.0 ); } setWidth( origin.x() ); // setting of the baseline should not be needed as the table row will only occur // inside a table where it does not matter if a table row has a baseline or not }
void TextPopup::show(int x, int y, const std::string &str1, const std::string &str2, const std::string &str3) { mText1->setCaption(str1); mText1->adjustSize(); mText2->setCaption(str2); mText2->adjustSize(); mText3->setCaption(str3); mText3->adjustSize(); int minWidth = mText1->getWidth(); if (mText2->getWidth() > minWidth) minWidth = mText2->getWidth(); if (mText3->getWidth() > minWidth) minWidth = mText3->getWidth(); minWidth += 4 * getPadding(); setWidth(minWidth); int cnt = 1; if (!str2.empty()) cnt ++; if (!str3.empty()) cnt ++; setHeight((2 * getPadding() + mText1->getFont()->getHeight()) * cnt); const int distance = 20; int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; if (posX + getWidth() > mainGraphics->mWidth) posX = mainGraphics->mWidth - getWidth(); if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); setVisible(true); requestMoveToTop(); }
void RenderFrameSet::layout() { ASSERT(needsLayout()); bool doFullRepaint = selfNeedsLayout() && checkForRepaintDuringLayout(); IntRect oldBounds; if (doFullRepaint) oldBounds = absoluteClippedOverflowRect(); if (!parent()->isFrameSet() && !document()->printing()) { setWidth(view()->viewWidth()); setHeight(view()->viewHeight()); } size_t cols = frameSet()->totalCols(); size_t rows = frameSet()->totalRows(); if (m_rows.m_sizes.size() != rows || m_cols.m_sizes.size() != cols) { m_rows.resize(rows); m_cols.resize(cols); } int borderThickness = frameSet()->border(); layOutAxis(m_rows, frameSet()->rowLengths(), height() - (rows - 1) * borderThickness); layOutAxis(m_cols, frameSet()->colLengths(), width() - (cols - 1) * borderThickness); positionFrames(); RenderBox::layout(); computeEdgeInfo(); if (doFullRepaint) { view()->repaintViewRectangle(oldBounds); IntRect newBounds = absoluteClippedOverflowRect(); if (newBounds != oldBounds) view()->repaintViewRectangle(newBounds); } setNeedsLayout(false); }
void MsScoreView::setScore(Score* s) { _currentPage = 0; score = s; if (score) { score->doLayout(); Page* page = score->pages()[_currentPage]; QRectF pr(page->abbox()); qreal m1 = width() / pr.width(); qreal m2 = height() / pr.height(); mag = qMax(m1, m2); _boundingRect = QRectF(0.0, 0.0, pr.width() * mag, pr.height() * mag); setWidth(pr.width() * mag); setHeight(pr.height() * mag); } update(); }
void RenderReplaced::layout() { ASSERT(needsLayout()); LayoutRect oldContentRect = replacedContentRect(); setHeight(minimumReplacedHeight()); updateLogicalWidth(); updateLogicalHeight(); m_overflow.clear(); addVisualEffectOverflow(); updateLayerTransformAfterLayout(); invalidateBackgroundObscurationStatus(); clearNeedsLayout(); if (replacedContentRect() != oldContentRect) setShouldDoFullPaintInvalidation(); }
void GuiTable::recomputeDimensions() { int rows_nr = mModel->getRows(); int columns_nr = mModel->getColumns(); int width = 0; int height = 0; if (mSelectedRow >= rows_nr) mSelectedRow = rows_nr - 1; if (mSelectedColumn >= columns_nr) mSelectedColumn = columns_nr - 1; for (int i = 0; i < columns_nr; i++) width += getColumnWidth(i); height = getRowHeight() * rows_nr; setWidth(width); setHeight(height); }
/** * Update the robot values from the blob * * @param b The blob to update our object from. */ void VisualCross::updateCross(Blob *b) { setLeftTopX(b->getLeftTopX()); setLeftTopY(b->getLeftTopY()); setLeftBottomX(b->getLeftBottomX()); setLeftBottomY(b->getLeftBottomY()); setRightTopX(b->getRightTopX()); setRightTopY(b->getRightTopY()); setRightBottomX(b->getRightBottomX()); setRightBottomY(b->getRightBottomY()); setX(b->getLeftTopX()); setY(b->getLeftTopY()); setWidth(dist(b->getRightTopX(), b->getRightTopY(), b->getLeftTopX(), b->getLeftTopY())); setHeight(dist(b->getLeftTopX(), b->getLeftTopY(), b->getLeftBottomX(), b->getLeftBottomY())); setCenterX(getLeftTopX() + ROUND2(getWidth() / 2)); setCenterY(getRightTopY() + ROUND2(getHeight() / 2)); setDistance(1); setPossibleCrosses(&ConcreteCross::abstractCrossList); }
CComponentType::CComponentType( const CPerspective& owner ) : color( COMPONENTTYPE_DEF_RED, COMPONENTTYPE_DEF_GREEN, COMPONENTTYPE_DEF_BLUE ), owner( owner ) { setWidth( COMPONENTTYPE_WIDTH ); setHeight( COMPONENTTYPE_HEIGHT ); // Init optional component type attributes hasPriority = false; priority = 1; hasFrequency = false; frequency = 1; hasNecessity = false; necessity = 1; hasTime = false; time = 1; hasCycle = false; cycle = 1; // Initialize the draw factor (used for scaling of component types in simulation) drawFactor = 1.0; }
void RenderSVGImage::layout() { ASSERT(needsLayout()); LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); SVGImageElement* image = static_cast<SVGImageElement*>(node()); m_localTransform = image->animatedLocalTransform(); // minimum height setHeight(errorOccurred() ? intrinsicSize().height() : 0); calcWidth(); calcHeight(); m_localBounds = FloatRect(image->x().value(image), image->y().value(image), image->width().value(image), image->height().value(image)); repainter.repaintAfterLayout(); setNeedsLayout(false); }
void ItemContainer::recalculateHeight() { int numOfItems = 0; for (int i = 0; i < mInventory->getSize(); i++) { Item *item = mInventory->getItem(i); if (!item || item->getQuantity() <= 0 || !passesFilter(item)) continue; numOfItems++; } const int cols = std::max(1, getWidth() / gridWidth); const int rows = (numOfItems / cols) + (numOfItems % cols > 0 ? 1 : 0); const int height = rows * gridHeight + 8; if (height != getHeight()) setHeight(height); }