summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4a433a9)
raw | patch | inline | side by side (parent: 4a433a9)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Wed, 27 Feb 2008 09:35:01 +0000 (09:35 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Wed, 27 Feb 2008 09:35:01 +0000 (09:35 +0000) |
index f531257310cd62c82695648aec4ad25dc3a61bcf..f48648d18f5042b06cb5d394b5b154bb7536c023 100644 (file)
_wr.setUpdating (true);
- 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::RegisteredUnitMenu *_rumg = Gtk::manage( new Inkscape::UI::Widget::RegisteredUnitMenu(
+ _("Grid _units:"), "units", _wr, repr, doc) );
+ Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_ox = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
+ _("_Origin X:"), _("X coordinate of grid origin"), "originx", *_rumg, _wr, repr, doc) );
+ Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_oy = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
+ _("O_rigin Y:"), _("Y coordinate of grid origin"), "originy", *_rumg, _wr, repr, doc) );
+ Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_sy = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
+ _("Spacing _Y:"), _("Base length of z-axis"), "spacingy", *_rumg, _wr, repr, doc) );
Inkscape::UI::Widget::RegisteredScalar *_rsu_ax = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar(
_("Angle X:"), _("Angle of x-axis"), "gridanglex", _wr, repr, doc ) );
Inkscape::UI::Widget::RegisteredScalar *_rsu_az = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar(
_("Color of the major (highlighted) grid lines"),
"empcolor", "empopacity", _wr, repr, doc));
- Inkscape::UI::Widget::RegisteredSuffixedInteger *_rsi = new Inkscape::UI::Widget::RegisteredSuffixedInteger();
-
- 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);
- _rsi->init (_("_Major grid line every:"), _("lines"), "empspacing", _wr, repr, doc);
+ Inkscape::UI::Widget::RegisteredSuffixedInteger *_rsi = Gtk::manage( new Inkscape::UI::Widget::RegisteredSuffixedInteger(
+ _("_Major grid line every:"), _(""), _("lines"), "empspacing", _wr, repr, doc ) );
+
+ _rsu_ox->setDigits(4);
+ _rsu_ox->setIncrements(0.1, 1.0);
+
+ _rsu_oy->setDigits(4);
+ _rsu_oy->setIncrements(0.1, 1.0);
+
+ _rsu_sy->setDigits(4);
+ _rsu_sy->setIncrements(0.1, 1.0);
+
_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, _rumg,
+ 0, _rsu_ox,
+ 0, _rsu_oy,
+ 0, _rsu_sy,
0, _rsu_ax,
0, _rsu_az,
_rcp_gcol->_label, _rcp_gcol,
0, 0,
_rcp_gmcol->_label, _rcp_gmcol,
- _rsi->_label, &_rsi->_hbox,
+ 0, _rsi,
};
attach_all (*table, widget_array, sizeof(widget_array));
index 245c78ecae7c417299341d5a4d44cd93b4fff138..6ac2b4f0e13b0390d682df9ace5857ce7d81c269 100644 (file)
{
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::RegisteredUnitMenu *_rumg = Gtk::manage( new Inkscape::UI::Widget::RegisteredUnitMenu(
+ _("Grid _units:"), "units", _wr, repr, doc) );
+ Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_ox = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
+ _("_Origin X:"), _("X coordinate of grid origin"), "originx", *_rumg, _wr, repr, doc) );
+ Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_oy = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
+ _("O_rigin Y:"), _("Y coordinate of grid origin"), "originy", *_rumg, _wr, repr, doc) );
+ Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_sx = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
+ _("Spacing _X:"), _("Distance between vertical grid lines"), "spacingx", *_rumg, _wr, repr, doc) );
+ Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_sy = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
+ _("Spacing _Y:"), _("Distance between horizontal grid lines"), "spacingy", *_rumg, _wr, repr, doc) );
Inkscape::UI::Widget::RegisteredColorPicker *_rcp_gcol = Gtk::manage(
new Inkscape::UI::Widget::RegisteredColorPicker(
_("Color of the major (highlighted) grid lines"), "empcolor", "empopacity",
_wr, repr, doc));
- Inkscape::UI::Widget::RegisteredSuffixedInteger *_rsi = new Inkscape::UI::Widget::RegisteredSuffixedInteger();
+ Inkscape::UI::Widget::RegisteredSuffixedInteger *_rsi = Gtk::manage( new Inkscape::UI::Widget::RegisteredSuffixedInteger(
+ _("_Major grid line every:"), _(""), _("lines"), "empspacing", _wr, repr, doc) );
- // 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);
-
- _rsi->init (_("_Major grid line every:"), _("lines"), "empspacing", _wr, repr, doc);
+
+ _rsu_ox->setDigits(4);
+ _rsu_ox->setIncrements(0.1, 1.0);
+
+ _rsu_oy->setDigits(4);
+ _rsu_oy->setIncrements(0.1, 1.0);
+
+ _rsu_sx->setDigits(4);
+ _rsu_sx->setIncrements(0.1, 1.0);
+
+ _rsu_sy->setDigits(4);
+ _rsu_sy->setIncrements(0.1, 1.0);
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)
- );
+ "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(),
+ 0, _rumg,
+ 0, _rsu_ox,
+ 0, _rsu_oy,
+ 0, _rsu_sx,
+ 0, _rsu_sy,
_rcp_gcol->_label, _rcp_gcol,
0, 0,
_rcp_gmcol->_label, _rcp_gmcol,
- _rsi->_label, &_rsi->_hbox,
+ 0, _rsi,
0, _rcb_dotted,
};
index 66b1ddf564b9414826272817728a91b22721b30c..4004e151cc59cc1240f5a50d220ff444efa9f323 100644 (file)
_rcb_shad(_("_Show border shadow"), _("If set, page border shows a shadow on its right and lower side"), "inkscape:showpageshadow", _wr, false),
_rcp_bg(_("Back_ground:"), _("Background color"), _("Color and transparency of the page background (also used for bitmap export)"), "pagecolor", "inkscape:pageopacity", _wr),
_rcp_bord(_("Border _color:"), _("Page border color"), _("Color of the page border"), "bordercolor", "borderopacity", _wr),
+ _rum_deflt(_("Default _units:"), "inkscape:document-units", _wr),
+ _page_sizer(_wr),
//---------------------------------------------------------------
//General snap options
_rcb_sgui(_("Show _guides"), _("Show or hide guides"), "showguides", _wr),
{
_page_page.show();
- _rum_deflt.init (_("Default _units:"), "inkscape:document-units", _wr);
-
Gtk::Label* label_gen = manage (new Gtk::Label);
label_gen->set_markup (_("<b>General</b>"));
Gtk::Label* label_bor = manage (new Gtk::Label);
label_bor->set_markup (_("<b>Border</b>"));
Gtk::Label *label_for = manage (new Gtk::Label);
label_for->set_markup (_("<b>Format</b>"));
- _page_sizer.init (_wr);
Gtk::Widget *const widget_array[] =
{
label_gen, 0,
- _rum_deflt._label, _rum_deflt._sel,
+ 0, &_rum_deflt,
_rcp_bg._label, &_rcp_bg,
0, 0,
label_for, 0,
index 8f7625a2d0254f54ecb9879d4c5d15d41ed28d54..d2509d8a46d3193b1cb3ebeb1fb37fee6d9ceda0 100644 (file)
PageSizer _page_sizer;
//---------------------------------------------------------------
RegisteredCheckButton _rcb_sgui, _rcbsng;
- RegisteredUnitMenu _rum_gusn;
RegisteredColorPicker _rcp_gui, _rcp_hgui;
//---------------------------------------------------------------
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;
index 7b0fea5f558fd8b91d0397b444762ec8c24a8841..40f3addcf2b36f59b74d8c7a9c1c59d455663083 100644 (file)
/**
* Constructor
*/
-PageSizer::PageSizer() : Gtk::VBox(false,4)
+PageSizer::PageSizer(Registry & _wr)
+ : Gtk::VBox(false,4),
+ _dimensionUnits( _("U_nits:"), "units", _wr ),
+ _dimensionWidth( _("_Width:"), _("Width of paper"), "width", _dimensionUnits, _wr ),
+ _dimensionHeight( _("_Height:"), _("Height of paper"), "height", _dimensionUnits, _wr ),
+ _widgetRegistry(&_wr)
{
-
-
//# Set up the Paper Size combo box
_paperSizeListStore = Gtk::ListStore::create(_paperSizeListColumns);
_paperSizeList.set_model(_paperSizeListStore);
_customTable.set_border_width (4);
_customTable.set_row_spacings (4);
_customTable.set_col_spacings (4);
+ _customTable.attach(_dimensionWidth, 0,1,0,1);
+ _customTable.attach(_dimensionUnits, 1,2,0,1);
+ _customTable.attach(_dimensionHeight, 0,1,1,2);
+ _customTable.attach(_fitPageButton, 1,2,1,2);
_customFrame.add(_customTable);
_fitPageButton.set_use_underline();
_fitPageButton.set_label(_("_Fit page to selection"));
- _tips.set_tip(_fitPageButton,
- _("Resize the page to fit the current selection, or the entire drawing if there is no selection"));
-
-
-
+ _tips.set_tip(_fitPageButton, _("Resize the page to fit the current selection, or the entire drawing if there is no selection"));
}
* Initialize or reset this widget
*/
void
-PageSizer::init (Registry& reg)
+PageSizer::init ()
{
-
- /*
- Note that the registered widgets can only be placed onto a
- container after they have been init()-ed. That is why some
- of the widget creation is in the constructor, and the rest is
- here.
- */
-
- _widgetRegistry = ®
-
- _dimensionUnits.init (_("U_nits:"), "units",
- *_widgetRegistry);
- _dimensionWidth.init (_("_Width:"), _("Width of paper"), "width",
- _dimensionUnits, *_widgetRegistry);
- _dimensionHeight.init (_("_Height:"), _("Height of paper"), "height",
- _dimensionUnits, *_widgetRegistry);
-
- _customTable.attach(*(_dimensionWidth.getSU()), 0,1,0,1);
- _customTable.attach(*(_dimensionUnits._sel), 1,2,0,1);
- _customTable.attach(*(_dimensionHeight.getSU()), 0,1,1,2);
- _customTable.attach(_fitPageButton, 1,2,1,2);
-
- _landscape_connection = _landscapeButton.signal_toggled().connect (
- sigc::mem_fun (*this, &PageSizer::on_landscape));
- _portrait_connection = _portraitButton.signal_toggled().connect (
- sigc::mem_fun (*this, &PageSizer::on_portrait));
- _changedw_connection = _dimensionWidth.getSU()->signal_value_changed().connect (
- sigc::mem_fun (*this, &PageSizer::on_value_changed));
- _changedh_connection = _dimensionHeight.getSU()->signal_value_changed().connect (
- sigc::mem_fun (*this, &PageSizer::on_value_changed));
- _fitPageButton.signal_clicked().connect(
- sigc::mem_fun(*this, &PageSizer::fire_fit_canvas_to_selection_or_drawing));
+ _landscape_connection = _landscapeButton.signal_toggled().connect (sigc::mem_fun (*this, &PageSizer::on_landscape));
+ _portrait_connection = _portraitButton.signal_toggled().connect (sigc::mem_fun (*this, &PageSizer::on_portrait));
+ _changedw_connection = _dimensionWidth.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed));
+ _changedh_connection = _dimensionHeight.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed));
+ _fitPageButton.signal_clicked().connect(sigc::mem_fun(*this, &PageSizer::fire_fit_canvas_to_selection_or_drawing));
show_all_children();
-
}
_paperSizeListSelection->select(row);
}
- Unit const& unit = _dimensionUnits._sel->getUnit();
+ Unit const& unit = _dimensionUnits.getUnit();
_dimensionWidth.setValue (w / unit.factor);
_dimensionHeight.setValue (h / unit.factor);
{
if (!_portraitButton.get_active())
return;
- double w = _dimensionWidth.getSU()->getValue ("px");
- double h = _dimensionHeight.getSU()->getValue ("px");
+ double w = _dimensionWidth.getValue ("px");
+ double h = _dimensionHeight.getValue ("px");
if (h < w)
setDim (h, w);
}
{
if (!_landscapeButton.get_active())
return;
- double w = _dimensionWidth.getSU()->getValue ("px");
- double h = _dimensionHeight.getSU()->getValue ("px");
+ double w = _dimensionWidth.getValue ("px");
+ double h = _dimensionHeight.getValue ("px");
if (w < h)
setDim (h, w);
}
{
if (_widgetRegistry->isUpdating()) return;
- setDim (_dimensionWidth.getSU()->getValue("px"),
- _dimensionHeight.getSU()->getValue("px"));
+ setDim (_dimensionWidth.getValue("px"),
+ _dimensionHeight.getValue("px"));
}
index e3d10f578829861339c8159be082d04f2043ff89..f970afe44cf55fa1f4614ceb6475dfbabf030c0e 100644 (file)
/**
* Constructor
*/
- PageSizer();
+ PageSizer(Registry & _wr);
/**
* Destructor
/**
* Set up or reset this widget
*/
- void init (Registry& reg);
+ void init ();
/**
* Set the page size to the given dimensions. If 'changeList' is
index f8abecdbeb2402c67f43e9ae4721571890555eef..3b36ea6bc108f42e75a02bcb1c6bf22abdc3a0c0 100644 (file)
namespace UI {
namespace Widget {
-void
-RegisteredWdg::write_to_xml(const char * svgstr)
-{
- // Use local repr here. When repr is specified, use that one, but
- // if repr==NULL, get the repr of namedview of active desktop.
- Inkscape::XML::Node *local_repr = repr;
- SPDocument *local_doc = doc;
- if (!local_repr) {
- // no repr specified, use active desktop's namedview's repr
- SPDesktop* dt = SP_ACTIVE_DESKTOP;
- local_repr = SP_OBJECT_REPR (sp_desktop_namedview(dt));
- local_doc = sp_desktop_document(dt);
- }
-
- bool saved = sp_document_get_undo_sensitive (local_doc);
- sp_document_set_undo_sensitive (local_doc, false);
- if (!write_undo) local_repr->setAttribute(_key.c_str(), svgstr);
- sp_document_set_undo_sensitive (local_doc, saved);
-
- local_doc->setModifiedSinceSave();
- if (write_undo) {
- local_repr->setAttribute(_key.c_str(), svgstr);
- sp_document_done (local_doc, event_type, event_description);
- }
-}
-
-
/*#########################################
* Registered CHECKBUTTON
*/
* Registered UNITMENU
*/
-RegisteredUnitMenu::RegisteredUnitMenu()
-: _label(0), _sel(0)
-{
-}
-
RegisteredUnitMenu::~RegisteredUnitMenu()
{
_changed_connection.disconnect();
- if (_label) delete _label;
- if (_sel) delete _sel;
}
-void
-RegisteredUnitMenu::init (const Glib::ustring& label, const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
+RegisteredUnitMenu::RegisteredUnitMenu (const Glib::ustring& label, const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
+ : RegisteredWidget<Labelled> (label, "" /*tooltip*/, new UnitMenu())
{
init_parent(key, wr, repr_in, doc_in);
- _label = new Gtk::Label (label, 1.0, 0.5);
- _label->set_use_underline (true);
- _sel = new UnitMenu ();
- _label->set_mnemonic_widget (*_sel);
- _sel->setUnitType (UNIT_TYPE_LINEAR);
- _changed_connection = _sel->signal_changed().connect (sigc::mem_fun (*this, &RegisteredUnitMenu::on_changed));
+ getUnitMenu()->setUnitType (UNIT_TYPE_LINEAR);
+ _changed_connection = getUnitMenu()->signal_changed().connect (sigc::mem_fun (*this, &RegisteredUnitMenu::on_changed));
}
void
RegisteredUnitMenu::setUnit (const SPUnit* unit)
{
- _sel->setUnit (sp_unit_get_abbreviation (unit));
+ getUnitMenu()->setUnit (sp_unit_get_abbreviation (unit));
}
void
return;
Inkscape::SVGOStringStream os;
- os << _sel->getUnitAbbr();
+ os << getUnitMenu()->getUnitAbbr();
_wr->setUpdating (true);
* Registered SCALARUNIT
*/
-RegisteredScalarUnit::RegisteredScalarUnit()
-: _widget(0), _um(0)
-{
-}
-
RegisteredScalarUnit::~RegisteredScalarUnit()
{
- if (_widget) delete _widget;
_value_changed_connection.disconnect();
}
-void
-RegisteredScalarUnit::init (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, const RegisteredUnitMenu &rum, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
+RegisteredScalarUnit::RegisteredScalarUnit (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, const RegisteredUnitMenu &rum, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
+ : RegisteredWidget<ScalarUnit>(label, tip, UNIT_TYPE_LINEAR, "", "", rum.getUnitMenu()),
+ _um(0)
{
init_parent(key, wr, repr_in, doc_in);
- _widget = new ScalarUnit (label, tip, UNIT_TYPE_LINEAR, "", "", rum._sel);
- _widget->initScalar (-1e6, 1e6);
- _widget->setUnit (rum._sel->getUnitAbbr());
- _widget->setDigits (2);
- _um = rum._sel;
- _value_changed_connection = _widget->signal_value_changed().connect (sigc::mem_fun (*this, &RegisteredScalarUnit::on_value_changed));
-}
-
-ScalarUnit*
-RegisteredScalarUnit::getSU()
-{
- return _widget;
+ initScalar (-1e6, 1e6);
+ setUnit (rum.getUnitMenu()->getUnitAbbr());
+ setDigits (2);
+ _um = rum.getUnitMenu();
+ _value_changed_connection = signal_value_changed().connect (sigc::mem_fun (*this, &RegisteredScalarUnit::on_value_changed));
}
-void
-RegisteredScalarUnit::setValue (double val)
-{
- if (_widget)
- _widget->setValue (val);
-}
void
RegisteredScalarUnit::on_value_changed()
{
- if (_widget->setProgrammatically) {
- _widget->setProgrammatically = false;
+ if (setProgrammatically) {
+ setProgrammatically = false;
return;
}
_wr->setUpdating (true);
Inkscape::SVGOStringStream os;
- os << _widget->getValue("");
+ os << getValue("");
if (_um)
os << _um->getUnitAbbr();
* Registered SUFFIXEDINTEGER
*/
-RegisteredSuffixedInteger::RegisteredSuffixedInteger()
-: _label(0),
- setProgrammatically(false),
- _sb(0),
- _adj(0.0,0.0,100.0,1.0,1.0,1.0),
- _suffix(0)
-{
-}
-
RegisteredSuffixedInteger::~RegisteredSuffixedInteger()
{
_changed_connection.disconnect();
- if (_label) delete _label;
- if (_suffix) delete _suffix;
- if (_sb) delete _sb;
}
-void
-RegisteredSuffixedInteger::init (const Glib::ustring& label, const Glib::ustring& suffix, const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
+RegisteredSuffixedInteger::RegisteredSuffixedInteger (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& suffix, const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
+ : RegisteredWidget<Scalar>(label, tip, 0, suffix),
+ setProgrammatically(false)
{
init_parent(key, wr, repr_in, doc_in);
- _label = new Gtk::Label (label);
- _label->set_alignment (1.0, 0.5);
- _label->set_use_underline();
- _sb = new Gtk::SpinButton (_adj, 1.0, 0);
- _sb->set_numeric();
- _label->set_mnemonic_widget (*_sb);
- _suffix = new Gtk::Label (suffix);
- _hbox.pack_start (*_sb, true, true, 0);
- _hbox.pack_start (*_suffix, false, false, 0);
-
- _changed_connection = _adj.signal_value_changed().connect (sigc::mem_fun(*this, &RegisteredSuffixedInteger::on_value_changed));
-}
+ setRange (0, 1e6);
+ setDigits (0);
+ setIncrements(1, 10);
-void
-RegisteredSuffixedInteger::setValue (int i)
-{
- setProgrammatically = true;
- _adj.set_value (i);
+ _changed_connection = signal_value_changed().connect (sigc::mem_fun(*this, &RegisteredSuffixedInteger::on_value_changed));
}
void
_wr->setUpdating (true);
Inkscape::SVGOStringStream os;
- int value = int(_adj.get_value());
- os << value;
+ os << getValue();
write_to_xml(os.str().c_str());
* Registered RADIOBUTTONPAIR
*/
-RegisteredRadioButtonPair::RegisteredRadioButtonPair()
-: _hbox(0),
- setProgrammatically(false)
-{
-}
-
RegisteredRadioButtonPair::~RegisteredRadioButtonPair()
{
_changed_connection.disconnect();
}
-void
-RegisteredRadioButtonPair::init (const Glib::ustring& label,
-const Glib::ustring& label1, const Glib::ustring& label2,
-const Glib::ustring& tip1, const Glib::ustring& tip2,
-const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
+RegisteredRadioButtonPair::RegisteredRadioButtonPair (const Glib::ustring& label,
+ const Glib::ustring& label1, const Glib::ustring& label2,
+ const Glib::ustring& tip1, const Glib::ustring& tip2,
+ const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
+ : RegisteredWidget<Gtk::HBox>(),
+ _rb1(NULL),
+ _rb2(NULL)
{
init_parent(key, wr, repr_in, doc_in);
- _hbox = new Gtk::HBox;
- _hbox->add (*manage (new Gtk::Label (label)));
+ setProgrammatically = false;
+
+ add (*manage (new Gtk::Label (label)));
_rb1 = manage (new Gtk::RadioButton (label1, true));
- _hbox->add (*_rb1);
+ add (*_rb1);
Gtk::RadioButtonGroup group = _rb1->get_group();
_rb2 = manage (new Gtk::RadioButton (group, label2, true));
- _hbox->add (*_rb2);
+ add (*_rb2);
_rb2->set_active();
_tt.set_tip (*_rb1, tip1);
_tt.set_tip (*_rb2, tip2);
index 42bcf62d7eef9eb072673d5e6485411377863731..a3b04575e826a015045d8b912f4d7f296e0674ad 100644 (file)
#include "xml/node.h"
#include "registry.h"
+#include "ui/widget/scalar.h"
+#include "ui/widget/scalar-unit.h"
#include "ui/widget/point.h"
#include "ui/widget/random.h"
+#include "ui/widget/unit-menu.h"
#include "ui/widget/color-picker.h"
#include "inkscape.h"
namespace Widget {
class Registry;
-class Scalar;
-class ScalarUnit;
-class UnitMenu;
template <class W>
class RegisteredWidget : public W {
template< typename A, typename B >
RegisteredWidget( A& a, B& b ): W( a, b ) { construct(); }
template< typename A, typename B, typename C >
+ RegisteredWidget( A& a, B& b, C* c ): W( a, b, c ) { construct(); }
+ template< typename A, typename B, typename C >
RegisteredWidget( A& a, B& b, C& c ): W( a, b, c ) { construct(); }
template< typename A, typename B, typename C, typename D >
RegisteredWidget( A& a, B& b, C c, D d ): W( a, b, c, d ) { construct(); }
+ template< typename A, typename B, typename C, typename D, typename E , typename F>
+ RegisteredWidget( A& a, B& b, C c, D& d, E& e, F* f): W( a, b, c, d, e, f) { construct(); }
virtual ~RegisteredWidget() {};
}
};
-class RegisteredWdg {
-public:
- void set_undo_parameters(const unsigned int _event_type, Glib::ustring _event_description)
- {
- event_type = _event_type;
- event_description = _event_description;
- write_undo = true;
- }
-
- bool is_updating() {if (_wr) return _wr->isUpdating(); else return false;}
-
-protected:
- RegisteredWdg()
- {
- _wr = NULL;
- repr = NULL;
- doc = NULL;
- write_undo = false;
- }
-
- void init_parent(const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
- {
- _wr = ≀
- _key = key;
- repr = repr_in;
- doc = doc_in;
- if (repr && !doc) // doc cannot be NULL when repr is not NULL
- g_warning("Initialization of registered widget using defined repr but with doc==NULL");
- }
-
- void write_to_xml(const char * svgstr);
-
- Registry * _wr;
- Glib::ustring _key;
- Inkscape::XML::Node * repr;
- SPDocument * doc;
- unsigned int event_type;
- Glib::ustring event_description;
- bool write_undo;
-};
-
//#######################################################
class RegisteredCheckButton : public RegisteredWidget<Gtk::CheckButton> {
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
-
protected:
Gtk::Tooltips _tt;
sigc::connection _toggled_connection;
void on_toggled();
};
-class RegisteredUnitMenu : public RegisteredWdg {
+class RegisteredUnitMenu : public RegisteredWidget<Labelled> {
public:
- RegisteredUnitMenu();
~RegisteredUnitMenu();
- void init ( const Glib::ustring& label,
- const Glib::ustring& key,
- Registry& wr,
- Inkscape::XML::Node* repr_in,
- SPDocument *doc_in);
- inline void init ( const Glib::ustring& label,
- const Glib::ustring& key,
- Registry& wr)
- { init(label, key, wr, NULL, NULL); };
+ RegisteredUnitMenu ( const Glib::ustring& label,
+ const Glib::ustring& key,
+ Registry& wr,
+ Inkscape::XML::Node* repr_in = NULL,
+ SPDocument *doc_in = NULL );
void setUnit (const SPUnit*);
- Gtk::Label *_label;
- UnitMenu *_sel;
+ Unit getUnit() const { return static_cast<UnitMenu*>(_widget)->getUnit(); };
+ UnitMenu* getUnitMenu() const { return static_cast<UnitMenu*>(_widget); };
sigc::connection _changed_connection;
protected:
void on_changed();
};
-class RegisteredScalarUnit : public RegisteredWdg {
+class RegisteredScalarUnit : public RegisteredWidget<ScalarUnit> {
public:
- RegisteredScalarUnit();
~RegisteredScalarUnit();
- void init (const Glib::ustring& label,
- const Glib::ustring& tip,
- const Glib::ustring& key,
- const RegisteredUnitMenu &rum,
- 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,
- const RegisteredUnitMenu &rum,
- Registry& wr)
- { init(label, tip, key, rum, wr, NULL, NULL); };
-
- ScalarUnit* getSU();
- void setValue (double);
+ RegisteredScalarUnit ( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ const RegisteredUnitMenu &rum,
+ Registry& wr,
+ Inkscape::XML::Node* repr_in = NULL,
+ SPDocument *doc_in = NULL );
protected:
- ScalarUnit *_widget;
sigc::connection _value_changed_connection;
UnitMenu *_um;
void on_value_changed();
sigc::connection _changed_connection;
};
-class RegisteredSuffixedInteger : public RegisteredWdg {
+class RegisteredSuffixedInteger : public RegisteredWidget<Scalar> {
public:
- RegisteredSuffixedInteger();
- ~RegisteredSuffixedInteger();
- void init (const Glib::ustring& label1,
- const Glib::ustring& label2,
- const Glib::ustring& key,
- Registry& wr,
- Inkscape::XML::Node* repr_in,
- SPDocument *doc_in);
- inline void init ( const Glib::ustring& label1,
- const Glib::ustring& label2,
- const Glib::ustring& key,
- Registry& wr)
- { init(label1, label2, key, wr, NULL, NULL); };
+ virtual ~RegisteredSuffixedInteger();
+ RegisteredSuffixedInteger ( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& suffix,
+ const Glib::ustring& key,
+ Registry& wr,
+ Inkscape::XML::Node* repr_in = NULL,
+ SPDocument *doc_in = NULL );
- void setValue (int);
- Gtk::Label *_label;
- Gtk::HBox _hbox;
bool setProgrammatically; // true if the value was set by setValue, not changed by the user;
// if a callback checks it, it must reset it back to false
protected:
- Gtk::SpinButton *_sb;
- Gtk::Adjustment _adj;
- Gtk::Label *_suffix;
sigc::connection _changed_connection;
void on_value_changed();
};
-class RegisteredRadioButtonPair : public RegisteredWdg {
+class RegisteredRadioButtonPair : public RegisteredWidget<Gtk::HBox> {
public:
- RegisteredRadioButtonPair();
- ~RegisteredRadioButtonPair();
- void init (const Glib::ustring& label,
- const Glib::ustring& label1,
- const Glib::ustring& label2,
- const Glib::ustring& tip1,
- const Glib::ustring& tip2,
- const Glib::ustring& key,
- Registry& wr,
- Inkscape::XML::Node* repr_in,
- SPDocument *doc_in);
- inline void init ( const Glib::ustring& label,
- const Glib::ustring& label1,
- const Glib::ustring& label2,
- const Glib::ustring& tip1,
- const Glib::ustring& tip2,
- const Glib::ustring& key,
- Registry& wr)
- { init(label, label1, label2, tip1, tip2, key, wr, NULL, NULL); };
+ virtual ~RegisteredRadioButtonPair();
+ RegisteredRadioButtonPair ( const Glib::ustring& label,
+ const Glib::ustring& label1,
+ const Glib::ustring& label2,
+ const Glib::ustring& tip1,
+ const Glib::ustring& tip2,
+ const Glib::ustring& key,
+ Registry& wr,
+ Inkscape::XML::Node* repr_in = NULL,
+ SPDocument *doc_in = NULL );
void setValue (bool second);
- Gtk::HBox *_hbox;
bool setProgrammatically; // true if the value was set by setValue, not changed by the user;
// if a callback checks it, it must reset it back to false