Boost.UI
User Interface Boost library
choice.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_CHOICE_HPP
9 #define BOOST_UI_CHOICE_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 choice : public strings_box
30 {
31 public:
32  choice() {}
33 
35  explicit choice(widget& parent)
36  { create(parent); }
37  choice& create(widget& parent);
39 
41  explicit choice(widget& parent, const std::vector<uistring>& options)
42  { create(parent, options); }
43 
44  choice& create(widget& parent, const std::vector<uistring>& options);
45 
46  template <class Iterator>
47  explicit choice(widget& parent, Iterator first, Iterator last)
48  { create(parent, first, last); }
49 
50  template <class Iterator>
51  choice& create(widget& parent, Iterator first, Iterator last)
52  { return create(parent, std::vector<uistring>(first, last)); }
53 
54  template <class Range>
55  explicit choice(widget& parent, const Range& r)
56  { create(parent, r); }
57 
58  template <class Range>
59  choice& create(widget& parent, const Range& r)
60  { return create(parent, detail::range_to_vector_uistring(r)); }
61 
62 #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
63  template <class T>
64  explicit choice(widget& parent, std::initializer_list<T> list)
65  { create(parent, list); }
66 
67  template <class T>
68  choice& create(widget& parent, std::initializer_list<T> list)
69  { return create(parent, detail::initializer_list_to_vector_uistring(list)); }
70 #endif
71 
74  uistring text() const;
75 
77  index_type current_selection_index() const;
78 
80  BOOST_UI_DETAIL_HANDLER(select, choice);
81  BOOST_UI_DETAIL_HANDLER_EVENT(select_event, choice, index_event);
83 
84 private:
85  void on_select_raw(const boost::function<void()>& handler);
86  void on_select_event_raw(const boost::function<void(index_event&)>& handler);
87 
88  class detail_impl;
89  detail_impl* get_impl();
90  const detail_impl* get_impl() const;
91 };
92 
93 } // namespace ui
94 } // namespace boost
95 
96 #endif // BOOST_UI_CHOICE_HPP
boost::ui::uistring
Helper class to convert string between UI and application logic only.
Definition: string.hpp:49
boost::ui::choice::choice
choice(widget &parent, std::initializer_list< T > list)
Creates choice widget with options.
Definition: choice.hpp:64
boost::ui::choice::choice
choice(widget &parent, const std::vector< uistring > &options)
Creates choice widget with options.
Definition: choice.hpp:41
config.hpp
Configuration options.
boost::ui::choice::choice
choice(widget &parent, Iterator first, Iterator last)
Creates choice widget with options.
Definition: choice.hpp:47
boost::ui::index_event
Event class that holds some index in container.
Definition: event.hpp:55
boost::ui::choice::choice
choice(widget &parent)
Creates empty choice widget.
Definition: choice.hpp:35
boost
Boost C++ libraries namespace.
Definition: window.hpp:19
boost::ui::choice::create
choice & create(widget &parent, Iterator first, Iterator last)
Creates choice widget with options.
Definition: choice.hpp:51
boost::ui::choice
Widget to select string from popup list of strings.
Definition: choice.hpp:29
boost::ui::choice::create
choice & create(widget &parent, std::initializer_list< T > list)
Creates choice widget with options.
Definition: choice.hpp:68
boost::ui::choice::create
choice & create(widget &parent, const Range &r)
Creates choice widget with options.
Definition: choice.hpp:59
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::index_type
int index_type
Integral type for indexing items.
Definition: event.hpp:45
boost::ui::choice::choice
choice(widget &parent, const Range &r)
Creates choice widget with options.
Definition: choice.hpp:55
strings_box.hpp
Widget with array of strings.