Re: Ruler question

I apologize if this question has already been answered, but I can't
find the answer and could use some guidance.  I'd like the ruler in
my app to indicate screen pixels rather than units of 1/72 inch.  My
thought is to somehow get the current number of pixels per inch from
X and use this to set pixels_per_unit in the GtkRulerMetric for my
ruler.  Is this even possible, and, if so, how do I get the required
data from X?

I am not sure I understand, by default gtk rulers work in pixels,
not 1/72 inch. Anyway you can set this with:

gtk_ruler_set_metric (GTK_RULER (ruler), GTK_PIXELS);

There is a working example that comes with GTK showing how 
to implement a ruler, this example is in pixels, it shows 
how to set an area with 600 pixels by 400 pixels with two rulers:
a horizontal ruler from 7 to 13 with a mark every 100 pixels,
a vertical ruler from 0 to 400 pixels with a mark
every 100 pixels.

(Anyway, you should be able to get the rulers
width and height in pixels with:

width  = widget->allocation.width;
height = widget->allocation.height;

You probably need to put the ruler inside an 
event_box and measure the event_box instead.
Even better, you can measure the area directly,
if there is one, with the same commands.)

You can get the current ruler position with:

double position = GTK_RULER (hruler)->position;


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