RE: Trouble with Gtk::EventBox and Expose Events



Hi Andrew,

What I think happens is
1. The default signal handler draws the background and the label.
2. Your signal handler draws a new background on top of it all.

This is worth trying:

1. in BaseBox::BaseBox()
  signal_expose_event().connect(sigc::mem_fun(*this,
&BaseBox::_on_expose_event), false);

after = false makes BaseBox::_on_expose_event run before the default
signal handler.
I'm not sure about set_visible_window(false). Perhaps you should remove
it.

2. at the end of BaseBox::_on_expose_event(GdkEventExpose* event)
  propagate_expose(*get_child(), event);
  return true;

The expose_event signal will be sent to the label, making it draw
itself, I hope, and the default signal handler of EventBox will not be
called.

/Kjell

mån 2011-03-21 klockan 18:13 +0000 skrev Andrew:
> Hi,
> 
> I have a Gtk::Label and behind it I want to have a rectangle filled with
> the Base colour from the user's GTK theme (white) and a shadow as a
> border (http://i.imgur.com/fx8te.png)
> 
> I have tried to achieve this by packing the Gtk::Label into a
> Gtk::EventBox and then connecting to the EventBox's signal_expose_event.
> In this callback, I then draw the rectangle (using cairo) and draw the
> shadow using Gtk::Style::paint_shadow. (The code is at the end of this
> message)
> 
> However what happens is that the EventBox drawing seems to happen 'on
> top' of the label, and so covers the label (http://i.imgur.com/tFFGK.png)
> 
> How can I stop this happening/if I can't, is there a better way to do this?
> 
> Thanks,




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]