GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Apr 24, 2014 6:51 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 
Offline

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

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.

Code:
    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);
    cairo_line_to(cr,0,0);
    cairo_fill(cr);
    cairo_destroy(cr);


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

Code:
    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.

HeReSY


Top
 Profile  
 
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: asdfgh2091, Google [Bot] and 2 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