Re: Custom Widget - Image with label and MouseEvents (click, move-in/out)
- From: "Naveen Verma" <ernaveenverma gmail com>
- To: "Andreas Rammhold" <andreas rammhold de>
- Cc: gtkmm-list gnome org
- Subject: Re: Custom Widget - Image with label and MouseEvents (click, move-in/out)
- Date: Tue, 10 Jul 2007 10:19:33 +0300
Hi,
I did not try it. But is the set_size_request(int width, int height) will not help to set the size of the EventBox?
Could you please check this function.
-Br
Naveen
On 7/10/07, Andreas Rammhold <andreas rammhold de> wrote:
Hi,
First i would like to thank the gtk(mm) team for the great work! Thanks!
I'm searching for a code snip or a hint on creating a Widget which
displays a Image with a Label over it. The Image should change when the
mouse hovers it (BUTTON_PRESS_MASK | ENTER_NOTIFY_MASK | LEAVE_NOTIFY_MASK).
I already got sth. similar to it running (added on the end) but I can't
specify the height/width of the EventBox (set_allocation is
protected...) which would require a class for this. Ok, a class is not
the problem but how can I realise all this features as a widget?
I did some tests (took me about 3h) and couldn't get it working. The
best thing I got was <nothing> - a Allocated space without sth. in it.
The reason why I ask here, is because I don't think that I'm the only
one with such a requirement.
Any help is welcome, and thanks for your time!
Andreas Rammhold
Here's a code snip of what I currently have working (without a custom
widget):
myWindow::myWindow() :
Image("button.png")
{
EventBox.add
(Image);
EventBox.set_events(Gdk::BUTTON_PRESS_MASK | Gdk::ENTER_NOTIFY_MASK |
Gdk::LEAVE_NOTIFY_MASK );
EventBox.signal_button_press_event().connect(sigc::mem_fun(*this,&myWindow::onPress));
EventBox.signal_enter_notify_event
().connect(sigc::mem_fun(*this,&myWindow::onEnter));
EventBox.signal_leave_notify_event().connect(sigc::mem_fun(*this,&myWindow::onLeave));
add(EventBox);
show_all_children();
}
myWindow::onPress(GdkEventButton* event) {std::cout << "press"<<std::endl; }
myWindow::onEnter(GdkEventButton* event) {std::cout <<
"enter"<<std::endl; Image.set("hover.png"); }
myWindow::onLeave(GdkEventButton* event) {std::cout <<
"press"<<std::endl;
Image.set("button.png"); }
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]