MySQL Workbench  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
form.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, 2014, 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 
20 #ifndef _MFORMS_FORM_H_
21 #define _MFORMS_FORM_H_
22 
23 #include <mforms/base.h>
24 #include <mforms/view.h>
25 
26 #ifdef __APPLE__
27 #define TOP_FORM_PADDING 20
28 #else
29 #define TOP_FORM_PADDING 12
30 #endif
31 
32 namespace mforms {
33 
34  enum FormFlag
35  {
36  FormNone = 0,
37  FormSingleFrame = 1 << 0,
38  FormDialogFrame = 1 << 1,
39  FormResizable = 1 << 2,
40  FormMinimizable = 1 << 3,
41  FormHideOnClose = 1 << 4,
42  FormStayOnTop = 1 << 5,
43  FormToolWindow = 1 << 6, // Not combinable with any of the frame styles above. Also min and max
44  // are not available.
46  };
47 
48  class Form;
49  class Button;
50 
51 #ifndef DOXYGEN_SHOULD_SKIP_THIS
52 #ifndef SWIG
53  struct MFORMS_EXPORT FormImplPtrs
54  {
55  bool (*create)(Form *self, Form *owner, FormFlag flag);
56  void (*set_title)(Form *self, const std::string &title);
57  void (*show_modal)(Form *self, Button *accept, Button *cancel);
58  bool (*run_modal)(Form *self, Button *accept, Button *cancel);
59  void (*end_modal)(Form *self, bool result);
60  void (*set_content)(Form *self, View *view);
61  void (*close)(Form *self);
62 
63  void (*center)(Form *self);
64 
65  void (*flush_events)(Form *self);
66  };
67 #endif
68 #endif
69 
72  class MFORMS_EXPORT Form : public View
73  {
74  FormImplPtrs *_form_impl;
78  bool _active;
79 
80  boost::signals2::signal<void ()> _closed_signal;
81  boost::signals2::signal<void ()> _activated_signal;
82  boost::signals2::signal<void ()> _deactivated_signal;
83  protected:
84  Form();
85 
86  public:
100  virtual ~Form();
101 
103  static Form* main_form();
104 
109  virtual void set_content(View *view);
110 
113  virtual void set_title(const std::string &title);
114 
116  virtual void show_modal(Button *accept, Button *cancel);
117 
123  virtual bool run_modal(Button *accept, Button *cancel);
124 
131  virtual void end_modal(bool result);
132 
134  virtual void close();
135 
137  virtual void center();
138 
139  virtual void flush_events();
140 
142  void set_release_on_close(bool flag);
143 
144 #ifndef SWIG
145 
149  boost::signals2::signal<void ()>* signal_closed() { return &_closed_signal; }
150 
153  boost::signals2::signal<void ()>* signal_activated() { return &_activated_signal; }
154  boost::signals2::signal<void ()>* signal_deactivated() { return &_deactivated_signal; }
155 
156  void activated();
157  void deactivated();
158 #endif
159 
160  bool is_active();
161 
162  void was_closed()
163  {
164  _closed_signal();
165  if (_release_on_close)
166  release();
167  }
168 
169  };
170 };
171 
172 #endif
bool _release_on_close
Definition: form.h:77
View * _content
Definition: form.h:75
A standalone, top-level window.
Definition: form.h:72
boost::signals2::signal< void()> _activated_signal
Definition: form.h:81
#define MFORMS_EXPORT
Definition: base.h:33
boost::signals2::signal< void()> * signal_closed()
Signal sent when the user clicks the close button in the window.
Definition: form.h:149
bool _fixed_size
Definition: form.h:76
void was_closed()
Definition: form.h:162
boost::signals2::signal< void()> * signal_activated()
Signal sent when the window becomes the active window.
Definition: form.h:153
bool _active
Definition: form.h:78
FormImplPtrs * _form_impl
Definition: form.h:74
boost::signals2::signal< void()> _closed_signal
Definition: form.h:80
A clickable button control.
Definition: button.h:51
boost::signals2::signal< void()> * signal_deactivated()
Definition: form.h:154
boost::signals2::signal< void()> _deactivated_signal
Definition: form.h:82
FormFlag
Definition: form.h:34
MySQL Workbench 6.1 documentation