paramfloat.cpp revision 282963165a505f1e709cf741fb2825b6a78cdd6c
/*
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gtkmm/adjustment.h>
#include <gtkmm/spinbutton.h>
#include "extension.h"
#include "paramfloat.h"
namespace Inkscape {
namespace Extension {
/** \brief Use the superclass' allocator and set the \c _value */
ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
{
const char * defaultval = NULL;
if (defaultval != NULL) {
}
_precision = 1;
/* We're handling this by just killing both values */
_max = 10.0;
_min = 0.0;
}
// std::cout << "New Float:: value: " << _value << " max: " << _max << " min: " << _min << std::endl;
return;
}
/** \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
{
return _value;
}
/** \brief Return the value as a string */
ParamFloat::string (void)
{
return mystring;
}
/** \brief A class to make an adjustment that uses Extension params */
/** The parameter to adjust */
ParamFloat * _pref;
SPDocument * _doc;
public:
/** \brief Make the adjustment using an extension and the string
describing the parameter. */
ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
Gtk::Adjustment(0.0, param->min(), param->max(), 0.1), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) {
return;
};
void val_changed (void);
}; /* class ParamFloatAdjustment */
/** \brief A function to respond to the value_changed signal from the
adjustment.
This function just grabs the value from the adjustment and writes
it to the parameter. Very simple, but yet beautiful.
*/
void
ParamFloatAdjustment::val_changed (void)
{
//std::cout << "Value Changed to: " << this->get_value() << std::endl;
if (_changeSignal != NULL) {
_changeSignal->emit();
}
return;
}
/**
\brief Creates a Float Adjustment for a float parameter
Builds a hbox with a label and a float adjustment in it.
*/
ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal));
}
} /* namespace Extension */
} /* namespace Inkscape */