コード例 #1
0
ファイル: TextField.cpp プロジェクト: arvidsson/Agui
	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();

		
	}
コード例 #2
0
	void PriorTrickWidget::paintComponent( const agui::PaintEvent &paintEvent )
	{
		paintEvent.graphics()->drawText(
			agui::Point(alignString(m_priorTrickText,
			agui::ALIGN_CENTER),0),m_priorTrickText.c_str(),
			getFontColor(),getFont());

		//not interested if too few cards
		if(m_cards.size() < 3)
			return;

		int cutThroatYOffset = 0;
		if(m_cards.size() == 3)
		{
			agui::Dimension heartSz = getSuitImgSize(Card::HEARTS);
			cutThroatYOffset = (heartSz.getHeight() * m_scale * m_imgScale) / 2;
		}

		int newVGap = m_vgap * m_scale;
		int newHGap = m_hgap * m_scale;

		renderCard(agui::ALIGN_BOTTOM_CENTER,m_cards[0],0,-newVGap - cutThroatYOffset,
			paintEvent);
		renderCard(agui::ALIGN_MIDDLE_LEFT,m_cards[1],newHGap,
			(newVGap / 2) - cutThroatYOffset,paintEvent);

		if(m_cards.size() > 3)
		{
			renderCard(agui::ALIGN_TOP_CENTER,m_cards[2],0,
				getFont()->getLineHeight() + (newVGap / 2) - cutThroatYOffset,paintEvent);
		}

		renderCard(agui::ALIGN_MIDDLE_RIGHT,m_cards.back(),-newHGap,
			(newVGap / 2) - cutThroatYOffset,paintEvent);
	}
コード例 #3
0
ファイル: iuiEdit.cpp プロジェクト: ezhangle/atomic
void LabelStyle::draw()
{
    Label *w = static_cast<Label*>(getWidget());
    Rect rect(Position(), w->getSize());
    Color bg = getBGColor();
    TextPosition tpos(rect, getTextHAlign(), getTextVAlign(), getTextHSpacing(), getTextVSpacing());
    //iuiGetRenderer()->drawRect(rect, bg);
    iuiGetRenderer()->drawFont(tpos, getFontColor(), w->getText().c_str(), w->getText().size());
}
コード例 #4
0
ファイル: loganalyser.cpp プロジェクト: bula173/LogAnalyser
/** \brief Show events in main table widged.
 *   Table has to has three columns
 *  \param [in] tableWidget Pointer to main table widged
 *  \param [in] eventConteiner Pointer to EventsContainer
*/
void LogAnalyser::showEventsInMainTableWidged(QTableWidget *tableWidget, const std::shared_ptr<EventsContainer> pEventConteiner)
{

    //() << pEventConteiner->getNumberOfEvents();

    if(tableWidget->columnCount() == 5){
        for(int i = 0; i < pEventConteiner->getNumberOfEvents(); ++i){

           const auto event = pEventConteiner->getEvent(i);
           //qDebug() << event->getType() << event->getFontColor() << event->getBackroundColor();
           tableWidget->setRowCount(i+1);
           tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
           tableWidget->setItem(i, mainColumnMsg, new QTableWidgetItem(event->getMessage()));
           tableWidget->setItem(i, mainColumnPackets, new QTableWidgetItem(event->getPackets()));
           tableWidget->setItem(i, mainColumnType, new QTableWidgetItem(event->getType()));
           tableWidget->setItem(i, mainColumnTimeStamp, new QTableWidgetItem(event->getTimeStamp()));
           tableWidget->setItem(i, mainColumnInfo, new QTableWidgetItem(event->getInfo()));
           tableWidget->item(i,mainColumnMsg)->setTextColor(event->getFontColor());
           tableWidget->item(i,mainColumnPackets)->setTextColor(event->getFontColor());
           tableWidget->item(i,mainColumnType)->setTextColor(event->getFontColor());
           tableWidget->item(i,mainColumnTimeStamp)->setTextColor(event->getFontColor());
           tableWidget->item(i,mainColumnInfo)->setTextColor(event->getFontColor());
           tableWidget->item(i,mainColumnMsg)->setBackgroundColor(event->getBackroundColor());
           tableWidget->item(i,mainColumnPackets)->setBackgroundColor(event->getBackroundColor());
           tableWidget->item(i,mainColumnType)->setBackgroundColor(event->getBackroundColor());
           tableWidget->item(i,mainColumnTimeStamp)->setBackgroundColor(event->getBackroundColor());
           tableWidget->item(i,mainColumnInfo)->setBackgroundColor(event->getBackroundColor());
            //ui->plainTextEdit->insertPlainText(eventConteiner.getEvent(i)->buildXMLEvent());
       }
    } else {
        qDebug() << "Za malo kolumn" << tableWidget->rowCount();
    }

    ui->lineEditTimeFrom->setText(pEventConteiner->getEvent(pEventConteiner->getNumberOfEvents()-1)->getTimeStamp());
    ui->lineEditTimeTo->setText(pEventConteiner->getEvent(0)->getTimeStamp());

}
コード例 #5
0
ファイル: iuiButton.cpp プロジェクト: ezhangle/atomic
void ToggleButtonStyle::draw()
{
    ToggleButton *w = static_cast<ToggleButton*>(getWidget());
    Rect rect(Position(), w->getSize());
    TextPosition tpos(rect, getTextHAlign(), getTextVAlign(), getTextHSpacing(), getTextVSpacing());
    Color bg = getBGColor();
    if(w->isPressing() || w->isPressed()) {
        bg += vec4(0.4f, 0.4f, 0.4f, 0.0f);
    }
    else if(w->isHovered()) {
        bg += vec4(0.2f, 0.2f, 0.2f, 0.0f);
    }
    iuiGetRenderer()->drawRect(rect, bg);
    iuiGetRenderer()->drawOutlineRect(rect, getBorderColor());
    iuiGetRenderer()->drawFont(tpos, getFontColor(), w->getText().c_str(), w->getText().size());
}
コード例 #6
0
ファイル: RadioButton.cpp プロジェクト: jmasterx/Agui
	void RadioButton::paintComponent( const PaintEvent &paintEvent )
	{
		//draw the radio button
		Color checkFillColor = Color(255,255,255);
		if(getRadioButtonState() == CLICKED)
		{
			checkFillColor = Color(50,95,128);
		}
		else if(getRadioButtonState() == HOVERED)
		{
			checkFillColor = Color(200,220,230);
		}

		paintEvent.graphics()->drawFilledCircle(getRadioButtonPosition(),
			(float)getRadioButtonRadius(),checkFillColor);

		//draw the check mark if needed

		switch(getCheckedState())
		{
		case CHECKED:
			for(int i = 2; i < 8; ++i)
			paintEvent.graphics()->drawFilledCircle(getRadioButtonPosition(),
				(float)(getRadioButtonRadius() / i),Color(20,40 * i,200 * i));
		

			break;
		default:
			break;
		}

		if(isFocused())
		{
			paintEvent.graphics()->drawCircle(getRadioButtonPosition(),(float)getRadioButtonRadius(),
				Color(170,170,170));
		}
		else
		{
			paintEvent.graphics()->drawCircle(getRadioButtonPosition(),(float)getRadioButtonRadius(),
				Color(100,100,100));
		}


		//draw text
		textAreaMan.drawTextArea(paintEvent.graphics(),getFont(),getWordWrapRect(),getFontColor(),
			getTextLines(),getTextAlignment());
	}
コード例 #7
0
ファイル: propertylist.cpp プロジェクト: gaoyakun/atom3d
ATOM_ScrollBar* ATOM_PropertyList::setHScrollBar(int raw, const char* name, float min, float max, float pos, float step, int id, unsigned style, int customButtonId)
{
	ATOM_STACK_TRACE(ATOM_PropertyList::setHScrollBar);

	if(ATOM_Widget::AnyId == customButtonId)
	{
		ATOM_ListView::setLabel(0, raw, name, ATOM_Widget::AnyId, style);
	}
	else
	{
		ATOM_ListView::setButton(0, raw, name, customButtonId, style);
	}
	ATOM_ScrollBar* bar = ATOM_ListView::setHScrollBar(1, raw, min, max, pos, step, id, style);
	bar->getSlider()->setFontColor(getFontColor());
	bar->getSlider()->setFont(getFont());
	bar->getSlider()->showText(true);
	return bar;
}
コード例 #8
0
ファイル: iuiEdit.cpp プロジェクト: ezhangle/atomic
void EditboxStyle::draw()
{
    Editbox *w = static_cast<Editbox*>(getWidget());
    Rect rect(Position(), w->getSize());
    TextPosition tpos(rect, getTextHAlign(), getTextVAlign(), getTextHSpacing(), getTextVSpacing());
    Color bg = getBGColor();
    if(w->isFocused()) {
        bg += vec4(0.4f, 0.4f, 0.4f, 0.0f);
    }
    else if(w->isHovered()) {
        bg += vec4(0.2f, 0.2f, 0.2f, 0.0f);
    }
    iuiGetRenderer()->drawRect(rect, bg);
    iuiGetRenderer()->drawOutlineRect(rect, getBorderColor());
    iuiGetRenderer()->drawFont(tpos, getFontColor(), w->getText().c_str(), w->getText().size());
    if(w->isFocused() && ist::GetTick()%1000<500) {
        vec2 tsize = iuiGetRenderer()->computeTextSize(w->getText().c_str(), w->getCursorPos());
        Line l(Position(tsize.x, 0.0f), Position(tsize.x, tsize.y));
        iuiGetRenderer()->drawLine(l, getBorderColor());
    }
}
コード例 #9
0
ファイル: G_SelectButton.cpp プロジェクト: Thr44/Thr44-C-Lib
void G_SelectButton::draw(){//ofEventArgs & args){
	
	ofColor color;
	
	ofEnableAlphaBlending();
	if (isActive()) {
		color = getFillOverColor();
	}else {
		color = getFillColor();
	}
	ofSetColor(color.r, color.g, color.b, color.a);
	ofFill();
	ofBeginShape();
	GeometryUtils::drawRoundRect(x, y, width, height, this->getCornerRadius());
	ofEndShape(true);
	ofDisableAlphaBlending();
	float textWidth=font->stringWidth(this->label);
	float textX=this->x+((this->width-textWidth)*0.5);
	float textY=this->y+(floor(this->height*0.5));
	color = getFontColor();
	ofSetColor(color.r, color.g, color.b, color.a);
	font->drawString(this->label, textX, textY);
	
}
コード例 #10
0
ファイル: edit.cpp プロジェクト: gaoyakun/atom3d
void ATOM_Edit::onPaint (ATOM_WidgetDrawClientEvent *event)
{
	ATOM_STACK_TRACE(ATOM_Edit::onPaint);

	ATOM_GUICanvas* canvas = event->canvas;
	ATOM_WidgetState state = event->state;

	if (_textDirty)
	{
		calcTextLayout ();
		_textDirty = false;
	}

	callParentHandler (event);
	//render select image
	// 绘制前景
	if(_cusorOldPosition != _cusorNewPosition)
	{
		ATOM_GUIImage *image = getValidImage (_frontImageId);
		ATOM_ASSERT(image);
		if(_cursorPosition.x - _cusorOldPosition.x > 0)
		{
			image->draw (event->state, event->canvas, ATOM_Rect2Di(_cusorOldPosition.x, _cursorPosition.y, _cursorPosition.x - _cusorOldPosition.x, _clientRect.size.h));
		}
		else
			image->draw (event->state, event->canvas, ATOM_Rect2Di( _cursorPosition.x , _cursorPosition.y, _cusorOldPosition.x - _cursorPosition.x, _clientRect.size.h));
	}
	// render text
	const char *text = _text->getString();
	if (strcmp (text, ""))
	{
		if(_widgetFontOutLineColor.getByteA())
		{
			canvas->drawTextOutline (_text.get(), _textPosition.x, _textPosition.y, getFontColor(), _widgetFontOutLineColor);
		}
		else
		{
			canvas->drawText (_text.get(), _textPosition.x, _textPosition.y, getFontColor());
		}
	}

	// render cursor
	if(0 == (EDITTYPE_READONLY & _editType))
	{	// 只读的时候,不显示光标
		if (_cursorImageId != ATOM_INVALID_IMAGEID)
		{
			if((getRenderer()->getFocus() == this) && (ATOM_APP->getFrameStamp().currentTick % 1000 < 500))
			{
#if 1
				ATOM_GUIImage *image = getValidImage (_cursorImageId);
#else
				const ATOM_GUIImageList *imagelist = getValidImageList ();
				ATOM_GUIImage *image = imagelist->getImage (_cursorImageId);
#endif
				if (!image)
				{
					image = ATOM_GUIImageList::getDefaultImageList().getImage (ATOM_IMAGEID_WINDOW_BKGROUND);
					ATOM_ASSERT(image);
				}

				image->draw (event->state, event->canvas, ATOM_Rect2Di(_cursorPosition.x, _cursorPosition.y, _cursorWidth, _clientRect.size.h));
			}
		}
	}

	// render default text
	if(0 == (EDITTYPE_READONLY & _editType))
	{	// 只读的时候,不显示默认字体
		if((getRenderer()->getFocus() != this) && !strcmp (_text->getString(), ""))
		{
			const char *textDefault = _textDefault->getString();
			if (strcmp (textDefault, ""))
			{
				if(_widgetFontOutLineColor.getByteA())
				{
					canvas->drawTextOutline (_textDefault.get(), _textDefaultPosition.x, _textDefaultPosition.y, _fontDefualtColor, _widgetFontOutLineColor);
				}
				else
				{
					canvas->drawText (_textDefault.get(), _textDefaultPosition.x, _textDefaultPosition.y, _fontDefualtColor);
				}
			}
		}
	}
}
コード例 #11
0
ファイル: celldata.cpp プロジェクト: gaoyakun/atom3d
void ATOM_CellData::onPaint (ATOM_WidgetDrawClientEvent *event)
{
	ATOM_STACK_TRACE(ATOM_CellData::onPaint);

	ATOM_Rect2Di outRect(ATOM_Point2Di(0, 0), event->canvas->getSize());
	ATOM_Rect2Di inRect(_frameOffset, _frameOffset, outRect.size.w-_frameOffset*2, outRect.size.h-_frameOffset*2);

	bool inCD = (ATOM_INVALID_IMAGEID != _cooldownImageId) && _cooldownMax;

	if (_frameImageId != ATOM_INVALID_IMAGEID)
	{
		ATOM_GUIImage *image = getValidImage (_frameImageId);
		image->draw (event->state, event->canvas, outRect);
	}

	if (_clientImageId != ATOM_INVALID_IMAGEID)
	{
		ATOM_GUIImage *image = getValidImage (_clientImageId);
		if (!image)
		{
			image = ATOM_GUIImageList::getDefaultImageList().getImage (ATOM_IMAGEID_WINDOW_BKGROUND);
			ATOM_ASSERT(image);
		}
		if(_customColor)
		{
			image->draw (event->state, event->canvas, inRect, &_customColor);
		}
		else
		{
			image->draw (event->state, event->canvas, inRect);
		}

	}

	if (!_caption.empty())
	{
		if (_textDirty)
		{
			calcTextLayout ();
			_textDirty = false;
		}

		ATOM_GUICanvas::DrawTextInfo info;
		info.textObject = _text.get();
		info.textString = _text->getString();
		info.font = _text->getFont();
		info.x = _textPosition.x;
		info.y = _textPosition.y;
		info.shadowOffsetX = 0;
		info.shadowOffsetY = 0;
		info.textColor = getFontColor();
		info.outlineColor = _widgetFontOutLineColor;
		info.shadowColor = 0;
		info.underlineColor = _underlineColor;
		info.flags = ATOM_GUICanvas::DRAWTEXT_TEXTOBJECT;
		if(_widgetFontOutLineColor.getByteA())
		{
			info.flags |= ATOM_GUICanvas::DRAWTEXT_OUTLINE;
		}
		if(_underlineColor.getByteA())
		{
			info.flags |= ATOM_GUICanvas::DRAWTEXT_UNDERLINE;
		}
		event->canvas->drawTextEx(&info);
		//event->canvas->drawText (_text.get(), _textPosition.x, _textPosition.y, getFontColor());
	}
	//»æÖÆϱê×ÖÌå
	if (!_subscriptStr.empty())
	{
		if (_subscirptTextDirty)
		{
			calcSubscriptTextLayout();
			_subscirptTextDirty = false;
		}

		ATOM_GUICanvas::DrawTextInfo info;
		info.textObject = _subscriptText.get();
		info.textString = _subscriptText->getString();
		info.font = _subscriptText->getFont();
		info.x = _subscriptTextPosition.x;
		info.y = _subscriptTextPosition.y;
		info.shadowOffsetX = 0;
		info.shadowOffsetY = 0;
		info.textColor = getFontColor();
		info.outlineColor = _widgetFontOutLineColor;
		info.shadowColor = 0;
		info.underlineColor = _underlineColor;
		info.flags = ATOM_GUICanvas::DRAWTEXT_TEXTOBJECT;
		if(_widgetFontOutLineColor.getByteA())
		{
			info.flags |= ATOM_GUICanvas::DRAWTEXT_OUTLINE;
		}
		if(_underlineColor.getByteA())
		{
			info.flags |= ATOM_GUICanvas::DRAWTEXT_UNDERLINE;
		}
		event->canvas->drawTextEx(&info);
		//event->canvas->drawText (_text.get(), _textPosition.x, _textPosition.y, getFontColor());
	}
	//»æÖÆϱêͼƬ
	if(_subscriptImageId != ATOM_INVALID_IMAGEID)
	{
		ATOM_GUIImage *image = getValidImage (_subscriptImageId);
		if(!image)
		{
			image = ATOM_GUIImageList::getDefaultImageList().getImage(ATOM_IMAGEID_WINDOW_BKGROUND);
			ATOM_ASSERT(image);
		}
		image->draw(event->state,event->canvas,ATOM_Rect2Di(inRect.point.x+_subscriptRect.point.x,
			inRect.point.y+_subscriptRect.point.y,_subscriptRect.size.w,_subscriptRect.size.h));
	}

	if (_selectImageId != ATOM_INVALID_IMAGEID)
	{
#if 1
		ATOM_GUIImage *image = getValidImage (_selectImageId);
#else
		const ATOM_GUIImageList *imagelist = getValidImageList ();
		ATOM_GUIImage *image = imagelist->getImage (_selectImageId);
#endif
		if (!image)
		{
			image = ATOM_GUIImageList::getDefaultImageList().getImage (ATOM_IMAGEID_WINDOW_BKGROUND);
			ATOM_ASSERT(image);
		}
		image->draw (event->state, event->canvas, outRect);
	}

	//
	//bool inCD = (ATOM_INVALID_IMAGEID != _cooldownImageId) && _cooldownMax;

	//// »­CELL±³¾°
	//if(cell->_texture.pointer)
	//{
	//	unsigned color = inCD ? 0xFF808080 : 0xFFFFFFFF;
	//	canvas->drawTexturedRectEx(ATOM_Rect2Di(x*(xCellWidth+_xSpace), y*(yCellWidth+_ySpace), xCellWidth, yCellWidth), color, cell->_texture.pointer, cell->_region, false);
	//}
	//else if (_clientImageId != ATOM_INVALID_IMAGEID)
	//{
	//	imageDefault->draw (event->state, event->canvas, ATOM_Rect2Di(x*(xCellWidth+_xSpace), y*(yCellWidth+_ySpace), xCellWidth, yCellWidth));
	//}

	//if(cell->_text.pointer)
	//{
	//	const char* str = cell->_text->getString();
	//	if (strcmp (str, ""))
	//	{
	//		ATOM_FontHandle font = ATOM_GUIFont::getFontHandle (getFont());
	//		int charmargin = ATOM_GUIFont::getFontCharMargin (getFont());
	//		int charset = ATOM_GUIFont::getFontCharSet (getFont());
	//		ATOM_SetCharMargin (charmargin);
	//		int l, t, w, h;
	//		ATOM_CalcStringBounds (font, charset, str, strlen(str), &l, &t, &w, &h);
	//		canvas->drawText (cell->_text.pointer, x*(xCellWidth+_xSpace), y*(yCellWidth+_ySpace)-t, _fontColor);
	//	}
	//}

	// »­CD
	if(inCD)
	{
#if 1
		ATOM_GUIImage *image = getValidImage (_cooldownImageId);
#else
		ATOM_GUIImage* image = getValidImageList()->getImage (_cooldownImageId);
#endif
		if(image)
		{
			ATOM_Texture* texture = image->getTexture(WST_NORMAL);
			if(texture)
			{
				ATOM_CircleDrawer drawer(event->canvas, texture);
				drawer.DrawRemove(inRect, float(_cooldown)/float(_cooldownMax));
			}
		}
#if 0
		char buffer[256];
		sprintf (buffer, "%d", _cooldown);
		event->canvas->drawText (buffer, ATOM_GUIFont::getFontHandle(ATOM_GUIFont::getDefaultFont(10, 0)), 0, 0, 0xFFFFFFFF);
#endif
	}
}
 void CCBControlButton::needsLayout() {
     Label *label = static_cast<Label*>(this->getTitleLabel());
     
     if (label) {
         label->setScale(1);
         label->setOpacity(getTitleOpacityForState(_state));
     }
     
     ControlButton::needsLayout();
     
     Size maxSize(getMaxSize());
     float scale = 1.0f;
     
     if (label) {
         Size labelSize(label->getBoundingBox().size);
         float scaleX = 1.f, scaleY = 1.f;
         if (maxSize.width > 0 && maxSize.width - (this->getHorizontalOrigin() * 2) < labelSize.width) {
             scaleX = (maxSize.width - (this->getHorizontalOrigin() * 2)) / labelSize.width;
         }
         if (maxSize.height > 0 && maxSize.height - (this->getVerticalMargin() * 2) < labelSize.height) {
             scaleY = (maxSize.height - (this->getVerticalMargin() * 2)) / labelSize.height;
         }
         
         if (scaleX > 0.f && scaleY > 0.f) {
             scale = std::min(scaleX, scaleY);
         }
         else {
             scale = std::max(scaleX, scaleY);
         }
         
         label->setScale(scale);
         
         cocos2d::Point position = label->getPosition();
         position.x += this->_shadowOffset.width/2.f;
         position.y += this->_shadowOffset.height/2.f;
         
         label->setPosition(position);
         //DuongNT
         //label->setFontFillColor(getTitleColorForState(_state));
         label->setColor(Color3B(getFontColor()));
     }
     
     if (this->getBackgroundSprite() != NULL)
     {
         cocos2d::Size size = this->getBackgroundSprite()->getContentSize();
         size.width += abs(this->_shadowOffset.width)+this->_shadowBlurRadius*2.f;
         size.height += abs(this->_shadowOffset.height)+this->_shadowBlurRadius*2.f;
         
         if (size.width < this->_preferredSize.width) {
             size.width = this->_preferredSize.width;
         }
         if (size.height < this->_preferredSize.height) {
             size.height = this->_preferredSize.height;
         }
         
         if (maxSize.width > 0.f && size.width > maxSize.width) {
             size.width = maxSize.width;
         }
         
         if (maxSize.height > 0.f && size.height > maxSize.height) {
             size.height = maxSize.height;
         }
         
         this->getBackgroundSprite()->setContentSize(size);
     }
 }
コード例 #13
0
ファイル: Simulation.cpp プロジェクト: GustavoPB/CeCe
void Simulation::draw(render::Context& context)
{
    context.setStencilBuffer(getWorldSize().getWidth().value(), getWorldSize().getHeight().value());

    // Render modules
    m_modules.draw(*this, context);

    // Draw objects
    for (auto& obj : m_objects)
    {
        Assert(obj);
        if (obj->isVisible())
            obj->draw(context);
    }

#if defined(CECE_ENABLE_RENDER) && defined(CECE_ENABLE_BOX2D_PHYSICS) && defined(CECE_ENABLE_BOX2D_PHYSICS_DEBUG)
    if (isDrawPhysics())
        m_world.DrawDebugData();
#endif

#if CONFIG_RENDER_TEXT_ENABLE
    context.disableStencilBuffer();

    if (isSimulationTimeRender())
    {
        if (!m_font)
        {
            m_font.create(context, g_fontData);
            m_font->setSize(getFontSize());
        }

        OutStringStream oss;
        {
            auto time = getTotalTime().value();
            unsigned int seconds = time;
            unsigned int milliseconds = static_cast<unsigned int>(time * 1000) % 1000;

            const unsigned int hours = seconds / (60 * 60);
            seconds %= (60 * 60);
            const unsigned int minutes = seconds / 60;
            seconds %= 60;

            if (hours)
            {
                oss << std::setw(2) << std::setfill('0') << hours << ":";
                oss << std::setw(2) << std::setfill('0') << minutes << ":";
            }
            else if (minutes)
            {
                oss << std::setw(2) << std::setfill('0') << minutes << ":";
            }

            oss << std::setw(2) << std::setfill('0') << seconds << ".";
            oss << std::setw(3) << std::setfill('0') << milliseconds;
        }

        if (hasUnlimitedIterations())
        {
            oss << " (" << getIteration() << " / -)";
        }
        else
        {
            oss << " (" << getIteration() << " / " << getIterations() << ")";
        }

        m_font->draw(context, oss.str(), getFontColor());
    }
#endif
}
コード例 #14
0
	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() ? &regularColor : &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);
		}
	}
コード例 #15
0
ファイル: Button.cpp プロジェクト: arvidsson/Agui
	void Button::paintComponent( const PaintEvent &paintEvent )
	{

		resizableText.drawTextArea(paintEvent.graphics(),getFont(),
			getInnerRectangle(),getFontColor(),wrappedText,getTextAlignment());
	}
コード例 #16
0
ファイル: ListBox.cpp プロジェクト: jmasterx/StemwaterSpades
void ListBox::paintComponent( const agui::PaintEvent &paintEvent )
{
    int itemsSkipped = getVisibleItemStart();

    int hScrollHeight = 0;
    if(m_hScroll->isVisible())
    {
        hScrollHeight = m_hScroll->getHeight();
    }

    int maxitems = getVisibleItemCount();

    int h = getItemHeight() * itemsSkipped;
    int rcount = 0;
    int diff = getItemHeight() - getFont()->getLineHeight();

    agui::Color inverseFont = agui::Color(255,255,255);

    agui::Color* color;
    agui::Point absPos = getAbsolutePosition();
    agui::Rectangle parentRect = m_visbilityWidget ?
                                 m_visbilityWidget->getAbsoluteRectangle() :
                                 getParent()->getAbsoluteRectangle();

    int posX = absPos.getX() + (getInnerWidth() / 2);
    for(agui::ListItem::const_iterator it =
                getItemsBegin() + itemsSkipped ;
            it != getItemsEnd(); ++it)
    {
        if(rcount == maxitems)
        {
            break;
        }

        //if the item cannot be seen in the parent do not render it
        if(parentRect.pointInside(agui::Point(posX,
                                              absPos.getY() + h + getVerticalOffset()))
                || getSizeRectangle().pointInside(agui::Point(posX
                        ,absPos.getY() + getItemHeight() + h + getVerticalOffset()) ))
        {
            if(it->second)
            {
                int vOffset = m_vScroll->isVisible() ? m_vScroll->getWidth() + 1 : 0;
                paintEvent.graphics()->drawNinePatchImage(m_selImage,
                        agui::Point(0,h + getVerticalOffset()),
                        agui::Dimension(getInnerSize().getWidth() - vOffset,getItemHeight()));

                color = &inverseFont;
            }
            else if(itemsSkipped + rcount == getHoverIndex())
            {
                agui::Color highlight = agui::Color(
                                            getFontColor().getR() + 0.12f,
                                            getFontColor().getG() + 0.12f,
                                            getFontColor().getB() + 0.12f);

                color = (agui::Color*)&highlight;
            }
            else
            {
                color = (agui::Color*)&getFontColor();
            }
            paintEvent.graphics()->drawText(agui::Point(getHorizontalOffset() + 4 ,
                                            h + getVerticalOffset() + (diff / 2)),it->first.text.c_str(),*color,
                                            getFont());

        }


        h += getItemHeight();
        rcount++;

    }
}