Change Fl_Spinner to use double values instead of ints.

Update FLUID dependencies.

The # copies spinner was just a bit too small for 100 copies.

Didn't set the menu divider if there were exactly 10 files in the history.

Add documentation for Fl_Spinner.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4186 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2005-03-25 02:39:25 +00:00
parent 60b5a637f3
commit 6d65dcba88
9 changed files with 164 additions and 43 deletions

View File

@ -45,10 +45,10 @@
class Fl_Spinner : public Fl_Group
{
int value_; // Current value
int minimum_; // Minimum value
int maximum_; // Maximum value
int step_; // Amount to add/subtract for up/down
double value_; // Current value
double minimum_; // Minimum value
double maximum_; // Maximum value
double step_; // Amount to add/subtract for up/down
const char *format_; // Format string
Fl_Input input_; // Input field for the value
@ -57,11 +57,11 @@ class Fl_Spinner : public Fl_Group
down_button_; // Down button
static void sb_cb(Fl_Widget *w, Fl_Spinner *sb) {
int v; // New value
double v; // New value
if (w == &(sb->input_)) {
// Something changed in the input field...
v = atoi(sb->input_.value());
v = atof(sb->input_.value());
if (v < sb->minimum_) {
sb->value_ = sb->minimum_;
@ -107,11 +107,11 @@ class Fl_Spinner : public Fl_Group
H / 2 + 2, H / 2, "@-22>") {
end();
value_ = 1;
minimum_ = 1;
maximum_ = 100;
step_ = 1;
format_ = "%d";
value_ = 1.0;
minimum_ = 1.0;
maximum_ = 100.0;
step_ = 1.0;
format_ = "%.0f";
align(FL_ALIGN_LEFT);
@ -127,11 +127,11 @@ class Fl_Spinner : public Fl_Group
const char *format() { return (format_); }
void format(const char *f) { format_ = f; update(); }
int maxinum() const { return (maximum_); }
void maximum(int m) { maximum_ = m; }
int mininum() const { return (minimum_); }
void minimum(int m) { minimum_ = m; }
void range(int a, int b) { minimum_ = a; maximum_ = b; }
double maxinum() const { return (maximum_); }
void maximum(double m) { maximum_ = m; }
double mininum() const { return (minimum_); }
void minimum(double m) { minimum_ = m; }
void range(double a, double b) { minimum_ = a; maximum_ = b; }
void resize(int X, int Y, int W, int H) {
Fl_Group::resize(X,Y,W,H);
@ -140,8 +140,8 @@ class Fl_Spinner : public Fl_Group
down_button_.resize(X + W - H / 2 - 2, Y + H - H / 2,
H / 2 + 2, H / 2);
}
int step() const { return (step_); }
void step(int s) { step_ = s; }
double step() const { return (step_); }
void step(double s) { step_ = s; }
Fl_Color textcolor() const {
return (input_.textcolor());
}
@ -160,8 +160,8 @@ class Fl_Spinner : public Fl_Group
void textsize(uchar s) {
input_.textsize(s);
}
int value() const { return (value_); }
void value(int v) { value_ = v; update(); }
double value() const { return (value_); }
void value(double v) { value_ = v; update(); }
};
#endif // !Fl_Spinner_H

View File

@ -0,0 +1,107 @@
<html>
<body>
<!-- NEW PAGE -->
<h2><a name=Fl_Spinner>class Fl_Spinner</a></h2>
<hr>
<h3>Class Hierarchy</h3>
<ul><pre>
<a href=Fl_Group.html#Fl_Group>Fl_Group</a>
|
+----<b>Fl_Spinner</b>
|
+----<a href=Fl_Input.html#Fl_Input>Fl_Input</a>
<a href=Fl_Repeat_Button.html#Fl_Repeat_Button>Fl_Repeat_Button</a>
</pre></ul>
<h3>Include Files</h3>
<ul><pre>
#include &lt;FL/Fl_Spinner.H&gt;
</pre></ul>
<h3>Description</h3>
<p>The <tt>Fl_Spinner</tt> widget is a combination of the input
widget and repeat buttons. The user can either type into the
input area or use the buttons to change the value.
<h3>Methods</h3>
<ul>
<li><a href='#Fl_Spinner.Fl_Spinner'>Fl_Spinner</a></li>
<li><a href='#Fl_Spinner.~Fl_Spinner'>~Fl_Spinner</a></li>
<li><a href='#Fl_Spinner.format'>format</a></li>
<li><a href='#Fl_Spinner.maximum'>maximum</a></li>
<li><a href='#Fl_Spinner.minimum'>minimum</a></li>
<li><a href='#Fl_Spinner.range'>range</a></li>
<li><a href='#Fl_Spinner.step'>step</a></li>
<li><a href='#Fl_Spinner.textcolor'>textcolor</a></li>
<li><a href='#Fl_Spinner.textfont'>textfont</a></li>
<li><a href='#Fl_Spinner.textsize'>textsize</a></li>
<li><a href='#Fl_Spinner.value'>value</a></li>
</ul>
<h4><a name="Fl_Spinner.Fl_Spinner">Fl_Spinner::Fl_Spinner(int x, int y, int w,
int h, const char *label = 0)</a></h4>
<p>Creates a new <TT>Fl_Spinner</TT> widget using the given position, size,
and label string.
<h4><a name="Fl_Spinner.~Fl_Spinner">virtual Fl_Spinner::~Fl_Spinner()</a></h4>
<p>Destroys the widget and any value associated with it.
<h4><a name='Fl_Spinner.format'>void format(const char *f)<br />
const char *format()</a></h4>
<p>Sets or returns the format string for the value.</p>
<h4><a name='Fl_Spinner.maximum'>void maximum(double m)<br />
double maximum() const</a></h4>
<p>Sets or returns the maximum value of the widget.</p>
<h4><a name='Fl_Spinner.minimum'>void minimum(double m)<br />
double minimum() const</a></h4>
<p>Sets or returns the minimum value of the widget.</p>
<h4><a name='Fl_Spinner.range'>void range(double minval, double maxval)</a></h4>
<p>Sets the minimum and maximum values for the widget.</p>
<h4><a name='Fl_Spinner.step'>void step(double s)<br />
double step() const</a></h4>
<p>Sets or returns the amount to change the value when the user
clicks a button.</p>
<h4><a name='Fl_Spinner.textcolor'>void textcolor(Fl_Color c)<br />
Fl_Color textcolor() const</a></h4>
<p>Sets or returns the color of the text in the input field.</p>
<h4><a name='Fl_Spinner.textfont'>void textfont(uchar f)<br />
uchar textfont() const</a></h4>
<p>Sets or returns the font of the text in the input field.</p>
<h4><a name='Fl_Spinner.textsize'>void textsize(uchar s)<br />
uchar textsize() const</a></h4>
<p>Sets or returns the size of the text in the input field.</p>
<h4><a name="Fl_Spinner.value">void Fl_Spinner::value(double v)<br />
double Fl_Spinner::value() const</a></h4>
<p>Sets or returns the current value of the widget.</p>
</body>
</html>

View File

@ -119,6 +119,7 @@ HTMLFILES = \
Fl_Shared_Image.html \
Fl_Single_Window.html \
Fl_Slider.html \
Fl_Spinner.html \
Fl_Tabs.html \
Fl_Text_Buffer.html \
Fl_Text_Display.html \

View File

@ -76,6 +76,7 @@ Fl_Secret_Input.html
Fl_Select_Browser.html
Fl_Single_Window.html
Fl_Slider.html
Fl_Spinner.html
Fl_Tabs.html
Fl_Text_Buffer.html
Fl_Text_Display.html

View File

@ -79,6 +79,7 @@ description of the <TT>fl_</TT> functions, see
<A HREF="Fl_Shared_Image.html">Fl_Shared_Image</A><BR>
<A HREF="Fl_Single_Window.html">Fl_Single_Window</A><BR>
<A HREF="Fl_Slider.html">Fl_Slider</A><BR>
<A HREF="Fl_Spinner.html">Fl_Spinner</A><BR>
<A HREF="Fl_Tabs.html">Fl_Tabs</A><BR>
<A HREF="Fl_Text_Buffer.html">Fl_Text_Buffer</A><BR>
<A HREF="Fl_Text_Display.html">Fl_Text_Display</A><BR>
@ -165,6 +166,7 @@ description of the <TT>fl_</TT> functions, see
<LI><A HREF="Fl_Input_Choice.html">Fl_Input_Choice</A>
<LI><A HREF="Fl_Pack.html#Fl_Pack">Fl_Pack</A>
<LI><A HREF="Fl_Scroll.html#Fl_Scroll">Fl_Scroll</A>
<LI><A HREF="Fl_Slider.html#Fl_Slider">Fl_Slider</A>
<LI><A HREF="Fl_Tabs.html#Fl_Tabs">Fl_Tabs</A>
<LI><A HREF="Fl_Text_Display.html">Fl_Text_Display</A>
<UL>

View File

@ -909,7 +909,7 @@ void print_cb(Fl_Return_Button *, void *) {
print_progress->show();
// Figure out how many pages we'll have to print...
if (print_collate_button->value()) copies = print_copies->value();
if (print_collate_button->value()) copies = (int)print_copies->value();
else copies = 1;
if (print_pages->value()) {
@ -958,8 +958,8 @@ void print_cb(Fl_Return_Button *, void *) {
// Pipe the output into the lp command...
const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
snprintf(command, sizeof(command), "lp -s -d %s -n %d -t '%s' -o media=%s",
printer, print_collate_button->value() ? 1 : print_copies->value(),
snprintf(command, sizeof(command), "lp -s -d %s -n %.0f -t '%s' -o media=%s",
printer, print_collate_button->value() ? 1.0 : print_copies->value(),
basename, print_page_size->text(print_page_size->value()));
outfile = popen(command, "w");
} else {
@ -1483,7 +1483,8 @@ void load_history() {
fl_filename_relative(relative_history[i], sizeof(relative_history[i]),
absolute_history[i]);
Main_Menu[i + HISTORY_ITEM].flags = 0;
if (i == 9) Main_Menu[i + HISTORY_ITEM].flags = FL_MENU_DIVIDER;
else Main_Menu[i + HISTORY_ITEM].flags = 0;
} else break;
}
@ -1531,8 +1532,10 @@ void update_history(const char *flname) {
// Update the menu items as needed...
for (i = 0; i < max_files; i ++) {
fluid_prefs.set( Fl_Preferences::Name("file%d", i), absolute_history[i]);
if (absolute_history[i][0]) Main_Menu[i + HISTORY_ITEM].flags = 0;
else break;
if (absolute_history[i][0]) {
if (i == 9) Main_Menu[i + HISTORY_ITEM].flags = FL_MENU_DIVIDER;
else Main_Menu[i + HISTORY_ITEM].flags = 0;
} else break;
}
for (; i < 10; i ++) {

View File

@ -56,7 +56,8 @@ Fl_Menu_Type.o: ../FL/Fl_Double_Window.H ../FL/Fl_Window.H
Fl_Menu_Type.o: ../FL/Fl_Preferences.H ../FL/Fl_Tooltip.H ../FL/Fl_Button.H
Fl_Menu_Type.o: ../FL/Fl_Box.H ../FL/Fl_Light_Button.H
Fl_Menu_Type.o: ../FL/Fl_Check_Button.H ../FL/Fl_Light_Button.H
Fl_Menu_Type.o: ../FL/Fl_Button.H ../FL/Fl_Return_Button.H ../FL/fl_message.H
Fl_Menu_Type.o: ../FL/Fl_Button.H ../FL/Fl_Spinner.H ../FL/Fl_Repeat_Button.H
Fl_Menu_Type.o: ../FL/Fl.H ../FL/Fl_Return_Button.H ../FL/fl_message.H
Fl_Menu_Type.o: ../FL/fl_ask.H ../src/flstring.h ../FL/Fl_Export.H
Fl_Menu_Type.o: ../config.h ../FL/Fl_Output.H ../FL/Fl_Input.H
Fl_Menu_Type.o: Shortcut_Button.h
@ -108,12 +109,14 @@ Fl_Widget_Type.o: ../FL/Fl_Double_Window.H ../FL/Fl_Window.H
Fl_Widget_Type.o: ../FL/Fl_Preferences.H ../FL/Fl_Tooltip.H ../FL/Fl_Button.H
Fl_Widget_Type.o: ../FL/Fl_Box.H ../FL/Fl_Light_Button.H
Fl_Widget_Type.o: ../FL/Fl_Check_Button.H ../FL/Fl_Light_Button.H
Fl_Widget_Type.o: ../FL/Fl_Button.H ../FL/Fl_Return_Button.H
Fl_Widget_Type.o: ../FL/fl_message.H ../FL/fl_ask.H ../FL/Fl_Slider.H
Fl_Widget_Type.o: ../src/flstring.h ../FL/Fl_Export.H ../config.h
Fl_Widget_Type.o: widget_panel.h ../FL/Fl_Value_Input.H ../FL/Fl_Input.H
Fl_Widget_Type.o: Shortcut_Button.h CodeEditor.h ../FL/Fl_Text_Editor.H
Fl_Widget_Type.o: ../FL/Fl_Text_Display.H ../FL/fl_show_colormap.H
Fl_Widget_Type.o: ../FL/Fl_Button.H ../FL/Fl_Spinner.H
Fl_Widget_Type.o: ../FL/Fl_Repeat_Button.H ../FL/Fl.H
Fl_Widget_Type.o: ../FL/Fl_Return_Button.H ../FL/fl_message.H ../FL/fl_ask.H
Fl_Widget_Type.o: ../FL/Fl_Slider.H ../src/flstring.h ../FL/Fl_Export.H
Fl_Widget_Type.o: ../config.h widget_panel.h ../FL/Fl_Value_Input.H
Fl_Widget_Type.o: ../FL/Fl_Input.H Shortcut_Button.h CodeEditor.h
Fl_Widget_Type.o: ../FL/Fl_Text_Editor.H ../FL/Fl_Text_Display.H
Fl_Widget_Type.o: ../FL/fl_show_colormap.H
Fl_Window_Type.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
Fl_Window_Type.o: ../FL/Fl_Overlay_Window.H ../FL/Fl_Double_Window.H
Fl_Window_Type.o: ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
@ -133,6 +136,7 @@ Fl_Window_Type.o: ../FL/Fl_Double_Window.H ../FL/Fl_Preferences.H
Fl_Window_Type.o: ../FL/Fl_Tooltip.H ../FL/Fl_Button.H ../FL/Fl_Box.H
Fl_Window_Type.o: ../FL/Fl_Light_Button.H ../FL/Fl_Check_Button.H
Fl_Window_Type.o: ../FL/Fl_Light_Button.H ../FL/Fl_Button.H
Fl_Window_Type.o: ../FL/Fl_Spinner.H ../FL/Fl_Repeat_Button.H ../FL/Fl.H
Fl_Window_Type.o: ../FL/Fl_Return_Button.H widget_panel.h
Fl_Window_Type.o: ../FL/Fl_Value_Input.H ../FL/Fl_Input.H Shortcut_Button.h
Fl_Window_Type.o: CodeEditor.h ../FL/Fl_Text_Editor.H ../FL/Fl_Text_Display.H
@ -182,6 +186,7 @@ alignment_panel.o: ../FL/Fl_Input_.H ../FL/Fl_Light_Button.H
alignment_panel.o: ../FL/Fl_Choice.H ../FL/Fl_Menu_.H ../FL/Fl_Menu_Item.H
alignment_panel.o: ../FL/Fl_Image.H ../FL/Fl_Check_Button.H
alignment_panel.o: ../FL/Fl_Light_Button.H ../FL/Fl_Button.H
alignment_panel.o: ../FL/Fl_Spinner.H ../FL/Fl_Repeat_Button.H ../FL/Fl.H
alignment_panel.o: ../FL/Fl_Return_Button.H
code.o: ../src/flstring.h ../FL/Fl_Export.H ../config.h ../FL/Fl.H
code.o: ../FL/Enumerations.H ../FL/Fl_Export.H Fl_Type.h ../FL/Fl_Widget.H
@ -197,7 +202,8 @@ code.o: ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H ../FL/Fl_Valuator.H
code.o: ../FL/Fl_Text_Buffer.H ../FL/Fl_Double_Window.H ../FL/Fl_Window.H
code.o: ../FL/Fl_Preferences.H ../FL/Fl_Tooltip.H ../FL/Fl_Button.H
code.o: ../FL/Fl_Box.H ../FL/Fl_Light_Button.H ../FL/Fl_Check_Button.H
code.o: ../FL/Fl_Light_Button.H ../FL/Fl_Button.H ../FL/Fl_Return_Button.H
code.o: ../FL/Fl_Light_Button.H ../FL/Fl_Button.H ../FL/Fl_Spinner.H
code.o: ../FL/Fl_Repeat_Button.H ../FL/Fl.H ../FL/Fl_Return_Button.H
code.o: ../FL/filename.H
factory.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/Fl_Group.H
factory.o: ../FL/Fl_Menu_Item.H ../FL/Fl_Widget.H ../FL/Fl_Image.H
@ -236,6 +242,7 @@ file.o: ../FL/Fl_Tabs.H ../FL/Fl_Group.H ../FL/Fl_Box.H ../FL/Fl_Input.H
file.o: ../FL/Fl_Input_.H ../FL/Fl_Light_Button.H ../FL/Fl_Choice.H
file.o: ../FL/Fl_Menu_.H ../FL/Fl_Menu_Item.H ../FL/Fl_Image.H
file.o: ../FL/Fl_Check_Button.H ../FL/Fl_Light_Button.H ../FL/Fl_Button.H
file.o: ../FL/Fl_Spinner.H ../FL/Fl_Repeat_Button.H ../FL/Fl.H
file.o: ../FL/Fl_Return_Button.H ../FL/fl_message.H ../FL/fl_ask.H
file.o: Fl_Widget_Type.h Fl_Type.h ../FL/Fl_Menu.H Fluid_Image.h
file.o: ../FL/Fl_Shared_Image.H ../FL/fl_draw.H ../FL/Fl_Pack.H
@ -259,11 +266,11 @@ fluid.o: ../FL/Fl_Return_Button.H ../FL/fl_message.H ../FL/fl_ask.H
fluid.o: ../FL/filename.H ../src/flstring.h ../FL/Fl_Export.H ../config.h
fluid.o: alignment_panel.h ../FL/Fl_Text_Buffer.H ../FL/Fl_Text_Display.H
fluid.o: ../FL/Fl_Text_Buffer.H ../FL/Fl_Tooltip.H ../FL/Fl_Widget.H
fluid.o: ../FL/Fl_Tabs.H ../FL/Fl_Light_Button.H function_panel.h
fluid.o: ../FL/Fl_Window.H CodeEditor.h ../FL/Fl_Text_Editor.H
fluid.o: ../FL/Fl_Text_Display.H template_panel.h ../FL/Fl_Browser.H
fluid.o: print_panel.h ../FL/Fl_Round_Button.H ../FL/Fl_Spinner.H
fluid.o: ../FL/Fl_Repeat_Button.H ../FL/Fl_Progress.H about_panel.h undo.h
fluid.o: ../FL/Fl_Tabs.H ../FL/Fl_Light_Button.H ../FL/Fl_Spinner.H
fluid.o: ../FL/Fl_Repeat_Button.H function_panel.h ../FL/Fl_Window.H
fluid.o: CodeEditor.h ../FL/Fl_Text_Editor.H ../FL/Fl_Text_Display.H
fluid.o: template_panel.h ../FL/Fl_Browser.H print_panel.h
fluid.o: ../FL/Fl_Round_Button.H ../FL/Fl_Progress.H about_panel.h undo.h
fluid.o: Fl_Type.h ../FL/Fl_Menu.H Fluid_Image.h ../FL/Fl_Shared_Image.H
fluid.o: ../FL/Fl_Pack.H ../FL/Fl_Wizard.H ../FL/Fl_Menu_.H
fluid.o: ../FL/Fl_Input_Choice.H

View File

@ -296,7 +296,7 @@ Fl_Double_Window* make_print_panel() {
o->box(FL_THIN_DOWN_BOX);
o->labelfont(1);
o->align(FL_ALIGN_TOP_LEFT);
{ Fl_Spinner* o = print_copies = new Fl_Spinner(326, 96, 40, 25, "# Copies:");
{ Fl_Spinner* o = print_copies = new Fl_Spinner(321, 96, 45, 25, "# Copies:");
o->callback((Fl_Callback*)cb_print_copies);
o->when(FL_WHEN_CHANGED);
}

View File

@ -109,8 +109,8 @@ print_to->deactivate();}
print_collate_button->activate();
print_collate_group[0]->activate();
print_collate_group[1]->activate();
}}
xywh {326 96 40 25} when 1
}} selected
xywh {321 96 45 25} when 1
}
Fl_Check_Button print_collate_button {
label Collate
@ -277,7 +277,7 @@ print_update_status();}
}
Fl_Button {} {
label Use
callback {print_properties_panel->hide();} selected
callback {print_properties_panel->hide();}
xywh {60 95 53 25}
}
}