MySQL Workbench  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
fs_object_selector.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; version 2 of the
7  * License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17  * 02110-1301 USA
18  */
19 
25 #ifndef _FS_OBJECT_SELECTOR_H_
26 #define _FS_OBJECT_SELECTOR_H_
27 
28 #include "mforms/label.h"
29 #include "mforms/box.h"
30 #include "mforms/button.h"
31 #include "mforms/textentry.h"
32 #include "mforms/filechooser.h"
33 #include "base/trackable.h"
34 
35 namespace mforms {
36 
38  {
39  private:
43  std::string _extensions;
44  std::string _default_extension;
45  boost::function<void ()> _on_validate;
46  boost::signals2::scoped_connection _browse_connection; // The connection created when connecting the browse callback.
48  protected:
49  void enable_file_browsing();
50  void filename_changed();
51  void browse_file_callback();
52 
53  public:
54  FsObjectSelector(bool horizontal= true);
55  FsObjectSelector(Button* button, TextEntry* edit);
57 
58  void initialize(const std::string& initial_path, FileChooserType type, const std::string& extensions,
59  const std::string& button_text= "...", bool show_hidden = false,
60  boost::function<void ()> on_validate= boost::function<void ()>());
61  void set_filename(const std::string &path);
62  std::string get_filename();
63  void set_enabled(bool value);
64  void set_browse_callback(boost::function<void ()> browse_callback);
65 
66  TextEntry *get_entry() const { return _edit; }
67 
68  virtual std::string get_string_value();
69  virtual int get_int_value();
70  virtual bool get_bool_value();
71 
72 #ifndef SWIG
73  boost::signals2::signal<void ()>* signal_changed() { return _edit->signal_changed(); }
74 #endif
75 
76  static void clear_stored_filenames();
77  static bool check_and_confirm_file_overwrite(TextEntry* entry, const std::string &default_extension="");
78  bool check_and_confirm_file_overwrite();
79  };
80 
81 }
82 
83 #endif // _FS_OBJECT_SELECTOR_H_
Places child views sequentially in a vertical or horizontal layout.
Definition: box.h:50
#define MFORMS_EXPORT
Definition: base.h:33
boost::function< void()> _on_validate
Single line text edit control, with support for some special events.
Definition: textentry.h:66
TextEntry * get_entry() const
A clickable button control.
Definition: button.h:51
boost::signals2::signal< void()> * signal_changed()
FileChooserType
Definition: filechooser.h:28
boost::signals2::scoped_connection _browse_connection
MySQL Workbench 6.1 documentation