Exemple #1
0
void RichLabel::CreateLabel( const Gwen::UnicodeString & text, const DividedText & txt, int & x, int & y, int & lineheight, bool NoSplit )
{
	//
	// Use default font or is one set?
	//
	Gwen::Font* pFont = GetSkin()->GetDefaultFont();

	if ( txt.font ) { pFont = txt.font; }

	//
	// This string is too long for us, split it up.
	//
	Gwen::Point p = GetSkin()->GetRender()->MeasureText( pFont, text );

	if ( lineheight == -1 )
	{
		lineheight = p.y;
	}

	if ( !NoSplit )
	{
		if ( x + p.x > Width() )
		{
			return SplitLabel( text, pFont, txt, x, y, lineheight );
		}
	}

	//
	// Wrap
	//
	if ( x + p.x >= Width() )
	{
		CreateNewline( x, y, lineheight );
	}

	Gwen::Controls::Label*	pLabel = new Gwen::Controls::Label( this );
	pLabel->SetText( x == 0 ? Gwen::Utility::Strings::TrimLeft<Gwen::UnicodeString> ( text, U" " ) : text );
	pLabel->SetTextColor( txt.color );
	pLabel->SetFont( pFont );
	pLabel->SizeToContents();
	pLabel->SetPos( x, y );
	//lineheight = (lineheight + pLabel->Height()) / 2;
	x += pLabel->Width();

	if ( x >= Width() )
	{
		CreateNewline( x, y, lineheight );
	}
}
Gwen::Controls::Base* SettingsPanel::addSlider( Gwen::Controls::Base* pControl , Rectf bounds, string name, float value, float valueMin, float valueMax){
    
    
    Gwen::Controls::Base* cont = new Gwen::Controls::Base( pControl );
    cont->Dock( Gwen::Pos::Top );
    cont->SetMargin( Gwen::Margin(5,7,5,7) );
    cont->SetHeight( 38 );

    int px = 0;//bounds.getX1();
    int py = 0;//bounds.getY1();
    int w = bounds.getWidth();
    
    Gwen::Controls::Base* lbls = new Gwen::Controls::Base( cont );
    lbls->Dock( Gwen::Pos::Top );
    lbls->SetHeight( 20 );
    
    Gwen::Controls::Label* label = new Gwen::Controls::Label( lbls );
    label->Dock( Gwen::Pos::Left );
    label->SetText( name );
    label->SizeToContents();
//    label->SetPos( px, py );
    
    
    Gwen::Controls::Label* labelValue = new Gwen::Controls::Label( lbls );
//    labelValue->SizeToContents();
    labelValue->Dock( Gwen::Pos::Right );
    labelValue->SetWidth(w);
    labelValue->SetAlignment(Gwen::Pos::Right);
//    labelValue->SetPos( px, py );
    labelValue->SetText( toString(value) );
    
    Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider( cont );
    labelValue->Dock( Gwen::Pos::Top );
    pSlider->SetPos( px, py + 17 );
    pSlider->SetSize( w, 20 );
    pSlider->SetClampToNotches(false);
    pSlider->SetNotchCount( (valueMax-valueMin)/10 );
    pSlider->SetRange( valueMin, valueMax );
    pSlider->SetFloatValue( value );
    pSlider->SetName(name);
    pSlider->onValueChanged.Add( this, &SettingsPanel::onSliderLaserOutput );
        
    mLabelsMap[pSlider] = labelValue;
    mSliderValueMap[name] = pSlider;
    return pSlider;
}
Gwen::Controls::Base* SettingsPanel::addProperty( Gwen::Controls::Base* pControl , Rectf bounds, string name, int val){
    
    Gwen::Controls::Base* cont = new Gwen::Controls::Base( pControl );
    Gwen::Controls::Label* pLabelName = new Gwen::Controls::Label( cont );
    Gwen::Controls::Label* pLabelValue = new Gwen::Controls::Label( cont );
    
    cont->Dock( Gwen::Pos::Top );
    cont->SetMargin( Gwen::Margin(5,7,5,7) );
    cont->SetHeight( 20 );
    pLabelName->SetText( name );
    pLabelName->SetAlignment(Gwen::Pos::Left );
    pLabelName->Dock( Gwen::Pos::Left );
    pLabelName->SizeToContents();

    pLabelValue->Dock( Gwen::Pos::Right );
    pLabelValue->SetWidth( 300 );
    pLabelValue->SetText( toString(val) );
    pLabelValue->SetAlignment( Gwen::Pos::Right );
    pLabelValue->SetName( name );

    mLabelsValueMap[name] = pLabelValue;
    return pLabelName;
}
Exemple #4
0
	GWEN_CONTROL_INLINE( Label, GUnit )
	{
		{
			Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
			label->SetText( "Garry's Normal Label" );
			label->SizeToContents();
			label->SetPos( 10, 10 );
		}

		{
			Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
			label->SetText( L"Chinese: \u4E45\u6709\u5F52\u5929\u613F \u7EC8\u8FC7\u9B3C\u95E8\u5173" );
			label->SizeToContents();
			label->SetPos( 10, 30 );
		}

		{
			Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
			label->SetText( L"Japanese: \u751F\u3080\u304E\u3000\u751F\u3054\u3081\u3000\u751F\u305F\u307E\u3054" );
			label->SizeToContents();
			label->SetPos( 10, 50 );
		}

		{
			Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
			label->SetText( L"Korean: \uADF9\uC9C0\uD0D0\uD5D8\u3000\uD611\uD68C\uACB0\uC131\u3000\uCCB4\uACC4\uC801\u3000\uC5F0\uAD6C" );
			label->SizeToContents();
			label->SetPos( 10, 70 );
		}

		{
			Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
			label->SetText( L"Hindi: \u092F\u0947 \u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926 \u0939\u093F\u0928\u094D\u0926\u0940 \u092E\u0947\u0902 \u0939\u0948\u0964" );
			label->SizeToContents();
			label->SetPos( 10, 90 );
		}

		{
			Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
			label->SetText( L"Arabic: \u0627\u0644\u0622\u0646 \u0644\u062D\u0636\u0648\u0631 \u0627\u0644\u0645\u0624\u062A\u0645\u0631 \u0627\u0644\u062F\u0648\u0644\u064A" );
			label->SizeToContents();
			label->SetPos( 10, 110 );
		}

		{
			Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
			label->SetText( L"Wow, Coloured Text" );
			label->SetTextColor( Gwen::Color( 0, 0, 255, 255 ) );
			label->SizeToContents();
			label->SetPos( 10, 130 );
		}

		{
			Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
			label->SetText( L"Coloured Text With Alpha" );
			label->SetTextColor( Gwen::Color( 0, 0, 255, 100 ) );
			label->SizeToContents();
			label->SetPos( 10, 150 );
		}

		{
			//
			// Note that when using a custom font, this font object has to stick around
			// for the lifetime of the label. Rethink, or is that ideal?
			//
			m_Font.facename = L"Comic Sans MS";
			m_Font.size = 25;

			Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
			label->SetText( L"Custom Font (Comic Sans 25)" );
			label->SetFont( &m_Font );
			label->SizeToContents();
			label->SetPos( 10, 170 );
		}

		{
			Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
			label->SetText( L"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." );
			label->SizeToContents();
			label->SetBounds( 300, 10, 150, 500 );
		}

	}