Difference between revisions of "Label"

From uGFX Wiki
Jump to: navigation, search
(Created page with "== Example == <syntaxhighlight lang="php"> #include "gfx.h" static GHandle ghLabel1; static void createWidgets(void) { GWidgetInit wi; // Apply some default values fo...")
(No difference)

Revision as of 01:36, 30 June 2014

Example

#include "gfx.h"
 
static GHandle ghLabel1;
 
static void createWidgets(void) {
	GWidgetInit		wi;
 
	// Apply some default values for GWIN
	wi.customDraw = 0;
	wi.customParam = 0;
	wi.customStyle = 0;
	wi.g.show = TRUE;
 
	// Apply the label parameters	
	wi.g.y = 10;
	wi.g.x = 10;
	wi.g.width = 100;
	wi.g.height = 20;
	wi.text = "Label 1";
 
	// Create the actual label
	ghLabel1 = gwinLabelCreate(NULL, &wi);
}
 
int main(void) {
	// Initialize the display
	gfxInit();
 
	// Set the widget defaults
	gwinSetDefaultFont(gdispOpenFont("UI2"));
	gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);
	gdispClear(White);
 
	// create the widget
	createWidgets();
 
	while(1) {
		gwinSetText(ghLabel1, "This is some text", TRUE);
		gfxSleepMilliseconds(1000);
		gwinSetText(ghLabel1, "Aaaand some other text", TRUE);
		gfxSleepMilliseconds(1000);
	}
 
	return 0;
}