diff options
| author | Fabien Costantini <fabien@onepost.net> | 2008-09-15 08:41:54 +0000 |
|---|---|---|
| committer | Fabien Costantini <fabien@onepost.net> | 2008-09-15 08:41:54 +0000 |
| commit | b9ca1333769f87c029430a9d14a7a9937d400f93 (patch) | |
| tree | 61b8043afc286a950b7624004ed549f84531fdb3 /src/Fl_Valuator.cxx | |
| parent | fdcfef214e67b0b1162ef4098ba960efd7049523 (diff) | |
Doxygen documentation WP8 Done. Reserved WP9, WP10. Will now check WP3 from engelsman and integrates it.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6250 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Valuator.cxx')
| -rw-r--r-- | src/Fl_Valuator.cxx | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/Fl_Valuator.cxx b/src/Fl_Valuator.cxx index 296951022..faeb4f2b5 100644 --- a/src/Fl_Valuator.cxx +++ b/src/Fl_Valuator.cxx @@ -25,6 +25,12 @@ // http://www.fltk.org/str.php // +/** \fn int Fl_Valuator::changed() const + This value is true if the user has moved the slider. It is + turned off by value(x) and just before doing a callback + (the callback can turn it back on if desired). +*/ + // Base class for sliders and all other one-value "knobs" #include <FL/Fl.H> @@ -34,7 +40,11 @@ #include "flstring.h" Fl_Valuator::Fl_Valuator(int X, int Y, int W, int H, const char* L) - : Fl_Widget(X,Y,W,H,L) { +/** + Creates a new Fl_Valuator widget using the given position, + size, and label string. The default boxtype is FL_NO_BOX. +*/ +: Fl_Widget(X,Y,W,H,L) { align(FL_ALIGN_BOTTOM); when(FL_WHEN_CHANGED); value_ = 0; @@ -47,6 +57,7 @@ Fl_Valuator::Fl_Valuator(int X, int Y, int W, int H, const char* L) const double epsilon = 4.66e-10; +/** See double Fl_Valuator::step() const */ void Fl_Valuator::step(double s) { if (s < 0) s = -s; A = rint(s); @@ -54,13 +65,15 @@ void Fl_Valuator::step(double s) { while (fabs(s-A/B) > epsilon && B<=(0x7fffffff/10)) {B *= 10; A = rint(s*B);} } +/** Sets the step value to 1/10<SUP>digits.*/ void Fl_Valuator::precision(int p) { A = 1.0; for (B = 1; p--;) B *= 10; } - +/** Asks for partial redraw */ void Fl_Valuator::value_damage() {damage(FL_DAMAGE_EXPOSE);} // by default do partial-redraw +/** See double Fl_Valuator::value() const */ int Fl_Valuator::value(double v) { clear_changed(); if (v == value_) return 0; @@ -101,23 +114,53 @@ void Fl_Valuator::handle_release() { } } +/** + Round the passed value to the nearest step increment. Does + nothing if step is zero. +*/ double Fl_Valuator::round(double v) { if (A) return rint(v*B/A)*A/B; else return v; } +/** Clamps the passed value to the valuator range.*/ double Fl_Valuator::clamp(double v) { if ((v<min)==(min<=max)) return min; else if ((v>max)==(min<=max)) return max; else return v; } +/** + Adds n times the step value to the passed value. If + step was set to zero it uses fabs(maximum() - minimum()) / + 100. +*/ double Fl_Valuator::increment(double v, int n) { if (!A) return v+n*(max-min)/100; if (min > max) n = -n; return (rint(v*B/A)+n)*A/B; } +/** + Uses internal rules to format the fields numerical value into + the character array pointed to by the passed parameter.</P> + + <P>The actual format used depends on the current step value. If + the step value has been set to zero then a %g format is used. + If the step value is non-zero, then a %.*f format is used, + where the precision is calculated to show sufficient digits + for the current step value. An integer step value, such as 1 + or 1.0, gives a precision of 0, so the formatted value will + appear as an integer.</P> + + <P>This method is used by the Fl_Value_... group of widgets to + format the current value into a text string. + The return value is the length of the formatted text. + The formatted value is written into in <i>buffer</i>. + <i>buffer</i> should have space for at least 128 bytes.</P> + + <P>You may override this function to create your own text formatting. +*/ int Fl_Valuator::format(char* buffer) { double v = value(); // MRS: THIS IS A HACK - RECOMMEND ADDING BUFFER SIZE ARGUMENT |
