mirror of
https://github.com/fltk/fltk.git
synced 2026-06-04 23:42:15 +08:00
FileIcon, FileBrowser, FileChooser stuff.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1517 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+4
-2
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Enumerations.H,v 1.18.2.14.2.1 2001/08/01 21:24:48 easysw Exp $"
|
// "$Id: Enumerations.H,v 1.18.2.14.2.2 2001/08/02 16:17:04 easysw Exp $"
|
||||||
//
|
//
|
||||||
// Enumerations for the Fast Light Tool Kit (FLTK).
|
// Enumerations for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@@ -212,6 +212,8 @@ enum Fl_Labeltype { // labeltypes:
|
|||||||
_FL_PIXMAP_LABEL,
|
_FL_PIXMAP_LABEL,
|
||||||
_FL_IMAGE_LABEL,
|
_FL_IMAGE_LABEL,
|
||||||
_FL_MULTI_LABEL,
|
_FL_MULTI_LABEL,
|
||||||
|
_FL_ICON_LABEL,
|
||||||
|
|
||||||
FL_FREE_LABELTYPE
|
FL_FREE_LABELTYPE
|
||||||
};
|
};
|
||||||
extern Fl_Labeltype FL_EXPORT define_FL_SYMBOL_LABEL();
|
extern Fl_Labeltype FL_EXPORT define_FL_SYMBOL_LABEL();
|
||||||
@@ -372,5 +374,5 @@ enum Fl_Damage {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Enumerations.H,v 1.18.2.14.2.1 2001/08/01 21:24:48 easysw Exp $".
|
// End of "$Id: Enumerations.H,v 1.18.2.14.2.2 2001/08/02 16:17:04 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
+13
-20
@@ -1,9 +1,9 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Fl_FileBrowser.H,v 1.4 2000/01/16 07:44:20 robertk Exp $"
|
// "$Id: Fl_FileBrowser.H,v 1.4.2.1 2001/08/02 16:17:04 easysw Exp $"
|
||||||
//
|
//
|
||||||
// Fl_FileBrowser definitions for the Fast Light Tool Kit (FLTK).
|
// FileBrowser definitions.
|
||||||
//
|
//
|
||||||
// Copyright 1997-1999 by Easy Software Products.
|
// Copyright 1999-2001 by Michael Sweet.
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Library General Public
|
// modify it under the terms of the GNU Library General Public
|
||||||
@@ -20,30 +20,31 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Please report all bugs and problems to "fltk-bugs@easysw.com".
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Include necessary header files...
|
// Include necessary header files...
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef _FL_FILEBROWSER_H_
|
#ifndef _Fl_FileBrowser_H_
|
||||||
# define _FL_FILEBROWSER_H_
|
# define _Fl_FileBrowser_H_
|
||||||
|
|
||||||
# include <FL/Fl_Browser.H>
|
# include "Fl_Browser.H"
|
||||||
# include <FL/Fl_FileIcon.H>
|
# include "Fl_FileIcon.H"
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fl_FileBrowser class...
|
// Fl_FileBrowser class...
|
||||||
//
|
//
|
||||||
|
|
||||||
class FL_API Fl_FileBrowser : public Fl_Browser
|
class Fl_FileBrowser : public Fl_Browser
|
||||||
{
|
{
|
||||||
const char *directory_;
|
const char *directory_;
|
||||||
uchar iconsize_;
|
uchar iconsize_;
|
||||||
const char *pattern_;
|
const char *pattern_;
|
||||||
|
|
||||||
|
int full_height() const;
|
||||||
int item_height(void *) const;
|
int item_height(void *) const;
|
||||||
int item_width(void *) const;
|
int item_width(void *) const;
|
||||||
void item_draw(void *, int, int, int, int) const;
|
void item_draw(void *, int, int, int, int) const;
|
||||||
@@ -55,26 +56,18 @@ public:
|
|||||||
uchar iconsize() const { return (iconsize_); };
|
uchar iconsize() const { return (iconsize_); };
|
||||||
void iconsize(uchar s) { iconsize_ = s; redraw(); };
|
void iconsize(uchar s) { iconsize_ = s; redraw(); };
|
||||||
|
|
||||||
void directory(const char *directory) { load(directory); }
|
|
||||||
const char *directory(void) const { return (directory_); }
|
|
||||||
|
|
||||||
void filter(const char *pattern);
|
void filter(const char *pattern);
|
||||||
const char *filter() const { return (pattern_); };
|
const char *filter() const { return (pattern_); };
|
||||||
|
|
||||||
int load(const char *directory);
|
int load(const char *directory);
|
||||||
|
|
||||||
#ifdef FLTK_2
|
|
||||||
unsigned textsize() const { return (Fl_Browser::text_size()); };
|
|
||||||
void textsize(unsigned s) { Fl_Browser::text_size(s); };
|
|
||||||
#else
|
|
||||||
uchar textsize() const { return (Fl_Browser::textsize()); };
|
uchar textsize() const { return (Fl_Browser::textsize()); };
|
||||||
void textsize(uchar s) { Fl_Browser::textsize(s); };
|
void textsize(uchar s) { Fl_Browser::textsize(s); iconsize_ = 3 * s / 2; };
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !_FL_FILEBROWSER_H_
|
#endif // !_Fl_FileBrowser_H_
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_FileBrowser.H,v 1.4 2000/01/16 07:44:20 robertk Exp $".
|
// End of "$Id: Fl_FileBrowser.H,v 1.4.2.1 2001/08/02 16:17:04 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
+28
-28
@@ -1,49 +1,49 @@
|
|||||||
// generated by Fast Light User Interface Designer (fluid) version 2.0000
|
// generated by Fast Light User Interface Designer (fluid) version 1.0100
|
||||||
|
|
||||||
#ifndef Fl_FileChooser_h
|
#ifndef Fl_FileChooser_H
|
||||||
#define Fl_FileChooser_h
|
#define Fl_FileChooser_H
|
||||||
#include <FL/Fl.H>
|
#include <FL/Fl.H>
|
||||||
#include <FL/Fl_Window.H>
|
#include <FL/Fl_Window.H>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <FL/Fl_Choice.H>
|
|
||||||
#include <FL/Fl_Button.H>
|
|
||||||
#include "filename.H"
|
|
||||||
#include <FL/Fl_FileBrowser.H>
|
#include <FL/Fl_FileBrowser.H>
|
||||||
#include <FL/Fl_FileInput.H>
|
#include <FL/Fl_Button.H>
|
||||||
#include <FL/Fl_Return_Button.H>
|
#include <FL/Fl_Return_Button.H>
|
||||||
|
#include <FL/Fl_Input.H>
|
||||||
|
#include <FL/Fl_Choice.H>
|
||||||
|
#include <FL/fl_ask.H>
|
||||||
|
|
||||||
class FL_API Fl_FileChooser {
|
class Fl_FileChooser {
|
||||||
public:
|
public:
|
||||||
enum { SINGLE, MULTI, CREATE };
|
enum { SINGLE, MULTI, CREATE };
|
||||||
Fl_FileChooser(const char *d, const char *p, int t, const char *title);
|
Fl_FileChooser(const char *d, const char *p, int t, const char *title);
|
||||||
Fl_Window *window;
|
|
||||||
private:
|
private:
|
||||||
|
Fl_Window *window;
|
||||||
inline void cb_window_i(Fl_Window*, void*);
|
inline void cb_window_i(Fl_Window*, void*);
|
||||||
static void cb_window(Fl_Window*, void*);
|
static void cb_window(Fl_Window*, void*);
|
||||||
Fl_Choice *dirMenu;
|
Fl_FileBrowser *fileList;
|
||||||
inline void cb_dirMenu_i(Fl_Choice*, void*);
|
inline void cb_fileList_i(Fl_FileBrowser*, void*);
|
||||||
static void cb_dirMenu(Fl_Choice*, void*);
|
static void cb_fileList(Fl_FileBrowser*, void*);
|
||||||
|
inline void cb_Cancel_i(Fl_Button*, void*);
|
||||||
|
static void cb_Cancel(Fl_Button*, void*);
|
||||||
|
Fl_Return_Button *okButton;
|
||||||
|
inline void cb_okButton_i(Fl_Return_Button*, void*);
|
||||||
|
static void cb_okButton(Fl_Return_Button*, void*);
|
||||||
|
Fl_Input *fileName;
|
||||||
|
inline void cb_fileName_i(Fl_Input*, void*);
|
||||||
|
static void cb_fileName(Fl_Input*, void*);
|
||||||
Fl_Button *upButton;
|
Fl_Button *upButton;
|
||||||
inline void cb_upButton_i(Fl_Button*, void*);
|
inline void cb_upButton_i(Fl_Button*, void*);
|
||||||
static void cb_upButton(Fl_Button*, void*);
|
static void cb_upButton(Fl_Button*, void*);
|
||||||
Fl_Button *newButton;
|
Fl_Button *newButton;
|
||||||
inline void cb_newButton_i(Fl_Button*, void*);
|
inline void cb_newButton_i(Fl_Button*, void*);
|
||||||
static void cb_newButton(Fl_Button*, void*);
|
static void cb_newButton(Fl_Button*, void*);
|
||||||
inline void cb__i(Fl_Button*, void*);
|
Fl_Choice *dirMenu;
|
||||||
static void cb_(Fl_Button*, void*);
|
inline void cb_dirMenu_i(Fl_Choice*, void*);
|
||||||
Fl_FileBrowser *fileList;
|
static void cb_dirMenu(Fl_Choice*, void*);
|
||||||
inline void cb_fileList_i(Fl_FileBrowser*, void*);
|
inline void cb_allfiles_i(Fl_Button*, void*);
|
||||||
static void cb_fileList(Fl_FileBrowser*, void*);
|
static void cb_allfiles(Fl_Button*, void*);
|
||||||
Fl_FileInput *fileName;
|
|
||||||
inline void cb_fileName_i(Fl_FileInput*, void*);
|
|
||||||
static void cb_fileName(Fl_FileInput*, void*);
|
|
||||||
Fl_Return_Button *okButton;
|
|
||||||
inline void cb_okButton_i(Fl_Return_Button*, void*);
|
|
||||||
static void cb_okButton(Fl_Return_Button*, void*);
|
|
||||||
inline void cb_Cancel_i(Fl_Button*, void*);
|
|
||||||
static void cb_Cancel(Fl_Button*, void*);
|
|
||||||
char directory_[1024];
|
char directory_[1024];
|
||||||
int type_;
|
int type_;
|
||||||
void fileListCB();
|
void fileListCB();
|
||||||
@@ -56,7 +56,6 @@ public:
|
|||||||
int count();
|
int count();
|
||||||
void directory(const char *d);
|
void directory(const char *d);
|
||||||
char * directory();
|
char * directory();
|
||||||
void exec();
|
|
||||||
void filter(const char *p);
|
void filter(const char *p);
|
||||||
const char * filter();
|
const char * filter();
|
||||||
void hide();
|
void hide();
|
||||||
@@ -65,10 +64,11 @@ public:
|
|||||||
void label(const char *l);
|
void label(const char *l);
|
||||||
const char * label();
|
const char * label();
|
||||||
void rescan();
|
void rescan();
|
||||||
|
void show();
|
||||||
void textcolor(Fl_Color c);
|
void textcolor(Fl_Color c);
|
||||||
Fl_Color textcolor();
|
Fl_Color textcolor();
|
||||||
void textfont(Fl_Font f);
|
void textfont(uchar f);
|
||||||
Fl_Font textfont();
|
uchar textfont();
|
||||||
void textsize(uchar s);
|
void textsize(uchar s);
|
||||||
uchar textsize();
|
uchar textsize();
|
||||||
void type(int t);
|
void type(int t);
|
||||||
|
|||||||
+12
-14
@@ -1,9 +1,9 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Fl_FileIcon.H,v 1.1 2000/01/08 22:14:13 vincent Exp $"
|
// "$Id: Fl_FileIcon.H,v 1.1.2.1 2001/08/02 16:17:04 easysw Exp $"
|
||||||
//
|
//
|
||||||
// Fl_FileIcon definitions for the Fast Light Tool Kit (FLTK).
|
// Fl_FileIcon definitions.
|
||||||
//
|
//
|
||||||
// Copyright 1997-1999 by Easy Software Products.
|
// Copyright 1999-2001 by Michael Sweet.
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Library General Public
|
// modify it under the terms of the GNU Library General Public
|
||||||
@@ -20,24 +20,24 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Please report all bugs and problems to "fltk-bugs@easysw.com".
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Include necessary header files...
|
// Include necessary header files...
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef _FL_FILEICON_H_
|
#ifndef _Fl_Fl_FileIcon_H_
|
||||||
# define _FL_FILEICON_H_
|
# define _Fl_Fl_FileIcon_H_
|
||||||
|
|
||||||
# include <FL/Fl.H>
|
# include "Fl.H"
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fl_FileIcon class...
|
// Fl_FileIcon class...
|
||||||
//
|
//
|
||||||
|
|
||||||
class FL_API Fl_FileIcon //// Icon data
|
class Fl_FileIcon //// Icon data
|
||||||
{
|
{
|
||||||
static Fl_FileIcon *first_; // Pointer to first icon/filetype
|
static Fl_FileIcon *first_; // Pointer to first icon/filetype
|
||||||
Fl_FileIcon *next_; // Pointer to next icon/filetype
|
Fl_FileIcon *next_; // Pointer to next icon/filetype
|
||||||
@@ -56,7 +56,7 @@ class FL_API Fl_FileIcon //// Icon data
|
|||||||
FIFO, // Only named pipes
|
FIFO, // Only named pipes
|
||||||
DEVICE, // Only character and block devices
|
DEVICE, // Only character and block devices
|
||||||
LINK, // Only symbolic links
|
LINK, // Only symbolic links
|
||||||
DIR // Only directories
|
DIRECTORY // Only directories
|
||||||
};
|
};
|
||||||
|
|
||||||
enum // Data opcodes
|
enum // Data opcodes
|
||||||
@@ -84,7 +84,7 @@ class FL_API Fl_FileIcon //// Icon data
|
|||||||
void clear() { num_data_ = 0; }
|
void clear() { num_data_ = 0; }
|
||||||
void draw(int x, int y, int w, int h, Fl_Color ic, int active = 1);
|
void draw(int x, int y, int w, int h, Fl_Color ic, int active = 1);
|
||||||
void label(Fl_Widget *w);
|
void label(Fl_Widget *w);
|
||||||
// static void labeltype(const Fl_Label *o, int x, int y, int w, int h, Fl_Align a);
|
static void labeltype(const Fl_Label *o, int x, int y, int w, int h, Fl_Align a);
|
||||||
void load(const char *f);
|
void load(const char *f);
|
||||||
void load_fti(const char *fti);
|
void load_fti(const char *fti);
|
||||||
void load_xpm(const char *xpm);
|
void load_xpm(const char *xpm);
|
||||||
@@ -98,10 +98,8 @@ class FL_API Fl_FileIcon //// Icon data
|
|||||||
static void load_system_icons(void);
|
static void load_system_icons(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
//#define _FL_ICON_LABEL FL_FREE_LABELTYPE
|
#endif // !_Fl_Fl_FileIcon_H_
|
||||||
|
|
||||||
#endif // !_FL_FILEICON_H_
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_FileIcon.H,v 1.1 2000/01/08 22:14:13 vincent Exp $".
|
// End of "$Id: Fl_FileIcon.H,v 1.1.2.1 2001/08/02 16:17:04 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
+10
-3
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: code.cxx,v 1.9.2.9 2001/01/22 15:13:39 easysw Exp $"
|
// "$Id: code.cxx,v 1.9.2.9.2.1 2001/08/02 16:17:04 easysw Exp $"
|
||||||
//
|
//
|
||||||
// Code output routines for the Fast Light Tool Kit (FLTK).
|
// Code output routines for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@@ -254,6 +254,8 @@ static Fl_Type* write_code(Fl_Type* p) {
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern const char* header_file_name;
|
||||||
|
|
||||||
int write_code(const char *s, const char *t) {
|
int write_code(const char *s, const char *t) {
|
||||||
write_number++;
|
write_number++;
|
||||||
delete id_root; id_root = 0;
|
delete id_root; id_root = 0;
|
||||||
@@ -303,8 +305,13 @@ int write_code(const char *s, const char *t) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (t && include_H_from_C)
|
if (t && include_H_from_C) {
|
||||||
|
if (*header_file_name == '.' && strchr(header_file_name, '/') == NULL) {
|
||||||
write_c("#include \"%s\"\n", filename_name(t));
|
write_c("#include \"%s\"\n", filename_name(t));
|
||||||
|
} else {
|
||||||
|
write_c("#include \"%s\"\n", t);
|
||||||
|
}
|
||||||
|
}
|
||||||
for (Fl_Type* p = Fl_Type::first; p;) {
|
for (Fl_Type* p = Fl_Type::first; p;) {
|
||||||
// write all static data for this & all children first
|
// write all static data for this & all children first
|
||||||
p->write_static();
|
p->write_static();
|
||||||
@@ -405,5 +412,5 @@ void Fl_Type::write_code1() {
|
|||||||
void Fl_Type::write_code2() {}
|
void Fl_Type::write_code2() {}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: code.cxx,v 1.9.2.9 2001/01/22 15:13:39 easysw Exp $".
|
// End of "$Id: code.cxx,v 1.9.2.9.2.1 2001/08/02 16:17:04 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
+5
-5
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: fluid.cxx,v 1.15.2.13 2001/03/15 22:39:56 easysw Exp $"
|
// "$Id: fluid.cxx,v 1.15.2.13.2.1 2001/08/02 16:17:04 easysw Exp $"
|
||||||
//
|
//
|
||||||
// FLUID main entry for the Fast Light Tool Kit (FLTK).
|
// FLUID main entry for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@@ -181,13 +181,13 @@ void write_cb(Fl_Widget *, void *) {
|
|||||||
char hname[1024];
|
char hname[1024];
|
||||||
strcpy(i18n_program, filename_name(filename));
|
strcpy(i18n_program, filename_name(filename));
|
||||||
filename_setext(i18n_program, "");
|
filename_setext(i18n_program, "");
|
||||||
if (*code_file_name == '.') {
|
if (*code_file_name == '.' && strchr(code_file_name, '/') == NULL) {
|
||||||
strcpy(cname,filename_name(filename));
|
strcpy(cname,filename_name(filename));
|
||||||
filename_setext(cname, code_file_name);
|
filename_setext(cname, code_file_name);
|
||||||
} else {
|
} else {
|
||||||
strcpy(cname, code_file_name);
|
strcpy(cname, code_file_name);
|
||||||
}
|
}
|
||||||
if (*header_file_name == '.') {
|
if (*header_file_name == '.' && strchr(header_file_name, '/') == NULL) {
|
||||||
strcpy(hname,filename_name(filename));
|
strcpy(hname,filename_name(filename));
|
||||||
filename_setext(hname, header_file_name);
|
filename_setext(hname, header_file_name);
|
||||||
} else {
|
} else {
|
||||||
@@ -196,7 +196,7 @@ void write_cb(Fl_Widget *, void *) {
|
|||||||
if (!compile_only) goto_source_dir();
|
if (!compile_only) goto_source_dir();
|
||||||
int x = write_code(cname,hname);
|
int x = write_code(cname,hname);
|
||||||
if (!compile_only) leave_source_dir();
|
if (!compile_only) leave_source_dir();
|
||||||
strcat(cname, "/"); strcat(cname,header_file_name);
|
strcat(cname, " and "); strcat(cname,hname);
|
||||||
if (compile_only) {
|
if (compile_only) {
|
||||||
if (!x) {fprintf(stderr,"%s : %s\n",cname,strerror(errno)); exit(1);}
|
if (!x) {fprintf(stderr,"%s : %s\n",cname,strerror(errno)); exit(1);}
|
||||||
} else {
|
} else {
|
||||||
@@ -474,5 +474,5 @@ int main(int argc,char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: fluid.cxx,v 1.15.2.13 2001/03/15 22:39:56 easysw Exp $".
|
// End of "$Id: fluid.cxx,v 1.15.2.13.2.1 2001/08/02 16:17:04 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
+166
-65
@@ -1,9 +1,9 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Fl_FileBrowser.cxx,v 1.13 2001/07/29 22:04:43 spitzak Exp $"
|
// "$Id: Fl_FileBrowser.cxx,v 1.13.2.1 2001/08/02 16:17:04 easysw Exp $"
|
||||||
//
|
//
|
||||||
// Fl_FileBrowser routines for the Fast Light Tool Kit (FLTK).
|
// Fl_FileBrowser routines.
|
||||||
//
|
//
|
||||||
// Copyright 1997-1999 by Easy Software Products.
|
// Copyright 1999-2001 by Michael Sweet.
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Library General Public
|
// modify it under the terms of the GNU Library General Public
|
||||||
@@ -20,33 +20,34 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Please report all bugs and problems to "fltk-bugs@easysw.com".
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||||
//
|
//
|
||||||
// Contents:
|
// Contents:
|
||||||
//
|
//
|
||||||
// Fl_Fl_FileBrowser::item_width() - Return the width of a list item.
|
// Fl_FileBrowser::full_height() - Return the height of the list.
|
||||||
// Fl_Fl_FileBrowser::item_draw() - Draw a list item.
|
// Fl_FileBrowser::item_height() - Return the height of a list item.
|
||||||
// Fl_Fl_FileBrowser::FileBrowser() - Create a FileBrowser widget.
|
// Fl_FileBrowser::item_width() - Return the width of a list item.
|
||||||
// Fl_Fl_FileBrowser::load() - Load a directory into the browser.
|
// Fl_FileBrowser::item_draw() - Draw a list item.
|
||||||
// Fl_Fl_FileBrowser::filter() - Set the filename filter.
|
// Fl_FileBrowser::Fl_FileBrowser() - Create a Fl_FileBrowser widget.
|
||||||
|
// Fl_FileBrowser::load() - Load a directory into the browser.
|
||||||
|
// Fl_FileBrowser::filter() - Set the filename filter.
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Include necessary header files...
|
// Include necessary header files...
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <fltk/Fl_FileBrowser.h>
|
#include <FL/Fl_FileBrowser.H>
|
||||||
#include <fltk/fl_draw.h>
|
#include <FL/fl_draw.H>
|
||||||
#include <fltk/filename.h>
|
#include <FL/filename.H>
|
||||||
#include <fltk/vsnprintf.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <config.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(WIN32)
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
#endif /* _WIN32 */
|
#endif /* WIN32 */
|
||||||
|
|
||||||
#if defined(__EMX__)
|
#if defined(__EMX__)
|
||||||
#define INCL_DOS
|
#define INCL_DOS
|
||||||
@@ -54,6 +55,7 @@
|
|||||||
#include <os2.h>
|
#include <os2.h>
|
||||||
#endif /* __EMX__ */
|
#endif /* __EMX__ */
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// FL_BLINE definition from "Fl_Browser.cxx"...
|
// FL_BLINE definition from "Fl_Browser.cxx"...
|
||||||
//
|
//
|
||||||
@@ -72,6 +74,24 @@ struct FL_BLINE // data is in a linked list of these
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'Fl_FileBrowser::full_height()' - Return the height of the list.
|
||||||
|
//
|
||||||
|
|
||||||
|
int // O - Height in pixels
|
||||||
|
Fl_FileBrowser::full_height() const
|
||||||
|
{
|
||||||
|
int i, // Looping var
|
||||||
|
th; // Total height of list.
|
||||||
|
|
||||||
|
|
||||||
|
for (i = 0, th = 0; i < size(); i ++)
|
||||||
|
th += item_height(find_line(i));
|
||||||
|
|
||||||
|
return (th);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// 'Fl_FileBrowser::item_height()' - Return the height of a list item.
|
// 'Fl_FileBrowser::item_height()' - Return the height of a list item.
|
||||||
//
|
//
|
||||||
@@ -86,7 +106,8 @@ Fl_FileBrowser::item_height(void *p) const // I - List item data
|
|||||||
|
|
||||||
|
|
||||||
// Figure out the standard text height...
|
// Figure out the standard text height...
|
||||||
textheight = fl_height(textfont(), textsize())+leading();
|
fl_font(textfont(), textsize());
|
||||||
|
textheight = fl_height();
|
||||||
|
|
||||||
// We always have at least 1 line...
|
// We always have at least 1 line...
|
||||||
height = textheight;
|
height = textheight;
|
||||||
@@ -118,6 +139,7 @@ Fl_FileBrowser::item_height(void *p) const // I - List item data
|
|||||||
int // O - Width in pixels
|
int // O - Width in pixels
|
||||||
Fl_FileBrowser::item_width(void *p) const // I - List item data
|
Fl_FileBrowser::item_width(void *p) const // I - List item data
|
||||||
{
|
{
|
||||||
|
int i; // Looping var
|
||||||
FL_BLINE *line; // Pointer to line
|
FL_BLINE *line; // Pointer to line
|
||||||
char *text, // Pointer into text
|
char *text, // Pointer into text
|
||||||
*ptr, // Pointer into fragment
|
*ptr, // Pointer into fragment
|
||||||
@@ -125,19 +147,21 @@ Fl_FileBrowser::item_width(void *p) const // I - List item data
|
|||||||
int width, // Width of line
|
int width, // Width of line
|
||||||
tempwidth; // Width of fragment
|
tempwidth; // Width of fragment
|
||||||
int column; // Current column
|
int column; // Current column
|
||||||
|
const int *columns; // Columns
|
||||||
|
|
||||||
|
|
||||||
// Set the font and size...
|
// Set the font and size...
|
||||||
fl_font(text_font(), text_size());
|
fl_font(textfont(), textsize());
|
||||||
|
|
||||||
// Scan for newlines...
|
// Scan for newlines...
|
||||||
line = (FL_BLINE *)p;
|
line = (FL_BLINE *)p;
|
||||||
|
columns = column_widths();
|
||||||
|
|
||||||
if (strchr(line->txt, '\n') == NULL &&
|
if (strchr(line->txt, '\n') == NULL &&
|
||||||
strchr(line->txt, '\t') == NULL)
|
strchr(line->txt, column_char()) == NULL)
|
||||||
{
|
{
|
||||||
// Do a fast width calculation...
|
// Do a fast width calculation...
|
||||||
width = fl_width(line->txt);
|
width = (int)fl_width(line->txt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -152,7 +176,7 @@ Fl_FileBrowser::item_width(void *p) const // I - List item data
|
|||||||
// Newline - nul terminate this fragment and get the width...
|
// Newline - nul terminate this fragment and get the width...
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
|
|
||||||
tempwidth += fl_width(fragment);
|
tempwidth += (int)fl_width(fragment);
|
||||||
|
|
||||||
// Update the max width as needed...
|
// Update the max width as needed...
|
||||||
if (tempwidth > width)
|
if (tempwidth > width)
|
||||||
@@ -161,12 +185,19 @@ Fl_FileBrowser::item_width(void *p) const // I - List item data
|
|||||||
// Point back to the start of the fragment...
|
// Point back to the start of the fragment...
|
||||||
ptr = fragment;
|
ptr = fragment;
|
||||||
tempwidth = 0;
|
tempwidth = 0;
|
||||||
|
column = 0;
|
||||||
}
|
}
|
||||||
else if (*text == '\t')
|
else if (*text == column_char())
|
||||||
{
|
{
|
||||||
// Advance to the next column...
|
// Advance to the next column...
|
||||||
column ++;
|
column ++;
|
||||||
tempwidth = column * fl_width(" ");
|
if (columns)
|
||||||
|
{
|
||||||
|
for (i = 0, tempwidth = 0; i < column && columns[i]; i ++)
|
||||||
|
tempwidth += columns[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tempwidth = column * (int)(fl_height() * 0.6 * 8.0);
|
||||||
|
|
||||||
if (tempwidth > width)
|
if (tempwidth > width)
|
||||||
width = tempwidth;
|
width = tempwidth;
|
||||||
@@ -181,7 +212,7 @@ Fl_FileBrowser::item_width(void *p) const // I - List item data
|
|||||||
// Nul terminate this fragment and get the width...
|
// Nul terminate this fragment and get the width...
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
|
|
||||||
tempwidth += fl_width(fragment);
|
tempwidth += (int)fl_width(fragment);
|
||||||
|
|
||||||
// Update the max width as needed...
|
// Update the max width as needed...
|
||||||
if (tempwidth > width)
|
if (tempwidth > width)
|
||||||
@@ -212,42 +243,117 @@ Fl_FileBrowser::item_draw(void *p, // I - List item data
|
|||||||
int w, // I - Width of item
|
int w, // I - Width of item
|
||||||
int h) const // I - Height of item
|
int h) const // I - Height of item
|
||||||
{
|
{
|
||||||
Fl_Color c; // Color of text
|
int i; // Looping var
|
||||||
FL_BLINE *line; // Pointer to line
|
FL_BLINE *line; // Pointer to line
|
||||||
|
Fl_Color c; // Text color
|
||||||
|
char *text, // Pointer into text
|
||||||
|
*ptr, // Pointer into fragment
|
||||||
|
fragment[10240]; // Fragment of text
|
||||||
|
int width, // Width of line
|
||||||
|
height; // Height of line
|
||||||
|
int column; // Current column
|
||||||
|
const int *columns; // Columns
|
||||||
|
|
||||||
|
|
||||||
puts("Fl_FileBrowser::item_draw()");
|
(void)h;
|
||||||
|
|
||||||
// Draw the list item text...
|
// Draw the list item text...
|
||||||
line = (FL_BLINE *)p;
|
line = (FL_BLINE *)p;
|
||||||
|
|
||||||
fl_font(text_font(), text_size());
|
fl_font(textfont(), textsize());
|
||||||
if (line->flags & SELECTED)
|
|
||||||
c = fl_contrast(text_color(), selection_color());
|
|
||||||
else
|
|
||||||
c = text_color();
|
|
||||||
|
|
||||||
if (active_r())
|
if (line->flags & SELECTED)
|
||||||
fl_color(c);
|
c = contrast(textcolor(), selection_color());
|
||||||
else
|
else
|
||||||
fl_color(fl_inactive(c));
|
c = textcolor();
|
||||||
|
|
||||||
if (Fl_FileIcon::first() == NULL)
|
if (Fl_FileIcon::first() == NULL)
|
||||||
{
|
{
|
||||||
// No icons, just draw the text...
|
// No icons, just draw the text...
|
||||||
fl_draw(line->txt, x + 1, y, w - 2, h, FL_ALIGN_LEFT);
|
x ++;
|
||||||
|
w -= 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Icons; draw the text offset to the right...
|
// Draw the icon if it is set...
|
||||||
fl_draw(line->txt, x + iconsize_ + 9, y, w - iconsize_ - 10, h,
|
|
||||||
FL_ALIGN_LEFT);
|
|
||||||
|
|
||||||
// And then draw the icon if it is set...
|
|
||||||
if (line->data)
|
if (line->data)
|
||||||
((Fl_FileIcon *)line->data)->draw(x, y, iconsize_, iconsize_,
|
((Fl_FileIcon *)line->data)->draw(x, y, iconsize_, iconsize_,
|
||||||
(line->flags & SELECTED) ? FL_YELLOW :
|
(line->flags & SELECTED) ? FL_YELLOW :
|
||||||
FL_LIGHT2,
|
FL_LIGHT2,
|
||||||
active_r());
|
active_r());
|
||||||
|
|
||||||
|
// Draw the text offset to the right...
|
||||||
|
x += iconsize_ + 9;
|
||||||
|
w -= iconsize_ - 10;
|
||||||
|
|
||||||
|
// Center the text vertically...
|
||||||
|
line = (FL_BLINE *)p;
|
||||||
|
height = fl_height();
|
||||||
|
|
||||||
|
for (text = line->txt; *text != '\0'; text ++)
|
||||||
|
if (*text == '\n')
|
||||||
|
height += fl_height();
|
||||||
|
|
||||||
|
if (height < iconsize_)
|
||||||
|
y += (iconsize_ - height) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw the text...
|
||||||
|
line = (FL_BLINE *)p;
|
||||||
|
columns = column_widths();
|
||||||
|
width = 0;
|
||||||
|
column = 0;
|
||||||
|
|
||||||
|
if (active_r())
|
||||||
|
fl_color(c);
|
||||||
|
else
|
||||||
|
fl_color(inactive(c));
|
||||||
|
|
||||||
|
for (text = line->txt, ptr = fragment; *text != '\0'; text ++)
|
||||||
|
if (*text == '\n')
|
||||||
|
{
|
||||||
|
// Newline - nul terminate this fragment and draw it...
|
||||||
|
*ptr = '\0';
|
||||||
|
|
||||||
|
fl_draw(fragment, x + width, y, w - width, fl_height(),
|
||||||
|
(Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP));
|
||||||
|
|
||||||
|
// Point back to the start of the fragment...
|
||||||
|
ptr = fragment;
|
||||||
|
width = 0;
|
||||||
|
y += fl_height();
|
||||||
|
column = 0;
|
||||||
|
}
|
||||||
|
else if (*text == column_char())
|
||||||
|
{
|
||||||
|
// Tab - nul terminate this fragment and draw it...
|
||||||
|
*ptr = '\0';
|
||||||
|
|
||||||
|
fl_draw(fragment, x + width, y, w - width, fl_height(),
|
||||||
|
(Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP));
|
||||||
|
|
||||||
|
// Advance to the next column...
|
||||||
|
column ++;
|
||||||
|
if (columns)
|
||||||
|
{
|
||||||
|
for (i = 0, width = 0; i < column && columns[i]; i ++)
|
||||||
|
width += columns[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
width = column * (int)(fl_height() * 0.6 * 8.0);
|
||||||
|
|
||||||
|
ptr = fragment;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*ptr++ = *text;
|
||||||
|
|
||||||
|
if (ptr > fragment)
|
||||||
|
{
|
||||||
|
// Nul terminate this fragment and draw it...
|
||||||
|
*ptr = '\0';
|
||||||
|
|
||||||
|
fl_draw(fragment, x + width, y, w - width, fl_height(),
|
||||||
|
(Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +372,7 @@ Fl_FileBrowser::Fl_FileBrowser(int x, // I - Upper-lefthand X coordinate
|
|||||||
// Initialize the filter pattern, current directory, and icon size...
|
// Initialize the filter pattern, current directory, and icon size...
|
||||||
pattern_ = "*";
|
pattern_ = "*";
|
||||||
directory_ = "";
|
directory_ = "";
|
||||||
iconsize_ = 20; // This looks best for the default icons, if loaded...
|
iconsize_ = 3 * textsize() / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -283,6 +389,8 @@ Fl_FileBrowser::load(const char *directory)// I - Directory to load
|
|||||||
Fl_FileIcon *icon; // Icon to use
|
Fl_FileIcon *icon; // Icon to use
|
||||||
|
|
||||||
|
|
||||||
|
// printf("Fl_FileBrowser::load(\"%s\")\n", directory);
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
directory_ = directory;
|
directory_ = directory;
|
||||||
|
|
||||||
@@ -294,19 +402,22 @@ Fl_FileBrowser::load(const char *directory)// I - Directory to load
|
|||||||
//
|
//
|
||||||
|
|
||||||
num_files = 0;
|
num_files = 0;
|
||||||
icon = Fl_FileIcon::find("any", Fl_FileIcon::DEVICE);
|
if ((icon = Fl_FileIcon::find("any", Fl_FileIcon::DEVICE)) == NULL)
|
||||||
|
icon = Fl_FileIcon::find("any", Fl_FileIcon::DIRECTORY);
|
||||||
|
|
||||||
if (icon == (Fl_FileIcon *)0)
|
#if defined(WIN32)
|
||||||
icon = Fl_FileIcon::find("any", Fl_FileIcon::DIR);
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
DWORD drives; // Drive available bits
|
DWORD drives; // Drive available bits
|
||||||
|
|
||||||
|
|
||||||
drives = GetLogicalDrives();
|
drives = GetLogicalDrives();
|
||||||
for (i = 'A'; i <= 'Z'; i ++, drives >>= 1)
|
for (i = 'A'; i <= 'Z'; i ++, drives >>= 1)
|
||||||
if (drives & 1)
|
if (drives & 1)
|
||||||
{
|
{
|
||||||
sprintf(filename, "%c:", i);
|
sprintf(filename, "%c:", i);
|
||||||
|
|
||||||
|
if (i < 'C')
|
||||||
|
add(filename, icon);
|
||||||
|
else
|
||||||
add(filename, icon);
|
add(filename, icon);
|
||||||
|
|
||||||
num_files ++;
|
num_files ++;
|
||||||
@@ -331,10 +442,11 @@ Fl_FileBrowser::load(const char *directory)// I - Directory to load
|
|||||||
FILE *mtab; // /etc/mtab or /etc/mnttab file
|
FILE *mtab; // /etc/mtab or /etc/mnttab file
|
||||||
char line[1024]; // Input line
|
char line[1024]; // Input line
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open the file that contains a list of mounted filesystems...
|
// Open the file that contains a list of mounted filesystems...
|
||||||
//
|
//
|
||||||
# if defined(__hpux) || defined(__sun)
|
# if defined(hpux) || defined(__sun)
|
||||||
mtab = fopen("/etc/mnttab", "r"); // Fairly standard
|
mtab = fopen("/etc/mnttab", "r"); // Fairly standard
|
||||||
# elif defined(__sgi) || defined(linux)
|
# elif defined(__sgi) || defined(linux)
|
||||||
mtab = fopen("/etc/mtab", "r"); // More standard
|
mtab = fopen("/etc/mtab", "r"); // More standard
|
||||||
@@ -353,13 +465,14 @@ Fl_FileBrowser::load(const char *directory)// I - Directory to load
|
|||||||
if (sscanf(line, "%*s%4095s", filename) != 1)
|
if (sscanf(line, "%*s%4095s", filename) != 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// printf("Fl_FileBrowser::load() - adding \"%s\" to list...\n", filename);
|
||||||
add(filename, icon);
|
add(filename, icon);
|
||||||
num_files ++;
|
num_files ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(mtab);
|
fclose(mtab);
|
||||||
}
|
}
|
||||||
#endif // _WIN32
|
#endif // WIN32 || __EMX__
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -370,10 +483,9 @@ Fl_FileBrowser::load(const char *directory)// I - Directory to load
|
|||||||
// Build the file list...
|
// Build the file list...
|
||||||
//
|
//
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__EMX__)
|
#if defined(WIN32) || defined(__EMX__)
|
||||||
strncpy(filename, directory_, sizeof(filename) - 1);
|
strncpy(filename, directory_, sizeof(filename) - 1);
|
||||||
filename[sizeof(filename) - 1] = '\0';
|
filename[sizeof(filename) - 1] = '\0';
|
||||||
|
|
||||||
i = strlen(filename) - 1;
|
i = strlen(filename) - 1;
|
||||||
|
|
||||||
if (i == 2 && filename[1] == ':' &&
|
if (i == 2 && filename[1] == ':' &&
|
||||||
@@ -385,30 +497,19 @@ Fl_FileBrowser::load(const char *directory)// I - Directory to load
|
|||||||
num_files = filename_list(filename, &files);
|
num_files = filename_list(filename, &files);
|
||||||
#else
|
#else
|
||||||
num_files = filename_list(directory_, &files);
|
num_files = filename_list(directory_, &files);
|
||||||
#endif /* _WIN32 || __EMX__ */
|
#endif /* WIN32 || __EMX__ */
|
||||||
|
|
||||||
if (num_files <= 0)
|
if (num_files <= 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
// Add directories first...
|
|
||||||
for (i = 0; i < num_files; i ++)
|
|
||||||
if (strcmp(files[i]->d_name, ".") != 0 &&
|
|
||||||
strcmp(files[i]->d_name, "..") != 0)
|
|
||||||
{
|
|
||||||
snprintf(filename, sizeof(filename), "%s/%s", directory_, files[i]->d_name);
|
|
||||||
|
|
||||||
if (filename_isdir(filename))
|
|
||||||
add(files[i]->d_name, Fl_FileIcon::find(filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < num_files; i ++)
|
for (i = 0; i < num_files; i ++)
|
||||||
{
|
{
|
||||||
if (strcmp(files[i]->d_name, ".") != 0 &&
|
if (strcmp(files[i]->d_name, ".") != 0 &&
|
||||||
strcmp(files[i]->d_name, "..") != 0)
|
strcmp(files[i]->d_name, "..") != 0)
|
||||||
{
|
{
|
||||||
snprintf(filename, sizeof(filename), "%s/%s", directory_, files[i]->d_name);
|
sprintf(filename, "%s/%s", directory_, files[i]->d_name);
|
||||||
|
|
||||||
if (!filename_isdir(filename) &&
|
if (filename_isdir(filename) ||
|
||||||
filename_match(files[i]->d_name, pattern_))
|
filename_match(files[i]->d_name, pattern_))
|
||||||
add(files[i]->d_name, Fl_FileIcon::find(filename));
|
add(files[i]->d_name, Fl_FileIcon::find(filename));
|
||||||
}
|
}
|
||||||
@@ -442,5 +543,5 @@ Fl_FileBrowser::filter(const char *pattern) // I - Pattern string
|
|||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_FileBrowser.cxx,v 1.13 2001/07/29 22:04:43 spitzak Exp $".
|
// End of "$Id: Fl_FileBrowser.cxx,v 1.13.2.1 2001/08/02 16:17:04 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
+95
-102
@@ -1,25 +1,44 @@
|
|||||||
// generated by Fast Light User Interface Designer (fluid) version 2.0000
|
// generated by Fast Light User Interface Designer (fluid) version 1.0100
|
||||||
|
|
||||||
#include <fltk/Fl_FileChooser.h>
|
#include "../FL/Fl_FileChooser.H"
|
||||||
#include <fltk/vsnprintf.h>
|
|
||||||
|
|
||||||
inline void Fl_FileChooser::cb_window_i(Fl_Window*, void*) {
|
inline void Fl_FileChooser::cb_window_i(Fl_Window*, void*) {
|
||||||
fileList->deselect();
|
fileList->deselect();
|
||||||
fileName->value("");
|
fileName->value("");
|
||||||
window->hide();
|
window->hide();
|
||||||
}
|
}
|
||||||
void Fl_FileChooser::cb_window(Fl_Window* o, void* v) {
|
void Fl_FileChooser::cb_window(Fl_Window* o, void* v) {
|
||||||
((Fl_FileChooser*)(o->user_data()))->cb_window_i(o,v);
|
((Fl_FileChooser*)(o->user_data()))->cb_window_i(o,v);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Fl_FileChooser::cb_dirMenu_i(Fl_Choice*, void*) {
|
inline void Fl_FileChooser::cb_fileList_i(Fl_FileBrowser*, void*) {
|
||||||
if (dirMenu->value())
|
fileListCB();
|
||||||
directory(dirMenu->text(dirMenu->value()));
|
|
||||||
else
|
|
||||||
directory("");
|
|
||||||
}
|
}
|
||||||
void Fl_FileChooser::cb_dirMenu(Fl_Choice* o, void* v) {
|
void Fl_FileChooser::cb_fileList(Fl_FileBrowser* o, void* v) {
|
||||||
((Fl_FileChooser*)(o->parent()->user_data()))->cb_dirMenu_i(o,v);
|
((Fl_FileChooser*)(o->parent()->user_data()))->cb_fileList_i(o,v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Fl_FileChooser::cb_Cancel_i(Fl_Button*, void*) {
|
||||||
|
fileList->deselect();
|
||||||
|
fileName->value("");
|
||||||
|
window->hide();
|
||||||
|
}
|
||||||
|
void Fl_FileChooser::cb_Cancel(Fl_Button* o, void* v) {
|
||||||
|
((Fl_FileChooser*)(o->parent()->user_data()))->cb_Cancel_i(o,v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Fl_FileChooser::cb_okButton_i(Fl_Return_Button*, void*) {
|
||||||
|
window->hide();
|
||||||
|
}
|
||||||
|
void Fl_FileChooser::cb_okButton(Fl_Return_Button* o, void* v) {
|
||||||
|
((Fl_FileChooser*)(o->parent()->user_data()))->cb_okButton_i(o,v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Fl_FileChooser::cb_fileName_i(Fl_Input*, void*) {
|
||||||
|
fileNameCB();
|
||||||
|
}
|
||||||
|
void Fl_FileChooser::cb_fileName(Fl_Input* o, void* v) {
|
||||||
|
((Fl_FileChooser*)(o->parent()->user_data()))->cb_fileName_i(o,v);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Fl_FileChooser::cb_upButton_i(Fl_Button*, void*) {
|
inline void Fl_FileChooser::cb_upButton_i(Fl_Button*, void*) {
|
||||||
@@ -29,7 +48,7 @@ void Fl_FileChooser::cb_upButton(Fl_Button* o, void* v) {
|
|||||||
((Fl_FileChooser*)(o->parent()->user_data()))->cb_upButton_i(o,v);
|
((Fl_FileChooser*)(o->parent()->user_data()))->cb_upButton_i(o,v);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <fltk/Fl_Bitmap.h>
|
#include <FL/Fl_Bitmap.H>
|
||||||
static unsigned char bits_up[] =
|
static unsigned char bits_up[] =
|
||||||
"\0\0x\0\204\0\2\1""1\376y\200\375\200""1\200""1\200""1\200""1\200""1\200\1\
|
"\0\0x\0\204\0\2\1""1\376y\200\375\200""1\200""1\200""1\200""1\200""1\200\1\
|
||||||
\200\1\200\377\377\0\0";
|
\200\1\200\377\377\0\0";
|
||||||
@@ -47,104 +66,79 @@ static unsigned char bits_new[] =
|
|||||||
\200\1\200\377\377\0\0";
|
\200\1\200\377\377\0\0";
|
||||||
static Fl_Bitmap bitmap_new(bits_new, 16, 16);
|
static Fl_Bitmap bitmap_new(bits_new, 16, 16);
|
||||||
|
|
||||||
inline void Fl_FileChooser::cb__i(Fl_Button*, void*) {
|
inline void Fl_FileChooser::cb_dirMenu_i(Fl_Choice*, void*) {
|
||||||
fileList->filter("*");;
|
char pathname[1024];
|
||||||
rescan();
|
int i;
|
||||||
|
|
||||||
|
pathname[0] = '\0';
|
||||||
|
for (i = 1; i <= dirMenu->value(); i ++)
|
||||||
|
strcat(pathname, dirMenu->text(i));
|
||||||
|
directory(pathname);
|
||||||
}
|
}
|
||||||
void Fl_FileChooser::cb_(Fl_Button* o, void* v) {
|
void Fl_FileChooser::cb_dirMenu(Fl_Choice* o, void* v) {
|
||||||
((Fl_FileChooser*)(o->parent()->user_data()))->cb__i(o,v);
|
((Fl_FileChooser*)(o->parent()->user_data()))->cb_dirMenu_i(o,v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Fl_FileChooser::cb_allfiles_i(Fl_Button*, void*) {
|
||||||
|
const char *f;
|
||||||
|
if ((f = fl_input("New Filter?",
|
||||||
|
fileList->filter())) != NULL)
|
||||||
|
{
|
||||||
|
fileList->filter(f);
|
||||||
|
rescan();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
void Fl_FileChooser::cb_allfiles(Fl_Button* o, void* v) {
|
||||||
|
((Fl_FileChooser*)(o->parent()->user_data()))->cb_allfiles_i(o,v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char bits_allfiles[] =
|
static unsigned char bits_allfiles[] =
|
||||||
"\374?\4 \4 \4 \204!\244%\304#\364/\364/\304#\244%\204!\4 \4 \4 \374?";
|
"\374?\4 \4 \4 \204!\244%\304#\364/\364/\304#\244%\204!\4 \4 \4 \374?";
|
||||||
static Fl_Bitmap bitmap_allfiles(bits_allfiles, 16, 16);
|
static Fl_Bitmap bitmap_allfiles(bits_allfiles, 16, 16);
|
||||||
|
|
||||||
inline void Fl_FileChooser::cb_fileList_i(Fl_FileBrowser*, void*) {
|
|
||||||
fileListCB();
|
|
||||||
}
|
|
||||||
void Fl_FileChooser::cb_fileList(Fl_FileBrowser* o, void* v) {
|
|
||||||
((Fl_FileChooser*)(o->parent()->user_data()))->cb_fileList_i(o,v);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Fl_FileChooser::cb_fileName_i(Fl_FileInput*, void*) {
|
|
||||||
fileNameCB();
|
|
||||||
}
|
|
||||||
void Fl_FileChooser::cb_fileName(Fl_FileInput* o, void* v) {
|
|
||||||
((Fl_FileChooser*)(o->parent()->user_data()))->cb_fileName_i(o,v);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Fl_FileChooser::cb_okButton_i(Fl_Return_Button*, void*) {
|
|
||||||
char pathname[1024];
|
|
||||||
|
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s",
|
|
||||||
fileList->directory(), fileName->value());
|
|
||||||
if (filename_isdir(pathname))
|
|
||||||
directory(pathname);
|
|
||||||
else
|
|
||||||
window->hide();
|
|
||||||
}
|
|
||||||
void Fl_FileChooser::cb_okButton(Fl_Return_Button* o, void* v) {
|
|
||||||
((Fl_FileChooser*)(o->parent()->user_data()))->cb_okButton_i(o,v);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Fl_FileChooser::cb_Cancel_i(Fl_Button*, void*) {
|
|
||||||
fileList->deselect();
|
|
||||||
fileName->value("");
|
|
||||||
window->hide();
|
|
||||||
}
|
|
||||||
void Fl_FileChooser::cb_Cancel(Fl_Button* o, void* v) {
|
|
||||||
((Fl_FileChooser*)(o->parent()->user_data()))->cb_Cancel_i(o,v);
|
|
||||||
}
|
|
||||||
|
|
||||||
Fl_FileChooser::Fl_FileChooser(const char *d, const char *p, int t, const char *title) {
|
Fl_FileChooser::Fl_FileChooser(const char *d, const char *p, int t, const char *title) {
|
||||||
|
Fl_Window* w;
|
||||||
{ Fl_Window* o = window = new Fl_Window(375, 315, "Pick a File");
|
{ Fl_Window* o = window = new Fl_Window(375, 315, "Pick a File");
|
||||||
|
w = o;
|
||||||
o->callback((Fl_Callback*)cb_window, (void*)(this));
|
o->callback((Fl_Callback*)cb_window, (void*)(this));
|
||||||
((Fl_Window*)(o))->hotspot(o);
|
w->hotspot(o);
|
||||||
{ Fl_Choice* o = dirMenu = new Fl_Choice(65, 10, 210, 25, "Directory:"); o->begin();
|
|
||||||
o->callback((Fl_Callback*)cb_dirMenu);
|
|
||||||
o->tooltip("Click to access directory tree.");
|
|
||||||
o->set_flag(FL_ALIGN_LEFT | FL_ALIGN_RIGHT);
|
|
||||||
o->align(FL_ALIGN_LEFT | FL_ALIGN_RIGHT);
|
|
||||||
o->end();
|
|
||||||
}
|
|
||||||
{ Fl_Button* o = upButton = new Fl_Button(280, 10, 25, 25);
|
|
||||||
o->image(bitmap_up);
|
|
||||||
o->label_size(8);
|
|
||||||
o->callback((Fl_Callback*)cb_upButton);
|
|
||||||
o->tooltip("Click to display parent directory.");
|
|
||||||
}
|
|
||||||
{ Fl_Button* o = newButton = new Fl_Button(310, 10, 25, 25);
|
|
||||||
o->image(bitmap_new);
|
|
||||||
o->label_size(8);
|
|
||||||
o->callback((Fl_Callback*)cb_newButton);
|
|
||||||
o->tooltip("Click to create a new directory.");
|
|
||||||
}
|
|
||||||
{ Fl_Button* o = new Fl_Button(340, 10, 25, 25);
|
|
||||||
o->image(bitmap_allfiles);
|
|
||||||
o->label_color((Fl_Color)4);
|
|
||||||
o->label_size(28);
|
|
||||||
o->callback((Fl_Callback*)cb_);
|
|
||||||
o->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
|
|
||||||
o->tooltip("Click to show all files.");
|
|
||||||
}
|
|
||||||
{ Fl_FileBrowser* o = fileList = new Fl_FileBrowser(10, 45, 355, 180);
|
{ Fl_FileBrowser* o = fileList = new Fl_FileBrowser(10, 45, 355, 180);
|
||||||
|
o->type(2);
|
||||||
o->callback((Fl_Callback*)cb_fileList);
|
o->callback((Fl_Callback*)cb_fileList);
|
||||||
Fl_Group::current()->resizable(o);
|
Fl_Group::current()->resizable(o);
|
||||||
o->tooltip("Double-click to change directories.");
|
w->hotspot(o);
|
||||||
}
|
}
|
||||||
{ Fl_FileInput* o = fileName = new Fl_FileInput(10, 245, 355, 25, "Filename:");
|
{ Fl_Button* o = new Fl_Button(285, 280, 80, 25, "Cancel");
|
||||||
o->callback((Fl_Callback*)cb_fileName);
|
o->callback((Fl_Callback*)cb_Cancel);
|
||||||
o->align(FL_ALIGN_TOP | FL_ALIGN_LEFT);
|
|
||||||
o->when(FL_WHEN_ENTER_KEY);
|
|
||||||
o->tooltip("Type a filename or directory name here.");
|
|
||||||
fileName->when(FL_WHEN_CHANGED | FL_WHEN_ENTER_KEY_ALWAYS);
|
|
||||||
}
|
}
|
||||||
{ Fl_Return_Button* o = okButton = new Fl_Return_Button(240, 280, 55, 25, "OK");
|
{ Fl_Return_Button* o = okButton = new Fl_Return_Button(205, 280, 75, 25, "OK");
|
||||||
o->shortcut(0xff0d);
|
|
||||||
o->callback((Fl_Callback*)cb_okButton);
|
o->callback((Fl_Callback*)cb_okButton);
|
||||||
}
|
}
|
||||||
{ Fl_Button* o = new Fl_Button(300, 280, 65, 25, "Cancel");
|
{ Fl_Input* o = fileName = new Fl_Input(10, 245, 355, 25, "Filename:");
|
||||||
o->callback((Fl_Callback*)cb_Cancel);
|
o->callback((Fl_Callback*)cb_fileName);
|
||||||
|
o->align(FL_ALIGN_TOP_LEFT);
|
||||||
|
o->when(FL_WHEN_ENTER_KEY);
|
||||||
|
fileName->when(FL_WHEN_CHANGED | FL_WHEN_ENTER_KEY_ALWAYS);
|
||||||
|
}
|
||||||
|
{ Fl_Button* o = upButton = new Fl_Button(280, 10, 25, 25);
|
||||||
|
bitmap_up.label(o);
|
||||||
|
o->labelsize(8);
|
||||||
|
o->callback((Fl_Callback*)cb_upButton);
|
||||||
|
}
|
||||||
|
{ Fl_Button* o = newButton = new Fl_Button(310, 10, 25, 25);
|
||||||
|
bitmap_new.label(o);
|
||||||
|
o->labelsize(8);
|
||||||
|
o->callback((Fl_Callback*)cb_newButton);
|
||||||
|
}
|
||||||
|
{ Fl_Choice* o = dirMenu = new Fl_Choice(95, 10, 180, 25, "Directory:");
|
||||||
|
o->callback((Fl_Callback*)cb_dirMenu);
|
||||||
|
}
|
||||||
|
{ Fl_Button* o = new Fl_Button(340, 10, 25, 25);
|
||||||
|
bitmap_allfiles.label(o);
|
||||||
|
o->labelsize(28);
|
||||||
|
o->labelcolor(4);
|
||||||
|
o->callback((Fl_Callback*)cb_allfiles);
|
||||||
|
o->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
|
||||||
}
|
}
|
||||||
if (title) window->label(title);
|
if (title) window->label(title);
|
||||||
o->set_modal();
|
o->set_modal();
|
||||||
@@ -197,30 +191,29 @@ const char * Fl_FileChooser::label() {
|
|||||||
return (window->label());
|
return (window->label());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_FileChooser::exec() {
|
void Fl_FileChooser::show() {
|
||||||
window->exec();
|
window->show();
|
||||||
fileList->deselect();
|
fileList->deselect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_FileChooser::textcolor(Fl_Color c) {
|
void Fl_FileChooser::textcolor(Fl_Color c) {
|
||||||
fileList->textcolor(c);
|
fileList->textcolor(c);
|
||||||
fileList->text_color(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Fl_Color Fl_FileChooser::textcolor() {
|
Fl_Color Fl_FileChooser::textcolor() {
|
||||||
return (fileList->textcolor());
|
return (fileList->textcolor());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_FileChooser::textfont(Fl_Font f) {
|
void Fl_FileChooser::textfont(uchar f) {
|
||||||
fileList->text_font(f);
|
fileList->textfont(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Fl_Font Fl_FileChooser::textfont() {
|
uchar Fl_FileChooser::textfont() {
|
||||||
return (fileList->text_font());
|
return (fileList->textfont());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_FileChooser::textsize(uchar s) {
|
void Fl_FileChooser::textsize(uchar s) {
|
||||||
fileList->text_size(s);
|
fileList->textsize(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
uchar Fl_FileChooser::textsize() {
|
uchar Fl_FileChooser::textsize() {
|
||||||
|
|||||||
+61
-76
@@ -1,16 +1,10 @@
|
|||||||
# data file for the FLTK User Interface Designer (FLUID)
|
# data file for the Fltk User Interface Designer (fluid)
|
||||||
version 2.0000
|
version 1.0100
|
||||||
images_dir ./
|
header_name {../FL/Fl_FileChooser.H}
|
||||||
do_not_include_H_from_C
|
|
||||||
header_name {.H}
|
|
||||||
code_name {.cxx}
|
code_name {.cxx}
|
||||||
gridx 5
|
gridx 5
|
||||||
gridy 5
|
gridy 5
|
||||||
snap 3
|
snap 3
|
||||||
decl {\#include <fltk/Fl_FileChooser.h>} {}
|
|
||||||
|
|
||||||
decl {\#include <config.h>} {}
|
|
||||||
|
|
||||||
class Fl_FileChooser {open
|
class Fl_FileChooser {open
|
||||||
} {
|
} {
|
||||||
decl {enum { SINGLE, MULTI, CREATE };} {public
|
decl {enum { SINGLE, MULTI, CREATE };} {public
|
||||||
@@ -22,74 +16,68 @@ class Fl_FileChooser {open
|
|||||||
callback {fileList->deselect();
|
callback {fileList->deselect();
|
||||||
fileName->value("");
|
fileName->value("");
|
||||||
window->hide();} open
|
window->hide();} open
|
||||||
xywh {269 372 375 315} resizable hotspot
|
private xywh {208 292 375 315} resizable hotspot
|
||||||
code0 {if (title) window->label(title);}
|
code0 {if (title) window->label(title);}
|
||||||
code1 {\#include <stdio.h>}
|
code1 {\#include <stdio.h>}
|
||||||
code2 {\#include <stdlib.h>}
|
code2 {\#include <stdlib.h>}
|
||||||
code3 {\#include <string.h>} modal visible
|
code3 {\#include <string.h>} modal visible
|
||||||
} {
|
} {
|
||||||
Fl_Choice dirMenu {
|
|
||||||
label {Directory:}
|
|
||||||
callback {if (dirMenu->value())
|
|
||||||
directory(dirMenu->text(dirMenu->value()));
|
|
||||||
else
|
|
||||||
directory("");} open
|
|
||||||
tooltip {Click to access directory tree.}
|
|
||||||
private xywh {65 10 210 25}
|
|
||||||
code0 {o->set_flag(FL_ALIGN_LEFT | FL_ALIGN_RIGHT);
|
|
||||||
o->align(FL_ALIGN_LEFT | FL_ALIGN_RIGHT);}
|
|
||||||
} {}
|
|
||||||
Fl_Button upButton {
|
|
||||||
callback {up();}
|
|
||||||
tooltip {Click to display parent directory.}
|
|
||||||
private xywh {280 10 25 25} image not_inlined {up.xbm} labelsize 8
|
|
||||||
}
|
|
||||||
Fl_Button newButton {
|
|
||||||
callback {newdir();}
|
|
||||||
tooltip {Click to create a new directory.}
|
|
||||||
private xywh {310 10 25 25} image not_inlined {new.xbm} labelsize 8
|
|
||||||
}
|
|
||||||
Fl_Button {} {
|
|
||||||
callback {fileList->filter("*");;
|
|
||||||
rescan();}
|
|
||||||
tooltip {Click to show all files.}
|
|
||||||
private xywh {340 10 25 25} align 524304 image not_inlined {allfiles.xbm} labelcolor 4 labelsize 28
|
|
||||||
}
|
|
||||||
Fl_Browser fileList {
|
Fl_Browser fileList {
|
||||||
callback {fileListCB();}
|
callback {fileListCB();} selected
|
||||||
tooltip {Double-click to change directories.}
|
private xywh {10 45 355 180} type Hold resizable hotspot
|
||||||
private xywh {10 45 355 180} resizable
|
code0 {\#include <FL/Fl_FileBrowser.H>}
|
||||||
code0 {\#include "filename.H"}
|
|
||||||
code1 {\#include <fltk/Fl_FileBrowser.h>}
|
|
||||||
class Fl_FileBrowser
|
class Fl_FileBrowser
|
||||||
}
|
}
|
||||||
Fl_Input fileName {
|
|
||||||
label {Filename:}
|
|
||||||
callback {fileNameCB();} selected
|
|
||||||
tooltip {Type a filename or directory name here.}
|
|
||||||
private xywh {10 245 355 25} align 5 when 8
|
|
||||||
code0 {fileName->when(FL_WHEN_CHANGED | FL_WHEN_ENTER_KEY_ALWAYS);}
|
|
||||||
code1 {\#include <fltk/Fl_FileInput.h>}
|
|
||||||
class Fl_FileInput
|
|
||||||
}
|
|
||||||
Fl_Return_Button okButton {
|
|
||||||
label OK
|
|
||||||
callback {char pathname[1024];
|
|
||||||
|
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s",
|
|
||||||
fileList->directory(), fileName->value());
|
|
||||||
if (filename_isdir(pathname))
|
|
||||||
directory(pathname);
|
|
||||||
else
|
|
||||||
window->hide();}
|
|
||||||
private xywh {240 280 55 25} shortcut 0xff0d
|
|
||||||
}
|
|
||||||
Fl_Button {} {
|
Fl_Button {} {
|
||||||
label Cancel
|
label Cancel
|
||||||
callback {fileList->deselect();
|
callback {fileList->deselect();
|
||||||
fileName->value("");
|
fileName->value("");
|
||||||
window->hide();}
|
window->hide();}
|
||||||
private xywh {300 280 65 25}
|
private xywh {285 280 80 25}
|
||||||
|
}
|
||||||
|
Fl_Return_Button okButton {
|
||||||
|
label OK
|
||||||
|
callback {window->hide();}
|
||||||
|
private xywh {205 280 75 25}
|
||||||
|
}
|
||||||
|
Fl_Input fileName {
|
||||||
|
label {Filename:}
|
||||||
|
callback {fileNameCB();}
|
||||||
|
private xywh {10 245 355 25} align 5 when 8
|
||||||
|
code0 {fileName->when(FL_WHEN_CHANGED | FL_WHEN_ENTER_KEY_ALWAYS);}
|
||||||
|
}
|
||||||
|
Fl_Button upButton {
|
||||||
|
label {up.xbm}
|
||||||
|
callback {up();}
|
||||||
|
private xywh {280 10 25 25} labeltype image labelsize 8
|
||||||
|
}
|
||||||
|
Fl_Button newButton {
|
||||||
|
label {new.xbm}
|
||||||
|
callback {newdir();}
|
||||||
|
private xywh {310 10 25 25} labeltype image labelsize 8
|
||||||
|
}
|
||||||
|
Fl_Choice dirMenu {
|
||||||
|
label {Directory:}
|
||||||
|
callback {char pathname[1024];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
pathname[0] = '\\0';
|
||||||
|
for (i = 1; i <= dirMenu->value(); i ++)
|
||||||
|
strcat(pathname, dirMenu->text(i));
|
||||||
|
directory(pathname);} open
|
||||||
|
private xywh {95 10 180 25}
|
||||||
|
} {}
|
||||||
|
Fl_Button {} {
|
||||||
|
label {allfiles.xbm}
|
||||||
|
callback {const char *f;
|
||||||
|
if ((f = fl_input("New Filter?",
|
||||||
|
fileList->filter())) != NULL)
|
||||||
|
{
|
||||||
|
fileList->filter(f);
|
||||||
|
rescan();
|
||||||
|
}}
|
||||||
|
private xywh {340 10 25 25} labeltype image labelsize 28 labelcolor 4 align 16
|
||||||
|
code0 {\#include <FL/fl_ask.H>}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
code {window->size_range(345, 270, 345);
|
code {window->size_range(345, 270, 345);
|
||||||
@@ -149,33 +137,30 @@ rescan();} {}
|
|||||||
}
|
}
|
||||||
decl {void rescan();} {public
|
decl {void rescan();} {public
|
||||||
}
|
}
|
||||||
Function {exec()} {return_type void
|
Function {show()} {return_type void
|
||||||
} {
|
} {
|
||||||
code {window->exec();
|
code {window->show();
|
||||||
fileList->deselect();} {}
|
fileList->deselect();} {}
|
||||||
}
|
}
|
||||||
Function {textcolor(Fl_Color c)} {return_type void
|
Function {textcolor(Fl_Color c)} {return_type void
|
||||||
} {
|
} {
|
||||||
code {fileList->textcolor(c);
|
code {fileList->textcolor(c);} {}
|
||||||
fileList->text_color(c);} {}
|
|
||||||
}
|
}
|
||||||
Function {textcolor()} {return_type Fl_Color
|
Function {textcolor()} {return_type Fl_Color
|
||||||
} {
|
} {
|
||||||
code {return (fileList->textcolor());
|
code {return (fileList->textcolor());} {}
|
||||||
return (fileList->textcolor());} {}
|
|
||||||
}
|
}
|
||||||
Function {textfont(Fl_Font f)} {return_type void
|
Function {textfont(uchar f)} {return_type void
|
||||||
} {
|
} {
|
||||||
code {fileList->text_font(f);} {}
|
code {fileList->textfont(f);} {}
|
||||||
}
|
}
|
||||||
Function {textfont()} {return_type Fl_Font
|
Function {textfont()} {return_type uchar
|
||||||
} {
|
} {
|
||||||
code {return (fileList->text_font());
|
code {return (fileList->textfont());} {}
|
||||||
return (fileList->textfont());} {}
|
|
||||||
}
|
}
|
||||||
Function {textsize(uchar s)} {return_type void
|
Function {textsize(uchar s)} {return_type void
|
||||||
} {
|
} {
|
||||||
code {fileList->text_size(s);} {}
|
code {fileList->textsize(s);} {}
|
||||||
}
|
}
|
||||||
Function {textsize()} {return_type uchar
|
Function {textsize()} {return_type uchar
|
||||||
} {
|
} {
|
||||||
|
|||||||
+91
-83
@@ -1,9 +1,9 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Fl_FileChooser2.cxx,v 1.15 2001/07/29 22:04:43 spitzak Exp $"
|
// "$Id: Fl_FileChooser2.cxx,v 1.15.2.1 2001/08/02 16:17:04 easysw Exp $"
|
||||||
//
|
//
|
||||||
// More Fl_FileChooser routines for the Fast Light Tool Kit (FLTK).
|
// More Fl_FileChooser routines.
|
||||||
//
|
//
|
||||||
// Copyright 1997-2000 by Easy Software Products.
|
// Copyright 1999-2001 by Michael Sweet.
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Library General Public
|
// modify it under the terms of the GNU Library General Public
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Please report all bugs and problems to "fltk-bugs@easysw.com".
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
||||||
//
|
//
|
||||||
// Contents:
|
// Contents:
|
||||||
//
|
//
|
||||||
@@ -39,24 +39,28 @@
|
|||||||
// Include necessary headers.
|
// Include necessary headers.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <fltk/Fl_FileChooser.h>
|
#include <FL/Fl_FileChooser.H>
|
||||||
#include <fltk/filename.h>
|
#include <FL/filename.H>
|
||||||
#include <fltk/fl_ask.h>
|
#include <FL/fl_ask.H>
|
||||||
#include <fltk/vsnprintf.h>
|
#include <FL/x.H>
|
||||||
#include <fltk/x.h>
|
|
||||||
#include <config.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(WIN32)
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
#else
|
#else
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <pwd.h>
|
# include <pwd.h>
|
||||||
#endif /* _WIN32 */
|
#endif /* WIN32 */
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// 'Fl_FileChooser::directory()' - Set the directory in the file chooser.
|
// 'Fl_FileChooser::directory()' - Set the directory in the file chooser.
|
||||||
@@ -71,6 +75,8 @@ Fl_FileChooser::directory(const char *d) // I - Directory to change to
|
|||||||
int levels; // Number of levels in directory
|
int levels; // Number of levels in directory
|
||||||
|
|
||||||
|
|
||||||
|
// printf("Fl_FileChooser::directory(\"%s\")\n", d == NULL ? "(null)" : d);
|
||||||
|
|
||||||
// NULL == current directory
|
// NULL == current directory
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
d = ".";
|
d = ".";
|
||||||
@@ -78,11 +84,11 @@ Fl_FileChooser::directory(const char *d) // I - Directory to change to
|
|||||||
if (d[0] != '\0')
|
if (d[0] != '\0')
|
||||||
{
|
{
|
||||||
// Make the directory absolute...
|
// Make the directory absolute...
|
||||||
#if defined(_WIN32) || defined(__EMX__)
|
#if defined(WIN32) || defined(__EMX__)
|
||||||
if (d[0] != '/' && d[0] != '\\' && d[1] != ':')
|
if (d[0] != '/' && d[0] != '\\' && d[1] != ':')
|
||||||
#else
|
#else
|
||||||
if (d[0] != '/' && d[0] != '\\')
|
if (d[0] != '/' && d[0] != '\\')
|
||||||
#endif /* _WIN32 || __EMX__ */
|
#endif /* WIN32 || __EMX__ */
|
||||||
filename_absolute(directory_, d);
|
filename_absolute(directory_, d);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -102,11 +108,11 @@ Fl_FileChooser::directory(const char *d) // I - Directory to change to
|
|||||||
|
|
||||||
// Clear the directory menu and fill it as needed...
|
// Clear the directory menu and fill it as needed...
|
||||||
dirMenu->clear();
|
dirMenu->clear();
|
||||||
#if defined(_WIN32) || defined(__EMX__)
|
#if defined(WIN32) || defined(__EMX__)
|
||||||
dirMenu->add("My Computer");
|
dirMenu->add("My Computer");
|
||||||
#else
|
#else
|
||||||
dirMenu->add("File Systems");
|
dirMenu->add("File Systems");
|
||||||
#endif /* _WIN32 || __EMX__ */
|
#endif /* WIN32 || __EMX__ */
|
||||||
|
|
||||||
levels = 0;
|
levels = 0;
|
||||||
for (dirptr = directory_, pathptr = pathname; *dirptr != '\0';)
|
for (dirptr = directory_, pathptr = pathname; *dirptr != '\0';)
|
||||||
@@ -116,11 +122,12 @@ Fl_FileChooser::directory(const char *d) // I - Directory to change to
|
|||||||
// Need to quote the slash first, and then add it to the menu...
|
// Need to quote the slash first, and then add it to the menu...
|
||||||
*pathptr++ = '\\';
|
*pathptr++ = '\\';
|
||||||
*pathptr++ = '/';
|
*pathptr++ = '/';
|
||||||
*pathptr = '\0';
|
*pathptr++ = '\0';
|
||||||
dirptr ++;
|
dirptr ++;
|
||||||
|
|
||||||
dirMenu->add(pathname);
|
dirMenu->add(pathname);
|
||||||
levels ++;
|
levels ++;
|
||||||
|
pathptr = pathname;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*pathptr++ = *dirptr++;
|
*pathptr++ = *dirptr++;
|
||||||
@@ -134,7 +141,6 @@ Fl_FileChooser::directory(const char *d) // I - Directory to change to
|
|||||||
}
|
}
|
||||||
|
|
||||||
dirMenu->value(levels);
|
dirMenu->value(levels);
|
||||||
dirMenu->redraw();
|
|
||||||
|
|
||||||
// Rescan the directory...
|
// Rescan the directory...
|
||||||
rescan();
|
rescan();
|
||||||
@@ -163,7 +169,7 @@ Fl_FileChooser::count()
|
|||||||
|
|
||||||
// Is the file name a directory?
|
// Is the file name a directory?
|
||||||
if (directory_[0] != '\0')
|
if (directory_[0] != '\0')
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, filename);
|
sprintf(pathname, "%s/%s", directory_, filename);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(pathname, filename, sizeof(pathname) - 1);
|
strncpy(pathname, filename, sizeof(pathname) - 1);
|
||||||
@@ -176,13 +182,13 @@ Fl_FileChooser::count()
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, count = 0; i < fileList->size(); i ++)
|
for (i = 1, count = 0; i <= fileList->size(); i ++)
|
||||||
if (fileList->selected(i))
|
if (fileList->selected(i))
|
||||||
{
|
{
|
||||||
// See if this file is a directory...
|
// See if this file is a directory...
|
||||||
filename = (char *)fileList->text(i);
|
filename = (char *)fileList->text(i);
|
||||||
if (directory_[0] != '\0')
|
if (directory_[0] != '\0')
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, filename);
|
sprintf(pathname, "%s/%s", directory_, filename);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(pathname, filename, sizeof(pathname) - 1);
|
strncpy(pathname, filename, sizeof(pathname) - 1);
|
||||||
@@ -216,16 +222,16 @@ Fl_FileChooser::value(int f) // I - File number
|
|||||||
if (name[0] == '\0')
|
if (name[0] == '\0')
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, name);
|
sprintf(pathname, "%s/%s", directory_, name);
|
||||||
return ((const char *)pathname);
|
return ((const char *)pathname);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, count = 0; i < fileList->size(); i ++)
|
for (i = 1, count = 0; i <= fileList->size(); i ++)
|
||||||
if (fileList->selected(i))
|
if (fileList->selected(i))
|
||||||
{
|
{
|
||||||
// See if this file is a directory...
|
// See if this file is a directory...
|
||||||
name = fileList->text(i);
|
name = fileList->text(i);
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, name);
|
sprintf(pathname, "%s/%s", directory_, name);
|
||||||
|
|
||||||
if (!filename_isdir(pathname))
|
if (!filename_isdir(pathname))
|
||||||
{
|
{
|
||||||
@@ -253,21 +259,16 @@ Fl_FileChooser::value(const char *filename) // I - Filename + directory
|
|||||||
char pathname[1024]; // Local copy of filename
|
char pathname[1024]; // Local copy of filename
|
||||||
|
|
||||||
|
|
||||||
|
// printf("Fl_FileChooser::value(\"%s\")\n", filename == NULL ? "(null)" : filename);
|
||||||
|
|
||||||
// See if the filename is actually a directory...
|
// See if the filename is actually a directory...
|
||||||
if (filename == NULL || filename_isdir(filename))
|
if (filename == NULL || !filename[0] || filename_isdir(filename))
|
||||||
{
|
{
|
||||||
// Yes, just change the current directory...
|
// Yes, just change the current directory...
|
||||||
directory(filename);
|
directory(filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filename[0])
|
|
||||||
{
|
|
||||||
// Just show the current directory...
|
|
||||||
directory(NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Switch to single-selection mode as needed
|
// Switch to single-selection mode as needed
|
||||||
if (type_ == MULTI)
|
if (type_ == MULTI)
|
||||||
type(SINGLE);
|
type(SINGLE);
|
||||||
@@ -286,10 +287,7 @@ Fl_FileChooser::value(const char *filename) // I - Filename + directory
|
|||||||
directory(pathname);
|
directory(pathname);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
directory(NULL);
|
|
||||||
slash = pathname;
|
slash = pathname;
|
||||||
}
|
|
||||||
|
|
||||||
// Set the input field to the remaining portion
|
// Set the input field to the remaining portion
|
||||||
fileName->value(slash);
|
fileName->value(slash);
|
||||||
@@ -299,7 +297,7 @@ Fl_FileChooser::value(const char *filename) // I - Filename + directory
|
|||||||
// Then find the file in the file list and select it...
|
// Then find the file in the file list and select it...
|
||||||
count = fileList->size();
|
count = fileList->size();
|
||||||
|
|
||||||
for (i = 0; i < count; i ++)
|
for (i = 1; i <= count; i ++)
|
||||||
if (strcmp(fileList->text(i), slash) == 0)
|
if (strcmp(fileList->text(i), slash) == 0)
|
||||||
{
|
{
|
||||||
fileList->select(i);
|
fileList->select(i);
|
||||||
@@ -348,16 +346,16 @@ Fl_FileChooser::newdir()
|
|||||||
|
|
||||||
|
|
||||||
// Get a directory name from the user
|
// Get a directory name from the user
|
||||||
if ((dir = fl_input("New Directory?")) == NULL)
|
if ((dir = fl_input("New Directory?", NULL)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Make it relative to the current directory as needed...
|
// Make it relative to the current directory as needed...
|
||||||
#if defined(_WIN32) || defined(__EMX__)
|
#if defined(WIN32) || defined(__EMX__)
|
||||||
if (dir[0] != '/' && dir[0] != '\\' && dir[1] != ':')
|
if (dir[0] != '/' && dir[0] != '\\' && dir[1] != ':')
|
||||||
#else
|
#else
|
||||||
if (dir[0] != '/' && dir[0] != '\\')
|
if (dir[0] != '/' && dir[0] != '\\')
|
||||||
#endif /* _WIN32 || __EMX__ */
|
#endif /* WIN32 || __EMX__ */
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, dir);
|
sprintf(pathname, "%s/%s", directory_, dir);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(pathname, dir, sizeof(pathname) - 1);
|
strncpy(pathname, dir, sizeof(pathname) - 1);
|
||||||
@@ -365,11 +363,11 @@ Fl_FileChooser::newdir()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the directory; ignore EEXIST errors...
|
// Create the directory; ignore EEXIST errors...
|
||||||
#if defined(_WIN32)
|
#if defined(WIN32)
|
||||||
if (mkdir(pathname))
|
if (mkdir(pathname))
|
||||||
#else
|
#else
|
||||||
if (mkdir(pathname, 0777))
|
if (mkdir(pathname, 0777))
|
||||||
#endif /* _WIN32 || __EMX__ */
|
#endif /* WIN32 */
|
||||||
if (errno != EEXIST)
|
if (errno != EEXIST)
|
||||||
{
|
{
|
||||||
fl_alert("Unable to create directory!");
|
fl_alert("Unable to create directory!");
|
||||||
@@ -388,13 +386,14 @@ Fl_FileChooser::newdir()
|
|||||||
void
|
void
|
||||||
Fl_FileChooser::rescan()
|
Fl_FileChooser::rescan()
|
||||||
{
|
{
|
||||||
|
// printf("Fl_FileChooser::rescan(); directory = \"%s\"\n", directory_);
|
||||||
|
|
||||||
// Clear the current filename
|
// Clear the current filename
|
||||||
fileName->value("");
|
fileName->value("");
|
||||||
okButton->deactivate();
|
okButton->deactivate();
|
||||||
|
|
||||||
// Build the file list...
|
// Build the file list...
|
||||||
fileList->load(directory_);
|
fileList->load(directory_);
|
||||||
fileList->redraw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -406,38 +405,28 @@ Fl_FileChooser::rescan()
|
|||||||
void
|
void
|
||||||
Fl_FileChooser::fileListCB()
|
Fl_FileChooser::fileListCB()
|
||||||
{
|
{
|
||||||
char filename[1024], // New filename
|
char *filename, // New filename
|
||||||
pathname[1024]; // Full pathname to file
|
pathname[1024]; // Full pathname to file
|
||||||
|
|
||||||
|
|
||||||
strncpy(filename, fileList->text(fileList->value()), sizeof(filename) - 1);
|
filename = (char *)fileList->text(fileList->value());
|
||||||
filename[sizeof(filename) - 1] = '\0';
|
if (directory_[0] != '\0')
|
||||||
|
sprintf(pathname, "%s/%s", directory_, filename);
|
||||||
#if defined(_WIN32) || defined(__EMX__)
|
|
||||||
if (directory_[0] != '\0' && filename[0] != '/' && filename[0] != '\\' &&
|
|
||||||
!(isalpha(filename[0]) && filename[1] == ':'))
|
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, filename);
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(pathname, filename, sizeof(pathname) - 1);
|
strncpy(pathname, filename, sizeof(pathname) - 1);
|
||||||
pathname[sizeof(pathname) - 1] = '\0';
|
pathname[sizeof(pathname) - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Fl::event_clicks())
|
||||||
|
{
|
||||||
|
#if defined(WIN32) || defined(__EMX__)
|
||||||
|
if ((strlen(pathname) == 2 && pathname[1] == ':') ||
|
||||||
|
filename_isdir(pathname))
|
||||||
#else
|
#else
|
||||||
if (directory_[0] != '\0' && filename[0] != '/')
|
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, filename);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strncpy(pathname, filename, sizeof(pathname) - 1);
|
|
||||||
pathname[sizeof(pathname) - 1] = '\0';
|
|
||||||
}
|
|
||||||
#endif /* _WIN32 || __EMX__ */
|
|
||||||
|
|
||||||
if (Fl::event_clicks() || Fl::event_key() == FL_Enter)
|
|
||||||
{
|
|
||||||
puts("double-click");
|
|
||||||
if (filename_isdir(pathname))
|
if (filename_isdir(pathname))
|
||||||
|
#endif /* WIN32 || __EMX__ */
|
||||||
{
|
{
|
||||||
puts("directory");
|
|
||||||
directory(pathname);
|
directory(pathname);
|
||||||
upButton->activate();
|
upButton->activate();
|
||||||
}
|
}
|
||||||
@@ -447,6 +436,8 @@ Fl_FileChooser::fileListCB()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fileName->value(filename);
|
fileName->value(filename);
|
||||||
|
|
||||||
|
if (!filename_isdir(pathname))
|
||||||
okButton->activate();
|
okButton->activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -479,10 +470,12 @@ Fl_FileChooser::fileNameCB()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__EMX__)
|
#if defined(WIN32) || defined(__EMX__)
|
||||||
if (directory_[0] != '\0' && filename[0] != '/' && filename[0] != '\\' &&
|
if (directory_[0] != '\0' &&
|
||||||
|
filename[0] != '/' &&
|
||||||
|
filename[0] != '\\' &&
|
||||||
!(isalpha(filename[0]) && filename[1] == ':'))
|
!(isalpha(filename[0]) && filename[1] == ':'))
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, filename);
|
sprintf(pathname, "%s/%s", directory_, filename);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(pathname, filename, sizeof(pathname) - 1);
|
strncpy(pathname, filename, sizeof(pathname) - 1);
|
||||||
@@ -514,26 +507,33 @@ Fl_FileChooser::fileNameCB()
|
|||||||
pathname[sizeof(pathname) - 1] = '\0';
|
pathname[sizeof(pathname) - 1] = '\0';
|
||||||
|
|
||||||
if (filename[strlen(filename) - 1] == '/')
|
if (filename[strlen(filename) - 1] == '/')
|
||||||
strncat(pathname, "/", sizeof(pathname) - strlen(pathname) - 1);
|
strncat(pathname, "/", sizeof(pathname) - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, filename);
|
sprintf(pathname, "%s/%s", directory_, filename);
|
||||||
|
|
||||||
endpwent();
|
endpwent();
|
||||||
}
|
}
|
||||||
else if (directory_[0] != '\0' && filename[0] != '/')
|
else if (directory_[0] != '\0' &&
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, filename);
|
filename[0] != '/')
|
||||||
|
sprintf(pathname, "%s/%s", directory_, filename);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(pathname, filename, sizeof(pathname) - 1);
|
strncpy(pathname, filename, sizeof(pathname) - 1);
|
||||||
pathname[sizeof(pathname) - 1] = '\0';
|
pathname[sizeof(pathname) - 1] = '\0';
|
||||||
}
|
}
|
||||||
#endif /* _WIN32 || __EMX__ */
|
#endif /* WIN32 || __EMX__ */
|
||||||
|
|
||||||
if (Fl::event_key() == FL_Enter)
|
if (Fl::event_key() == FL_Enter)
|
||||||
{
|
{
|
||||||
// Enter pressed - select or change directory...
|
// Enter pressed - select or change directory...
|
||||||
|
|
||||||
|
#if defined(WIN32) || defined(__EMX__)
|
||||||
|
if ((strlen(pathname) == 2 && pathname[1] == ':') ||
|
||||||
|
filename_isdir(pathname))
|
||||||
|
#else
|
||||||
if (filename_isdir(pathname))
|
if (filename_isdir(pathname))
|
||||||
|
#endif /* WIN32 || __EMX__ */
|
||||||
directory(pathname);
|
directory(pathname);
|
||||||
else if (type_ == CREATE || access(pathname, 0) == 0)
|
else if (type_ == CREATE || access(pathname, 0) == 0)
|
||||||
{
|
{
|
||||||
@@ -547,7 +547,14 @@ Fl_FileChooser::fileNameCB()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// File doesn't exist, so alert the user...
|
// File doesn't exist, so beep at and alert the user...
|
||||||
|
// TODO: NEED TO ADD fl_beep() FUNCTION TO 2.0!
|
||||||
|
#ifdef WIN32
|
||||||
|
MessageBeep(MB_ICONEXCLAMATION);
|
||||||
|
#else
|
||||||
|
XBell(fl_display, 100);
|
||||||
|
#endif // WIN32
|
||||||
|
|
||||||
fl_alert("Please choose an existing file!");
|
fl_alert("Please choose an existing file!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -589,15 +596,15 @@ Fl_FileChooser::fileNameCB()
|
|||||||
max_match = 100000;
|
max_match = 100000;
|
||||||
first_line = 0;
|
first_line = 0;
|
||||||
|
|
||||||
for (i = 0; i < num_files && max_match > min_match; i ++)
|
for (i = 1; i <= num_files && max_match > min_match; i ++)
|
||||||
{
|
{
|
||||||
file = fileList->text(i);
|
file = fileList->text(i);
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__EMX__)
|
#if defined(WIN32) || defined(__EMX__)
|
||||||
if (strnicmp(filename, file, min_match) == 0)
|
if (strnicmp(filename, file, min_match) == 0)
|
||||||
#else
|
#else
|
||||||
if (strncmp(filename, file, min_match) == 0)
|
if (strncmp(filename, file, min_match) == 0)
|
||||||
#endif // _WIN32 || __EMX__
|
#endif // WIN32 || __EMX__
|
||||||
{
|
{
|
||||||
// OK, this one matches; check against the previous match
|
// OK, this one matches; check against the previous match
|
||||||
if (max_match == 100000)
|
if (max_match == 100000)
|
||||||
@@ -615,11 +622,11 @@ Fl_FileChooser::fileNameCB()
|
|||||||
{
|
{
|
||||||
// Succeeding match; compare to find maximum string match...
|
// Succeeding match; compare to find maximum string match...
|
||||||
while (max_match > min_match)
|
while (max_match > min_match)
|
||||||
#if defined(_WIN32) || defined(__EMX__)
|
#if defined(WIN32) || defined(__EMX__)
|
||||||
if (strnicmp(file, pathname, max_match) == 0)
|
if (strnicmp(file, pathname, max_match) == 0)
|
||||||
#else
|
#else
|
||||||
if (strncmp(file, pathname, max_match) == 0)
|
if (strncmp(file, pathname, max_match) == 0)
|
||||||
#endif // _WIN32 || __EMX__
|
#endif // WIN32 || __EMX__
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
max_match --;
|
max_match --;
|
||||||
@@ -640,7 +647,7 @@ Fl_FileChooser::fileNameCB()
|
|||||||
else if (max_match > min_match && max_match != 100000)
|
else if (max_match > min_match && max_match != 100000)
|
||||||
{
|
{
|
||||||
// Add the matching portion...
|
// Add the matching portion...
|
||||||
fileName->replace(0, min_match, pathname, strlen(pathname));
|
fileName->replace(0, min_match, pathname);
|
||||||
|
|
||||||
// Highlight it; if the user just pressed the backspace
|
// Highlight it; if the user just pressed the backspace
|
||||||
// key, position the cursor at the start of the selection.
|
// key, position the cursor at the start of the selection.
|
||||||
@@ -654,9 +661,10 @@ Fl_FileChooser::fileNameCB()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// See if we need to enable the OK button...
|
// See if we need to enable the OK button...
|
||||||
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, fileName->value());
|
sprintf(pathname, "%s/%s", directory_, fileName->value());
|
||||||
|
|
||||||
if (type_ == CREATE || access(pathname, 0) == 0)
|
if ((type_ == CREATE || access(pathname, 0) == 0) &&
|
||||||
|
!filename_isdir(pathname))
|
||||||
okButton->activate();
|
okButton->activate();
|
||||||
else
|
else
|
||||||
okButton->deactivate();
|
okButton->deactivate();
|
||||||
@@ -665,5 +673,5 @@ Fl_FileChooser::fileNameCB()
|
|||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_FileChooser2.cxx,v 1.15 2001/07/29 22:04:43 spitzak Exp $".
|
// End of "$Id: Fl_FileChooser2.cxx,v 1.15.2.1 2001/08/02 16:17:04 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
+919
-23
File diff suppressed because it is too large
Load Diff
+10
-3
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Fl_Input.cxx,v 1.10.2.15 2001/01/28 06:57:33 spitzak Exp $"
|
// "$Id: Fl_Input.cxx,v 1.10.2.15.2.1 2001/08/02 16:17:04 easysw Exp $"
|
||||||
//
|
//
|
||||||
// Input widget for the Fast Light Tool Kit (FLTK).
|
// Input widget for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@@ -239,7 +239,14 @@ int Fl_Input::handle(int event) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FL_KEYBOARD:
|
case FL_KEYBOARD:
|
||||||
return handle_key();
|
if (Fl::event_key() == FL_Tab && mark() != position()) {
|
||||||
|
// Set the current cursor position to the end of the selection...
|
||||||
|
if (mark() > position())
|
||||||
|
position(mark());
|
||||||
|
else
|
||||||
|
position(position());
|
||||||
|
return (1);
|
||||||
|
} else return handle_key();
|
||||||
|
|
||||||
case FL_PUSH:
|
case FL_PUSH:
|
||||||
if (Fl::focus() != this) {
|
if (Fl::focus() != this) {
|
||||||
@@ -277,5 +284,5 @@ Fl_Input::Fl_Input(int x, int y, int w, int h, const char *l)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_Input.cxx,v 1.10.2.15 2001/01/28 06:57:33 spitzak Exp $".
|
// End of "$Id: Fl_Input.cxx,v 1.10.2.15.2.1 2001/08/02 16:17:04 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
+6
-2
@@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# "$Id: Makefile,v 1.18.2.14.2.2 2001/08/02 15:31:59 easysw Exp $"
|
# "$Id: Makefile,v 1.18.2.14.2.3 2001/08/02 16:17:04 easysw Exp $"
|
||||||
#
|
#
|
||||||
# Library makefile for the Fast Light Tool Kit (FLTK).
|
# Library makefile for the Fast Light Tool Kit (FLTK).
|
||||||
#
|
#
|
||||||
@@ -40,6 +40,10 @@ CPPFILES = \
|
|||||||
Fl_Counter.cxx \
|
Fl_Counter.cxx \
|
||||||
Fl_Dial.cxx \
|
Fl_Dial.cxx \
|
||||||
Fl_Double_Window.cxx \
|
Fl_Double_Window.cxx \
|
||||||
|
Fl_FileBrowser.cxx \
|
||||||
|
Fl_FileChooser.cxx \
|
||||||
|
Fl_FileChooser2.cxx \
|
||||||
|
Fl_FileIcon.cxx \
|
||||||
Fl_Gl_Choice.cxx \
|
Fl_Gl_Choice.cxx \
|
||||||
Fl_Gl_Overlay.cxx \
|
Fl_Gl_Overlay.cxx \
|
||||||
Fl_Gl_Window.cxx \
|
Fl_Gl_Window.cxx \
|
||||||
@@ -209,5 +213,5 @@ install: $(LIBRARY) $(DSONAME)
|
|||||||
ln -s FL $(includedir)/Fl
|
ln -s FL $(includedir)/Fl
|
||||||
|
|
||||||
#
|
#
|
||||||
# End of "$Id: Makefile,v 1.18.2.14.2.2 2001/08/02 15:31:59 easysw Exp $".
|
# End of "$Id: Makefile,v 1.18.2.14.2.3 2001/08/02 16:17:04 easysw Exp $".
|
||||||
#
|
#
|
||||||
|
|||||||
+13
-592
File diff suppressed because it is too large
Load Diff
+10
-5
@@ -48,6 +48,12 @@ Fl_Dial.o: ../FL/Fl_Valuator.H ../FL/Fl_Widget.H ../FL/fl_draw.H ../FL/math.h
|
|||||||
Fl_Double_Window.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H
|
Fl_Double_Window.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H
|
||||||
Fl_Double_Window.o: ../FL/Fl_Double_Window.H ../FL/Fl_Window.H ../FL/x.H
|
Fl_Double_Window.o: ../FL/Fl_Double_Window.H ../FL/Fl_Window.H ../FL/x.H
|
||||||
Fl_Double_Window.o: ../FL/fl_draw.H
|
Fl_Double_Window.o: ../FL/fl_draw.H
|
||||||
|
Fl_FileBrowser.o: ../FL/fl_draw.H ../FL/Enumerations.H ../FL/filename.H
|
||||||
|
Fl_FileChooser.o: ../FL/Fl_Bitmap.H
|
||||||
|
Fl_FileChooser2.o: ../FL/filename.H ../FL/fl_ask.H ../FL/Enumerations.H
|
||||||
|
Fl_FileChooser2.o: ../FL/x.H ../FL/Fl_Window.H
|
||||||
|
Fl_FileIcon.o: ../config.h ../FL/Fl_Widget.H ../FL/fl_draw.H
|
||||||
|
Fl_FileIcon.o: ../FL/Enumerations.H ../FL/filename.H
|
||||||
Fl_Gl_Choice.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/x.H
|
Fl_Gl_Choice.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/x.H
|
||||||
Fl_Gl_Choice.o: ../FL/Fl_Window.H Fl_Gl_Choice.H
|
Fl_Gl_Choice.o: ../FL/Fl_Window.H Fl_Gl_Choice.H
|
||||||
Fl_Gl_Overlay.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/x.H
|
Fl_Gl_Overlay.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/x.H
|
||||||
@@ -198,12 +204,11 @@ fl_draw_pixmap.o: ../FL/x.H ../FL/Fl_Window.H
|
|||||||
fl_engraved_label.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Widget.H
|
fl_engraved_label.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Widget.H
|
||||||
fl_engraved_label.o: ../FL/fl_draw.H
|
fl_engraved_label.o: ../FL/fl_draw.H
|
||||||
fl_file_chooser.o: ../config.h ../FL/fl_file_chooser.H ../FL/Enumerations.H
|
fl_file_chooser.o: ../config.h ../FL/fl_file_chooser.H ../FL/Enumerations.H
|
||||||
fl_file_chooser.o: ../FL/Fl.H ../FL/Fl_Window.H ../FL/Fl_Group.H
|
fl_file_chooser.o: ../FL/Fl_FileChooser.H ../FL/Fl.H ../FL/Fl_Window.H
|
||||||
fl_file_chooser.o: ../FL/Fl_Widget.H ../FL/Fl_Box.H ../FL/Fl_Button.H
|
fl_file_chooser.o: ../FL/Fl_Group.H ../FL/Fl_Widget.H ../FL/Fl_Button.H
|
||||||
fl_file_chooser.o: ../FL/Fl_Return_Button.H ../FL/Fl_Button.H
|
fl_file_chooser.o: ../FL/Fl_Return_Button.H ../FL/Fl_Button.H
|
||||||
fl_file_chooser.o: ../FL/Fl_Browser_.H ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H
|
fl_file_chooser.o: ../FL/Fl_Input.H ../FL/Fl_Input_.H ../FL/Fl_Choice.H
|
||||||
fl_file_chooser.o: ../FL/Fl_Valuator.H ../FL/Fl_Input.H ../FL/Fl_Input_.H
|
fl_file_chooser.o: ../FL/Fl_Menu_.H ../FL/Fl_Menu_Item.H ../FL/fl_ask.H
|
||||||
fl_file_chooser.o: ../FL/fl_draw.H ../FL/filename.H
|
|
||||||
fl_font.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/fl_draw.H
|
fl_font.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/fl_draw.H
|
||||||
fl_font.o: ../FL/x.H ../FL/Fl_Window.H Fl_Font.H
|
fl_font.o: ../FL/x.H ../FL/Fl_Window.H Fl_Font.H
|
||||||
fl_labeltype.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Widget.H
|
fl_labeltype.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Widget.H
|
||||||
|
|||||||
Reference in New Issue
Block a user