help drawing text
- From: Mathew Yeates <mathew yeates tv>
- To: gtk-i18n-list gnome org
- Subject: help drawing text
- Date: Wed, 15 Dec 2004 17:48:11 -0800
Any help would be greatly appreciated. The following code does not draw
the text I want. I am using gtk2.4 on Cygwin. Am I doing something
wrong? Or does the following code work on other platforms?
Thx
Mathew
#include <gtk/gtk.h>
#include <gtkwidget.h>
gboolean realize_callback(GtkWidget * widget, gpointer data)
{
PangoContext *pc;
PangoLayout *pl;
PangoFontDescription *desc;
GdkGC *gc;
GtkStyle *style;
style = gtk_widget_get_style(widget);
/*
gc=style->fg_gc[GTK_STATE_NORMAL];
*/
gc = style->black_gc;
pc = gtk_widget_get_pango_context(widget);
pl = gtk_widget_create_pango_layout(widget, "TITLE");
desc = pango_font_description_from_string("Sans 12");
pango_context_set_font_description(pc, desc);
gdk_draw_layout(widget->window, gc, 100, 100, pl);
return TRUE;
}
int main(int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *drawing_area;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Test");
drawing_area = gtk_drawing_area_new();
gtk_drawing_area_size(drawing_area, 300, 300);
g_signal_connect(G_OBJECT(drawing_area), "realize",
G_CALLBACK(realize_callback), NULL);
gtk_container_add(GTK_CONTAINER(window), drawing_area);
gtk_widget_show(drawing_area);
gtk_widget_show(window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]