page-sizer.cpp revision d5541e1a99b939f95e3be8604da2780cf39602bb
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/**
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * @file
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc *
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Paper-size widget and helper functions
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/*
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Authors:
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * bulia byak <buliabyak@users.sf.net>
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Lauris Kaplinski <lauris@kaplinski.com>
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Jon Phillips <jon@rejon.org>
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Bob Jamison <ishmal@users.sf.net>
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Abhishek Sharma
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc *
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Copyright (C) 2000 - 2006 Authors
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc *
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Released under GNU GPL. Read the file 'COPYING' for more information
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#ifdef HAVE_CONFIG_H
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc# include <config.h>
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#endif
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "page-sizer.h"
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include <cmath>
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include <string>
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include <string.h>
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include <vector>
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include <glibmm/i18n.h>
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include <2geom/transforms.h>
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "desktop-handles.h"
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "document.h"
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "desktop.h"
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "helper/action.h"
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "util/units.h"
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "inkscape.h"
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "sp-namedview.h"
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "sp-root.h"
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "ui/widget/button.h"
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng#include "ui/widget/scalar-unit.h"
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "verbs.h"
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "xml/node.h"
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#include "xml/repr.h"
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhanstatic Inkscape::Util::UnitTable unit_table;
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhanusing std::pair;
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhannamespace Inkscape {
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhannamespace UI {
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhannamespace Widget {
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan /** \note
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * The ISO page sizes in the table below differ from ghostscript's idea of page sizes (by
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * less than 1pt). Being off by <1pt should be OK for most purposes, but may cause fuzziness
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * (antialiasing) problems when printing to 72dpi or 144dpi printers or bitmap files due to
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * postscript's different coordinate system (y=0 meaning bottom of page in postscript and top
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * of page in SVG). I haven't looked into whether this does in fact cause fuzziness, I merely
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * note the possibility. Rounding done by extension/internal/ps.cpp (e.g. floor/ceil calls)
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * will also affect whether fuzziness occurs.
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan *
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * The remainder of this comment discusses the origin of the numbers used for ISO page sizes in
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * this table and in ghostscript.
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan *
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * The versions here, in mm, are the official sizes according to
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * <a href="http://en.wikipedia.org/wiki/Paper_sizes">http://en.wikipedia.org/wiki/Paper_sizes</a>
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * at 2005-01-25. (The ISO entries in the below table
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * were produced mechanically from the table on that page.)
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan *
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * (The rule seems to be that A0, B0, ..., D0. sizes are rounded to the nearest number of mm
127ac1c2b792d87fda08d45d8b25e5ffe9293b3efei feng - Sun Microsystems - Beijing China * from the "theoretical size" (i.e. 1000 * sqrt(2) or pow(2.0, .25) or the like), whereas
127ac1c2b792d87fda08d45d8b25e5ffe9293b3efei feng - Sun Microsystems - Beijing China * going from e.g. A0 to A1 always take the floor of halving -- which by chance coincides
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * exactly with flooring the "theoretical size" for n != 0 instead of the rounding to nearest
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * done for n==0.)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc *
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Ghostscript paper sizes are given in gs_statd.ps according to gs(1). gs_statd.ps always
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * uses an integer number of pt: sometimes gs_statd.ps rounds to nearest (e.g. a1), sometimes
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * floors (e.g. a10), sometimes ceils (e.g. a8).
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc *
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * I'm not sure how ghostscript's gs_statd.ps was calculated: it isn't just rounding the
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * "theoretical size" of each page to pt (see a0), nor is it rounding the a0 size times an
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * appropriate power of two (see a1). Possibly it was prepared manually, with a human applying
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * inconsistent rounding rules when converting from mm to pt.
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc /** \todo
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Should we include the JIS B series (used in Japan)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * (JIS B0 is sometimes called JB0, and similarly for JB1 etc)?
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Should we exclude B7--B10 and A7--10 to make the list smaller ?
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Should we include any of the ISO C, D and E series (see below) ?
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcstruct PaperSizeRec {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc char const * const name; //name
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc double const smaller; //lesser dimension
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc double const larger; //greater dimension
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Inkscape::Util::Unit const unit; //units
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc};
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc// list of page formats that should be in landscape automatically
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcstatic std::vector<std::string> lscape_papers;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcstatic void
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcfill_landscape_papers() {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc lscape_papers.push_back("US #10 Envelope");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc lscape_papers.push_back("DL Envelope");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc lscape_papers.push_back("Banner 468x60");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc lscape_papers.push_back("Business Card (ISO 7810)");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc lscape_papers.push_back("Business Card (US)");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc lscape_papers.push_back("Business Card (Europe)");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc lscape_papers.push_back("Business Card (Aus/NZ)");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcstatic PaperSizeRec const inkscape_papers[] = {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "A4", 210, 297, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "US Letter", 8.5, 11, unit_table.getUnit("in") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "US Legal", 8.5, 14, unit_table.getUnit("in") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "US Executive", 7.25, 10.5, unit_table.getUnit("in") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "A0", 841, 1189, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "A1", 594, 841, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "A2", 420, 594, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "A3", 297, 420, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "A5", 148, 210, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "A6", 105, 148, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "A7", 74, 105, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "A8", 52, 74, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "A9", 37, 52, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "A10", 26, 37, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "B0", 1000, 1414, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "B1", 707, 1000, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "B2", 500, 707, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "B3", 353, 500, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "B4", 250, 353, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "B5", 176, 250, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "B6", 125, 176, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "B7", 88, 125, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "B8", 62, 88, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "B9", 44, 62, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "B10", 31, 44, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc//#if 0
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc /*
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan Whether to include or exclude these depends on how
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc big we mind our page size menu
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc becoming. C series is used for envelopes;
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan don't know what D and E series are used for.
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "C0", 917, 1297, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "C1", 648, 917, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "C2", 458, 648, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "C3", 324, 458, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "C4", 229, 324, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "C5", 162, 229, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "C6", 114, 162, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "C7", 81, 114, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "C8", 57, 81, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "C9", 40, 57, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "C10", 28, 40, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "D1", 545, 771, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "D2", 385, 545, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "D3", 272, 385, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "D4", 192, 272, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "D5", 136, 192, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "D6", 96, 136, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "D7", 68, 96, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "E3", 400, 560, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "E4", 280, 400, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "E5", 200, 280, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "E6", 140, 200, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc//#endif
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "CSE", 462, 649, unit_table.getUnit("pt") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "US #10 Envelope", 4.125, 9.5, unit_table.getUnit("in") },
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan /* See http://www.hbp.com/content/PCR_envelopes.cfm for a much larger list of US envelope
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc sizes. */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "DL Envelope", 110, 220, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Ledger/Tabloid", 11, 17, unit_table.getUnit("in") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc /* Note that `Folio' (used in QPrinter/KPrinter) is deliberately absent from this list, as it
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc means different sizes to different people: different people may expect the width to be
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc either 8, 8.25 or 8.5 inches, and the height to be either 13 or 13.5 inches, even
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc restricting our interpretation to foolscap folio. If you wish to introduce a folio-like
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc page size to the list, then please consider using a name more specific than just `Folio' or
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc `Foolscap Folio'. */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Banner 468x60", 60, 468, unit_table.getUnit("px") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Icon 16x16", 16, 16, unit_table.getUnit("px") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Icon 32x32", 32, 32, unit_table.getUnit("px") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Icon 48x48", 48, 48, unit_table.getUnit("px") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc /* business cards */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Business Card (ISO 7810)", 53.98, 85.60, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Business Card (US)", 2, 3.5, unit_table.getUnit("in") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Business Card (Europe)", 55, 85, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Business Card (Aus/NZ)", 55, 90, unit_table.getUnit("mm") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc // Start Arch Series List
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Arch A", 9, 12, unit_table.getUnit("in") }, // 229 x 305 mm
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Arch B", 12, 18, unit_table.getUnit("in") }, // 305 x 457 mm
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Arch C", 18, 24, unit_table.getUnit("in") }, // 457 x 610 mm
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Arch D", 24, 36, unit_table.getUnit("in") }, // 610 x 914 mm
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Arch E", 36, 48, unit_table.getUnit("in") }, // 914 x 1219 mm
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "Arch E1", 30, 42, unit_table.getUnit("in") }, // 762 x 1067 mm
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc /*
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * The above list of Arch sizes were taken from the following site:
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * http://en.wikipedia.org/wiki/Paper_size
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Further detail can be found at http://www.ansi.org
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Sizes are assumed to be arbitrary rounding to MM unless shown to be otherwise
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * No conflicting information was found regarding sizes in MM
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * September 2009 - DAK
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { NULL, 0, 0, unit_table.getUnit("px") },
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc};
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc//########################################################################
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc//# P A G E S I Z E R
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc//########################################################################
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc//The default unit for this widget and its calculations
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcstatic Inkscape::Util::Unit _px_unit = unit_table.getUnit("px");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/**
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Constructor
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcPageSizer::PageSizer(Registry & _wr)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc : Gtk::VBox(false,4),
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionUnits( _("U_nits:"), "units", _wr ),
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionWidth( _("_Width:"), _("Width of paper"), "width", _dimensionUnits, _wr ),
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionHeight( _("_Height:"), _("Height of paper"), "height", _dimensionUnits, _wr ),
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTop( _("T_op margin:"), _("Top margin"), "fit-margin-top", _wr ),
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginLeft( _("L_eft:"), _("Left margin"), "fit-margin-left", _wr),
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginRight( _("Ri_ght:"), _("Right margin"), "fit-margin-right", _wr),
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginBottom( _("Botto_m:"), _("Bottom margin"), "fit-margin-bottom", _wr),
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _lockMarginUpdate(false),
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _widgetRegistry(&_wr)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc{
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc // set precision of scalar entry boxes
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _wr.setUpdating (true);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionWidth.setDigits(5);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionHeight.setDigits(5);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTop.setDigits(5);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginLeft.setDigits(5);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginRight.setDigits(5);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginBottom.setDigits(5);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _wr.setUpdating (false);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //# Set up the Paper Size combo box
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeListStore = Gtk::ListStore::create(_paperSizeListColumns);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeList.set_model(_paperSizeListStore);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeList.append_column(_("Name"),
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeListColumns.nameColumn);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeList.append_column(_("Description"),
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeListColumns.descColumn);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeList.set_headers_visible(false);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeListSelection = _paperSizeList.get_selection();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paper_size_list_connection =
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeListSelection->signal_changed().connect (
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc sigc::mem_fun (*this, &PageSizer::on_paper_size_list_changed));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeListScroller.add(_paperSizeList);
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan _paperSizeListScroller.set_shadow_type(Gtk::SHADOW_IN);
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan _paperSizeListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeListScroller.set_size_request(-1, 90);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan fill_landscape_papers();
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc for (PaperSizeRec const *p = inkscape_papers; p->name; p++)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Glib::ustring name = p->name;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc char formatBuf[80];
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc snprintf(formatBuf, 79, "%0.1f x %0.1f", p->smaller, p->larger);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Glib::ustring desc = formatBuf;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc desc.append(" " + p->unit.abbr);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc PaperSize paper(name, p->smaller, p->larger, p->unit);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeTable[name] = paper;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Gtk::TreeModel::Row row = *(_paperSizeListStore->append());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc row[_paperSizeListColumns.nameColumn] = name;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc row[_paperSizeListColumns.descColumn] = desc;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //Gtk::TreeModel::iterator iter = _paperSizeListStore->children().begin();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //if (iter)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc // _paperSizeListSelection->select(iter);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc pack_start (_paperSizeListScroller, true, true, 0);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //## Set up orientation radio buttons
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc pack_start (_orientationBox, false, false, 0);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _orientationLabel.set_label(_("Orientation:"));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _orientationBox.pack_start(_orientationLabel, false, false, 0);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _landscapeButton.set_use_underline();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _landscapeButton.set_label(_("_Landscape"));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _landscapeButton.set_active(true);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Gtk::RadioButton::Group group = _landscapeButton.get_group();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _orientationBox.pack_end (_landscapeButton, false, false, 5);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _portraitButton.set_use_underline();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _portraitButton.set_label(_("_Portrait"));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _portraitButton.set_active(true);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _orientationBox.pack_end (_portraitButton, false, false, 5);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _portraitButton.set_group (group);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _portraitButton.set_active (true);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc // Setting default custom unit to document unit
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc SPDesktop *dt = SP_ACTIVE_DESKTOP;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc SPNamedView *nv = sp_desktop_namedview(dt);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _wr.setUpdating (true);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (nv->units) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionUnits.setUnit(nv->units);
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan } else if (nv->doc_units) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionUnits.setUnit(nv->doc_units);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _wr.setUpdating (false);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //## Set up custom size frame
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customFrame.set_label(_("Custom size"));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc pack_start (_customFrame, false, false, 0);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customFrame.add(_customDimTable);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.set_border_width(4);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#if WITH_GTKMM_3_0
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.set_row_spacing(4);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.set_column_spacing(4);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionWidth.set_hexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionWidth.set_vexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.attach(_dimensionWidth, 0, 0, 1, 1);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionUnits.set_hexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionUnits.set_vexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.attach(_dimensionUnits, 1, 0, 1, 1);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionHeight.set_hexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionHeight.set_vexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.attach(_dimensionHeight, 0, 1, 1, 1);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageMarginExpander.set_hexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageMarginExpander.set_vexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.attach(_fitPageMarginExpander, 0, 2, 2, 1);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#else
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf _customDimTable.resize(3, 2);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.set_row_spacings(4);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.set_col_spacings(4);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.attach(_dimensionWidth, 0,1, 0,1);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.attach(_dimensionUnits, 1,2, 0,1);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.attach(_dimensionHeight, 0,1, 1,2);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.attach(_fitPageMarginExpander, 0,2, 2,3);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#endif
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimTabOrderGList = NULL;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionWidth.gobj());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionHeight.gobj());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionUnits.gobj());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimTabOrderGList = g_list_append(_dimTabOrderGList, _fitPageMarginExpander.gobj());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Glib::ListHandle<Widget *> dimFocusChain(_dimTabOrderGList, Glib::OWNERSHIP_NONE);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.set_focus_chain(dimFocusChain);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //## Set up fit page expander
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageMarginExpander.set_use_underline();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageMarginExpander.set_label(_("Resi_ze page to content..."));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageMarginExpander.add(_marginTable);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //## Set up margin settings
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.set_border_width(4);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#if WITH_GTKMM_3_0
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.set_row_spacing(4);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.set_column_spacing(4);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTopAlign.set_hexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTopAlign.set_vexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.attach(_marginTopAlign, 0, 0, 2, 1);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginLeftAlign.set_hexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginLeftAlign.set_vexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.attach(_marginLeftAlign, 0, 1, 1, 1);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginRightAlign.set_hexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginRightAlign.set_vexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.attach(_marginRightAlign, 1, 1, 1, 1);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginBottomAlign.set_hexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginBottomAlign.set_vexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.attach(_marginBottomAlign, 0, 2, 2, 1);
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageButtonAlign.set_hexpand();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageButtonAlign.set_vexpand();
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan _marginTable.attach(_fitPageButtonAlign, 0, 3, 2, 1);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#else
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.set_border_width(4);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.set_row_spacings(4);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.set_col_spacings(4);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.attach(_marginTopAlign, 0,2, 0,1);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.attach(_marginLeftAlign, 0,1, 1,2);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.attach(_marginRightAlign, 1,2, 1,2);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.attach(_marginBottomAlign, 0,2, 2,3);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTable.attach(_fitPageButtonAlign, 0,2, 3,4);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#endif
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTopAlign.set(0.5, 0.5, 0.0, 1.0);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginTopAlign.add(_marginTop);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginLeftAlign.set(0.0, 0.5, 0.0, 1.0);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginLeftAlign.add(_marginLeft);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginRightAlign.set(1.0, 0.5, 0.0, 1.0);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginRightAlign.add(_marginRight);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginBottomAlign.set(0.5, 0.5, 0.0, 1.0);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginBottomAlign.add(_marginBottom);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageButtonAlign.set(0.5, 0.5, 0.0, 1.0);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageButtonAlign.add(_fitPageButton);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageButton.set_use_underline();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageButton.set_label(_("_Resize page to drawing or selection"));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageButton.set_tooltip_text(_("Resize the page to fit the current selection, or the entire drawing if there is no selection"));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/**
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan * Destructor
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcPageSizer::~PageSizer()
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan{
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc g_list_free(_dimTabOrderGList);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/**
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Initialize or reset this widget
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcvoid
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcPageSizer::init ()
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc{
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _landscape_connection = _landscapeButton.signal_toggled().connect (sigc::mem_fun (*this, &PageSizer::on_landscape));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _portrait_connection = _portraitButton.signal_toggled().connect (sigc::mem_fun (*this, &PageSizer::on_portrait));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _changedw_connection = _dimensionWidth.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _changedh_connection = _dimensionHeight.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageButton.signal_clicked().connect(sigc::mem_fun(*this, &PageSizer::fire_fit_canvas_to_selection_or_drawing));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc show_all_children();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/**
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Set document dimensions (if not called by Doc prop's update()) and
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * set the PageSizer's widgets and text entries accordingly. If
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * 'changeList' is true, then adjust the paperSizeList to show the closest
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * standard page size.
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc *
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * \param w, h given in px
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * \param changeList whether to modify the paper size list
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhanvoid
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcPageSizer::setDim (double w, double h, bool changeList)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc{
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China static bool _called = false;
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China if (_called) {
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China return;
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _called = true;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paper_size_list_connection.block();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _landscape_connection.block();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _portrait_connection.block();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _changedw_connection.block();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _changedh_connection.block();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc double const old_height = doc->getHeight();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc doc->setWidth (Inkscape::Util::Quantity(w, &_px_unit));
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China doc->setHeight (Inkscape::Util::Quantity(h, &_px_unit));
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China // The origin for the user is in the lower left corner; this point should remain stationary when
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China Geom::Translate const vert_offset(Geom::Point(0, (old_height - h)));
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China doc->getRoot()->translateChildItems(vert_offset);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size"));
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China }
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China if ( w != h ) {
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _landscapeButton.set_sensitive(true);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _portraitButton.set_sensitive (true);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _landscape = ( w > h );
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _landscapeButton.set_active(_landscape ? true : false);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _portraitButton.set_active (_landscape ? false : true);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China } else {
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _landscapeButton.set_sensitive(false);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _portraitButton.set_sensitive (false);
127ac1c2b792d87fda08d45d8b25e5ffe9293b3efei feng - Sun Microsystems - Beijing China }
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China if (changeList)
127ac1c2b792d87fda08d45d8b25e5ffe9293b3efei feng - Sun Microsystems - Beijing China {
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China Gtk::TreeModel::Row row = (*find_paper_size(w, h));
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China if (row)
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _paperSizeListSelection->select(row);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China }
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China Unit const& unit = _dimensionUnits.getUnit();
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _dimensionWidth.setValue (w / unit.factor);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _dimensionHeight.setValue (h / unit.factor);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _paper_size_list_connection.unblock();
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _landscape_connection.unblock();
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _portrait_connection.unblock();
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _changedw_connection.unblock();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _changedh_connection.unblock();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _called = false;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/**
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Updates the scalar widgets for the fit margins. (Just changes the value
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * of the ui widgets to match the xml).
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcvoid
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcPageSizer::updateFitMarginsUI(Inkscape::XML::Node *nv_repr)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc{
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (!_lockMarginUpdate) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc double value = 0.0;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (sp_repr_get_double(nv_repr, "fit-margin-top", &value)) {
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan _marginTop.setValue(value);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (sp_repr_get_double(nv_repr, "fit-margin-left", &value)) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginLeft.setValue(value);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (sp_repr_get_double(nv_repr, "fit-margin-right", &value)) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginRight.setValue(value);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (sp_repr_get_double(nv_repr, "fit-margin-bottom", &value)) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _marginBottom.setValue(value);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/**
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Returns an iterator pointing to a row in paperSizeListStore which
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * contains a paper of the specified size (specified in px), or
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * paperSizeListStore->children().end() if no such paper exists.
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcGtk::ListStore::iterator
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcPageSizer::find_paper_size (double w, double h) const
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc{
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc double smaller = w;
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan double larger = h;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if ( h < w ) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc smaller = h; larger = w;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf g_return_val_if_fail(smaller <= larger, _paperSizeListStore->children().end());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc std::map<Glib::ustring, PaperSize>::const_iterator iter;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc for (iter = _paperSizeTable.begin() ;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc iter != _paperSizeTable.end() ; ++iter) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc PaperSize paper = iter->second;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Inkscape::Util::Unit const &i_unit = paper.unit;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc double smallX = Inkscape::Util::Quantity::convert(paper.smaller, &i_unit, &_px_unit);
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan double largeX = Inkscape::Util::Quantity::convert(paper.larger, &i_unit, &_px_unit);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if ((std::abs(smaller - smallX) <= 0.1) &&
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc (std::abs(larger - largeX) <= 0.1) ) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Gtk::ListStore::iterator p;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc // We need to search paperSizeListStore explicitly for the
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc // specified paper size because it is sorted in a different
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc // way than paperSizeTable (which is sorted alphabetically)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc for (p = _paperSizeListStore->children().begin(); p != _paperSizeListStore->children().end(); ++p) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if ((*p)[_paperSizeListColumns.nameColumn] == paper.name) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc return p;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc return _paperSizeListStore->children().end();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/**
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Tell the desktop to fit the page size to the selection or drawing.
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcvoid
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini VaradhanPageSizer::fire_fit_canvas_to_selection_or_drawing()
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc{
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc SPDesktop *dt = SP_ACTIVE_DESKTOP;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (!dt) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc return;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc SPDocument *doc;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc SPNamedView *nv;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Inkscape::XML::Node *nv_repr;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan if ((doc = sp_desktop_document(SP_ACTIVE_DESKTOP))
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc && (nv = sp_document_namedview(doc, 0))
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc && (nv_repr = nv->getRepr())) {
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan _lockMarginUpdate = true;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc sp_repr_set_svg_double(nv_repr, "fit-margin-top", _marginTop.getValue());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc sp_repr_set_svg_double(nv_repr, "fit-margin-left", _marginLeft.getValue());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc sp_repr_set_svg_double(nv_repr, "fit-margin-right", _marginRight.getValue());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc sp_repr_set_svg_double(nv_repr, "fit-margin-bottom", _marginBottom.getValue());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _lockMarginUpdate = false;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Verb *verb = Verb::get( SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING );
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (verb) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc SPAction *action = verb->get_action(dt);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (action) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc sp_action_perform(action, NULL);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/**
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Paper Size list callback for when a user changes the selection
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcvoid
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcPageSizer::on_paper_size_list_changed()
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc{
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //Glib::ustring name = _paperSizeList.get_active_text();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Gtk::TreeModel::iterator miter = _paperSizeListSelection->get_selected();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if(!miter)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //error?
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc return;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Gtk::TreeModel::Row row = *miter;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Glib::ustring name = row[_paperSizeListColumns.nameColumn];
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc std::map<Glib::ustring, PaperSize>::const_iterator piter =
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeTable.find(name);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (piter == _paperSizeTable.end()) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc g_warning("paper size '%s' not found in table", name.c_str());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc return;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc PaperSize paper = piter->second;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc double w = paper.smaller;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc double h = paper.larger;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (std::find(lscape_papers.begin(), lscape_papers.end(), paper.name.c_str()) != lscape_papers.end()) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc // enforce landscape mode if this is desired for the given page format
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _landscape = true;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc } else {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc // otherwise we keep the current mode
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _landscape = _landscapeButton.get_active();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Inkscape::Util::Unit const &src_unit = paper.unit;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc w = Inkscape::Util::Quantity::convert(w, &src_unit, &_px_unit);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc h = Inkscape::Util::Quantity::convert(h, &src_unit, &_px_unit);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (_landscape)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc setDim (h, w, false);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc else
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc setDim (w, h, false);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/**
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Portrait button callback
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcvoid
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcPageSizer::on_portrait()
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc{
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (!_portraitButton.get_active())
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc return;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc double w = _dimensionWidth.getValue ("px");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc double h = _dimensionHeight.getValue ("px");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (h < w) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc setDim (h, w);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni/**
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Landscape button callback
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanonivoid
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael VanoniPageSizer::on_landscape()
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc{
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (!_landscapeButton.get_active())
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc return;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc double w = _dimensionWidth.getValue ("px");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc double h = _dimensionHeight.getValue ("px");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (w < h) {
e2cf88ac9d753a00c17aa235f6afdc76574fe3a6Quaker Fang setDim (h, w);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc }
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/**
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Callback for the dimension widgets
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc */
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcvoid
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcPageSizer::on_value_changed()
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc{
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (_widgetRegistry->isUpdating()) return;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc setDim (_dimensionWidth.getValue("px"),
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _dimensionHeight.getValue("px"));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc} // namespace Widget
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc} // namespace UI
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc} // namespace Inkscape
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/*
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Local Variables:
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc mode:c++
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc c-file-style:"stroustrup"
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China c-file-offsets:((innamespace . 0)(inline-open . 0))
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China indent-tabs-mode:nil
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc fill-column:99
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc End:
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc*/
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc