diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2006-06-22 07:35:39 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2006-06-22 07:35:39 +0000 |
| commit | 05bd3ade18e53762079994c41cbb953994d994c9 (patch) | |
| tree | 897d2d7307a5e3830bced4fe438978a3d937a0ca /fluid | |
| parent | baa92d1d7da42270b6dafe8f6498f439e33394b6 (diff) | |
Added support for floating point Fl_Spinner
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5221 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid')
| -rw-r--r-- | fluid/Fl_Widget_Type.cxx | 30 | ||||
| -rw-r--r-- | fluid/factory.cxx | 6 |
2 files changed, 28 insertions, 8 deletions
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index 893b0f40b..f4f99d2cf 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -32,6 +32,7 @@ #include "alignment_panel.h" #include <FL/fl_message.H> #include <FL/Fl_Slider.H> +#include <FL/Fl_Spinner.H> #include <FL/Fl_Window.H> #include "../src/flstring.h" #include <stdio.h> @@ -1590,7 +1591,11 @@ void subtype_cb(Fl_Choice* i, void* v) { int j; for (j = 0;; j++) { if (!m[j].text) {j = 0; break;} - if (m[j].argument() == current_widget->o->type()) break; + if (current_widget->is_spinner()) { + if (m[j].argument() == ((Fl_Spinner*)current_widget->o)->type()) break; + } else { + if (m[j].argument() == current_widget->o->type()) break; + } } i->value(j); i->activate(); @@ -1603,9 +1608,12 @@ void subtype_cb(Fl_Choice* i, void* v) { if (o->selected && o->is_widget()) { Fl_Widget_Type* q = (Fl_Widget_Type*)o; if (q->subtypes()==m) { - q->o->type(n); - q->redraw(); - mod = 1; + if (q->is_spinner()) + ((Fl_Spinner*)q->o)->type(n); + else + q->o->type(n); + q->redraw(); + mod = 1; } } } @@ -2061,7 +2069,9 @@ void Fl_Widget_Type::write_widget_code() { write_c(");\n"); } - if (o->type() != tplate->type() && !is_window()) + if (is_spinner() && ((Fl_Spinner*)o)->type() != ((Fl_Spinner*)tplate)->type()) + write_c("%so->type(%d);\n", indent(), ((Fl_Spinner*)o)->type()); + else if (o->type() != tplate->type() && !is_window()) write_c("%so->type(%d);\n", indent(), o->type()); if (o->box() != tplate->box() || subclass()) write_c("%so->box(FL_%s);\n", indent(), boxname(o->box())); @@ -2203,7 +2213,10 @@ void Fl_Widget_Type::write_properties() { } write_string("xywh {%d %d %d %d}", o->x(), o->y(), o->w(), o->h()); Fl_Widget* tplate = ((Fl_Widget_Type*)factory)->o; - if (o->type() != tplate->type() || is_window()) { + if (is_spinner() && ((Fl_Spinner*)o)->type() != ((Fl_Spinner*)tplate)->type()) { + write_string("type"); + write_word(item_name(subtypes(), ((Fl_Spinner*)o)->type())); + } else if (o->type() != tplate->type() || is_window()) { write_string("type"); write_word(item_name(subtypes(), o->type())); } @@ -2304,7 +2317,10 @@ void Fl_Widget_Type::read_property(const char *c) { } else if (!strcmp(c,"deimage")) { inactive_name(read_word()); } else if (!strcmp(c,"type")) { - o->type(item_number(subtypes(), read_word())); + if (is_spinner()) + ((Fl_Spinner*)o)->type(item_number(subtypes(), read_word())); + else + o->type(item_number(subtypes(), read_word())); } else if (!strcmp(c,"box")) { const char* value = read_word(); if ((x = boxnumber(value))) { diff --git a/fluid/factory.cxx b/fluid/factory.cxx index 71391e7f1..8b255f6c6 100644 --- a/fluid/factory.cxx +++ b/fluid/factory.cxx @@ -378,8 +378,12 @@ int Fl_Counter_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) { //////////////////////////////////////////////////////////////// #include <FL/Fl_Spinner.H> +static Fl_Menu_Item spinner_type_menu[] = { + {"Integer",0,0,(void*)FL_INT_INPUT}, + {"Float", 0,0,(void*)FL_FLOAT_INPUT}, + {0}}; class Fl_Spinner_Type : public Fl_Widget_Type { - Fl_Menu_Item *subtypes() {return 0;} + Fl_Menu_Item *subtypes() {return spinner_type_menu;} int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c); int pixmapID() { return 47; } public: |
