can't set background color for Gtk::Entry



I'm trying to change the background color for a Gtk::Entry widget. I tried all sorts of thins, like:

// assume entry is a pointer to a Gtk::Entry
// and getBgColor() returnd a Gtk::Color object

    entry->modify_bg(Gtk::STATE_NORMAL, getBgColor());
    entry->modify_bg(Gtk::STATE_ACTIVE, getBgColor());
    entry->modify_bg(Gtk::STATE_PRELIGHT, getBgColor());
    entry->modify_bg(Gtk::STATE_SELECTED, getBgColor());
    entry->modify_bg(Gtk::STATE_INSENSITIVE, getBgColor());

    Glib::RefPtr<Gtk::Style>     style = entry->get_style();
    style->set_bg(Gtk::STATE_NORMAL, getBgColor());
    style->set_bg(Gtk::STATE_ACTIVE, getBgColor());
    style->set_bg(Gtk::STATE_PRELIGHT, getBgColor());
    style->set_bg(Gtk::STATE_SELECTED, getBgColor());
    style->set_bg(Gtk::STATE_INSENSITIVE, getBgColor());
    entry->set_style(style);


unfortunately, none of the above works - the background color for the Gtk::Entry does not change :(

what am I doing wrong? (using Gtk-- 2.5.5)


Akos



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