float.cpp revision 0f0f026a553fd84ffaaa90a368f87a842ecfcdd5
/*
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
* Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gtkmm/adjustment.h>
#include "ui/widget/spinbutton.h"
#include "extension/extension.h"
#include "preferences.h"
#include "float.h"
namespace Inkscape {
namespace Extension {
/** Use the superclass' allocator and set the \c _value. */
bool gui_hidden,
{
}
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;
}
/**
* A function to set the \c _value.
*
* 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.
*
* @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.
*/
{
}
}
return _value;
}
{
string += startstring;
return;
}
/** A class to make an adjustment that uses Extension params. */
/** The parameter to adjust. */
ParamFloat * _pref;
SPDocument * _doc;
public:
/** 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, 1.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) {
return;
};
void val_changed (void);
}; /* class ParamFloatAdjustment */
/**
* 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;
}
/**
* Creates a Float Adjustment for a float parameter.
*
* Builds a hbox with a label and a float adjustment in it.
*/
Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
if (_gui_hidden) {
return NULL;
}
ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal));
scale->set_draw_value(false);
}
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 0.1, _precision));
}
} /* namespace Extension */
} /* namespace Inkscape */