//! draws the element and its children
void CGUIProgressBar::draw()
{
  if(!IsVisible) return;
  IGUISkin* skin = Environment->getSkin();
  if(!skin) return;
  irr::video::IVideoDriver* driver = Environment->getVideoDriver();
  if(!driver) return;

  core::rect<s32> FrameRect(AbsoluteRect);
  driver->draw2DRectangle(Background, FrameRect, &AbsoluteClippingRect);

  skin->draw3DSunkenPane(this, Background, true, false, FrameRect, &AbsoluteClippingRect);
  FrameRect.UpperLeftCorner.X += 1;
  FrameRect.UpperLeftCorner.Y += 1;
  FrameRect.LowerRightCorner.X -= 1;
  FrameRect.LowerRightCorner.Y -= 1;

  core::rect<s32> ProgressRect(FrameRect);
  if(Horizontal)
    ProgressRect.LowerRightCorner.X = ProgressRect.UpperLeftCorner.X + (Pos * (FrameRect.LowerRightCorner.X - FrameRect.UpperLeftCorner.X) / Max);
  else
    ProgressRect.UpperLeftCorner.Y = ProgressRect.LowerRightCorner.Y - (Pos * (FrameRect.LowerRightCorner.Y - FrameRect.UpperLeftCorner.Y) / Max);
  driver->draw2DRectangle(Foreground, ProgressRect, &AbsoluteClippingRect);
  IGUIElement::draw();
}
Exemple #2
0
//! draws the element and its children
void CGUIMenu::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();
	IGUIFont* font = skin->getFont(EGDF_MENU);
	
	if (font != LastFont)
	{
		if (LastFont)
			LastFont->drop();
		LastFont = font;
		if (LastFont)
			LastFont->grab();

		recalculateSize();
	}

	core::rect<s32> rect = AbsoluteRect;

	// draw frame

	skin->draw3DToolBar(this, rect, &AbsoluteClippingRect);

	// loop through all menu items

	rect = AbsoluteRect;

	for (s32 i=0; i<(s32)Items.size(); ++i)
	{
		if (!Items[i].IsSeparator)
		{
			rect = getRect(Items[i], AbsoluteRect);

			// draw highlighted
			if (i == HighLighted && Items[i].Enabled)
			{
				skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_DARK_SHADOW),
					true, true, rect, &AbsoluteClippingRect);
			}
			// draw text

			EGUI_DEFAULT_COLOR c = EGDC_BUTTON_TEXT;

			if (i == HighLighted)
				c = EGDC_HIGH_LIGHT_TEXT;

			if (!Items[i].Enabled)
				c = EGDC_GRAY_TEXT;

			if (font)
				font->draw(Items[i].Text.c_str(), rect, 
					skin->getColor(c), true, true, &AbsoluteClippingRect);
		}
	}

	IGUIElement::draw();
}
Exemple #3
0
//! draws the element and its children
void CGUIComboBox::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();

	// font changed while the listbox is open?
	if ( ActiveFont != skin->getFont() && ListBox )
	{
		// close and re-open to use new font-size
		openCloseMenu();
		openCloseMenu();
	}


	IGUIElement *currentFocus = Environment->getFocus();
	if (currentFocus != LastFocus)
	{
		HasFocus = currentFocus == this || isMyChild(currentFocus);
		LastFocus = currentFocus;
	}

	// set colors each time as skin-colors can be changed
	SelectedText->setBackgroundColor(skin->getColor(EGDC_HIGH_LIGHT));
	if(isEnabled())
	{
		SelectedText->setDrawBackground(HasFocus);
		SelectedText->setOverrideColor(skin->getColor(HasFocus ? EGDC_HIGH_LIGHT_TEXT : EGDC_BUTTON_TEXT));
	}
	else
	{
		SelectedText->setDrawBackground(false);
		SelectedText->setOverrideColor(skin->getColor(EGDC_GRAY_TEXT));
	}
	ListButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL));
	ListButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL));


	core::rect<s32> frameRect(AbsoluteRect);

	// draw the border

	skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT),
		true, true, frameRect, &AbsoluteClippingRect);

	// draw children
	IGUIElement::draw();
}
void CGUIPanel::draw()
{
	if (NeedsUpdate)
	{
		calculateClientArea();
		resizeInnerPane();
		NeedsUpdate = false;
	}

	IGUISkin* skin = Environment->getSkin();
	if (Border && skin)
	{
		skin->draw3DSunkenPane( this, skin->getColor( EGDC_APP_WORKSPACE), false, true, AbsoluteRect, &AbsoluteClippingRect );
	}

	IGUIElement::draw();
}
//! draws the element and its children
void CGUICheckBox::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();
	if (skin)
	{
		const core::rect<s32> rect = AbsoluteRect;
		const s32 height = skin->getSize(EGDS_CHECK_BOX_WIDTH);

		core::rect<s32> checkRect(AbsoluteRect.UpperLeftCorner.X,
					((AbsoluteRect.getHeight() - height) / 2) + AbsoluteRect.UpperLeftCorner.Y,
					0, 0);

		checkRect.LowerRightCorner.X = checkRect.UpperLeftCorner.X + height;
		checkRect.LowerRightCorner.Y = checkRect.UpperLeftCorner.Y + height;

		EGUI_DEFAULT_COLOR col = EGDC_GRAY_EDITABLE;
		if ( isEnabled() )
			col = Pressed ? EGDC_FOCUSED_EDITABLE : EGDC_EDITABLE;
		skin->draw3DSunkenPane(this, skin->getColor(col),
			false, true, checkRect, &AbsoluteClippingRect);

		if (Checked)
		{
			skin->drawIcon(this, EGDI_CHECK_BOX_CHECKED, checkRect.getCenter(),
				checkTime, os::Timer::getTime(), false, &AbsoluteClippingRect);
		}
		if (Text.size())
		{
			checkRect = AbsoluteRect;
			checkRect.UpperLeftCorner.X += height + 5;

			IGUIFont* font = skin->getFont();
			if (font)
			{
				font->draw(Text.c_str(), checkRect,
						skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), false, true, &AbsoluteClippingRect);
			}
		}
	}
	IGUIElement::draw();
}
Exemple #6
0
//! draws the element and its children
void CGUIComboBox::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();
	IGUIElement *currentFocus = Environment->getFocus();
	if (currentFocus != LastFocus)
	{
		HasFocus = currentFocus == this || isMyChild(currentFocus);
		LastFocus = currentFocus;
	}

	core::rect<s32> frameRect(AbsoluteRect);

	// draw the border

	skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT),
		true, true, frameRect, &AbsoluteClippingRect);

	// Draw text

	if (Selected != -1)
	{
		frameRect = AbsoluteRect;
		frameRect.UpperLeftCorner.X += 2;
		frameRect.UpperLeftCorner.Y += 2;
		frameRect.LowerRightCorner.X -= ListButton->getAbsolutePosition().getWidth() + 2;
		frameRect.LowerRightCorner.Y -= 2;
		if (HasFocus)
			skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), frameRect, &AbsoluteClippingRect);

		IGUIFont* font = skin->getFont();
		if (font)
			font->draw(Items[Selected].c_str(), frameRect, 
				skin->getColor(HasFocus ? EGDC_HIGH_LIGHT_TEXT : EGDC_BUTTON_TEXT),
				false, true, &AbsoluteClippingRect);
	}

	// draw buttons
	IGUIElement::draw();
}
//! draws the element and its children
void CGUICheckBox::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();

	core::rect<s32> rect = AbsoluteRect;

	s32 height = skin->getSize(EGDS_CHECK_BOX_WIDTH);

	core::rect<s32> checkRect(AbsoluteRect.UpperLeftCorner.X,
				((AbsoluteRect.getHeight() - height) / 2) + AbsoluteRect.UpperLeftCorner.Y,
				0, 0);

	checkRect.LowerRightCorner.X = checkRect.UpperLeftCorner.X + height;
	checkRect.LowerRightCorner.Y = checkRect.UpperLeftCorner.Y + height;

	skin->draw3DSunkenPane(this, skin->getColor(Pressed || !IsEnabled ? EGDC_3D_FACE : EGDC_ACTIVE_CAPTION),
		false, true, checkRect, &AbsoluteClippingRect);

	if (Checked && Environment->getSkin())
		Environment->getSkin()->drawIcon(this, EGDI_CHECK_BOX_CHECKED, checkRect.getCenter(),
			checkTime, os::Timer::getTime(), false, &AbsoluteClippingRect);

	if (Text.size())
	{
		checkRect = AbsoluteRect;
		checkRect.UpperLeftCorner.X += height + 5;

		IGUIFont* font = skin->getFont();
		if (font)
			font->draw(Text.c_str(), checkRect,
					skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), false, true, &AbsoluteClippingRect);
	}

	IGUIElement::draw();
}
Exemple #8
0
//! draws the element and its children
void CGUIComboBox::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();
	IGUIElement *currentFocus = Environment->getFocus();
	if (currentFocus != LastFocus)
	{
		HasFocus = currentFocus == this || isMyChild(currentFocus);
		LastFocus = currentFocus;

		SelectedText->setBackgroundColor(skin->getColor(EGDC_HIGH_LIGHT));

		if(isEnabled())
		{
			SelectedText->setDrawBackground(HasFocus);
			SelectedText->setOverrideColor(skin->getColor(HasFocus ? EGDC_HIGH_LIGHT_TEXT : EGDC_BUTTON_TEXT));
		}
		else
		{
			SelectedText->setDrawBackground(false);
			SelectedText->setOverrideColor(skin->getColor(EGDC_GRAY_TEXT)); 
		}
	}

	core::rect<s32> frameRect(AbsoluteRect);

	// draw the border

	skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT),
		true, true, frameRect, &AbsoluteClippingRect);

	// draw children
	IGUIElement::draw();
}
Exemple #9
0
//! draws the element and its children
void CGUIListBox::draw()
{
	if (!IsVisible)
		return;

	recalculateItemHeight(); // if the font changed

	IGUISkin* skin = Environment->getSkin();
	irr::video::IVideoDriver* driver = Environment->getVideoDriver();

	core::rect<s32>* clipRect = 0;
	if (Clip)
		clipRect = &AbsoluteClippingRect;

	// draw background
	core::rect<s32> frameRect(AbsoluteRect);

	skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), true,
		DrawBack, frameRect, clipRect);
	
	// draw items

	core::rect<s32> clientClip(AbsoluteRect);
	clientClip.UpperLeftCorner.Y += 1;
	clientClip.UpperLeftCorner.X += 1;
	clientClip.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE);
	clientClip.LowerRightCorner.Y -= 1;

	if (clipRect)
		clientClip.clipAgainst(*clipRect);

	frameRect = AbsoluteRect;
	frameRect.UpperLeftCorner.X += 1;
	frameRect.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE);
	frameRect.LowerRightCorner.Y = AbsoluteRect.UpperLeftCorner.Y + ItemHeight;

	frameRect.UpperLeftCorner.Y -= ScrollBar->getPos();
	frameRect.LowerRightCorner.Y -= ScrollBar->getPos();
	

	for (s32 i=0; i<(s32)Items.size(); ++i)
	{
		if (frameRect.LowerRightCorner.Y >= AbsoluteRect.UpperLeftCorner.Y &&
			frameRect.UpperLeftCorner.Y <= AbsoluteRect.LowerRightCorner.Y)
		{
			if (i == Selected)
				driver->draw2DRectangle(skin->getColor(EGDC_HIGH_LIGHT), frameRect, &clientClip);

			core::rect<s32> textRect = frameRect;
			textRect.UpperLeftCorner.X += 3;

			if (Font)
			{
				if (IconFont && Items[i].icon.size())
					IconFont->draw(Items[i].icon.c_str(), textRect, skin->getColor((i==Selected) ? EGDC_HIGH_LIGHT_TEXT : EGDC_BUTTON_TEXT), false, true, &clientClip);

				textRect.UpperLeftCorner.X += ItemsIconWidth+3;

				Font->draw(Items[i].text.c_str(), textRect, skin->getColor((i==Selected) ? EGDC_HIGH_LIGHT_TEXT : EGDC_BUTTON_TEXT), false, true, &clientClip);

				textRect.UpperLeftCorner.X -= ItemsIconWidth+3;
			}
		}

		frameRect.UpperLeftCorner.Y += ItemHeight;
		frameRect.LowerRightCorner.Y += ItemHeight;
	}

	IGUIElement::draw();
}
//! draws the element and its children
void CGUIStaticText::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();
	irr::video::IVideoDriver* driver = Environment->getVideoDriver();

	core::rect<s32> frameRect(AbsoluteRect);

	// draw background

	if (Background)
	{
		driver->draw2DRectangle( skin->getColor(gui::EGDC_3D_FACE),
			frameRect, &AbsoluteClippingRect);
	}

	// draw the border

	if (Border)
	{
		skin->draw3DSunkenPane(this, 0, true, false, frameRect, &AbsoluteClippingRect);	
		frameRect.UpperLeftCorner.X += 3;
	}

	// draw the text
	if (Text.size())
	{
		IGUIFont* font = OverrideFont;
		if (!OverrideFont)
			font = skin->getFont();

		if (font)
		{
			if (!WordWrap)
				font->draw(Text.c_str(), frameRect, 
					OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT),
					false, true, &AbsoluteClippingRect);
			else
			{
				if (font != LastBreakFont)
					breakText();

				core::rect<s32> r = frameRect;
				s32 height = font->getDimension(L"A").Height;

				for (u32 i=0; i<BrokenText.size(); ++i)
				{
					font->draw(BrokenText[i].c_str(), r,
						OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT),
						false, false, &AbsoluteClippingRect);

					r.LowerRightCorner.Y += height;
					r.UpperLeftCorner.Y += height;
				}
			}
		}
	}

	IGUIElement::draw();
}
Exemple #11
0
//! draws the element and its children
void CGUIEditBox::draw()
{
#ifndef SERVER_ONLY
    if (!IsVisible)
        return;

    const bool focus = Environment->hasFocus(this);

    IGUISkin* skin = Environment->getSkin();
    if (!skin)
        return;

    FrameRect = AbsoluteRect;

    // draw the border

    if (Border)
    {
        EGUI_DEFAULT_COLOR col = EGDC_GRAY_EDITABLE;
        if ( isEnabled() )
            col = focus ? EGDC_FOCUSED_EDITABLE : EGDC_EDITABLE;
        skin->draw3DSunkenPane(this, skin->getColor(col),
            false, true, FrameRect, &AbsoluteClippingRect);

        FrameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1;
        FrameRect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y)+1;
        FrameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X)+1;
        FrameRect.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y)+1;
    }
    core::rect<s32> localClipRect = FrameRect;
    localClipRect.clipAgainst(AbsoluteClippingRect);

    // draw the text

    IGUIFont* font = OverrideFont;
    if (!OverrideFont)
        font = skin->getFont();

    s32 cursorLine = 0;
    s32 charcursorpos = 0;

    if (font)
    {
        if (LastBreakFont != font)
        {
            breakText();
        }

        // calculate cursor pos

        core::stringw *txtLine = &Text;
        s32 startPos = 0;

        core::stringw s, s2;

        // get mark position
        const bool ml = (!PasswordBox && (WordWrap || MultiLine));
        const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
        const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
        const s32 hlineStart = ml ? getLineFromPos(realmbgn) : 0;
        const s32 hlineCount = ml ? getLineFromPos(realmend) - hlineStart + 1 : 1;
        const s32 lineCount = ml ? BrokenText.size() : 1;

        // Save the override color information.
        // Then, alter it if the edit box is disabled.
        const bool prevOver = OverrideColorEnabled;
        const video::SColor prevColor = OverrideColor;

        if (Text.size())
        {
            if (!isEnabled() && !OverrideColorEnabled)
            {
                OverrideColorEnabled = true;
                OverrideColor = skin->getColor(EGDC_GRAY_TEXT);
            }

            for (s32 i=0; i < lineCount; ++i)
            {
                setTextRect(i);

                // clipping test - don't draw anything outside the visible area
                core::rect<s32> c = localClipRect;
                c.clipAgainst(CurrentTextRect);
                if (!c.isValid())
                    continue;

                // get current line
                if (PasswordBox)
                {
                    if (BrokenText.size() != 1)
                    {
                        BrokenText.clear();
                        BrokenText.push_back(core::stringw());
                    }
                    if (BrokenText[0].size() != Text.size())
                    {
                        BrokenText[0] = Text;
                        for (u32 q = 0; q < Text.size(); ++q)
                        {
                            BrokenText[0] [q] = PasswordChar;
                        }
                    }
                    txtLine = &BrokenText[0];
                    startPos = 0;
                }
                else
                {
                    txtLine = ml ? &BrokenText[i] : &Text;
                    startPos = ml ? BrokenTextPositions[i] : 0;
                }

                font->draw(translations->fribidize(txtLine->c_str()), CurrentTextRect,
                           OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT),
                           false, true, &localClipRect);
                // draw with fribidize no matter what language, because in fribidize function,
                // it will return the input pointer if (this->isRTLLanguage()) from Translations::isRTLText
                // is false

                // draw mark and marked text
                if (focus && MarkBegin != MarkEnd && i >= hlineStart && i < hlineStart + hlineCount)
                {

                    s32 mbegin = 0, mend = 0;
                    s32 lineStartPos = 0, lineEndPos = txtLine->size();

                    if (i == hlineStart)
                    {
                        // highlight start is on this line
                        s = txtLine->subString(0, realmbgn - startPos);
                        mbegin = font->getDimension(s.c_str()).Width;

                        // deal with kerning
                        mbegin += font->getKerningWidth(
                            &((*txtLine)[realmbgn - startPos]),
                            realmbgn - startPos > 0 ? &((*txtLine)[realmbgn - startPos - 1]) : 0);

                        lineStartPos = realmbgn - startPos;
                    }
                    if (i == hlineStart + hlineCount - 1)
                    {
                        // highlight end is on this line
                        s2 = txtLine->subString(0, realmend - startPos);
                        mend = font->getDimension(s2.c_str()).Width;
                        lineEndPos = (s32)s2.size();
                    }
                    else
                        mend = font->getDimension(txtLine->c_str()).Width;

                    CurrentTextRect.UpperLeftCorner.X += mbegin;
                    CurrentTextRect.LowerRightCorner.X = CurrentTextRect.UpperLeftCorner.X + mend - mbegin;

                    // draw mark
                    skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), CurrentTextRect, &localClipRect);

                    // draw marked text
                    s = txtLine->subString(lineStartPos, lineEndPos - lineStartPos);

                    if (s.size())
                        font->draw(s.c_str(), CurrentTextRect,
                            OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_HIGH_LIGHT_TEXT),
                            false, true, &localClipRect);

                }
            }

            // Return the override color information to its previous settings.
            OverrideColorEnabled = prevOver;
            OverrideColor = prevColor;
        }

        // draw cursor

        if (WordWrap || MultiLine)
        {
            cursorLine = getLineFromPos(CursorPos);
            txtLine = &BrokenText[cursorLine];
            startPos = BrokenTextPositions[cursorLine];
        }
        s = txtLine->subString(0,CursorPos-startPos);
        charcursorpos = font->getDimension(s.c_str()).Width ;
        // + font->getKerningWidth(L"_", CursorPos-startPos > 0 ? &((*txtLine)[CursorPos-startPos-1]) : 0);

        if (focus && (getTime() - BlinkStartTime) % 2 == 0 && !m_rtl)
        {
            //setTextRect(cursorLine);
            //CurrentTextRect.UpperLeftCorner.X += charcursorpos;

            setTextRect(0);

            core::rect< s32 > caret_rect = CurrentTextRect;
            caret_rect.UpperLeftCorner.X += charcursorpos - 1;
            caret_rect.LowerRightCorner.X = caret_rect.UpperLeftCorner.X + 2;
            GL32_draw2DRectangle( video::SColor(255,0,0,0), caret_rect );

            /*
            font->draw(L"_", CurrentTextRect,
                OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT),
                false, true, &localClipRect);
             */
        }
    }

    // draw children
    IGUIElement::draw();
#endif
}
//! draws the element and its children
void CGUICheckBox::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();
	if (skin)
	{
		video::IVideoDriver* driver = Environment->getVideoDriver();
		core::rect<s32> frameRect(AbsoluteRect);

		// draw background
		if (Background)
		{
			video::SColor bgColor = skin->getColor(gui::EGDC_3D_FACE);
			driver->draw2DRectangle(bgColor, frameRect, &AbsoluteClippingRect);
		}

		// draw the border
		if (Border)
		{
			skin->draw3DSunkenPane(this, 0, true, false, frameRect, &AbsoluteClippingRect);
			frameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X);
			frameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X);
		}

		const s32 height = skin->getSize(EGDS_CHECK_BOX_WIDTH);

		// the rectangle around the "checked" area.
		core::rect<s32> checkRect(frameRect.UpperLeftCorner.X,
					((frameRect.getHeight() - height) / 2) + frameRect.UpperLeftCorner.Y,
					0, 0);

		checkRect.LowerRightCorner.X = checkRect.UpperLeftCorner.X + height;
		checkRect.LowerRightCorner.Y = checkRect.UpperLeftCorner.Y + height;

		EGUI_DEFAULT_COLOR col = EGDC_GRAY_EDITABLE;
		if ( isEnabled() )
			col = Pressed ? EGDC_FOCUSED_EDITABLE : EGDC_EDITABLE;
		skin->draw3DSunkenPane(this, skin->getColor(col),
			false, true, checkRect, &AbsoluteClippingRect);

		// the checked icon
		if (Checked)
		{
			skin->drawIcon(this, EGDI_CHECK_BOX_CHECKED, checkRect.getCenter(),
				CheckTime, os::Timer::getTime(), false, &AbsoluteClippingRect);
		}

		// associated text
		if (Text.size())
		{
			checkRect = frameRect;
			checkRect.UpperLeftCorner.X += height + 5;

			IGUIFont* font = skin->getFont();
			if (font)
			{
				font->draw(Text.c_str(), checkRect,
						skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), false, true, &AbsoluteClippingRect);
			}
		}
	}
	IGUIElement::draw();
}
//! draws the element and its children
void CGUIStaticText::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();
	if (!skin)
		return;
	video::IVideoDriver* driver = Environment->getVideoDriver();

	core::rect<s32> frameRect(AbsoluteRect);

	// draw background

	if (Background)
	{
		driver->draw2DRectangle(BGColor, frameRect, &AbsoluteClippingRect);
	}

	// draw the border

	if (Border)
	{
		skin->draw3DSunkenPane(this, 0, true, false, frameRect, &AbsoluteClippingRect);
		frameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X);
	}

	// draw the text
	if (Text.size())
	{
		IGUIFont* font = OverrideFont;
		if (!OverrideFont)
			font = skin->getFont();

		if (font)
		{
			if (!WordWrap)
			{
				if (VAlign == EGUIA_LOWERRIGHT)
				{
					frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y -
						font->getDimension(L"A").Height - font->getKerningHeight();
				}
				if (HAlign == EGUIA_LOWERRIGHT)
				{
					frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X -
						font->getDimension(Text.c_str()).Width;
				}

				font->draw(Text.c_str(), frameRect,
					OverrideColorEnabled ? OverrideColor : skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT),
					HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, &AbsoluteClippingRect);
			}
			else
			{
				if (font != LastBreakFont)
					breakText();

				core::rect<s32> r = frameRect;
				s32 height = font->getDimension(L"A").Height + font->getKerningHeight();
				s32 totalHeight = height * BrokenText.size();
				if (VAlign == EGUIA_CENTER)
				{
					r.UpperLeftCorner.Y = r.getCenter().Y - (totalHeight / 2);
				}
				else if (VAlign == EGUIA_LOWERRIGHT)
				{
					r.UpperLeftCorner.Y = r.LowerRightCorner.Y - totalHeight;
				}

				for (u32 i=0; i<BrokenText.size(); ++i)
				{
					if (HAlign == EGUIA_LOWERRIGHT)
					{
						r.UpperLeftCorner.X = frameRect.LowerRightCorner.X -
							font->getDimension(BrokenText[i].c_str()).Width;
					}

					font->draw(BrokenText[i].c_str(), r,
						OverrideColorEnabled ? OverrideColor : skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT),
						HAlign == EGUIA_CENTER, false, &AbsoluteClippingRect);

					r.LowerRightCorner.Y += height;
					r.UpperLeftCorner.Y += height;
				}
			}
		}
	}

	IGUIElement::draw();
}
Exemple #14
0
/**
 * \brief Draw function draws the container component.
 * If texture for empty slot is not set, simple rectangles will be drawn.
 * This function also goes through the list of items and draws them textures in place.
 * \author Petar Bajic 
 * \date July, 21 2008.
 */
void CGUIContainer::draw()
{
	if(!IsVisible)
		return;

	//Draw Container
	IGUISkin* skin = Environment->getSkin();	
	core::rect<s32>* clipRect = 0;
	core::rect<s32> iconAbsoluteSquare;
	clipRect = &AbsoluteClippingRect;
	core::rect<s32> frameRect(AbsoluteRect);
	skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), false, true, frameRect, clipRect);
	skin->draw2DRectangle(this, skin->getColor(EGDC_BUTTON_TEXT), frameRect, clipRect);

	//Draw Slots
	for(u32 x = 0; x < m_Width; x++)
	{
		for(u32 y = 0; y < m_Height; y++)
		{
			iconAbsoluteSquare.UpperLeftCorner = AbsoluteRect.UpperLeftCorner + position2d<s32>( m_Spacing.Width + x*(slotRect.getWidth() + m_Spacing.Width), m_Spacing.Height + y*(slotRect.getHeight() + m_Spacing.Height));
			iconAbsoluteSquare.LowerRightCorner = position2d<s32>(iconAbsoluteSquare.UpperLeftCorner.X + slotRect.getWidth(), iconAbsoluteSquare.UpperLeftCorner.Y + slotRect.getHeight());
			if (!m_SlotTexture)
			{
				//draw simlpe graphic squares
				Environment->getVideoDriver()->draw2DRectangle(SColor(255,50,155,0),iconAbsoluteSquare);
			}
			else
			{
				//draw fancy slot icons with textures
				Environment->getVideoDriver()->draw2DImage(
				m_SlotTexture,
				iconAbsoluteSquare.UpperLeftCorner,
				core::rect<s32>(core::position2d<s32>(0,0), m_SlotTexture->getOriginalSize()),
				&iconAbsoluteSquare);
			}
		}
	}

	//Draw Items in Container
	u32 index = 0;
	if (m_ListOfItems.size() == m_Width*m_Height)
	{
		for(u32 x = 0; x < m_Width; x++)
		{
			for(u32 y = 0; y < m_Height; y++)
			{
				index = x + y*m_Width;
				if ((m_ListOfItems[index].pick != NULL) && (m_ListOfItems[index].pick->m_IconTexture != NULL))
				{
					iconAbsoluteSquare.UpperLeftCorner = AbsoluteRect.UpperLeftCorner + position2d<s32>( m_Spacing.Width + x*(slotRect.getWidth() + m_Spacing.Width), m_Spacing.Height + y*(slotRect.getHeight() + m_Spacing.Height));
					iconAbsoluteSquare.LowerRightCorner = iconAbsoluteSquare.UpperLeftCorner + position2d<s32>(slotRect.getWidth(), slotRect.getHeight());
					//Draw item in container
					Environment->getVideoDriver()->draw2DImage(
					m_ListOfItems[index].pick->m_IconTexture,
					iconAbsoluteSquare.UpperLeftCorner,
					core::rect<s32>(core::position2d<s32>(0,0), m_ListOfItems[index].pick->m_IconTexture->getOriginalSize()),
					&iconAbsoluteSquare);
				}
				else
				{
					//TODO: Draw invalid icon image!!
				}
			}
		}
	}
}