FLTK 1.4.0
Fl_File_Chooser.H
1//
2// Fl_File_Chooser dialog for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2024 by Bill Spitzak and others.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16// =======================================================================
17// DO NOT EDIT FL/Fl_File_Chooser.H and src/Fl_File_Chooser.cxx !!!
18// =======================================================================
19// Please use fluid to change src/Fl_File_Chooser.fl interactively
20// and then use fluid to "write code" or edit and use fluid -c .
21// =======================================================================
22//
23
24// generated by Fast Light User Interface Designer (fluid) version 1.0400
25
26#ifndef Fl_File_Chooser_H
27#define Fl_File_Chooser_H
28#include <FL/Fl.H>
29#include <FL/Fl_Double_Window.H>
30#include <FL/Fl_Group.H>
31#include <FL/Fl_Choice.H>
32#include <FL/Fl_Menu_Button.H>
33#include <FL/Fl_Button.H>
34#include <FL/Fl_Preferences.H>
35#include <FL/Fl_Tile.H>
36#include <FL/Fl_File_Browser.H>
37#include <FL/Fl_Box.H>
38#include <FL/Fl_Check_Button.H>
39#include <FL/Fl_File_Input.H>
40#include <FL/Fl_Return_Button.H>
41#include <FL/fl_ask.H>
42
43class FL_EXPORT Fl_File_Chooser {
44public:
49 enum Type {
50 SINGLE = 0,
51 MULTI = 1,
52 CREATE = 2,
55 DIRECTORY = 4
56 };
57private:
58 static Fl_Preferences *prefs_;
59 void (*callback_)(Fl_File_Chooser*, void *);
60 void *data_;
61 char directory_[FL_PATH_MAX];
62 char pattern_[FL_PATH_MAX];
63 char preview_text_[2048];
64 int type_;
65 void favoritesButtonCB();
66 void favoritesCB(Fl_Widget *w);
67 void fileListCB();
68 void fileNameCB();
69 void newdir();
70 static void previewCB(Fl_File_Chooser *fc);
71 void showChoiceCB();
72 void update_favorites();
73 void update_preview();
74public:
75 Fl_File_Chooser(const char *pathname, const char *pattern, int type_val, const char *title);
76private:
77 Fl_Double_Window *window;
78 inline void cb_window_i(Fl_Double_Window*, void*);
79 static void cb_window(Fl_Double_Window*, void*);
80 Fl_Choice *showChoice;
81 inline void cb_showChoice_i(Fl_Choice*, void*);
82 static void cb_showChoice(Fl_Choice*, void*);
83 Fl_Menu_Button *favoritesButton;
84 inline void cb_favoritesButton_i(Fl_Menu_Button*, void*);
85 static void cb_favoritesButton(Fl_Menu_Button*, void*);
86public:
88private:
89 inline void cb_newButton_i(Fl_Button*, void*);
90 static void cb_newButton(Fl_Button*, void*);
91 inline void cb__i(Fl_Tile*, void*);
92 static void cb_(Fl_Tile*, void*);
93 Fl_File_Browser *fileList;
94 inline void cb_fileList_i(Fl_File_Browser*, void*);
95 static void cb_fileList(Fl_File_Browser*, void*);
96 Fl_Box *errorBox;
97 Fl_Box *previewBox;
98public:
100private:
101 inline void cb_previewButton_i(Fl_Check_Button*, void*);
102 static void cb_previewButton(Fl_Check_Button*, void*);
103public:
105private:
106 inline void cb_showHiddenButton_i(Fl_Check_Button*, void*);
107 static void cb_showHiddenButton(Fl_Check_Button*, void*);
108 Fl_File_Input *fileName;
109 inline void cb_fileName_i(Fl_File_Input*, void*);
110 static void cb_fileName(Fl_File_Input*, void*);
111 Fl_Return_Button *okButton;
112 inline void cb_okButton_i(Fl_Return_Button*, void*);
113 static void cb_okButton(Fl_Return_Button*, void*);
114 Fl_Button *cancelButton;
115 inline void cb_cancelButton_i(Fl_Button*, void*);
116 static void cb_cancelButton(Fl_Button*, void*);
117 Fl_Double_Window *favWindow;
118 Fl_File_Browser *favList;
119 inline void cb_favList_i(Fl_File_Browser*, void*);
120 static void cb_favList(Fl_File_Browser*, void*);
121 Fl_Button *favUpButton;
122 inline void cb_favUpButton_i(Fl_Button*, void*);
123 static void cb_favUpButton(Fl_Button*, void*);
124 Fl_Button *favDeleteButton;
125 inline void cb_favDeleteButton_i(Fl_Button*, void*);
126 static void cb_favDeleteButton(Fl_Button*, void*);
127 Fl_Button *favDownButton;
128 inline void cb_favDownButton_i(Fl_Button*, void*);
129 static void cb_favDownButton(Fl_Button*, void*);
130 Fl_Button *favCancelButton;
131 inline void cb_favCancelButton_i(Fl_Button*, void*);
132 static void cb_favCancelButton(Fl_Button*, void*);
133 Fl_Return_Button *favOkButton;
134 inline void cb_favOkButton_i(Fl_Return_Button*, void*);
135 static void cb_favOkButton(Fl_Return_Button*, void*);
136public:
138 void callback(void (*cb)(Fl_File_Chooser *, void *), void *d = 0);
139 void color(Fl_Color c);
140 Fl_Color color();
141 int count();
142 void directory(const char *d);
143 char * directory();
144 void filter(const char *p);
145 const char * filter();
146 int filter_value();
147 void filter_value(int f);
148 void iconsize(uchar s);
149 uchar iconsize();
150 void label(const char *l);
151 const char * label();
152 void ok_label(const char *l);
153 const char * ok_label();
154 void preview(int e);
155 int preview() const { return previewButton->value(); }
156private:
157 void showHidden(int e);
158 void remove_hidden_files();
159public:
160 void rescan();
161 void rescan_keep_filename();
162 void show();
163 void hide();
164 int shown();
165 void textcolor(Fl_Color c);
166 Fl_Color textcolor();
167 void textfont(Fl_Font f);
168 Fl_Font textfont();
169 void textsize(Fl_Fontsize s);
170 Fl_Fontsize textsize();
171 void type(int t);
172 int type();
173 void * user_data() const;
174 void user_data(void *d);
175 const char *value(int f = 1);
176 void value(const char *filename);
177 int visible();
178 void position(int x, int y);
179 int x() const;
180 int y() const;
181 int w() const;
182 int h() const;
183 void size(int w, int h);
184 void resize(int x, int y, int w, int h);
188 static const char *add_favorites_label;
192 static const char *all_files_label;
196 static const char *custom_filter_label;
200 static const char *existing_file_label;
204 static const char *favorites_label;
208 static const char *filename_label;
212 static const char *filesystems_label;
216 static const char *manage_favorites_label;
220 static const char *new_directory_label;
224 static const char *new_directory_tooltip;
228 static const char *preview_label;
232 static const char *save_label;
236 static const char *show_label;
240 static const char *hidden_label;
246private:
247 Fl_Widget* ext_group;
248public:
249 Fl_Widget* add_extra(Fl_Widget* gr);
250protected:
251 void show_error_box(int val);
252};
253FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname,int relative=0);
254FL_EXPORT char *fl_file_chooser(const char *message,const char *pat,const char *fname,int relative=0);
255FL_EXPORT void fl_file_chooser_callback(void (*cb)(const char*));
256FL_EXPORT void fl_file_chooser_ok_label(const char*l);
257#endif
int Fl_Font
A font number is an index into the internal font table.
Definition: Enumerations.H:1054
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition: Enumerations.H:1111
int Fl_Fontsize
Size of a font in pixels.
Definition: Enumerations.H:1083
Fl static class.
Fl_Box widget.
Fl_Group and Fl_End classes.
This widget simply draws its box, and possibly its label.
Definition: Fl_Box.H:33
Buttons generate callbacks when they are clicked by the user.
Definition: Fl_Button.H:76
int value(int v)
Sets the current value of the button.
Definition: Fl_Button.cxx:40
A button with a "checkmark" to show its status.
Definition: Fl_Check_Button.H:28
A button that is used to pop up a menu.
Definition: Fl_Choice.H:104
The Fl_Double_Window provides a double-buffered window.
Definition: Fl_Double_Window.H:31
The Fl_File_Browser widget displays a list of filenames, optionally with file-specific icons.
Definition: Fl_File_Browser.H:37
The Fl_File_Chooser widget displays a standard file selection dialog that supports various selection ...
Definition: Fl_File_Chooser.H:43
static const char * preview_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:228
Fl_Check_Button * showHiddenButton
When checked, hidden files (i.e., filename begins with dot) are displayed.
Definition: Fl_File_Chooser.H:104
static const char * favorites_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:204
static const char * hidden_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:240
static const char * manage_favorites_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:216
int preview() const
Returns the current state of the preview box.
Definition: Fl_File_Chooser.H:155
static const char * new_directory_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:220
static const char * add_favorites_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:188
static const char * all_files_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:192
static const char * filesystems_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:212
static const char * filename_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:208
static const char * show_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:236
Fl_Button * newButton
The "new directory" button is exported so that application developers can control the appearance and ...
Definition: Fl_File_Chooser.H:87
static const char * custom_filter_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:196
Fl_Check_Button * previewButton
The "preview" button is exported so that application developers can control the appearance and use.
Definition: Fl_File_Chooser.H:99
static Fl_File_Sort_F * sort
the sort function that is used when loading the contents of a directory.
Definition: Fl_File_Chooser.H:245
static const char * new_directory_tooltip
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:224
Type
Determines the type of file chooser presented to the user.
Definition: Fl_File_Chooser.H:49
static const char * existing_file_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:200
static const char * save_label
[standard text may be customized at run-time]
Definition: Fl_File_Chooser.H:232
This widget displays a pathname in a text input field.
Definition: Fl_File_Input.H:45
This is a button that when pushed pops up a menu (or hierarchy of menus) defined by an array of Fl_Me...
Definition: Fl_Menu_Button.H:56
Fl_Preferences store user settings between application starts.
Definition: Fl_Preferences.H:125
The Fl_Return_Button is a subclass of Fl_Button that generates a callback when it is pressed or when ...
Definition: Fl_Return_Button.H:31
The Fl_Tile class lets you resize its children by dragging the border between them.
Definition: Fl_Tile.H:27
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:110
API for common dialogs.
unsigned char uchar
unsigned char
Definition: fl_types.h:30
#define FL_PATH_MAX
all path buffers should use this length
Definition: filename.H:45
int() Fl_File_Sort_F(struct dirent **, struct dirent **)
File sorting function.
Definition: filename.H:114
char * fl_dir_chooser(const char *message, const char *fname, int relative)
Shows a file chooser dialog and gets a directory.
Definition: fl_file_dir.cxx:184
char * fl_file_chooser(const char *message, const char *pat, const char *fname, int relative)
Shows a file chooser dialog and gets a filename.
Definition: fl_file_dir.cxx:89
void fl_file_chooser_callback(void(*cb)(const char *))
Set the file chooser callback.
Definition: fl_file_dir.cxx:58
void fl_file_chooser_ok_label(const char *l)
Set the "OK" button label.
Definition: fl_file_dir.cxx:68