示例#1
0
int main(void) {
	uint8_t i;
	font_t	font1, font2;

	/* initialize and clear the display */
	gfxInit();

	/* Set some fonts */
	font1 = gdispOpenFont("UI2");
	font2 = gdispOpenFont("DejaVu Sans 12");
	gwinSetDefaultFont(font1);

	/* create the three console windows */
	{
		GWindowInit		wi;

		wi.show = TRUE;
		wi.x = 0; wi.y = 0; wi.width = gdispGetWidth(); wi.height = gdispGetHeight()/2;
		GW1 = gwinConsoleCreate(NULL, &wi);
		wi.y = gdispGetHeight()/2; wi.width = gdispGetWidth()/2; wi.height = gdispGetHeight();
		GW2 = gwinConsoleCreate(NULL, &wi);
		wi.x = gdispGetWidth()/2; wi.height = gdispGetHeight();
		GW3 = gwinConsoleCreate(NULL, &wi);
	}

	/* Use a special font for GW1 */
	gwinSetFont(GW1, font2);

	/* Set the fore- and background colors for each console */
	gwinSetColor(GW1, Green);
	gwinSetBgColor(GW1, Black);
	gwinSetColor(GW2, White);
	gwinSetBgColor(GW2, Blue);
	gwinSetColor(GW3, Black);
	gwinSetBgColor(GW3, Red);

	/* clear all console windows - to set background */
	gwinClear(GW1);
	gwinClear(GW2);
	gwinClear(GW3);

	/* Output some data on the first console */
	for(i = 0; i < 10; i++) {
		gwinPrintf(GW1, "Hello uGFX!\r\n");
	}

	/* Output some data on the second console */
	for(i = 0; i < 16; i++) {
		gwinPrintf(GW2, "Message Nr.: %d\r\n", i+1);
	}

	/* Output some data on the third console */
	for(i = 0; i < 18; i++) {
		gwinPrintf(GW3, "Message Nr.: %d\r\n", i+1);
	}

	while(TRUE) {
		gfxSleepMilliseconds(500);
	}
}
示例#2
0
GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font) {
	if (!(gc = (GConsoleObject *)_gwinInit((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject))))
		return 0;
	gc->gwin.type = GW_CONSOLE;
	gwinSetFont(&gc->gwin, font);
	gc->stream.vmt = &GWindowConsoleVMT;
	gc->cx = 0;
	gc->cy = 0;
	return (GHandle)gc;
}
示例#3
0
static void createSettingsFrame(void)
{
	GWidgetInit wi;

	gwinWidgetClearInit(&wi);
	wi.g.show = FALSE;

	wi.g.width = 320;
	wi.g.height = 190;
	wi.g.y = 25;
	wi.g.x = 0;
	wi.text = "Settings";
	ghFrame1 = gwinFrameCreate(0, &wi, GWIN_FRAME_CLOSE_BTN);// | GWIN_FRAME_MINMAX_BTN);

	// Apply some default values for GWIN
	wi.customDraw = 0;
	wi.customParam = 0;
	wi.customStyle = 0;
	wi.g.show = true;

	// Apply the list parameters
	wi.g.width = 65;
	wi.g.height = 50;
	wi.g.y = 10;
	wi.g.x = 10;
	wi.text = "Month";
	wi.g.parent = ghFrame1;

	// Create the actual list
	ghListMonth = gwinListCreate(NULL, &wi, FALSE);
	char item[20];
	int i = 0;
	for (i = 0; i < 12; i++) {
		sprintf(item, "%s", months[i]);
		gwinListAddItem(ghListMonth, item, true);
	}
	gwinListSetScroll(ghListMonth, scrollSmooth);

	// Apply some default values for GWIN
	wi.customDraw = 0;
	wi.customParam = 0;
	wi.customStyle = 0;
	wi.g.show = true;

	// Apply the list parameters
	wi.g.width = 25;
	wi.g.height = 50;
	wi.g.y = 10;
	wi.g.x = 80;
	wi.text = "Day";
	wi.g.parent = ghFrame1;

	// Create the actual list
	ghListDay = gwinListCreate(NULL, &wi, FALSE);
	for (i = 1; i <= 31; i++) {
		sprintf(item, "%i", i);
		gwinListAddItem(ghListDay, item, true);
	}
	gwinListSetScroll(ghListDay, scrollSmooth);

	// Apply some default values for GWIN
	wi.customDraw = 0;
	wi.customParam = 0;
	wi.customStyle = 0;
	wi.g.show = true;

	// Apply the list parameters
	wi.g.width = 45;
	wi.g.height = 50;
	wi.g.y = 10;
	wi.g.x = 110;
	wi.text = "Year";
	wi.g.parent = ghFrame1;

	// Create the actual list
	ghListYear = gwinListCreate(NULL, &wi, FALSE);
	for (i = 2016; i <= 2030; i++) {
		sprintf(item, "%i", i);
		gwinListAddItem(ghListYear, item, true);
	}
	gwinListSetScroll(ghListYear, scrollSmooth);

	wi.g.width = 25;
	wi.g.height = 50;
	wi.g.y = 10;
	wi.g.x = 160;
	wi.text = "Hour";
	wi.g.parent = ghFrame1;

	// Create the actual list
	ghListHour = gwinListCreate(NULL, &wi, FALSE);
	for (i = 1; i <= 24; i++) {
		sprintf(item, "%i", i);
		gwinListAddItem(ghListHour, item, true);
	}
	gwinListSetScroll(ghListHour, scrollSmooth);

	wi.g.width = 25;
	wi.g.height = 50;
	wi.g.y = 10;
	wi.g.x = 190;
	wi.text = "Min";
	wi.g.parent = ghFrame1;

	// Create the actual list
	ghListMin = gwinListCreate(NULL, &wi, FALSE);
	for (i = 1; i <= 60; i++) {
		sprintf(item, "%i", i);
		gwinListAddItem(ghListMin, item, true);
	}
	gwinListSetScroll(ghListMin, scrollSmooth);

	// create Slider1
	wi.g.y = 10; wi.g.x = 235; wi.g.width = 20; wi.g.height = 100; wi.text = "B";
	wi.g.parent = ghFrame1;
	ghSliderBl = gwinSliderCreate(NULL, &wi);

	// create Slider2
	wi.g.y = 10; wi.g.x = 260; wi.g.width = 20; wi.g.height = 100; wi.text = "C";
	wi.g.parent = ghFrame1;
	ghSliderCt = gwinSliderCreate(NULL, &wi);

	// Apply the checkbox parameters
	wi.g.width = 60;        // includes text
	wi.g.height = 20;
	wi.g.y = 75;
	wi.g.x = 10;
	wi.text = " 12 Hr";
	ghCheckBoxHR = gwinCheckboxCreate(NULL, &wi);

	// create button widget: ghBtnSettings
	wi.g.show = TRUE;
	wi.g.x = 235;
	wi.g.y = 130;
	wi.g.width = 50;
	wi.g.height = 27;
	wi.g.parent = ghFrame1;
	wi.text = "Save";
	wi.customDraw = gwinButtonDraw_Rounded;
	//wi.customParam = &iconSettings;
	//wi.customStyle = &WhiteWidgetStyle;
	ghBtnSave = gwinButtonCreate(0, &wi);
	gwinSetFont(ghBtnSave, dejavu_sans_16_anti_aliased_u);

	// Create label widget: ghlblDateTime
	wi.g.show = TRUE;
	wi.g.x = 75;
	wi.g.y = 75;
	wi.g.width = 150;
	wi.g.height = 17;
	wi.g.parent = ghFrame1;
	wi.text = "00/00/00 00:00:00";
	wi.customDraw = gwinLabelDrawJustifiedLeft;
	wi.customParam = 0;
	//wi.customStyle = &syBar;
	ghlblDateTime = gwinLabelCreate(0, &wi);
	gwinLabelSetBorder(ghlblDateTime, FALSE);
	gwinSetFont(ghlblDateTime, dejavu_sans_16_anti_aliased_u);
	gwinRedraw(ghlblDateTime);
}
示例#4
0
文件: main.c 项目: bhdminh/uGFX
int main(void) {
	uint8_t i;
	font_t	font1, font2;

	/* initialize and clear the display */
	gfxInit();

	/* Set some fonts */
	font1 = gdispOpenFont("UI2");
	font2 = gdispOpenFont("DejaVu Sans 12");
	gwinSetDefaultFont(font1);

	/* create the three console windows */
	{
		GWindowInit		wi;

		gwinClearInit(&wi);
		wi.show = TRUE;
		wi.x = 0; wi.y = 0; wi.width = gdispGetWidth(); wi.height = gdispGetHeight()/2;
		GW1 = gwinConsoleCreate(0, &wi);
		wi.y = gdispGetHeight()/2; wi.width = gdispGetWidth()/2; wi.height = gdispGetHeight();
		GW2 = gwinConsoleCreate(0, &wi);
		wi.x = gdispGetWidth()/2; wi.height = gdispGetHeight();
		GW3 = gwinConsoleCreate(0, &wi);
	}

	/* Use a special font for GW1 */
	gwinSetFont(GW1, font2);

	/* Set the fore- and background colors for each console */
	gwinSetColor(GW1, Green);
	gwinSetBgColor(GW1, Black);
	gwinSetColor(GW2, White);
	gwinSetBgColor(GW2, Blue);
	gwinSetColor(GW3, Black);
	gwinSetBgColor(GW3, Red);

	/* clear all console windows - to set background */
	gwinClear(GW1);
	gwinClear(GW2);
	gwinClear(GW3);

	/* Output some data on the first console */
	for(i = 0; i < 10; i++) {
		gwinPrintf(GW1, "Hello \033buGFX\033B!\n");
	}

	/* Output some data on the second console - Fast */
	for(i = 0; i < 32; i++) {
		gwinPrintf(GW2, "Message Nr.: \0331\033b%d\033B\033C\n", i+1);
	}

	/* Output some data on the third console - Slowly */
	for(i = 0; i < 32; i++) {
		gwinPrintf(GW3, "Message Nr.: \033u%d\033U\n", i+1);
		gfxSleepMilliseconds(500);
	}

	/* Make console 3 invisible and then visible again to demonstrate the history buffer */
	gwinPrintf(GW2, "Making red window \033uinvisible\033U\n");
	gwinSetVisible(GW3, FALSE);
	gfxSleepMilliseconds(1000);
	gwinPrintf(GW2, "Making red window \033uvisible\033U\n");
	gwinSetVisible(GW3, TRUE);
	gwinPrintf(GW3, "\033bI'm back!!!\033B\n", i+1);

	while(TRUE) {
		gfxSleepMilliseconds(500);
	}
}