summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-07-19 15:06:18 +0200
committerMatthias Melcher <github@matthiasm.com>2023-07-19 15:06:25 +0200
commitaeedd1831611994bd51640159361af10c1b08264 (patch)
treec5178a5f14d2e5053b9c49b1498054b1e1c38fe9
parent069a6b430b248aace1ec0f1a72099e95f046a68d (diff)
FLUID fixes wrong type IDs and more cleanup
-rw-r--r--fluid/Fl_Menu_Type.cxx8
-rw-r--r--fluid/Fl_Type.h3
-rw-r--r--fluid/Fl_Widget_Type.cxx60
-rw-r--r--fluid/factory.cxx429
-rw-r--r--fluid/file.cxx2
5 files changed, 248 insertions, 254 deletions
diff --git a/fluid/Fl_Menu_Type.cxx b/fluid/Fl_Menu_Type.cxx
index ccd11b71a..37d44148d 100644
--- a/fluid/Fl_Menu_Type.cxx
+++ b/fluid/Fl_Menu_Type.cxx
@@ -697,11 +697,11 @@ void shortcut_in_cb(Fl_Shortcut_Button* i, void* v) {
if (v == LOAD) {
if (current_widget->is_button())
i->value( ((Fl_Button*)(current_widget->o))->shortcut() );
- else if (current_widget->is_input())
+ else if (current_widget->is_a(Fl_Type::ID_Input))
i->value( ((Fl_Input_*)(current_widget->o))->shortcut() );
else if (current_widget->is_a(Fl_Type::ID_Value_Input))
i->value( ((Fl_Value_Input*)(current_widget->o))->shortcut() );
- else if (current_widget->is_text_display())
+ else if (current_widget->is_a(Fl_Type::ID_Text_Display))
i->value( ((Fl_Text_Display*)(current_widget->o))->shortcut() );
else {
i->hide();
@@ -719,7 +719,7 @@ void shortcut_in_cb(Fl_Shortcut_Button* i, void* v) {
if (b->shortcut() != (int)i->value()) mod = 1;
b->shortcut(i->value());
if (o->is_menu_item()) ((Fl_Widget_Type*)o)->redraw();
- } else if (o->selected && o->is_input()) {
+ } else if (o->selected && o->is_a(Fl_Type::ID_Input)) {
Fl_Input_* b = (Fl_Input_*)(((Fl_Widget_Type*)o)->o);
if (b->shortcut() != (int)i->value()) mod = 1;
b->shortcut(i->value());
@@ -727,7 +727,7 @@ void shortcut_in_cb(Fl_Shortcut_Button* i, void* v) {
Fl_Value_Input* b = (Fl_Value_Input*)(((Fl_Widget_Type*)o)->o);
if (b->shortcut() != (int)i->value()) mod = 1;
b->shortcut(i->value());
- } else if (o->selected && o->is_text_display()) {
+ } else if (o->selected && o->is_a(Fl_Type::ID_Text_Display)) {
Fl_Text_Display* b = (Fl_Text_Display*)(((Fl_Widget_Type*)o)->o);
if (b->shortcut() != (int)i->value()) mod = 1;
b->shortcut(i->value());
diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h
index fca1f54d9..bd604eae3 100644
--- a/fluid/Fl_Type.h
+++ b/fluid/Fl_Type.h
@@ -186,9 +186,6 @@ public:
virtual int is_widget() const {return 0;}
/// TODO: Misnamed: This is true if the widget is a button or a menu item with button functionality
virtual int is_button() const {return 0;}
- virtual int is_input() const {return 0;}
- virtual int is_text_display() const {return 0;}
- virtual int is_spinner() const {return 0;}
virtual int is_menu_item() const {return 0;}
virtual int is_menu_button() const {return 0;}
virtual int is_group() const {return 0;}
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx
index 0c8cf9226..a45100563 100644
--- a/fluid/Fl_Widget_Type.cxx
+++ b/fluid/Fl_Widget_Type.cxx
@@ -2040,7 +2040,7 @@ void min_cb(Fl_Value_Input* i, void* v) {
if (current_widget->is_a(Fl_Type::ID_Valuator)) {
i->activate();
i->value(((Fl_Valuator*)(current_widget->o))->minimum());
- } else if (current_widget->is_spinner()) {
+ } else if (current_widget->is_a(Fl_Type::ID_Spinner)) {
i->activate();
i->value(((Fl_Spinner*)(current_widget->o))->minimum());
} else {
@@ -2058,7 +2058,7 @@ void min_cb(Fl_Value_Input* i, void* v) {
((Fl_Valuator*)(q->o))->minimum(n);
q->o->redraw();
mod = 1;
- } else if (q->is_spinner()) {
+ } else if (q->is_a(Fl_Type::ID_Spinner)) {
((Fl_Spinner*)(q->o))->minimum(n);
q->o->redraw();
mod = 1;
@@ -2074,7 +2074,7 @@ void max_cb(Fl_Value_Input* i, void* v) {
if (current_widget->is_a(Fl_Type::ID_Valuator)) {
i->activate();
i->value(((Fl_Valuator*)(current_widget->o))->maximum());
- } else if (current_widget->is_spinner()) {
+ } else if (current_widget->is_a(Fl_Type::ID_Spinner)) {
i->activate();
i->value(((Fl_Spinner*)(current_widget->o))->maximum());
} else {
@@ -2092,7 +2092,7 @@ void max_cb(Fl_Value_Input* i, void* v) {
((Fl_Valuator*)(q->o))->maximum(n);
q->o->redraw();
mod = 1;
- } else if (q->is_spinner()) {
+ } else if (q->is_a(Fl_Type::ID_Spinner)) {
((Fl_Spinner*)(q->o))->maximum(n);
q->o->redraw();
mod = 1;
@@ -2108,7 +2108,7 @@ void step_cb(Fl_Value_Input* i, void* v) {
if (current_widget->is_a(Fl_Type::ID_Valuator)) {
i->activate();
i->value(((Fl_Valuator*)(current_widget->o))->step());
- } else if (current_widget->is_spinner()) {
+ } else if (current_widget->is_a(Fl_Type::ID_Spinner)) {
i->activate();
i->value(((Fl_Spinner*)(current_widget->o))->step());
} else {
@@ -2126,7 +2126,7 @@ void step_cb(Fl_Value_Input* i, void* v) {
((Fl_Valuator*)(q->o))->step(n);
q->o->redraw();
mod = 1;
- } else if (q->is_spinner()) {
+ } else if (q->is_a(Fl_Type::ID_Spinner)) {
((Fl_Spinner*)(q->o))->step(n);
q->o->redraw();
mod = 1;
@@ -2145,7 +2145,7 @@ void value_cb(Fl_Value_Input* i, void* v) {
} else if (current_widget->is_button()) {
i->activate();
i->value(((Fl_Button*)(current_widget->o))->value());
- } else if (current_widget->is_spinner()) {
+ } else if (current_widget->is_a(Fl_Type::ID_Spinner)) {
i->activate();
i->value(((Fl_Spinner*)(current_widget->o))->value());
} else
@@ -2164,7 +2164,7 @@ void value_cb(Fl_Value_Input* i, void* v) {
((Fl_Button*)(q->o))->value(n != 0);
if (q->is_menu_item()) q->redraw();
mod = 1;
- } else if (q->is_spinner()) {
+ } else if (q->is_a(Fl_Type::ID_Spinner)) {
((Fl_Spinner*)(q->o))->value(n);
mod = 1;
}
@@ -2461,7 +2461,7 @@ void subtype_cb(Fl_Choice* i, void* v) {
int j;
for (j = 0;; j++) {
if (!m[j].text) {j = 0; break;}
- if (current_widget->is_spinner()) {
+ if (current_widget->is_a(Fl_Type::ID_Spinner)) {
if (m[j].argument() == ((Fl_Spinner*)current_widget->o)->type()) break;
} else {
if (m[j].argument() == current_widget->o->type()) break;
@@ -2479,7 +2479,7 @@ 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) {
- if (q->is_spinner())
+ if (q->is_a(Fl_Type::ID_Spinner))
((Fl_Spinner*)q->o)->type(n);
else if (q->is_flex())
((Fl_Flex_Type*)q)->change_subtype_to(n);
@@ -3008,7 +3008,7 @@ void Fl_Widget_Type::write_widget_code(Fd_Code_Writer& f) {
f.write_c(");\n");
}
- if (is_spinner() && ((Fl_Spinner*)o)->type() != ((Fl_Spinner*)tplate)->type())
+ if (is_a(Fl_Type::ID_Spinner) && ((Fl_Spinner*)o)->type() != ((Fl_Spinner*)tplate)->type())
f.write_c("%s%s->type(%d);\n", f.indent(), var, ((Fl_Spinner*)o)->type());
else if (o->type() != tplate->type() && !is_window())
f.write_c("%s%s->type(%d);\n", f.indent(), var, o->type());
@@ -3018,9 +3018,9 @@ void Fl_Widget_Type::write_widget_code(Fd_Code_Writer& f) {
// write shortcut command if needed
int shortcut = 0;
if (is_button()) shortcut = ((Fl_Button*)o)->shortcut();
- else if (is_input()) shortcut = ((Fl_Input_*)o)->shortcut();
+ else if (is_a(ID_Input)) shortcut = ((Fl_Input_*)o)->shortcut();
else if (is_a(ID_Value_Input)) shortcut = ((Fl_Value_Input*)o)->shortcut();
- else if (is_text_display()) shortcut = ((Fl_Text_Display*)o)->shortcut();
+ else if (is_a(ID_Text_Display)) shortcut = ((Fl_Text_Display*)o)->shortcut();
if (shortcut) {
if (g_project.use_FL_COMMAND && (shortcut & (FL_CTRL|FL_META))) {
f.write_c("%s%s->shortcut(", f.indent(), var);
@@ -3083,7 +3083,7 @@ void Fl_Widget_Type::write_widget_code(Fd_Code_Writer& f) {
if (x != y) f.write_c("%s%s->slider_size(%g);\n", f.indent(), var, x);
}
}
- if (is_spinner()) {
+ if (is_a(Fl_Type::ID_Spinner)) {
Fl_Spinner* v = (Fl_Spinner*)o;
Fl_Spinner* t = (Fl_Spinner*)(tplate);
if (v->minimum()!=t->minimum())
@@ -3186,7 +3186,7 @@ void Fl_Widget_Type::write_properties(Fd_Project_Writer &f) {
if (bind_deimage_) f.write_string("bind_deimage 1");
f.write_string("xywh {%d %d %d %d}", o->x(), o->y(), o->w(), o->h());
Fl_Widget* tplate = ((Fl_Widget_Type*)factory)->o;
- if (is_spinner() && ((Fl_Spinner*)o)->type() != ((Fl_Spinner*)tplate)->type()) {
+ if (is_a(Fl_Type::ID_Spinner) && ((Fl_Spinner*)o)->type() != ((Fl_Spinner*)tplate)->type()) {
f.write_string("type");
f.write_word(item_name(subtypes(), ((Fl_Spinner*)o)->type()));
} else if (subtypes() && (o->type() != tplate->type() || is_window())) {
@@ -3195,7 +3195,7 @@ void Fl_Widget_Type::write_properties(Fd_Project_Writer &f) {
}
if (o->box() != tplate->box()) {
f.write_string("box"); f.write_word(boxname(o->box()));}
- if (is_input()) {
+ if (is_a(ID_Input)) {
Fl_Input_* b = (Fl_Input_*)o;
if (b->shortcut()) f.write_string("shortcut 0x%x", b->shortcut());
}
@@ -3203,7 +3203,7 @@ void Fl_Widget_Type::write_properties(Fd_Project_Writer &f) {
Fl_Value_Input* b = (Fl_Value_Input*)o;
if (b->shortcut()) f.write_string("shortcut 0x%x", b->shortcut());
}
- if (is_text_display()) {
+ if (is_a(ID_Text_Display)) {
Fl_Text_Display* b = (Fl_Text_Display*)o;
if (b->shortcut()) f.write_string("shortcut 0x%x", b->shortcut());
}
@@ -3253,7 +3253,7 @@ void Fl_Widget_Type::write_properties(Fd_Project_Writer &f) {
if (x != y) f.write_string("slider_size %g", x);
}
}
- if (is_spinner()) {
+ if (is_a(Fl_Type::ID_Spinner)) {
Fl_Spinner* v = (Fl_Spinner*)o;
Fl_Spinner* t = (Fl_Spinner*)(tplate);
if (v->minimum()!=t->minimum()) f.write_string("minimum %g",v->minimum());
@@ -3329,7 +3329,7 @@ void Fl_Widget_Type::read_property(Fd_Project_Reader &f, const char *c) {
} else if (!strcmp(c,"compress_deimage")) {
compress_deimage_ = (int)atol(f.read_word());
} else if (!strcmp(c,"type")) {
- if (is_spinner())
+ if (is_a(ID_Spinner))
((Fl_Spinner*)o)->type(item_number(subtypes(), f.read_word()));
else
o->type(item_number(subtypes(), f.read_word()));
@@ -3399,18 +3399,20 @@ void Fl_Widget_Type::read_property(Fd_Project_Reader &f, const char *c) {
if (sscanf(f.read_word(),"%d",&x) == 1) o->when(x);
} else if (!strcmp(c,"minimum")) {
if (is_a(ID_Valuator)) ((Fl_Valuator*)o)->minimum(strtod(f.read_word(),0));
- if (is_spinner()) ((Fl_Spinner*)o)->minimum(strtod(f.read_word(),0));
+ if (is_a(ID_Spinner)) ((Fl_Spinner*)o)->minimum(strtod(f.read_word(),0));
} else if (!strcmp(c,"maximum")) {
if (is_a(ID_Valuator)) ((Fl_Valuator*)o)->maximum(strtod(f.read_word(),0));
- if (is_spinner()) ((Fl_Spinner*)o)->maximum(strtod(f.read_word(),0));
+ if (is_a(ID_Spinner)) ((Fl_Spinner*)o)->maximum(strtod(f.read_word(),0));
} else if (!strcmp(c,"step")) {
if (is_a(ID_Valuator)) ((Fl_Valuator*)o)->step(strtod(f.read_word(),0));
- if (is_spinner()) ((Fl_Spinner*)o)->step(strtod(f.read_word(),0));
+ if (is_a(ID_Spinner)) ((Fl_Spinner*)o)->step(strtod(f.read_word(),0));
} else if (!strcmp(c,"value")) {
if (is_a(ID_Valuator)) ((Fl_Valuator*)o)->value(strtod(f.read_word(),0));
- if (is_spinner()) ((Fl_Spinner*)o)->value(strtod(f.read_word(),0));
- } else if ((!strcmp(c,"slider_size")||!strcmp(c,"size")) && is_a(ID_Slider)) {
+ if (is_a(ID_Spinner)) ((Fl_Spinner*)o)->value(strtod(f.read_word(),0));
+ } else if ( (!strcmp(c,"slider_size") || !strcmp(c,"size")) && is_a(ID_Slider)) {
((Fl_Slider*)o)->slider_size(strtod(f.read_word(),0));
+ } else if ( (!strcmp(c,"slider_size") || !strcmp(c,"size")) ) {
+ int x = is_a(ID_Slider);
} else if (!strcmp(c,"textfont")) {
if (sscanf(f.read_word(),"%d",&x) == 1) {ft=(Fl_Font)x; textstuff(1,ft,s,cc);}
} else if (!strcmp(c,"textsize")) {
@@ -3430,9 +3432,9 @@ void Fl_Widget_Type::read_property(Fd_Project_Reader &f, const char *c) {
} else if (!strcmp(c,"shortcut")) {
int shortcut = (int)strtol(f.read_word(),0,0);
if (is_button()) ((Fl_Button*)o)->shortcut(shortcut);
- else if (is_input()) ((Fl_Input_*)o)->shortcut(shortcut);
+ else if (is_a(ID_Input)) ((Fl_Input_*)o)->shortcut(shortcut);
else if (is_a(ID_Value_Input)) ((Fl_Value_Input*)o)->shortcut(shortcut);
- else if (is_text_display()) ((Fl_Text_Display*)o)->shortcut(shortcut);
+ else if (is_a(ID_Text_Display)) ((Fl_Text_Display*)o)->shortcut(shortcut);
} else {
if (!strncmp(c,"code",4)) {
int n = atoi(c+4);
@@ -3629,7 +3631,7 @@ void Fl_Widget_Type::copy_properties() {
}
// copy all attributes specific to widgets derived from Fl_Input_
- if (is_input()) {
+ if (is_a(ID_Input)) {
Fl_Input_* d = (Fl_Input_*)live_widget, *s = (Fl_Input_*)o;
d->shortcut(s->shortcut());
d->textfont(ff);
@@ -3647,7 +3649,7 @@ void Fl_Widget_Type::copy_properties() {
}
// copy all attributes specific to widgets derived from Fl_Text_Display
- if (is_text_display()) {
+ if (is_a(ID_Text_Display)) {
Fl_Text_Display* d = (Fl_Text_Display*)live_widget, *s = (Fl_Text_Display*)o;
d->shortcut(s->shortcut());
d->textfont(ff);
@@ -3669,7 +3671,7 @@ void Fl_Widget_Type::copy_properties() {
}
// copy all attributes specific to Fl_Spinner and derived classes
- if (is_spinner()) {
+ if (is_a(ID_Spinner)) {
Fl_Spinner* d = (Fl_Spinner*)live_widget, *s = (Fl_Spinner*)o;
d->minimum(s->minimum());
d->maximum(s->maximum());
diff --git a/fluid/factory.cxx b/fluid/factory.cxx
index 213da40d3..aa75beb76 100644
--- a/fluid/factory.cxx
+++ b/fluid/factory.cxx
@@ -42,11 +42,14 @@
#include <FL/Fl_Counter.H>
#include <FL/Fl_Dial.H>
#include <FL/Fl_File_Browser.H>
+#include <FL/Fl_File_Input.H>
#include <FL/Fl_Flex.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Help_View.H>
+#include <FL/Fl_Input.H>
#include <FL/Fl_Light_Button.H>
#include <FL/Fl_Menu_Item.H>
+#include <FL/Fl_Output.H>
#include <FL/Fl_Pixmap.H>
#include <FL/Fl_Progress.H>
#include <FL/Fl_Return_Button.H>
@@ -54,6 +57,10 @@
#include <FL/Fl_Round_Button.H>
#include <FL/Fl_Roller.H>
#include <FL/Fl_Scrollbar.H>
+#include <FL/Fl_Simple_Terminal.H>
+#include <FL/Fl_Spinner.H>
+#include <FL/Fl_Text_Display.H>
+#include <FL/Fl_Text_Editor.H>
#include <FL/Fl_Tree.H>
#include <FL/Fl_Value_Slider.H>
#include <FL/Fl_Value_Input.H>
@@ -615,7 +622,7 @@ class Fl_Counter_Type : public Fl_Valuator_Type
}
public:
void ideal_size(int &w, int &h) FL_OVERRIDE {
- h = layout->labelsize + 8;
+ h = layout->textsize + 8;
w = layout->labelsize * 4 + 4 * h; // make room for the arrows
Fd_Snap_Action::better_size(w, h);
}
@@ -687,7 +694,7 @@ public:
}
Fl_Widget_Type *_make() FL_OVERRIDE { return new Fl_Dial_Type(); }
ID id() const FL_OVERRIDE { return ID_Dial; }
- bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Adjuster) ? true : super::is_a(inID); }
+ bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Dial) ? true : super::is_a(inID); }
};
static Fl_Dial_Type Fl_Dial_type;
@@ -720,7 +727,7 @@ public:
}
Fl_Widget_Type *_make() FL_OVERRIDE { return new Fl_Roller_Type(); }
ID id() const FL_OVERRIDE { return ID_Roller; }
- bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Adjuster) ? true : super::is_a(inID); }
+ bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Roller) ? true : super::is_a(inID); }
};
static Fl_Roller_Type Fl_Roller_type;
@@ -760,7 +767,7 @@ public:
}
Fl_Widget_Type *_make() FL_OVERRIDE { return new Fl_Slider_Type(); }
ID id() const FL_OVERRIDE { return ID_Slider; }
- bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Adjuster) ? true : super::is_a(inID); }
+ bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Slider) ? true : super::is_a(inID); }
};
static Fl_Slider_Type Fl_Slider_type;
@@ -821,7 +828,7 @@ public:
}
Fl_Widget_Type *_make() FL_OVERRIDE { return new Fl_Value_Slider_Type(); }
ID id() const FL_OVERRIDE { return ID_Value_Slider; }
- bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Adjuster) ? true : super::is_a(inID); }
+ bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Value_Slider) ? true : super::is_a(inID); }
};
static Fl_Value_Slider_Type Fl_Value_Slider_type;
@@ -906,87 +913,56 @@ static Fl_Value_Output_Type Fl_Value_Output_type;
-// ----vv Continue Here vv----
+// ---- Input ---------------------------------------------------------- MARK: -
-// ---- Spinner ----
+// ---- Input ----
-#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 { // FIXME: Fl_Group, *NOT* Fl_Valuator
- Fl_Menu_Item *subtypes() FL_OVERRIDE {return spinner_type_menu;}
- int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) FL_OVERRIDE;
-public:
- void ideal_size(int &w, int &h) FL_OVERRIDE {
- Fl_Spinner *myo = (Fl_Spinner *)o;
- fl_font(myo->textfont(), myo->textsize());
- h = fl_height() + myo->textsize() - 6;
- if (h < 15) h = 15;
- w -= Fl::box_dw(o->box());
- int ww = (int)fl_width('m');
- w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box()) + h / 2;
- if (w < 40) w = 40 ;
- }
- const char *type_name() FL_OVERRIDE {return "Fl_Spinner";}
- const char *alt_type_name() FL_OVERRIDE {return "fltk::Spinner";}
- int is_spinner() const FL_OVERRIDE { return 1; }
- Fl_Widget *widget(int x,int y,int w,int h) FL_OVERRIDE {
- return new Fl_Spinner(x,y,w,h,"spinner:");
- }
- Fl_Widget_Type *_make() FL_OVERRIDE {return new Fl_Spinner_Type();}
- ID id() const FL_OVERRIDE { return ID_Spinner; }
+static Fl_Menu_Item input_type_menu[] = {
+ { "Normal", 0, 0, (void*)FL_NORMAL_INPUT },
+ { "Multiline", 0, 0, (void*)FL_MULTILINE_INPUT },
+ { "Secret", 0, 0, (void*)FL_SECRET_INPUT },
+ { "Int", 0, 0, (void*)FL_INT_INPUT },
+ { "Float", 0, 0, (void*)FL_FLOAT_INPUT },
+ {0}
};
-static Fl_Spinner_Type Fl_Spinner_type;
-int Fl_Spinner_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
- Fl_Spinner *myo = (Fl_Spinner*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
- switch (w) {
- case 4:
- case 0: f = (Fl_Font)myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
- case 1: myo->textfont(f); break;
- case 2: myo->textsize(s); break;
- case 3: myo->textcolor(c); break;
+/**
+ \brief Manage simple text input widgets.
+ The managed class is derived from Fl_Input_, but for simpleicity, deriving from
+ Fl_Widget_Type seems sufficient here.
+ */
+class Fl_Input_Type : public Fl_Widget_Type
+{
+ typedef Fl_Widget_Type super;
+ Fl_Menu_Item *subtypes() FL_OVERRIDE { return input_type_menu; }
+ int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) FL_OVERRIDE {
+ Fl_Input_ *myo = (Fl_Input_*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
+ switch (w) {
+ case 4:
+ case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
+ case 1: myo->textfont(f); break;
+ case 2: myo->textsize(s); break;
+ case 3: myo->textcolor(c); break;
+ }
+ return 1;
}
- return 1;
-}
-
-////////////////////////////////////////////////////////////////
-
-#include <FL/Fl_Input.H>
-static Fl_Menu_Item input_type_menu[] = {
- {"Normal",0,0,(void*)FL_NORMAL_INPUT},
- {"Multiline",0,0,(void*)FL_MULTILINE_INPUT},
- {"Secret",0,0,(void*)FL_SECRET_INPUT},
- {"Int",0,0,(void*)FL_INT_INPUT},
- {"Float",0,0,(void*)FL_FLOAT_INPUT},
- {0}};
-class Fl_Input_Type : public Fl_Widget_Type { // FIXME: Fl_Input_
- Fl_Menu_Item *subtypes() FL_OVERRIDE {return input_type_menu;}
- int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) FL_OVERRIDE;
public:
void ideal_size(int &w, int &h) FL_OVERRIDE {
- Fl_Input *myo = (Fl_Input *)o;
- fl_font(myo->textfont(), myo->textsize());
- h = fl_height() + myo->textsize() - 6;
- w -= Fl::box_dw(o->box());
- int ww = (int)fl_width('m');
- w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
- if (h < 15) h = 15;
- if (w < 15) w = 15;
- }
- const char *type_name() FL_OVERRIDE {return "Fl_Input";}
- const char *alt_type_name() FL_OVERRIDE {return "fltk::Input";}
- int is_input() const FL_OVERRIDE {return 1;}
- Fl_Widget *widget(int x,int y,int w,int h) FL_OVERRIDE {
- Fl_Input *myo = new Fl_Input(x,y,w,h,"input:");
+ h = layout->labelsize + 8;
+ w = layout->labelsize * 6 + 8;
+ Fd_Snap_Action::better_size(w, h);
+ }
+ const char *type_name() FL_OVERRIDE { return "Fl_Input"; }
+ const char *alt_type_name() FL_OVERRIDE { return "fltk::Input"; }
+ Fl_Widget *widget(int x, int y, int w, int h) FL_OVERRIDE {
+ Fl_Input *myo = new Fl_Input(x, y, w, h, "input:");
myo->value("Text Input");
return myo;
}
- Fl_Widget_Type *_make() FL_OVERRIDE {return new Fl_Input_Type();}
+ Fl_Widget_Type *_make() FL_OVERRIDE { return new Fl_Input_Type(); }
ID id() const FL_OVERRIDE { return ID_Input; }
+ bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Input) ? true : super::is_a(inID); }
void copy_properties() FL_OVERRIDE {
Fl_Widget_Type::copy_properties();
Fl_Input_ *d = (Fl_Input_*)live_widget, *s = (Fl_Input_*)o;
@@ -998,151 +974,157 @@ public:
};
static Fl_Input_Type Fl_Input_type;
-int Fl_Input_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
- Fl_Input_ *myo = (Fl_Input_*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
- switch (w) {
- case 4:
- case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
- case 1: myo->textfont(f); break;
- case 2: myo->textsize(s); break;
- case 3: myo->textcolor(c); break;
- }
- return 1;
-}
-////////////////////////////////////////////////////////////////
+// ---- File Input ----
-#include <FL/Fl_File_Input.H>
-class Fl_File_Input_Type : public Fl_Widget_Type { // FIXME: Fl_Input
- Fl_Menu_Item *subtypes() FL_OVERRIDE {return 0;}
- int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) FL_OVERRIDE;
+/**
+ \brief Manage file name input widgets.
+ */
+class Fl_File_Input_Type : public Fl_Input_Type
+{
+ typedef Fl_Input_Type super;
+ Fl_Menu_Item *subtypes() FL_OVERRIDE { return NULL; } // Don't inherit.
public:
void ideal_size(int &w, int &h) FL_OVERRIDE {
- Fl_File_Input *myo = (Fl_File_Input *)o;
- fl_font(myo->textfont(), myo->textsize());
- h = fl_height() + myo->textsize() + 4;
- w -= Fl::box_dw(o->box());
- int ww = (int)fl_width('m');
- w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
- if (h < 20) h = 20;
- if (w < 50) w = 50;
- }
- const char *type_name() FL_OVERRIDE {return "Fl_File_Input";}
- const char *alt_type_name() FL_OVERRIDE {return "fltk::FileInput";}
- int is_input() const FL_OVERRIDE {return 1;}
- Fl_Widget *widget(int x,int y,int w,int h) FL_OVERRIDE {
- Fl_File_Input *myo = new Fl_File_Input(x,y,w,h,"file:");
- myo->value("/now/is/the/time/for/a/filename.ext");
+ h = layout->labelsize + 8 + 10; // Directoy bar is additional 10 pixels high
+ w = layout->labelsize * 10 + 8;
+ Fd_Snap_Action::better_size(w, h);
+ }
+ const char *type_name() FL_OVERRIDE { return "Fl_File_Input"; }
+ const char *alt_type_name() FL_OVERRIDE { return "fltk::FileInput"; }
+ Fl_Widget *widget(int x, int y, int w, int h) FL_OVERRIDE {
+ Fl_File_Input *myo = new Fl_File_Input(x, y, w, h, "file:");
+ myo->value("/usr/include/FL/Fl.H");
return myo;
}
- Fl_Widget_Type *_make() FL_OVERRIDE {return new Fl_File_Input_Type();}
+ Fl_Widget_Type *_make() FL_OVERRIDE { return new Fl_File_Input_Type(); }
ID id() const FL_OVERRIDE { return ID_File_Input; }
+ bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_File_Input) ? true : super::is_a(inID); }
};
+
static Fl_File_Input_Type Fl_File_Input_type;
-int Fl_File_Input_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
- Fl_File_Input *myo = (Fl_File_Input*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
- switch (w) {
- case 4:
- case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
- case 1: myo->textfont(f); break;
- case 2: myo->textsize(s); break;
- case 3: myo->textcolor(c); break;
+
+// ---- Output ----
+
+static Fl_Menu_Item output_type_menu[] = {
+ { "Normal", 0, 0, (void*)FL_NORMAL_OUTPUT },
+ { "Multiline", 0, 0, (void*)FL_MULTILINE_OUTPUT },
+ { 0 }
+};
+
+/**
+ \brief Manage Output widgets, derived from Input.
+ */
+class Fl_Output_Type : public Fl_Input_Type
+{
+ typedef Fl_Input_Type super;
+ Fl_Menu_Item *subtypes() FL_OVERRIDE { return output_type_menu; }
+public:
+ const char *type_name() FL_OVERRIDE { return "Fl_Output"; }
+ const char *alt_type_name() FL_OVERRIDE { return "fltk::Output"; }
+ Fl_Widget *widget(int x, int y, int w, int h) FL_OVERRIDE {
+ Fl_Output *myo = new Fl_Output(x, y, w, h, "output:");
+ myo->value("Text Output");
+ return myo;
}
- return 1;
-}
+ Fl_Widget_Type *_make() FL_OVERRIDE { return new Fl_Output_Type(); }
+ ID id() const FL_OVERRIDE { return ID_Output; }
+ bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Output) ? true : super::is_a(inID); }
+};
-////////////////////////////////////////////////////////////////
+static Fl_Output_Type Fl_Output_type;
-#include <FL/Fl_Text_Display.H>
-class Fl_Text_Display_Type : public Fl_Widget_Type { // FIXME: Fl_Group
- int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) FL_OVERRIDE;
+
+
+// ---- Text Editor ---------------------------------------------------- MARK: -
+
+
+// ---- Text Display ----
+
+/**
+ \brief Manage the Text Display as a base class.
+ Fl_Text_Dissplay is actually derived from Fl_Group, but for FLUID, deriving
+ the type from Widget is better.
+ */
+class Fl_Text_Display_Type : public Fl_Widget_Type
+{
+ typedef Fl_Widget_Type super;
+ int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) FL_OVERRIDE {
+ Fl_Text_Display *myo = (Fl_Text_Display*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
+ switch (w) {
+ case 4:
+ case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
+ case 1: myo->textfont(f); break;
+ case 2: myo->textsize(s); break;
+ case 3: myo->textcolor(c); break;
+ }
+ return 1;
+ }
public:
void ideal_size(int &w, int &h) FL_OVERRIDE {
- Fl_Text_Display *myo = (Fl_Text_Display *)o;
- fl_font(myo->textfont(), myo->textsize());
- h -= Fl::box_dh(o->box());
- w -= Fl::box_dw(o->box());
- int ww = (int)fl_width('m');
- w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
- h = ((h + fl_height() - 1) / fl_height()) * fl_height() + Fl::box_dh(o->box());
- if (h < 30) h = 30;
- if (w < 50) w = 50;
- }
- const char *type_name() FL_OVERRIDE {return "Fl_Text_Display";}
- const char *alt_type_name() FL_OVERRIDE {return "fltk::TextDisplay";}
- int is_text_display() const FL_OVERRIDE {return 1;}
- Fl_Widget *widget(int x,int y,int w,int h) FL_OVERRIDE {
- Fl_Text_Display *myo = new Fl_Text_Display(x,y,w,h);
+ h = layout->textsize * 4 + 8;
+ w = layout->textsize * 10 + 8;
+ Fd_Snap_Action::better_size(w, h);
+ }
+ const char *type_name() FL_OVERRIDE { return "Fl_Text_Display"; }
+ const char *alt_type_name() FL_OVERRIDE { return "fltk::TextDisplay"; }
+ Fl_Widget *widget(int x, int y, int w, int h) FL_OVERRIDE {
+ Fl_Text_Display *myo = new Fl_Text_Display(x, y, w, h);
+ if (!batch_mode) {
+ Fl_Text_Buffer *b = new Fl_Text_Buffer();
+ b->text("Lorem ipsum dolor\nsit amet, consetetur\nsadipscing elitr");
+ myo->buffer(b);
+ }
return myo;
}
- Fl_Widget_Type *_make() FL_OVERRIDE {return new Fl_Text_Display_Type();}
+ Fl_Widget_Type *_make() FL_OVERRIDE { return new Fl_Text_Display_Type(); }
ID id() const FL_OVERRIDE { return ID_Text_Display; }
+ bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Text_Display) ? true : super::is_a(inID); }
};
static Fl_Text_Display_Type Fl_Text_Display_type;
-int Fl_Text_Display_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
- Fl_Text_Display *myo = (Fl_Text_Display*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
- switch (w) {
- case 4:
- case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
- case 1: myo->textfont(f); break;
- case 2: myo->textsize(s); break;
- case 3: myo->textcolor(c); break;
- }
- return 1;
-}
-////////////////////////////////////////////////////////////////
+// ---- Text Editor ----
-#include <FL/Fl_Text_Editor.H>
-class Fl_Text_Editor_Type : public Fl_Widget_Type { // FIXME: Fl_Text_Display
- int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) FL_OVERRIDE;
+/**
+ \brief Manage Text Editors based on Text Display.
+ */
+class Fl_Text_Editor_Type : public Fl_Text_Display_Type
+{
+ typedef Fl_Text_Display_Type super;
public:
- void ideal_size(int &w, int &h) FL_OVERRIDE {
- Fl_Text_Editor *myo = (Fl_Text_Editor *)o;
- fl_font(myo->textfont(), myo->textsize());
- h -= Fl::box_dh(o->box());
- w -= Fl::box_dw(o->box());
- int ww = (int)fl_width('m');
- w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
- h = ((h + fl_height() - 1) / fl_height()) * fl_height() + Fl::box_dh(o->box());
- if (h < 30) h = 30;
- if (w < 50) w = 50;
- }
const char *type_name() FL_OVERRIDE {return "Fl_Text_Editor";}
const char *alt_type_name() FL_OVERRIDE {return "fltk::TextEditor";}
- int is_text_display() const FL_OVERRIDE {return 1;}
- Fl_Widget *widget(int x,int y,int w,int h) FL_OVERRIDE {
- Fl_Text_Editor *myo = new Fl_Text_Editor(x,y,w,h);
+ Fl_Widget *widget(int x, int y, int w, int h) FL_OVERRIDE {
+ Fl_Text_Editor *myo = new Fl_Text_Editor(x, y, w, h);
+ if (!batch_mode) {
+ Fl_Text_Buffer *b = new Fl_Text_Buffer();
+ b->text("Lorem ipsum dolor\nsit amet, consetetur\nsadipscing elitr");
+ myo->buffer(b);
+ }
return myo;
}
- Fl_Widget_Type *_make() FL_OVERRIDE {return new Fl_Text_Editor_Type();}
+ Fl_Widget_Type *_make() FL_OVERRIDE { return new Fl_Text_Editor_Type(); }
ID id() const FL_OVERRIDE { return ID_Text_Editor; }
+ bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Text_Editor) ? true : super::is_a(inID); }
};
+
static Fl_Text_Editor_Type Fl_Text_Editor_type;
-int Fl_Text_Editor_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
- Fl_Text_Editor *myo = (Fl_Text_Editor*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
- switch (w) {
- case 4:
- case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
- case 1: myo->textfont(f); break;
- case 2: myo->textsize(s); break;
- case 3: myo->textcolor(c); break;
- }
- return 1;
-}
-////////////////////////////////////////////////////////////////
+// ---- Simple Terminal ----
-#include <FL/Fl_Simple_Terminal.H>
-class Fl_Simple_Terminal_Type : public Fl_Text_Editor_Type { // FIXME: Fl_Text_Display
+/**
+ \brief Manage a simple terminal widget.
+ */
+class Fl_Simple_Terminal_Type : public Fl_Text_Display_Type
+{
+ typedef Fl_Text_Display_Type super;
public:
- const char *type_name() FL_OVERRIDE {return "Fl_Simple_Terminal";}
- const char *alt_type_name() FL_OVERRIDE {return "fltk::SimpleTerminal";}
- int is_text_display() const FL_OVERRIDE {return 1;}
- Fl_Widget *widget(int x,int y,int w,int h) FL_OVERRIDE {
+ const char *type_name() FL_OVERRIDE { return "Fl_Simple_Terminal"; }
+ const char *alt_type_name() FL_OVERRIDE { return "fltk::SimpleTerminal"; }
+ Fl_Widget *widget(int x, int y, int w, int h) FL_OVERRIDE {
Fl_Widget *myo = 0L;
if (batch_mode) {
// The Fl_Simple_Terminal constructor attaches a buffer which in turn
@@ -1150,59 +1132,72 @@ public:
// superclass Fl_Text_Display to avoid that.
myo = new Fl_Text_Display(x,y,w,h);
} else {
- myo = new Fl_Simple_Terminal(x,y,w,h);
+ Fl_Simple_Terminal *term = new Fl_Simple_Terminal(x, y, w, h);
+ term->text("> ls -als");
+ myo = term;
}
return myo;
}
Fl_Widget_Type *_make() FL_OVERRIDE {return new Fl_Simple_Terminal_Type();}
ID id() const FL_OVERRIDE { return ID_Simple_Terminal; }
+ bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Simple_Terminal) ? true : super::is_a(inID); }
};
-static Fl_Simple_Terminal_Type Fl_Simple_Terminal_type;
-
-
-
-
+static Fl_Simple_Terminal_Type Fl_Simple_Terminal_type;
+// ---- Other ---------------------------------------------------------- MARK: -
+// ---- Spinner ----
-////////////////////////////////////////////////////////////////
+static Fl_Menu_Item spinner_type_menu[] = {
+ { "Integer", 0, 0, (void*)FL_INT_INPUT },
+ { "Float", 0, 0, (void*)FL_FLOAT_INPUT },
+ { 0 }
+};
-#include <FL/Fl_Output.H>
-static Fl_Menu_Item output_type_menu[] = {
- {"Normal",0,0,(void*)FL_NORMAL_OUTPUT},
- {"Multiline",0,0,(void*)FL_MULTILINE_OUTPUT},
- {0}};
-class Fl_Output_Type : public Fl_Input_Type {
- Fl_Menu_Item *subtypes() FL_OVERRIDE {return output_type_menu;}
+/**
+ \brief Manage Spinner widgets.
+ \note Fl_Spinner is derived from Fl_Group, *not* Fl_Valuator as one may expect.
+ For FLUID, this means some special handling and no Group support.
+ */
+class Fl_Spinner_Type : public Fl_Widget_Type
+{
+ typedef Fl_Widget_Type super;
+ Fl_Menu_Item *subtypes() FL_OVERRIDE { return spinner_type_menu; }
+ int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) FL_OVERRIDE {
+ Fl_Spinner *myo = (Fl_Spinner*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
+ switch (w) {
+ case 4:
+ case 0: f = (Fl_Font)myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
+ case 1: myo->textfont(f); break;
+ case 2: myo->textsize(s); break;
+ case 3: myo->textcolor(c); break;
+ }
+ return 1;
+ }
public:
void ideal_size(int &w, int &h) FL_OVERRIDE {
- Fl_Output *myo = (Fl_Output *)o;
- fl_font(myo->textfont(), myo->textsize());
- h = fl_height() + myo->textsize() - 6;
- w -= Fl::box_dw(o->box());
- int ww = (int)fl_width('m');
- w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
- if (h < 15) h = 15;
- if (w < 15) w = 15;
- }
- const char *type_name() FL_OVERRIDE {return "Fl_Output";}
- const char *alt_type_name() FL_OVERRIDE {return "fltk::Output";}
- Fl_Widget *widget(int x,int y,int w,int h) FL_OVERRIDE {
- Fl_Output *myo = new Fl_Output(x,y,w,h,"output:");
- myo->value("Text Output");
- return myo;
+ h = layout->labelsize + 8;
+ w = layout->labelsize * 4 + 8;
+ Fd_Snap_Action::better_size(w, h);
}
- Fl_Widget_Type *_make() FL_OVERRIDE {return new Fl_Output_Type();}
- ID id() const FL_OVERRIDE { return ID_Output; }
+ const char *type_name() FL_OVERRIDE { return "Fl_Spinner"; }
+ const char *alt_type_name() FL_OVERRIDE { return "fltk::Spinner"; }
+ Fl_Widget *widget(int x, int y, int w, int h) FL_OVERRIDE {
+ return new Fl_Spinner(x, y, w, h, "spinner:");
+ }
+ Fl_Widget_Type *_make() FL_OVERRIDE { return new Fl_Spinner_Type(); }
+ ID id() const FL_OVERRIDE { return ID_Spinner; }
+ bool is_a(ID inID) FL_OVERRIDE { return (inID==ID_Spinner) ? true : super::is_a(inID); }
};
-static Fl_Output_Type Fl_Output_type;
+
+static Fl_Spinner_Type Fl_Spinner_type;
-////////////////////////////////////////////////////////////////
+// ---- Type Factory --------------------------------------------------- MARK: -
extern class Fl_Function_Type Fl_Function_type;
extern class Fl_Code_Type Fl_Code_type;
diff --git a/fluid/file.cxx b/fluid/file.cxx
index 3e39d7407..d6faf29c3 100644
--- a/fluid/file.cxx
+++ b/fluid/file.cxx
@@ -443,7 +443,7 @@ int Fd_Project_Reader::read_project(const char *filename, int merge, Strategy st
void Fd_Project_Reader::read_error(const char *format, ...) {
va_list args;
va_start(args, format);
- if (!fin) {
+ if (!fin) { // FIXME: this line suppresses any error messages in interactve mode
char buffer[1024];
vsnprintf(buffer, sizeof(buffer), format, args);
fl_message("%s", buffer);