MySQL Workbench  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
selector.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 
20 #ifndef _MFORMS_POPUPSELECT_H_
21 #define _MFORMS_POPUPSELECT_H_
22 
23 #include <mforms/view.h>
24 
25 
26 namespace mforms {
27  class Selector;
28 
30  {
33  };
35 
36 #ifndef DOXYGEN_SHOULD_SKIP_THIS
37 #ifndef SWIG
38  struct SelectorImplPtrs
39  {
40  bool (*create)(Selector *self, SelectorStyle style);
41  void (*clear)(Selector *self);
42  void (*add_items)(Selector *self, const std::list<std::string> &items);
43  int (*add_item)(Selector *self, const std::string &item);
44  std::string (*get_item)(Selector *self, int index);
45  std::string (*get_text)(Selector *self);
46  void (*set_index)(Selector *self, int index);
47  int (*get_index)(Selector *self);
48  int (*get_item_count)(Selector *self);
49  void (*set_value)(Selector *self, const std::string& value);
50  };
51 #endif
52 #endif
53 
55  class MFORMS_EXPORT Selector : public View
56  {
57  public:
63 
65  void clear();
67  int add_item(const std::string &item);
69  void add_items(const std::list<std::string> &items);
70 
72  std::string get_item_title(int i);
73 
75  void set_selected(int index);
77  int index_of_item_with_title(const std::string &title);
78 
80  virtual std::string get_string_value();
82  int get_selected_index();
83 
84  // set_value methods sets control text to the given value if selector is of type SelectorCombo,
85  // otherwise shortcuts to set_selected(index_of_item_with_title)
86  void set_value(const std::string& value);
87 
89  int get_item_count();
90 
91 #ifndef SWIG
92 
93  boost::signals2::signal<void ()>* signal_changed() { return &_signal_changed; }
94 
95  public:
96 #ifndef DOXYGEN_SHOULD_SKIP_THIS
97  void callback();
98 #endif
99 #endif
100  protected:
101  SelectorImplPtrs *_selector_impl;
102  boost::signals2::signal<void ()> _signal_changed;
103  bool _updating;
104  bool _editable;
105  };
106 };
107 
108 #endif
The value list is shown when clicking the arrow. The value is freely editable.
Definition: selector.h:31
SelectorStyle
Definition: selector.h:29
#define MFORMS_EXPORT
Definition: base.h:33
boost::signals2::signal< void()> _signal_changed
Definition: selector.h:102
boost::signals2::signal< void()> * signal_changed()
Signal emitted when selected item changes.
Definition: selector.h:93
The value list is shown when clicking the arrow.
Definition: selector.h:32
SelectorImplPtrs * _selector_impl
Definition: selector.h:101
A button (or text entry) with a popup menu that allows selection of a single item.
Definition: selector.h:55
MySQL Workbench 6.1 documentation