mirror of
https://github.com/fltk/fltk.git
synced 2025-12-13 07:34:40 +08:00
Hide window before doing callback for OK button (STR #1565)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5644 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -1,5 +1,7 @@
|
||||
CHANGES IN FLTK 1.1.8
|
||||
|
||||
- Fl_File_Chooser now hides the window before doing a callback
|
||||
when the user clicks on the OK button (STR #1565)
|
||||
- Fixed indentation of nested HTML elements (STR #1549)
|
||||
- Made layout of Fl_Help_Dialog consistent with other
|
||||
help windows and web browsers.
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
// generated by Fast Light User Interface Designer (fluid) version 1.0107
|
||||
// generated by Fast Light User Interface Designer (fluid) version 1.0108
|
||||
|
||||
#ifndef Fl_File_Chooser_H
|
||||
#define Fl_File_Chooser_H
|
||||
@@ -49,24 +49,24 @@
|
||||
|
||||
class FL_EXPORT Fl_File_Chooser {
|
||||
public:
|
||||
enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };
|
||||
enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };
|
||||
private:
|
||||
static Fl_Preferences prefs_;
|
||||
void (*callback_)(Fl_File_Chooser*, void *);
|
||||
void *data_;
|
||||
char directory_[1024];
|
||||
char pattern_[1024];
|
||||
char preview_text_[2048];
|
||||
int type_;
|
||||
void favoritesButtonCB();
|
||||
void favoritesCB(Fl_Widget *w);
|
||||
void fileListCB();
|
||||
void fileNameCB();
|
||||
void newdir();
|
||||
static void previewCB(Fl_File_Chooser *fc);
|
||||
void showChoiceCB();
|
||||
void update_favorites();
|
||||
void update_preview();
|
||||
static Fl_Preferences prefs_;
|
||||
void (*callback_)(Fl_File_Chooser*, void *);
|
||||
void *data_;
|
||||
char directory_[1024];
|
||||
char pattern_[1024];
|
||||
char preview_text_[2048];
|
||||
int type_;
|
||||
void favoritesButtonCB();
|
||||
void favoritesCB(Fl_Widget *w);
|
||||
void fileListCB();
|
||||
void fileNameCB();
|
||||
void newdir();
|
||||
static void previewCB(Fl_File_Chooser *fc);
|
||||
void showChoiceCB();
|
||||
void update_favorites();
|
||||
void update_preview();
|
||||
public:
|
||||
Fl_File_Chooser(const char *d, const char *p, int t, const char *title);
|
||||
private:
|
||||
@@ -128,10 +128,10 @@ public:
|
||||
void callback(void (*cb)(Fl_File_Chooser *, void *), void *d = 0);
|
||||
void color(Fl_Color c);
|
||||
Fl_Color color();
|
||||
int count();
|
||||
void directory(const char *d);
|
||||
int count();
|
||||
void directory(const char *d);
|
||||
char * directory();
|
||||
void filter(const char *p);
|
||||
void filter(const char *p);
|
||||
const char * filter();
|
||||
int filter_value();
|
||||
void filter_value(int f);
|
||||
@@ -142,10 +142,10 @@ public:
|
||||
const char * label();
|
||||
void ok_label(const char *l);
|
||||
const char * ok_label();
|
||||
void preview(int e);
|
||||
int preview() const { return previewButton->value(); };
|
||||
void rescan();
|
||||
void rescan_keep_filename();
|
||||
void preview(int e);
|
||||
int preview() const { return previewButton->value(); };
|
||||
void rescan();
|
||||
void rescan_keep_filename();
|
||||
void show();
|
||||
int shown();
|
||||
void textcolor(Fl_Color c);
|
||||
@@ -158,23 +158,23 @@ public:
|
||||
int type();
|
||||
void * user_data() const;
|
||||
void user_data(void *d);
|
||||
const char *value(int f = 1);
|
||||
void value(const char *filename);
|
||||
const char *value(int f = 1);
|
||||
void value(const char *filename);
|
||||
int visible();
|
||||
static const char *add_favorites_label;
|
||||
static const char *all_files_label;
|
||||
static const char *custom_filter_label;
|
||||
static const char *existing_file_label;
|
||||
static const char *favorites_label;
|
||||
static const char *filename_label;
|
||||
static const char *filesystems_label;
|
||||
static const char *manage_favorites_label;
|
||||
static const char *new_directory_label;
|
||||
static const char *new_directory_tooltip;
|
||||
static const char *preview_label;
|
||||
static const char *save_label;
|
||||
static const char *show_label;
|
||||
static Fl_File_Sort_F *sort;
|
||||
static const char *add_favorites_label;
|
||||
static const char *all_files_label;
|
||||
static const char *custom_filter_label;
|
||||
static const char *existing_file_label;
|
||||
static const char *favorites_label;
|
||||
static const char *filename_label;
|
||||
static const char *filesystems_label;
|
||||
static const char *manage_favorites_label;
|
||||
static const char *new_directory_label;
|
||||
static const char *new_directory_tooltip;
|
||||
static const char *preview_label;
|
||||
static const char *save_label;
|
||||
static const char *show_label;
|
||||
static Fl_File_Sort_F *sort;
|
||||
};
|
||||
FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname,int relative=0);
|
||||
FL_EXPORT char *fl_file_chooser(const char *message,const char *pat,const char *fname,int relative=0);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
// generated by Fast Light User Interface Designer (fluid) version 1.0107
|
||||
// generated by Fast Light User Interface Designer (fluid) version 1.0108
|
||||
|
||||
#include "../FL/Fl_File_Chooser.H"
|
||||
#include <FL/fl_draw.H>
|
||||
@@ -96,11 +96,11 @@ void Fl_File_Chooser::cb_fileName(Fl_File_Input* o, void* v) {
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::cb_okButton_i(Fl_Return_Button*, void*) {
|
||||
// Do any callback that is registered...
|
||||
window->hide();
|
||||
|
||||
// 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()->parent()->parent()->user_data()))->cb_okButton_i(o,v);
|
||||
@@ -159,134 +159,131 @@ void Fl_File_Chooser::cb_favOkButton(Fl_Return_Button* o, void* v) {
|
||||
}
|
||||
|
||||
Fl_File_Chooser::Fl_File_Chooser(const char *d, const char *p, int t, const char *title) {
|
||||
Fl_Double_Window* w;
|
||||
{ Fl_Double_Window* o = window = new Fl_Double_Window(490, 380, "Choose File");
|
||||
w = o;
|
||||
o->callback((Fl_Callback*)cb_window, (void*)(this));
|
||||
{ window = new Fl_Double_Window(490, 380, "Choose File");
|
||||
window->callback((Fl_Callback*)cb_window, (void*)(this));
|
||||
{ Fl_Group* o = new Fl_Group(10, 10, 470, 25);
|
||||
{ Fl_Choice* o = showChoice = new Fl_Choice(65, 10, 215, 25, "Show:");
|
||||
o->down_box(FL_BORDER_BOX);
|
||||
o->labelfont(1);
|
||||
o->callback((Fl_Callback*)cb_showChoice);
|
||||
Fl_Group::current()->resizable(o);
|
||||
{ showChoice = new Fl_Choice(65, 10, 215, 25, "Show:");
|
||||
showChoice->down_box(FL_BORDER_BOX);
|
||||
showChoice->labelfont(1);
|
||||
showChoice->callback((Fl_Callback*)cb_showChoice);
|
||||
Fl_Group::current()->resizable(showChoice);
|
||||
showChoice->label(show_label);
|
||||
}
|
||||
{ Fl_Menu_Button* o = favoritesButton = new Fl_Menu_Button(290, 10, 155, 25, "Favorites");
|
||||
o->down_box(FL_BORDER_BOX);
|
||||
o->callback((Fl_Callback*)cb_favoritesButton);
|
||||
o->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
|
||||
} // Fl_Choice* showChoice
|
||||
{ favoritesButton = new Fl_Menu_Button(290, 10, 155, 25, "Favorites");
|
||||
favoritesButton->down_box(FL_BORDER_BOX);
|
||||
favoritesButton->callback((Fl_Callback*)cb_favoritesButton);
|
||||
favoritesButton->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
|
||||
favoritesButton->label(favorites_label);
|
||||
}
|
||||
} // Fl_Menu_Button* favoritesButton
|
||||
{ Fl_Button* o = newButton = new Fl_Button(455, 10, 25, 25);
|
||||
o->image(image_new);
|
||||
o->labelsize(8);
|
||||
o->callback((Fl_Callback*)cb_newButton);
|
||||
newButton->image(image_new);
|
||||
newButton->labelsize(8);
|
||||
newButton->callback((Fl_Callback*)cb_newButton);
|
||||
o->tooltip(new_directory_tooltip);
|
||||
}
|
||||
} // Fl_Button* newButton
|
||||
o->end();
|
||||
}
|
||||
} // Fl_Group* o
|
||||
{ Fl_Tile* o = new Fl_Tile(10, 45, 470, 225);
|
||||
o->callback((Fl_Callback*)cb_);
|
||||
{ Fl_File_Browser* o = fileList = new Fl_File_Browser(10, 45, 295, 225);
|
||||
o->type(2);
|
||||
o->callback((Fl_Callback*)cb_fileList);
|
||||
w->hotspot(o);
|
||||
}
|
||||
{ Fl_Box* o = previewBox = new Fl_Box(305, 45, 175, 225, "?");
|
||||
o->box(FL_DOWN_BOX);
|
||||
o->labelsize(100);
|
||||
o->align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE);
|
||||
}
|
||||
{ fileList = new Fl_File_Browser(10, 45, 295, 225);
|
||||
fileList->type(2);
|
||||
fileList->callback((Fl_Callback*)cb_fileList);
|
||||
fileList->window()->hotspot(fileList);
|
||||
} // Fl_File_Browser* fileList
|
||||
{ previewBox = new Fl_Box(305, 45, 175, 225, "?");
|
||||
previewBox->box(FL_DOWN_BOX);
|
||||
previewBox->labelsize(100);
|
||||
previewBox->align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE);
|
||||
} // Fl_Box* previewBox
|
||||
o->end();
|
||||
Fl_Group::current()->resizable(o);
|
||||
}
|
||||
} // Fl_Tile* o
|
||||
{ Fl_Group* o = new Fl_Group(10, 275, 470, 95);
|
||||
{ Fl_Group* o = new Fl_Group(10, 275, 470, 20);
|
||||
{ Fl_Check_Button* o = previewButton = new Fl_Check_Button(10, 275, 73, 20, "Preview");
|
||||
o->down_box(FL_DOWN_BOX);
|
||||
o->value(1);
|
||||
o->shortcut(0x80070);
|
||||
o->callback((Fl_Callback*)cb_previewButton);
|
||||
{ previewButton = new Fl_Check_Button(10, 275, 73, 20, "Preview");
|
||||
previewButton->down_box(FL_DOWN_BOX);
|
||||
previewButton->value(1);
|
||||
previewButton->shortcut(0x80070);
|
||||
previewButton->callback((Fl_Callback*)cb_previewButton);
|
||||
previewButton->label(preview_label);
|
||||
}
|
||||
} // Fl_Check_Button* previewButton
|
||||
{ Fl_Box* o = new Fl_Box(115, 275, 365, 20);
|
||||
Fl_Group::current()->resizable(o);
|
||||
}
|
||||
} // Fl_Box* o
|
||||
o->end();
|
||||
}
|
||||
{ Fl_File_Input* o = fileName = new Fl_File_Input(115, 300, 365, 35);
|
||||
o->labelfont(1);
|
||||
o->callback((Fl_Callback*)cb_fileName);
|
||||
o->when(FL_WHEN_ENTER_KEY);
|
||||
Fl_Group::current()->resizable(o);
|
||||
} // Fl_Group* o
|
||||
{ fileName = new Fl_File_Input(115, 300, 365, 35);
|
||||
fileName->labelfont(1);
|
||||
fileName->callback((Fl_Callback*)cb_fileName);
|
||||
fileName->when(FL_WHEN_ENTER_KEY);
|
||||
Fl_Group::current()->resizable(fileName);
|
||||
fileName->when(FL_WHEN_CHANGED | FL_WHEN_ENTER_KEY_ALWAYS);
|
||||
}
|
||||
} // Fl_File_Input* fileName
|
||||
{ Fl_Box* o = new Fl_Box(10, 310, 105, 25, "Filename:");
|
||||
o->labelfont(1);
|
||||
o->align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
|
||||
o->label(filename_label);
|
||||
}
|
||||
} // Fl_Box* o
|
||||
{ Fl_Group* o = new Fl_Group(10, 345, 470, 25);
|
||||
{ Fl_Return_Button* o = okButton = new Fl_Return_Button(313, 345, 85, 25, "OK");
|
||||
o->callback((Fl_Callback*)cb_okButton);
|
||||
{ okButton = new Fl_Return_Button(313, 345, 85, 25, "OK");
|
||||
okButton->callback((Fl_Callback*)cb_okButton);
|
||||
okButton->label(fl_ok);
|
||||
}
|
||||
} // Fl_Return_Button* okButton
|
||||
{ Fl_Button* o = cancelButton = new Fl_Button(408, 345, 72, 25, "Cancel");
|
||||
o->callback((Fl_Callback*)cb_cancelButton);
|
||||
cancelButton->callback((Fl_Callback*)cb_cancelButton);
|
||||
o->label(fl_cancel);
|
||||
}
|
||||
} // Fl_Button* cancelButton
|
||||
{ Fl_Box* o = new Fl_Box(10, 345, 30, 25);
|
||||
Fl_Group::current()->resizable(o);
|
||||
}
|
||||
} // Fl_Box* o
|
||||
o->end();
|
||||
}
|
||||
} // Fl_Group* o
|
||||
o->end();
|
||||
}
|
||||
} // Fl_Group* o
|
||||
if (title) window->label(title);
|
||||
o->set_modal();
|
||||
o->end();
|
||||
}
|
||||
{ Fl_Double_Window* o = favWindow = new Fl_Double_Window(355, 150, "Manage Favorites");
|
||||
w = o;
|
||||
o->user_data((void*)(this));
|
||||
{ Fl_File_Browser* o = favList = new Fl_File_Browser(10, 10, 300, 95);
|
||||
o->type(2);
|
||||
o->callback((Fl_Callback*)cb_favList);
|
||||
Fl_Group::current()->resizable(o);
|
||||
}
|
||||
window->set_modal();
|
||||
window->end();
|
||||
} // Fl_Double_Window* window
|
||||
{ favWindow = new Fl_Double_Window(355, 150, "Manage Favorites");
|
||||
favWindow->user_data((void*)(this));
|
||||
{ favList = new Fl_File_Browser(10, 10, 300, 95);
|
||||
favList->type(2);
|
||||
favList->callback((Fl_Callback*)cb_favList);
|
||||
Fl_Group::current()->resizable(favList);
|
||||
} // Fl_File_Browser* favList
|
||||
{ Fl_Group* o = new Fl_Group(320, 10, 25, 95);
|
||||
{ Fl_Button* o = favUpButton = new Fl_Button(320, 10, 25, 25, "@8>");
|
||||
o->callback((Fl_Callback*)cb_favUpButton);
|
||||
}
|
||||
{ Fl_Button* o = favDeleteButton = new Fl_Button(320, 45, 25, 25, "X");
|
||||
o->labelfont(1);
|
||||
o->callback((Fl_Callback*)cb_favDeleteButton);
|
||||
Fl_Group::current()->resizable(o);
|
||||
}
|
||||
{ Fl_Button* o = favDownButton = new Fl_Button(320, 80, 25, 25, "@2>");
|
||||
o->callback((Fl_Callback*)cb_favDownButton);
|
||||
}
|
||||
{ favUpButton = new Fl_Button(320, 10, 25, 25, "@8>");
|
||||
favUpButton->callback((Fl_Callback*)cb_favUpButton);
|
||||
} // Fl_Button* favUpButton
|
||||
{ favDeleteButton = new Fl_Button(320, 45, 25, 25, "X");
|
||||
favDeleteButton->labelfont(1);
|
||||
favDeleteButton->callback((Fl_Callback*)cb_favDeleteButton);
|
||||
Fl_Group::current()->resizable(favDeleteButton);
|
||||
} // Fl_Button* favDeleteButton
|
||||
{ favDownButton = new Fl_Button(320, 80, 25, 25, "@2>");
|
||||
favDownButton->callback((Fl_Callback*)cb_favDownButton);
|
||||
} // Fl_Button* favDownButton
|
||||
o->end();
|
||||
}
|
||||
} // Fl_Group* o
|
||||
{ Fl_Group* o = new Fl_Group(10, 113, 335, 29);
|
||||
{ Fl_Button* o = favCancelButton = new Fl_Button(273, 115, 72, 25, "Cancel");
|
||||
o->callback((Fl_Callback*)cb_favCancelButton);
|
||||
{ favCancelButton = new Fl_Button(273, 115, 72, 25, "Cancel");
|
||||
favCancelButton->callback((Fl_Callback*)cb_favCancelButton);
|
||||
favCancelButton->label(fl_cancel);
|
||||
}
|
||||
{ Fl_Return_Button* o = favOkButton = new Fl_Return_Button(181, 115, 79, 25, "Save");
|
||||
o->callback((Fl_Callback*)cb_favOkButton);
|
||||
} // Fl_Button* favCancelButton
|
||||
{ favOkButton = new Fl_Return_Button(181, 115, 79, 25, "Save");
|
||||
favOkButton->callback((Fl_Callback*)cb_favOkButton);
|
||||
favOkButton->label(save_label);
|
||||
}
|
||||
} // Fl_Return_Button* favOkButton
|
||||
{ Fl_Box* o = new Fl_Box(10, 115, 161, 25);
|
||||
Fl_Group::current()->resizable(o);
|
||||
}
|
||||
} // Fl_Box* o
|
||||
o->end();
|
||||
}
|
||||
} // Fl_Group* o
|
||||
favWindow->label(manage_favorites_label);
|
||||
o->set_modal();
|
||||
o->size_range(181, 150);
|
||||
o->end();
|
||||
}
|
||||
favWindow->set_modal();
|
||||
favWindow->size_range(181, 150);
|
||||
favWindow->end();
|
||||
} // Fl_Double_Window* favWindow
|
||||
callback_ = 0;
|
||||
data_ = 0;
|
||||
directory_[0] = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# data file for the Fltk User Interface Designer (fluid)
|
||||
version 1.0107
|
||||
version 1.0108
|
||||
header_name {../FL/Fl_File_Chooser.H}
|
||||
code_name {.cxx}
|
||||
comment {//
|
||||
@@ -134,11 +134,11 @@ window->hide();}
|
||||
} {
|
||||
Fl_Return_Button okButton {
|
||||
label OK
|
||||
callback {// Do any callback that is registered...
|
||||
if (callback_)
|
||||
(*callback_)(this, data_);
|
||||
callback {window->hide();
|
||||
|
||||
window->hide();}
|
||||
// Do any callback that is registered...
|
||||
if (callback_)
|
||||
(*callback_)(this, data_);} selected
|
||||
private xywh {313 345 85 25}
|
||||
code0 {\#include <FL/fl_ask.H>}
|
||||
code1 {okButton->label(fl_ok);}
|
||||
@@ -309,8 +309,7 @@ Fl::flush();
|
||||
fl_cursor(FL_CURSOR_WAIT);
|
||||
rescan_keep_filename();
|
||||
fl_cursor(FL_CURSOR_DEFAULT);
|
||||
fileName->take_focus();} {selected
|
||||
}
|
||||
fileName->take_focus();} {}
|
||||
}
|
||||
Function {shown()} {return_type int
|
||||
} {
|
||||
|
||||
Reference in New Issue
Block a user