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. 
thought is to somehow get the current number of pixels per inch
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
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);
I've done this

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;
and I've done this too

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;


For the rulers, I set:
width  = widget->allocation.width;
height = widget->allocation.height;

every time I resize the drawing area.  In addition to the rulers, my
program indicates the cursor position in the status bar.  The problem
is that the little triangle on the ruler is not in the position shown
in the status bar, but is off (on the low side) by up to 10 pixels. 
Very disconcerting to the user.  What's worse, the magnitude of the
discrepancy seems to vary and I don't know why.  The rulers and the
drawing area are set in a table embedded in a scrollable window.

Steven I. Usdansky
usdanskys rocketmail com

Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices

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