Re: more size questions
- From: Chris Vine <chris cvine freeserve co uk>
- To: "D. R. Evans" <doc evans gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: more size questions
- Date: Fri, 9 Sep 2011 13:19:28 +0100
On Thu, 08 Sep 2011 15:55:35 -0600
"D. R. Evans" <doc evans gmail com> wrote:
> My understanding (such as it is) after googling is that in order to
> control the foreground and background colours for a Label, one
> actually has to define both a Label and an EventBox of the same size
> (because the background of a Label is actually transparent).
Gtk::Widget::modify_fg() certainly works on labels in GTK+2 and
Gtk::Widget::override_color() in GTK+3. Very probably
Gtk::Widget::modify_bg() and Gtk::Widget::override_background_color()
work as well (I don't know), although possibly the fact that labels do
not have their own GdkWindow object may affect setting a background. If
that is the case, an event box will deal with it.
However, often using styles is a better way of doing it.
What have you actually tried doing, and what doesn't work for you?
You don't need to worry about the "same size" stuff on this particular
point. If you add a label to an event box (which derives from Gtk::Bin
and therefore only takes one child) they will by definition be the same
size through the ordinary size request mechanisms. That is not to say
that your travails with getting a fixed label size in your other thread
are ill judged (for fixed size maybe the easiest thing is to write your
text to a cairo pattern with cairo or pango-cairo and paint that onto a
Gdk::Window from a Gtk::DrawingArea - see eg
http://zetcode.com/tutorials/cairographicstutorial/cairotext/ for an
example written in C). Most people however want all their text displayed
and the normal approach is to size it at construction time for the
longest known text it will display. You can use pango-cairo then to
size it for you. That only of course works if the text is determined
programatically rather than by user input.
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]