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



Yes, you missed something:  Check out:

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

If one goes far enough down the rabbit hole, one eventually finds the missing piece of the puzzle, i.e.  Pango::Attribute::create_attr_background.

I am trying to accomplish your goal in my own code as follows:

<code>
Gtk::Entry *lookup_entry;
Pango::AttrList attrlist;
Glib::RefPtr<Pango::Layout> layout;
Pango::Attribute attr;


lookup_entry = new Gtk::Entry();
layout = lookup_entry->get_layout();
attrlist = layout.get_attributes();
attr = Pango::Attribute::create_attr_background(65535,0,0);
attrlist.change(attr);
layout.set_attributes(attrlist);
</code>

According to the docs, the foregoing code should work.  However, I am running into a compiler error which reads:

'get_attributes' undeclared (first use this function)

I get another message for 'set_attributes', even though when I peruse <pangomm/layout.h> both of these functions are prototyped for the 'Pango::Layout' class.  Maybe Murray can wade in at this point and rescue both of us?


On Tue, 2005-02-15 at 09:08, Akos Maroy wrote:
Bob Caryl wrote:
> 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.

I did look at the Pango layout, but the word 'color' does not appear on 
that page anywhere. I also looked at the AttrList, Context, etc. 
structures referenced on this page, but they don't contain any 
color-related information either.

am I missing something?
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]