File: wizard.h

package info (click to toggle)
mysql-workbench 6.3.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 113,932 kB
  • ctags: 87,814
  • sloc: ansic: 955,521; cpp: 427,465; python: 59,728; yacc: 59,129; xml: 54,204; sql: 7,091; objc: 965; makefile: 638; sh: 613; java: 237; perl: 30; ruby: 6; php: 1
file content (122 lines) | stat: -rw-r--r-- 3,782 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* 
 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; version 2 of the
 * License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#pragma once

#include <mforms/form.h>
#include <vector>

namespace mforms {

  class Wizard;
  class View;
  class Form;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#ifndef SWIG
  struct MFORMS_EXPORT WizardImplPtrs
  {
    bool (*create)(Wizard *self, Form *owner);
    void (*set_title)(Wizard *self, const std::string &title);
    void (*run_modal)(Wizard *self);
    void (*close)(Wizard *self);

    void (*set_content)(Wizard *self, View *view);
    void (*set_heading)(Wizard *self, const std::string &);
    void (*set_step_list)(Wizard *self, const std::vector<std::string> &);
    void (*set_allow_cancel)(Wizard *self, bool flag);
    void (*set_allow_back)(Wizard *self, bool flag);
    void (*set_allow_next)(Wizard *self, bool flag);
    void (*set_show_extra)(Wizard *self, bool flag);
  
    void (*set_extra_caption)(Wizard *self, const std::string &);
    void (*set_next_caption)(Wizard *self, const std::string &);
  };
#endif
#endif

  class MFORMS_EXPORT Wizard : public Form
  {
    friend class ControlFactory;

    WizardImplPtrs *_wizard_impl;
    View *_content;

    Wizard();

  private:
    // hide methods from base-class that are not supported
    Wizard(Form *owner, FormFlag flag) {}
    virtual bool run_modal(Button *accept, Button *cancel) { return false; }
    virtual void show_modal(Button *accept, Button *cancel) {}
    virtual void end_modal(bool result) {}

  public:
    Wizard(Form* owner);
    virtual ~Wizard();

    virtual void set_title(const std::string &title);
    virtual void run();
    virtual void close();
    
    //!< set_content should place view as a wizard's current page.
    //!< Note: When view is 0, then content should be removed
    virtual void set_content(View *view);
    void set_heading(const std::string &text);
    //!< 1st char of each step title must be . for executed tasks, * for current and - for not executed
    void set_step_list(const std::vector<std::string> &steps);
    void set_allow_cancel(bool flag);
    void set_allow_back(bool flag);
    void set_allow_next(bool flag);
    void set_show_extra(bool flag);
    void set_extra_caption(const std::string &caption);
    void set_next_caption(const std::string &caption= "");
    
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#ifndef SWIG
    void set_cancel_handler(const boost::function<bool ()> &slot);
    boost::signals2::signal<void ()>* signal_next_clicked() { return &_next_signal; }
    boost::signals2::signal<void ()>* signal_back_clicked() { return &_back_signal; }
    boost::signals2::signal<void ()>* signal_extra_clicked() { return &_extra_signal; }

  public:
    void back_clicked()
    {
      _back_signal();
    }
    
    void next_clicked()
    {
      _next_signal();
    }
    
    void extra_clicked()
    {
      _extra_signal();
    }
    
    boost::function<bool ()> _cancel_slot;
#endif
#endif
  protected:
    boost::signals2::signal<void ()> _back_signal;
    boost::signals2::signal<void ()> _next_signal;
    boost::signals2::signal<void ()> _extra_signal;
  };
};