Boost.UI
User Interface Boost library
list_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_LIST_BOX_HPP
9 #define BOOST_UI_LIST_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 list_box : public strings_box
30 {
31 public:
32  list_box() {}
33 
35  explicit list_box(widget& parent)
36  { create(parent); }
37  list_box& create(widget& parent);
39 
41  explicit list_box(widget& parent, const std::vector<uistring>& options)
42  { create(parent, options); }
43 
44  list_box& create(widget& parent, const std::vector<uistring>& options);
45 
46  template <class Iterator>
47  explicit list_box(widget& parent, Iterator first, Iterator last)
48  { create(parent, first, last); }
49 
50  template <class Iterator>
51  list_box& create(widget& parent, Iterator first, Iterator last)
52  { return create(parent, std::vector<uistring>(first, last)); }
53 
54  template <class Range>
55  explicit list_box(widget& parent, const Range& r)
56  { create(parent, r); }
57 
58  template <class Range>
59  list_box& 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 list_box(widget& parent, std::initializer_list<T> list)
65  { create(parent, list); }
66 
67  template <class T>
68  list_box& create(widget& parent, std::initializer_list<T> list)
69  { return create(parent, detail::initializer_list_to_vector_uistring(list)); }
70 #endif
71 
74  bool has_selection() const
75  { return selected_index() != npos; }
76 
78  size_type selected_index() const;
79 
81  uistring selected_string() const;
82 
84  BOOST_UI_DETAIL_HANDLER(select, list_box);
85  BOOST_UI_DETAIL_HANDLER_EVENT(select_event, list_box, index_event);
87 
89  BOOST_UI_DETAIL_HANDLER(activate, list_box);
90  BOOST_UI_DETAIL_HANDLER_EVENT(activate_event, list_box, index_event);
92 
93 private:
94  void on_select_raw(const boost::function<void()>& handler);
95  void on_select_event_raw(const boost::function<void(index_event&)>& handler);
96 
97  void on_activate_raw(const boost::function<void()>& handler);
98  void on_activate_event_raw(const boost::function<void(index_event&)>& handler);
99 
100  class detail_impl;
101  detail_impl* get_impl();
102  const detail_impl* get_impl() const;
103 };
104 
105 } // namespace ui
106 } // namespace boost
107 
108 #endif // BOOST_UI_LIST_BOX_HPP
boost::ui::uistring
Helper class to convert string between UI and application logic only.
Definition: string.hpp:49
boost::ui::list_box::create
list_box & create(widget &parent, const Range &r)
Creates list_box widget with options.
Definition: list_box.hpp:59
boost::ui::list_box::list_box
list_box(widget &parent, const std::vector< uistring > &options)
Creates list_box widget with options.
Definition: list_box.hpp:41
config.hpp
Configuration options.
boost::ui::index_event
Event class that holds some index in container.
Definition: event.hpp:55
boost
Boost C++ libraries namespace.
Definition: window.hpp:19
boost::ui::list_box::list_box
list_box(widget &parent, const Range &r)
Creates list_box widget with options.
Definition: list_box.hpp:55
boost::ui::list_box::list_box
list_box(widget &parent, Iterator first, Iterator last)
Creates list_box widget with options.
Definition: list_box.hpp:47
boost::ui::list_box::create
list_box & create(widget &parent, Iterator first, Iterator last)
Creates list_box widget with options.
Definition: list_box.hpp:51
boost::ui::list_box::list_box
list_box(widget &parent)
Creates empty list_box widget.
Definition: list_box.hpp:35
boost::ui::list_box::has_selection
bool has_selection() const
Returns true if list_box has selected options, false otherwise.
Definition: list_box.hpp:74
boost::ui::list_box::list_box
list_box(widget &parent, std::initializer_list< T > list)
Creates list_box widget with options.
Definition: list_box.hpp:64
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::list_box::create
list_box & create(widget &parent, std::initializer_list< T > list)
Creates list_box widget with options.
Definition: list_box.hpp:68
boost::ui::list_box
Widget to select one or more strings.
Definition: list_box.hpp:29
strings_box.hpp
Widget with array of strings.