GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Aug 30, 2016 2:59 pm

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Drawing on the Background of a button in Gtk3
PostPosted: Thu Nov 17, 2011 5:58 pm 

Joined: Thu Nov 17, 2011 5:36 pm
Posts: 4

i am new to gtk programming an i tried to draw on the background of a button.
The draw signal is catched by my funtion, so that it should draw the lines.
Heres is my code of the drawing function.

    cairo_t *cr = NULL;
    cr = gdk_cairo_create(gtk_widget_get_window(m_pWidget));
    cairo_set_source_rgb (cr, 0, 0, 0);
    cairo_set_line_width(cr, 2);
    cairo_move_to(cr, 0, 0);
    cairo_line_to(cr, 100, 150);
    cairo_line_to(cr, 0, 150);

if i use the same code for a GtkWindow it works fine.
To create the button i use these two functions.

    m_pWidget = gtk_button_new_with_label("Hello");
    gtk_widget_set_app_paintable(m_pWidget, true);

Can someone pint me in the right direction to draw on the buttons background.


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 3 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group