Пример #1
0
bool exit_handler(PG_Pointer clientdata) {

	// we can pass in some pointer to any userdata
	// (in this case we get a pointer to the application object)
	PG_Application* app = (PG_Application*) clientdata;

	// exit the application eventloop
	app->Quit();

	// return true to signal that we have processed this message
	return true;
}
Пример #2
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;
}
Пример #3
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;
}
Пример #4
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;
}
Пример #5
0
bool exit_handler(PG_Pointer clientdata) {
    PG_Application* app = (PG_Application*) clientdata;
    app->Quit();
    return true;
}
Пример #6
0
int main(int argc, char *argv[])
{

  app.SetEmergencyQuit(true);
  app.LoadTheme("default");
	int i;
	int rgb_size[3];
	int w = 640;
	int h = 480;
  int bpp=16;

	Uint32 video_flags;
	int value;

	if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
		fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
		exit( 1 );
  }


	/* Set the flags we want to use for setting the video mode */
	video_flags = SDL_OPENGLBLIT;

	for ( i=1; argv[i]; ++i ) {
		if ( strcmp(argv[i], "-fullscreen") == 0 ) {
			video_flags |= SDL_FULLSCREEN;
		}
	}

	/* Initialize the display */
	switch (bpp) {
	    case 8:
		rgb_size[0] = 2;
		rgb_size[1] = 3;
		rgb_size[2] = 3;
		break;
	    case 15:
	    case 16:
		rgb_size[0] = 5;
		rgb_size[1] = 6;
		rgb_size[2] = 5;
		break;
		default:
		rgb_size[0] = 8;
		rgb_size[1] = 8;
		rgb_size[2] = 8;
		break;
	}
	SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
	SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
	SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
	SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );



  if (!app.InitScreen(640, 480, 0, video_flags)) {
      fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
     exit(1);
  }
	app.EnableBackground();
 	SDL_WM_SetCaption( "MadIVS", "madivs" );




  GLWidget gl_view1(NULL, PG_Rect(100,100,200,200));
	new PG_Label(&gl_view1, PG_Rect(0,0,90,20), "GL View 1");


    // now we have to make the button visible

  gl_view1.Show();

	PG_Button* btn1 = new PG_Button(NULL, 1, PG_Rect(30,30,100,50), "Quit");
	btn1->Show();


	PG_Rect rs(0,0, PG_Application::GetScreenWidth(), PG_Application::GetScreenHeight());
  PG_Widget::UpdateRect(rs);
  SDL_UpdateRects(SDL_GetVideoSurface(), 1, &rs);
	
  int done=0;	
	while( !done ) {
		GLenum gl_error;
		char* pg_error;
		SDL_Event event;


		gl_view1.Update();

		glRotatef(1, 1.0, 1.0, 1.0);

		SDL_GL_SwapBuffers( );

		/* Check for error conditions. */
		gl_error = glGetError( );

		if( gl_error != GL_NO_ERROR ) {
			fprintf( stderr, "testgl: OpenGL error: %d\n", gl_error );
		}

		pg_error = SDL_GetError( );

		if( pg_error[0] != '\0' ) {
			fprintf(stderr, "testgl: SDL error '%s'\n", pg_error);
			SDL_ClearError();
		}


		/* Check if there's a pending event. */
/*		if ( SDL_PollEvent( &event ) ) {
			HandleEvent(&event, &app);
		}*/
		

	}


	return(0);
}