Re: Drawing with pango
Problem solved: Changed to cairo...
Greets
Wolf S. Kappesser schrieb:
> Hello,
>
> I search (and try hard ) to run this pango/gtk+ "application". Its only
> should put a string to a pango-layout.
> It didn't work. (Nothing will happen on the graphicwindow...)
>
> Its a main.c and the eventhandler for expose from my interface.c
> If needed, I will post the glade3 XML too.
>
> Big thanks for any helps.
> Best regard
>
>
> CODE: main.c
> gtk_set_locale ();
> gtk_init (&argc, &argv);
>
> gxml = glade_xml_new (GLADE_FILE, NULL, NULL);
>
>
> glade_xml_signal_autoconnect (gxml);
>
> window = glade_xml_get_widget (gxml, "window");
> fixed = glade_xml_get_widget (gxml, "fixed1");
> connect = glade_xml_get_widget (gxml, "connect");
> console = glade_xml_get_widget (gxml, "console");
> da = glade_xml_get_widget ( gxml, "drawingarea1");
>
> ....
> <snip/>
> ....
>
> g_signal_connect (window, "expose-event",
> G_CALLBACK (on_expose_event), da);
>
>
>
>
> gtk_widget_show (window);
>
> gtk_main ();
>
>
> **********************************************************
>
>
> CODE: interface.c
> FUNCTION: on_expose_event
>
>
> gboolean
> on_expose_event(GtkWidget * widget, GdkEvent* event, GtkWidget * label)
> {
> PangoContext *ct;
> PangoLayout *layout;
> PangoFontDescription * font;
>
> gint width, height;
>
> // prepare graphicdevice and output
>
> font = pango_font_description_from_string ("Courier,Medium 8");
> ct = gtk_widget_get_pango_context(widget);
> layout = pango_layout_new (ct);
> g_object_unref (ct);
>
> pango_layout_context_changed(layout);
> pango_layout_set_font_description (layout, font);
> pango_layout_set_text (layout, "Some UTF-8 text", -1);
>
> //pango_layout_get_size (layout, &width, &height);
> width = 50;
> height = 50;
>
> g_return_val_if_fail (widget != NULL, FALSE);
>
> /* Clear the text from the background of the widget. */
> //gdk_window_clear_area (widget->window, 0, 0, widget->allocation.width,
> // widget->allocation.height);
>
> /* Draw the PangoLayout on the widget, which is the message text. */
> gdk_draw_layout (widget->window ,
> widget->style->fg_gc[widget->state] ,
> widget->allocation.width ,
> widget->allocation.height ,
> layout);
> return TRUE;
> }
>
>
>
Reply to: