index 55f63b443b586eaad8d6f84217af0f39985fa42f..bac6854a13e873d874e65526fc3a0bee10c7788c 100644 (file)
* Derek P. Moore <derekm@hackunix.org>
* Lauris Kaplinski <lauris@kaplinski.com>
* Frank Felfe <innerspace@iname.com>
* Derek P. Moore <derekm@hackunix.org>
* Lauris Kaplinski <lauris@kaplinski.com>
* Frank Felfe <innerspace@iname.com>
+ * John Bintz <jcoswell@coswellproductions.org>
+ * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
*
*
+ * Copyright (C) 2007 Johan Engelen
+ * Copyright (C) 2006 John Bintz
* Copyright (C) 1999-2005 Authors
* Copyright (C) 2000-2001 Ximian, Inc.
*
* Copyright (C) 1999-2005 Authors
* Copyright (C) 2000-2001 Ximian, Inc.
*
#include <gtkmm/separator.h>
#include <gtkmm/base.h>
#include <gtkmm/separator.h>
#include <gtkmm/base.h>
+#include <sigc++/functors/mem_fun.h>
+
#include "macros.h"
#include "path-prefix.h"
#include "prefs-utils.h"
#include "macros.h"
#include "path-prefix.h"
#include "prefs-utils.h"
_act_grp(Gtk::ActionGroup::create()),
_ui_mgr(Gtk::UIManager::create()),
_update_s_f(false),
_act_grp(Gtk::ActionGroup::create()),
_ui_mgr(Gtk::UIManager::create()),
_update_s_f(false),
- _update_a_f(false)
+ _update_a_f(false),
+ _interaction_disabled_counter(0)
{
g_warning("Creating new EditWidget");
{
g_warning("Creating new EditWidget");
Gtk::Stock::REDO, Glib::ustring(),
_("PLACEHOLDER, do not translate")));
Gtk::Stock::REDO, Glib::ustring(),
_("PLACEHOLDER, do not translate")));
+ _act_grp->add(Gtk::Action::create("UndoHistory",
+ Stock::UNDO_HISTORY, Glib::ustring(),
+ _("PLACEHOLDER, do not translate")));
+
_act_grp->add(Gtk::Action::create("Cut",
Gtk::Stock::CUT, Glib::ustring(),
_("PLACEHOLDER, do not translate")));
_act_grp->add(Gtk::Action::create("Cut",
Gtk::Stock::CUT, Glib::ustring(),
_("PLACEHOLDER, do not translate")));
void
EditWidget::setTransient (void* p, int i)
{
void
EditWidget::setTransient (void* p, int i)
{
-#ifndef WIN32
gtk_window_set_transient_for (static_cast<GtkWindow*>(p), this->gobj());
if (i==2)
this->Gtk::Window::present();
gtk_window_set_transient_for (static_cast<GtkWindow*>(p), this->gobj());
if (i==2)
this->Gtk::Window::present();
-#endif
}
NR::Point
}
NR::Point
_svg_canvas.widget().queue_draw();
}
_svg_canvas.widget().queue_draw();
}
+void
+EditWidget::requestCanvasUpdateAndWait()
+{
+ requestCanvasUpdate();
+
+ while (gtk_events_pending())
+ gtk_main_iteration_do(FALSE);
+}
+
+void
+EditWidget::enableInteraction()
+{
+ g_return_if_fail(_interaction_disabled_counter > 0);
+
+ _interaction_disabled_counter--;
+
+ if (_interaction_disabled_counter == 0) {
+ this->set_sensitive(true);
+ }
+}
+
+void
+EditWidget::disableInteraction()
+{
+ if (_interaction_disabled_counter == 0) {
+ this->set_sensitive(false);
+ }
+
+ _interaction_disabled_counter++;
+}
+
void
EditWidget::activateDesktop()
{
void
EditWidget::activateDesktop()
{
void
EditWidget::viewSetPosition (NR::Point p)
{
void
EditWidget::viewSetPosition (NR::Point p)
{
- p -= _namedview->gridorigin;
+ // p -= _namedview->gridorigin;
+ /// \todo Why was the origin corrected for the grid origin? (johan)
+
double lo, up, pos, max;
_top_ruler.get_range (lo, up, pos, max);
_top_ruler.set_range (lo, up, p[NR::X], max);
double lo, up, pos, max;
_top_ruler.get_range (lo, up, pos, max);
_top_ruler.set_range (lo, up, p[NR::X], max);
void
EditWidget::updateRulers()
{
void
EditWidget::updateRulers()
{
- NR::Point origin = _namedview->gridorigin;
-
+ //NR::Point gridorigin = _namedview->gridorigin;
+ /// \todo Why was the origin corrected for the grid origin? (johan)
+
NR::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
double lo, up, pos, max;
double const scale = _desktop->current_zoom();
NR::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
double lo, up, pos, max;
double const scale = _desktop->current_zoom();
- double s = viewbox.min()[NR::X] / scale - origin[NR::X];
- double e = viewbox.max()[NR::X] / scale - origin[NR::X];
+ double s = viewbox.min()[NR::X] / scale; //- gridorigin[NR::X];
+ double e = viewbox.max()[NR::X] / scale; //- gridorigin[NR::X];
_top_ruler.get_range(lo, up, pos, max);
_top_ruler.set_range(s, e, pos, e);
_top_ruler.get_range(lo, up, pos, max);
_top_ruler.set_range(s, e, pos, e);
- s = viewbox.min()[NR::Y] / -scale - origin[NR::Y];
- e = viewbox.max()[NR::Y] / -scale - origin[NR::Y];
- _left_ruler.set_range(s, e, origin[NR::Y], e);
+ s = viewbox.min()[NR::Y] / -scale; //- gridorigin[NR::Y];
+ e = viewbox.max()[NR::Y] / -scale; //- gridorigin[NR::Y];
+ _left_ruler.set_range(s, e, 0 /*gridorigin[NR::Y]*/, e);
/// \todo is that correct?
}
/// \todo is that correct?
}
/* The desktop region we always show unconditionally */
SPDocument *doc = _desktop->doc();
/* The desktop region we always show unconditionally */
SPDocument *doc = _desktop->doc();
- NR::Rect const r = sp_item_bbox_desktop(SP_ITEM(SP_DOCUMENT_ROOT(doc)));
- NR::Rect darea(NR::Point(MIN(r.min()[NR::X], -sp_document_width(doc)),
- MIN(r.min()[NR::Y], -sp_document_height(doc))),
- NR::Point(MAX(r.max()[NR::X], 2 * sp_document_width(doc)),
- MAX(r.max()[NR::Y], 2 * sp_document_height(doc))));
+ NR::Rect darea = NR::Rect(NR::Point(-sp_document_width(doc),
+ -sp_document_height(doc)),
+ NR::Point(2 * sp_document_width(doc),
+ 2 * sp_document_height(doc)));
+ darea = NR::union_bounds(darea, sp_item_bbox_desktop(SP_ITEM(SP_DOCUMENT_ROOT(doc))));
/* Canvas region we always show unconditionally */
NR::Rect carea(NR::Point(darea.min()[NR::X] * scale - 64,
/* Canvas region we always show unconditionally */
NR::Rect carea(NR::Point(darea.min()[NR::X] * scale - 64,
NR::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
/* Viewbox is always included into scrollable region */
NR::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
/* Viewbox is always included into scrollable region */
- carea = NR::Rect::union_bounds(carea, viewbox);
+ carea = NR::union_bounds(carea, viewbox);
Gtk::Adjustment *adj = _bottom_scrollbar.get_adjustment();
adj->set_value(viewbox.min()[NR::X]);
Gtk::Adjustment *adj = _bottom_scrollbar.get_adjustment();
adj->set_value(viewbox.min()[NR::X]);
}
}
-/// \todo make this a member function when the signal is a sigc++ signal
-void _namedview_modified (SPNamedView* nv, guint flags, EditWidget* ew)
-{
- if (flags & SP_OBJECT_MODIFIED_FLAG)
- {
- ew->_dt2r = 1.0 / nv->doc_units->unittobase;
- ew->_top_ruler.update_metric();
- ew->_left_ruler.update_metric();
- ew->_tooltips.set_tip (ew->_top_ruler, ew->_top_ruler.get_tip());
- ew->_tooltips.set_tip (ew->_left_ruler, ew->_left_ruler.get_tip());
- ew->updateRulers();
+void EditWidget::_namedview_modified (SPObject *obj, guint flags) {
+ SPNamedView *nv = static_cast<SPNamedView *>(obj);
+ if (flags & SP_OBJECT_MODIFIED_FLAG) {
+ this->_dt2r = 1.0 / nv->doc_units->unittobase;
+ this->_top_ruler.update_metric();
+ this->_left_ruler.update_metric();
+ this->_tooltips.set_tip(this->_top_ruler, this->_top_ruler.get_tip());
+ this->_tooltips.set_tip(this->_left_ruler, this->_left_ruler.get_tip());
+ this->updateRulers();
}
}
}
}
_svg_canvas.init (_desktop);
_desktop->init (_namedview, _svg_canvas.spobj());
sp_namedview_window_from_document (_desktop);
_svg_canvas.init (_desktop);
_desktop->init (_namedview, _svg_canvas.spobj());
sp_namedview_window_from_document (_desktop);
+ sp_namedview_update_layers_from_document (_desktop);
_dt2r = 1.0 / _namedview->doc_units->unittobase;
/// \todo convert to sigc++ when SPObject hierarchy gets converted
/* Listen on namedview modification */
_dt2r = 1.0 / _namedview->doc_units->unittobase;
/// \todo convert to sigc++ when SPObject hierarchy gets converted
/* Listen on namedview modification */
- g_signal_connect (G_OBJECT (_desktop->namedview), "modified",
- G_CALLBACK (_namedview_modified), this);
+ _namedview_modified_connection = _desktop->namedview->connectModified(sigc::mem_fun(*this, &EditWidget::_namedview_modified));
_layer_selector.setDesktop (_desktop);
_selected_style_status.setDesktop (_desktop);
_layer_selector.setDesktop (_desktop);
_selected_style_status.setDesktop (_desktop);
if (_desktop) {
_layer_selector.unreference();
Inkscape::NSApplication::Editor::removeDesktop (_desktop); // clears selection too
if (_desktop) {
_layer_selector.unreference();
Inkscape::NSApplication::Editor::removeDesktop (_desktop); // clears selection too
- sp_signal_disconnect_by_data (G_OBJECT (_desktop->namedview), this);
+ _namedview_modified_connection.disconnect();
_desktop->destroy();
Inkscape::GC::release (_desktop);
_desktop = 0;
_desktop->destroy();
Inkscape::GC::release (_desktop);
_desktop = 0;
NR::Rect d(NR::Point(0, 0),
NR::Point(sp_document_width(_desktop->doc()), sp_document_height(_desktop->doc())));
NR::Rect d(NR::Point(0, 0),
NR::Point(sp_document_width(_desktop->doc()), sp_document_height(_desktop->doc())));
- if (fabs(d.dimensions()[NR::X]) < 1.0 || fabs(d.dimensions()[NR::Y]) < 1.0) {
+ if (d.isEmpty(1.0)) {
return;
}
_desktop->set_display_area(d.min()[NR::X], d.min()[NR::Y], d.max()[NR::X], d.max()[NR::Y], 10);
return;
}
_desktop->set_display_area(d.min()[NR::X], d.min()[NR::Y], d.max()[NR::X], d.max()[NR::Y], 10);
- _namedview_modified(_desktop->namedview, SP_OBJECT_MODIFIED_FLAG, this);
+ _namedview_modified(_desktop->namedview, SP_OBJECT_MODIFIED_FLAG);
setTitle (SP_DOCUMENT_NAME(_desktop->doc()));
}
setTitle (SP_DOCUMENT_NAME(_desktop->doc()));
}