From f5fe60fdb44fc4a99d97f8ff19d1f62a530cf895 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 17 Mar 2010 17:41:44 -0700 Subject: [PATCH] Added wrappers for the "optiongroup" type that correspond to existing "float", "enum" etc. wrappers. --- src/extension/extension.cpp | 15 +++++++++++++++ src/extension/extension.h | 32 +++++++++++++++++++++++++------ src/extension/param/parameter.cpp | 21 ++++++++++++++++++++ src/extension/param/parameter.h | 4 ++++ 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index b36d2e3a1..b4cf06bda 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -440,6 +440,14 @@ Extension::get_param_enum (const gchar * name, const SPDocument * doc, const Ink return param->get_enum(doc, node); } + +gchar const *Extension::get_param_optiongroup( gchar const * name, SPDocument const * doc, Inkscape::XML::Node const * node) +{ + Parameter* param = param_shared(name, parameters); + return param->get_optiongroup(doc, node); +} + + /** \return The value of the parameter identified by the name \brief Gets a parameter identified by name with the bool placed @@ -597,6 +605,13 @@ Extension::set_param_string (const gchar * name, const gchar * value, SPDocument return param->set_string(value, doc, node); } +gchar const * Extension::set_param_optiongroup(gchar const * name, gchar const * value, SPDocument * doc, Inkscape::XML::Node * node) +{ + Parameter * param = param_shared(name, parameters); + return param->set_optiongroup(value, doc, node); +} + + /** \return The passed in value \brief Sets a parameter identified by name with the string diff --git a/src/extension/extension.h b/src/extension/extension.h index 6210e2eba..c71ae59b4 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -139,8 +139,8 @@ public: g_slist_length(parameters); }; /** \brief A function to get the the number of parameters that are visible to the user that the extension has. - \return The number of visible parameters. - + \return The number of visible parameters. + \note Currently this just calls param_count as visible isn't implemented but in the future it'll do something different. Please call the appropriate function in code so that it'll work in the @@ -153,16 +153,17 @@ public: class param_wrong_type {}; class param_not_color_param {}; class param_not_enum_param {}; + class param_not_optiongroup_param {}; class param_not_string_param {}; class param_not_float_param {}; class param_not_int_param {}; class param_not_bool_param {}; - - /** An error class for when a parameter is looked for that just + + /** An error class for when a parameter is looked for that just * simply doesn't exist */ class param_not_exist {}; - - /** An error class for when a filename already exists, but the user + + /** An error class for when a filename already exists, but the user * doesn't want to overwrite it */ class no_overwrite {}; @@ -176,37 +177,56 @@ public: bool get_param_bool (const gchar * name, const SPDocument * doc = NULL, const Inkscape::XML::Node * node = NULL); + int get_param_int (const gchar * name, const SPDocument * doc = NULL, const Inkscape::XML::Node * node = NULL); + float get_param_float (const gchar * name, const SPDocument * doc = NULL, const Inkscape::XML::Node * node = NULL); + const gchar * get_param_string (const gchar * name, const SPDocument * doc = NULL, const Inkscape::XML::Node * node = NULL); + guint32 get_param_color (const gchar * name, const SPDocument * doc = NULL, const Inkscape::XML::Node * node = NULL); + const gchar * get_param_enum (const gchar * name, const SPDocument * doc = NULL, const Inkscape::XML::Node * node = NULL); + + gchar const *get_param_optiongroup( gchar const * name, + SPDocument const * doc = 0, + Inkscape::XML::Node const * node = 0); + bool set_param_bool (const gchar * name, bool value, SPDocument * doc = NULL, Inkscape::XML::Node * node = NULL); + int set_param_int (const gchar * name, int value, SPDocument * doc = NULL, Inkscape::XML::Node * node = NULL); + float set_param_float (const gchar * name, float value, SPDocument * doc = NULL, Inkscape::XML::Node * node = NULL); + const gchar * set_param_string (const gchar * name, const gchar * value, SPDocument * doc = NULL, Inkscape::XML::Node * node = NULL); + + gchar const * set_param_optiongroup(gchar const * name, + gchar const * value, + SPDocument * doc = 0, + Inkscape::XML::Node * node = 0); + guint32 set_param_color (const gchar * name, guint32 color, SPDocument * doc = NULL, diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 2773af61d..3320cddca 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -204,6 +204,16 @@ Parameter::get_enum (const SPDocument * doc, const Inkscape::XML::Node * node) return param->get(doc, node); } +/** \brief Wrapper to cast to the object and use it's function. */ +gchar const *Parameter::get_optiongroup(SPDocument const * doc, Inkscape::XML::Node const * node) +{ + ParamRadioButton * param = dynamic_cast(this); + if (!param) { + throw Extension::param_not_optiongroup_param(); + } + return param->get(doc, node); +} + guint32 Parameter::get_color(const SPDocument* doc, const Inkscape::XML::Node* node) { @@ -253,6 +263,17 @@ Parameter::set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * throw Extension::param_not_string_param(); return stringpntr->set(in, doc, node); } + +gchar const * Parameter::set_optiongroup( gchar const * in, SPDocument * doc, Inkscape::XML::Node * node ) +{ + ParamRadioButton *param = dynamic_cast(this); + if (!param) { + throw Extension::param_not_optiongroup_param(); + } + return param->set(in, doc, node); +} + + /** \brief Wrapper to cast to the object and use it's function. */ guint32 Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h index 54249c12e..c62dad9cc 100644 --- a/src/extension/param/parameter.h +++ b/src/extension/param/parameter.h @@ -98,9 +98,13 @@ public: const gchar * get_enum (const SPDocument * doc, const Inkscape::XML::Node * node); + gchar const * get_optiongroup( SPDocument const * doc, + Inkscape::XML::Node const * node); + bool set_bool (bool in, SPDocument * doc, Inkscape::XML::Node * node); int set_int (int in, SPDocument * doc, Inkscape::XML::Node * node); float set_float (float in, SPDocument * doc, Inkscape::XML::Node * node); + gchar const * set_optiongroup(gchar const *in, SPDocument * doc, Inkscape::XML::Node *node); const gchar * set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); guint32 set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node); -- 2.30.2