Boost.UI
User Interface Boost library
combo_box.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Kolya Kosenko
2 
3 // Distributed under the Boost Software License, Version 1.0.
4 // See http://www.boost.org/LICENSE_1_0.txt
5 
7 
8 #ifndef BOOST_UI_COMBO_BOX_HPP
9 #define BOOST_UI_COMBO_BOX_HPP
10 
11 #include <boost/ui/config.hpp>
12 
13 #ifdef BOOST_HAS_PRAGMA_ONCE
14 #pragma once
15 #endif
16 
17 #include <boost/ui/strings_box.hpp>
18 
19 namespace boost {
20 namespace ui {
21 
28 
29 class BOOST_UI_DECL combo_box : public strings_box
30 {
31 public:
32  combo_box() {}
33 
35  explicit combo_box(widget& parent)
36  { create(parent); }
37 
38  combo_box& create(widget& parent);
40 
42  explicit combo_box(widget& parent, const uistring& text)
43  { create(parent, text); }
44 
45  combo_box& create(widget& parent, const uistring& text)
46  { return create(parent, text, std::vector<uistring>()); }
48 
50  explicit combo_box(widget& parent, const std::vector<uistring>& options)
51  { create(parent, options); }
52 
53  combo_box& create(widget& parent, const std::vector<uistring>& options)
54  { return create(parent, uistring(), options); }
55 
56  template <class Iterator>
57  explicit combo_box(widget& parent, Iterator first, Iterator last)
58  { create(parent, first, last); }
59 
60  template <class Iterator>
61  combo_box& create(widget& parent, Iterator first, Iterator last)
62  { return create(parent, std::vector<uistring>(first, last)); }
63 
64  template <class Range>
65  explicit combo_box(widget& parent, const Range& r)
66  { create(parent, r); }
67 
68  template <class Range>
69  combo_box& create(widget& parent, const Range& r)
70  { return create(parent, detail::range_to_vector_uistring(r)); }
71 
72 #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
73  template <class T>
74  explicit combo_box(widget& parent, std::initializer_list<T> list)
75  { create(parent, list); }
76 
77  template <class T>
78  combo_box& create(widget& parent, std::initializer_list<T> list)
79  { return create(parent, detail::initializer_list_to_vector_uistring(list)); }
80 #endif
81 
84  explicit combo_box(widget& parent, const uistring& text,
85  const std::vector<uistring>& options)
86  { create(parent, text, options); }
87 
88  combo_box& create(widget& parent, const uistring& text, const std::vector<uistring>& options);
89 
90  template <class Range>
91  explicit combo_box(widget& parent, const uistring& text, const Range& r)
92  { create(parent, text, r); }
93 
94  template <class Range>
95  combo_box& create(widget& parent, const uistring& text, const Range& r)
96  { return create(parent, text, detail::range_to_vector_uistring(r)); }
97 
98 #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
99  template <class T>
100  explicit combo_box(widget& parent, const uistring& text, std::initializer_list<T> list)
101  { create(parent, text, list); }
102 
103  template <class T>
104  combo_box& create(widget& parent, const uistring& text, std::initializer_list<T> list)
105  { return create(parent, text, detail::initializer_list_to_vector_uistring(list)); }
106 #endif
107 
110  combo_box& text(const uistring& txt);
111 
113  uistring text() const;
114 
116  BOOST_UI_DETAIL_HANDLER(select, combo_box);
117  BOOST_UI_DETAIL_HANDLER_EVENT(select_event, combo_box, index_event);
119 
120 private:
121  void on_select_raw(const boost::function<void()>& handler);
122  void on_select_event_raw(const boost::function<void(index_event&)>& handler);
123 
124  class detail_impl;
125  detail_impl* get_impl();
126  const detail_impl* get_impl() const;
127 };
128 
129 } // namespace ui
130 } // namespace boost
131 
132 #endif // BOOST_UI_COMBO_BOX_HPP
boost::ui::uistring
Helper class to convert string between UI and application logic only.
Definition: string.hpp:49
boost::ui::combo_box::combo_box
combo_box(widget &parent, Iterator first, Iterator last)
Creates combo box widget with options and without initial text.
Definition: combo_box.hpp:57
boost::ui::combo_box::create
combo_box & create(widget &parent, const uistring &text, std::initializer_list< T > list)
Creates combo_box widget with options and initial text.
Definition: combo_box.hpp:104
boost::ui::combo_box::create
combo_box & create(widget &parent, const std::vector< uistring > &options)
Creates combo box widget with options and without initial text.
Definition: combo_box.hpp:53
boost::ui::combo_box::create
combo_box & create(widget &parent, const uistring &text, const Range &r)
Creates combo_box widget with options and initial text.
Definition: combo_box.hpp:95
config.hpp
Configuration options.
boost::ui::combo_box::create
combo_box & create(widget &parent, Iterator first, Iterator last)
Creates combo box widget with options and without initial text.
Definition: combo_box.hpp:61
boost::ui::combo_box::combo_box
combo_box(widget &parent, const uistring &text)
Creates combo box widget without options and with initial text.
Definition: combo_box.hpp:42
boost::ui::combo_box::combo_box
combo_box(widget &parent, const uistring &text, const Range &r)
Creates combo_box widget with options and initial text.
Definition: combo_box.hpp:91
boost::ui::index_event
Event class that holds some index in container.
Definition: event.hpp:55
boost::ui::combo_box::combo_box
combo_box(widget &parent)
Creates empty combo box widget.
Definition: combo_box.hpp:35
boost
Boost C++ libraries namespace.
Definition: window.hpp:19
boost::ui::combo_box::create
combo_box & create(widget &parent, const Range &r)
Creates combo box widget with options and without initial text.
Definition: combo_box.hpp:69
boost::ui::combo_box::create
combo_box & create(widget &parent, const uistring &text)
Creates combo box widget without options and with initial text.
Definition: combo_box.hpp:45
boost::ui::combo_box::combo_box
combo_box(widget &parent, const std::vector< uistring > &options)
Creates combo box widget with options and without initial text.
Definition: combo_box.hpp:50
boost::ui::combo_box::combo_box
combo_box(widget &parent, const uistring &text, std::initializer_list< T > list)
Creates combo_box widget with options and initial text.
Definition: combo_box.hpp:100
boost::ui::combo_box
Widget to select one or more strings and edit it.
Definition: combo_box.hpp:29
boost::ui::combo_box::create
combo_box & create(widget &parent, std::initializer_list< T > list)
Creates combo box widget with options and without initial text.
Definition: combo_box.hpp:78
boost::ui::combo_box::combo_box
combo_box(widget &parent, std::initializer_list< T > list)
Creates combo box widget with options and without initial text.
Definition: combo_box.hpp:74
boost::ui::combo_box::combo_box
combo_box(widget &parent, const uistring &text, const std::vector< uistring > &options)
Creates combo_box widget with options and initial text.
Definition: combo_box.hpp:84
boost::ui::strings_box
Abstract widget that holds array of strings.
Definition: strings_box.hpp:71
boost::ui::widget
Base class for all widgets.
Definition: widget.hpp:45
boost::ui::combo_box::combo_box
combo_box(widget &parent, const Range &r)
Creates combo box widget with options and without initial text.
Definition: combo_box.hpp:65
strings_box.hpp
Widget with array of strings.