Change background color when mouse over
- From: "Germán Diago" <germandiago gmail com>
- To: gtkmm-list gnome org
- Subject: Change background color when mouse over
- Date: Wed, 18 Jun 2008 01:16:18 +0200
Hello. I'm implementing a custom widget, which is a Gtk::VBox and
contains a Gtk::Image and a label.
I want the widget to change color when the mouse goes over it (I just
want to change the VBox zone)
Looking at the documentation I found a way to change the color for
Gtk::VBox with a Gtk::EventBox, but
I don't know how to color it just when the mouse goes over it.
Any help, please?
Here is the code:
class PhotoTile : public Gtk::VBox
{
private:
Gtk::VBox box_;
Gtk::Image image_;
Gtk::Label label_;
Gtk::EventBox evtbox_;
std::string imagename_;
public:
PhotoTile()
{
box_.set_spacing(12);
box_.set_border_width(12);
evtbox_.add(box_);
evtbox_.modify_bg(Gtk::STATE_NORMAL, Gdk::Color("blue"));
}
void setImage(const std::string & imagepath)
{
image_.set(imagepath);
box_.pack_start(image_, false, false);
imagename_ = std::string(Glib::path_get_basename(imagepath), 0,
Glib::path_get_basename(imagepath).find_last_of('.'));
label_.set_text("<b>" + imagename_ + "</b>");
label_.set_use_markup(true);
box_.pack_start(label_, false, false);
pack_start(evtbox_, false, false);
show_all();
}
};
And thanks for your time.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]