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(); }
int PriorTrickWidget::alignString( const std::string& text, agui::AlignmentEnum align ) { int w = getFont()->getTextWidth(text); int h = getFont()->getLineHeight(); agui::AreaAlignmentEnum a; if(align == agui::ALIGN_LEFT) a = agui::ALIGN_TOP_LEFT; else if(align == agui::ALIGN_CENTER) a = agui::ALIGN_TOP_CENTER; else a = agui::ALIGN_TOP_RIGHT; return createAlignedPosition(a,getInnerRectangle(), agui::Dimension(w,h)).getX(); }
void RadioButton::positionRadioButton() { radioButtonPosition = createAlignedPosition( getRadioButtonAlignment(),getInnerRectangle(), Dimension(getRadioButtonRadius() * 2, getRadioButtonRadius() * 2)); radioButtonPosition = Point( radioButtonPosition.getX() + (getRadioButtonRadius() ), radioButtonPosition.getY() + (getRadioButtonRadius() )); radioButtonRect = Rectangle(Point( radioButtonPosition.getX() - getRadioButtonRadius(), radioButtonPosition.getY() - getRadioButtonRadius()), Dimension(getRadioButtonRadius() * 2, getRadioButtonRadius() * 2)); }
void RadioButton::resizeCaption() { int x = 0; int y = 0; int sizeX = 0; int sizeY = 0; switch (getRadioButtonAlignment()) { case ALIGN_TOP_LEFT: case ALIGN_MIDDLE_LEFT: case ALIGN_BOTTOM_LEFT: x += getRadioButtonRadius() * 2; x += getSidePadding(); break; case ALIGN_TOP_CENTER: y += getRadioButtonRadius() * 2; break; case ALIGN_BOTTOM_CENTER: sizeY -= getRadioButtonRadius() * 2; break; case ALIGN_TOP_RIGHT: case ALIGN_MIDDLE_RIGHT: case ALIGN_BOTTOM_RIGHT: sizeX -= getRadioButtonRadius() * 2; sizeX += getSidePadding(); x += getSidePadding(); break; default: break; // ALIGN_MIDDLE_CENTER? } sizeX -= x; sizeY -= y; Rectangle areaRect = getInnerRectangle(); sizeX += areaRect.getWidth(); sizeY += areaRect.getHeight(); wordWrapRect = Rectangle(x,y,sizeX,sizeY); }
void PriorTrickWidget::renderCard( agui::AreaAlignmentEnum align, const Card& card, int hgap, int vgap, const agui::PaintEvent& paintEvent ) { int textImageOffset = 1.0f * m_scale; agui::Dimension imgSz = getSuitImgSize(card.getSuit()); int cw = m_rankFont->getTextWidth(card.getShortRankString()); int ch = m_rankFont->getLineHeight(); agui::Image* suitImg = getSuitImage(card.getSuit()); int itemWidth = (imgSz.getWidth() * m_imgScale * m_scale); int itemHeight = (imgSz.getHeight() * m_scale * m_imgScale) > ch ? imgSz.getHeight() * m_scale * m_imgScale : ch; agui::Point startPoint = createAlignedPosition( align,getInnerRectangle(),agui::Dimension(itemWidth,itemHeight)); if(vgap != 0) { startPoint.setX(startPoint.getX() + hgap); } if(hgap > 0) { startPoint.setX(startPoint.getX() + (12.3f * m_scale) + textImageOffset); } int textDiff = ((imgSz.getHeight() * m_scale * m_imgScale) - ch) / 2; paintEvent.graphics()->drawText(agui::Point( startPoint.getX() - cw - textImageOffset, startPoint.getY() + vgap + textDiff), card.getShortRankString().c_str(), card.isRed() ? m_red : m_black,m_rankFont); int imgX = startPoint.getX(); int imgY = startPoint.getY() + vgap; paintEvent.graphics()->drawScaledImage(suitImg,agui::Point(imgX,imgY - (4 * m_imgScale * m_scale)), agui::Point(),agui::Dimension(suitImg->getWidth(),suitImg->getHeight()), agui::Dimension(suitImg->getWidth() * m_scale * m_imgScale, suitImg->getHeight() * m_scale *m_imgScale)); }
void Button::paintComponent( const PaintEvent &paintEvent ) { resizableText.drawTextArea(paintEvent.graphics(),getFont(), getInnerRectangle(),getFontColor(),wrappedText,getTextAlignment()); }