mirror of
https://github.com/fltk/fltk.git
synced 2025-12-17 11:04:20 +08:00
Fl_FileXYZ -> Fl_File_XYZ
Fl_HelpXYZ -> Fl_Help_XYZ Fl_File_Chooser now supports directory choosing. Added fl_dir_chooser() function. Now set FLTK_DOCDIR env var in test/demo. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1612 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
259
src/Fl_File_Chooser.cxx
Normal file
259
src/Fl_File_Chooser.cxx
Normal file
@@ -0,0 +1,259 @@
|
||||
// generated by Fast Light User Interface Designer (fluid) version 1.0100
|
||||
|
||||
#include "../FL/Fl_File_Chooser.H"
|
||||
|
||||
inline void Fl_File_Chooser::cb_window_i(Fl_Window*, void*) {
|
||||
fileList->deselect();
|
||||
fileName->value("");
|
||||
window->hide();
|
||||
}
|
||||
void Fl_File_Chooser::cb_window(Fl_Window* o, void* v) {
|
||||
((Fl_File_Chooser*)(o->user_data()))->cb_window_i(o,v);
|
||||
}
|
||||
|
||||
inline void Fl_File_Chooser::cb_fileList_i(Fl_File_Browser*, void*) {
|
||||
fileListCB();
|
||||
}
|
||||
void Fl_File_Chooser::cb_fileList(Fl_File_Browser* o, void* v) {
|
||||
((Fl_File_Chooser*)(o->parent()->user_data()))->cb_fileList_i(o,v);
|
||||
}
|
||||
|
||||
inline void Fl_File_Chooser::cb_Cancel_i(Fl_Button*, void*) {
|
||||
fileList->deselect();
|
||||
fileName->value("");
|
||||
window->hide();
|
||||
}
|
||||
void Fl_File_Chooser::cb_Cancel(Fl_Button* o, void* v) {
|
||||
((Fl_File_Chooser*)(o->parent()->user_data()))->cb_Cancel_i(o,v);
|
||||
}
|
||||
|
||||
inline void Fl_File_Chooser::cb_okButton_i(Fl_Return_Button*, void*) {
|
||||
// Do any callback that is registered...
|
||||
if (callback_)
|
||||
(*callback_)(this, data_);
|
||||
|
||||
window->hide();
|
||||
}
|
||||
void Fl_File_Chooser::cb_okButton(Fl_Return_Button* o, void* v) {
|
||||
((Fl_File_Chooser*)(o->parent()->user_data()))->cb_okButton_i(o,v);
|
||||
}
|
||||
|
||||
inline void Fl_File_Chooser::cb_fileName_i(Fl_Input*, void*) {
|
||||
fileNameCB();
|
||||
}
|
||||
void Fl_File_Chooser::cb_fileName(Fl_Input* o, void* v) {
|
||||
((Fl_File_Chooser*)(o->parent()->user_data()))->cb_fileName_i(o,v);
|
||||
}
|
||||
|
||||
inline void Fl_File_Chooser::cb_upButton_i(Fl_Button*, void*) {
|
||||
up();
|
||||
}
|
||||
void Fl_File_Chooser::cb_upButton(Fl_Button* o, void* v) {
|
||||
((Fl_File_Chooser*)(o->parent()->user_data()))->cb_upButton_i(o,v);
|
||||
}
|
||||
|
||||
#include <FL/Fl_Bitmap.H>
|
||||
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\
|
||||
\200\1\200\377\377\0\0";
|
||||
static Fl_Bitmap bitmap_up(bits_up, 16, 16);
|
||||
|
||||
inline void Fl_File_Chooser::cb_newButton_i(Fl_Button*, void*) {
|
||||
newdir();
|
||||
}
|
||||
void Fl_File_Chooser::cb_newButton(Fl_Button* o, void* v) {
|
||||
((Fl_File_Chooser*)(o->parent()->user_data()))->cb_newButton_i(o,v);
|
||||
}
|
||||
|
||||
static unsigned char bits_new[] =
|
||||
"\0\0x\0\204\0\2\1\1\376\1\200""1\200""1\200\375\200\375\200""1\200""1\200\1\
|
||||
\200\1\200\377\377\0\0";
|
||||
static Fl_Bitmap bitmap_new(bits_new, 16, 16);
|
||||
|
||||
inline void Fl_File_Chooser::cb_dirMenu_i(Fl_Choice*, void*) {
|
||||
char pathname[1024];
|
||||
int i;
|
||||
|
||||
pathname[0] = '\0';
|
||||
for (i = 1; i <= dirMenu->value(); i ++)
|
||||
strcat(pathname, dirMenu->text(i));
|
||||
directory(pathname);
|
||||
}
|
||||
void Fl_File_Chooser::cb_dirMenu(Fl_Choice* o, void* v) {
|
||||
((Fl_File_Chooser*)(o->parent()->user_data()))->cb_dirMenu_i(o,v);
|
||||
}
|
||||
|
||||
inline void Fl_File_Chooser::cb__i(Fl_Button*, void*) {
|
||||
const char *f;
|
||||
if ((f = fl_input("New Filter?",
|
||||
fileList->filter())) != NULL)
|
||||
{
|
||||
fileList->filter(f);
|
||||
rescan();
|
||||
};
|
||||
}
|
||||
void Fl_File_Chooser::cb_(Fl_Button* o, void* v) {
|
||||
((Fl_File_Chooser*)(o->parent()->user_data()))->cb__i(o,v);
|
||||
}
|
||||
|
||||
static unsigned char bits_allfiles[] =
|
||||
"\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);
|
||||
|
||||
Fl_File_Chooser::Fl_File_Chooser(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");
|
||||
w = o;
|
||||
o->callback((Fl_Callback*)cb_window, (void*)(this));
|
||||
w->hotspot(o);
|
||||
{ Fl_File_Browser* o = fileList = new Fl_File_Browser(10, 45, 355, 180);
|
||||
o->type(2);
|
||||
o->callback((Fl_Callback*)cb_fileList);
|
||||
Fl_Group::current()->resizable(o);
|
||||
w->hotspot(o);
|
||||
}
|
||||
{ Fl_Button* o = new Fl_Button(285, 280, 80, 25, "Cancel");
|
||||
o->callback((Fl_Callback*)cb_Cancel);
|
||||
o->label(fl_cancel);
|
||||
}
|
||||
{ Fl_Return_Button* o = okButton = new Fl_Return_Button(200, 280, 75, 25, "OK");
|
||||
o->callback((Fl_Callback*)cb_okButton);
|
||||
okButton->label(fl_ok);
|
||||
}
|
||||
{ Fl_Input* o = fileName = new Fl_Input(10, 245, 355, 25, "Filename:");
|
||||
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);
|
||||
o->image(bitmap_up);
|
||||
o->labelsize(8);
|
||||
o->callback((Fl_Callback*)cb_upButton);
|
||||
}
|
||||
{ Fl_Button* o = newButton = new Fl_Button(310, 10, 25, 25);
|
||||
o->image(bitmap_new);
|
||||
o->labelsize(8);
|
||||
o->callback((Fl_Callback*)cb_newButton);
|
||||
}
|
||||
{ Fl_Choice* o = dirMenu = new Fl_Choice(95, 10, 180, 25, "Directory:");
|
||||
o->down_box(FL_BORDER_BOX);
|
||||
o->callback((Fl_Callback*)cb_dirMenu);
|
||||
}
|
||||
{ Fl_Button* o = new Fl_Button(340, 10, 25, 25);
|
||||
o->image(bitmap_allfiles);
|
||||
o->labelsize(28);
|
||||
o->labelcolor(4);
|
||||
o->callback((Fl_Callback*)cb_);
|
||||
o->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
|
||||
}
|
||||
if (title) window->label(title);
|
||||
o->set_modal();
|
||||
o->end();
|
||||
}
|
||||
window->size_range(345, 270, 345);
|
||||
fileList->filter(p);
|
||||
type(t);
|
||||
value(d);
|
||||
callback_ = 0;
|
||||
data_ = 0;
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::callback(void (*cb)(Fl_File_Chooser *, void *), void *d) {
|
||||
callback_ = cb;
|
||||
data_ = d;
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::color(Fl_Color c) {
|
||||
fileList->color(c);
|
||||
}
|
||||
|
||||
Fl_Color Fl_File_Chooser::color() {
|
||||
return (fileList->color());
|
||||
}
|
||||
|
||||
char * Fl_File_Chooser::directory() {
|
||||
return directory_;
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::filter(const char *p) {
|
||||
fileList->filter(p);
|
||||
rescan();
|
||||
}
|
||||
|
||||
const char * Fl_File_Chooser::filter() {
|
||||
return (fileList->filter());
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::hide() {
|
||||
window->hide();
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::iconsize(uchar s) {
|
||||
fileList->iconsize(s);
|
||||
}
|
||||
|
||||
uchar Fl_File_Chooser::iconsize() {
|
||||
return (fileList->iconsize());
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::label(const char *l) {
|
||||
window->label(l);
|
||||
}
|
||||
|
||||
const char * Fl_File_Chooser::label() {
|
||||
return (window->label());
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::show() {
|
||||
window->show();
|
||||
fileList->deselect();
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::textcolor(Fl_Color c) {
|
||||
fileList->textcolor(c);
|
||||
}
|
||||
|
||||
Fl_Color Fl_File_Chooser::textcolor() {
|
||||
return (fileList->textcolor());
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::textfont(uchar f) {
|
||||
fileList->textfont(f);
|
||||
}
|
||||
|
||||
uchar Fl_File_Chooser::textfont() {
|
||||
return (fileList->textfont());
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::textsize(uchar s) {
|
||||
fileList->textsize(s);
|
||||
}
|
||||
|
||||
uchar Fl_File_Chooser::textsize() {
|
||||
return (fileList->textsize());
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::type(int t) {
|
||||
type_ = t;
|
||||
if (t & MULTI)
|
||||
fileList->type(FL_MULTI_BROWSER);
|
||||
else
|
||||
fileList->type(FL_HOLD_BROWSER);
|
||||
if (t & CREATE)
|
||||
newButton->deactivate();
|
||||
else
|
||||
newButton->activate();
|
||||
if (t & DIRECTORY)
|
||||
fileList->filetype(Fl_File_Browser::DIRECTORIES);
|
||||
else
|
||||
fileList->filetype(Fl_File_Browser::FILES);
|
||||
}
|
||||
|
||||
int Fl_File_Chooser::type() {
|
||||
return (type_);
|
||||
}
|
||||
|
||||
int Fl_File_Chooser::visible() {
|
||||
return window->visible();
|
||||
}
|
||||
Reference in New Issue
Block a user