Exemple #1
0
void redraw_screen(void)
{
	GP_Fill(win, gray_pixel);

	GP_TextStyle style = GP_DEFAULT_TEXT_STYLE;

	switch (font_flag) {
	case 0:
		style.font = &GP_DefaultConsoleFont;
	break;
	case 1:
		style.font = &GP_DefaultProportionalFont;
	break;
	case 2:
		style.font = GP_FontTinyMono;
	break;
	case 3:
		style.font = GP_FontTiny;
	break;
	case 4:
		style.font = GP_FontC64;
	break;
	case 5:
		style.font = font;
	break;
	}

	style.pixel_xmul = mul;
	style.pixel_ymul = mul;
	style.pixel_xspace = space;
	style.pixel_yspace = space;
	style.char_xspace = tracking;

	/* Text alignment (we are always drawing to the right
	 * and below the starting point).
	 */
	int align = GP_ALIGN_RIGHT|GP_VALIGN_BELOW;

	struct FileLine *line = first_line;
	unsigned int i;
	for (i = 0; i < win->h/GP_TextHeight(&style); i++) {
		if (line == NULL)
			break;
		GP_Text(win, &style, 16, 16 + (1.0 * GP_TextHeight(&style))*i,
		        align, black_pixel, gray_pixel, line->text);
		line = line->next;
	}
}
Exemple #2
0
void redraw_screen(void)
{
	GP_Fill(win->context, black_pixel);

	GP_TextStyle style = GP_DEFAULT_TEXT_STYLE;

	switch (font_flag) {
	case 0:
		style.font = &GP_DefaultProportionalFont;
	break;
	case 1:
		style.font = &GP_DefaultConsoleFont;
	break;
	case 2:
		style.font = GP_FontTiny;
	break;
	case 3:
		style.font = GP_FontTinyMono;
	break;
	case 4:
		style.font = font;
	break;
	}

	print_font_properties(style.font);

	/* Text alignment (we are always drawing to the right
	 * and below the starting point).
	 */
	int align = GP_ALIGN_RIGHT|GP_VALIGN_BELOW;

	const size_t TEST_STRING_COUNT = sizeof(test_strings)/sizeof(const char *);
	size_t i;
	for (i = 0; i < TEST_STRING_COUNT; i++) {
		const char *test_string = test_strings[i];

		style.pixel_xmul = 1;
		style.pixel_ymul = 1;
		style.pixel_xspace = 0;
		style.pixel_yspace = 0;
		style.char_xspace = tracking;

		GP_FillRectXYWH(win->context,
			16, SPACING*i + 16,
			GP_TextWidth(&style, test_string),
			GP_FontHeight(style.font),
			dark_gray_pixel);

		GP_RectXYWH(win->context,
			15, SPACING*i + 15,
			GP_TextMaxWidth(&style, strlen(test_string)) + 1,
			GP_FontHeight(style.font) + 1,
			blue_pixel);

		GP_Text(win->context, &style, 16, SPACING*i + 16, align,
		        white_pixel, dark_gray_pixel, test_string);

		style.pixel_xmul = 2;
		style.pixel_ymul = 2;
		style.pixel_yspace = 1;

		GP_Text(win->context, &style, 34, SPACING * i + 44, align,
		        white_pixel, black_pixel, test_string);

		GP_RectXYWH(win->context, 33, SPACING * i + 43,
		            GP_TextWidth(&style, test_string) + 1,
			    GP_TextHeight(&style) + 1, dark_gray_pixel);

		style.pixel_xmul = 4;
		style.pixel_ymul = 2;

		style.pixel_xspace = 1;
		style.pixel_yspace = 1;

		if (font_flag == 2 || font_flag == 3) {
			style.pixel_xmul = 2;
			style.pixel_ymul = 5;

			style.pixel_xspace = 2;
			style.pixel_yspace = 2;
		}

		GP_Text(win->context, &style, 64, SPACING*i + 88, align,
		        dark_gray_pixel, black_pixel, test_string);
	}
}