parameter.cpp revision 3544219f7a0314290353726315a594f92749eb96
/** @file
* @brief 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/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 "bool.h"
#include "color.h"
#include "description.h"
#include "groupheader.h"
#include "enum.h"
#include "float.h"
#include "int.h"
#include "notebook.h"
#include "radiobutton.h"
#include "string.h"
namespace Inkscape {
namespace Extension {
/**
\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;
bool gui_hidden = false;
const char * gui_hide;
const char * gui_tip;
gui_hidden = true;
}
/* else stays false */
}
/* In this case we just don't have enough information */
return NULL;
}
}
}
if (max_length != NULL) {
}
param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamRadioButton::MINIMAL);
} else {
param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamRadioButton::FULL);
}
}
/* 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();
}
/** \brief Wrapper to cast to the object and use it's function. */
{
if (!param) {
throw Extension::param_not_optiongroup_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();
}
gchar const * Parameter::set_optiongroup( gchar const * in, SPDocument * doc, Inkscape::XML::Node * node )
{
if (!param) {
throw Extension::param_not_optiongroup_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, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext) :
extension(ext), _name(NULL), _desc(NULL), _scope(scope), _text(NULL), _gui_hidden(gui_hidden), _gui_tip(NULL)
{
}
// 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;
}
/** \brief All the code in Notebook::get_param to get the notebook content */
{
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:fileencoding=utf-8:textwidth=99 :