Re: can't set background color for Gtk::Entry



Your code doesn't work because you are not modifying the object that actually renders the editable cell within the entry.  You need to retrieve the Pango layout for the entry and modify the background color attribute of the layout.  The following URL is a good place to start delving into this:

http://www.gtkmm.org/gtkmm2/docs/reference/html/classPango_1_1Layout.html

Hope this helps a little.

On Tue, 2005-02-15 at 06:04, Akos Maroy wrote:
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
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
Robert L. Caryl Jr.
Fiscal Systems Inc.
102 Commerce Circle
Madison  AL 35758


256.772.8920 ext. 108 -- Office
256.527.7855 -- Cell

This email message may contain privileged or confidential information. If you are not the recipient, you may not disclose, use, disseminate, distribute, copy or rely on this message or attachment in any way. If you received this email message in error, please return by forwarding the message and its attachment to the sender and then delete the message and its attachment from your computer.  Fiscal Systems, Inc. and its affiliates do not accept liability for any errors, omissions, corruption or virus in the contents of this message or any attachments that arise as a result of e-mail transmission.


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