index 626c3094107116fecb279779930106091382e9a1..bac6854a13e873d874e65526fc3a0bee10c7788c 100644 (file)
* 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.
*
_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");
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();
-#endif
}
NR::Point
_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::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);
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();
- 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);
- 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?
}
/* 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,
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]);
_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
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;
}