Example #1
0
void ColorPicker::NumericTyped( gwen::Controls::Base* control )
{
	TextBoxNumeric* box = gwen_cast<TextBoxNumeric> ( control );

	if ( !box )
	{ return; }

	if ( box->GetText() == L"" )
	{ return; }

	int textValue = atoi( box->GetText().c_str() );

	if ( textValue < 0 ) { textValue = 0; }

	if ( textValue > 255 ) { textValue = 255; }

	if ( box->GetName().find( "Red" ) != gwen::String::npos )
	{ SetRed( textValue ); }

	if ( box->GetName().find( "Green" ) != gwen::String::npos )
	{ SetGreen( textValue ); }

	if ( box->GetName().find( "Blue" ) != gwen::String::npos )
	{ SetBlue( textValue ); }

	if ( box->GetName().find( "Alpha" ) != gwen::String::npos )
	{ SetAlpha( textValue ); }

	UpdateControls();
}
Example #2
0
void ColorPicker::NumericTyped( Gwen::Controls::Base* control )
{
	TextBoxNumeric* box = gwen_cast<TextBoxNumeric>(control);
	if (!box)
		return;

	if ( box->GetText() == L"")
		return;

	int textValue = atoi( Utility::UnicodeToString( box->GetText()).c_str()  );
	if ( textValue < 0) textValue = 0;
	if ( textValue > 255) textValue = 255;

	if ( box->GetName().find("Red") != Gwen::String::npos )
		SetRed( textValue );

	if ( box->GetName().find("Green") != Gwen::String::npos )
		SetGreen( textValue );

	if ( box->GetName().find("Blue") != Gwen::String::npos )
		SetBlue( textValue );

	if ( box->GetName().find("Alpha") != Gwen::String::npos )
		SetAlpha( textValue );

	UpdateControls();
}
Example #3
0
void HSVColorPicker::NumericTyped( Gwen::Controls::Base* control )
{
	TextBoxNumeric* box = gwen_cast<TextBoxNumeric> ( control );

	if ( !box ) { return; }

	if ( box->GetText() == U"" )	{ return; }

	int textValue = atoi( box->GetText().c_str() );

	if ( textValue < 0 ) { textValue = 0; }

	if ( textValue > 255 ) { textValue = 255; }

	Gwen::Color newColor = GetColor();

	if ( box->GetName().find( "Red" ) != Gwen::String::npos )
	{
		newColor.r = textValue;
	}
	else if ( box->GetName().find( "Green" ) != Gwen::String::npos )
	{
		newColor.g = textValue;
	}
	else if ( box->GetName().find( "Blue" ) != Gwen::String::npos )
	{
		newColor.b = textValue;
	}
	else if ( box->GetName().find( "Alpha" ) != Gwen::String::npos )
	{
		newColor.a = textValue;
	}

	SetColor( newColor );
}