Re: [gtkmm] Right justified TreeView column - restricting expansion of final column



On Sat, 2002-07-20 at 02:01, Daniel Evison wrote:
> 
> Another question please - if the right-most column in a TreeView has to be
> right justified, what is the best way to restrict it's width to something so
> it doesn't end up right-justified in the left-over space the the TreeView
> doesn't need?
> eg. (approx) if a window is 1000 wide, and there are five columns which only
> need to be 100 each, the fifth ends up 600 wide, and right-justified in it.
> I want it to be right justified in only the space that it needs (say 100),
> with the blank space (say 500) to the right.
> I tried some combinations of these properties of cell_renderer:
>   property_width
>   property_is_expander
>   property_is_expanded
> but couldn't get it to work.

I think it doesn't make sense to play with these properties. I'm not
100% sure of that, but I think that property_width is set by the
renderer itself or by underlaying pango calls when the renderer is
filled with text to display in the cell. So even if you modify this
property it will be overwriten a while later. It might work only if you
create your own renderer.
And properties is_expander and is_expanded are probably used by TreeView
when displaying data from a TreeStore to display row expand icon.

> I have gotten around this by adding a new blank column as the final column
> which gets expanded to the left-over space, but that required a blank field
> in the model too, and doesn't seem the most elegant solution.

I think it's the easiest solution. You don't need extra column in model,
you can use insert_column_with_data_func with any column already used in
the model (one model column may be used to display multiple view columns
so it's no problem) and add some fake callback that always leaves the
renderer blank.
Other solution that may work if you use a fixed width font (or display
numbers only - numbers are usually fixed sized even in proportional
fonts) is also using data_func to setup the renderer and simply use
left-aligned text and add some spaces in front of each number to align
them.
Most complex solution would probably be playing with Pango or FreeType
to find actual size of displayed text and then compute custom alignment
for each cell, but it might be very slow.

-- 
struct Sig {
  string name("     J a r e k   D u k a t     ");
  string mail(" madmaxer (at) poczta (dot) fm ");
};


----------------------------------------------------------------------
Na dobry poczatek dnia... >>> http://link.interia.pl/f1629 





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