index 88da74a1dd689bc5fedc34b7727fc25d9faa7335..7e5d46739b5e2e833db339ebf438a1972d07906a 100644 (file)
namespace Inkscape {
namespace Extension {
+/*
+template <typename T> class ParamSpecific : public Parameter {
+private:
+ T _value;
+public:
+ ParamSpecific (const gchar * name, const gchar * guitext, Inkscape::Extension * ext, Inkscape::XML::Node * xml);
+ T get (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node);
+ T set (T in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
+ Gtk::Widget * get_widget(void);
+ Glib::ustring * string (void);
+};
+
+bool
+ParamSpecific<bool>::get (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node)
+{
+ return _value;
+}
+
+int
+ParamSpecific<int>::get (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node)
+{
+ return _value;
+}
+*/
+
/** \brief A boolean parameter */
class ParamBool : public Parameter {
private:
public:
ParamBool(const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
/** \brief Returns \c _value */
- bool get (const Inkscape::XML::Document * doc) { return _value; }
- bool set (bool in, Inkscape::XML::Document * doc);
+ bool get (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node) { return _value; }
+ bool set (bool in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
Gtk::Widget * get_widget(void);
Glib::ustring * string (void);
};
public:
ParamInt (const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
/** \brief Returns \c _value */
- int get (const Inkscape::XML::Document * doc) { return _value; }
- int set (int in, Inkscape::XML::Document * doc);
+ int get (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node) { return _value; }
+ int set (int in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
int max (void) { return _max; }
int min (void) { return _min; }
Gtk::Widget * get_widget(void);
public:
ParamFloat (const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
/** \brief Returns \c _value */
- float get (const Inkscape::XML::Document * doc) { return _value; }
- float set (float in, Inkscape::XML::Document * doc);
+ float get (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node) { return _value; }
+ float set (float in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
float max (void) { return _max; }
float min (void) { return _min; }
Gtk::Widget * get_widget(void);
ParamString(const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
~ParamString(void);
/** \brief Returns \c _value, with a \i const to protect it. */
- const gchar * get (const Inkscape::XML::Document * doc) { return _value; }
- const gchar * set (const gchar * in, Inkscape::XML::Document * doc);
+ const gchar * get (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node) { return _value; }
+ const gchar * set (const gchar * in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
Gtk::Widget * get_widget(void);
Glib::ustring * string (void);
};
@@ -251,13 +276,14 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
/** \brief A function to set the \c _value
\param in The value to set to
\param doc A document that should be used to set the value.
+ \param node The node where the value may be placed
This function sets the internal value, but it also sets the value
in the preferences structure. To put it in the right place, \c PREF_DIR
and \c pref_name() are used.
*/
bool
-ParamBool::set (bool in, Inkscape::XML::Document * doc)
+ParamBool::set (bool in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node)
{
_value = in;
/** \brief A function to set the \c _value
\param in The value to set to
\param doc A document that should be used to set the value.
+ \param node The node where the value may be placed
This function sets the internal value, but it also sets the value
in the preferences structure. To put it in the right place, \c PREF_DIR
and \c pref_name() are used.
*/
int
-ParamInt::set (int in, Inkscape::XML::Document * doc)
+ParamInt::set (int in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node)
{
_value = in;
if (_value > _max) _value = _max;
/** \brief A function to set the \c _value
\param in The value to set to
\param doc A document that should be used to set the value.
+ \param node The node where the value may be placed
This function sets the internal value, but it also sets the value
in the preferences structure. To put it in the right place, \c PREF_DIR
and \c pref_name() are used.
*/
float
-ParamFloat::set (float in, Inkscape::XML::Document * doc)
+ParamFloat::set (float in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node)
{
_value = in;
if (_value > _max) _value = _max;
/** \brief A function to set the \c _value
\param in The value to set to
\param doc A document that should be used to set the value.
+ \param node The node where the value may be placed
This function sets the internal value, but it also sets the value
in the preferences structure. To put it in the right place, \c PREF_DIR
the passed in value is duplicated using \c g_strdup().
*/
const gchar *
-ParamString::set (const gchar * in, Inkscape::XML::Document * doc)
+ParamString::set (const gchar * in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node)
{
if (in == NULL) return NULL; /* Can't have NULL string */
/** \brief Wrapper to cast to the object and use it's function. */
bool
-Parameter::get_bool (const Inkscape::XML::Document * doc)
+Parameter::get_bool (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node)
{
ParamBool * boolpntr;
boolpntr = dynamic_cast<ParamBool *>(this);
if (boolpntr == NULL)
throw Extension::param_wrong_type();
- return boolpntr->get(doc);
+ return boolpntr->get(doc, node);
}
/** \brief Wrapper to cast to the object and use it's function. */
int
-Parameter::get_int (const Inkscape::XML::Document * doc)
+Parameter::get_int (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node)
{
ParamInt * intpntr;
intpntr = dynamic_cast<ParamInt *>(this);
if (intpntr == NULL)
throw Extension::param_wrong_type();
- return intpntr->get(doc);
+ return intpntr->get(doc, node);
}
/** \brief Wrapper to cast to the object and use it's function. */
float
-Parameter::get_float (const Inkscape::XML::Document * doc)
+Parameter::get_float (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node)
{
ParamFloat * floatpntr;
floatpntr = dynamic_cast<ParamFloat *>(this);
if (floatpntr == NULL)
throw Extension::param_wrong_type();
- return floatpntr->get(doc);
+ return floatpntr->get(doc, node);
}
/** \brief Wrapper to cast to the object and use it's function. */
const gchar *
-Parameter::get_string (const Inkscape::XML::Document * doc)
+Parameter::get_string (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node)
{
ParamString * stringpntr;
stringpntr = dynamic_cast<ParamString *>(this);
if (stringpntr == NULL)
throw Extension::param_wrong_type();
- return stringpntr->get(doc);
+ return stringpntr->get(doc, node);
}
/** \brief Wrapper to cast to the object and use it's function. */
bool
-Parameter::set_bool (bool in, Inkscape::XML::Document * doc)
+Parameter::set_bool (bool in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node)
{
ParamBool * boolpntr;
boolpntr = dynamic_cast<ParamBool *>(this);
if (boolpntr == NULL)
throw Extension::param_wrong_type();
- return boolpntr->set(in, doc);
+ return boolpntr->set(in, doc, node);
}
/** \brief Wrapper to cast to the object and use it's function. */
int
-Parameter::set_int (int in, Inkscape::XML::Document * doc)
+Parameter::set_int (int in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node)
{
ParamInt * intpntr;
intpntr = dynamic_cast<ParamInt *>(this);
if (intpntr == NULL)
throw Extension::param_wrong_type();
- return intpntr->set(in, doc);
+ return intpntr->set(in, doc, node);
}
/** \brief Wrapper to cast to the object and use it's function. */
float
-Parameter::set_float (float in, Inkscape::XML::Document * doc)
+Parameter::set_float (float in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node)
{
ParamFloat * floatpntr;
floatpntr = dynamic_cast<ParamFloat *>(this);
if (floatpntr == NULL)
throw Extension::param_wrong_type();
- return floatpntr->set(in, doc);
+ return floatpntr->set(in, doc, node);
}
/** \brief Wrapper to cast to the object and use it's function. */
const gchar *
-Parameter::set_string (const gchar * in, Inkscape::XML::Document * doc)
+Parameter::set_string (const gchar * in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node)
{
ParamString * stringpntr;
stringpntr = dynamic_cast<ParamString *>(this);
if (stringpntr == NULL)
throw Extension::param_wrong_type();
- return stringpntr->set(in, doc);
+ return stringpntr->set(in, doc, node);
}
/** \brief Initialize the object, to do that, copy the data. */
describing the parameter. */
ParamFloatAdjustment (ParamFloat * param) :
Gtk::Adjustment(0.0, param->min(), param->max(), 0.1), _pref(param) {
- this->set_value(_pref->get(NULL) /* \todo fix */);
+ this->set_value(_pref->get(NULL, NULL) /* \todo fix */);
this->signal_value_changed().connect(sigc::mem_fun(this, &ParamFloatAdjustment::val_changed));
return;
};
ParamFloatAdjustment::val_changed (void)
{
// std::cout << "Value Changed to: " << this->get_value() << std::endl;
- _pref->set(this->get_value(), NULL /* \todo fix */);
+ _pref->set(this->get_value(), NULL /* \todo fix */, NULL);
return;
}
describing the parameter. */
ParamIntAdjustment (ParamInt * param) :
Gtk::Adjustment(0.0, param->min(), param->max(), 1.0), _pref(param) {
- this->set_value(_pref->get(NULL) /* \todo fix */);
+ this->set_value(_pref->get(NULL, NULL) /* \todo fix */);
this->signal_value_changed().connect(sigc::mem_fun(this, &ParamIntAdjustment::val_changed));
return;
};
ParamIntAdjustment::val_changed (void)
{
// std::cout << "Value Changed to: " << this->get_value() << std::endl;
- _pref->set((int)this->get_value(), NULL /* \todo fix */);
+ _pref->set((int)this->get_value(), NULL /* \todo fix */, NULL);
return;
}
*/
ParamBoolCheckButton (ParamBool * param) :
Gtk::CheckButton(), _pref(param) {
- this->set_active(_pref->get(NULL) /**\todo fix */);
+ this->set_active(_pref->get(NULL, NULL) /**\todo fix */);
this->signal_toggled().connect(sigc::mem_fun(this, &ParamBoolCheckButton::on_toggle));
return;
}
void
ParamBoolCheckButton::on_toggle (void)
{
- _pref->set(this->get_active(), NULL /**\todo fix this */);
+ _pref->set(this->get_active(), NULL /**\todo fix this */, NULL);
return;
}
*/
ParamStringEntry (ParamString * pref) :
Gtk::Entry(), _pref(pref) {
- if (_pref->get(NULL) != NULL)
- this->set_text(Glib::ustring(_pref->get(NULL)));
+ if (_pref->get(NULL, NULL) != NULL)
+ this->set_text(Glib::ustring(_pref->get(NULL, NULL)));
this->signal_changed().connect(sigc::mem_fun(this, &ParamStringEntry::changed_text));
};
void changed_text (void);
ParamStringEntry::changed_text (void)
{
Glib::ustring data = this->get_text();
- _pref->set(data.c_str(), NULL);
+ _pref->set(data.c_str(), NULL, NULL);
return;
}