Exemple #1
0
int main(int argc, char* argv[]) {
	char theme[20];
	strcpy(theme, "simple");

	// initial flags for screensurface
	Uint32 flags = SDL_SWSURFACE|SDL_HWPALETTE;
	int bpp = 16;

	// construct the application object
	PG_Application app;
	
	if(!app.LoadTheme(theme)) {
	    printf("Unable to load theme \"%s\"", theme);
	    return -1;
	}
	
	if(!app.InitScreen(640, 480, bpp, flags)){
		printf("Resolution not supported\n");
		exit(-1);
	}

	PG_ColorSelector colorsel1(NULL, PG_Rect(10,10,300,150));
	colorsel1.Show();

	PG_Gradient g;
	g.colors[0].r = 255;
	g.colors[0].g = 0;
	g.colors[0].b = 0;
	
	g.colors[1].r = 0;
	g.colors[1].g = 255;
	g.colors[1].b = 0;
	
	g.colors[2].r = 0;
	g.colors[2].g = 0;
	g.colors[2].b = 255;
	
	g.colors[3].r = 255;
	g.colors[3].g = 255;
	g.colors[3].b = 255;
	
	PG_ColorSelector colorsel2(NULL, PG_Rect(10,170,300,150));
	colorsel2.SetColorGradient(g);
	colorsel2.Show();
	
	app.SetEmergencyQuit(true);
    app.Run();

	return EXIT_SUCCESS;
}
Exemple #2
0
int main(int argc,char *argv[])

{
	// init application, pretty usual
	PG_Application app;
	app.SetEmergencyQuit(true);
	app.LoadTheme("default");
	app.InitScreen(800,600,32,SDL_SWSURFACE);

	// init cairo, more interesting
	cr = cairo_create();
	char* image = (char*)PG_Application::GetScreen()->pixels;
	int width = PG_Application::GetScreenWidth();
	int height = PG_Application::GetScreenHeight();
	int stride = PG_Application::GetScreen()->pitch;
	
	cairo_set_target_image(cr, image, CAIRO_FORMAT_ARGB32, width, height, stride);
	
	// connect PG_Button::sigBlit to cairoBlitButton
	PG_Button::sigBlit.connect(slot(cairoBlitButton));

	PG_Button btn1(NULL, PG_Rect(300,400,200,50), "Button 1");
	btn1.Show();

	CMyWindow win1(NULL, PG_Rect(200,200,360,290), "CAIRO sample", PG_Window::DEFAULT);
	win1.Show();

	CMyWindow win2(NULL, PG_Rect(50,50,200,350), "CAIRO sample", PG_Window::DEFAULT);
	win2.Show();

	CMyWindow win3(NULL, PG_Rect(100,80,400,200), "CAIRO sample", PG_Window::DEFAULT);
	win3.Show();

	app.Run();
	
	return 0;
}
Exemple #3
0
int main( int argc, char **argv )
{
	PG_Application app;
	
	app.LoadTheme( "default" );
	
	app.InitScreen( 640, 480, 0 );
	app.SetEmergencyQuit(true);
	
	PG_Label l( NULL, PG_Rect(10,50,250,25), NULL );
	l.Show();
	
	PG_TabBar bar( NULL, PG_Rect(10, 10, 300, 33) );
	bar.sigTabSelect.connect(slot(handleTab), &l);
	bar.Show();
	
	bar.AddTab("Tab1");
	bar.AddTab("Tab2");
	bar.AddTab("Tab3");
	bar.AddTab("MoreTab1");
	bar.AddTab("MoreTab2");
	bar.AddTab("MoreTab3");
	bar.AddTab("EvenLongerTab1");
	bar.AddTab("Tab4");
	
	PG_NoteBook notebook(NULL, PG_Rect(50, 100, 300, 200));
	
	notebook.sigPageSelect.connect(slot(handlePageSelect));
	
	PG_Button b(NULL, 1, PG_Rect(0,0,10,10), "Big fat button");
	b.sigButtonClick.connect(slot(handleBigFatButton));
	
	notebook.AddPage("button", &b, slot(handlePageButton));
	
	PG_Widget* custom = notebook.CreatePage("custom", slot(handlePageCustom));
	custom->SetID(2);
	PG_Label label(custom, PG_Rect(5,5,100,25), "My Page");
	PG_CheckButton check(custom, -1, PG_Rect(5,35,150,25), "Check me");
	
	PG_ListBox listpage(NULL, PG_Rect(0,0,300,100));
	listpage.AddItem(new PG_ListBoxItem(25, "Item1"));
	listpage.AddItem(new PG_ListBoxItem(25, "Item2"));
	listpage.AddItem(new PG_ListBoxItem(25, "Item3"));
	listpage.AddItem(new PG_ListBoxItem(25, "Item4"));
	listpage.AddItem(new PG_ListBoxItem(25, "Item5"));
	listpage.AddItem(new PG_ListBoxItem(25, "Item6"));
	listpage.AddItem(new PG_ListBoxItem(25, "Item7"));
	listpage.AddItem(new PG_ListBoxItem(25, "Item8"));
	listpage.AddItem(new PG_ListBoxItem(25, "Item9"));
	listpage.AddItem(new PG_ListBoxItem(25, "Item10"));
	listpage.SetID(3);
	
	notebook.AddPage("list", &listpage);

	PG_NoteBook subnotebook(NULL, PG_Rect(0,0,100,100));
	
	PG_Widget* complex = subnotebook.CreatePage("custom2");
	PG_Button b2(complex, -1, PG_Rect(10,10,100,25), "Button");
	
	subnotebook.AddPage("button2", new PG_Button(NULL, -1, 	PG_Rect(0,0,10,10), "Not so big button"));
	
	notebook.AddPage("complex", &subnotebook);
	
	notebook.Show();
	
	app.Run();
	
	return 0;
}