parameter.cpp revision f61e22edfbabba7d9ffdfb87c7661a372989e858
/** \file
* Parameters for extensions.
*/
/*
* Author:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl>
*
* Copyright (C) 2005-2007 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef linux // does the dollar sign need escaping when passed as string parameter?
# define ESCAPE_DOLLAR_COMMANDLINE
#endif
#include <gtkmm/adjustment.h>
#include <gtkmm/spinbutton.h>
#include "extension.h"
#include "document-private.h"
#include "sp-object.h"
#include "color.h"
#include "widgets/sp-color-selector.h"
#include "widgets/sp-color-notebook.h"
#include "parameter.h"
#include "parambool.h"
#include "paramcolor.h"
#include "paramdescription.h"
#include "paramenum.h"
#include "paramfloat.h"
#include "paramint.h"
#include "paramnotebook.h"
#include "paramradiobutton.h"
#include "paramstring.h"
namespace Inkscape {
namespace Extension {
private:
class Choice {
public:
return;
};
~Choice (void) {
};
}; /* class Choice */
/** \brief Internal value. This should point to a string that has
been allocated in memory. And should be free'd. */
public:
ParamEnum(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
~ParamEnum(void);
/** \brief Returns \c _value, with a \i const to protect it. */
const gchar * get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _current_choice != NULL ? _current_choice->_value : NULL; }
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
}; /* class ParamEnum */
/**
\return None
\brief This function creates a parameter that can be used later. This
is typically done in the creation of the extension and defined
in the XML file describing the extension (it's private so people
have to use the system) :)
\param in_repr The XML describing the parameter
This function first grabs all of the data out of the Repr and puts
it into local variables. Actually, these are just pointers, and the
data is not duplicated so we need to be careful with it. If there
isn't a name or a type in the XML, then no parameter is created as
the function just returns.
From this point on, we're pretty committed as we've allocated an
object and we're starting to fill it. The name is set first, and
is created with a strdup to actually allocate memory for it. Then
there is a case statement (roughly because strcmp requires 'ifs')
based on what type of parameter this is. Depending which type it
is, the value is interpreted differently, but they are relatively
straight forward. In all cases the value is set to the default
value from the XML and the type is set to the interpreted type.
*/
{
const char * name;
const char * type;
const char * guitext;
const char * desc;
const char * scope_str;
/* In this case we just don't have enough information */
return NULL;
}
}
}
}
/* Note: param could equal NULL */
return param;
}
/** \brief Wrapper to cast to the object and use it's function. */
bool
{
throw Extension::param_not_bool_param();
}
/** \brief Wrapper to cast to the object and use it's function. */
int
{
throw Extension::param_not_int_param();
}
/** \brief Wrapper to cast to the object and use it's function. */
float
{
throw Extension::param_not_float_param();
}
/** \brief Wrapper to cast to the object and use it's function. */
const gchar *
{
if (stringpntr == NULL)
throw Extension::param_not_string_param();
}
/** \brief Wrapper to cast to the object and use it's function. */
const gchar *
{
throw Extension::param_not_enum_param();
}
{
throw Extension::param_not_color_param();
}
/** \brief Wrapper to cast to the object and use it's function. */
bool
{
throw Extension::param_not_bool_param();
}
/** \brief Wrapper to cast to the object and use it's function. */
int
{
throw Extension::param_not_int_param();
}
/** \brief Wrapper to cast to the object and use it's function. */
float
{
floatpntr = dynamic_cast<ParamFloat *>(this);
throw Extension::param_not_float_param();
}
/** \brief Wrapper to cast to the object and use it's function. */
const gchar *
{
if (stringpntr == NULL)
throw Extension::param_not_string_param();
}
/** \brief Wrapper to cast to the object and use it's function. */
{
throw Extension::param_not_color_param();
}
/** \brief Oop, now that we need a parameter, we need it's name. */
Parameter::Parameter (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext) :
{
// printf("Adding description: '%s' on '%s'\n", _desc, _name);
}
else
return;
}
/** \brief Just free the allocated name. */
{
}
/** \brief Build the name to write the parameter from the extension's
ID and the name of this parameter. */
gchar *
{
}
{
}
{
return retval;
}
{
break;
}
}
}
return params;
}
/** \brief Basically, if there is no widget pass a NULL. */
Parameter::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/)
{
return NULL;
}
/** \brief If I'm not sure which it is, just don't return a value. */
void
{
return;
}
void
{
if (value == "") {
return;
}
final += "--";
final += "=";
return;
}
ParamEnum::ParamEnum (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * /*xml*/) :
{
return;
}
{
}
/** \brief Return the value as a string */
{
return mystring;
}
ParamEnum::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/)
{
return NULL;
}
const gchar *
{
return NULL;
}
} /* namespace Extension */
} /* namespace Inkscape */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :