Beispiel #1
0
void CGUISpinBox::draw()
{
	if ( !isVisible() )
		return;

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

	video::SColor iconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
	if ( iconColor != CurrentIconColor )
	{
		refreshSprites();
	}

	IGUISpinBox::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();
}
Beispiel #3
0
//! draws the element and its children
void CGUIImage::draw()
{
	if (!IsVisible)
		return;

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

	if (Texture)
	{
		core::rect<s32> sourceRect(SourceRect);
		if (sourceRect.getWidth() == 0 || sourceRect.getHeight() == 0)
		{
			sourceRect = core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(Texture->getOriginalSize()));
		}

		if (ScaleImage)
		{
			const video::SColor Colors[] = {Color,Color,Color,Color};

			core::rect<s32> clippingRect(AbsoluteClippingRect);
			checkBounds(clippingRect);

			driver->draw2DImage(Texture, AbsoluteRect, sourceRect,
				&clippingRect, Colors, UseAlphaChannel);
		}
		else
		{
			core::rect<s32> clippingRect(AbsoluteRect.UpperLeftCorner, sourceRect.getSize());
			checkBounds(clippingRect);
			clippingRect.clipAgainst(AbsoluteClippingRect);

			driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, sourceRect,
				&clippingRect, Color, UseAlphaChannel);
		}
	}
	else
	{
		core::rect<s32> clippingRect(AbsoluteClippingRect);
		checkBounds(clippingRect);

		skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &clippingRect);
	}

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

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

		rect<SINT32> rect = AbsoluteRect;
		Sapphire::rect<SINT32>* clip = &AbsoluteClippingRect;

		// draw frame
		skin->draw3DToolBar(this, rect, clip);

		IGUIElement::draw();
	}
void CGUITextureCacheBrowser::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();

	core::rect<s32> rect = AbsoluteRect;
	core::rect<s32> *cl = &AbsoluteClippingRect;

	// draw body fast
	rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER),
		AbsoluteRect, &AbsoluteClippingRect);

	// draw window text
	if (Text.size())
	{
		rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X);
		rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y);
		rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;

		IGUIFont* font = skin->getFont();
		if (font)
			font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, cl);
	}

	IGUIElement::draw();
}
//! draws the element and its children
void CGUIWindow::draw()
{
	if ( IsVisible )
	{
		IGUISkin* skin = Environment->getSkin();

		core::rect<s32> rect = AbsoluteRect;

		// draw body fast
        if ( DrawBackground )
        {
            rect = skin->draw3DWindowBackground(this, DrawTitlebar, skin->getColor(EGDC_ACTIVE_BORDER),
                AbsoluteRect, &AbsoluteClippingRect);

            if (DrawTitlebar && Text.size())
            {
                rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X);
                rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y);
                rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;

                IGUIFont* font = skin->getFont(EGDF_WINDOW);
                if (font)
                {
                    font->draw(Text.c_str(), rect,
                        skin->getColor(EGDC_ACTIVE_CAPTION), false, true, &AbsoluteClippingRect);
                }
            }
        }
	}

	IGUIElement::draw();
}
//! constructor
CGUITabControl::CGUITabControl(IGUIEnvironment* environment,
	IGUIElement* parent, const core::rect<s32>& rectangle,
	bool fillbackground, bool border, s32 id)
	: IGUITabControl(environment, parent, id, rectangle), ActiveTab(-1),
	Border(border), FillBackground(fillbackground), ScrollControl(false), TabHeight(0), VerticalAlignment(EGUIA_UPPERLEFT),
	UpButton(0), DownButton(0), TabMaxWidth(0), CurrentScrollTabIndex(0), TabExtraWidth(20)
{
	#ifdef _DEBUG
	setDebugName("CGUITabControl");
	#endif

	video::SColor color(255,255,255,255);
	IGUISkin* skin = Environment->getSkin();
	IGUISpriteBank* sprites = 0;

	TabHeight = 32;

	if (skin)
	{
		sprites = skin->getSpriteBank();
		color = skin->getColor(EGDC_WINDOW_SYMBOL);
		TabHeight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2;
	}

	UpButton = Environment->addButton(core::rect<s32>(0,0,10,10), this);

	if (UpButton)
	{
		UpButton->setSpriteBank(sprites);
		UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_LEFT), color);
		UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_LEFT), color);
		UpButton->setVisible(false);
		UpButton->setSubElement(true);
		UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
		UpButton->setOverrideFont(Environment->getBuiltInFont());
		UpButton->grab();
	}

	DownButton = Environment->addButton(core::rect<s32>(0,0,10,10), this);

	if (DownButton)
	{
		DownButton->setSpriteBank(sprites);
		DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_RIGHT), color);
		DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_RIGHT), color);
		DownButton->setVisible(false);
		DownButton->setSubElement(true);
		DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
		DownButton->setOverrideFont(Environment->getBuiltInFont());
		DownButton->grab();
	}

	setTabVerticalAlignment(EGUIA_UPPERLEFT);
}
Beispiel #8
0
void CGUIComboBox::openCloseMenu()
{
	if (ListBox)
	{
		// close list box
		Environment->setFocus(this);
		ListBox->remove();
		ListBox = 0;
	}
	else
	{
		if (Parent)
			Parent->bringToFront(this);

		IGUISkin* skin = Environment->getSkin();		
		s32 h = Items.size();

		if (h > 5)
			h = 5;
		if (h == 0)
			h = 1;

		IGUIFont* font = skin->getFont();
		if (font)
			h *= (font->getDimension(L"A").Height + 4);

		// open list box
		core::rect<s32> r(0, AbsoluteRect.getHeight(),
			AbsoluteRect.getWidth(), AbsoluteRect.getHeight() + h);

		ListBox = new CGUIListBox(Environment, this, -1, r, false, true, true);
		ListBox->setSubElement(true);
		ListBox->drop();

		for (s32 i=0; i<(s32)Items.size(); ++i)
			ListBox->addItem(Items[i].c_str());

		ListBox->setSelected(Selected);

		// set focus
		Environment->setFocus(ListBox);
	}
}
Beispiel #9
0
s32 CGUIEditBox::getCursorPos(s32 x, s32 y)
{
    IGUIFont* font = OverrideFont;
    IGUISkin* skin = Environment->getSkin();
    if (!OverrideFont)
        font = skin->getFont();

    const u32 lineCount = (WordWrap || MultiLine) ? BrokenText.size() : 1;

    core::stringw *txtLine=0;
    s32 startPos=0;
    x+=3;

    for (u32 i=0; i < lineCount; ++i)
    {
        setTextRect(i);
        if (i == 0 && y < CurrentTextRect.UpperLeftCorner.Y)
            y = CurrentTextRect.UpperLeftCorner.Y;
        if (i == lineCount - 1 && y > CurrentTextRect.LowerRightCorner.Y )
            y = CurrentTextRect.LowerRightCorner.Y;

        // is it inside this region?
        if (y >= CurrentTextRect.UpperLeftCorner.Y && y <= CurrentTextRect.LowerRightCorner.Y)
        {
            // we've found the clicked line
            txtLine = (WordWrap || MultiLine) ? &BrokenText[i] : &Text;
            startPos = (WordWrap || MultiLine) ? BrokenTextPositions[i] : 0;
            break;
        }
    }

    if (x < CurrentTextRect.UpperLeftCorner.X)
        x = CurrentTextRect.UpperLeftCorner.X;

    s32 idx = txtLine ? font->getCharacterFromPos(txtLine->c_str(), x - CurrentTextRect.UpperLeftCorner.X) : -1;

    // click was on or left of the line
    if (idx != -1)
        return idx + startPos;

    // click was off the right edge of the line, go to end.
    return txtLine->size() + startPos;
}
Beispiel #10
0
//! draws the element and its children
void CGUIImage::draw()
{
	if (!IsVisible)
		return;

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

	core::rect<s32> rect = AbsoluteRect;

	if (Texture)
		driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, 
			core::rect<s32>(core::position2d<s32>(0,0), Texture->getOriginalSize()),
			&AbsoluteClippingRect, video::SColor(255,255,255,255), UseAlphaChannel);
	else
		driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &AbsoluteClippingRect);

	IGUIElement::draw();
}
Beispiel #11
0
game::game(void)
{
	//create the device
	//and get desktop width and height
	RECT desktop;
	const HWND hDesktop = GetDesktopWindow();
	GetWindowRect(hDesktop, &desktop);
	//assign the width and height
	horizontal = desktop.right;
	vertical = desktop.bottom;

	device = createDevice(video::EDT_OPENGL, dimension2d<u32>(horizontal, vertical), 16, false, false, false, 0);

	device->setWindowCaption(L"PSI TEAM 3");
	device->setResizable(false);

	// initialize driver, scenemanager and gui environment
	driver = device->getVideoDriver();
	smgr = device->getSceneManager();
	guienv = device->getGUIEnvironment();
	playerCamera = new PlayerCamera(device);

	IGUISkin* skin = guienv->getSkin();
	IGUIFont* font = guienv->getFont("../media/fonts/candara14.bmp");
	skin->setFont(font);

	// initialize networkUtilities (all networking stuff is handled in in this class)
	networkUtilities = new NonRealtimeNetworkingUtilities();

	// initialize gameStateDTO
	gameState = new GameStateDTO(16);

	// initialize players
	localPlayer = new Player(device);
	opposingPlayer = new Player(device);

	fields = new std::vector<vector3df>();

	smgr->addCameraSceneNode(0, vector3df(0,8,-8), vector3df(0,0,0));


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

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


		ColourValue iconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
		if (iconColor != CurrentIconColor)
		{
			refreshControls();
		}


		SliderRect = AbsoluteRect;

		// draws the background
		skin->draw2DRectangle(this, skin->getColor(EGDC_SCROLLBAR), SliderRect, &AbsoluteClippingRect);

		if (!Math::iszero(range()))
		{
			// recalculate slider rectangle
			if (Horizontal)
			{
				SliderRect.UpperLeftCorner.x = AbsoluteRect.UpperLeftCorner.x + DrawPos + RelativeRect.getHeight() - DrawHeight / 2;
				SliderRect.LowerRightCorner.x = SliderRect.UpperLeftCorner.x + DrawHeight;
			}
			else
			{
				SliderRect.UpperLeftCorner.y = AbsoluteRect.UpperLeftCorner.y + DrawPos + RelativeRect.getWidth() - DrawHeight / 2;
				SliderRect.LowerRightCorner.y = SliderRect.UpperLeftCorner.y + DrawHeight;
			}

			skin->draw3DButtonPaneStandard(this, SliderRect, &AbsoluteClippingRect);
		}

		// draw buttons
		IGUIElement::draw();
	}
Beispiel #13
0
// ----------------------------------------------------------------------------
void Editor::initAfterDataDirKnown()
{
    m_rcs = RoadCrossSectionWndw::get();

    // fonts
    IGUISkin* skin = m_gui_env->getSkin();
    m_font = m_gui_env->getFont(m_data_loc + L"editor/font/font.xml");
    skin->setFont(m_font);

    // removing gui transparency
    for (s32 i = 0; i < EGDC_COUNT; ++i)
    {
        video::SColor col = skin->getColor((EGUI_DEFAULT_COLOR)i);
        col.setAlpha(255);
        skin->setColor((EGUI_DEFAULT_COLOR)i, col);
    }

    // free camera
    ICameraSceneNode* cam;
    cam = m_scene_manager->addCameraSceneNodeMaya();
    cam->setID(1);
    cam->setFarValue(20000.f);
    cam->setTarget(vector3df(0, 0, 0));
    cam->setInputReceiverEnabled(false);

    // viewport init
    ICameraSceneNode* norm_cam;
    norm_cam = m_scene_manager->addCameraSceneNode(0, vector3df(25, 50, 30),
        vector3df(5, 10, 6));
    norm_cam->setID(2);
    m_viewport = Viewport::get(norm_cam, &m_mouse, &m_keys);
    m_viewport->setFreeCamera(cam);
    m_indicator = m_viewport->getIndicator();
    m_scene_manager->setActiveCamera(norm_cam);

    m_msg_wndw = MsgWndw::get();

    m_toolbar = ToolBar::getToolBar();
    m_new_dialog_wndw = NewDialogWndw::get();
    m_new_dialog_wndw->hide();
    m_welcome_screen = WelcomeScreen::get();
} // initAfterDataDirKnown
Beispiel #14
0
//! Returns the height of the text in pixels when it is drawn.
s32 CGUIStaticText::getTextHeight()
{
	IGUISkin* skin = Environment->getSkin();

	if (!skin)
		return 0;

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

	if (!font)
		return 0;

	s32 height = font->getDimension(L"A").Height;

	if (WordWrap)
		height *= BrokenText.size();

	return height;
}
Beispiel #15
0
//! draws the element and its children
void CGUIScrollBar::draw()
{
	if (!IsVisible)
		return;

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

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

	core::rect<s32> rect = AbsoluteRect;
	core::rect<s32>* clip = 0;

	if (!NoClip)
		clip = &AbsoluteClippingRect;

	// draws the background
	driver->draw2DRectangle(skin->getColor(EGDC_SCROLLBAR), rect, clip);

	if (Max!=0)
	{
		// draw thumb
		if (Horizontal)
		{
			rect.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X + DrawPos + RelativeRect.getHeight() - DrawHeight/2;
			rect.LowerRightCorner.X = rect.UpperLeftCorner.X + DrawHeight;	
		}
		else
		{
			rect.UpperLeftCorner.Y = AbsoluteRect.UpperLeftCorner.Y + DrawPos + RelativeRect.getWidth() - DrawHeight/2;
			rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + DrawHeight;	
		}

		skin->draw3DButtonPaneStandard(this, rect, clip);
	}

	// draw buttons
	IGUIElement::draw();
}
Beispiel #16
0
		void CGUISpinBox::refreshSprites()
		{
			IGUISpriteBank * sb = 0;
			if (Environment && Environment->getSkin())
			{
				sb = Environment->getSkin()->getSpriteBank();
			}

			if (sb)
			{
				IGUISkin * skin = Environment->getSkin();
				CurrentIconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
				ButtonSpinDown->setSpriteBank(sb);
				ButtonSpinDown->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_SMALL_CURSOR_DOWN), CurrentIconColor);
				ButtonSpinDown->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_SMALL_CURSOR_DOWN), CurrentIconColor);
				ButtonSpinUp->setSpriteBank(sb);
				ButtonSpinUp->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_SMALL_CURSOR_UP), CurrentIconColor);
				ButtonSpinUp->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_SMALL_CURSOR_UP), CurrentIconColor);
			}
			else
			{
				ButtonSpinDown->setText(L"-");
				ButtonSpinUp->setText(L"+");
			}
		}
//! draws the element and its children
void CGUIFileOpenDialog::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();

	core::rect<s32> rect = AbsoluteRect;

	rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER),
		rect, &AbsoluteClippingRect);

	if (Text.size())
	{
		rect.UpperLeftCorner.X += 2;
		rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;

		IGUIFont* font = skin->getFont(EGDF_WINDOW);
		if (font)
			font->draw(Text.c_str(), rect,
					skin->getColor(EGDC_ACTIVE_CAPTION),
					false, true, &AbsoluteClippingRect);
	}

	IGUIElement::draw();
}
Beispiel #18
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();
}
CGUITextureCacheBrowser::CGUITextureCacheBrowser(IGUIEnvironment* environment, s32 id, IGUIElement *parent) 
:	IGUIWindow(environment, parent, id, core::rect<s32>(0,0,300,200)),
	Dragging(false), DragStart(0,0), CloseButton(0), Images(), SelectedTexture(-1)
{
	#ifdef _DEBUG
	setDebugName("CGUIWindow");
	#endif

	IGUISkin* skin = 0;
	IGUISpriteBank* sprites = 0;
	video::SColor color(255,255,255,255);

	if (environment)
		skin = environment->getSkin();
	
	s32 buttonw = 15;
	if (skin)
	{
		buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
		sprites = skin->getSpriteBank();
		color = skin->getColor(EGDC_WINDOW_SYMBOL);
	}
	s32 posx = RelativeRect.getWidth() - buttonw - 4;

	CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, 
		L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" );
	CloseButton->setSubElement(true);
	CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
	if (sprites)
	{
		CloseButton->setSpriteBank(sprites);
		CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color);
		CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color);
	}

	CloseButton->grab();

	// window title
	Text = L"Texture Browser";

	// panel element
	Panel = new CGUIPanel(environment, this);
	Panel->setRelativePosition( core::rect<s32>(1, buttonw + 5, 151, RelativeRect.getHeight() - 1));
	Panel->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
	Panel->setBorder(true);
	Panel->setSubElement(true);

	// some buttons
	

	// add images from texture cache
	updateImageList();

}
Beispiel #20
0
void CGUIListBox::recalculateItemHeight()
{
	IGUISkin* skin = Environment->getSkin();

	if (Font != skin->getFont())
	{
		if (Font)
			Font->drop();

		Font = skin->getFont();
		ItemHeight = 0;

		if (Font)
		{
			ItemHeight = Font->getDimension(L"A").Height + 4;
			Font->grab();
		}
	}

	TotalItemHeight = ItemHeight * Items.size();
	ScrollBar->setMax(TotalItemHeight - AbsoluteRect.getHeight());
}
Beispiel #21
0
//! draws the element and its children
void CGUIImage::draw()
{
	if (!IsVisible)
		return;

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

	core::rect<s32> rect = AbsoluteRect;

	if (Texture)
	{
		if (ScaleImage)
		{
			video::SColor Colors[4];
			Colors[0] = Color;
			Colors[1] = Color;
			Colors[2] = Color;
			Colors[3] = Color;

			driver->draw2DImage(Texture, AbsoluteRect, 
				core::rect<s32>(core::position2d<s32>(0,0), Texture->getOriginalSize()),
				&AbsoluteClippingRect, Colors, UseAlphaChannel);
		}
		else
		{
			driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, 
				core::rect<s32>(core::position2d<s32>(0,0), Texture->getOriginalSize()),
				&AbsoluteClippingRect, Color, UseAlphaChannel);
		}
	}
	else
	{
		skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &AbsoluteClippingRect);
	}

	IGUIElement::draw();
}
Beispiel #22
0
//! calculate the position of input composition window
core::position2di CGUIEditBox::calculateICPos()
{
    core::position2di pos;
    IGUIFont* font = OverrideFont;
    IGUISkin* skin = Environment->getSkin();
    if (!OverrideFont)
        font = skin->getFont();

    //drop the text that clipping on the right side
    if (WordWrap | MultiLine)
    {
        // todo : It looks like a heavy drinker. Strange!!
        pos.X = CurrentTextRect.LowerRightCorner.X - font->getDimension(Text.subString(CursorPos, BrokenTextPositions[getLineFromPos(CursorPos)] + BrokenText[getLineFromPos(CursorPos)].size() - CursorPos).c_str()).Width;
        pos.Y = CurrentTextRect.UpperLeftCorner.Y + font->getDimension(L"|").Height + (Border ? 3 : 0) - ((MultiLine | WordWrap) ? 3 : 0);
    }
    else
    {
        pos.X = CurrentTextRect.LowerRightCorner.X - font->getDimension(Text.subString(CursorPos, Text.size() - CursorPos).c_str()).Width;
        pos.Y = AbsoluteRect.getCenter().Y + (Border ? 3 : 0); //bug? The text is always drawn in the height of the center. SetTextAlignment() doesn't influence.
    }

    return pos;
}
//! Set the alignment of the tabs
void CGUITabControl::setTabVerticalAlignment( EGUI_ALIGNMENT alignment )
{
	VerticalAlignment = alignment;

	IGUISkin* skin = Environment->getSkin();
	s32 ButtonSize = 16;
	if (skin)
	{
		ButtonSize = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
		if (ButtonSize > TabHeight)
			ButtonSize = TabHeight;
	}

	TabMaxWidth = s32(f32(ButtonSize) * 2.5f);
	s32 ButtonX = RelativeRect.getWidth() - TabMaxWidth - 1;
	s32 ButtonY = 0;

	if (VerticalAlignment == EGUIA_UPPERLEFT)
	{
		ButtonY = (TabHeight / 2) - (ButtonSize / 2);
		UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
		DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
	}
	else
	{
		ButtonY = RelativeRect.getHeight() - (TabHeight / 2) - (ButtonSize / 2);
		UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
		DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
	}

	UpButton->setRelativePosition(core::rect<s32>(ButtonX, ButtonY, ButtonX+ButtonSize, ButtonY+ButtonSize));
	ButtonX += ButtonSize + 1;
	DownButton->setRelativePosition(core::rect<s32>(ButtonX, ButtonY, ButtonX+ButtonSize, ButtonY+ButtonSize));

	recalculateScrollBar();
}
Beispiel #24
0
//! draws the element and its children
void CGUIWindow::draw()
{
    if (IsVisible)
    {
        IGUISkin* skin = Environment->getSkin();


        // update each time because the skin is allowed to change this always.
        updateClientRect();

        if ( CurrentIconColor != skin->getColor(EGDC_WINDOW_SYMBOL) )
            refreshSprites();

        core::rect<s32> rect = AbsoluteRect;

        // draw body fast
        if (DrawBackground)
        {
            rect = skin->draw3DWindowBackground(this, DrawTitlebar,
                                                skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER),
                                                AbsoluteRect, &AbsoluteClippingRect);

            if (DrawTitlebar && Text.size())
            {
                rect.UpperLeftCorner.X += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_X);
                rect.UpperLeftCorner.Y += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_Y);
                rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;

                IGUIFont* font = skin->getFont(EGDF_WINDOW);
                if (font)
                {
                    font->draw(Text.c_str(), rect,
                               skin->getColor(IsActive ? EGDC_ACTIVE_CAPTION:EGDC_INACTIVE_CAPTION),
                               false, true, &AbsoluteClippingRect);
                }
            }
        }
    }

    IGUIElement::draw();
}
Beispiel #25
0
//! 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();
}
Beispiel #26
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();
}
Beispiel #27
0
//! constructor
CGUIComboBox::CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent,
	s32 id, core::rect<s32> rectangle)
	: IGUIComboBox(environment, parent, id, rectangle),
	ListButton(0), ListBox(0), Selected(-1), HasFocus(false), LastFocus(0)
{
	#ifdef _DEBUG
	setDebugName("CGUICheckBox");
	#endif

	IGUISkin* skin = Environment->getSkin();

	s32 width = 15;
	if (skin)
		width = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);

	core::rect<s32> r;
	r.UpperLeftCorner.X = rectangle.getWidth() - width - 2;
	r.LowerRightCorner.X = rectangle.getWidth() - 2;
	
	r.UpperLeftCorner.Y = 2;
	r.LowerRightCorner.Y = rectangle.getHeight() - 2;

	ListButton = Environment->addButton(r, this, -1, L"");
	if (skin && skin->getSpriteBank())
	{
		ListButton->setSpriteBank(skin->getSpriteBank());
		ListButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL));
		ListButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL));
	}
	ListButton->setSubElement(true);
	ListButton->setTabStop(false);

	// this element can be tabbed to
	setTabStop(true);
	setTabOrder(-1);
}
//! draws the element and its children
void CGUIColorSelectDialog::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();
	core::rect<s32> rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER),
		AbsoluteRect, &AbsoluteClippingRect);

	if (Text.size())
	{
		rect.UpperLeftCorner.X += 2;
		rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;

		IGUIFont* font = skin->getFont(EGDF_WINDOW);
		if (font)
			font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true,
			&AbsoluteClippingRect);
	}

	IGUIElement::draw();

	// draw color selector after the window elements
	core::vector2di pos(ColorRing.Control->getAbsolutePosition().UpperLeftCorner);
	pos.X += ColorRing.Texture->getOriginalSize().Width/2;
	pos.Y += ColorRing.Texture->getOriginalSize().Height/2;
#if 0
	const f32 h = Battery[4]->getValue();
	const f32 s = Battery[5]->getValue();
	const f32 l = Battery[6]->getValue();
	const f32 factor = 58.f*(((s==0)&&(l<50))?(l*0.33f/50):(
		(s<100)?((.33f+(s*0.33f/100))):((0.66f+(l-50)*0.33f/50))));

#else
	const f32 factor = 44;
#endif
	pos.X += core::round32(sinf(Battery[4]->getValue()*core::DEGTORAD)*factor);
	pos.Y -= core::round32(cosf(Battery[4]->getValue()*core::DEGTORAD)*factor);
	Environment->getVideoDriver()->draw2DPolygon(pos, 4, 0xffffffff, 4);
}
Beispiel #29
0
//! 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();
}
Beispiel #30
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();
}