libt3widget
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules
filedialog.h
1 /* Copyright (C) 2011-2012 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_WIDGET_FILEDIALOG_H
15 #define T3_WIDGET_FILEDIALOG_H
16 
17 #include <t3widget/interfaces.h>
18 #include <t3widget/dialogs/dialog.h>
19 #include <t3widget/widgets/filepane.h>
20 #include <t3widget/widgets/button.h>
21 #include <t3widget/widgets/checkbox.h>
22 #include <t3widget/widgets/frame.h>
23 
24 namespace t3_widget {
25 
26 class T3_WIDGET_API file_dialog_t : public dialog_t {
27  private:
28  struct T3_WIDGET_LOCAL implementation_t {
29  file_name_list_t names;
31  std::string current_dir, lang_codeset_filter;
32 
33  int name_offset;
34 
35  file_pane_t *file_pane;
36  frame_t *file_pane_frame;
37  text_field_t *file_line;
38  button_t *cancel_button, *ok_button;
39  checkbox_t *show_hidden_box;
40  smart_label_t *show_hidden_label;
41  bool option_widget_set;
42  sigc::connection cancel_button_up_connection, ok_button_up_connection;
43 
44  implementation_t(void) : view(&names), option_widget_set(false) {}
45  };
46  pimpl_ptr<implementation_t>::t impl;
47 
48  protected:
49  file_dialog_t(int height, int width, const char *_title);
50 
51  widget_t *get_anchor_widget(void);
52  void insert_extras(widget_t *widget);
53  void ok_callback(void);
54  void ok_callback(const std::string *file);
55  virtual const std::string *get_filter(void) = 0;
56 
57  public:
58  virtual bool set_size(optint height, optint width);
59  void change_dir(const std::string *dir);
60  virtual int set_file(const char *file);
61  void refresh_view(void);
62  void set_options_widget(widget_t *options);
63  virtual void reset(void);
64 
65  T3_WIDGET_SIGNAL(file_selected, void, const std::string *);
66 };
67 
68 class T3_WIDGET_API open_file_dialog_t : public file_dialog_t {
69  private:
70  class T3_WIDGET_API filter_text_field_t : public text_field_t {
71  public:
72  virtual void set_focus(focus_t _focus);
73  T3_WIDGET_SIGNAL(lose_focus, void);
74  };
75 
76  struct implementation_t {
77  int filter_offset,
78  filter_width;
79  filter_text_field_t *filter_line;
80  smart_label_t *filter_label;
81  };
82  pimpl_ptr<implementation_t>::t impl;
83 
84  virtual const std::string *get_filter(void);
85 
86  public:
87  open_file_dialog_t(int height, int width);
88  virtual bool set_size(optint height, optint width);
89  virtual void reset(void);
90 };
91 
92 
93 class T3_WIDGET_API save_as_dialog_t : public file_dialog_t {
94  private:
95  static std::string empty_filter;
96 
97  struct implementation_t {
98  button_t *create_button;
99  };
100  pimpl_ptr<implementation_t>::t impl;
101 
102  protected:
103  virtual const std::string *get_filter(void) { return &empty_filter; }
104  public:
105  save_as_dialog_t(int height, int width);
106  void create_folder(void);
107 };
108 
109 }; // namespace
110 #endif
Implementation of the file_list_t interface.
Definition: contentlist.h:79
The t3_widget namespace is contains all classes, functions and global variables in the libt3widget li...
Definition: autocompleter.cc:18
Definition: smartlabel.h:38
A widget displaying the contents of a directory.
Definition: filepane.h:30
Class implementing a checkbox.
Definition: checkbox.h:23
Definition: textfield.h:27
Base class for widgets.
Definition: widget.h:24
Definition: filedialog.h:26
Definition: filedialog.h:93
Definition: filedialog.h:68
Class defining values with a separate validity check.
Definition: util.h:29
Button widget.
Definition: button.h:23
A widget showing a frame.
Definition: frame.h:26
Base class for dialogs.
Definition: dialog.h:27
Filted file list implementation.
Definition: contentlist.h:208