Esempio n. 1
0
void GUIChatConsole::drawPrompt()
{
	if (m_font == NULL)
		return;

	u32 row = m_chat_backend->getConsoleBuffer().getRows();
	s32 line_height = m_fontsize.Y;
	s32 y = row * line_height + m_height - m_desired_height;

	ChatPrompt& prompt = m_chat_backend->getPrompt();
	std::wstring prompt_text = prompt.getVisiblePortion();

	// FIXME Draw string at once, not character by character
	// That will only work with the cursor once we have a monospace font
	for (u32 i = 0; i < prompt_text.size(); ++i)
	{
		wchar_t ws[2] = {prompt_text[i], 0};
		s32 x = (1 + i) * m_fontsize.X;
		core::rect<s32> destrect(
			x, y, x + m_fontsize.X, y + m_fontsize.Y);
		m_font->draw(
			ws,
			destrect,
			video::SColor(255, 255, 255, 255),
			false,
			false,
			&AbsoluteClippingRect);
	}

	// Draw the cursor during on periods
	if ((m_cursor_blink & 0x8000) != 0)
	{
		s32 cursor_pos = prompt.getVisibleCursorPosition();
		if (cursor_pos >= 0)
		{
			s32 cursor_len = prompt.getCursorLength();
			video::IVideoDriver* driver = Environment->getVideoDriver();
			s32 x = (1 + cursor_pos) * m_fontsize.X;
			core::rect<s32> destrect(
				x,
				y + m_fontsize.Y * (1.0 - m_cursor_height),
				x + m_fontsize.X * MYMAX(cursor_len, 1),
				y + m_fontsize.Y * (cursor_len ? m_cursor_height+1 : 1)
			);
			video::SColor cursor_color(255,255,255,255);
			driver->draw2DRectangle(
				cursor_color,
				destrect,
				&AbsoluteClippingRect);
		}
	}

}
Esempio n. 2
0
gInput::gInput(int x, int y, int w, int h, const char *L)
: Fl_Input(x, y, w, h, L) {
	//Fl::set_boxtype(G_BOX, gDrawBox, 1, 1, 2, 2);
	box(G_BOX);
	labelsize(11);
	labelcolor(COLOR_TEXT_0);
	color(COLOR_BG_DARK);
	textcolor(COLOR_TEXT_0);
	cursor_color(COLOR_TEXT_0);
	selection_color(COLOR_BD_0);
	textsize(11);

}
Esempio n. 3
0
static int render_address_col(HexView* prView, const int row) {
    SceUInt32 address = 0;
    if (prView == NULL) {
        return HEXVIEW_NULLPTR;
    }
    if (prView->cursorPos.y == row) {
        if (cursor_color(prView) < 0) {
            return HEXVIEW_FAILURE;
        }
    } else {
        if (panel_color(prView) < 0) {
            return HEXVIEW_FAILURE;
        }
    }
    address = row_address(prView, row);
    pspDebugScreenKprintf("0x%08X", address);
    return HEXVIEW_SUCCESS;
}
Esempio n. 4
0
static int render_value_col(HexView* prView, const int row, const int col) {
    SceUInt32 address = 0;
    SceUChar8* prValue = NULL;

    if (prView == NULL) {
        return HEXVIEW_NULLPTR;
    }
    address = row_address(prView, row);
    address += col;
    prValue = (SceUChar8*)address;
    if (panel_color(prView) < 0) {
        return HEXVIEW_FAILURE;
    }
    if (prView->cursorPos.y == row) {
        if (prView->cursorPos.x == col) {
            if (cursor_color(prView) < 0) {
                return HEXVIEW_FAILURE;
            }
        }
    }
    pspDebugScreenKprintf("%02X", *prValue);
    return HEXVIEW_SUCCESS;
}
Esempio n. 5
0
static int render_row(HexView* prView, const int row) {
    ColorConfig* prPcolor = NULL;
    ColorConfig* prCcolor = NULL;
    CursorPos* prCursor = NULL;
    CursorPos* prPos = NULL;
    Dimension* prSize = NULL;
    SceUInt32 address = 0;

    if (prView == NULL) {
        return HEXVIEW_NULLPTR;
    }

    prPcolor = get_panelcolor(prView);
    prCcolor = get_cursorcolor(prView);
    prCursor = get_cursorpos(prView);
    prPos = get_position(prView);
    prSize = get_size(prView);

    pspDebugScreenSetXY(prPos->x, prPos->y + row);
    if (row == prCursor->y) {
        if (cursor_color(prView) < 0) {
            return HEXVIEW_FAILURE;
        }
    } else {
        if (panel_color(prView) < 0) {
            return HEXVIEW_FAILURE;
        }
    }
    address = row_address(prView, row);
    pspDebugScreenKprintf("0x%08X", address);

    pspDebugScreenSetBackColor(prPcolor->background);
    pspDebugScreenSetTextColor(prPcolor->text);

    return HEXVIEW_SUCCESS;
}
Esempio n. 6
0
RenderQueue* BREW::CreateSpinButtonDrawable( SharedPtr<const SpinButton> spinbutton ) const {
	sf::Color border_color( GetProperty<sf::Color>( "BorderColor", spinbutton ) );
	sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", spinbutton ) );
	sf::Color text_color( GetProperty<sf::Color>( "Color", spinbutton ) );
	sf::Color cursor_color( GetProperty<sf::Color>( "Color", spinbutton ) );
	float text_padding( GetProperty<float>( "Padding", spinbutton ) );
	float cursor_thickness( GetProperty<float>( "Thickness", spinbutton ) );
	float border_width( GetProperty<float>( "BorderWidth", spinbutton ) );
	int border_color_shift( GetProperty<int>( "BorderColorShift", spinbutton ) );
	const sf::Font& font( *GetResourceManager().GetFont( GetProperty<std::string>( "FontName", spinbutton ) ) );
	const unsigned int& font_size( GetProperty<unsigned int>( "FontSize", spinbutton ) );
	float stepper_aspect_ratio( GetProperty<float>( "StepperAspectRatio", spinbutton ) );
	sf::Color stepper_color( GetProperty<sf::Color>( "StepperBackgroundColor", spinbutton ) );
	sf::Color stepper_border_color( GetProperty<sf::Color>( "BorderColor", spinbutton ) );
	sf::Color stepper_arrow_color( GetProperty<sf::Color>( "StepperArrowColor", spinbutton ) );

	RenderQueue* queue( new RenderQueue );

	// Pane.
	queue->Add(
		Renderer::Get().CreatePane(
			sf::Vector2f( 0.f, 0.f ),
			sf::Vector2f( spinbutton->GetAllocation().width, spinbutton->GetAllocation().height ),
			border_width,
			background_color,
			border_color,
			-border_color_shift
		)
	);

	float button_width = ( spinbutton->GetAllocation().height / 2.f ) * stepper_aspect_ratio;

	// Up Stepper.
	queue->Add(
		Renderer::Get().CreatePane(
			sf::Vector2f( spinbutton->GetAllocation().width - button_width - border_width, border_width ),
			sf::Vector2f( button_width, spinbutton->GetAllocation().height / 2.f - border_width ),
			border_width,
			stepper_color,
			stepper_border_color,
			spinbutton->IsIncreaseStepperPressed() ? -border_color_shift : border_color_shift
		)
	);

	// Up Stepper Triangle.
	queue->Add(
		Renderer::Get().CreateTriangle(
			sf::Vector2f( spinbutton->GetAllocation().width - button_width / 2.f - border_width, ( spinbutton->IsIncreaseStepperPressed() ? 1.f : 0.f ) + border_width + spinbutton->GetAllocation().height / 6.f ),
			sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f * 3.f - border_width, ( spinbutton->IsIncreaseStepperPressed() ? 1.f : 0.f ) + border_width + spinbutton->GetAllocation().height / 3.f ),
			sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f - border_width, ( spinbutton->IsIncreaseStepperPressed() ? 1.f : 0.f ) + border_width + spinbutton->GetAllocation().height / 3.f ),
			stepper_arrow_color
		)
	);

	// Down Stepper.
	queue->Add(
		Renderer::Get().CreatePane(
			sf::Vector2f( spinbutton->GetAllocation().width - button_width - border_width, spinbutton->GetAllocation().height / 2.f ),
			sf::Vector2f( button_width, spinbutton->GetAllocation().height / 2.f - border_width ),
			border_width,
			stepper_color,
			stepper_border_color,
			spinbutton->IsDecreaseStepperPressed() ? -border_color_shift : border_color_shift
		)
	);

	// Down Stepper Triangle.
	queue->Add(
		Renderer::Get().CreateTriangle(
			sf::Vector2f( spinbutton->GetAllocation().width - button_width / 2.f - border_width, ( spinbutton->IsDecreaseStepperPressed() ? 1.f : 0.f ) + spinbutton->GetAllocation().height - border_width - spinbutton->GetAllocation().height / 6.f ),
			sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f - border_width, ( spinbutton->IsDecreaseStepperPressed() ? 1.f : 0.f ) + spinbutton->GetAllocation().height - border_width - spinbutton->GetAllocation().height / 3.f ),
			sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f * 3.f - border_width, ( spinbutton->IsDecreaseStepperPressed() ? 1.f : 0.f ) + spinbutton->GetAllocation().height - border_width - spinbutton->GetAllocation().height / 3.f ),
			stepper_arrow_color
		)
	);

	float line_height = GetFontLineHeight( font, font_size );
	sf::Text vis_label( spinbutton->GetVisibleText(), font, font_size );
	vis_label.setColor( text_color );
	vis_label.setPosition( text_padding, spinbutton->GetAllocation().height / 2.f - line_height / 2.f );

	queue->Add( Renderer::Get().CreateText( vis_label ) );

	// Draw cursor if spinbutton is active and cursor is visible.
	if( spinbutton->HasFocus() && spinbutton->IsCursorVisible() ) {
		sf::String cursor_string( spinbutton->GetVisibleText() );
		if( spinbutton->GetCursorPosition() - spinbutton->GetVisibleOffset() < cursor_string.getSize() ) {
			cursor_string.erase( spinbutton->GetCursorPosition() - spinbutton->GetVisibleOffset(), cursor_string.getSize() );
		}

		// Get metrics.
		sf::Vector2f metrics( GetTextMetrics( cursor_string, font, font_size ) );

		queue->Add(
			Renderer::Get().CreateRect(
				sf::FloatRect(
					metrics.x + text_padding,
					spinbutton->GetAllocation().height / 2.f - line_height / 2.f,
					cursor_thickness,
					line_height
				),
				cursor_color
			)
		);
	}

	return queue;
}