示例#1
0
文件: about.c 项目: timxx/zenity
static GtkWidget *
zenity_create_monk (void)
{
  GtkWidget *canvas_board;
  GnomeCanvasItem *canvas_item;
  GdkPixbuf *pixbuf;
  GdkColor color = { 0, 0xffff, 0xffff, 0xffff };

  canvas_board = gnome_canvas_new ();

  gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas_board), 0, 0,
                                  ZENITY_CANVAS_X, ZENITY_CANVAS_Y);

  gtk_widget_set_size_request (canvas_board, ZENITY_CANVAS_X, ZENITY_CANVAS_Y);

  gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (canvas_board)),
                            &color, FALSE, TRUE);

  gtk_widget_modify_bg (GTK_WIDGET (canvas_board), GTK_STATE_NORMAL, &color);

  pixbuf = gdk_pixbuf_new_from_file (ZENITY_CLOTHES_PATH "monk.png", NULL);

  canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root),
                                       GNOME_TYPE_CANVAS_PIXBUF,
                                       "x", (ZENITY_CANVAS_X / 2.0)/2.0 + 10.0,
                                       "y", (ZENITY_CANVAS_Y / 2.0)/2.0 - 50.0,
                                       "pixbuf", pixbuf,
                                       "anchor", GTK_ANCHOR_NW,
                                       NULL);

  zenity_create_clothes (canvas_board);

  return canvas_board;
}
示例#2
0
文件: diagwin.C 项目: ggcov/ggcov
void
diagwin_t::populate()
{
    GnomeCanvasGroup *root = gnome_canvas_root(GNOME_CANVAS(canvas_));

    _log.debug("diagwin_t::populate\n");

    while (root->item_list != 0)
    {
	gtk_object_destroy(GTK_OBJECT(root->item_list->data));
    }

    set_diagram_colors(diagram_);
    diagram_->prepare();

    scenegen_t *sg = new canvas_scenegen_t(GNOME_CANVAS(canvas_));
    diagram_->render(sg);
    delete sg;

    /* setup the canvas to show the whole diagram */
    dbounds_t bounds;
    diagram_->get_bounds(&bounds);
    gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas_),
				   bounds.x1, bounds.y1,
				   bounds.x2, bounds.y2);

    if (!GTK_WIDGET_REALIZED(canvas_))
	gtk_signal_connect(GTK_OBJECT(canvas_), "realize",
			   GTK_SIGNAL_FUNC(diagwin_realize_cb), 0);
    else
	zoom_all();
}
示例#3
0
static int configure( Tcl_Interp *interp, CanvasParams *para,
      GnoclOption options[] )
{
   if( options[scrollRegionIdx].status == GNOCL_STATUS_CHANGED )
   {
      Tcl_Obj *obj = options[scrollRegionIdx].val.obj;
      int     k, no;
      double  val[4];   /* x, y, w, h */

      if( Tcl_ListObjLength( interp, obj, &no ) != TCL_OK 
         || no != 4 )
      {
         Tcl_SetResult( interp, 
               "scrollRegion must be proper list with four members", 
               TCL_STATIC );
         return TCL_ERROR;
      }
      for( k = 0; k < no; ++k )
      {
         Tcl_Obj *tp;
         if( Tcl_ListObjIndex( interp, obj, k, &tp ) != TCL_OK )
            return TCL_ERROR;
         if( Tcl_GetDoubleFromObj( interp, tp, &val[k] ) )
            return TCL_ERROR;
      }
      gnome_canvas_set_scroll_region( para->canvas, 
            val[0], val[1], val[0] + val[2], val[1] + val[3] ); 
   }

   if( options[pixelPerUnitIdx].status == GNOCL_STATUS_CHANGED )
   {
      gnome_canvas_set_pixels_per_unit( para->canvas, 
            options[pixelPerUnitIdx].val.d );
   }

   if( options[centerScrollIdx].status == GNOCL_STATUS_CHANGED )
   {
      gnome_canvas_set_center_scroll_region( para->canvas, 
            options[centerScrollIdx].val.b );
   }

#if 0
   if( popt->scrollbar.changed )
   {
      GtkPolicyType hor, vert;
      if( gnoclGetScrollbarPolicy( interp, popt->scrollbar.val, 
            &hor, &vert ) != TCL_OK )
         return TCL_ERROR;

      gtk_scrolled_window_set_policy( para->scrollWin, hor, vert );
   }
#endif

   return TCL_OK;
}
示例#4
0
GtkWidget * ui_common_create_view_axis_indicator(AmitkLayout layout) {

  GtkWidget * axis_indicator;
  AmitkView i_view;

#ifdef AMIDE_LIBGNOMECANVAS_AA
  axis_indicator = gnome_canvas_new_aa();
#else
  axis_indicator = gnome_canvas_new();
#endif
  switch(layout) {
  case AMITK_LAYOUT_ORTHOGONAL:
    gtk_widget_set_size_request(axis_indicator, 2.0*AXIS_WIDTH, 2.0*ORTHOGONAL_AXIS_HEIGHT);
    gnome_canvas_set_scroll_region(GNOME_CANVAS(axis_indicator), 0.0, 0.0, 
				   2.0*AXIS_WIDTH, 2.0*ORTHOGONAL_AXIS_HEIGHT);
    ui_common_draw_view_axis(GNOME_CANVAS(axis_indicator), 0, 0, AMITK_VIEW_TRANSVERSE, 
			     layout, AXIS_WIDTH, ORTHOGONAL_AXIS_HEIGHT);
    ui_common_draw_view_axis(GNOME_CANVAS(axis_indicator), 1, 0, AMITK_VIEW_CORONAL, 
			     layout, AXIS_WIDTH, ORTHOGONAL_AXIS_HEIGHT);
    ui_common_draw_view_axis(GNOME_CANVAS(axis_indicator), 0, 1, AMITK_VIEW_SAGITTAL, 
			     layout, AXIS_WIDTH, ORTHOGONAL_AXIS_HEIGHT);

    break;
  case AMITK_LAYOUT_LINEAR:
  default:
    gtk_widget_set_size_request(axis_indicator, 3.0*AXIS_WIDTH, LINEAR_AXIS_HEIGHT);
    gnome_canvas_set_scroll_region(GNOME_CANVAS(axis_indicator), 0.0, 0.0, 
				   3.0*AXIS_WIDTH, LINEAR_AXIS_HEIGHT);
    for (i_view=0;i_view< AMITK_VIEW_NUM;i_view++)
      ui_common_draw_view_axis(GNOME_CANVAS(axis_indicator), 0, i_view, i_view,
			       layout, AXIS_WIDTH, LINEAR_AXIS_HEIGHT);
    break;
  }


  return GTK_WIDGET(axis_indicator);
}
示例#5
0
void
gnc_header_reconfigure (GncHeader *header)
{
    GnomeCanvas *canvas;
    GtkWidget *widget;
    GnucashSheet *sheet;
    SheetBlockStyle *old_style;
    int w, h;

    g_return_if_fail (header != NULL);
    g_return_if_fail (GNC_IS_HEADER (header));

    canvas = GNOME_CANVAS_ITEM(header)->canvas;
    widget = GTK_WIDGET (header->sheet);
    sheet = GNUCASH_SHEET(header->sheet);
    old_style = header->style;

    header->style = gnucash_sheet_get_style_from_cursor
                    (sheet, header->cursor_name);

    if (header->style == NULL)
        return;

    sheet->width = header->style->dimensions->width;

    w = header->style->dimensions->width;
    h = header->style->dimensions->height;
    h *= header->num_phys_rows;
    h /= header->style->nrows;
    h += 2;

    if (header->height != h ||
            header->width != w  ||
            header->style != old_style)
    {
        header->height = h;
        header->width = w;

        gnome_canvas_set_scroll_region (GNOME_CANVAS(canvas),
                                        0, 0, w, h);

        gtk_widget_set_size_request (GTK_WIDGET(canvas), -1, h);

        gnc_header_request_redraw (header);
    }
}
示例#6
0
static TEG_STATUS canvas_create_map( void )
{
	char *filename;
	GnomeCanvasGroup* root;
	GdkPixbuf *im;
	GnomeCanvasItem *image;

	gtk_widget_push_colormap (gdk_rgb_get_cmap ());
	canvas_map = gnome_canvas_new ();
	root = gnome_canvas_root(GNOME_CANVAS(canvas_map));

	filename = theme_load_file( gui_theme.board );

	im = gdk_pixbuf_new_from_file(filename, NULL);

	if (im){
		image = gnome_canvas_item_new (
				root,
				gnome_canvas_pixbuf_get_type (),
				"pixbuf", im,
				"x", 0.0,
				"y", 0.0,
				"width", (double) gdk_pixbuf_get_width(im),
				"height", (double) gdk_pixbuf_get_height(im),
				"anchor", GTK_ANCHOR_NW,
				NULL);
		canvas_create_countries(root);
		armies_init(root);
		dices_init(root);
		gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas_map),0,0,gdk_pixbuf_get_width(im),gdk_pixbuf_get_height(im));

		gdk_pixbuf_unref(im);

	} else {
		g_warning (_("Could not find the %s file"),gui_theme.board);
		return TEG_STATUS_ERROR;
	}


	gtk_widget_pop_colormap ();
	gtk_widget_pop_visual ();

	return TEG_STATUS_SUCCESS;
}
示例#7
0
static void midi_section_init(MidiSection* self)
{
    MidiSectionPrivate* p = MIDI_SECTION_GET_PRIVATE(self);
    GtkBox* box = GTK_BOX(self);
    GtkWidget* pad;
    GtkWidget* view;
    GtkWidget* scroll;
    GnomeCanvas* canvas;
    GnomeCanvasPoints* points;
    int x1, x2, y1, y2;

    p->patch = -1;
    p->ignore = FALSE;
    x1 = 0;
    y1 = 0;
    x2 = (PHIN_KEYBOARD_KEY_WIDTH * MIDI_NOTES);
    y2 = HEIGHT;

    /* adjustment */
    p->adj = (GtkAdjustment*) gtk_adjustment_new(0, 0, 0, 0, 0, 0);

    /* viewport */
    view = gtk_viewport_new(p->adj, NULL);
    gtk_box_pack_start(box, view, FALSE, FALSE, 0);
    gtk_viewport_set_shadow_type(GTK_VIEWPORT(view), GTK_SHADOW_NONE);
    gtk_widget_set_size_request(view, 0, y2);
    gtk_widget_show(view);

    /* canvas */
    canvas = (GnomeCanvas*) gnome_canvas_new();
    gtk_widget_set_size_request(GTK_WIDGET(canvas), x2,	y2);
    gnome_canvas_set_scroll_region(canvas, 0, 0, x2 - 1, y2 -1);
    gtk_container_add(GTK_CONTAINER(view), GTK_WIDGET(canvas));
    g_signal_connect(G_OBJECT(canvas), "event",
		     G_CALLBACK(range_cb), (gpointer)p);
    gtk_widget_show(GTK_WIDGET(canvas));

    /* range display backdrop */
    gnome_canvas_item_new(gnome_canvas_root(canvas),
			  gnome_canvas_rect_get_type(),
			  "x1", (gdouble)0,
			  "y1", (gdouble)0,
			  "x2", (gdouble)x2,
			  "y2", (gdouble)y2,
			  "fill-color-rgba", BG_COLOR,
			  NULL);
    /* range */
    p->range = gnome_canvas_item_new(gnome_canvas_root(canvas),
					gnome_canvas_rect_get_type(),
					"x1", (gdouble)x1,
					"y1", (gdouble)y1,
					"x2", (gdouble)PHIN_KEYBOARD_KEY_WIDTH,
					"y2", (gdouble)y2,
					"fill-color-rgba", RANGE_COLOR,
					"outline-color", "black",
					NULL);
    gnome_canvas_item_hide(p->range);
    
    /* range root note */
    p->note = gnome_canvas_item_new(gnome_canvas_root(canvas),
				       gnome_canvas_rect_get_type(),
				       "x1", (gdouble)x1,
				       "y1", (gdouble)y1,
				       "x2", (gdouble)PHIN_KEYBOARD_KEY_WIDTH,
				       "y2", (gdouble)y2,
				       "fill-color-rgba", NOTE_COLOR,
				       "outline-color", "black",
				       NULL);
    gnome_canvas_item_hide(p->note);

    p->canvas = canvas;

    /* range display border */
    points = gnome_canvas_points_new(4);

    points->coords[0] = x1;
    points->coords[1] = y2;
    points->coords[2] = x1;
    points->coords[3] = y1;
    points->coords[4] = x2-1;
    points->coords[5] = y1;
    points->coords[6] = x2-1;
    points->coords[7] = y2;

    gnome_canvas_item_new(gnome_canvas_root(canvas),
			  gnome_canvas_line_get_type(),
			  "points", points,
			  "width-units", (gdouble)1,
			  "fill-color-rgba", 0,
			  NULL);
    gnome_canvas_points_unref(points);


    /* keyboard */
    p->keyboard = phin_hkeyboard_new(p->adj, MIDI_NOTES, TRUE);
    gtk_box_pack_start(box, p->keyboard, FALSE, FALSE, 0);
    gtk_widget_show(p->keyboard);

    /* vpad */
    pad = gui_vpad_new(GUI_SCROLLSPACE);
    gtk_box_pack_start(box, pad, FALSE, FALSE, 0);
    gtk_widget_show(pad);

    /* scrollbar */
    scroll = gtk_hscrollbar_new(p->adj);
    gtk_box_pack_start(box, scroll, FALSE, FALSE, 0);
    gtk_widget_show(scroll);

    /* done */
    connect(p);
}
示例#8
0
void ui_common_study_preferences_widgets(GtkWidget * packing_table,
					 gint table_row,
					 GtkWidget ** proi_width_spin,
					 GnomeCanvasItem ** proi_item,
#ifdef AMIDE_LIBGNOMECANVAS_AA
					 GtkWidget ** proi_transparency_spin,
#else
					 GtkWidget ** pline_style_menu,
					 GtkWidget ** pfill_roi_button,
#endif
					 GtkWidget ** playout_button1,
					 GtkWidget ** playout_button2,
					 GtkWidget ** ppanel_layout_button1,
					 GtkWidget ** ppanel_layout_button2,
					 GtkWidget ** ppanel_layout_button3,
					 GtkWidget ** pmaintain_size_button,
					 GtkWidget ** ptarget_size_spin) {

  GtkWidget * label;
  GtkObject * adjustment;
  GtkWidget * roi_canvas;
  GnomeCanvasPoints * roi_line_points;
  GtkWidget * image;
  GtkWidget * hseparator;
#ifndef AMIDE_LIBGNOMECANVAS_AA
  GdkLineStyle i_line_style;
#endif


  /* widgets to change the roi's size */
  label = gtk_label_new(_("ROI Width (pixels)"));
  gtk_table_attach(GTK_TABLE(packing_table), label, 
		   0,1, table_row, table_row+1,
		   0, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(label);

  adjustment = gtk_adjustment_new(AMITK_PREFERENCES_MIN_ROI_WIDTH,
				  AMITK_PREFERENCES_MIN_ROI_WIDTH,
				  AMITK_PREFERENCES_MAX_ROI_WIDTH,1.0, 1.0, 0.0);
  *proi_width_spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1.0, 0);
  gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(*proi_width_spin),FALSE);
  gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(*proi_width_spin), TRUE);
  gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(*proi_width_spin), TRUE);
  gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(*proi_width_spin), GTK_UPDATE_ALWAYS);
  gtk_table_attach(GTK_TABLE(packing_table), *proi_width_spin, 1,2, 
		   table_row, table_row+1, GTK_FILL, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(*proi_width_spin);

  /* a little canvas indicator thingie to show the user who the new preferences will look */
#ifdef AMIDE_LIBGNOMECANVAS_AA
  roi_canvas = gnome_canvas_new_aa();
#else
  roi_canvas = gnome_canvas_new();
#endif
  gtk_widget_set_size_request(roi_canvas, 100, 100);
  gnome_canvas_set_scroll_region(GNOME_CANVAS(roi_canvas), 0.0, 0.0, 100.0, 100.0);
  gtk_table_attach(GTK_TABLE(packing_table),  roi_canvas, 2,3,table_row,table_row+2,
		   GTK_FILL, 0,  X_PADDING, Y_PADDING);
  gtk_widget_show(roi_canvas);

  /* the box */
  roi_line_points = gnome_canvas_points_new(5);
  roi_line_points->coords[0] = 25.0; /* x1 */
  roi_line_points->coords[1] = 25.0; /* y1 */
  roi_line_points->coords[2] = 75.0; /* x2 */
  roi_line_points->coords[3] = 25.0; /* y2 */
  roi_line_points->coords[4] = 75.0; /* x3 */
  roi_line_points->coords[5] = 75.0; /* y3 */
  roi_line_points->coords[6] = 25.0; /* x4 */
  roi_line_points->coords[7] = 75.0; /* y4 */
  roi_line_points->coords[8] = 25.0; /* x4 */
  roi_line_points->coords[9] = 25.0; /* y4 */

  
  *proi_item = gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(roi_canvas)), 
#ifdef AMIDE_LIBGNOMECANVAS_AA
				     gnome_canvas_polygon_get_type(),
#else
				     gnome_canvas_line_get_type(),
#endif
				     "points", roi_line_points, 
				     NULL);
  gnome_canvas_points_unref(roi_line_points);
  table_row++;


#ifdef AMIDE_LIBGNOMECANVAS_AA
  /* widget to change the transparency level */
  /* only works for anti-aliased canvases */
  /* widgets to change the roi's size */

  label = gtk_label_new(_("ROI Transparency"));
  gtk_table_attach(GTK_TABLE(packing_table), label, 
		   0, 1, table_row, table_row+1,
		   0, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(label);

  *proi_transparency_spin = gtk_spin_button_new_with_range(0.0,1.0,AMITK_PREFERENCES_DEFAULT_CANVAS_ROI_TRANSPARENCY);
  gtk_spin_button_set_increments(GTK_SPIN_BUTTON(*proi_transparency_spin),0.1,0.1);
  gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(*proi_transparency_spin),FALSE);
  gtk_table_attach(GTK_TABLE(packing_table), *proi_transparency_spin, 1,2, 
		   table_row, table_row+1, GTK_FILL, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(*proi_transparency_spin);
  table_row++;
#else
  /* widgets to change the roi's line style */
  /* Anti-aliased canvas doesn't yet support this */
  /* also need to remove #ifndef for relevant lines in amitk_canvas_object.c and other locations  */
  label = gtk_label_new(_("ROI Line Style:"));
  gtk_table_attach(GTK_TABLE(packing_table), label, 0,1,
  		   table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(label);

  *pline_style_menu = gtk_combo_box_new_text();
  for (i_line_style=0; i_line_style<=GDK_LINE_DOUBLE_DASH; i_line_style++) 
     gtk_combo_box_append_text(GTK_COMBO_BOX(*pline_style_menu),
			       line_style_names[i_line_style]);
  gtk_widget_set_size_request (*pline_style_menu, 125, -1);
  gtk_table_attach(GTK_TABLE(packing_table),  *pline_style_menu, 1,2, 
  		   table_row,table_row+1, GTK_FILL, 0,  X_PADDING, Y_PADDING);
  gtk_widget_show(*pline_style_menu);
  table_row++;

  /* do we want to fill in isocontour roi's */
  label = gtk_label_new(_("Draw Isocontours/Freehands Filled:"));
  gtk_table_attach(GTK_TABLE(packing_table), label, 
		   0,1, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(label);

  *pfill_roi_button = gtk_check_button_new();
  gtk_table_attach(GTK_TABLE(packing_table), *pfill_roi_button,
		   1,2, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(*pfill_roi_button);
  table_row++;
#endif

  hseparator = gtk_hseparator_new();
  gtk_table_attach(GTK_TABLE(packing_table), hseparator, 
		   0, 3, table_row, table_row+1,
		   GTK_FILL, 0, X_PADDING, Y_PADDING);
  table_row++;
  gtk_widget_show(hseparator);


  label = gtk_label_new(_("Canvas Layout:"));
  gtk_table_attach(GTK_TABLE(packing_table), label, 
		   0,1, table_row, table_row+1,
		   0, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(label);

  /* the radio buttons */
  *playout_button1 = gtk_radio_button_new(NULL);
  image = gtk_image_new_from_stock("amide_icon_layout_linear",GTK_ICON_SIZE_DIALOG);
  gtk_button_set_image(GTK_BUTTON(*playout_button1), image);
  gtk_table_attach(GTK_TABLE(packing_table), *playout_button1,
  		   1,2, table_row, table_row+1,
  		   0, 0, X_PADDING, Y_PADDING);
  g_object_set_data(G_OBJECT(*playout_button1), "layout", GINT_TO_POINTER(AMITK_LAYOUT_LINEAR));
  gtk_widget_show(*playout_button1);

  *playout_button2 = gtk_radio_button_new(NULL);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(*playout_button2), 
			     gtk_radio_button_get_group(GTK_RADIO_BUTTON(*playout_button1)));
  image = gtk_image_new_from_stock("amide_icon_layout_orthogonal",GTK_ICON_SIZE_DIALOG);
  gtk_button_set_image(GTK_BUTTON(*playout_button2), image);
  gtk_table_attach(GTK_TABLE(packing_table), *playout_button2, 2,3, table_row, table_row+1,
  		   0, 0, X_PADDING, Y_PADDING);
  g_object_set_data(G_OBJECT(*playout_button2), "layout", GINT_TO_POINTER(AMITK_LAYOUT_ORTHOGONAL));
  gtk_widget_show(*playout_button2);

  table_row++;


  label = gtk_label_new(_("Multiple Canvases Layout:"));
  gtk_table_attach(GTK_TABLE(packing_table), label, 
		   0,1, table_row, table_row+1,
		   0, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(label);

  /* the radio buttons */
  *ppanel_layout_button1 = gtk_radio_button_new(NULL);
  image = gtk_image_new_from_stock("amide_icon_panels_mixed", GTK_ICON_SIZE_LARGE_TOOLBAR);
  gtk_button_set_image(GTK_BUTTON(*ppanel_layout_button1), image);
  gtk_table_attach(GTK_TABLE(packing_table), *ppanel_layout_button1,
  		   1,2, table_row, table_row+1,
  		   0, 0, X_PADDING, Y_PADDING);
  g_object_set_data(G_OBJECT(*ppanel_layout_button1), "panel_layout", GINT_TO_POINTER(AMITK_PANEL_LAYOUT_MIXED));
  gtk_widget_show(*ppanel_layout_button1);

  *ppanel_layout_button2 = gtk_radio_button_new(NULL);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(*ppanel_layout_button2), 
			     gtk_radio_button_get_group(GTK_RADIO_BUTTON(*ppanel_layout_button1)));
  image = gtk_image_new_from_stock("amide_icon_panels_linear_x", GTK_ICON_SIZE_LARGE_TOOLBAR);
  gtk_button_set_image(GTK_BUTTON(*ppanel_layout_button2), image);
  gtk_table_attach(GTK_TABLE(packing_table), *ppanel_layout_button2,
  		   2,3, table_row, table_row+1,
  		   0, 0, X_PADDING, Y_PADDING);
  g_object_set_data(G_OBJECT(*ppanel_layout_button2), "panel_layout", GINT_TO_POINTER(AMITK_PANEL_LAYOUT_LINEAR_X));
  gtk_widget_show(*ppanel_layout_button2);

  *ppanel_layout_button3 = gtk_radio_button_new(NULL);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(*ppanel_layout_button3), 
			     gtk_radio_button_get_group(GTK_RADIO_BUTTON(*ppanel_layout_button1)));
  image = gtk_image_new_from_stock("amide_icon_panels_linear_y", GTK_ICON_SIZE_LARGE_TOOLBAR);
  gtk_button_set_image(GTK_BUTTON(*ppanel_layout_button3), image);
  gtk_table_attach(GTK_TABLE(packing_table), *ppanel_layout_button3,
  		   3,4, table_row, table_row+1,
  		   0, 0, X_PADDING, Y_PADDING);
  g_object_set_data(G_OBJECT(*ppanel_layout_button3), "panel_layout", GINT_TO_POINTER(AMITK_PANEL_LAYOUT_LINEAR_Y));
  gtk_widget_show(*ppanel_layout_button3);

  table_row++;


  /* do we want the size of the canvas to not resize */
  label = gtk_label_new(_("Maintain view size constant:"));
  gtk_table_attach(GTK_TABLE(packing_table), label, 
		   0,1, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(label);

  *pmaintain_size_button = gtk_check_button_new();
  gtk_table_attach(GTK_TABLE(packing_table), *pmaintain_size_button, 
		   1,2, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(*pmaintain_size_button);
  table_row++;


  /* widgets to change the amount of empty space in the center of the target */
  label = gtk_label_new(_("Target Empty Area (pixels)"));
  gtk_table_attach(GTK_TABLE(packing_table), label, 
		   0,1, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(label);

  adjustment = gtk_adjustment_new(AMITK_PREFERENCES_MIN_TARGET_EMPTY_AREA, 
				  AMITK_PREFERENCES_MIN_TARGET_EMPTY_AREA, 
				  AMITK_PREFERENCES_MAX_TARGET_EMPTY_AREA, 1.0, 1.0, 0.0);
  *ptarget_size_spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1.0, 0);
  gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(*ptarget_size_spin),FALSE);
  gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(*ptarget_size_spin), TRUE);
  gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(*ptarget_size_spin), TRUE);
  gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(*ptarget_size_spin), GTK_UPDATE_ALWAYS);

  gtk_table_attach(GTK_TABLE(packing_table), *ptarget_size_spin, 1,2, 
		   table_row, table_row+1, GTK_FILL, 0, X_PADDING, Y_PADDING);
  gtk_widget_show(*ptarget_size_spin);


  return;
}
示例#9
0
GtkWidget *
ghack_init_map_window()
{
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *table;
    GtkWidget *frame;
    GtkWidget *w;
    GtkWidget *hSeparator;
    GtkAdjustment *adj;
    GnomeCanvasImage *bg;
    double width, height, x, y;
    int i;

    width = COLNO * ghack_glyph_width();
    height = ROWNO * ghack_glyph_height();

    vbox = gtk_vbox_new(FALSE, 4);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
    gtk_widget_show(vbox);

    /* Add in a horiz seperator */
    hSeparator = gtk_hseparator_new();
    gtk_box_pack_start(GTK_BOX(vbox), hSeparator, FALSE, FALSE, 2);
    gtk_widget_show(hSeparator);

    hbox = gtk_hbox_new(FALSE, 4);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
    gtk_widget_show(hbox);

    /* Create the Zoom spinbutton.
    */
    ghack_map.zoom = 1.0;
    w = gtk_label_new("Zoom:");
    gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
    gtk_widget_show(w);
    adj =
        GTK_ADJUSTMENT(gtk_adjustment_new(1.00, 0.5, 3.00, 0.05, 0.50, 0.50));
    w = gtk_spin_button_new(adj, 0.5, 2);
    gtk_widget_set_usize(w, 50, 0);
    gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
    gtk_widget_show(w);

    /* Canvas and scrollbars
    */
    gtk_widget_push_visual(gdk_imlib_get_visual());
    gtk_widget_push_colormap(gdk_imlib_get_colormap());
    ghack_map.canvas = GNOME_CANVAS(gnome_canvas_new());
    // gtk_widget_push_visual(gdk_rgb_get_visual());
    // gtk_widget_push_colormap(gdk_rgb_get_cmap());
    // ghack_map.canvas = GNOME_CANVAS (gnome_canvas_new_aa());

    gtk_widget_pop_colormap();
    gtk_widget_pop_visual();
    gtk_widget_show(GTK_WIDGET(ghack_map.canvas));

    table = gtk_table_new(2, 2, FALSE);
    gtk_table_set_row_spacings(GTK_TABLE(table), 4);
    gtk_table_set_col_spacings(GTK_TABLE(table), 4);
    gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
    gtk_widget_show(table);

    frame = gtk_frame_new(NULL);
    ghack_map.frame = frame;
    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
    gtk_table_attach(GTK_TABLE(table), frame, 0, 1, 0, 1,
                     GTK_EXPAND | GTK_FILL | GTK_SHRINK,
                     GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
    gtk_widget_show(frame);

    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(ghack_map.canvas));
    gnome_canvas_set_scroll_region(GNOME_CANVAS(ghack_map.canvas), 0, 0,
                                   width + 2 * ghack_glyph_width(),
                                   height + 2 * ghack_glyph_height());

    gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(ghack_map.canvas), 1.0);

    w = gtk_hscrollbar_new(GTK_LAYOUT(ghack_map.canvas)->hadjustment);
    gtk_table_attach(GTK_TABLE(table), w, 0, 1, 1, 2,
                     GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0);
    gtk_widget_show(w);

    w = gtk_vscrollbar_new(GTK_LAYOUT(ghack_map.canvas)->vadjustment);
    gtk_table_attach(GTK_TABLE(table), w, 1, 2, 0, 1, GTK_FILL,
                     GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
    gtk_widget_show(w);

    myCanvasGroup = GNOME_CANVAS_GROUP(gnome_canvas_item_new(
                                           gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas)),
                                           gnome_canvas_group_get_type(), "x", 0.0, "y", 0.0, NULL));

    /* Tile the map background with a pretty image */
    background = gdk_imlib_load_image((char *) "mapbg.xpm");
    if (background == NULL) {
        g_warning(
            "Bummer! Failed to load the map background image (mapbg.xpm)!");
    } else {
        gdk_imlib_render(background, background->rgb_width,
                         background->rgb_height);

        /* Tile the map background */
        for (y = 0; y < height + background->rgb_height;
                y += background->rgb_height) {
            for (x = 0; x < width + background->rgb_width;
                    x += background->rgb_width) {
                bg = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
                                            myCanvasGroup, gnome_canvas_image_get_type(), "x",
                                            (double) x, "y", (double) y, "width",
                                            (double) background->rgb_width, "height",
                                            (double) background->rgb_height, "image", background,
                                            "anchor", (GtkAnchorType) GTK_ANCHOR_CENTER, NULL));
                gnome_canvas_item_lower_to_bottom(GNOME_CANVAS_ITEM(bg));
            }
        }
    }

    /* ghack_map.map is an array of canvas images.  Each cell of
     * the array will contain one tile.  Here, we create the
     * space for the cells and then create the cells for easy
     * access later.
    */
    for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
        for (x = 0; x < width; x += ghack_glyph_width()) {
            ghack_map.map[i++] = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
                    myCanvasGroup, gnome_canvas_image_get_type(), "x", (double) x,
                    "y", (double) y, "width", (double) ghack_glyph_width(),
                    "height", (double) ghack_glyph_height(), "anchor",
                    GTK_ANCHOR_NORTH_WEST, NULL));
        }
    }

    /* Set up the pet mark image */
    petmark = gdk_imlib_create_image_from_xpm_data(pet_mark_xpm);
    if (petmark == NULL) {
        g_warning("Bummer! Failed to load the pet_mark image!");
    } else {
        gdk_imlib_render(petmark, petmark->rgb_width, petmark->rgb_height);

        /* ghack_map.overlay is an array of canvas images used to
         * overlay tile images...
         */
        for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
            for (x = 0; x < width; x += ghack_glyph_width()) {
                ghack_map.overlay[i] =
                    GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
                                           myCanvasGroup, gnome_canvas_image_get_type(), "x",
                                           (double) x, "y", (double) y, "width",
                                           (double) petmark->rgb_width, "height",
                                           (double) petmark->rgb_height, "image", petmark,
                                           "anchor", GTK_ANCHOR_NORTH_WEST, NULL));
                gnome_canvas_item_lower_to_bottom(
                    GNOME_CANVAS_ITEM(ghack_map.overlay[i++]));
            }
        }
    }

    /* Resize the canvas when the spinbutton changes
    */
    gtk_signal_connect(GTK_OBJECT(adj), "value_changed",
                       (GtkSignalFunc) ghack_map_window_zoom,
                       ghack_map.canvas);

    /* Game signals
    */
    gtk_signal_connect(GTK_OBJECT(vbox), "ghack_curs",
                       GTK_SIGNAL_FUNC(ghack_map_cursor_to), NULL);
    gtk_signal_connect(GTK_OBJECT(vbox), "ghack_putstr",
                       GTK_SIGNAL_FUNC(ghack_map_putstr), NULL);
    gtk_signal_connect(GTK_OBJECT(vbox), "ghack_print_glyph",
                       GTK_SIGNAL_FUNC(ghack_map_print_glyph), NULL);
    gtk_signal_connect(GTK_OBJECT(vbox), "ghack_clear",
                       GTK_SIGNAL_FUNC(ghack_map_clear), NULL);
    gtk_signal_connect(GTK_OBJECT(vbox), "ghack_display",
                       GTK_SIGNAL_FUNC(ghack_map_display), NULL);
    gtk_signal_connect(GTK_OBJECT(vbox), "ghack_cliparound",
                       GTK_SIGNAL_FUNC(ghack_map_cliparound), NULL);
    gtk_signal_connect(GTK_OBJECT(ghack_map.canvas), "button_press_event",
                       GTK_SIGNAL_FUNC(ghack_handle_button_press), NULL);
    gtk_signal_connect(GTK_OBJECT(ghack_map.canvas), "gnome_delay_output",
                       GTK_SIGNAL_FUNC(ghack_delay), NULL);

    return GTK_WIDGET(vbox);
}
示例#10
0
void
ghack_reinit_map_window()
{
    GnomeCanvasImage *bg;
    double width, height, x, y;
    int i;

    /* ghack_map_clear(NULL, NULL); */

    width = COLNO * ghack_glyph_width();
    height = ROWNO * ghack_glyph_height();

    gnome_canvas_set_scroll_region(GNOME_CANVAS(ghack_map.canvas), 0, 0,
                                   width + 2 * ghack_glyph_width(),
                                   height + 2 * ghack_glyph_height());

    /* remove everything currently in the canvas map */
    gtk_object_destroy(GTK_OBJECT(myCanvasGroup));

    /* Put some groups back */
    myCanvasGroup = GNOME_CANVAS_GROUP(gnome_canvas_item_new(
                                           gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas)),
                                           gnome_canvas_group_get_type(), "x", 0.0, "y", 0.0, NULL));

    /* Tile the map background with a pretty image */
    if (background != NULL) {
        /* Tile the map background */
        for (y = 0; y < height + background->rgb_height;
                y += background->rgb_height) {
            for (x = 0; x < width + background->rgb_width;
                    x += background->rgb_width) {
                bg = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
                                            myCanvasGroup, gnome_canvas_image_get_type(), "x",
                                            (double) x, "y", (double) y, "width",
                                            (double) background->rgb_width, "height",
                                            (double) background->rgb_height, "image", background,
                                            "anchor", (GtkAnchorType) GTK_ANCHOR_CENTER, NULL));
                gnome_canvas_item_lower_to_bottom(GNOME_CANVAS_ITEM(bg));
            }
        }
    }

    /* ghack_map.map is an array of canvas images.  Each cell of
     * the array will contain one tile.  Here, we create the
     * space for the cells and then create the cells for easy
     * access later.
    */
    for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
        for (x = 0; x < width; x += ghack_glyph_width()) {
            ghack_map.map[i++] = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
                    myCanvasGroup, gnome_canvas_image_get_type(), "x", (double) x,
                    "y", (double) y, "width", (double) ghack_glyph_width(),
                    "height", (double) ghack_glyph_height(), "anchor",
                    GTK_ANCHOR_NORTH_WEST, NULL));
        }
    }

    if (petmark != NULL) {
        /* ghack_map.overlay is an array of canvas images used to
         * overlay tile images...
        */
        for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
            for (x = 0; x < width; x += ghack_glyph_width()) {
                ghack_map.overlay[i] =
                    GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
                                           myCanvasGroup, gnome_canvas_image_get_type(), "x",
                                           (double) x, "y", (double) y, "width",
                                           (double) petmark->rgb_width, "height",
                                           (double) petmark->rgb_height, "image", petmark,
                                           "anchor", GTK_ANCHOR_NORTH_WEST, NULL));
                gnome_canvas_item_lower_to_bottom(
                    GNOME_CANVAS_ITEM(ghack_map.overlay[i++]));
            }
        }
    }

    ghack_map_cliparound(NULL, u.ux, u.uy, NULL);
    ghack_map_cursor_to(NULL, u.ux, u.uy, NULL);
    gnome_canvas_update_now(ghack_map.canvas);
    doredraw();
}
示例#11
0
static void draw_keyboard(PhatKeyboard* self)
{
    gint i, pos, note;

    /* make sure our construction properties are set (this is
     * _lame_ass_) */
    if (self->nkeys < 0
        || self->orientation < 0
        || self->label < 0)
        return;

    self->keys = g_new(_Key, self->nkeys);
    self->hold = 0;
    /* orientation */
    if (self->orientation == GTK_ORIENTATION_VERTICAL)
    {
        gtk_widget_set_size_request(GTK_WIDGET(self), PHAT_KEYBOARD_KEY_LENGTH, 0);
        gtk_widget_set_size_request(GTK_WIDGET(self->canvas), PHAT_KEYBOARD_KEY_LENGTH, (PHAT_KEYBOARD_KEY_WIDTH * self->nkeys));
        gnome_canvas_set_scroll_region(self->canvas, 0, 0, PHAT_KEYBOARD_KEY_LENGTH-1, (PHAT_KEYBOARD_KEY_WIDTH * self->nkeys) - 1);
    }
    else
    {
        gtk_widget_set_size_request(GTK_WIDGET(self), 0, PHAT_KEYBOARD_KEY_LENGTH);
        gtk_widget_set_size_request(GTK_WIDGET(self->canvas), (PHAT_KEYBOARD_KEY_WIDTH * self->nkeys), PHAT_KEYBOARD_KEY_LENGTH);
        gnome_canvas_set_scroll_region(self->canvas, 0, 0, (PHAT_KEYBOARD_KEY_WIDTH * self->nkeys) - 1, PHAT_KEYBOARD_KEY_LENGTH-1);
    }

    /* keys */
    if (self->orientation == GTK_ORIENTATION_VERTICAL)
    {
        for (i = note = 0, pos = (PHAT_KEYBOARD_KEY_WIDTH * self->nkeys) - 1; i < self->nkeys; ++i, ++note, pos -= PHAT_KEYBOARD_KEY_WIDTH)
        {
            if (note > 11)
                note = 0;

            switch (note)
            {
            case 0:
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
            case 11:
                draw_key(self, i, pos, KEY_NAT_BG, KEY_NAT_HI,
                         KEY_NAT_LOW, KEY_NAT_PRE,
                         KEY_NAT_ON, KEY_NAT_SHAD);
                break;
            default:
                draw_key(self, i, pos, KEY_ACC_BG, KEY_ACC_HI,
                         KEY_ACC_LOW, KEY_ACC_PRE,
                         KEY_ACC_ON, KEY_ACC_SHAD);
                break;
            }
        }
    }
    else                        /* gaarrrrrr */
    {
        for (i = note = 0, pos = 0; i < self->nkeys; ++i, ++note, pos += PHAT_KEYBOARD_KEY_WIDTH)
        {
            if (note > 11)
                note = 0;

            switch (note)
            {
            case 0:
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
            case 11:
                draw_key(self, i, pos, KEY_NAT_BG, KEY_NAT_HI,
                         KEY_NAT_LOW, KEY_NAT_PRE,
                         KEY_NAT_ON, KEY_NAT_SHAD);
                break;
            default:
                draw_key(self, i, pos, KEY_ACC_BG, KEY_ACC_HI,
                         KEY_ACC_LOW, KEY_ACC_PRE,
                         KEY_ACC_ON, KEY_ACC_SHAD);
                break;
            }
        }
    }
}
示例#12
0
static void
create_app_helper (GtkWidget *widget, gpointer data)
{
	GtkWidget *app;
	GtkWidget *vbox;
	GtkWidget *frame;
	GtkWidget *vbox2;
	GtkWidget *w;
	GtkWidget *popup;
        GnomeAppBar *bar;
	GnomeCanvasItem *item;

	app = gnome_app_new ("testGNOME", "GnomeAppHelper test");
	gnome_app_create_menus (GNOME_APP (app), helper_main_menu);
	gnome_app_create_toolbar (GNOME_APP (app), helper_toolbar);

        bar = GNOME_APPBAR(gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_USER));
        gnome_app_set_statusbar(GNOME_APP(app), GTK_WIDGET(bar));

        gnome_app_install_appbar_menu_hints(GNOME_APPBAR(bar), helper_main_menu);

	vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL);

	/* Shared popup menu */

	popup = gnome_popup_menu_new (helper_shared_popup);

	frame = gtk_frame_new ("Shared popup menu");
	gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
	gtk_widget_show (frame);

	vbox2 = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
	gtk_container_set_border_width (GTK_CONTAINER (vbox2), GNOME_PAD_SMALL);
	gtk_container_add (GTK_CONTAINER (frame), vbox2);
	gtk_widget_show (vbox2);

	w = gtk_entry_new ();
	gtk_box_pack_start (GTK_BOX (vbox2), w, FALSE, FALSE, 0);
	gtk_widget_show (w);
	gnome_popup_menu_attach (popup, w, w);
	
	w = gtk_entry_new ();
	gtk_box_pack_start (GTK_BOX (vbox2), w, FALSE, FALSE, 0);
	gtk_widget_show (w);
	gnome_popup_menu_attach (popup, w, w);

	/* Popup menu explicitly popped */

	popup = gnome_popup_menu_new (helper_explicit_popup);

	frame = gtk_frame_new ("Explicit popup menu");
	gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
	gtk_widget_show (frame);

	w = gnome_canvas_new ();
	gtk_widget_set_size_request ((w), 200, 100);
	gnome_canvas_set_scroll_region (GNOME_CANVAS (w), 0.0, 0.0, 200.0, 100.0);
	gtk_container_add (GTK_CONTAINER (frame), w);
	gtk_widget_show (w);

	g_signal_connect (w, "destroy",
			  G_CALLBACK (delete_event),
			  popup);

	item = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (w)),
				      gnome_canvas_ellipse_get_type (),
				      "x1", 5.0,
				      "y1", 5.0,
				      "x2", 95.0,
				      "y2", 95.0,
				      "fill_color", "white",
				      "outline_color", "black",
				      NULL);
	g_signal_connect (item, "event",
			  G_CALLBACK (item_event),
			  popup);

	item = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (w)),
				      gnome_canvas_ellipse_get_type (),
				      "x1", 105.0,
				      "y1", 0.0,
				      "x2", 195.0,
				      "y2", 95.0,
				      "fill_color", "white",
				      "outline_color", "black",
				      NULL);
	g_signal_connect (item, "event",
			  G_CALLBACK (item_event),
			  popup);

	gnome_app_set_contents (GNOME_APP (app), vbox);
	gtk_widget_show (app);
}
示例#13
0
static void
set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc)
{
	gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height);
}