MySQL Workbench  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
listbox.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 #ifndef _MFORMS_LISTBOX_H_
20 #define _MFORMS_LISTBOX_H_
21 
22 #include <mforms/view.h>
23 
24 #include <vector>
25 
26 namespace mforms {
27  class ListBox;
28 
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 #ifndef SWIG
31  struct ListBoxImplPtrs
32  {
33  bool (*create)(ListBox *self, bool multi_select);
34  void (*clear)(ListBox *self);
35  void (*set_heading)(ListBox *self, const std::string &text);
36  void (*add_items)(ListBox *self, const std::list<std::string> &items);
37  int (*add_item)(ListBox *self, const std::string &item);
38  void (*remove_indexes)(ListBox *self, const std::vector<int> &indexes);
39  void (*remove_index)(ListBox *self, int index);
40  std::string (*get_text)(ListBox *self);
41  void (*set_index)(ListBox *self, int index);
42  int (*get_index)(ListBox *self);
43  std::vector<int> (*get_selected_indices)(ListBox* self);
44  };
45 #endif
46 #endif
47 
49  class MFORMS_EXPORT ListBox : public View
50  {
51  public:
56  ListBox(bool multi);
57 
59  void clear();
61  void set_heading(const std::string &text);
62 
64  int add_item(const std::string &item);
65 
67  void add_items(const std::list<std::string> &items);
68 
70  void remove_index(int index);
71 
74  void remove_indexes(const std::vector<int> &indexes);
75 
77  void set_selected(int index);
78 
80  virtual std::string get_string_value();
81 
83  int get_selected_index();
84 
86  std::vector<int> get_selected_indices(); // For multi selection lists.
87 
88 #ifndef SWIG
89 
93  boost::signals2::signal<void ()>* signal_changed() { return &_signal_changed; }
94 
95 #ifndef DOXYGEN_SHOULD_SKIP_THIS
96  public:
97  void selection_changed();
98 #endif
99 #endif
100  protected:
101  ListBoxImplPtrs *_listbox_impl;
102 
103  boost::signals2::signal<void ()> _signal_changed;
104 
105  bool _updating;
106  };
107 };
108 
109 #endif
ListBoxImplPtrs * _listbox_impl
Definition: listbox.h:101
boost::signals2::signal< void()> _signal_changed
Definition: listbox.h:103
boost::signals2::signal< void()> * signal_changed()
Signal emitted when the selection changes.
Definition: listbox.h:93
#define MFORMS_EXPORT
Definition: base.h:33
A list control with a single column and multiple rows.
Definition: listbox.h:49
bool _updating
Definition: listbox.h:105
MySQL Workbench 6.1 documentation