Пример #1
0
// test some fgui primitives
void render_stuff(void)
{
	/* draw background */
	fgui_fill_rectangle(0, 0, WIDTH, HEIGHT, FGUI_COLOR(221,221,221));

	fgui_draw_string("Use TAB to cycle focus", 100, 1*LINEHEIGHT, 0, NULL);

	fgui_draw_string("Line", 10, 2*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_line(160, 5+2*LINEHEIGHT, 220, 5+2*LINEHEIGHT, FGUI_COLOR(31,127,31));

	fgui_draw_string("Rectangles and Circles", 10, 3*LINEHEIGHT, 0, NULL);
	fgui_draw_rectangle(160, 3*LINEHEIGHT, 10, 10, FGUI_COLOR(0,0,255));
	fgui_fill_rectangle(160+20, 3*LINEHEIGHT, 10, 10, FGUI_COLOR(31, 191, 31));
	fgui_fill_rectangle(160+40, 3*LINEHEIGHT, 10, 10, FGUI_COLOR(31, 191, 31));
	fgui_draw_rectangle(160+40, 3*LINEHEIGHT, 10, 10, FGUI_COLOR(0,0,255));

	fgui_fill_circle(160+65, 5+3*LINEHEIGHT, 5, FGUI_COLOR(255, 255, 255));
	fgui_draw_circle(160+65, 5+3*LINEHEIGHT, 5, FGUI_COLOR(120,120,120));
	fgui_fill_circle(160+65, 5+3*LINEHEIGHT, 3, FGUI_COLOR(48, 48, 152));
	fgui_draw_circle(160+65, 5+3*LINEHEIGHT, 3, FGUI_COLOR(48, 48, 192));

	fgui_fill_circle(160+85, 5+3*LINEHEIGHT, 5, FGUI_COLOR(255, 255, 255));
	fgui_draw_circle(160+85, 5+3*LINEHEIGHT, 5, FGUI_COLOR(120,120,120));
	fgui_fill_circle(160+105, 5+3*LINEHEIGHT, 5, FGUI_COLOR(255, 255, 255));
	fgui_draw_circle(160+105, 5+3*LINEHEIGHT, 5, FGUI_COLOR(120,120,120));

	fgui_fill_rectangle(10, -6+4*LINEHEIGHT, 110, 2*LINEHEIGHT+2, FGUI_COLOR(255, 255,255));
	fgui_draw_string("this colored string\nspans multiple\nlines", 10, -4+4*LINEHEIGHT,
		FGUI_COLOR(255,0,0), NULL);

	fgui_draw_string("checkbox", 10, 6*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_string("push button", 10, 7*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_string("2nd push button", 10, 8*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_string("label widget", 10, 10*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_string("combobox", 10, 9*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_string("lineedit", 10, 11*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);

	fgui_application_draw(&app);
}
Пример #2
0
void fgui_combobox_draw(struct fgui_widget *widget)
{
	size_t i;
	struct fgui_combobox *combobox = (struct fgui_combobox *)widget;
	int n = 1;
	int h = combobox->base.area.h*n;
	int x1 = combobox->base.area.x+2;
	int y1 = combobox->base.area.y;
	int x2 = x1+combobox->base.area.w-5;
	int y2 = y1+h-1;

	if (!combobox->base.has_focus && !fgui_combobox_type) { // Cheap hack
			combobox->is_expanded = false;
	} else if (combobox->is_expanded) {
		n = combobox->num_items;
		h = combobox->base.area.h*n;
		y2 = y1+h-1;
	}

	/* combobox background */
	fgui_fill_rectangle(combobox->base.area.x, combobox->base.area.y, combobox->base.area.w, h,
			FGUI_COMBOBOX_BG_COLOR);

	if (fgui_combobox_type == 0){ // Cheap hack to multipurpose combobox
	/* border */
	fgui_draw_line(x1, y1, x2, y1, FGUI_COMBOBOX_BORDER_COLOR);
	fgui_draw_line(x1, y2, x2, y2, FGUI_COMBOBOX_BORDER_COLOR);
	fgui_draw_line(x1-2, y1+2, x1-2, y2-2, FGUI_COMBOBOX_BORDER_COLOR);
	fgui_draw_line(x2+2, y1+2, x2+2, y2-2, FGUI_COMBOBOX_BORDER_COLOR);

	/* border shading */
	fgui_draw_line(x1, 1+y1, x2, 1+y1, FGUI_COMBOBOX_TOP_COLOR);
	fgui_draw_line(x1, 2+y1, x2, 2+y1, FGUI_COMBOBOX_TOQ_COLOR);
	fgui_draw_line(x1, 3+y1, x2, 3+y1, FGUI_COMBOBOX_TOR_COLOR);

	fgui_draw_line(x1, y2-1, x2, y2-1, FGUI_COMBOBOX_BOT_COLOR);
	fgui_draw_line(x1, y2-2, x2, y2-2, FGUI_COMBOBOX_BOQ_COLOR);
	fgui_draw_line(x1, y2-3, x2, y2-3, FGUI_COMBOBOX_BOR_COLOR);

	fgui_draw_line(x1-1, y1+2, x1-1, y2-2, FGUI_COMBOBOX_TOP_COLOR);
	fgui_draw_line(x2+1, y1+2, x2+1, y2-2, FGUI_COMBOBOX_BOT_COLOR);
	}

	if (combobox->is_expanded) {
		/* highlight current item */
		fgui_fill_rectangle(x1-1, y1+1 + combobox->base.area.h * combobox->current_item,
				combobox->base.area.w-2,
				combobox->base.area.h-2,
				FGUI_COMBOBOX_HIGHLIGHT_COLOR);

		for (i = 0; i < combobox->num_items; i++) {
			/* current item text */
			fgui_draw_string(combobox->items[i].text,
				x1, combobox->base.area.y+2 + combobox->base.area.h * i,
				FGUI_COMBOBOX_TEXT_COLOR, NULL);
		}
	} else {
		/* if focus, draw red border */
		if (combobox->base.has_focus) {
			fgui_draw_rectangle(combobox->base.area.x, combobox->base.area.y,
					combobox->base.area.w, combobox->base.area.h,
					FGUI_COMBOBOX_FOCUS_COLOR);
		}

		/* current item text */
		fgui_draw_string(combobox->items[combobox->current_item].text,
				x1, combobox->base.area.y+2,
				FGUI_COMBOBOX_TEXT_COLOR, NULL);

		/* draw arrow to indicate that this is a combobox */
		fgui_draw_triangle(combobox->base.area.x + combobox->base.area.w - 15,
				combobox->base.area.y + combobox->base.area.h / 2 - 2,
				combobox->base.area.x + combobox->base.area.w - 5,
				combobox->base.area.y + combobox->base.area.h / 2 - 2,
				combobox->base.area.x + combobox->base.area.w - 10,
				combobox->base.area.y + combobox->base.area.h / 2 + 3,
				FGUI_COMBOBOX_BORDER_COLOR);
	}
	if (fgui_combobox_type == 0){ // Cheap hack to multipurpose combobox
	/* draw rounded border corners */
	fgui_set_pixel(x1-1,y1+1, FGUI_COMBOBOX_BORDER_COLOR);
	fgui_set_pixel(x2+1,y1+1, FGUI_COMBOBOX_BORDER_COLOR);
	fgui_set_pixel(x1-1,y2-1, FGUI_COMBOBOX_BORDER_COLOR);
	fgui_set_pixel(x2+1,y2-1, FGUI_COMBOBOX_BORDER_COLOR);
	}
}
Пример #3
0
void fgui_label_draw(struct fgui_widget *widget)
{
	struct fgui_label *label = (struct fgui_label *)widget;
	fgui_draw_string(label->text, label->base.area.x, label->base.area.y,
			LABEL_TEXT_COLOR, &label->base.area);
}
Пример #4
0
// test some fgui primitives
void render_stuff(void)
{
	/* draw background */
	fgui_fill_rectangle(0, 0, WIDTH, HEIGHT, FGUI_COLOR(221,221,221));

	fgui_draw_string("Use TAB to cycle focus", 50, 1*LINEHEIGHT, 0, NULL);

	fgui_draw_string("line:", 50, 2*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_line(200, 2*LINEHEIGHT, 220, 2*LINEHEIGHT, FGUI_COLOR(0,255,0));

	fgui_draw_string("empty rectangle", 50, 3*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_rectangle(200, 3*LINEHEIGHT, 10, 10, FGUI_COLOR(0,0,255));

	fgui_draw_string("filled rectangle", 50, 4*LINEHEIGHT, 0, NULL);
	fgui_fill_rectangle(200, 4*LINEHEIGHT, 10, 10, FGUI_COLOR(0, 255, 0));

	fgui_draw_string("circle", 50, 5*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_circle(200, 5*LINEHEIGHT, 5, FGUI_COLOR(255, 255, 255));

	//fgui_draw_triangle(50, 50, 55, 55, 60, 50, 0xff);

	fgui_draw_string("this colored string\nspans multiple\nlines", 200, 6*LINEHEIGHT,
		FGUI_COLOR(255,0,0), NULL);

	fgui_draw_string("push button", 50, 8*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_string("2nd push button", 50, 9*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_string("label widget", 50, 11*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_string("combobox", 50, 10*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);
	fgui_draw_string("lineedit", 50, 12*LINEHEIGHT, FGUI_COLOR(0,0,0), NULL);

	fgui_application_draw(&app);
}