summaryrefslogtreecommitdiff
path: root/fluid
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2002-05-01 08:51:59 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2002-05-01 08:51:59 +0000
commitb338c743b4423976a98860dab4a231e176e76385 (patch)
tree9d22a3452e39cce7ac91a1e386fb077a6beeafc7 /fluid
parent43b4048b9c613e23ce80e2ce9c96cf30334fe931 (diff)
Fix FLUID so that open_cb() and open_history_cb() set the filename
before reading the file so that images are loaded properly. Return NULL if no file is selected in the file chooser. Add Fl_File_Input to FLUID. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2154 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid')
-rw-r--r--fluid/factory.cxx34
-rw-r--r--fluid/fluid.cxx9
2 files changed, 37 insertions, 6 deletions
diff --git a/fluid/factory.cxx b/fluid/factory.cxx
index 320938794..9185d5c04 100644
--- a/fluid/factory.cxx
+++ b/fluid/factory.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: factory.cxx,v 1.4.2.11.2.6 2002/04/11 11:52:41 easysw Exp $"
+// "$Id: factory.cxx,v 1.4.2.11.2.7 2002/05/01 08:51:59 easysw Exp $"
//
// Widget factory code for the Fast Light Tool Kit (FLTK).
//
@@ -356,6 +356,35 @@ int Fl_Input_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
////////////////////////////////////////////////////////////////
+#include <FL/Fl_File_Input.H>
+class Fl_File_Input_Type : public Fl_Widget_Type {
+ Fl_Menu_Item *subtypes() {return 0;}
+ int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
+public:
+ virtual const char *type_name() {return "Fl_File_Input";}
+ Fl_Widget *widget(int x,int y,int w,int h) {
+ Fl_File_Input *myo = new Fl_File_Input(x,y,w,h,"file:");
+ myo->value("/now/is/the/time/for/a/filename.ext");
+ return myo;
+ }
+ Fl_Widget_Type *_make() {return new Fl_File_Input_Type();}
+};
+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;
+ }
+ return 1;
+}
+
+////////////////////////////////////////////////////////////////
+
#include <FL/Fl_Text_Display.H>
class Fl_Text_Display_Type : public Fl_Widget_Type {
int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
@@ -703,6 +732,7 @@ Fl_Menu_Item New_Menu[] = {
{0,0,cb,(void*)&Fl_Value_Output_type},
{0},
{"text",0,0,0,FL_SUBMENU},
+ {0,0,cb,(void*)&Fl_File_Input_type},
{0,0,cb,(void*)&Fl_Input_type},
{0,0,cb,(void*)&Fl_Output_type},
{0,0,cb,(void*)&Fl_Text_Display_type},
@@ -894,5 +924,5 @@ int lookup_symbol(const char *name, int &v, int numberok) {
}
//
-// End of "$Id: factory.cxx,v 1.4.2.11.2.6 2002/04/11 11:52:41 easysw Exp $".
+// End of "$Id: factory.cxx,v 1.4.2.11.2.7 2002/05/01 08:51:59 easysw Exp $".
//
diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx
index c66d07d24..3ab7f0226 100644
--- a/fluid/fluid.cxx
+++ b/fluid/fluid.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fluid.cxx,v 1.15.2.13.2.16 2002/04/30 22:25:18 matthiaswm Exp $"
+// "$Id: fluid.cxx,v 1.15.2.13.2.17 2002/05/01 08:51:59 easysw Exp $"
//
// FLUID main entry for the Fast Light Tool Kit (FLTK).
//
@@ -149,21 +149,22 @@ void open_cb(Fl_Widget *, void *v) {
if (!v && modflag && !fl_ask("Discard changes?")) return;
const char *c;
if (!(c = fl_file_chooser("Open:", "*.f[ld]", filename))) return;
+ if (!v) {set_filename(c);}
if (!read_file(c, v!=0)) {
fl_message("Can't read %s: %s", c, strerror(errno));
return;
}
- if (!v) {set_filename(c); modflag = 0;}
+ if (!v) {modflag = 0;}
else modflag = 1;
}
void open_history_cb(Fl_Widget *, void *v) {
if (modflag && !fl_ask("Discard changes?")) return;
+ set_filename((char *)v);
if (!read_file((char *)v, 0)) {
fl_message("Can't read %s: %s", v, strerror(errno));
return;
}
- set_filename((char *)v);
modflag = 0;
}
@@ -614,5 +615,5 @@ int main(int argc,char **argv) {
}
//
-// End of "$Id: fluid.cxx,v 1.15.2.13.2.16 2002/04/30 22:25:18 matthiaswm Exp $".
+// End of "$Id: fluid.cxx,v 1.15.2.13.2.17 2002/05/01 08:51:59 easysw Exp $".
//