mirror of https://github.com/fltk/fltk
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
This commit is contained in:
parent
43b4048b9c
commit
b338c743b4
|
@ -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 $".
|
||||
//
|
||||
|
|
|
@ -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 $".
|
||||
//
|
||||
|
|
|
@ -55,14 +55,12 @@ if ((f = fl_input(filter_label,
|
|||
code0 {\#include <FL/Fl_File_Browser.H>}
|
||||
class Fl_File_Browser
|
||||
}
|
||||
Fl_Input fileName {
|
||||
Fl_File_Input fileName {
|
||||
label {Filename:}
|
||||
callback {fileNameCB();}
|
||||
private xywh {10 245 355 35} align 5 when 8
|
||||
code0 {fileName->when(FL_WHEN_CHANGED | FL_WHEN_ENTER_KEY_ALWAYS);}
|
||||
code1 {fileName->label(filename_label);}
|
||||
code2 {\#include <FL/Fl_File_Input.H>}
|
||||
class Fl_File_Input
|
||||
}
|
||||
Fl_Return_Button okButton {
|
||||
label OK
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.9 2002/05/01 08:28:59 easysw Exp $"
|
||||
// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.10 2002/05/01 08:51:59 easysw Exp $"
|
||||
//
|
||||
// More Fl_File_Chooser routines.
|
||||
//
|
||||
|
@ -228,7 +228,10 @@ Fl_File_Chooser::value(int f) // I - File number
|
|||
{
|
||||
name = fileName->value();
|
||||
if (name[0] == '\0') return NULL;
|
||||
else return name;
|
||||
else if (fl_filename_isdir(name)) {
|
||||
if (type_ & DIRECTORY) return name;
|
||||
else return NULL;
|
||||
} else return name;
|
||||
}
|
||||
|
||||
for (i = 1, count = 0; i <= fileList->size(); i ++)
|
||||
|
@ -698,5 +701,5 @@ Fl_File_Chooser::fileNameCB()
|
|||
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.9 2002/05/01 08:28:59 easysw Exp $".
|
||||
// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.10 2002/05/01 08:51:59 easysw Exp $".
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue