Re: hscale width with value_pos = GTK_POS_RIGHT



On 16 Mar 2002, Havoc Pennington wrote:


Oliver Rauch <oliver rauch rauch-domain de> writes:

I want to create several hscales, packed vertically.
I define the width of the hscales with
gtk_widget_set_size_request(scale, 201, -1)

When I set gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_TOP)
then all the scales have the same width. But this builds to
high widows. So I would like to use GTK_POS_RIGHT instead.

But then gtk_widget_set_size_request(scale, 201, -1) defines
the width of scale + value and because the value ranges
and representations of the values (number of digits) are
different the scales itself have different withs what looks
bad.

I would prefer that the scales all have the same width,
is there a way to make the scales look common with GTK_POS_RIGHT?

The best way of doing this I can think of is to disable the
scale value label (set_show_value or something?) and then just have
your own labels that watch the values. GTK_POS_RIGHT is sort of
useless in many cases for this reason.

Or you could just pre-define the number of digits?
(and put them all in a table)

ie:

for(c=0, c<SOME_NUMBER; c++){
   merge_coeff_adj[c] = gtk_adjustment_new(50, 0, 100.1, 1, 1, 0.1);
   merge_hscale[c] = gtk_hscale_new(GTK_ADJUSTMENT(merge_coeff_adj[c]));
   gtk_widget_show(pi->merge_hscale[c]);
   gtk_table_attach(GTK_TABLE(pi_merge_table), merge_hscale[c], 1, 2, c, c+1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0);
   gtk_scale_set_value_pos(GTK_SCALE(merge_hscale[c]), GTK_POS_RIGHT);
   gtk_scale_set_digits(GTK_SCALE(merge_hscale[c]), 1);
   }

This of course assumes you know the number of digits you want, which you
just might not... :)  THe above works for me anyhow.


Andrew Janke                   e-mail: rotor bic mni mcgill ca
Post-Doc (I think)             http://www.cmr.uq.edu.au/~rotor/
McConnell Brain Imaging Center
Montreal Neurological Institute
Montreal (Canada)




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