GTK+ widget background image alignment
I set background image for a button by:
bg_pixmap[NORMAL] = "img.png"
but most of the times the image is offset with certain x, y when:
- there is padding around
- there is adjacent widgets at left/top
- align the button 0.5, 0.5 of an alignment container of larger size
- ...
how can I specify the background image to alway start from 0, 0 of the button?
EDIT
it seems bg_pixmap is always tiling start from 0, 0 of the window ( but shown only in the button area )....
but when I use bg_pixmap on widgets not has state changes (only NORMAL image is shown)开发者_运维知识库, the image is aligned correctly... (e.g. drawing area, event box, etc...)
Looks that Gdk::Window::set_back_pixmap is the function you are looking for. Point is the parent_relative boolean that change the tiling starting point.
C. F.
WORKAROUND
I worked around this and make an "image button" works with rc style file:
add GtkButton inside an EventBox EventBox -> Visible Window = Yes ( No won't make it work )
精彩评论