コード例 #1
0
ファイル: main.cpp プロジェクト: plerenius/lium
/**
 *	Function that calculates a fractal and shows it in a GTK+ pixbuf
 *
 * @param[in] 	_oZmid		Center coordinate for the Mandelbrot fractal
 * @param[in] 	_oZxy		Size of the Mandelbrot window
 * @param[in] 	_rZoomFactor	Zoom factor ( Deduces the size of the window)
 * @return		Returns true success, otherwise false
 */
bool  bCalc_Fractal( void )
{
  // Create fractal
  int iSizeX=800;
  int iSizeY=800;
  Fractal  *poFractal= new Cmandelbrot( iSizeX, iSizeY);

  if(!poFractal)
    return false;
  
  bool bRet=poFractal->bCalc(oZmid,oZxy,rScale, 255);

  if (sFractal.pGDKimage2 == NULL )
  {
    sFractal.pGDKvisual2 = gdk_visual_get_system();
    sFractal.pGDKimage2= gdk_image_new( GDK_IMAGE_NORMAL, sFractal.pGDKvisual2, poFractal->iSizeX,poFractal->iSizeY);
  }

  if (sFractal.pGDKimage2 == NULL )
  {
    fprintf( stderr, "Not able to create gdkimage object\n");
    return FALSE;
  }

  if(sFractal.pWindow2== NULL)
  {
    sFractal.pWindow2= gtk_window_new(GTK_WINDOW_TOPLEVEL);
  }

  if(sFractal.pImage2==NULL)
  {
    sFractal.pImage2= gtk_image_new_from_image( sFractal.pGDKimage2, NULL );
  }
  else
  {
     gtk_image_set_from_image(GTK_IMAGE(sFractal.pImage2), sFractal.pGDKimage2, NULL );
  }

  for (int i=0; i<poFractal->iSizeX; i++)
  {
    for (int j=0; j<poFractal->iSizeY; j++)
    {
      unsigned int uiColor = poFractal->uiGetPixBufColor(i,j);
      gdk_image_put_pixel( sFractal.pGDKimage2, i, j,(int) uiColor); //65535*rAbsSqr/rMax);
    }
  }

  if(poFractal)
    delete poFractal;

  return bRet;
}
コード例 #2
0
ファイル: notebook.c プロジェクト: Sorikairo/Raytracer
void		creat_notebook(t_init *init, t_menu *menu, t_launch_infos *infos)
{
  infos->notebook->notebook = gtk_notebook_new();
  gtk_box_pack_start(GTK_BOX(init->vbox),
		     infos->notebook->notebook, TRUE, TRUE, 0);
  infos->notebook->text_view = gtk_text_view_new();
  infos->notebook->text_buffer = gtk_text_view_get_buffer(
							  GTK_TEXT_VIEW(infos->notebook->text_view));
  gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(infos->notebook->text_view),
			      GTK_WRAP_WORD);
  creat_editor(menu, infos);
  infos->notebook->tablabel = gtk_label_new("SCENE");
  infos->notebook->image = gdk_image_new(GDK_IMAGE_NORMAL,
					 gdk_visual_get_system(), 800, 600);
  infos->notebook->scene = gtk_image_new_from_image(infos->notebook->image,
						    NULL);
  gtk_notebook_append_page(GTK_NOTEBOOK(infos->notebook->notebook),
  			   infos->notebook->scene, infos->notebook->tablabel);
  gtk_notebook_set_tab_pos(GTK_NOTEBOOK(infos->notebook->notebook),
			   GTK_POS_TOP);
  gtk_notebook_set_scrollable(GTK_NOTEBOOK(infos->notebook->notebook), TRUE);
}
コード例 #3
0
ファイル: bmp.c プロジェクト: ProjectZeroSlackr/XMP
static void file_info_box_build()
{
	GtkWidget *hbox1, *vbox1;
	GtkWidget *info_exit, *info_mute;
	GtkWidget *info_unmute, *info_about;
	GtkWidget *scrw1;
	GtkWidget *expander;
	GdkVisual *visual;
	PangoFontDescription *desc;

	info_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_object_set_data(GTK_OBJECT(info_window),
					"info_window", info_window);
	gtk_window_set_title(GTK_WINDOW(info_window),"Extended Module Player");
	gtk_window_set_policy(GTK_WINDOW(info_window), FALSE, FALSE, TRUE);
	gtk_signal_connect(GTK_OBJECT(info_window), "destroy",
		GTK_SIGNAL_FUNC(gtk_widget_destroyed), &info_window);
	gtk_container_border_width(GTK_CONTAINER(info_window), 0);
	gtk_widget_realize (info_window);

	vbox1 = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(info_window), vbox1);
	gtk_object_set_data(GTK_OBJECT(vbox1), "vbox1", vbox1);
	gtk_container_border_width(GTK_CONTAINER(vbox1), 4);

	visual = gdk_visual_get_system();

	/*
	 * Image
	 */

	frame1 = gtk_event_box_new();
	gtk_object_set_data(GTK_OBJECT(frame1), "frame1", frame1);
	gtk_widget_set_size_request(frame1, 300, 128);
	gtk_box_pack_start(GTK_BOX(vbox1), frame1, FALSE, FALSE, 0);

	image = gdk_image_new(GDK_IMAGE_FASTEST, visual, 300, 128);
	ximage = GDK_IMAGE_XIMAGE(image);
	image1 = gtk_image_new_from_image(image, NULL);

	gtk_object_set_data(GTK_OBJECT(image1), "image1", image1);
	gtk_container_add (GTK_CONTAINER(frame1), image1);
	gtk_widget_set_events (frame1, GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK);
	gtk_signal_connect (GTK_OBJECT (frame1), "button_press_event",
			(GtkSignalFunc)image1_clicked, NULL);

	/*
	 * Buttons
	 */

	hbox1 = gtk_hbox_new (TRUE, 0);
	gtk_object_set_data(GTK_OBJECT(hbox1), "hbox1", hbox1);
	gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, FALSE, 0);

	info_mute = gtk_button_new_with_label("Mute");
	gtk_signal_connect (GTK_OBJECT (info_mute), "clicked",
                            (GtkSignalFunc) button_mute, NULL);
	gtk_object_set_data(GTK_OBJECT(info_mute), "info_mute", info_mute);
	gtk_box_pack_start(GTK_BOX(hbox1), info_mute, TRUE, TRUE, 0);

	info_unmute = gtk_button_new_with_label("Unmute");
	gtk_signal_connect (GTK_OBJECT (info_unmute), "clicked",
                            (GtkSignalFunc) button_unmute, NULL);
	gtk_object_set_data(GTK_OBJECT(info_unmute), "info_unmute", info_unmute);
	gtk_box_pack_start(GTK_BOX(hbox1), info_unmute, TRUE, TRUE, 0);

	info_about = gtk_button_new_with_label("About");
	gtk_signal_connect_object(GTK_OBJECT(info_about), "clicked",
			(GtkSignalFunc) aboutbox, NULL);
	gtk_object_set_data(GTK_OBJECT(info_about), "info_about", info_about);
	gtk_box_pack_start(GTK_BOX(hbox1), info_about, TRUE, TRUE, 0);

	info_exit = gtk_button_new_with_label("Close");
	gtk_signal_connect_object(GTK_OBJECT(info_exit), "clicked",
		GTK_SIGNAL_FUNC(gtk_widget_hide), GTK_OBJECT(info_window));
	gtk_object_set_data(GTK_OBJECT(info_exit), "info_exit", info_exit);
	gtk_box_pack_start(GTK_BOX(hbox1), info_exit, TRUE, TRUE, 0);

	/*
	 * Info area
	 */

	expander = gtk_expander_new("Module information");

	scrw1 = gtk_scrolled_window_new(NULL, NULL);
	gtk_object_set_data(GTK_OBJECT(scrw1), "scrw1", scrw1);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrw1),
				GTK_POLICY_ALWAYS, GTK_POLICY_AUTOMATIC);

	gtk_container_add(GTK_CONTAINER(expander), scrw1);
	gtk_box_pack_start(GTK_BOX(vbox1), expander, TRUE, TRUE, 0);

	gtk_widget_set_size_request(scrw1, 290, 200);
	text1b = gtk_text_buffer_new(NULL);
	text1 = gtk_text_view_new_with_buffer(text1b);
	desc = pango_font_description_new();
	pango_font_description_set_family(desc, "Monospace");
	gtk_widget_modify_font(text1, desc);
	pango_font_description_free(desc);
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text1), GTK_WRAP_NONE);

	gtk_object_set_data(GTK_OBJECT(text1), "text1", text1);
	gtk_container_add(GTK_CONTAINER(scrw1), text1);
	gtk_widget_realize(text1);

	gtk_widget_realize(image1);

	display = GDK_WINDOW_XDISPLAY(info_window->window);
	window = GDK_WINDOW_XWINDOW(info_window->window);
    	colormap = gdk_colormap_get_system();

	gdk_color_black(colormap, color_black);
	gdk_color_white(colormap, color_white);

	init_visual(visual);

	set_palette();
	clear_screen();

	ii->wresult = 0;

	panel_setup();
	gtk_timeout_add(50, (GtkFunction)panel_loop, NULL);
}
コード例 #4
0
ファイル: gtk-screen.c プロジェクト: DavidGriffith/tme
/* this makes a new screen: */
struct tme_gtk_screen *
_tme_gtk_screen_new(struct tme_gtk_display *display)
{
  struct tme_gtk_screen *screen, **_prev;
  GtkWidget *menu_bar;
  GtkWidget *menu;
  GtkWidget *submenu;
  GtkWidget *menu_item;
  tme_uint8_t *bitmap_data;
  unsigned int y;
#define BLANK_SIDE (16 * 8)

  /* create the new screen and link it in: */
  for (_prev = &display->tme_gtk_display_screens;
       (screen = *_prev) != NULL;
       _prev = &screen->tme_gtk_screen_next);
  screen = *_prev = tme_new0(struct tme_gtk_screen, 1);

  /* the backpointer to the display: */
  screen->tme_gtk_screen_display = display;
  
  /* there is no framebuffer connection yet: */
  screen->tme_gtk_screen_fb = NULL;

  /* the user hasn't specified a scaling yet: */
  screen->tme_gtk_screen_fb_scale
    = -TME_FB_XLAT_SCALE_NONE;

  /* we have no colorset: */
  screen->tme_gtk_screen_colorset = TME_FB_COLORSET_NONE;

  /* create the top-level window, and allow it to shrink, grow,
     and auto-shrink: */
  screen->tme_gtk_screen_window
    = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_policy(GTK_WINDOW(screen->tme_gtk_screen_window),
			FALSE, FALSE, TRUE);

  /* create the outer vertical packing box: */
  screen->tme_gtk_screen_vbox0
    = gtk_vbox_new(FALSE, 0);

  /* add the outer vertical packing box to the window: */
  gtk_container_add(GTK_CONTAINER(screen->tme_gtk_screen_window),
		    screen->tme_gtk_screen_vbox0);

  /* create the menu bar and pack it into the outer vertical packing
     box: */
  menu_bar = gtk_menu_bar_new ();
  gtk_box_pack_start(GTK_BOX(screen->tme_gtk_screen_vbox0), 
		     menu_bar,
		     FALSE, FALSE, 0);
  gtk_widget_show(menu_bar);

  /* create the Screen menu: */
  menu = gtk_menu_new();

  /* create the Screen scaling submenu: */
  submenu
    = _tme_gtk_display_menu_radio(screen,
				  _tme_gtk_screen_submenu_scaling);

  /* create the Screen scaling submenu item: */
  menu_item = gtk_menu_item_new_with_label(_("Scale"));
  gtk_widget_show(menu_item);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu);
  gtk_menu_append(GTK_MENU(menu), menu_item);

  /* create the Screen menu bar item, attach the menu to it, and 
     attach the menu bar item to the menu bar: */
  menu_item = gtk_menu_item_new_with_label("Screen");
  gtk_widget_show(menu_item);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), menu);
  gtk_menu_bar_append(GTK_MENU_BAR(menu_bar), menu_item);

  /* create an event box for the framebuffer area: */
  screen->tme_gtk_screen_event_box
    = gtk_event_box_new();

  /* pack the event box into the outer vertical packing box: */
  gtk_box_pack_start(GTK_BOX(screen->tme_gtk_screen_vbox0), 
		     screen->tme_gtk_screen_event_box,
		     FALSE, FALSE, 0);

  /* show the event box: */
  gtk_widget_show(screen->tme_gtk_screen_event_box);

  /* create a GdkImage of an alternating-bits area.  we must use
     malloc() here since this memory will end up as part of an XImage,
     and X will call free() on it: */
  bitmap_data = (tme_uint8_t *)
    malloc((BLANK_SIDE * BLANK_SIDE) / 8);
  assert(bitmap_data != NULL);
  for (y = 0;
       y < BLANK_SIDE;
       y++) {
    memset(bitmap_data
	   + (y * BLANK_SIDE / 8),
	   (y & 1
	    ? 0x33
	    : 0xcc),
	   (BLANK_SIDE / 8));
  }
  screen->tme_gtk_screen_gdkimage
    = gdk_image_new_bitmap(gdk_visual_get_system(),
			   bitmap_data,
			   BLANK_SIDE,
			   BLANK_SIDE);

  /* create the GtkImage for the framebuffer area: */
  screen->tme_gtk_screen_gtkimage
    = gtk_image_new_from_image(screen->tme_gtk_screen_gdkimage, NULL);

  /* add the GtkImage to the event box: */
  gtk_container_add(GTK_CONTAINER(screen->tme_gtk_screen_event_box), 
		    screen->tme_gtk_screen_gtkimage);

  /* show the GtkImage: */
  gtk_widget_show(screen->tme_gtk_screen_gtkimage);

  /* show the outer vertical packing box: */
  gtk_widget_show(screen->tme_gtk_screen_vbox0);

  /* show the top-level window: */
  gtk_widget_show(screen->tme_gtk_screen_window);

  /* there is no translation function: */
  screen->tme_gtk_screen_fb_xlat = NULL;

  /* attach the mouse to this screen: */
  _tme_gtk_mouse_attach(screen);

  /* attach the keyboard to this screen: */
  _tme_gtk_keyboard_attach(screen);

  return (screen);
}