コード例 #1
0
ファイル: CGUIWindow.cpp プロジェクト: RaptorFactor/pseuwow
//! constructor
CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
    : IGUIWindow(environment, parent, id, rectangle), Dragging(false), IsDraggable(true), DrawBackground(true), DrawTitlebar(true), IsActive(false)
{
#ifdef _DEBUG
    setDebugName("CGUIWindow");
#endif

    IGUISkin* skin = 0;
    if (environment)
        skin = environment->getSkin();

    CurrentIconColor = video::SColor(255,255,255,255);

    s32 buttonw = 15;
    if (skin)
    {
        buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
    }
    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->setTabStop(false);
    CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
    posx -= buttonw + 2;

    RestoreButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
                                           L"", skin ? skin->getDefaultText(EGDT_WINDOW_RESTORE) : L"Restore" );
    RestoreButton->setVisible(false);
    RestoreButton->setSubElement(true);
    RestoreButton->setTabStop(false);
    RestoreButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
    posx -= buttonw + 2;

    MinButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
                                       L"", skin ? skin->getDefaultText(EGDT_WINDOW_MINIMIZE) : L"Minimize" );
    MinButton->setVisible(false);
    MinButton->setSubElement(true);
    MinButton->setTabStop(false);
    MinButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);

    MinButton->grab();
    RestoreButton->grab();
    CloseButton->grab();

    // this element is a tab group
    setTabGroup(true);
    setTabStop(true);
    setTabOrder(-1);

    refreshSprites();
    updateClientRect();
}
コード例 #2
0
ファイル: CGUISpinBox.cpp プロジェクト: Botyto/Core
		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();
		}
コード例 #3
0
//! constructor
CGUISpinBox::CGUISpinBox(const wchar_t* text, bool border,IGUIEnvironment* environment,
			IGUIElement* parent, s32 id, const core::rect<s32>& rectangle)
: IGUISpinBox(environment, parent, id, rectangle),
	EditBox(0), ButtonSpinUp(0), ButtonSpinDown(0), StepSize(1.f),
	RangeMin(-FLT_MAX), RangeMax(FLT_MAX), FormatString(L"%f"),
	DecimalPlaces(-1)
{
	#ifdef _DEBUG
	setDebugName("CGUISpinBox");
	#endif

	CurrentIconColor = video::SColor(255,255,255,255);
	s32 ButtonWidth = 16;
	IGUISpriteBank *sb = 0;
	if (environment && environment->getSkin())
	{
		ButtonWidth = environment->getSkin()->getSize(EGDS_SCROLLBAR_SIZE);
		sb = environment->getSkin()->getSpriteBank();
	}

	ButtonSpinDown = Environment->addButton(
		core::rect<s32>(rectangle.getWidth() - ButtonWidth, rectangle.getHeight()/2 +1,
						rectangle.getWidth(), rectangle.getHeight()), this);
	ButtonSpinDown->grab();
	ButtonSpinDown->setSubElement(true);
	ButtonSpinDown->setTabStop(false);
	ButtonSpinDown->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_CENTER, EGUIA_LOWERRIGHT);

	ButtonSpinUp = Environment->addButton(
		core::rect<s32>(rectangle.getWidth() - ButtonWidth, 0,
						rectangle.getWidth(), rectangle.getHeight()/2), this);
	ButtonSpinUp->grab();
	ButtonSpinUp->setSubElement(true);
	ButtonSpinUp->setTabStop(false);
	ButtonSpinUp->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_CENTER);

	const core::rect<s32> rectEdit(0, 0, rectangle.getWidth() - ButtonWidth - 1, rectangle.getHeight());
	EditBox = Environment->addEditBox(text, rectEdit, border, this, -1);
	EditBox->grab();
	EditBox->setSubElement(true);
	EditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);

	refreshSprites();
}
コード例 #4
0
ファイル: CGUIWindow.cpp プロジェクト: RaptorFactor/pseuwow
//! 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();
}