MySQL Workbench  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
filechooser.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, 2013, 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 #ifndef _MFILECHOOSERS_FILECHOOSER_H_
20 #define _MFILECHOOSERS_FILECHOOSER_H_
21 
22 #include "base/file_utilities.h"
23 #include <mforms/base.h>
24 #include <mforms/view.h>
25 #include <vector>
26 
27 namespace mforms {
29  {
33  };
34 
35  class Form;
36  class FileChooser;
37 
38 #ifndef DOXYGEN_SHOULD_SKIP_THIS
39 #ifndef SWIG
40  struct MFORMS_EXPORT FileChooserImplPtrs
41  {
42  bool (*create)(FileChooser *self, mforms::Form *owner, FileChooserType type, bool show_hidden);
43  void (*set_title)(FileChooser *self, const std::string &title);
44  bool (*run_modal)(FileChooser *self);
45  void (*set_directory)(FileChooser *self, const std::string &path);
46  void (*set_path)(FileChooser *self, const std::string &path);//TODO windows
47  std::string (*get_directory)(FileChooser *self);
48  std::string (*get_path)(FileChooser *self);
49  void (*set_extensions)(FileChooser *self, const std::string &extensions, const std::string &default_extension);
50 
51  void (*add_selector_option)(FileChooser *self, const std::string &name,
52  const std::string &label, const std::vector<std::pair<std::string, std::string> > &options);//TODO windows
53  std::string (*get_selector_option_value)(FileChooser *self, const std::string &name); //TODO windows
54  };
55 #endif
56 #endif
57 
61  {
62  FileChooserImplPtrs *_filechooser_impl;
63 
64  public:
65  typedef std::vector<std::pair<std::string, std::string> > StringPairVector;
66 
67  // keeps a mapping of option name -> list of value identifiers
68  std::map<std::string, std::vector<std::string> > _selector_options;
69  StringPairVector split_extensions(const std::string &extensions, bool file_extensions=true);
70 
71  public:
77  FileChooser(FileChooserType, bool show_hidden = false);
78  FileChooser(mforms::Form *owner, FileChooserType, bool show_hidden = false);
79 
81  virtual void set_title(const std::string &title);
82 
86  virtual bool run_modal();
87 
89  void set_directory(const std::string &path);
90 
92  void set_path(const std::string &path);
93 
95  std::string get_path();
96 
98  std::string get_directory();
99 
105  void set_extensions(const std::string &extensions, const std::string &default_extension);
106 
109  void add_selector_option(const std::string &name, const std::string &label, const StringPairVector &options);
112  void add_selector_option(const std::string &name, const std::string &label, const std::string &options);
114  std::string get_selector_option_value(const std::string &name);
115 
116  static std::string last_directory;
117  };
118 };
119 #endif
A standalone, top-level window.
Definition: form.h:72
static std::string last_directory
Definition: filechooser.h:116
#define MFORMS_EXPORT
Definition: base.h:33
A File Picker dialog.
Definition: filechooser.h:60
FileChooserImplPtrs * _filechooser_impl
Definition: filechooser.h:62
std::map< std::string, std::vector< std::string > > _selector_options
Definition: filechooser.h:68
std::vector< std::pair< std::string, std::string > > StringPairVector
Definition: filechooser.h:65
FileChooserType
Definition: filechooser.h:28
MySQL Workbench 6.1 documentation