Code

RegisteredCheckbutton is now subclassed from RegisteredWidget<CheckButton>
authorjohanengelen <johanengelen@users.sourceforge.net>
Tue, 15 Jan 2008 23:43:23 +0000 (23:43 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Tue, 15 Jan 2008 23:43:23 +0000 (23:43 +0000)
12 files changed:
src/display/canvas-axonomgrid.cpp
src/display/canvas-axonomgrid.h
src/display/canvas-grid.cpp
src/display/canvas-grid.h
src/live_effects/parameter/bool.cpp
src/live_effects/parameter/bool.h
src/live_effects/parameter/point.cpp
src/live_effects/parameter/point.h
src/ui/dialog/document-properties.cpp
src/ui/dialog/document-properties.h
src/ui/widget/registered-widget.cpp
src/ui/widget/registered-widget.h

index c64887d1c91e104faf19e79b3778f55345c1d150..65caa41cb5b13cbe21172c33bd18b2cdbe995bb8 100644 (file)
@@ -193,7 +193,7 @@ attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int
 }
 
 CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc)
-    : CanvasGrid(nv, in_repr, in_doc, GRID_AXONOMETRIC), table(1, 1)
+    : CanvasGrid(nv, in_repr, in_doc, GRID_AXONOMETRIC)
 {
     gridunit = sp_unit_get_by_abbreviation( prefs_get_string_attribute("options.grids.axonom", "units") );
     if (!gridunit)
@@ -214,62 +214,6 @@ CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_r
     tan_angle[Z] = tan(angle_rad[Z]);
 
     snapper = new CanvasAxonomGridSnapper(this, namedview, 0);
-
-    // initialize widgets:
-    vbox.set_border_width(2);
-    table.set_spacings(2);
-    vbox.pack_start(table, false, false, 0);
-
-_wr.setUpdating (true);
-    Inkscape::UI::Widget::ScalarUnit * sutemp;
-    _rumg.init (_("Grid _units:"), "units", _wr, repr, doc);
-    _rsu_ox.init (_("_Origin X:"), _("X coordinate of grid origin"),
-                  "originx", _rumg, _wr, repr, doc);
-        sutemp = _rsu_ox.getSU();
-        sutemp->setDigits(4);
-        sutemp->setIncrements(0.1, 1.0);
-    _rsu_oy.init (_("O_rigin Y:"), _("Y coordinate of grid origin"),
-                  "originy", _rumg, _wr, repr, doc);
-        sutemp = _rsu_oy.getSU();
-        sutemp->setDigits(4);
-        sutemp->setIncrements(0.1, 1.0);
-    _rsu_sy.init (_("Spacing _Y:"), _("Base length of z-axis"),
-                  "spacingy", _rumg, _wr, repr, doc);
-        sutemp = _rsu_sy.getSU();
-        sutemp->setDigits(4);
-        sutemp->setIncrements(0.1, 1.0);
-    _rsu_ax.init (_("Angle X:"), _("Angle of x-axis"),
-                  "gridanglex", _wr, repr, doc);
-    _rsu_az.init (_("Angle Z:"), _("Angle of z-axis"),
-                  "gridanglez", _wr, repr, doc);
-    _rcp_gcol.init (_("Grid line _color:"), _("Grid line color"),
-                    _("Color of grid lines"), "color", "opacity", _wr, repr, doc);
-    _rcp_gmcol.init (_("Ma_jor grid line color:"), _("Major grid line color"),
-                     _("Color of the major (highlighted) grid lines"),
-                     "empcolor", "empopacity", _wr, repr, doc);
-    _rsi.init (_("_Major grid line every:"), _("lines"), "empspacing", _wr, repr, doc);
-_wr.setUpdating (false);
-
-    Gtk::Widget const *const widget_array[] = {
-        0,                  _rcbgrid._button,
-        _rumg._label,       _rumg._sel,
-        0,                  _rsu_ox.getSU(),
-        0,                  _rsu_oy.getSU(),
-        0,                  _rsu_sy.getSU(),
-        0,                  _rsu_ax.getS(),
-        0,                  _rsu_az.getS(),
-        _rcp_gcol._label,   _rcp_gcol._cp,
-        0,                  0,
-        _rcp_gmcol._label,  _rcp_gmcol._cp,
-        _rsi._label,        &_rsi._hbox,
-    };
-
-    attach_all (table, widget_array, sizeof(widget_array));
-
-    vbox.show();
-
-    if (repr) readRepr();
-    updateWidgets();
 }
 
 CanvasAxonomGrid::~CanvasAxonomGrid ()
@@ -434,10 +378,72 @@ CanvasAxonomGrid::onReprAttrChanged(Inkscape::XML::Node */*repr*/, gchar const *
 
 
 
-Gtk::Widget &
-CanvasAxonomGrid::getWidget()
+Gtk::Widget *
+CanvasAxonomGrid::newSpecificWidget()
 {
-    return vbox;
+    Gtk::Table * table = Gtk::manage( new Gtk::Table(1,1) );
+
+    Inkscape::UI::Widget::RegisteredUnitMenu *_rumg = new Inkscape::UI::Widget::RegisteredUnitMenu();
+    Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_ox = new Inkscape::UI::Widget::RegisteredScalarUnit();
+    Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_oy = new Inkscape::UI::Widget::RegisteredScalarUnit();
+    Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_sy = new Inkscape::UI::Widget::RegisteredScalarUnit();
+    Inkscape::UI::Widget::RegisteredScalar *_rsu_ax = new Inkscape::UI::Widget::RegisteredScalar();
+    Inkscape::UI::Widget::RegisteredScalar *_rsu_az = new Inkscape::UI::Widget::RegisteredScalar();
+    Inkscape::UI::Widget::RegisteredColorPicker *_rcp_gcol = new Inkscape::UI::Widget::RegisteredColorPicker();
+    Inkscape::UI::Widget::RegisteredColorPicker *_rcp_gmcol = new Inkscape::UI::Widget::RegisteredColorPicker();
+    Inkscape::UI::Widget::RegisteredSuffixedInteger *_rsi = new Inkscape::UI::Widget::RegisteredSuffixedInteger();
+
+    // initialize widgets:
+    table->set_spacings(2);
+
+_wr.setUpdating (true);
+    Inkscape::UI::Widget::ScalarUnit * sutemp = NULL;
+    _rumg->init (_("Grid _units:"), "units", _wr, repr, doc);
+    _rsu_ox->init (_("_Origin X:"), _("X coordinate of grid origin"),
+                  "originx", *_rumg, _wr, repr, doc);
+        sutemp = _rsu_ox->getSU();
+        sutemp->setDigits(4);
+        sutemp->setIncrements(0.1, 1.0);
+    _rsu_oy->init (_("O_rigin Y:"), _("Y coordinate of grid origin"),
+                  "originy", *_rumg, _wr, repr, doc);
+        sutemp = _rsu_oy->getSU();
+        sutemp->setDigits(4);
+        sutemp->setIncrements(0.1, 1.0);
+    _rsu_sy->init (_("Spacing _Y:"), _("Base length of z-axis"),
+                  "spacingy", *_rumg, _wr, repr, doc);
+        sutemp = _rsu_sy->getSU();
+        sutemp->setDigits(4);
+        sutemp->setIncrements(0.1, 1.0);
+    _rsu_ax->init (_("Angle X:"), _("Angle of x-axis"),
+                  "gridanglex", _wr, repr, doc);
+    _rsu_az->init (_("Angle Z:"), _("Angle of z-axis"),
+                  "gridanglez", _wr, repr, doc);
+    _rcp_gcol->init (_("Grid line _color:"), _("Grid line color"),
+                    _("Color of grid lines"), "color", "opacity", _wr, repr, doc);
+    _rcp_gmcol->init (_("Ma_jor grid line color:"), _("Major grid line color"),
+                     _("Color of the major (highlighted) grid lines"),
+                     "empcolor", "empopacity", _wr, repr, doc);
+    _rsi->init (_("_Major grid line every:"), _("lines"), "empspacing", _wr, repr, doc);
+_wr.setUpdating (false);
+
+    Gtk::Widget const *const widget_array[] = {
+        _rumg->_label,       _rumg->_sel,
+        0,                  _rsu_ox->getSU(),
+        0,                  _rsu_oy->getSU(),
+        0,                  _rsu_sy->getSU(),
+        0,                  _rsu_ax->getS(),
+        0,                  _rsu_az->getS(),
+        _rcp_gcol->_label,   _rcp_gcol->_cp,
+        0,                  0,
+        _rcp_gmcol->_label,  _rcp_gmcol->_cp,
+        _rsi->_label,        &_rsi->_hbox,
+    };
+
+    attach_all (*table, widget_array, sizeof(widget_array));
+
+    if (repr) readRepr();
+    updateWidgets();
+    return table;
 }
 
 
@@ -447,7 +453,7 @@ CanvasAxonomGrid::getWidget()
 void
 CanvasAxonomGrid::updateWidgets()
 {
-    if (_wr.isUpdating()) return;
+/*    if (_wr.isUpdating()) return;
 
     _wr.setUpdating (true);
 
@@ -479,6 +485,7 @@ CanvasAxonomGrid::updateWidgets()
     _wr.setUpdating (false);
 
     return;
+    */
 }
 
 
index a5bc33fa933bf9b423cd41b738ac3ad4499ac501..ad9466eb86d7a079ce8945834d5c1813922dd540 100644 (file)
@@ -41,8 +41,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();
 
     SPUnit const* gridunit;
 
@@ -63,22 +61,15 @@ public:
     double spacing_ylines;
                           
     NR::Point sw;          /**< the scaling factors of the affine transform */
-    
-    
+
+protected:
+    virtual Gtk::Widget * newSpecificWidget();
+
 private:
     CanvasAxonomGrid(const CanvasAxonomGrid&);
     CanvasAxonomGrid& operator=(const CanvasAxonomGrid&);
     
     void updateWidgets();
-
-    Gtk::Table table;
-    
-    Inkscape::UI::Widget::RegisteredCheckButton _rcbgrid, _rcbsnbb, _rcbsnnod;
-    Inkscape::UI::Widget::RegisteredUnitMenu    _rumg, _rums;
-    Inkscape::UI::Widget::RegisteredScalarUnit  _rsu_ox, _rsu_oy, _rsu_sy;
-    Inkscape::UI::Widget::RegisteredScalar      _rsu_ax, _rsu_az;
-    Inkscape::UI::Widget::RegisteredColorPicker _rcp_gcol, _rcp_gmcol;
-    Inkscape::UI::Widget::RegisteredSuffixedInteger _rsi;
 };
 
 
index b6897ae4821b412311e6a9c5b25dfa06a407c46c..a15fdf2434921098505af9052691cf298d60fecd 100644 (file)
@@ -157,7 +157,7 @@ grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i
     };
 
 CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc, GridType type)
-    : namelabel("", Gtk::ALIGN_CENTER), visible(true), gridtype(type)
+    : visible(true), gridtype(type)
 {
     repr = in_repr;
     doc = in_doc;
@@ -167,22 +167,6 @@ CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocume
 
     namedview = nv;
     canvasitems = NULL;
-
-    Glib::ustring str("<b>");
-    str += getName();
-    str += "</b>";
-    namelabel.set_markup(str);
-    vbox.pack_start(namelabel, true, true);
-
-    _rcb_enabled.init ( _("_Enabled"),
-                        _("Determines whether to snap to this grid or not. Can be 'on' for invisible grids."),
-                         "enabled", _wr, false, repr, doc);
-    vbox.pack_start(*dynamic_cast<Gtk::Widget*>(_rcb_enabled._button), true, true);
-
-    _rcb_visible.init ( _("_Visible"),
-                        _("Determines whether the grid is displayed or not. Objects are still snapped to invisible grids."),
-                         "visible", _wr, true, repr, doc);
-    vbox.pack_start(*dynamic_cast<Gtk::Widget*>(_rcb_visible._button), true, true);
 }
 
 CanvasGrid::~CanvasGrid()
@@ -325,6 +309,34 @@ CanvasGrid::createCanvasItem(SPDesktop * desktop)
     return item;
 }
 
+Gtk::Widget *
+CanvasGrid::newWidget()
+{
+    Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox() );
+    Gtk::Label * namelabel = Gtk::manage(new Gtk::Label("", Gtk::ALIGN_CENTER) );
+
+    Glib::ustring str("<b>");
+    str += getName();
+    str += "</b>";
+    namelabel->set_markup(str);
+    vbox->pack_start(*namelabel, true, true);
+
+    Inkscape::UI::Widget::RegisteredCheckButton * _rcb_visible = Gtk::manage(
+        new Inkscape::UI::Widget::RegisteredCheckButton( _("_Enabled"),
+                        _("Determines whether to snap to this grid or not. Can be 'on' for invisible grids."),
+                         "enabled", _wr, false, repr, doc) );
+    Inkscape::UI::Widget::RegisteredCheckButton * _rcb_enabled = Gtk::manage(
+        new Inkscape::UI::Widget::RegisteredCheckButton( _("_Visible"),
+                        _("Determines whether the grid is displayed or not. Objects are still snapped to invisible grids."),
+                         "visible", _wr, true, repr, doc) );
+
+    vbox->pack_start(*_rcb_enabled, true, true);
+    vbox->pack_start(*_rcb_visible, true, true);
+    vbox->pack_start(*newSpecificWidget(), true, true);
+
+    return dynamic_cast<Gtk::Widget *> (vbox);
+}
+
 void
 CanvasGrid::on_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, void *data)
 {
@@ -389,7 +401,7 @@ attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int
 }
 
 CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc)
-    : CanvasGrid(nv, in_repr, in_doc, GRID_RECTANGULAR), table(1, 1)
+    : CanvasGrid(nv, in_repr, in_doc, GRID_RECTANGULAR)
 {
     gridunit = sp_unit_get_by_abbreviation( prefs_get_string_attribute("options.grids.xy", "units") );
     if (!gridunit)
@@ -404,65 +416,6 @@ CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPD
     render_dotted = prefs_get_int_attribute ("options.grids.xy", "dotted", 0) == 1;
 
     snapper = new CanvasXYGridSnapper(this, namedview, 0);
-
-    // initialize widgets:
-    vbox.set_border_width(2);
-    table.set_spacings(2);
-    vbox.pack_start(table, false, false, 0);
-
-_wr.setUpdating (true);
-    Inkscape::UI::Widget::ScalarUnit * sutemp;
-    _rumg.init (_("Grid _units:"), "units", _wr, repr, doc);
-    _rsu_ox.init (_("_Origin X:"), _("X coordinate of grid origin"),
-                  "originx", _rumg, _wr, repr, doc);
-        sutemp = _rsu_ox.getSU();
-        sutemp->setDigits(4);
-        sutemp->setIncrements(0.1, 1.0);
-    _rsu_oy.init (_("O_rigin Y:"), _("Y coordinate of grid origin"),
-                  "originy", _rumg, _wr, repr, doc);
-        sutemp = _rsu_oy.getSU();
-        sutemp->setDigits(4);
-        sutemp->setIncrements(0.1, 1.0);
-    _rsu_sx.init (_("Spacing _X:"), _("Distance between vertical grid lines"),
-                  "spacingx", _rumg, _wr, repr, doc);
-        sutemp = _rsu_sx.getSU();
-        sutemp->setDigits(4);
-        sutemp->setIncrements(0.1, 1.0);
-    _rsu_sy.init (_("Spacing _Y:"), _("Distance between horizontal grid lines"),
-                  "spacingy", _rumg, _wr, repr, doc);
-        sutemp = _rsu_sy.getSU();
-        sutemp->setDigits(4);
-        sutemp->setIncrements(0.1, 1.0);
-    _rcp_gcol.init (_("Grid line _color:"), _("Grid line color"),
-                    _("Color of grid lines"), "color", "opacity", _wr, repr, doc);
-    _rcp_gmcol.init (_("Ma_jor grid line color:"), _("Major grid line color"),
-                     _("Color of the major (highlighted) grid lines"),
-                     "empcolor", "empopacity", _wr, repr, doc);
-    _rsi.init (_("_Major grid line every:"), _("lines"), "empspacing", _wr, repr, doc);
-    _rcb_dotted.init ( _("_Show dots instead of lines"),
-                       _("If set, displays dots at gridpoints instead of gridlines"),
-                        "dotted", _wr, false, repr, doc);
-_wr.setUpdating (false);
-
-    Gtk::Widget const *const widget_array[] = {
-        _rumg._label,       _rumg._sel,
-        0,                  _rsu_ox.getSU(),
-        0,                  _rsu_oy.getSU(),
-        0,                  _rsu_sx.getSU(),
-        0,                  _rsu_sy.getSU(),
-        _rcp_gcol._label,   _rcp_gcol._cp,
-        0,                  0,
-        _rcp_gmcol._label,  _rcp_gmcol._cp,
-        _rsi._label,        &_rsi._hbox,
-        0,                  _rcb_dotted._button,
-    };
-
-    attach_all (table, widget_array, sizeof(widget_array));
-
-    vbox.show();
-
-    if (repr) readRepr();
-    updateWidgets();
 }
 
 CanvasXYGrid::~CanvasXYGrid ()
@@ -550,8 +503,7 @@ static gboolean sp_nv_read_opacity(gchar const *str, guint32 *color)
     @param widget Widget associated with the scalar.
 */
 static void validateScalar(double oldVal,
-                           double* pTarget,
-                           Inkscape::UI::Widget::RegisteredScalarUnit& widget)
+                           double* pTarget)
 {
     // Avoid nullness.
     if ( pTarget == NULL )
@@ -565,7 +517,6 @@ static void validateScalar(double oldVal,
 
         // Reset the scalar and associated widget to the old value.
         *pTarget = oldVal;
-        widget.setValue( *pTarget);
     } //if
 
 } //validateScalar
@@ -579,8 +530,7 @@ static void validateScalar(double oldVal,
     @param widget Widget associated with the int.
 */
 static void validateInt(gint oldVal,
-                        gint* pTarget,
-                        Inkscape::UI::Widget::RegisteredSuffixedInteger& widget)
+                        gint* pTarget)
 {
     // Avoid nullness.
     if ( pTarget == NULL )
@@ -594,7 +544,6 @@ static void validateInt(gint oldVal,
 
         // Reset the int and associated widget to the old value.
         *pTarget = oldVal;
-        widget.setValue( *pTarget);
     } //if
 
 } //validateInt
@@ -616,14 +565,14 @@ CanvasXYGrid::readRepr()
     if ( (value = repr->attribute("spacingx")) ) {
         double oldVal = spacing[NR::X];
         sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[NR::X], &gridunit);
-        validateScalar( oldVal, &spacing[NR::X], _rsu_sx );
+        validateScalar( oldVal, &spacing[NR::X]);
         spacing[NR::X] = sp_units_get_pixels(spacing[NR::X], *(gridunit));
 
     }
     if ( (value = repr->attribute("spacingy")) ) {
         double oldVal = spacing[NR::Y];
         sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[NR::Y], &gridunit);
-        validateScalar( oldVal, &spacing[NR::Y], _rsu_sy );
+        validateScalar( oldVal, &spacing[NR::Y]);
         spacing[NR::Y] = sp_units_get_pixels(spacing[NR::Y], *(gridunit));
 
     }
@@ -646,7 +595,7 @@ CanvasXYGrid::readRepr()
     if ( (value = repr->attribute("empspacing")) ) {
         gint oldVal = empspacing;
         empspacing = atoi(value);
-        validateInt( oldVal, &empspacing, _rsi );
+        validateInt( oldVal, &empspacing);
     }
 
     if ( (value = repr->attribute("dotted")) ) {
@@ -684,10 +633,79 @@ CanvasXYGrid::onReprAttrChanged(Inkscape::XML::Node */*repr*/, gchar const */*ke
 
 
 
-Gtk::Widget &
-CanvasXYGrid::getWidget()
+Gtk::Widget *
+CanvasXYGrid::newSpecificWidget()
 {
-    return vbox;
+    Gtk::Table * table = Gtk::manage( new Gtk::Table(1,1) );
+
+    Inkscape::UI::Widget::RegisteredUnitMenu *_rumg = new Inkscape::UI::Widget::RegisteredUnitMenu();
+    Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_ox = new Inkscape::UI::Widget::RegisteredScalarUnit();
+    Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_oy = new Inkscape::UI::Widget::RegisteredScalarUnit();
+    Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_sx = new Inkscape::UI::Widget::RegisteredScalarUnit();
+    Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_sy = new Inkscape::UI::Widget::RegisteredScalarUnit();
+    Inkscape::UI::Widget::RegisteredColorPicker *_rcp_gcol = new Inkscape::UI::Widget::RegisteredColorPicker();
+    Inkscape::UI::Widget::RegisteredColorPicker *_rcp_gmcol = new Inkscape::UI::Widget::RegisteredColorPicker();
+    Inkscape::UI::Widget::RegisteredSuffixedInteger *_rsi = new Inkscape::UI::Widget::RegisteredSuffixedInteger();
+
+    // initialize widgets:
+    table->set_spacings(2);
+
+_wr.setUpdating (true);
+    Inkscape::UI::Widget::ScalarUnit * sutemp;
+    _rumg->init (_("Grid _units:"), "units", _wr, repr, doc);
+    _rsu_ox->init (_("_Origin X:"), _("X coordinate of grid origin"),
+                  "originx", *_rumg, _wr, repr, doc);
+        sutemp = _rsu_ox->getSU();
+        sutemp->setDigits(4);
+        sutemp->setIncrements(0.1, 1.0);
+    _rsu_oy->init (_("O_rigin Y:"), _("Y coordinate of grid origin"),
+                  "originy", *_rumg, _wr, repr, doc);
+        sutemp = _rsu_oy->getSU();
+        sutemp->setDigits(4);
+        sutemp->setIncrements(0.1, 1.0);
+    _rsu_sx->init (_("Spacing _X:"), _("Distance between vertical grid lines"),
+                  "spacingx", *_rumg, _wr, repr, doc);
+        sutemp = _rsu_sx->getSU();
+        sutemp->setDigits(4);
+        sutemp->setIncrements(0.1, 1.0);
+    _rsu_sy->init (_("Spacing _Y:"), _("Distance between horizontal grid lines"),
+                  "spacingy", *_rumg, _wr, repr, doc);
+        sutemp = _rsu_sy->getSU();
+        sutemp->setDigits(4);
+        sutemp->setIncrements(0.1, 1.0);
+    _rcp_gcol->init (_("Grid line _color:"), _("Grid line color"),
+                    _("Color of grid lines"), "color", "opacity", _wr, repr, doc);
+    _rcp_gmcol->init (_("Ma_jor grid line color:"), _("Major grid line color"),
+                     _("Color of the major (highlighted) grid lines"),
+                     "empcolor", "empopacity", _wr, repr, doc);
+    _rsi->init (_("_Major grid line every:"), _("lines"), "empspacing", _wr, repr, doc);
+
+    Inkscape::UI::Widget::RegisteredCheckButton * _rcb_dotted = Gtk::manage(
+                new Inkscape::UI::Widget::RegisteredCheckButton( _("_Show dots instead of lines"),
+                       _("If set, displays dots at gridpoints instead of gridlines"),
+                        "dotted", _wr, false, repr, doc) 
+                );
+_wr.setUpdating (false);
+
+    Gtk::Widget const *const widget_array[] = {
+        _rumg->_label,       _rumg->_sel,
+        0,                  _rsu_ox->getSU(),
+        0,                  _rsu_oy->getSU(),
+        0,                  _rsu_sx->getSU(),
+        0,                  _rsu_sy->getSU(),
+        _rcp_gcol->_label,   _rcp_gcol->_cp,
+        0,                  0,
+        _rcp_gmcol->_label,  _rcp_gmcol->_cp,
+        _rsi->_label,        &_rsi->_hbox,
+        0,                  _rcb_dotted,
+    };
+
+    attach_all (*table, widget_array, sizeof(widget_array));
+
+    if (repr) readRepr();
+    updateWidgets();
+
+    return table;
 }
 
 
@@ -697,6 +715,7 @@ CanvasXYGrid::getWidget()
 void
 CanvasXYGrid::updateWidgets()
 {
+/*
     if (_wr.isUpdating()) return;
 
     _wr.setUpdating (true);
@@ -731,6 +750,7 @@ CanvasXYGrid::updateWidgets()
     _wr.setUpdating (false);
 
     return;
+*/
 }
 
 
index b8ed8174c617d22200b416c6e563f36353a7609a..c201fa7df8e794f91a59f14c16efbbe579dae654 100644 (file)
@@ -89,7 +89,7 @@ public:
     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;
@@ -104,18 +104,15 @@ public:
 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;
-    Gtk::Label namelabel;
-
     Inkscape::UI::Widget::Registry _wr;
-    Inkscape::UI::Widget::RegisteredCheckButton _rcb_visible;
     bool visible;
-    Inkscape::UI::Widget::RegisteredCheckButton _rcb_enabled;
-    
+
     GridType gridtype;
 
 private:
@@ -135,8 +132,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;
@@ -149,20 +144,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;
-
     bool render_dotted;
 };
 
index 14fd88423821c7aa406e33190b48efdd3a7ece72..383dc8186a2c6af01b0080d76c40f6cb80749362 100644 (file)
@@ -28,13 +28,10 @@ BoolParam::BoolParam( const Glib::ustring& label, const Glib::ustring& tip,
                       Effect* effect, bool default_value )
     : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value)
 {
-    checkwdg = NULL;
 }
 
 BoolParam::~BoolParam()
 {
-    if (checkwdg)
-        delete checkwdg;
 }
 
 void
@@ -60,23 +57,25 @@ BoolParam::param_writeSVGValue() const
 Gtk::Widget *
 BoolParam::param_newWidget(Gtk::Tooltips * tooltips)
 {
-    // WIDGET TODO: This implementation is incorrect, it should create a *new* widget for the caller, not just return an already created widget
-    g_warning("BoolParam::param_newWidget still needs recoding to work with multiple document views");
-    if (!checkwdg) {
-        checkwdg = new Inkscape::UI::Widget::RegisteredCheckButton();
-        checkwdg->init(param_label, param_tooltip, param_key, *param_wr, false, param_effect->getRepr(), param_effect->getSPDoc());
-        checkwdg->setActive(value);
-        checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter"));
-    }
-    return dynamic_cast<Gtk::Widget *> (checkwdg->_button);
+    Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage( 
+        new Inkscape::UI::Widget::RegisteredCheckButton( param_label,
+                                                         param_tooltip,
+                                                         param_key,
+                                                         *param_wr,
+                                                         false,
+                                                         param_effect->getRepr(),
+                                                         param_effect->getSPDoc()) );
+
+    checkwdg->setActive(value);
+    checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter"));
+
+    return dynamic_cast<Gtk::Widget *> (checkwdg);
 }
 
 void
 BoolParam::param_setValue(bool newvalue)
 {
     value = newvalue;
-    if (checkwdg)
-        checkwdg->setActive(newvalue);
 }
 
 } /* namespace LivePathEffect */
index 38811812d6ebe48c382a319d49603a4baa8a9073..55197721dd299468cd080b94eb80fe450963c89e 100644 (file)
@@ -45,8 +45,6 @@ private:
     BoolParam(const BoolParam&);
     BoolParam& operator=(const BoolParam&);
 
-    Inkscape::UI::Widget::RegisteredCheckButton * checkwdg;
-
     bool value;
     bool defvalue;
 };
index 5284bc7975ea9244257de670ae2e1c2989456357..31c4ae55bdd04574e46c9eb77da8cd5d35502da5 100644 (file)
@@ -32,19 +32,11 @@ PointParam::PointParam( const Glib::ustring& label, const Glib::ustring& tip,
                         Effect* effect, Geom::Point default_value )
     : Geom::Point(default_value), Parameter(label, tip, key, wr, effect), defvalue(default_value)
 {
-    _widget = NULL;
-    pointwdg = NULL;
     knot = NULL;
-    _tooltips = NULL;
 }
 
 PointParam::~PointParam()
 {
-    if (pointwdg)
-        delete pointwdg;
-    if (_tooltips)
-        delete _tooltips;
-
     if (knot)
         g_object_unref (G_OBJECT (knot));
 }
@@ -84,39 +76,41 @@ PointParam::param_newWidget(Gtk::Tooltips * tooltips)
 {
     // WIDGET TODO: This implementation is incorrect, it should create a *new* widget for the caller, not just return an already created widget
     g_warning("PointParam::param_newWidget still needs recoding to work with multiple document views");
-    if (!_widget) {
-        pointwdg = new Inkscape::UI::Widget::RegisteredPoint();
-        pointwdg->init(param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
-        pointwdg->setValue( (*this)[0], (*this)[1] );
-        pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
-
-        Gtk::Widget*  pIcon = Gtk::manage( sp_icon_get_icon( "draw_node", Inkscape::ICON_SIZE_BUTTON) );
-        Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
-        pButton->set_relief(Gtk::RELIEF_NONE);
-        pIcon->show();
-        pButton->add(*pIcon);
-        pButton->show();
-        pButton->signal_clicked().connect(sigc::mem_fun(*this, &PointParam::on_button_click));
+    Inkscape::UI::Widget::RegisteredPoint * pointwdg = Gtk::manage(
+        new Inkscape::UI::Widget::RegisteredPoint( param_label,
+                                                   param_tooltip,
+                                                   param_key,
+                                                   *param_wr,
+                                                   param_effect->getRepr(),
+                                                   param_effect->getSPDoc() ) );
+    pointwdg->setValue( (*this)[0], (*this)[1] );
+    pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
+
+    Gtk::Widget*  pIcon = Gtk::manage( sp_icon_get_icon( "draw_node", Inkscape::ICON_SIZE_BUTTON) );
+    Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
+    pButton->set_relief(Gtk::RELIEF_NONE);
+    pIcon->show();
+    pButton->add(*pIcon);
+    pButton->show();
+    pButton->signal_clicked().connect(sigc::mem_fun(*this, &PointParam::on_button_click));
 #ifndef LPEPOINTPARAM_DEBUG
-        pButton->set_sensitive(false);
+    pButton->set_sensitive(false);
 #endif
 
-        _widget = Gtk::manage( new Gtk::HBox() );
-        static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
-        static_cast<Gtk::HBox*>(_widget)->pack_start(*(pointwdg->getPoint()), true, true);
-        static_cast<Gtk::HBox*>(_widget)->show_all_children();
+    Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() );
+    static_cast<Gtk::HBox*>(hbox)->pack_start(*pButton, true, true);
+    static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true);
+    static_cast<Gtk::HBox*>(hbox)->show_all_children();
 
-        tooltips->set_tip(*pButton, _("Edit on-canvas"));
-    }
-    return dynamic_cast<Gtk::Widget *> (_widget);
+    tooltips->set_tip(*pButton, _("Edit on-canvas"));
+
+    return dynamic_cast<Gtk::Widget *> (hbox);
 }
 
 void
 PointParam::param_setValue(Geom::Point newpoint)
 {
     *dynamic_cast<Geom::Point *>( this ) = newpoint;
-    if (pointwdg)
-        pointwdg->setValue(newpoint[0], newpoint[1]);
 }
 
 void
index 7eb1a70c1e0f91953c8984fd12939fd530939c9a..a47fa77f53391e894fa73288113ea04f97bae53e 100644 (file)
@@ -51,9 +51,6 @@ private:
     PointParam(const PointParam&);
     PointParam& operator=(const PointParam&);
 
-    Gtk::Widget * _widget;
-    Gtk::Tooltips * _tooltips;
-    Inkscape::UI::Widget::RegisteredPoint * pointwdg;
     void on_button_click();
 
     SPKnot *knot;
index c8f9bde7c6efd1dad1166a3bb7e67508e1920662..1a1ba3689a21848f1fe61f270b07faee01e42d53 100644 (file)
@@ -9,7 +9,7 @@
  *   Jon Phillips <jon@rejon.org>
  *   Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
  *
- * Copyright (C) 2006-2007 Johan Engelen  <johan@shouraizou.nl>
+ * Copyright (C) 2006-2008 Johan Engelen  <johan@shouraizou.nl>
  * Copyright (C) 2000 - 2005 Authors
  *
  * Released under GNU GPL.  Read the file 'COPYING' for more information
@@ -185,14 +185,24 @@ DocumentProperties::build_page()
 {
     _page_page.show();
 
-    _rcp_bg.init (_("Back_ground:"), _("Background color"), _("Color and transparency of the page background (also used for bitmap export)"),
+    _rcp_bg.init(
+                   _("Back_ground:"),
+                   _("Background color"), 
+                   _("Color and transparency of the page background (also used for bitmap export)"),
                    "pagecolor", "inkscape:pageopacity", _wr);
-    _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);
+    _rcb_canb = Gtk::manage( new RegisteredCheckButton(
+                   _("Show page _border"), 
+                   _("If set, rectangular page border is shown"), "showborder", _wr, false) );
+    _rcb_bord = Gtk::manage( new RegisteredCheckButton(
+                   _("Border on _top of drawing"),
+                   _("If set, border is always on top of the drawing"), "borderlayer", _wr, false) );
     _rcp_bord.init (_("Border _color:"), _("Page border color"),
                     _("Color of the page border"),
                     "bordercolor", "borderopacity", _wr);
-    _rcb_shad.init (_("_Show border shadow"), _("If set, page border shows a shadow on its right and lower side"), "inkscape:showpageshadow", _wr, false);
+    _rcb_shad = Gtk::manage( new RegisteredCheckButton(
+                    _("_Show border shadow"),
+                    _("If set, page border shows a shadow on its right and lower side"),
+                    "inkscape:showpageshadow", _wr, false) );
     _rum_deflt.init (_("Default _units:"), "inkscape:document-units", _wr);
 
     Gtk::Label* label_gen = manage (new Gtk::Label);
@@ -213,9 +223,9 @@ DocumentProperties::build_page()
         0,                 &_page_sizer,
         0,                 0,
         label_bor,         0,
-        0,                 _rcb_canb._button,
-        0,                 _rcb_bord._button,
-        0,                 _rcb_shad._button,
+        0,                 _rcb_canb,
+        0,                 _rcb_bord,
+        0,                 _rcb_shad,
         _rcp_bord._label,  _rcp_bord._cp,
     };
 
@@ -227,27 +237,29 @@ DocumentProperties::build_guides()
 {
     _page_guides.show();
 
-    _rcb_sgui.init (_("Show _guides"), _("Show or hide guides"), "showguides", _wr);
+    _rcb_sgui = Gtk::manage( new RegisteredCheckButton(
+                _("Show _guides"), _("Show or hide guides"), "showguides", _wr) );
     _rcp_gui.init (_("Guide co_lor:"), _("Guideline color"),
                    _("Color of guidelines"), "guidecolor", "guideopacity", _wr);
     _rcp_hgui.init (_("_Highlight color:"), _("Highlighted guideline color"),
                     _("Color of a guideline when it is under mouse"),
                     "guidehicolor", "guidehiopacity", _wr);
-                    
-    _rcbsng.init (_("_Snap guides while dragging"),
+
+    _rcbsng = Gtk::manage( new RegisteredCheckButton(
+                  _("_Snap guides while dragging"),
                   _("While dragging a guide, snap to object nodes or bounding box corners ('Snap to nodes' or 'snap to bounding box corners' must be enabled in the 'Snap' tab; only a small part of the guide near the cursor will snap)"),
-                  "inkscape:snap-guide", _wr);
-                    
+                  "inkscape:snap-guide", _wr) );
+
     Gtk::Label *label_gui = manage (new Gtk::Label);
     label_gui->set_markup (_("<b>Guides</b>"));
 
     Gtk::Widget *const widget_array[] =
     {
         label_gui,       0,
-        0,               _rcb_sgui._button,
+        0,               _rcb_sgui,
         _rcp_gui._label, _rcp_gui._cp,
         _rcp_hgui._label, _rcp_hgui._cp,
-        0,                  _rcbsng._button,        
+        0,                  _rcbsng,
     };
 
     attach_all(_page_guides.table(), widget_array, G_N_ELEMENTS(widget_array));
@@ -257,30 +269,30 @@ void
 DocumentProperties::build_snap()
 {
     _page_snap.show();
-       //General options
-    _rcbsg.init (_("_Enable snapping"),
+    //General options
+    _rcbsg = Gtk::manage( new RegisteredCheckButton( _("_Enable snapping"),
                 _("Toggle snapping on or off"),
-                "inkscape:snap-global", _wr);    
-       _rcbsnbb.init (_("_Bounding box corners"),
+                "inkscape:snap-global", _wr) );
+    _rcbsnbb = Gtk::manage( new RegisteredCheckButton( _("_Bounding box corners"),
                 _("Only available in the selector tool: snap bounding box corners to guides, to grids, and to other bounding boxes (but not to nodes or paths)"),
-                "inkscape:snap-bbox", _wr);
-    _rcbsnn.init (_("_Nodes"),
+                "inkscape:snap-bbox", _wr) );
+    _rcbsnn = Gtk::manage( new RegisteredCheckButton( _("_Nodes"),
                 _("Snap nodes (e.g. path nodes, special points in shapes, gradient handles, text base points, transformation origins, etc.) to guides, to grids, to paths and to other nodes"),
-                "inkscape:snap-nodes", _wr);
+                "inkscape:snap-nodes", _wr) );
 
     //Options for snapping to objects
-    _rcbsnop.init (_("Snap to path_s"),
+    _rcbsnop = Gtk::manage( new RegisteredCheckButton( _("Snap to path_s"),
                 _("Snap nodes to object paths"),
-                "inkscape:object-paths", _wr);
-    _rcbsnon.init (_("Snap to n_odes"),
+                "inkscape:object-paths", _wr) );
+    _rcbsnon = Gtk::manage( new RegisteredCheckButton( _("Snap to n_odes"),
                 _("Snap nodes and guides to object nodes"),
-                "inkscape:object-nodes", _wr);
-    _rcbsnbbn.init (_("Snap to bounding box co_rners"),
+                "inkscape:object-nodes", _wr) );
+    _rcbsnbbn = Gtk::manage( new RegisteredCheckButton( _("Snap to bounding box co_rners"),
                 _("Snap bounding box corners to other bounding box corners"),
-                "inkscape:bbox-nodes", _wr);
-    _rcbsnbbp.init (_("Snap to bounding bo_x edges"),
+                "inkscape:bbox-nodes", _wr) );
+    _rcbsnbbp = Gtk::manage( new RegisteredCheckButton( _("Snap to bounding bo_x edges"),
                 _("Snap bounding box corners and guides to bounding box edges"),
-                "inkscape:bbox-paths", _wr);
+                "inkscape:bbox-paths", _wr) );
 
     _rsu_sno.init (_("Snap _distance"), _("Snap only when _closer than:"),
                   _("Snapping distance, in screen pixels, for snapping to objects"),
@@ -302,20 +314,20 @@ DocumentProperties::build_snap()
     //Other options to locate here: e.g. visual snapping indicators on/off
 
     std::list<Gtk::ToggleButton*> slaves;
-    slaves.push_back(_rcbsnop._button);
-    slaves.push_back(_rcbsnon._button);
-    _rcbsnn.setSlaveButton(slaves);
+    slaves.push_back(_rcbsnop);
+    slaves.push_back(_rcbsnon);
+    _rcbsnn->setSlaveButton(slaves);
 
     slaves.clear();
-    slaves.push_back(_rcbsnbbp._button);
-    slaves.push_back(_rcbsnbbn._button);
-    _rcbsnbb.setSlaveButton(slaves);
+    slaves.push_back(_rcbsnbbp);
+    slaves.push_back(_rcbsnbbn);
+    _rcbsnbb->setSlaveButton(slaves);
     
     slaves.clear();
-    slaves.push_back(_rcbsnn._button);
-    slaves.push_back(_rcbsnbb._button);
+    slaves.push_back(_rcbsnn);
+    slaves.push_back(_rcbsnbb);
     
-    _rcbsg.setSlaveButton(slaves);
+    _rcbsg->setSlaveButton(slaves);
 
     Gtk::Label *label_g = manage (new Gtk::Label);
     label_g->set_markup (_("<b>Snapping</b>"));
@@ -331,17 +343,17 @@ DocumentProperties::build_snap()
     Gtk::Widget *const array[] =
     {
         label_g,            0,
-        0,                  _rcbsg._button,
+        0,                  _rcbsg,
         0,                  0,
         label_w,            0,
-        0,                  _rcbsnn._button,
-        0,                  _rcbsnbb._button,
+        0,                  _rcbsnn,
+        0,                  _rcbsnbb,
         0,                                     0,
         label_o,            0,
-        0,                                     _rcbsnop._button,
-        0,                                     _rcbsnon._button,
-        0,                  _rcbsnbbp._button,
-        0,                  _rcbsnbbn._button,
+        0,                                     _rcbsnop,
+        0,                                     _rcbsnon,
+        0,                  _rcbsnbbp,
+        0,                  _rcbsnbbn,
         0,                  _rsu_sno._vbox,
         0,                                     0,
         label_gr,           0,
@@ -358,19 +370,19 @@ void
 DocumentProperties::build_snap_dtls()
 {
     _page_snap_dtls.show();
-       
-       _rcbsigg.init (_("_Grid with guides"),
+
+    _rcbsigg = Gtk::manage( new RegisteredCheckButton( _("_Grid with guides"),
                 _("Snap to grid-guide intersections"),
-                "inkscape:snap-intersection-grid-guide", _wr);
-       
-       _rcbsils.init (_("_Line segments"),
+                "inkscape:snap-intersection-grid-guide", _wr) );
+
+    _rcbsils = Gtk::manage( new RegisteredCheckButton( _("_Line segments"),
                 _("Snap to intersections of line segments ('snap to paths' must be enabled, see the previous tab)"),
-                "inkscape:snap-intersection-line-segments", _wr);
+                "inkscape:snap-intersection-line-segments", _wr) );
     
     //Applies to both nodes and guides, but not to bboxes, that's why its located here
-    _rcbic.init (_("Rotation _center"),
+    _rcbic = Gtk::manage( new RegisteredCheckButton( _("Rotation _center"),
                 _("Consider the rotation center of an object when snapping"),
-                "inkscape:snap-center", _wr);
+                "inkscape:snap-center", _wr) );
     
     //Other options to locate here: e.g. visual snapping indicators on/off
 
@@ -382,11 +394,11 @@ DocumentProperties::build_snap_dtls()
     Gtk::Widget *const array[] =
     {
         label_i,            0,
-        0,                  _rcbsigg._button,
-        0,                  _rcbsils._button,
+        0,                  _rcbsigg,
+        0,                  _rcbsils,
         0,                  0,
         label_m,            0,
-        0,                  _rcbic._button,
+        0,                  _rcbic,
     };
 
     attach_all(_page_snap_dtls.table(), array, G_N_ELEMENTS(array));
@@ -402,8 +414,8 @@ DocumentProperties::update_gridspage()
     SPNamedView *nv = sp_desktop_namedview(dt);
 
     //remove all tabs
-    while (_grids_notebook.get_current_page() != -1) {
-        _grids_notebook.remove_page(-1);
+    while (_grids_notebook.get_n_pages() != 0) {
+        _grids_notebook.remove_page(-1); // this also deletes the page.
     }
 
     //add tabs
@@ -423,7 +435,7 @@ DocumentProperties::update_gridspage()
             default:
                 break;
         }
-        _grids_notebook.append_page(grid->getWidget(), _createPageTabLabel(name, icon));
+        _grids_notebook.append_page(*grid->newWidget(), _createPageTabLabel(name, icon));
         grids_present = true;
     }
     _grids_notebook.show_all();
@@ -488,10 +500,10 @@ DocumentProperties::update()
 
     //-----------------------------------------------------------page page
     _rcp_bg.setRgba32 (nv->pagecolor);
-    _rcb_canb.setActive (nv->showborder);
-    _rcb_bord.setActive (nv->borderlayer == SP_BORDER_LAYER_TOP);
+    _rcb_canb->setActive (nv->showborder);
+    _rcb_bord->setActive (nv->borderlayer == SP_BORDER_LAYER_TOP);
     _rcp_bord.setRgba32 (nv->bordercolor);
-    _rcb_shad.setActive (nv->showpageshadow);
+    _rcb_shad->setActive (nv->showpageshadow);
 
     if (nv->doc_units)
         _rum_deflt.setUnit (nv->doc_units);
@@ -501,29 +513,29 @@ DocumentProperties::update()
     _page_sizer.setDim (doc_w_px, doc_h_px);
 
     //-----------------------------------------------------------guide
-    _rcb_sgui.setActive (nv->showguides);
+    _rcb_sgui->setActive (nv->showguides);
     _rcp_gui.setRgba32 (nv->guidecolor);
     _rcp_hgui.setRgba32 (nv->guidehicolor);
 
     //-----------------------------------------------------------snap
 
-    _rcbsnbb.setActive (nv->snap_manager.getSnapModeBBox());
-    _rcbsnn.setActive (nv->snap_manager.getSnapModeNode());
-    _rcbsng.setActive (nv->snap_manager.getSnapModeGuide());
-    _rcbic.setActive (nv->snap_manager.getIncludeItemCenter());
-    _rcbsigg.setActive (nv->snap_manager.getSnapIntersectionGG());
-    _rcbsils.setActive (nv->snap_manager.getSnapIntersectionLS());    
-    _rcbsnop.setActive(nv->snap_manager.object.getSnapToItemPath());
-    _rcbsnon.setActive(nv->snap_manager.object.getSnapToItemNode());
-    _rcbsnbbp.setActive(nv->snap_manager.object.getSnapToBBoxPath());
-    _rcbsnbbn.setActive(nv->snap_manager.object.getSnapToBBoxNode());
+    _rcbsnbb->setActive (nv->snap_manager.getSnapModeBBox());
+    _rcbsnn->setActive (nv->snap_manager.getSnapModeNode());
+    _rcbsng->setActive (nv->snap_manager.getSnapModeGuide());
+    _rcbic->setActive (nv->snap_manager.getIncludeItemCenter());
+    _rcbsigg->setActive (nv->snap_manager.getSnapIntersectionGG());
+    _rcbsils->setActive (nv->snap_manager.getSnapIntersectionLS());    
+    _rcbsnop->setActive(nv->snap_manager.object.getSnapToItemPath());
+    _rcbsnon->setActive(nv->snap_manager.object.getSnapToItemNode());
+    _rcbsnbbp->setActive(nv->snap_manager.object.getSnapToBBoxPath());
+    _rcbsnbbn->setActive(nv->snap_manager.object.getSnapToBBoxNode());
     _rsu_sno.setValue (nv->objecttolerance);
 
     _rsu_sn.setValue (nv->gridtolerance);
 
     _rsu_gusn.setValue (nv->guidetolerance);
     
-    _rcbsg.setActive (nv->snap_manager.getSnapEnabledGlobally());    
+    _rcbsg->setActive (nv->snap_manager.getSnapEnabledGlobally());    
 
     //-----------------------------------------------------------grids page
 
index cee1533c521b492e4cb9f46c044aacd232df73a9..b23fbef9b68051796eeda6cc49ac68bda23412c9 100644 (file)
@@ -5,7 +5,7 @@
  *   Ralf Stephan <ralf@ark.in-berlin.de>
  *   Bryce W. Harrington <bryce@bryceharrington.org>
  *
- * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
+ * Copyright (C) 2006-2008 Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) 2004, 2005 Authors
  *
  * Released under GNU GPL.  Read the file 'COPYING' for more information.
@@ -65,26 +65,26 @@ protected:
     Gtk::VBox      _grids_vbox;
 
     //---------------------------------------------------------------
-    RegisteredCheckButton _rcb_canb, _rcb_bord, _rcb_shad;
+    RegisteredCheckButton *_rcb_canb, *_rcb_bord, *_rcb_shad;
     RegisteredColorPicker _rcp_bg, _rcp_bord;
     RegisteredUnitMenu    _rum_deflt;
     PageSizer             _page_sizer;
     //---------------------------------------------------------------
-    RegisteredCheckButton _rcbgrid;
+    RegisteredCheckButton *_rcbgrid;
     RegisteredUnitMenu    _rums;
     //---------------------------------------------------------------
-    RegisteredCheckButton _rcb_sgui, _rcbsng;
+    RegisteredCheckButton *_rcb_sgui, *_rcbsng;
     RegisteredUnitMenu    _rum_gusn;
     RegisteredColorPicker _rcp_gui, _rcp_hgui;
     //---------------------------------------------------------------
-    RegisteredCheckButton _rcbsg, _rcbsnbb, _rcbsnn, _rcbsnop;
-    RegisteredCheckButton _rcbsnon, _rcbsnbbp, _rcbsnbbn;
+    RegisteredCheckButton *_rcbsg, *_rcbsnbb, *_rcbsnn, *_rcbsnop;
+    RegisteredCheckButton *_rcbsnon, *_rcbsnbbp, *_rcbsnbbn;
     RegisteredUnitMenu    _rumso;
     ToleranceSlider       _rsu_sno, _rsu_sn, _rsu_gusn;
     RegisteredRadioButtonPair _rrb_pix;
     //---------------------------------------------------------------
-    RegisteredCheckButton _rcbic;
-    RegisteredCheckButton _rcbsigg, _rcbsils;
+    RegisteredCheckButton *_rcbic;
+    RegisteredCheckButton *_rcbsigg, *_rcbsils;
     //---------------------------------------------------------------
     Gtk::Notebook   _grids_notebook;
     Gtk::HBox       _grids_hbox_crea;
index a54c89292e17ead789cc6aedddf67e282ce8094b..e582a117f2b37bf949fdcf1e363ff558ef9f133c 100644 (file)
@@ -107,37 +107,31 @@ RegisteredWdg::write_to_xml(const char * svgstr)
 
 //====================================================
 
-RegisteredCheckButton::RegisteredCheckButton()
-: _button(0),
-   setProgrammatically(false)
-{
-}
-
 RegisteredCheckButton::~RegisteredCheckButton()
 {
     _toggled_connection.disconnect();
-    if (_button) delete _button;
 }
 
-void
-RegisteredCheckButton::init (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
+RegisteredCheckButton::RegisteredCheckButton (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
+    : RegisteredWidget<Gtk::CheckButton>()
 {
     init_parent(key, wr, repr_in, doc_in);
 
-    _button = new Gtk::CheckButton;
-    _tt.set_tip (*_button, tip);
+    setProgrammatically = false;
+
+    _tt.set_tip (*this, tip);
     Gtk::Label *l = new Gtk::Label (label);
     l->set_use_underline (true);
-    _button->add (*manage (l));
-    _button->set_alignment (right? 1.0 : 0.0, 0.5);
-    _toggled_connection = _button->signal_toggled().connect (sigc::mem_fun (*this, &RegisteredCheckButton::on_toggled));
+    add (*manage (l));
+    set_alignment (right? 1.0 : 0.0, 0.5);
+    _toggled_connection = signal_toggled().connect (sigc::mem_fun (*this, &RegisteredCheckButton::on_toggled));
 }
 
 void
 RegisteredCheckButton::setActive (bool b)
 {
     setProgrammatically = true;
-    _button->set_active (b);
+    set_active (b);
     //The slave button is greyed out if the master button is unchecked
     for (std::list<Gtk::ToggleButton*>::const_iterator i = _slavebuttons.begin(); i != _slavebuttons.end(); i++) {
         (*i)->set_sensitive(b);
@@ -157,10 +151,10 @@ RegisteredCheckButton::on_toggled()
         return;
     _wr->setUpdating (true);
 
-    write_to_xml(_button->get_active() ? "true" : "false");
+    write_to_xml(get_active() ? "true" : "false");
     //The slave button is greyed out if the master button is unchecked
     for (std::list<Gtk::ToggleButton*>::const_iterator i = _slavebuttons.begin(); i != _slavebuttons.end(); i++) {
-        (*i)->set_sensitive(_button->get_active());
+        (*i)->set_sensitive(get_active());
     }
 
     _wr->setUpdating (false);
@@ -546,53 +540,31 @@ RegisteredRadioButtonPair::on_value_changed()
  * Registered POINT
  */
 
-RegisteredPoint::RegisteredPoint()
-{
-    _widget = NULL;
-}
-
 RegisteredPoint::~RegisteredPoint()
 {
-    if (_widget) 
-        delete _widget;
-
     _value_x_changed_connection.disconnect();
     _value_y_changed_connection.disconnect();
 }
 
-void
-RegisteredPoint::init ( const Glib::ustring& label, const Glib::ustring& tip, 
+RegisteredPoint::RegisteredPoint ( const Glib::ustring& label, const Glib::ustring& tip, 
                         const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, 
                         SPDocument* doc_in )
+    : RegisteredWidget<Point> (label, tip)
 {
     init_parent(key, wr, repr_in, doc_in);
 
-    _widget = new Point (label, tip);
-    _widget->setRange (-1e6, 1e6);
-    _widget->setDigits (2);
-    _widget->setIncrements(0.1, 1.0);
-    _value_x_changed_connection = _widget->signal_x_value_changed().connect (sigc::mem_fun (*this, &RegisteredPoint::on_value_changed));
-    _value_y_changed_connection = _widget->signal_y_value_changed().connect (sigc::mem_fun (*this, &RegisteredPoint::on_value_changed));
-}
-
-Point*
-RegisteredPoint::getPoint()
-{
-    return _widget;
-}
-
-void
-RegisteredPoint::setValue (double xval, double yval)
-{
-    if (_widget)
-        _widget->setValue(xval, yval);
+    setRange (-1e6, 1e6);
+    setDigits (2);
+    setIncrements(0.1, 1.0);
+    _value_x_changed_connection = signal_x_value_changed().connect (sigc::mem_fun (*this, &RegisteredPoint::on_value_changed));
+    _value_y_changed_connection = signal_y_value_changed().connect (sigc::mem_fun (*this, &RegisteredPoint::on_value_changed));
 }
 
 void
 RegisteredPoint::on_value_changed()
 {
-    if (_widget->setProgrammatically()) {
-        _widget->clearProgrammatically();
+    if (setProgrammatically()) {
+        clearProgrammatically();
         return;
     }
 
@@ -602,7 +574,7 @@ RegisteredPoint::on_value_changed()
     _wr->setUpdating (true);
 
     Inkscape::SVGOStringStream os;
-    os << _widget->getXValue() << "," << _widget->getYValue();
+    os << getXValue() << "," << getYValue();
 
     write_to_xml(os.str().c_str());
 
index 1a55014270228019a12c4bd94e2b9e3a7dc798bf..7c643715f2fb0d08d56f00c3e72402ab3dea93c3 100644 (file)
@@ -3,8 +3,9 @@
  *
  * Authors:
  *   Ralf Stephan <ralf@ark.in-berlin.de>
+ *   Johan Engelen <j.b.c.engelen@utwente.nl>
  *
- * Copyright (C) 2005 Authors
+ * Copyright (C) 2005-2008 Authors
  *
  * Released under GNU GPL.  Read the file 'COPYING' for more information.
  */
 #include <gtkmm/box.h>
 #include <gtkmm/adjustment.h>
 #include <gtkmm/tooltips.h>
+#include <gtkmm/togglebutton.h>
 
 #include "xml/node.h"
 #include "registry.h"
 
+#include "ui/widget/point.h"
 #include "ui/widget/random.h"
 
 class SPUnit;
@@ -28,7 +31,6 @@ namespace Gtk {
     class HScale;
     class RadioButton;
     class SpinButton;
-    class ToggleButton;
 }
 
 namespace Inkscape {
@@ -40,7 +42,6 @@ class Registry;
 class Scalar;
 class ScalarUnit;
 class UnitMenu;
-class Point;
 
 template <class W>
 class RegisteredWidget : public W {
@@ -137,24 +138,23 @@ protected:
 
 //#######################################################
 
-class RegisteredCheckButton : public RegisteredWdg {
+class RegisteredCheckButton : public RegisteredWidget<Gtk::CheckButton> {
 public:
-    RegisteredCheckButton();
-    ~RegisteredCheckButton();
-    void init (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right=true, Inkscape::XML::Node* repr_in=NULL, SPDocument *doc_in=NULL);
+    virtual ~RegisteredCheckButton();
+    RegisteredCheckButton (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right=true, Inkscape::XML::Node* repr_in=NULL, SPDocument *doc_in=NULL);
+
     void setActive (bool);
 
-    Gtk::ToggleButton *_button;
     std::list<Gtk::ToggleButton*> _slavebuttons;
 
     // a slave button is only sensitive when the master button is active
     // i.e. a slave button is greyed-out when the master button is not checked
 
     void setSlaveButton(std::list<Gtk::ToggleButton*> btns) {
-       _slavebuttons = btns;
+        _slavebuttons = btns;
     }
 
-    bool setProgrammatically; // true if the value was set by setValue, not changed by the user;
+    bool setProgrammatically; // true if the value was set by setActive, not changed by the user;
                                 // if a callback checks it, it must reset it back to false
 
 
@@ -336,27 +336,17 @@ protected:
     void on_value_changed();
 };
 
-class RegisteredPoint : public RegisteredWdg {
+class RegisteredPoint : public RegisteredWidget<Point> {
 public:
-    RegisteredPoint();
-    ~RegisteredPoint();
-    void init (const Glib::ustring& label, 
-               const Glib::ustring& tip, 
-               const Glib::ustring& key, 
-               Registry& wr,
-               Inkscape::XML::Node* repr_in,
-               SPDocument *doc_in);
-    inline void init ( const Glib::ustring& label, 
-                       const Glib::ustring& tip, 
-                       const Glib::ustring& key, 
-                       Registry& wr)
-        { init(label, tip, key, wr, NULL, NULL); };
-
-    Point* getPoint();
-    void setValue (double xval, double yval);
+    virtual ~RegisteredPoint();
+    RegisteredPoint ( const Glib::ustring& label, 
+                      const Glib::ustring& tip, 
+                      const Glib::ustring& key, 
+                      Registry& wr,
+                      Inkscape::XML::Node* repr_in = NULL,
+                      SPDocument *doc_in = NULL );
 
 protected:
-    Point   *_widget;
     sigc::connection  _value_x_changed_connection;
     sigc::connection  _value_y_changed_connection;
     void on_value_changed();