Re: Drawing Pango Layouts
- From: Twiine <cooli_best gmx de>
- To: "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: Re: Drawing Pango Layouts
- Date: Wed, 22 May 2002 21:00:06 +0300
Havoc Pennington wrote:
Twiine <cooli_best gmx de> writes:
I have a question concerning the drawing of pango layouts. I want to
draw a pango layout using different colors. So I added the needed
attributes using pango_layout_set_attributes and tried to draw the
entire thing with gtk_paint_layout. This doesn`t work since
gtk_paint_layout uses the GCs of the style argument to determine the
colors of the text. As far as I know its the same for
gtk_draw_layout. Is there a function which uses the pango attributes
for drawing? Or can I convert the attributes to a GC so that I can
paint them with gdk_draw_layout?
gtk_paint_layout and gdk_draw_layout() should use any colors specified
in the PangoAttrList for the layout.
I modified hello world with the commands my program uses but I still get
the same results. When I click the button the appearing text ist still
black on gray :). What am I doing wrong?
#include <gtk/gtk.h>
void hello( GtkWidget *widget,
gpointer data )
{
PangoLayout *layout; PangoAttrList *attrs;
layout = gtk_widget_create_pango_layout(widget,NULL);
pango_layout_set_font_description(layout,
pango_font_description_from_string("fixed 10"));
attrs = pango_attr_list_new();
pango_attr_list_insert(attrs,
pango_attr_foreground_new(0x0000, 0xFFFF, 0x0000));
pango_attr_list_insert(attrs,
pango_attr_background_new(0xFFFF, 0x0000, 0x0000));
pango_layout_set_attributes(layout, attrs);
pango_layout_set_text(layout ,"WWWW", -1);
gtk_paint_layout (widget->style, widget->window,
GTK_WIDGET_STATE(widget),
FALSE, NULL, widget, "label",
0, 0, layout);
g_free(attrs);
g_free(layout);
}
gint delete_event( GtkWidget *widget,
GdkEvent *event,
gpointer data )
{
g_print ("delete event occurred\n");
return TRUE;
}
void destroy( GtkWidget *widget,
gpointer data )
{
gtk_main_quit ();
}
int main( int argc,
char *argv[] )
{
GtkWidget *window;
GtkWidget *button;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (delete_event), NULL);
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (destroy), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 30);
button = gtk_button_new_with_label ("Click me");
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (hello), NULL);
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show (button);
gtk_widget_show (window);
gtk_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]