2016 ソフトウェア設計及び演習用の班Wiki

gr01::プログラム

#include <gtk/gtk.h>

gboolean cb_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)

{ GdkWindow *drawable = widget->window; cairo_t *cr; cairo_surface_t *surface;

cr = gdk_cairo_create (drawable);

surface = (cairo_surface_t *) user_data; cairo_set_source_surface (cr, surface, 0.0, 0.0); cairo_paint (cr); //cairo_set_font_size (cairo_t *cr, double size);

cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); cairo_rectangle (cr, 10.0, 650.0, 1180.0, 140.0); cairo_stroke_preserve (cr); cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); cairo_fill (cr);

cairo_set_source_rgb (cr, 0.0 , 0.0 , 0.0); cairo_select_font_face (cr, "VL ゴ シ ッ ク", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_move_to (cr, 90.0 , 690.0); cairo_set_font_size (cr, 30.0); cairo_show_text (cr, "さぼろー");

cairo_set_source_rgb (cr, 0.0 , 0.0 , 0.0); cairo_select_font_face (cr, "VL ゴ シ ッ ク", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_move_to (cr, 100.0 , 750.0); cairo_set_font_size (cr, 50.0); cairo_show_text (cr, "「かぶとむし採りに行こうぜ」");

cairo_destroy (cr);

return FALSE; }

int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *canvas; cairo_surface_t *surface;

gtk_init (&argc, &argv);

surface = cairo_image_surface_create_from_png ("./e1.png");

window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW(window), "たんいっち"); gtk_widget_set_size_request (window, cairo_image_surface_get_width(surface) * 1.0, cairo_image_surface_get_height(surface) * 1.0); g_signal_connect (G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);

canvas = gtk_drawing_area_new (); gtk_container_add (GTK_CONTAINER(window), canvas); g_signal_connect (G_OBJECT(canvas), "expose_event", G_CALLBACK (cb_expose_event), surface);

gtk_widget_show_all (window); gtk_main ();

cairo_surface_destroy (surface);

return 0; }


最終更新日:2016/06/10 15:40:48