summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5bf9e75)
raw | patch | inline | side by side (parent: 5bf9e75)
author | Abhishek Sharma public <spyzerdotabhishek0at-signgmaildotcom> | |
Wed, 11 Aug 2010 14:49:55 +0000 (20:19 +0530) | ||
committer | Abhishek Sharma public <spyzerdotabhishek0at-signgmaildotcom> | |
Wed, 11 Aug 2010 14:49:55 +0000 (20:19 +0530) |
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index 2046b95101aaca86b3c43e837fc9ec9673ded798..9e97aa432fd1ebe4830f841ba7267de837c33832 100644 (file)
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
int wx, wy;
SPDesktop *desktop = dtw->desktop;
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview);
+ //Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview);
gdk_window_get_pointer(GTK_WIDGET(dtw->canvas)->window, &wx, &wy, NULL);
Geom::Point const event_win(wx, wy);
Geom::Point const event_dt(desktop->w2d(event_w));
// explicitly show guidelines; if I draw a guide, I want them on
- sp_repr_set_boolean(repr, "showguides", TRUE);
- sp_repr_set_boolean(repr, "inkscape:guide-bbox", TRUE);
+ /*sp_repr_set_boolean(repr, "showguides", TRUE);
+ sp_repr_set_boolean(repr, "inkscape:guide-bbox", TRUE);*/
+
+ desktop->namedview->setGuides(true);
// calculate the normal of the guidelines when dragged from the edges of rulers.
Geom::Point normal_bl_to_tr(-1.,1.); //bottomleft to topright
@@ -183,7 +185,8 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge
Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide");
sp_repr_set_point(repr, "orientation", normal);
sp_repr_set_point(repr, "position", from_2geom(event_dt));
- SP_OBJECT_REPR(desktop->namedview)->appendChild(repr);
+ //SP_OBJECT_REPR(desktop->namedview)->appendChild(repr);
+ desktop->namedview->appendChild(repr);
Inkscape::GC::release(repr);
SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE,
_("Create guide"));
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 9a8725fac7054ebc7bb5c8934ef95020e0a3540c..049b5fcf80604bab290882db2933b793a83bbd85 100644 (file)
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
|| SP_IS_FLOWDIV(o)
|| SP_IS_FLOWPARA(o)
|| SP_IS_TEXTPATH(o))
- && !SP_OBJECT_REPR(o)->attribute("style"))
+ && /*!SP_OBJECT_REPR(o)->attribute("style")*/ !o->getAttribute("style"))
&&
!(SP_IS_FLOWREGION(o) ||
SP_IS_FLOWREGIONEXCLUDE(o) ||
}
}
- sp_repr_css_change(SP_OBJECT_REPR(o), css_set, "style");
+ //sp_repr_css_change(SP_OBJECT_REPR(o), css_set, "style");
+ o->changeCSS(css_set,"style");
sp_repr_css_attr_unref(css_set);
}
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 3f9fc7806a0b98a9a97e65f057d3181e27695aa6..e7ef2897e9e22fa57de4e9c1c0b233de749e3e46 100644 (file)
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -970,10 +970,12 @@ void SPDesktop::applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool(tool_path + "/usecurrent") && css_current) {
- sp_repr_css_set(obj->getRepr(), css_current, "style");
+ //sp_repr_css_set(obj->getRepr(), css_current, "style");
+ obj->setCSS(css_current,"style");
} else {
SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/style");
- sp_repr_css_set(obj->getRepr(), css, "style");
+ //sp_repr_css_set(obj->getRepr(), css, "style");
+ obj->setCSS(css,"style");
sp_repr_css_attr_unref(css);
}
if (css_current) {
}
} else {
//there is no grid present at the moment. add a rectangular grid and make it visible
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview);
- Inkscape::CanvasGrid::writeNewGridToRepr(repr, sp_desktop_document(this), Inkscape::GRID_RECTANGULAR);
+ //Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview);
+ //Inkscape::CanvasGrid::writeNewGridToRepr(repr, sp_desktop_document(this), Inkscape::GRID_RECTANGULAR);
+ namedview->writeNewGrid(sp_desktop_document(this), Inkscape::GRID_RECTANGULAR);
showGrids(true);
}
}
void SPDesktop::toggleSnapGlobal()
{
- bool v = namedview->snap_manager.snapprefs.getSnapEnabledGlobally();
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview);
- sp_repr_set_boolean(repr, "inkscape:snap-global", !v);
+ //bool v = namedview->snap_manager.snapprefs.getSnapEnabledGlobally();
+ //Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview);
+ //sp_repr_set_boolean(repr, "inkscape:snap-global", !v);
+ bool v=namedview->getSnapGlobal();
+ namedview->setSnapGlobal(!v);
}
//----------------------------------------------------------------------
diff --git a/src/document.cpp b/src/document.cpp
index 6b72f0bb802faed78125f390ae6558c7860f0571..702c58d5dc871025201e4792edcfe8eb3042252b 100644 (file)
--- a/src/document.cpp
+++ b/src/document.cpp
* otherwise. Used for percentage margins.
* \return the margin size in px, else 0.0 if anything is invalid.
*/
-static double getMarginLength(Inkscape::XML::Node * const nv_repr,
- gchar const * const key,
+//static double getMarginLength(/*Inkscape::XML::Node * const nv_repr*/
+/* gchar const * const key,
SPUnit const * const margin_units,
SPUnit const * const return_units,
double const width,
double const height,
- bool const use_width)
-{
- double value;
- if (!sp_repr_get_double (nv_repr, key, &value)) {
+ bool const use_width)*/
+//{
+ // double value;
+ /*if (!sp_repr_get_double (nv_repr, key, &value)) {
return 0.0;
- }
+ }*/
+/* if(!this->storeAsDouble(key,&value)) {
+ return 0.0;
+ }
if (margin_units == &sp_unit_get_by_id (SP_UNIT_PERCENT)) {
return (use_width)? width * value : height * value;
}
return 0.0;
}
return value;
-}
+}*/
/**
* Given a Geom::Rect that may, for example, correspond to the bbox of an object,
SPNamedView *nv = sp_document_namedview(this, 0);
if (with_margins && nv) {
- Inkscape::XML::Node *nv_repr = SP_OBJECT_REPR (nv);
- if (nv_repr != NULL) {
- gchar const * const units_abbr = nv_repr->attribute("units");
+ //Inkscape::XML::Node *nv_repr = SP_OBJECT_REPR (nv);
+ if (nv != NULL) {
+ //gchar const * const units_abbr = nv_repr->attribute("units");
+ gchar const * const units_abbr = nv->getAttribute("units");
SPUnit const *margin_units = NULL;
if (units_abbr != NULL) {
margin_units = sp_unit_get_by_abbreviation(units_abbr);
if (margin_units == NULL) {
margin_units = &px;
}
+ /*
margin_top = getMarginLength(nv_repr, "fit-margin-top",
margin_units, &px, w, h, false);
margin_left = getMarginLength(nv_repr, "fit-margin-left",
margin_right = getMarginLength(nv_repr, "fit-margin-right",
margin_units, &px, w, h, true);
margin_bottom = getMarginLength(nv_repr, "fit-margin-bottom",
- margin_units, &px, w, h, false);
+ margin_units, &px, w, h, false);*/
+ margin_top = nv->getMarginLength("fit-margin-top",margin_units, &px, w, h, false);
+ margin_top = nv->getMarginLength("fit-margin-left",margin_units, &px, w, h, true);
+ margin_top = nv->getMarginLength("fit-margin-right",margin_units, &px, w, h, true);
+ margin_top = nv->getMarginLength("fit-margin-bottom",margin_units, &px, w, h, false);
+
+
}
}
index 7c93c5f07beed800b671dc272465d09c7a5b71ce..f7123da47833d4dac45e44d105183b55d1851ad4 100644 (file)
static Iterator next(Iterator i) { return SP_OBJECT_NEXT(i); }
};
-struct Reverse {
+struct ReverseSelect {
typedef GSList *Iterator;
static Iterator children(SPObject *o) {
root = desktop->currentRoot();
}
- SPItem *item=next_item_from_list<Reverse>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive);
+ SPItem *item=next_item_from_list<ReverseSelect>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive);
if (item) {
selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer);
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index c4ce6355b320c1ace8d770b0fd77b2305887fd25..61685b3217e2b73fc6b93779f35b12b511c52950 100644 (file)
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
#define MIN_ONSCREEN_DISTANCE 50
+void SPNamedView::writeNewGrid(SPDocument *document,int gridtype)
+{
+ g_assert(this->getRepr() != NULL);
+ Inkscape::CanvasGrid::writeNewGridToRepr(this->getRepr(),document,static_cast<Inkscape::GridType>(gridtype));
+}
+
/*
* Restores window geometry from the document settings or defaults in prefs
*/
}
}
+bool SPNamedView::getSnapGlobal() const
+{
+ return this->snap_manager.snapprefs.getSnapEnabledGlobally();
+}
+
+void SPNamedView::setSnapGlobal(bool v)
+{
+ g_assert(this->getRepr() != NULL);
+ sp_repr_set_boolean(this->getRepr(), "inkscape:snap-global", v);
+}
+
void sp_namedview_update_layers_from_document (SPDesktop *desktop)
{
SPObject *layer = NULL;
return (SPNamedView *) nv;
}
+void SPNamedView::setGuides(bool v)
+{
+ g_assert(this->getRepr() != NULL);
+ sp_repr_set_boolean(this->getRepr(), "showguides", v);
+ sp_repr_set_boolean(this->getRepr(), "inkscape:guide-bbox", v);
+
+}
+
+/**
+ * Gets page fitting margin information from the namedview node in the XML.
+ * \param nv_repr reference to this document's namedview
+ * \param key the same key used by the RegisteredScalarUnit in
+ * ui/widget/page-sizer.cpp
+ * \param margin_units units for the margin
+ * \param return_units units to return the result in
+ * \param width width in px (for percentage margins)
+ * \param height height in px (for percentage margins)
+ * \param use_width true if the this key is left or right margins, false
+ * otherwise. Used for percentage margins.
+ * \return the margin size in px, else 0.0 if anything is invalid.
+ */
+double SPNamedView::getMarginLength(gchar const * const key,
+ SPUnit const * const margin_units,
+ SPUnit const * const return_units,
+ double const width,
+ double const height,
+ bool const use_width)
+{
+ double value;
+ if(!this->storeAsDouble(key,&value)) {
+ return 0.0;
+ }
+ if (margin_units == &sp_unit_get_by_id (SP_UNIT_PERCENT)) {
+ return (use_width)? width * value : height * value;
+ }
+ if (!sp_convert_distance (&value, margin_units, return_units)) {
+ return 0.0;
+ }
+ return value;
+}
+
+
/**
* Returns namedview's default metric.
*/
diff --git a/src/sp-namedview.h b/src/sp-namedview.h
index 048096d8c0096e569761f332afb9f0d51be03425..337a67deb10fd557ff23fa9ff8c25b3071e9b2ce 100644 (file)
--- a/src/sp-namedview.h
+++ b/src/sp-namedview.h
#include "sp-object-group.h"
#include "sp-metric.h"
#include "snap.h"
+#include "display/canvas-grid.h"
+#include "document.h"
namespace Inkscape {
class CanvasGrid;
void translateGuides(Geom::Translate const &translation);
void scrollAllDesktops(double dx, double dy, bool is_scrolling);
+ void writeNewGrid(SPDocument *document,int gridtype);
+ bool getSnapGlobal() const;
+ void setSnapGlobal(bool v);
+ void setGuides(bool v);
+
+ private:
+ double getMarginLength(gchar const * const key,SPUnit const * const margin_units,SPUnit const * const return_units,double const width,double const height,bool const use_width);
+ friend class SPDocument;
};
struct SPNamedViewClass {
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index 80f39db4ac9051f5fe223a71ad2ff8a8fa2ec06f..88d24bffd08753216cf44ca6d762131f084e19d2 100644 (file)
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
}
}
+void SPObject::setCSS(SPCSSAttr *css, gchar const *attr)
+{
+ g_assert(this->getRepr() != NULL);
+ sp_repr_css_set(this->getRepr(), css, attr);
+}
+
+void SPObject::changeCSS(SPCSSAttr *css, gchar const *attr)
+{
+ g_assert(this->getRepr() != NULL);
+ sp_repr_css_change(this->getRepr(), css, attr);
+}
+
/**
* Retrieves the children as a GSList object, optionally ref'ing the children
* in the process, if add_ref is specified.
getRepr()->setAttribute(key, NULL, false);
}
+bool SPObject::storeAsDouble( gchar const *key, double *val ) const
+{
+ g_assert(this->getRepr()!= NULL);
+ return sp_repr_get_double(((Inkscape::XML::Node *)(this->getRepr())),key,val);
+}
+
/* Helper */
gchar *
diff --git a/src/sp-object.h b/src/sp-object.h
index 4856bdd06757fccb4e0937da7621f89778eb79ae..b7b3f9cc48df57dadd0ce5e20a1673baa35b375d 100644 (file)
--- a/src/sp-object.h
+++ b/src/sp-object.h
#include "forward.h"
#include "version.h"
#include "util/forward-pointer-iterator.h"
+#include "desktop-style.h"
namespace Inkscape {
namespace XML {
void removeAttribute(gchar const *key, SPException *ex=0);
gchar const *getStyleProperty(gchar const *key, gchar const *def) const;
SPObject *prev();
+ void setCSS(SPCSSAttr *css, gchar const *attr);
+ void changeCSS(SPCSSAttr *css, gchar const *attr);
+ bool storeAsDouble( gchar const *key, double *val ) const;
private:
// Private member functions used in the definitions of setTitle(),