Re: Change background color when mouse over



2008/6/18 Germán Diago <germandiago gmail com>:
> 2008/6/18 Jamiil <arbolone gmail com>:
>> Hi Diego!
>> I had the intention of writing such widget, and I think it is fantastic that
>> you have taken the initiative. I would very much appreciate if you post the
>> source code somewhere, so that the whole community can benefit.
>>
>> Keep up the good work Diego!
>>
>> Germán Diago wrote:
>>>
>>> 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.
>>> _______________________________________________
>>> gtkmm-list mailing list
>>> gtkmm-list gnome org
>>> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>>>
>>>
>>
>>
>> --
>> Happiness has many doors, and when one of them closes another opens, yet we
>> spent so much time looking at the one that is shut that we don't see the one
>> that just opened..
>>
>>
>
> Ok. Now I have a semi-implementation. It works for now. It's a little
> ugly, but it's testing for now. I'd
> like to find a way to draw a rounded selection around the image. When
> the user clicks the area in
> which the image is held, it will be drawn in red and if you put the
> mouse over, it will be blue. This
> is just testing.
>
And José, thanks for your time too, that helped.


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