document-properties.cpp revision c026f3fa6df4c655f56c0aa5d2fc30bed8758004
/** \file
*
* Document properties dialog, Gtkmm-style
*
* Authors:
* bulia byak <buliabyak@users.sf.net>
* Bryce W. Harrington <bryce@bryceharrington.org>
* Lauris Kaplinski <lauris@kaplinski.com>
* Jon Phillips <jon@rejon.org>
* Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
*
* Copyright (C) 2006-2007 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 2000 - 2005 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtkmm.h>
#include "ui/widget/color-picker.h"
#include "ui/widget/scalar-unit.h"
#include "xml/node-event-vector.h"
#include "prefs-utils.h"
#include "inkscape.h"
#include "verbs.h"
#include "document.h"
#include "desktop-handles.h"
#include "desktop.h"
#include "sp-namedview.h"
#include "document-properties.h"
#include "display/canvas-grid.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
#define SPACE_SIZE_X 15
#define SPACE_SIZE_Y 10
//===================================================
//---------------------------------------------------
static DocumentProperties *_instance = 0;
static void on_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void * data);
static void on_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void * data);
static void on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer);
on_child_added, /* child_added */
on_child_removed, /* child_removed */
NULL, /* content_changed */
NULL /* order_changed */
};
{
_instance = new DocumentProperties();
return *_instance;
}
void
{
if (_instance)
{
delete _instance;
_instance = 0;
}
}
_prefs_path("dialogs.documentoptions")
{
build_page();
build_guides();
build_snap();
_grids_button_remove.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onRemoveGrid));
}
void
{
update();
_doc_replaced_connection = SP_ACTIVE_DESKTOP->connectDocumentReplaced (sigc::ptr_fun (on_doc_replaced));
}
{
repr->removeListenerByData (this);
root->removeListenerByData (this);
}
//========================================================================
/**
* Helper function that attaches widgets in a 3xn table. The widgets come in an
* array that has two entries per table row. The two entries code for four
* possible cases: (0,0) means insert space in first column; (0, non-0) means
* widget in columns 2-3; (non-0, 0) means label in columns 1-3; and
* (non-0, non-0) means two widgets in columns 2 and 3.
**/
inline void
{
for (unsigned i = 0, r = start; i < n; i += 2)
{
{
}
else
{
if (arr[i+1])
else if (arr[i])
{
}
else
{
}
}
++r;
}
}
void
{
_page_page.show();
_rcp_bg.init (_("Back_ground:"), _("Background color"), _("Color and transparency of the page background (also used for bitmap export)"),
_rcb_canb.init (_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false);
_rcb_bord.init (_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false);
_("Color of the page border"),
_rcb_shad.init (_("_Show border shadow"), _("If set, page border shows a shadow on its right and lower side"), "inkscape:showpageshadow", _wr, false);
{
label_gen, 0,
0, 0,
label_for, 0,
0, &_page_sizer,
0, 0,
label_bor, 0,
};
}
void
{
_page_guides.show();
_("Color of a guideline when it is under mouse"),
{
label_gui, 0,
};
}
void
{
_page_snap.show();
//General options
_("Snap bounding box corners to grid lines, to guides, and to other bounding boxes (Snapping of bounding boxes is only available in the selector tool)"),
"inkscape:snap-bbox", _wr);
_("Snap nodes to grid lines, to guides, to paths, and to other nodes"),
"inkscape:snap-nodes", _wr);
//Options for snapping to objects
_("Snap nodes to object paths"),
"inkscape:object-paths", _wr);
_("Snap nodes and guides to object nodes"),
"inkscape:object-nodes", _wr);
_("Snap bounding box corners to other bounding box corners"),
"inkscape:bbox-nodes", _wr);
_("Snap bounding box corners and guides to bounding box edges"),
"inkscape:bbox-paths", _wr);
_("Snapping distance, in screen pixels, for snapping to objects"),
_("If set, objects snap to the nearest object, regardless of distance"),
"objecttolerance", _wr);
//Options for snapping to grids
_("Snapping distance, in screen pixels, for snapping to grid"),
_("If set, objects snap to the nearest grid line, regardless of distance"),
"gridtolerance", _wr);
//Options for snapping to guides
_("Snapping distance, in screen pixels, for snapping to guides"),
_("If set, objects snap to the nearest guide, regardless of distance"),
"guidetolerance", _wr);
{
label_g, 0,
0, 0,
0, 0,
0, 0,
0, 0,
label_o, 0,
0, 0,
label_gr, 0,
0, 0,
label_gu, 0,
};
}
void
{
_("Snap to grid-guide intersections"),
"inkscape:snap-intersection-grid-guide", _wr);
_("Snap to intersections of line segments ('snap to paths' must be enabled, see the previous tab)"),
"inkscape:snap-intersection-line-segments", _wr);
_("While dragging a guide, snap to object nodes or bounding box corners ('snap to nodes' or 'snap to bounding box corners', both on the previous tab, must be enabled)"),
"inkscape:snap-guide", _wr);
//Applies to both nodes and guides, but not to bboxes, that's why its located here
_("Also snap the rotation center of an object when snapping nodes or guides"),
"inkscape:snap-center", _wr);
{
label_i, 0,
0, 0,
label_m, 0,
};
}
/**
* Called for _updating_ the dialog (e.g. when a new grid was manually added in XML)
*/
void
{
//remove all tabs
}
//add tabs
bool grids_present = false;
grids_present = true;
}
if (grids_present)
else
}
/**
* Build grid page of dialog.
*/
void
{
/// \todo FIXME: gray out snapping when grid is off.
/// Dissenting view: you want snapping without grid.
for (gint t = 0; t <= GRID_MAXTYPENR; t++) {
}
}
}
/**
* Update dialog widgets from desktop. Also call updateWidget routines of the grids.
*/
void
{
if (_wr.isUpdating()) return;
_wr.setUpdating (true);
set_sensitive (true);
//-----------------------------------------------------------page page
//-----------------------------------------------------------guide
//-----------------------------------------------------------snap
//-----------------------------------------------------------grids page
_wr.setUpdating (false);
}
//--------------------------------------------------------------------
void
{
{
}
hide();
}
static void
on_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void * /*data*/)
{
if (!_instance)
return;
}
static void
on_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void * /*data*/)
{
if (!_instance)
return;
}
/**
* Called when XML node attribute changed; updates dialog widgets.
*/
static void
on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer)
{
if (!_instance)
return;
}
static void
{
if (!_instance)
return;
_instance->_doc_replaced_connection = SP_ACTIVE_DESKTOP->connectDocumentReplaced (sigc::ptr_fun (on_doc_replaced));
}
static void
{
if (!_instance)
return;
}
static void
{
if (!_instance)
return;
}
/*########################################################################
# BUTTON CLICK HANDLERS (callbacks)
########################################################################*/
void
{
}
void
{
return;
if (!page) return;
// find the grid with name tabtext (it's id) and delete that one.
found_grid = grid;
break; // break out of for-loop
}
}
if (found_grid) {
// delete the grid that corresponds with the selected tab
// when the grid is deleted from SVG, the SPNamedview handler automatically deletes the object, so found_grid becomes an invalid pointer!
}
}
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0))
indent-tabs-mode:nilu
fill-column:99
End:
*/
// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :