Ejemplo n.º 1
0
	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();

		
	}
Ejemplo n.º 2
0
	void ScrollPane::paintBackground( const PaintEvent &paintEvent )
	{
		//draw background
		paintEvent.graphics()->drawFilledRectangle(getSizeRectangle(),getBackColor());

		Color  Top = Color(110,110,110);
		Color  Left = Color(110,110,110);
		Color  Bottom = Color(110,110,110);
		Color  Right = Color(110,110,110);


		//top
		paintEvent.graphics()->drawLine(Point(0,1),
			Point(getSize().getWidth(),1),Top);
		//left
		paintEvent.graphics()->drawLine(Point(1,1),
			Point(1,getSize().getHeight()),Left);

		//right
		paintEvent.graphics()->drawLine(Point(getSize().getWidth() ,1),
			Point(getSize().getWidth() ,getSize().getHeight()),Right);

		//bottom
		paintEvent.graphics()->drawLine(Point(0,getSize().getHeight()),
			Point(getSize().getWidth(),getSize().getHeight()),Bottom);
	}
Ejemplo n.º 3
0
	void Button::paintBackground( const PaintEvent &paintEvent )
	{
		Color color = getBackColor();

		switch (getButtonState())
		{
		case HOVERED:
			color = Color((float)(color.getR() + 0.075f), 
				(float)(color.getG() + 0.075f),
				(float)(color.getB() + 0.075f), 
				(float)(color.getA() ));
			break;
		case CLICKED:
			color = Color((float)(color.getR() - 0.075f), 
				(float)(color.getG() - 0.075f),
				(float)(color.getB() - 0.075f), (float)(color.getA() ));
			break;
		default:
			break;
		}

		paintEvent.graphics()->drawFilledRectangle(getSizeRectangle(),color);

		Color shadow = Color(
			color.getR() - 0.2f,
			color.getG() - 0.2f,
			color.getB() - 0.2f);

		Color highlight = Color(
			color.getR() + 0.2f,
			color.getG() + 0.2f,
			color.getB() + 0.2f);

		//top
		paintEvent.graphics()->drawLine(Point(0,1),
			Point(getSize().getWidth(),1),highlight);
		//left
		paintEvent.graphics()->drawLine(Point(1,1),
			Point(1,getSize().getHeight()),highlight);

		//bottom
		paintEvent.graphics()->drawLine(Point(0,getSize().getHeight() ),
			Point(getSize().getWidth(),getSize().getHeight() ),shadow);

		//right
		paintEvent.graphics()->drawLine(Point(getSize().getWidth() ,1),
			Point(getSize().getWidth() ,getSize().getHeight()),shadow);

		//bottom
		paintEvent.graphics()->drawLine(Point(0,getSize().getHeight() - 1 ),
			Point(getSize().getWidth(),getSize().getHeight() - 1 ),shadow);

		//right
		paintEvent.graphics()->drawLine(Point(getSize().getWidth()  - 1,0),
			Point(getSize().getWidth() - 1 ,getSize().getHeight()),shadow);

	}
Ejemplo n.º 4
0
	void TextField::paintBackground( const PaintEvent &paintEvent )
	{
		paintEvent.graphics()->drawFilledRectangle(getSizeRectangle(),getBackColor());

		Color  Top = Color(171,171,171);
		Color  Left = Color(227,227,227);
		Color  Bottom = Color(231,231,231);
		Color  Right = Color(222,222,222);


		if(isFocused())
		{
			Top = Color(63,123,173);
			Left = Color(181,207,231);
			Bottom = Color(183,217,237);
			Right = Color(164,201,227);
		}



		//top
		paintEvent.graphics()->drawLine(Point(0,1),
			Point(getSize().getWidth(),1),Top);

		//left
		paintEvent.graphics()->drawLine(Point(1,1),
			Point(1,getSize().getHeight()),Left);

		//right
		paintEvent.graphics()->drawLine(Point(getSize().getWidth() ,1),
			Point(getSize().getWidth() ,getSize().getHeight()),Right);

		//bottom
		paintEvent.graphics()->drawLine(Point(0,getSize().getHeight()),
			Point(getSize().getWidth(),getSize().getHeight()),Bottom);
	}
Ejemplo n.º 5
0
	void HScrollBar::paintBackground( const PaintEvent &paintEvent )
	{
		paintEvent.graphics()->drawFilledRectangle(getSizeRectangle(),
			getBackColor());

	}
Ejemplo n.º 6
0
	void EmptyWidget::paintBackground( const PaintEvent &paintEvent )
	{
		if(getBackColor().getA() > 0.0f)
		paintEvent.graphics()->drawFilledRectangle(getSizeRectangle(),getBackColor());
	}
Ejemplo n.º 7
0
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++;

    }
}