MySQL Workbench  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
wizard.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, 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 _MFORMS_WIZARD_H_
20 #define _MFORMS_WIZARD_H_
21 
22 #include <mforms/form.h>
23 #include <vector>
24 
25 namespace mforms {
26 
27  class Wizard;
28  class View;
29  class Form;
30 
31 #ifndef DOXYGEN_SHOULD_SKIP_THIS
32 #ifndef SWIG
33  struct MFORMS_EXPORT WizardImplPtrs
34  {
35  bool (*create)(Wizard *self, Form *owner);
36  void (*set_title)(Wizard *self, const std::string &title);
37  void (*run_modal)(Wizard *self);
38  void (*close)(Wizard *self);
39 
40  void (*set_content)(Wizard *self, View *view);
41  void (*set_heading)(Wizard *self, const std::string &);
42  void (*set_step_list)(Wizard *self, const std::vector<std::string> &);
43  void (*set_allow_cancel)(Wizard *self, bool flag);
44  void (*set_allow_back)(Wizard *self, bool flag);
45  void (*set_allow_next)(Wizard *self, bool flag);
46  void (*set_show_extra)(Wizard *self, bool flag);
47 
48  void (*set_extra_caption)(Wizard *self, const std::string &);
49  void (*set_next_caption)(Wizard *self, const std::string &);
50  };
51 #endif
52 #endif
53 
54  class MFORMS_EXPORT Wizard : public Form
55  {
56  friend class ControlFactory;
57 
58  WizardImplPtrs *_wizard_impl;
60 
61  Wizard();
62 
63  private:
64  // hide methods from base-class that are not supported
65  Wizard(Form *owner, FormFlag flag) {}
66  virtual bool run_modal(Button *accept, Button *cancel) { return false; }
67  virtual void show_modal(Button *accept, Button *cancel) {}
68  virtual void end_modal(bool result) {}
69 
70  public:
71  Wizard(Form* owner);
72  virtual ~Wizard();
73 
74  virtual void set_title(const std::string &title);
75  virtual void run();
76  virtual void close();
77 
80  virtual void set_content(View *view);
81  void set_heading(const std::string &text);
83  void set_step_list(const std::vector<std::string> &steps);
84  void set_allow_cancel(bool flag);
85  void set_allow_back(bool flag);
86  void set_allow_next(bool flag);
87  void set_show_extra(bool flag);
88  void set_extra_caption(const std::string &caption);
89  void set_next_caption(const std::string &caption= "");
90 
91 #ifndef DOXYGEN_SHOULD_SKIP_THIS
92 #ifndef SWIG
93  void set_cancel_handler(const boost::function<bool ()> &slot);
94  boost::signals2::signal<void ()>* signal_next_clicked() { return &_next_signal; }
95  boost::signals2::signal<void ()>* signal_back_clicked() { return &_back_signal; }
96  boost::signals2::signal<void ()>* signal_extra_clicked() { return &_extra_signal; }
97 
98  public:
99  void back_clicked()
100  {
101  _back_signal();
102  }
103 
104  void next_clicked()
105  {
106  _next_signal();
107  }
108 
109  void extra_clicked()
110  {
111  _extra_signal();
112  }
113 
114  boost::function<bool ()> _cancel_slot;
115 #endif
116 #endif
117  protected:
118  boost::signals2::signal<void ()> _back_signal;
119  boost::signals2::signal<void ()> _next_signal;
120  boost::signals2::signal<void ()> _extra_signal;
121  };
122 };
123 
124 #endif
125 
virtual bool run_modal(Button *accept, Button *cancel)
Shows the window as a modal window.
Definition: wizard.h:66
boost::signals2::signal< void()> _back_signal
Definition: wizard.h:118
virtual void show_modal(Button *accept, Button *cancel)
Deprecated.
Definition: wizard.h:67
View * _content
Definition: wizard.h:59
A standalone, top-level window.
Definition: form.h:72
virtual void end_modal(bool result)
Ends a modal session started with run_modal()
Definition: wizard.h:68
Wizard(Form *owner, FormFlag flag)
Definition: wizard.h:65
#define MFORMS_EXPORT
Definition: base.h:33
WizardImplPtrs * _wizard_impl
Definition: wizard.h:58
boost::signals2::signal< void()> _extra_signal
Definition: wizard.h:120
A clickable button control.
Definition: button.h:51
boost::signals2::signal< void()> _next_signal
Definition: wizard.h:119
FormFlag
Definition: form.h:34
MySQL Workbench 6.1 documentation