Code

Rename LPE: mirror reflect --> mirror symmetry
[inkscape.git] / src / display / canvas-grid.h
index ec5e52c9060ccce17f04322816a82872c3f24c0c..a9e317534b90dd12740b80b49aef5681741f8786 100644 (file)
@@ -6,26 +6,24 @@
  *
  * Generic (and quite unintelligent) grid item for gnome canvas
  *
- * Copyright (C) Johan Engelen 2006 <johan@shouraizou.nl>
+ * Copyright (C) Johan Engelen 2006-2007 <johan@shouraizou.nl>
  * Copyright (C) Lauris Kaplinski 2000
  *
  */
 
-#include <display/sp-canvas.h>
-#include "xml/repr.h"
-#include <gtkmm/box.h>
-
+#include <cstring>
+#include <string>
 
+#include <gtkmm/box.h>
 #include <gtkmm.h>
+
+#include "display/sp-canvas.h"
+#include "xml/repr.h"
 #include "ui/widget/color-picker.h"
 #include "ui/widget/scalar-unit.h"
-
 #include "ui/widget/registered-widget.h"
 #include "ui/widget/registry.h"
-#include "ui/widget/tolerance-slider.h"
-
 #include "xml/node-event-vector.h"
-
 #include "snapper.h"
 #include "line-snapper.h"
 
@@ -67,9 +65,12 @@ GtkType grid_canvasitem_get_type (void);
 
 class CanvasGrid {
 public:
-    CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc);
     virtual ~CanvasGrid();
 
+    // TODO: see effect.h and effect.cpp from live_effects how to link enums to SVGname to typename properly. (johan)
+    const char * getName();
+    const char * getSVGName();
+    GridType     getGridType();
     static const char * getName(GridType type);
     static const char * getSVGName(GridType type);
     static GridType     getGridTypeFromSVGName(const char * typestr);
@@ -83,10 +84,10 @@ public:
     virtual void Update (NR::Matrix const &affine, unsigned int flags) = 0;
     virtual void Render (SPCanvasBuf *buf) = 0;
 
-    virtual void readRepr() {};
-    virtual void onReprAttrChanged (Inkscape::XML::Node * /*repr*/, const gchar */*key*/, const gchar */*oldval*/, const gchar */*newval*/, bool /*is_interactive*/) {};
+    virtual void readRepr() = 0;
+    virtual void onReprAttrChanged (Inkscape::XML::Node * /*repr*/, const gchar */*key*/, const gchar */*oldval*/, const gchar */*newval*/, bool /*is_interactive*/) = 0;
 
-    virtual Gtk::Widget & getWidget() = 0;
+    Gtk::Widget * newWidget();
 
     Inkscape::XML::Node * repr;
     SPDocument *doc;
@@ -95,24 +96,33 @@ public:
 
     static void on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data);
 
+    bool isVisible() { return (isEnabled() &&visible); };
+    bool isEnabled();
+
 protected:
+    CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc, GridType type);
+
+    virtual Gtk::Widget * newSpecificWidget() = 0;
+
     GSList * canvasitems;  // list of created canvasitems
 
     SPNamedView * namedview;
 
-    Gtk::VBox vbox;
+    Inkscape::UI::Widget::Registry _wr;
+    bool visible;
+
+    GridType gridtype;
 
 private:
     CanvasGrid(const CanvasGrid&);
     CanvasGrid& operator=(const CanvasGrid&);
-
 };
 
 
 class CanvasXYGrid : public CanvasGrid {
 public:
     CanvasXYGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc);
-    ~CanvasXYGrid();
+    virtual ~CanvasXYGrid();
 
     void Update (NR::Matrix const &affine, unsigned int flags);
     void Render (SPCanvasBuf *buf);
@@ -120,8 +130,6 @@ public:
     void readRepr();
     void onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive);
 
-    Gtk::Widget & getWidget();
-
     NR::Point origin;
     guint32 color;
     guint32 empcolor;
@@ -134,22 +142,16 @@ public:
                             variables */
     NR::Point ow;      /**< Transformed origin by the affine for the zoom */
     NR::Point sw;      /**< Transformed spacing by the affine for the zoom */
+
+protected:
+    virtual Gtk::Widget * newSpecificWidget();
+
 private:
     CanvasXYGrid(const CanvasXYGrid&);
     CanvasXYGrid& operator=(const CanvasXYGrid&);
 
     void updateWidgets();
 
-    Gtk::Table table;
-
-    Inkscape::UI::Widget::RegisteredUnitMenu    _rumg, _rums;
-    Inkscape::UI::Widget::RegisteredScalarUnit  _rsu_ox, _rsu_oy, _rsu_sx, _rsu_sy;
-    Inkscape::UI::Widget::RegisteredColorPicker _rcp_gcol, _rcp_gmcol;
-    Inkscape::UI::Widget::RegisteredSuffixedInteger _rsi;
-    Inkscape::UI::Widget::RegisteredCheckButton _rcb_dotted;
-
-    Inkscape::UI::Widget::Registry _wr;
-
     bool render_dotted;
 };
 
@@ -159,6 +161,7 @@ class CanvasXYGridSnapper : public LineSnapper
 {
 public:
     CanvasXYGridSnapper(CanvasXYGrid *grid, SPNamedView const *nv, NR::Coord const d);
+    bool ThisSnapperMightSnap() const;
 
 private:
     LineList _getSnapLines(NR::Point const &p) const;