ruler.cpp revision 2ead517a14f1be388a96d10027ba2401f73ca832
561N/A * Customized ruler class for inkscape. Note that this is a fork of 837N/A * The GIMP code is released under the GPL 3. The GIMP code itself 561N/A * is a fork of the now-obsolete GtkRuler widget from GTK+ 2. 919N/A * Major differences between implementations in Inkscape and GIMP are 919N/A * - We use a 1,2,4,8... scale for inches and 1,2,5,10... for everything 919N/A * else. GIMP uses 1,2,5,10... for everything. 919N/A * - We use a default font size of PANGO_SCALE_X_SMALL for labels, 919N/A * GIMP uses PANGO_SCALE_SMALL (i.e., a bit larger than ours). 919N/A * - We abbreviate large numbers in tick-labels (e.g., 10000 -> 10k) 919N/A * Lauris Kaplinski <lauris@kaplinski.com> 919N/A * Frank Felfe <innerspace@iname.com> 919N/A * bulia byak <buliabyak@users.sf.net> 919N/A * Diederik van Lierop <mail@diedenrezi.nl> 919N/A * Jon A. Cruz <jon@joncruz.org> 919N/A * Alex Valavanis <valavanisalex@gmail.com> 561N/A * Copyright (C) 1999-2011 authors 561N/A * Released under GNU GPL, read the file 'COPYING' for more information /* All distances below are in 1/72nd's of an inch. (According to * Adobe, that's a point, but points are really 1/72.27 in.) // Ruler metric for general use. {
1,
2,
5,
10,
25,
50,
100,
250,
500,
1000,
2500,
5000,
10000,
25000,
50000,
100000 },
// Ruler metric for inch scales. {
1,
2,
4,
8,
16,
32,
64,
128,
256,
512,
1024,
2048,
4096,
8192,
16384,
32768 },
_(
"The orientation of the ruler"),
/* FIXME: Should probably use g_param_spec_enum */ _(
"Lower limit of ruler"),
_(
"Upper limit of ruler"),
_(
"Position of mark on the ruler"),
_(
"Maximum size of the ruler"),
" background-color: @theme_bg_color;\n" " background-color: @bg_color;\n" * @lower: the lower limit of the ruler * @upper: the upper limit of the ruler * @max_size: the maximum size of the ruler used when calculating the space to * This sets the range of the ruler. * @lower: (allow-none): location to store lower limit of the ruler, or %NULL * @upper: (allow-none): location to store upper limit of the ruler, or %NULL * @max_size: location to store the maximum size of the ruler used when calculating * the space to leave for the text, or %NULL. * Retrieves values indicating the range and current position of a #SPRuler. * See sp_ruler_set_range(). /* If a backing store exists, restore the ruler */ * @orientation: the ruler's orientation * Return value: a new #SPRuler widget. /* Returns TRUE if a translation should be done */ * sp_ruler_remove_track_widget: * @widget: the track widget to remove * Removes a previously added track widget from the ruler. See * sp_ruler_add_track_widget(). * @unit: the #SPMetric to set the ruler to * This sets the unit of the ruler. * Return value: the unit currently used in the @ruler widget. * @position: the position to set the ruler to * This sets the position of the ruler. * Return value: the current position of the @ruler widget. * Use the maximum extents of the ruler to determine the largest * possible number to be displayed. Calculate the height in pixels * of this displayed text. Use this height to find a scale which * leaves sufficient room for drawing the ruler. * We calculate the text size as for the vruler instead of * actually measuring the text width, so that the result for the * scale looks consistent with an accompanying vruler /* Inkscape change to ruler: Use a 1,2,4,8... scale for inches * or a 1,2,5,10... scale for everything else */ /* drawing starts here */ /* hack to get proper subdivisions at full pixels */ /* Calculate the length of the tickmarks. Make sure that * this length increases for each set of ticks // due to the typical values for cur, lower and increment, pos will often end up to // be e.g. 641.50000000000; rounding behaviour is not defined in such a case (see round.h) // and jitter will be apparent (upon redrawing some of the lines on the ruler might jump a // by a pixel, and jump back on the next redraw). This is suppressed by adding 1e-9 (that's only one nanopixel ;-)) c-file-style:"stroustrup" c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :