GType gnucash_cursor_get_type (void) { static GType gnucash_cursor_type = 0; if (!gnucash_cursor_type) { static const GTypeInfo gnucash_cursor_info = { sizeof (GnucashCursorClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc) gnucash_cursor_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (GnucashCursor), 0, /* n_preallocs */ (GInstanceInitFunc) gnucash_cursor_init }; gnucash_cursor_type = g_type_register_static (gnome_canvas_group_get_type (), "GnucashCursor", &gnucash_cursor_info, 0); } return gnucash_cursor_type; }
void G_cont_create( int cont, GnomeCanvasGroup *root ) { if(!initialized) G_cont_init(); G_conts[cont].cont_group = GNOME_CANVAS_GROUP( gnome_canvas_item_new ( root, gnome_canvas_group_get_type (), "x", (double) G_conts[cont].x, "y", (double) G_conts[cont].y, NULL)); }
GType e_minicard_get_type (void) { static GType type = 0; if (!type) { static const GTypeInfo info = { sizeof (EMinicardClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc) e_minicard_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (EMinicard), 0, /* n_preallocs */ (GInstanceInitFunc) e_minicard_init, }; type = g_type_register_static (gnome_canvas_group_get_type (), "EMinicard", &info, 0); } return type; }
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); }
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(); }
/* so much gayness in here, either I suck or gnome-canvas does; most * likely, we both do */ static void draw_key(PhatKeyboard* self, gint index, gint pos, guint bg, guint hi, guint low, guint pre, guint on, guint shad) { _Key* key = &self->keys[index]; GnomeCanvasPoints* points; gint x1; gint y1; gint x2; gint y2; if (self->orientation == GTK_ORIENTATION_VERTICAL) { x1 = 0; y1 = pos + 1; /* teh gayz0r */ x2 = PHAT_KEYBOARD_KEY_LENGTH - 1; y2 = pos - PHAT_KEYBOARD_KEY_WIDTH + 1; } else { x1 = pos + PHAT_KEYBOARD_KEY_WIDTH - 1; y1 = 0; x2 = pos; y2 = PHAT_KEYBOARD_KEY_LENGTH - 1; } /* key group */ key->group = (GnomeCanvasGroup*) gnome_canvas_item_new(gnome_canvas_root(self->canvas), gnome_canvas_group_get_type(), NULL); g_signal_connect(G_OBJECT(key->group), "event", G_CALLBACK(key_press_cb), (gpointer)key); key->index = index; key->hold = 0; key->keyboard = self; /* draw main key rect */ gnome_canvas_item_new(key->group, gnome_canvas_rect_get_type(), "x1", (gdouble)x1, "y1", (gdouble)y1, "x2", (gdouble)x2, "y2", (gdouble)y2, "fill-color-rgba", bg, NULL); /* draw prelight rect */ key->pre = gnome_canvas_item_new(key->group, gnome_canvas_rect_get_type(), "x1", (gdouble)x1, "y1", (gdouble)y1, "x2", (gdouble)x2, "y2", (gdouble)y2, "fill-color-rgba", pre, NULL); gnome_canvas_item_hide(key->pre); /* draw key highlight */ points = gnome_canvas_points_new(3); if (self->orientation == GTK_ORIENTATION_VERTICAL) { points->coords[0] = x1+1; points->coords[1] = y1; points->coords[2] = x1+1; points->coords[3] = y2+1; points->coords[4] = x2; points->coords[5] = y2+1; } else { points->coords[0] = x1; points->coords[1] = y1+1; points->coords[2] = x2; points->coords[3] = y1+1; points->coords[4] = x2; points->coords[5] = y2; } gnome_canvas_item_new(key->group, gnome_canvas_line_get_type(), "points", points, "width-units", (gdouble)1, "fill-color-rgba", hi, NULL); gnome_canvas_points_unref(points); /* draw key border */ points = gnome_canvas_points_new(4); if (self->orientation == GTK_ORIENTATION_VERTICAL) { points->coords[0] = x1; points->coords[1] = y1; points->coords[2] = x1; points->coords[3] = y2; points->coords[4] = x2; points->coords[5] = y2; points->coords[6] = x2; points->coords[7] = y1; } else { points->coords[0] = x2; points->coords[1] = y1; points->coords[2] = x1; points->coords[3] = y1; points->coords[4] = x1; points->coords[5] = y2; points->coords[6] = x2; points->coords[7] = y2; } gnome_canvas_item_new(key->group, gnome_canvas_line_get_type(), "points", points, "width-units", (gdouble)1, "fill-color-rgba", low, NULL); gnome_canvas_points_unref(points); if (self->orientation == GTK_ORIENTATION_VERTICAL) { /* draw active rect */ key->on = gnome_canvas_item_new(key->group, gnome_canvas_rect_get_type(), "x1", (gdouble)x1+1, "y1", (gdouble)y1, "x2", (gdouble)x2, "y2", (gdouble)y2+1, "fill-color-rgba", on, NULL); } else { /* draw active rect */ key->on = gnome_canvas_item_new(key->group, gnome_canvas_rect_get_type(), "x1", (gdouble)x1, "y1", (gdouble)y1+1, "x2", (gdouble)x2, "y2", (gdouble)y2, "fill-color-rgba", on, NULL); } gnome_canvas_item_hide(key->on); /* draw active shadow */ points = gnome_canvas_points_new(6); if (self->orientation == GTK_ORIENTATION_VERTICAL) { points->coords[0] = x1+1; points->coords[1] = y1; points->coords[2] = x1+1; points->coords[3] = y2+1; points->coords[4] = x2; points->coords[5] = y2+1; points->coords[6] = x2; points->coords[7] = y2 + 3; points->coords[8] = x1 + 3; points->coords[9] = y2 + 3; points->coords[10] = x1 + 3; points->coords[11] = y1; } else { points->coords[0] = x1; points->coords[1] = y1 + 1; points->coords[2] = x2; points->coords[3] = y1 + 1; points->coords[4] = x2; points->coords[5] = y2; points->coords[6] = x2 + 2; points->coords[7] = y2; points->coords[8] = x2 + 2; points->coords[9] = y1 + 3; points->coords[10] = x1; points->coords[11] = y1 + 3; } key->shad = gnome_canvas_item_new(key->group, gnome_canvas_polygon_get_type(), "points", points, "fill-color-rgba", shad, NULL); gnome_canvas_item_hide(key->shad); gnome_canvas_points_unref(points); /* draw label if applicable */ if (self->label && (index % 12) == 0) { gchar* s = g_strdup_printf("%d", index / 12 + 1); if (self->orientation == GTK_ORIENTATION_VERTICAL) { gnome_canvas_item_new(key->group, gnome_canvas_text_get_type(), "text", s, "x", (gdouble)(x2 - 2), "y", (gdouble)(y1 - (PHAT_KEYBOARD_KEY_WIDTH / 2)), "anchor", GTK_ANCHOR_EAST, "fill-color-rgba", (gint)KEY_TEXT_BG, "font", "sans", "size-points", (gdouble)TEXT_POINTS, NULL); } else { gnome_canvas_item_new(key->group, gnome_canvas_text_get_type(), "text", s, "x", (gdouble)(x1 - (PHAT_KEYBOARD_KEY_WIDTH / 2)), "y", (gdouble)(y2 - 2), "anchor", GTK_ANCHOR_SOUTH, "fill-color-rgba", (gint)KEY_TEXT_BG, "font", "sans", "size-points", (gdouble)TEXT_POINTS, "justification", GTK_JUSTIFY_CENTER, NULL); } g_free(s); } }