From ea8910e53270b7bd85bd9234186bcf7c4fdd4739 Mon Sep 17 00:00:00 2001 From: gustav_b Date: Thu, 17 Jan 2008 00:56:37 +0000 Subject: [PATCH] RegisteredColorPicker is now subclassed from RegisteredWidget instead of old RegisteredWdg --- src/display/canvas-axonomgrid.cpp | 23 ++++++++++------- src/display/canvas-grid.cpp | 24 ++++++++++------- src/ui/dialog/document-properties.cpp | 33 +++++++++--------------- src/ui/widget/registered-widget.cpp | 37 +++++++++++++-------------- src/ui/widget/registered-widget.h | 34 ++++++++++-------------- 5 files changed, 73 insertions(+), 78 deletions(-) diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 22141faf8..e494ac9dd 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -394,8 +394,18 @@ _wr.setUpdating (true); _("Angle X:"), _("Angle of x-axis"), "gridanglex", _wr, repr, doc ) ); Inkscape::UI::Widget::RegisteredScalar *_rsu_az = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( _("Angle Z:"), _("Angle of z-axis"), "gridanglez", _wr, repr, doc ) ); - 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::RegisteredColorPicker *_rcp_gcol = Gtk::manage( + new Inkscape::UI::Widget::RegisteredColorPicker( + _("Grid line _color:"), _("Grid line color"), _("Color of grid lines"), + "color", "opacity", _wr, repr, doc)); + + Inkscape::UI::Widget::RegisteredColorPicker *_rcp_gmcol = Gtk::manage( + new Inkscape::UI::Widget::RegisteredColorPicker( + _("Ma_jor grid line color:"), _("Major grid line color"), + _("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; @@ -415,11 +425,6 @@ _wr.setUpdating (true); 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); _wr.setUpdating (false); @@ -430,9 +435,9 @@ _wr.setUpdating (false); 0, _rsu_sy->getSU(), 0, _rsu_ax, 0, _rsu_az, - _rcp_gcol->_label, _rcp_gcol->_cp, + _rcp_gcol->_label, _rcp_gcol, 0, 0, - _rcp_gmcol->_label, _rcp_gmcol->_cp, + _rcp_gmcol->_label, _rcp_gmcol, _rsi->_label, &_rsi->_hbox, }; diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index f36d8dc5a..104c28747 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -649,8 +649,18 @@ CanvasXYGrid::newSpecificWidget() 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::RegisteredColorPicker *_rcp_gcol = Gtk::manage( + new Inkscape::UI::Widget::RegisteredColorPicker( + _("Grid line _color:"), _("Grid line color"), _("Color of grid lines"), + "color", "opacity", _wr, repr, doc)); + + Inkscape::UI::Widget::RegisteredColorPicker *_rcp_gmcol = Gtk::manage( + new Inkscape::UI::Widget::RegisteredColorPicker( + _("Ma_jor grid line color:"), _("Major grid line color"), + _("Color of the major (highlighted) grid lines"), "empcolor", "empopacity", + _wr, repr, doc)); + Inkscape::UI::Widget::RegisteredSuffixedInteger *_rsi = new Inkscape::UI::Widget::RegisteredSuffixedInteger(); // initialize widgets: @@ -679,11 +689,7 @@ _wr.setUpdating (true); 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( @@ -699,9 +705,9 @@ _wr.setUpdating (false); 0, _rsu_oy->getSU(), 0, _rsu_sx->getSU(), 0, _rsu_sy->getSU(), - _rcp_gcol->_label, _rcp_gcol->_cp, + _rcp_gcol->_label, _rcp_gcol, 0, 0, - _rcp_gmcol->_label, _rcp_gmcol->_cp, + _rcp_gmcol->_label, _rcp_gmcol, _rsi->_label, &_rsi->_hbox, 0, _rcb_dotted, }; diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 293e6cf19..4ed23d7b2 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -87,11 +87,15 @@ DocumentProperties::DocumentProperties() _rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false), _rcb_bord(_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false), _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), //--------------------------------------------------------------- //General snap options _rcb_sgui(_("Show _guides"), _("Show or hide guides"), "showguides", _wr), _rcbsng(_("_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), + _rcp_gui(_("Guide co_lor:"), _("Guideline color"), _("Color of guidelines"), "guidecolor", "guideopacity", _wr), + _rcp_hgui(_("_Highlight color:"), _("Highlighted guideline color"), _("Color of a guideline when it is under mouse"), "guidehicolor", "guidehiopacity", _wr), //--------------------------------------------------------------- _rcbsg(_("_Enable snapping"), _("Toggle snapping on or off"), "inkscape:snap-global", _wr), _rcbsnbb(_("_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)"), @@ -101,8 +105,8 @@ DocumentProperties::DocumentProperties() //Options for snapping to objects _rcbsnop(_("Snap to path_s"), _("Snap nodes to object paths"), "inkscape:object-paths", _wr), _rcbsnon(_("Snap to n_odes"), _("Snap nodes and guides to object nodes"), "inkscape:object-nodes", _wr), - _rcbsnbbn(_("Snap to bounding box co_rners"), _("Snap bounding box corners to other bounding box corners"), "inkscape:bbox-nodes", _wr), _rcbsnbbp(_("Snap to bounding bo_x edges"), _("Snap bounding box corners and guides to bounding box edges"), "inkscape:bbox-paths", _wr), + _rcbsnbbn(_("Snap to bounding box co_rners"), _("Snap bounding box corners to other bounding box corners"), "inkscape:bbox-nodes", _wr), //--------------------------------------------------------------- //Applies to both nodes and guides, but not to bboxes, that's why its located here _rcbic( _("Rotation _center"), _("Consider the rotation center of an object when snapping"), "inkscape:snap-center", _wr), @@ -213,13 +217,6 @@ 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)"), - "pagecolor", "inkscape:pageopacity", _wr); - _rcp_bord.init (_("Border _color:"), _("Page border color"), - _("Color of the page border"), - "bordercolor", "borderopacity", _wr); _rum_deflt.init (_("Default _units:"), "inkscape:document-units", _wr); Gtk::Label* label_gen = manage (new Gtk::Label); @@ -234,7 +231,7 @@ DocumentProperties::build_page() { label_gen, 0, _rum_deflt._label, _rum_deflt._sel, - _rcp_bg._label, _rcp_bg._cp, + _rcp_bg._label, &_rcp_bg, 0, 0, label_for, 0, 0, &_page_sizer, @@ -243,7 +240,7 @@ DocumentProperties::build_page() 0, &_rcb_canb, 0, &_rcb_bord, 0, &_rcb_shad, - _rcp_bord._label, _rcp_bord._cp, + _rcp_bord._label, &_rcp_bord, }; attach_all(_page_page.table(), widget_array, G_N_ELEMENTS(widget_array)); @@ -254,22 +251,16 @@ DocumentProperties::build_guides() { _page_guides.show(); - _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); - Gtk::Label *label_gui = manage (new Gtk::Label); label_gui->set_markup (_("Guides")); Gtk::Widget *const widget_array[] = { - label_gui, 0, - 0, &_rcb_sgui, - _rcp_gui._label, _rcp_gui._cp, - _rcp_hgui._label, _rcp_hgui._cp, - 0, &_rcbsng, + label_gui, 0, + 0, &_rcb_sgui, + _rcp_gui._label, &_rcp_gui, + _rcp_hgui._label, &_rcp_hgui, + 0, &_rcbsng, }; attach_all(_page_guides.table(), widget_array, G_N_ELEMENTS(widget_array)); diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 4d0e05e98..629de910f 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -293,42 +293,41 @@ RegisteredScalar::on_value_changed() * Registered COLORPICKER */ -RegisteredColorPicker::RegisteredColorPicker() -: _label(0), _cp(0) -{ -} - -RegisteredColorPicker::~RegisteredColorPicker() -{ - _changed_connection.disconnect(); - if (_cp) delete _cp; - if (_label) delete _label; -} - -void -RegisteredColorPicker::init (const Glib::ustring& label, const Glib::ustring& title, const Glib::ustring& tip, const Glib::ustring& ckey, const Glib::ustring& akey, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in) +RegisteredColorPicker::RegisteredColorPicker(const Glib::ustring& label, + const Glib::ustring& title, + const Glib::ustring& tip, + const Glib::ustring& ckey, + const Glib::ustring& akey, + Registry& wr, + Inkscape::XML::Node* repr_in, + SPDocument *doc_in) + : RegisteredWidget (title, tip, 0, true) { init_parent("", wr, repr_in, doc_in); _label = new Gtk::Label (label, 1.0, 0.5); _label->set_use_underline (true); - _cp = new ColorPicker (title,tip,0,true); - _label->set_mnemonic_widget (*_cp); + _label->set_mnemonic_widget (*this); _ckey = ckey; _akey = akey; - _changed_connection = _cp->connectChanged (sigc::mem_fun (*this, &RegisteredColorPicker::on_changed)); + _changed_connection = connectChanged (sigc::mem_fun (*this, &RegisteredColorPicker::on_changed)); +} + +RegisteredColorPicker::~RegisteredColorPicker() +{ + _changed_connection.disconnect(); } void RegisteredColorPicker::setRgba32 (guint32 rgba) { - _cp->setRgba32 (rgba); + ColorPicker::setRgba32 (rgba); } void RegisteredColorPicker::closeWindow() { - _cp->closeWindow(); + ColorPicker::closeWindow(); } void diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 3d99aec5b..e6281e0ef 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -23,6 +23,7 @@ #include "ui/widget/point.h" #include "ui/widget/random.h" +#include "ui/widget/color-picker.h" #include "inkscape.h" #include "document.h" @@ -42,7 +43,6 @@ namespace Inkscape { namespace UI { namespace Widget { -class ColorPicker; class Registry; class Scalar; class ScalarUnit; @@ -71,6 +71,8 @@ protected: 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, typename D > + RegisteredWidget( A& a, B& b, C c, D d ): W( a, b, c, d ) { construct(); } virtual ~RegisteredWidget() {}; @@ -262,31 +264,23 @@ protected: void on_value_changed(); }; -class RegisteredColorPicker : public RegisteredWdg { +class RegisteredColorPicker : public RegisteredWidget { public: - RegisteredColorPicker(); - ~RegisteredColorPicker(); - void init (const Glib::ustring& label, - const Glib::ustring& title, - const Glib::ustring& tip, - const Glib::ustring& ckey, - const Glib::ustring& akey, - Registry& wr, - Inkscape::XML::Node* repr_in, - SPDocument *doc_in); - inline void init ( const Glib::ustring& label, - const Glib::ustring& title, - const Glib::ustring& tip, - const Glib::ustring& ckey, - const Glib::ustring& akey, - Registry& wr) - { init(label, title, tip, ckey, akey, wr, NULL, NULL); }; + virtual ~RegisteredColorPicker(); + + RegisteredColorPicker (const Glib::ustring& label, + const Glib::ustring& title, + const Glib::ustring& tip, + const Glib::ustring& ckey, + const Glib::ustring& akey, + Registry& wr, + Inkscape::XML::Node* repr_in = NULL, + SPDocument *doc_in = NULL); void setRgba32 (guint32); void closeWindow(); Gtk::Label *_label; - ColorPicker *_cp; protected: Glib::ustring _ckey, _akey; -- 2.30.2