page-sizer.cpp revision d2025f1114b6fefb3954e83c6557afc2cb3af64b
/** \file
*
* Paper-size widget and helper functions
*
* Authors:
* bulia byak <buliabyak@users.sf.net>
* Lauris Kaplinski <lauris@kaplinski.com>
* Jon Phillips <jon@rejon.org>
* Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
* Bob Jamison <ishmal@users.sf.net>
*
* Copyright (C) 2000 - 2006 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#include <cmath>
#include <gtkmm.h>
#include "ui/widget/scalar-unit.h"
#include "inkscape.h"
#include "verbs.h"
#include "desktop-handles.h"
#include "document.h"
#include "desktop.h"
#include "page-sizer.h"
namespace Inkscape {
namespace UI {
namespace Widget {
/** \note
* The ISO page sizes in the table below differ from ghostscript's idea of page sizes (by
* less than 1pt). Being off by <1pt should be OK for most purposes, but may cause fuzziness
* (antialiasing) problems when printing to 72dpi or 144dpi printers or bitmap files due to
* postscript's different coordinate system (y=0 meaning bottom of page in postscript and top
* of page in SVG). I haven't looked into whether this does in fact cause fuzziness, I merely
* will also affect whether fuzziness occurs.
*
* The remainder of this comment discusses the origin of the numbers used for ISO page sizes in
* this table and in ghostscript.
*
* The versions here, in mm, are the official sizes according to
* at 2005-01-25. (The ISO entries in the below table
* were produced mechanically from the table on that page.)
*
* (The rule seems to be that A0, B0, ..., D0. sizes are rounded to the nearest number of mm
* from the "theoretical size" (i.e. 1000 * sqrt(2) or pow(2.0, .25) or the like), whereas
* going from e.g. A0 to A1 always take the floor of halving -- which by chance coincides
* exactly with flooring the "theoretical size" for n != 0 instead of the rounding to nearest
* done for n==0.)
*
* Ghostscript paper sizes are given in gs_statd.ps according to gs(1). gs_statd.ps always
* uses an integer number of pt: sometimes gs_statd.ps rounds to nearest (e.g. a1), sometimes
* floors (e.g. a10), sometimes ceils (e.g. a8).
*
* I'm not sure how ghostscript's gs_statd.ps was calculated: it isn't just rounding the
* "theoretical size" of each page to pt (see a0), nor is it rounding the a0 size times an
* appropriate power of two (see a1). Possibly it was prepared manually, with a human applying
* inconsistent rounding rules when converting from mm to pt.
*/
/** \todo
* Should we include the JIS B series (used in Japan)
* (JIS B0 is sometimes called JB0, and similarly for JB1 etc)?
* Should we exclude B7--B10 and A7--10 to make the list smaller ?
* Should we include any of the ISO C, D and E series (see below) ?
*/
struct PaperSizeRec {
char const * const name; //name
double const smaller; //lesser dimension
double const larger; //greater dimension
};
static PaperSizeRec const inkscape_papers[] = {
//#if 0
/*
Whether to include or exclude these depends on how
big we mind our page size menu
becoming. C series is used for envelopes;
don't know what D and E series are used for.
*/
//#endif
// TODO: Select landscape by default.
/* See http://www.hbp.com/content/PCR_envelopes.cfm for a much larger list of US envelope
sizes. */
// TODO: Select landscape by default.
means different sizes to different people: different people may expect the width to be
either 8, 8.25 or 8.5 inches, and the height to be either 13 or 13.5 inches, even
restricting our interpretation to foolscap folio. If you wish to introduce a folio-like
page size to the list, then please consider using a name more specific than just `Folio' or
`Foolscap Folio'. */
// TODO: Select landscape by default.
{ NULL, 0, 0, SP_UNIT_PX },
};
//########################################################################
//# P A G E S I Z E R
//########################################################################
//The default unit for this widget and its calculations
/**
* Constructor
*/
{
//# Set up the Paper Size combo box
_paperSizeList.set_headers_visible(false);
{
char formatBuf[80];
if (p->unit == SP_UNIT_IN)
else if (p->unit == SP_UNIT_MM)
else if (p->unit == SP_UNIT_PX)
}
//Gtk::TreeModel::Row row = _paperSizeListStore->children()[0];
//if (row)
// _paperSizeListSelection->select(row);
pack_start (_paperSizeListBox, false, false, 0);
//## Set up orientation radio buttons
pack_start (_orientationBox, false, false, 0);
_landscapeButton.set_active(true);
_portraitButton.set_active(true);
_portraitButton.set_active (true);
//## Set up custom size frame
pack_start (_customFrame, false, false, 0);
_("Resize the page to fit the current selection, or the entire drawing if there is no selection"));
}
/**
* Destructor
*/
{
}
/**
* Initialize or reset this widget
*/
void
{
/*
Note that the registered widgets can only be placed onto a
container after they have been init()-ed. That is why some
of the widget creation is in the constructor, and the rest is
here.
*/
_widgetRegistry = ®
}
/**
* Set document dimensions (if not called by Doc prop's update()) and
* set the PageSizer's widgets and text entries accordingly. If
* 'chageList' is true, then adjust the paperSizeList to show the closest
* standard page size.
*
* \param w, h given in px
* \param changeList whether to modify the paper size list
*/
void
{
static bool _called = false;
if (_called)
return;
_called = true;
/* TODO: annotate */ "page-sizer.cpp:301");
}
_landscape = ( w > h );
if (changeList)
{
int index = find_paper_size(w, h);
if (row)
}
_called = false;
}
/**
* Returns an index into paperSizeTable of a paper of the specified
* size (specified in px), or -1 if there's no such paper.
*/
int
PageSizer::find_paper_size (double w, double h) const
{
double smaller = w;
double larger = h;
if ( h < w ) {
}
int index = 0;
return index;
index++;
}
return -1;
}
/**
* Tell the desktop to change the page size
*/
void
{
if (!dt)
return;
if (verb) {
if (action)
}
}
/**
* Paper Size list callback for when a user changes the selection
*/
void
{
//Glib::ustring name = _paperSizeList.get_active_text();
if(!miter)
{
//error?
return;
}
return;
}
if (_landscape)
setDim (h, w, false);
else
setDim (w, h, false);
}
/**
* Portrait button callback
*/
void
{
if (!_portraitButton.get_active())
return;
if (h < w)
setDim (h, w);
}
/**
* Landscape button callback
*/
void
{
if (!_landscapeButton.get_active())
return;
if (w < h)
setDim (h, w);
}
/**
* Callback for the dimension widgets
*/
void
{
if (_widgetRegistry->isUpdating()) return;
}
} // namespace Widget
} // namespace UI
} // namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :