void TitleBarTheme::CloseIcon::paint(const Component *comp, Graphics &g, int x, int y) const { int spacing = 2; int border = 1; g.setPaint(&foreground); int xbase = x + spacing + border; int ybase = y + spacing + border; g.setLineWidth(2); g.drawLine(xbase, ybase, xbase + getIconWidth() - spacing - spacing - border - border, ybase + getIconHeight() - spacing - spacing - border - border); g.drawLine(xbase + getIconWidth() - spacing - spacing - border - border, ybase, xbase, ybase + getIconHeight() - spacing - spacing - border - border); g.setLineWidth(1); }
void RadioButtonTheme::DefaultIcon::paint(const Component *comp, Graphics &g, int x, int y) const { int spacing = 3; int border = 1; int xbase = x + getIconWidth()/2; int ybase = y + getIconHeight()/2; int radius = getIconWidth() - spacing - spacing - border - border; g.setPaint(&background); g.fillCircle(xbase,ybase,radius); g.setPaint(&foreground); g.fillCircle(xbase,ybase,radius - border); }
void PopUpMenu::paintComponent( const agui::PaintEvent &paintEvent ) { int totalHeight = 0; agui::Color regularColor = agui::Color( getFontColor().getR(),getFontColor().getG(),getFontColor().getB(),getOpacity()); agui::Color disabledColor = agui::Color( getDisabledFontColor().getR(),getDisabledFontColor().getG(), getDisabledFontColor().getB(),getOpacity()); for(int i = 0; i < getLength(); ++i) { int w = 0; agui::PopUpMenuItem* item = getItemAt(i); if(i == getSelectedIndex() && item->getItemType() != agui::PopUpMenuItem::SEPARATOR) { paintEvent.graphics()->drawNinePatchImage( m_highlightImg,agui::Point(0,totalHeight), agui::Dimension(getInnerWidth(),getItemHeight()),getOpacity()); } //draw the icon if(isShowingIcon()) { if(item->getIcon()) { paintEvent.graphics()-> drawImage(item->getIcon(),getIconPosition(i,totalHeight),getOpacity()); } w += getIconWidth(); } if(item->isSeparator()) { paintEvent.graphics()->drawLine( agui::Point(w,totalHeight + (getItemHeight(item) / 2)), agui::Point(getInnerWidth(),totalHeight + (getItemHeight(item) / 2)), agui::Color(90,90,90)); paintEvent.graphics()->drawLine( agui::Point(w,totalHeight + (getItemHeight(item) / 2) + 1), agui::Point(getInnerWidth(),totalHeight + (getItemHeight(item) / 2) + 1), agui::Color(200,200,200)); } w += getStartTextGap(); agui::Color* fontColor = item->isEnabled() ? ®ularColor : &disabledColor; paintEvent.graphics()->drawText(agui::Point(w,getTextCenter() + totalHeight), item->getText().c_str(), *fontColor, getFont()); w+= getMiddleTextGap(); agui::Point shortcutPoint = alignString(item->getShortcutText(),agui::ALIGN_MIDDLE_RIGHT); shortcutPoint.setX(shortcutPoint.getX() - getEndTextGap()); shortcutPoint.setY(getTextCenter() + totalHeight); paintEvent.graphics()->drawText(shortcutPoint, item->getShortcutText().c_str(),*fontColor, getFont()); if(item->isSubMenu()) { paintEvent.graphics()->drawImage(m_subArrowImg, createAlignedPosition(agui::ALIGN_MIDDLE_CENTER, agui::Rectangle(getInnerWidth() - getEndTextGap(), totalHeight,getEndTextGap(),getItemHeight()), agui::Dimension(m_subArrowImg->getWidth(),m_subArrowImg->getHeight())), getOpacity()); } totalHeight += getItemHeight(item); } }