page-sizer.cpp revision d5541e1a99b939f95e3be8604da2780cf39602bb
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Paper-size widget and helper functions
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 * Copyright (C) 2000 - 2006 Authors
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Released under GNU GPL. Read the file 'COPYING' for more information
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhanstatic Inkscape::Util::UnitTable unit_table;
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 * 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 * 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 * (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 * 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 * 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 * 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// list of page formats that should be in landscape automatically
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcstatic void
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc { "US Executive", 7.25, 10.5, unit_table.getUnit("in") },
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 { "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 /* 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 /* 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 // Start Arch Series List
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 * The above list of Arch sizes were taken from the following site:
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//# P A G E S I Z E R
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc//########################################################################
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc//The default unit for this widget and its calculations
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcstatic Inkscape::Util::Unit _px_unit = unit_table.getUnit("px");
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Constructor
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 // set precision of scalar entry boxes
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //# Set up the Paper Size combo box
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeListStore = Gtk::ListStore::create(_paperSizeListColumns);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _paperSizeListSelection = _paperSizeList.get_selection();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc sigc::mem_fun (*this, &PageSizer::on_paper_size_list_changed));
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan _paperSizeListScroller.set_shadow_type(Gtk::SHADOW_IN);
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan _paperSizeListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc for (PaperSizeRec const *p = inkscape_papers; p->name; p++)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc snprintf(formatBuf, 79, "%0.1f x %0.1f", p->smaller, p->larger);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Gtk::TreeModel::Row row = *(_paperSizeListStore->append());
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //Gtk::TreeModel::iterator iter = _paperSizeListStore->children().begin();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //if (iter)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc // _paperSizeListSelection->select(iter);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //## Set up orientation radio buttons
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _orientationBox.pack_start(_orientationLabel, false, false, 0);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Gtk::RadioButton::Group group = _landscapeButton.get_group();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _orientationBox.pack_end (_landscapeButton, false, false, 5);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _orientationBox.pack_end (_portraitButton, false, false, 5);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc // Setting default custom unit to document unit
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //## Set up custom size frame
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.attach(_fitPageMarginExpander, 0, 2, 2, 1);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _customDimTable.attach(_fitPageMarginExpander, 0,2, 2,3);
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 //## Set up fit page expander
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc _fitPageMarginExpander.set_label(_("Resi_ze page to content..."));
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //## Set up margin settings
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan _marginTable.attach(_fitPageButtonAlign, 0, 3, 2, 1);
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 * Initialize or reset this widget
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 * 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 * \param w, h given in px
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * \param changeList whether to modify the paper size list
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China static bool _called = false;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP);
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 _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 _landscapeButton.set_sensitive(false);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _portraitButton.set_sensitive (false);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China Gtk::TreeModel::Row row = (*find_paper_size(w, h));
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China _paperSizeListSelection->select(row);
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 _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 * Updates the scalar widgets for the fit margins. (Just changes the value
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * of the ui widgets to match the xml).
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcPageSizer::updateFitMarginsUI(Inkscape::XML::Node *nv_repr)
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (sp_repr_get_double(nv_repr, "fit-margin-top", &value)) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (sp_repr_get_double(nv_repr, "fit-margin-left", &value)) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (sp_repr_get_double(nv_repr, "fit-margin-right", &value)) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (sp_repr_get_double(nv_repr, "fit-margin-bottom", &value)) {
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 double smaller = w;
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if ( h < w ) {
3a1a8936dac0ebe7e956fa122b0b0d15e62d4108zf g_return_val_if_fail(smaller <= larger, _paperSizeListStore->children().end());
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 g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end());
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 * Tell the desktop to fit the page size to the selection or drawing.
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini VaradhanPageSizer::fire_fit_canvas_to_selection_or_drawing()
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan if ((doc = sp_desktop_document(SP_ACTIVE_DESKTOP))
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 Verb *verb = Verb::get( SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING );
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Paper Size list callback for when a user changes the selection
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc //Glib::ustring name = _paperSizeList.get_active_text();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Gtk::TreeModel::iterator miter = _paperSizeListSelection->get_selected();
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Glib::ustring name = row[_paperSizeListColumns.nameColumn];
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc std::map<Glib::ustring, PaperSize>::const_iterator piter =
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc g_warning("paper size '%s' not found in table", name.c_str());
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 // otherwise we keep the current mode
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc w = Inkscape::Util::Quantity::convert(w, &src_unit, &_px_unit);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc h = Inkscape::Util::Quantity::convert(h, &src_unit, &_px_unit);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc setDim (h, w, false);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc setDim (w, h, false);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Portrait button callback
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (h < w) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Landscape button callback
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc if (w < h) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc * Callback for the dimension widgets
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc} // namespace Widget
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc} // namespace UI
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc} // namespace Inkscape
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc Local Variables:
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// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :