summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-01-16 20:12:15 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-01-16 20:12:15 +0000
commitf47d8974f04de245c3eb52c549773599348b3d04 (patch)
tree215f0f698b961f2eccb2ef5c4e5b27f9b9491a98 /src/ui
parentfix initialization of grid document properties (diff)
downloadinkscape-f47d8974f04de245c3eb52c549773599348b3d04.tar.gz
inkscape-f47d8974f04de245c3eb52c549773599348b3d04.zip
RegisteredEnum is now subclassed from RegisteredWidget<enum> instead of old RegisteredWdg
(bzr r4523)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/widget/registered-enums.h58
-rw-r--r--src/ui/widget/registered-widget.cpp36
-rw-r--r--src/ui/widget/registered-widget.h31
3 files changed, 46 insertions, 79 deletions
diff --git a/src/ui/widget/registered-enums.h b/src/ui/widget/registered-enums.h
index e3c72e821..739745817 100644
--- a/src/ui/widget/registered-enums.h
+++ b/src/ui/widget/registered-enums.h
@@ -19,70 +19,43 @@ namespace Inkscape {
namespace UI {
namespace Widget {
-template<typename E> class RegisteredEnum : public RegisteredWdg
+template<typename E> class RegisteredEnum : public RegisteredWidget< LabelledComboBoxEnum<E> >
{
public:
- RegisteredEnum() {
- labelled = NULL;
- }
-
- ~RegisteredEnum() {
+ virtual ~RegisteredEnum() {
_changed_connection.disconnect();
- if (labelled)
- delete labelled;
}
- void init ( const Glib::ustring& label,
+ RegisteredEnum ( const Glib::ustring& label,
const Glib::ustring& tip,
const Glib::ustring& key,
const Util::EnumDataConverter<E>& c,
Registry& wr,
- Inkscape::XML::Node* repr_in,
- SPDocument *doc_in)
+ Inkscape::XML::Node* repr_in = NULL,
+ SPDocument *doc_in = NULL )
+ : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c)
{
- init_parent(key, wr, repr_in, doc_in);
-
- labelled = new LabelledComboBoxEnum<E> (label, tip, c);
+ RegisteredWidget< LabelledComboBoxEnum<E> >::init_parent(key, wr, repr_in, doc_in);
_changed_connection = combobox()->signal_changed().connect (sigc::mem_fun (*this, &RegisteredEnum::on_changed));
}
- inline void init ( const Glib::ustring& label,
- const Glib::ustring& key,
- Registry& wr)
- {
- init(label, key, wr, NULL, NULL);
- }
-
void set_active_by_id (E id) {
- ComboBoxEnum<E> * cb = combobox();
- if (cb)
- cb->set_active_by_id(id);
+ combobox()->set_active_by_id(id);
};
void set_active_by_key (const Glib::ustring& key) {
- ComboBoxEnum<E> * cb = combobox();
- if (cb)
- cb->set_active_by_key(key);
+ combobox()->set_active_by_key(key);
}
inline const Util::EnumData<E>* get_active_data() {
- ComboBoxEnum<E> * cb = combobox();
- if (cb)
- return cb->get_active_data();
- else
- return NULL;
+ combobox()->get_active_data();
}
ComboBoxEnum<E> * combobox() {
- if (labelled) {
- return labelled->getCombobox();
- } else {
- return NULL;
- }
+ return LabelledComboBoxEnum<E>::getCombobox();
}
- LabelledComboBoxEnum<E> * labelled;
sigc::connection _changed_connection;
protected:
@@ -92,16 +65,17 @@ protected:
return;
}
- if (_wr->isUpdating())
+ if (RegisteredWidget< LabelledComboBoxEnum<E> >::_wr->isUpdating())
return;
- _wr->setUpdating (true);
+
+ RegisteredWidget< LabelledComboBoxEnum<E> >::_wr->setUpdating (true);
const Util::EnumData<E>* data = combobox()->get_active_data();
if (data) {
- write_to_xml(data->key.c_str());
+ RegisteredWidget< LabelledComboBoxEnum<E> >::write_to_xml(data->key.c_str());
}
- _wr->setUpdating (false);
+ RegisteredWidget< LabelledComboBoxEnum<E> >::_wr->setUpdating (false);
}
};
diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp
index dfa42107e..f471dc40d 100644
--- a/src/ui/widget/registered-widget.cpp
+++ b/src/ui/widget/registered-widget.cpp
@@ -32,11 +32,6 @@
#include "svg/svg-color.h"
#include "svg/stringstream.h"
-#include "inkscape.h"
-#include "document.h"
-#include "desktop-handles.h"
-#include "sp-namedview.h"
-
#include "verbs.h"
// for interruptability bug:
@@ -48,37 +43,6 @@ namespace Widget {
//===================================================
-//---------------------------------------------------
-
-
-
-template<class W>
-void RegisteredWidget<W>::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);
- }
-}
-
void
RegisteredWdg::write_to_xml(const char * svgstr)
{
diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h
index 9a0ba46fc..900eaafbb 100644
--- a/src/ui/widget/registered-widget.h
+++ b/src/ui/widget/registered-widget.h
@@ -23,6 +23,11 @@
#include "ui/widget/point.h"
#include "ui/widget/random.h"
+#include "inkscape.h"
+
+#include "document.h"
+#include "desktop-handles.h"
+#include "sp-namedview.h"
class SPUnit;
class SPDocument;
@@ -79,7 +84,31 @@ protected:
g_warning("Initialization of registered widget using defined repr but with doc==NULL");
}
- void write_to_xml(const char * svgstr);
+ void 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);
+ }
+ }
Registry * _wr;
Glib::ustring _key;