index 2c2f3363bcdc44bcc014d320d128a4c00b773069..f193f04d20fa44aa9bc65e783e7023cb6bc8eb16 100644 (file)
* Lauris Kaplinski <lauris@kaplinski.com>
* Jon Phillips <jon@rejon.org>
* Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
* Lauris Kaplinski <lauris@kaplinski.com>
* Jon Phillips <jon@rejon.org>
* Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
- * Bob Jamison <ishmal@users.sf.net>
+ * Bob Jamison <ishmal@users.sf.net>
*
* Copyright (C) 2000 - 2006 Authors
*
*
* Copyright (C) 2000 - 2006 Authors
*
* this table and in ghostscript.
*
* The versions here, in mm, are the official sizes according to
* this table and in ghostscript.
*
* The versions here, in mm, are the official sizes according to
- * <a href="http://en.wikipedia.org/wiki/Paper_sizes">http://en.wikipedia.org/wiki/Paper_sizes</a>
+ * <a href="http://en.wikipedia.org/wiki/Paper_sizes">http://en.wikipedia.org/wiki/Paper_sizes</a>
* at 2005-01-25. (The ISO entries in the below table
* were produced mechanically from the table on that page.)
*
* at 2005-01-25. (The ISO entries in the below table
* were produced mechanically from the table on that page.)
*
* inconsistent rounding rules when converting from mm to pt.
*/
/** \todo
* inconsistent rounding rules when converting from mm to pt.
*/
/** \todo
- * Should we include the JIS B series (used in Japan)
+ * 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) ?
* (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) ?
//#if 0
//#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;
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.
- */
+ don't know what D and E series are used for.
+ */
{ "C0", 917, 1297, SP_UNIT_MM },
{ "C1", 648, 917, SP_UNIT_MM },
{ "C0", 917, 1297, SP_UNIT_MM },
{ "C1", 648, 917, SP_UNIT_MM },
{ "CSE", 462, 649, SP_UNIT_PT },
{ "US #10 Envelope", 4.125, 9.5, SP_UNIT_IN },
{ "CSE", 462, 649, SP_UNIT_PT },
{ "US #10 Envelope", 4.125, 9.5, SP_UNIT_IN },
- // TODO: Select landscape by default.
+ // TODO: Select landscape by default.
/* See http://www.hbp.com/content/PCR_envelopes.cfm for a much larger list of US envelope
sizes. */
{ "DL Envelope", 110, 220, SP_UNIT_MM },
/* See http://www.hbp.com/content/PCR_envelopes.cfm for a much larger list of US envelope
sizes. */
{ "DL Envelope", 110, 220, SP_UNIT_MM },
- // TODO: Select landscape by default.
+ // TODO: Select landscape by default.
{ "Ledger/Tabloid", 11, 17, SP_UNIT_IN },
/* Note that `Folio' (used in QPrinter/KPrinter) is deliberately absent from this list, as it
means different sizes to different people: different people may expect the width to be
{ "Ledger/Tabloid", 11, 17, SP_UNIT_IN },
/* Note that `Folio' (used in QPrinter/KPrinter) is deliberately absent from this list, as it
means different sizes to different people: different people may expect the width to be
page size to the list, then please consider using a name more specific than just `Folio' or
`Foolscap Folio'. */
{ "Banner 468x60", 60, 468, SP_UNIT_PX },
page size to the list, then please consider using a name more specific than just `Folio' or
`Foolscap Folio'. */
{ "Banner 468x60", 60, 468, SP_UNIT_PX },
- // TODO: Select landscape by default.
+ // TODO: Select landscape by default.
{ "Icon 16x16", 16, 16, SP_UNIT_PX },
{ "Icon 32x32", 32, 32, SP_UNIT_PX },
{ "Icon 48x48", 48, 48, SP_UNIT_PX },
{ "Icon 16x16", 16, 16, SP_UNIT_PX },
{ "Icon 32x32", 32, 32, SP_UNIT_PX },
{ "Icon 48x48", 48, 48, SP_UNIT_PX },
/**
* Constructor
/**
* Constructor
- */
-PageSizer::PageSizer() : Gtk::VBox(false,4)
+ */
+PageSizer::PageSizer(Registry & _wr)
+ : Gtk::VBox(false,4),
+ _dimensionUnits( _("U_nits:"), "units", _wr ),
+ _dimensionWidth( _("_Width:"), _("Width of paper"), "width", _dimensionUnits, _wr ),
+ _dimensionHeight( _("_Height:"), _("Height of paper"), "height", _dimensionUnits, _wr ),
+ _widgetRegistry(&_wr)
{
{
-
-
- //# Set up the Paper Size combo box
+ //# Set up the Paper Size combo box
_paperSizeListStore = Gtk::ListStore::create(_paperSizeListColumns);
_paperSizeList.set_model(_paperSizeListStore);
_paperSizeList.append_column(_("Name"),
_paperSizeListStore = Gtk::ListStore::create(_paperSizeListColumns);
_paperSizeList.set_model(_paperSizeListStore);
_paperSizeList.append_column(_("Name"),
- _paperSizeListColumns.nameColumn);
+ _paperSizeListColumns.nameColumn);
_paperSizeList.append_column(_("Description"),
_paperSizeList.append_column(_("Description"),
- _paperSizeListColumns.descColumn);
- _paperSizeList.set_headers_visible(false);
+ _paperSizeListColumns.descColumn);
+ _paperSizeList.set_headers_visible(false);
_paperSizeListSelection = _paperSizeList.get_selection();
_paperSizeListSelection = _paperSizeList.get_selection();
- _paper_size_list_connection =
- _paperSizeListSelection->signal_changed().connect (
- sigc::mem_fun (*this, &PageSizer::on_paper_size_list_changed));
- _paperSizeListScroller.add(_paperSizeList);
- _paperSizeListScroller.set_shadow_type(Gtk::SHADOW_IN);
- _paperSizeListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
- _paperSizeListScroller.set_size_request(-1, 90);
-
+ _paper_size_list_connection =
+ _paperSizeListSelection->signal_changed().connect (
+ sigc::mem_fun (*this, &PageSizer::on_paper_size_list_changed));
+ _paperSizeListScroller.add(_paperSizeList);
+ _paperSizeListScroller.set_shadow_type(Gtk::SHADOW_IN);
+ _paperSizeListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
+ _paperSizeListScroller.set_size_request(-1, 90);
+
for (PaperSizeRec const *p = inkscape_papers; p->name; p++)
for (PaperSizeRec const *p = inkscape_papers; p->name; p++)
- {
+ {
Glib::ustring name = p->name;
char formatBuf[80];
snprintf(formatBuf, 79, "%0.1f x %0.1f", p->smaller, p->larger);
Glib::ustring name = p->name;
char formatBuf[80];
snprintf(formatBuf, 79, "%0.1f x %0.1f", p->smaller, p->larger);
//## Set up orientation radio buttons
pack_start (_orientationBox, false, false, 0);
//## Set up orientation radio buttons
pack_start (_orientationBox, false, false, 0);
- _orientationLabel.set_label(_("Page orientation:"));
+ _orientationLabel.set_label(_("Page orientation:"));
_orientationBox.pack_start(_orientationLabel, false, false, 0);
_orientationBox.pack_start(_orientationLabel, false, false, 0);
+ _landscapeButton.set_use_underline();
_landscapeButton.set_label(_("_Landscape"));
_landscapeButton.set_label(_("_Landscape"));
- _landscapeButton.set_active(true);
+ _landscapeButton.set_active(true);
Gtk::RadioButton::Group group = _landscapeButton.get_group();
_orientationBox.pack_end (_landscapeButton, false, false, 5);
Gtk::RadioButton::Group group = _landscapeButton.get_group();
_orientationBox.pack_end (_landscapeButton, false, false, 5);
+ _portraitButton.set_use_underline();
_portraitButton.set_label(_("_Portrait"));
_portraitButton.set_label(_("_Portrait"));
- _portraitButton.set_active(true);
+ _portraitButton.set_active(true);
_orientationBox.pack_end (_portraitButton, false, false, 5);
_portraitButton.set_group (group);
_portraitButton.set_active (true);
_orientationBox.pack_end (_portraitButton, false, false, 5);
_portraitButton.set_group (group);
_portraitButton.set_active (true);
-
+
//## Set up custom size frame
_customFrame.set_label(_("Custom size"));
pack_start (_customFrame, false, false, 0);
//## Set up custom size frame
_customFrame.set_label(_("Custom size"));
pack_start (_customFrame, false, false, 0);
_customTable.set_border_width (4);
_customTable.set_row_spacings (4);
_customTable.set_col_spacings (4);
_customTable.set_border_width (4);
_customTable.set_row_spacings (4);
_customTable.set_col_spacings (4);
+ _customTable.attach(_dimensionWidth, 0,1,0,1);
+ _customTable.attach(_dimensionUnits, 1,2,0,1);
+ _customTable.attach(_dimensionHeight, 0,1,1,2);
+ _customTable.attach(_fitPageButton, 1,2,1,2);
_customFrame.add(_customTable);
_customFrame.add(_customTable);
-
- _fitPageButton.set_label(_("_Fit page to selection"));
- _tips.set_tip(_fitPageButton,
- _("Resize the page to fit the current selection, or the entire drawing if there is no selection"));
-
-
+ _fitPageButton.set_use_underline();
+ _fitPageButton.set_label(_("_Fit page to selection"));
+ _tips.set_tip(_fitPageButton, _("Resize the page to fit the current selection, or the entire drawing if there is no selection"));
}
/**
* Destructor
}
/**
* Destructor
- */
+ */
PageSizer::~PageSizer()
{
}
PageSizer::~PageSizer()
{
}
/**
* Initialize or reset this widget
/**
* Initialize or reset this widget
- */
+ */
void
void
-PageSizer::init (Registry& reg)
+PageSizer::init ()
{
{
+ _landscape_connection = _landscapeButton.signal_toggled().connect (sigc::mem_fun (*this, &PageSizer::on_landscape));
+ _portrait_connection = _portraitButton.signal_toggled().connect (sigc::mem_fun (*this, &PageSizer::on_portrait));
+ _changedw_connection = _dimensionWidth.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed));
+ _changedh_connection = _dimensionHeight.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed));
+ _fitPageButton.signal_clicked().connect(sigc::mem_fun(*this, &PageSizer::fire_fit_canvas_to_selection_or_drawing));
- /*
- 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 = ®
-
- _dimensionUnits.init (_("U_nits:"), "units",
- *_widgetRegistry);
- _dimensionWidth.init (_("_Width:"), _("Width of paper"), "width",
- _dimensionUnits, *_widgetRegistry);
- _dimensionHeight.init (_("_Height:"), _("Height of paper"), "height",
- _dimensionUnits, *_widgetRegistry);
-
- _customTable.attach(*(_dimensionWidth.getSU()), 0,1,0,1);
- _customTable.attach(*(_dimensionUnits._sel), 1,2,0,1);
- _customTable.attach(*(_dimensionHeight.getSU()), 0,1,1,2);
- _customTable.attach(_fitPageButton, 1,2,1,2);
-
- _landscape_connection = _landscapeButton.signal_toggled().connect (
- sigc::mem_fun (*this, &PageSizer::on_landscape));
- _portrait_connection = _portraitButton.signal_toggled().connect (
- sigc::mem_fun (*this, &PageSizer::on_portrait));
- _changedw_connection = _dimensionWidth.getSU()->signal_value_changed().connect (
- sigc::mem_fun (*this, &PageSizer::on_value_changed));
- _changedh_connection = _dimensionHeight.getSU()->signal_value_changed().connect (
- sigc::mem_fun (*this, &PageSizer::on_value_changed));
- _fitPageButton.signal_clicked().connect(
- sigc::mem_fun(*this, &PageSizer::fire_fit_canvas_to_selection_or_drawing));
-
show_all_children();
show_all_children();
-
}
}
* 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
* 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.
+ * standard page size.
*
* \param w, h given in px
*
* \param w, h given in px
- * \param changeList whether to modify the paper size list
+ * \param changeList whether to modify the paper size list
*/
void
PageSizer::setDim (double w, double h, bool changeList)
{
static bool _called = false;
*/
void
PageSizer::setDim (double w, double h, bool changeList)
{
static bool _called = false;
- if (_called)
- return;
+ if (_called) {
+ return;
+ }
_called = true;
_called = true;
-
+
_paper_size_list_connection.block();
_paper_size_list_connection.block();
- _landscape_connection.block();
- _portrait_connection.block();
+ _landscape_connection.block();
+ _portrait_connection.block();
_changedw_connection.block();
_changedh_connection.block();
_changedw_connection.block();
_changedh_connection.block();
SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP);
sp_document_set_width (doc, w, &_px_unit);
sp_document_set_height (doc, h, &_px_unit);
SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP);
sp_document_set_width (doc, w, &_px_unit);
sp_document_set_height (doc, h, &_px_unit);
- sp_document_done (doc, SP_VERB_NONE,
- /* TODO: annotate */ "page-sizer.cpp:301");
- }
-
+ sp_document_done (doc, SP_VERB_NONE, _("Set page size"));
+ }
+
_landscape = ( w > h );
_landscapeButton.set_active(_landscape ? true : false);
_portraitButton.set_active (_landscape ? false : true);
_landscape = ( w > h );
_landscapeButton.set_active(_landscape ? true : false);
_portraitButton.set_active (_landscape ? false : true);
-
+
if (changeList)
{
if (changeList)
{
- int index = find_paper_size(w, h);
- Gtk::TreeModel::Row row = _paperSizeListStore->children()[index];
+ Gtk::TreeModel::Row row = (*find_paper_size(w, h));
if (row)
_paperSizeListSelection->select(row);
}
if (row)
_paperSizeListSelection->select(row);
}
-
- Unit const& unit = _dimensionUnits._sel->getUnit();
+
+ Unit const& unit = _dimensionUnits.getUnit();
_dimensionWidth.setValue (w / unit.factor);
_dimensionHeight.setValue (h / unit.factor);
_paper_size_list_connection.unblock();
_dimensionWidth.setValue (w / unit.factor);
_dimensionHeight.setValue (h / unit.factor);
_paper_size_list_connection.unblock();
- _landscape_connection.unblock();
+ _landscape_connection.unblock();
_portrait_connection.unblock();
_changedw_connection.unblock();
_changedh_connection.unblock();
_portrait_connection.unblock();
_changedw_connection.unblock();
_changedh_connection.unblock();
-
+
_called = false;
}
_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.
+/**
+ * Returns an iterator pointing to a row in paperSizeListStore which
+ * contains a paper of the specified size (specified in px), or
+ * paperSizeListStore->children().end() if no such paper exists.
*/
*/
-int
+Gtk::ListStore::iterator
PageSizer::find_paper_size (double w, double h) const
{
double smaller = w;
PageSizer::find_paper_size (double w, double h) const
{
double smaller = w;
smaller = h; larger = w;
}
smaller = h; larger = w;
}
- g_return_val_if_fail(smaller <= larger, -1);
-
- int index = 0;
+ g_return_val_if_fail(smaller <= larger, _paperSizeListStore->children().end());
+
std::map<Glib::ustring, PaperSize>::const_iterator iter;
for (iter = _paperSizeTable.begin() ;
std::map<Glib::ustring, PaperSize>::const_iterator iter;
for (iter = _paperSizeTable.begin() ;
- iter != _paperSizeTable.end() ; iter++) {
+ iter != _paperSizeTable.end() ; iter++) {
PaperSize paper = iter->second;
SPUnit const &i_unit = sp_unit_get_by_id(paper.unit);
double smallX = sp_units_get_pixels(paper.smaller, i_unit);
double largeX = sp_units_get_pixels(paper.larger, i_unit);
PaperSize paper = iter->second;
SPUnit const &i_unit = sp_unit_get_by_id(paper.unit);
double smallX = sp_units_get_pixels(paper.smaller, i_unit);
double largeX = sp_units_get_pixels(paper.larger, i_unit);
-
- g_return_val_if_fail(smallX <= largeX, -1);
-
+
+ g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end());
+
if ((std::abs(smaller - smallX) <= 0.1) &&
if ((std::abs(smaller - smallX) <= 0.1) &&
- (std::abs(larger - largeX) <= 0.1) )
- return index;
-
- index++;
+ (std::abs(larger - largeX) <= 0.1) ) {
+ Gtk::ListStore::iterator p;
+ // We need to search paperSizeListStore explicitly for the
+ // specified paper size because it is sorted in a different
+ // way than paperSizeTable (which is sorted alphabetically)
+ for (p = _paperSizeListStore->children().begin(); p != _paperSizeListStore->children().end(); p++) {
+ if ((*p)[_paperSizeListColumns.nameColumn] == paper.name) {
+ return p;
+ }
+ }
+ }
}
}
- return -1;
+ return _paperSizeListStore->children().end();
}
/**
* Tell the desktop to change the page size
}
/**
* Tell the desktop to change the page size
- */
+ */
void
PageSizer::fire_fit_canvas_to_selection_or_drawing()
{
SPDesktop *dt = SP_ACTIVE_DESKTOP;
void
PageSizer::fire_fit_canvas_to_selection_or_drawing()
{
SPDesktop *dt = SP_ACTIVE_DESKTOP;
- if (!dt)
- return;
+ if (!dt) {
+ return;
+ }
Verb *verb = Verb::get( SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING );
if (verb) {
SPAction *action = verb->get_action(dt);
if (action)
Verb *verb = Verb::get( SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING );
if (verb) {
SPAction *action = verb->get_action(dt);
if (action)
- sp_action_perform(action, NULL);
+ sp_action_perform(action, NULL);
}
}
}
}
/**
* Paper Size list callback for when a user changes the selection
/**
* Paper Size list callback for when a user changes the selection
- */
+ */
void
PageSizer::on_paper_size_list_changed()
{
void
PageSizer::on_paper_size_list_changed()
{
{
if (!_portraitButton.get_active())
return;
{
if (!_portraitButton.get_active())
return;
- double w = _dimensionWidth.getSU()->getValue ("px");
- double h = _dimensionHeight.getSU()->getValue ("px");
- if (h < w)
- setDim (h, w);
+ double w = _dimensionWidth.getValue ("px");
+ double h = _dimensionHeight.getValue ("px");
+ if (h < w) {
+ setDim (h, w);
+ }
}
/**
* Landscape button callback
}
/**
* Landscape button callback
- */
+ */
void
PageSizer::on_landscape()
{
if (!_landscapeButton.get_active())
return;
void
PageSizer::on_landscape()
{
if (!_landscapeButton.get_active())
return;
- double w = _dimensionWidth.getSU()->getValue ("px");
- double h = _dimensionHeight.getSU()->getValue ("px");
- if (w < h)
- setDim (h, w);
+ double w = _dimensionWidth.getValue ("px");
+ double h = _dimensionHeight.getValue ("px");
+ if (w < h) {
+ setDim (h, w);
+ }
}
/**
* Callback for the dimension widgets
}
/**
* Callback for the dimension widgets
- */
+ */
void
PageSizer::on_value_changed()
{
if (_widgetRegistry->isUpdating()) return;
void
PageSizer::on_value_changed()
{
if (_widgetRegistry->isUpdating()) return;
- setDim (_dimensionWidth.getSU()->getValue("px"),
- _dimensionHeight.getSU()->getValue("px"));
+ setDim (_dimensionWidth.getValue("px"),
+ _dimensionHeight.getValue("px"));
}
}