Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class list_box

boost::ui::list_box — Widget to select one or more strings.

Synopsis

// In header: <boost/ui/list_box.hpp>


class list_box : public boost::ui::strings_box {
public:
  // construct/copy/destruct
  explicit list_box(widget &);
  explicit list_box(widget &, const std::vector< uistring > &);
  template<typename Iterator> explicit list_box(widget &, Iterator, Iterator);
  template<typename Range> explicit list_box(widget &, const Range &);
  template<typename T> explicit list_box(widget &, std::initializer_list< T >);
  list_box();

  // public member functions
  bool has_selection() const;
  size_type selected_index() const;
  uistring selected_string() const;

  // private member functions
  void on_select_raw(const boost::function< void()> &);
  void on_select_event_raw(const boost::function< void(index_event &)> &);
  void on_activate_raw(const boost::function< void()> &);
  void on_activate_event_raw(const boost::function< void(index_event &)> &);
  detail_impl * get_impl();
  const detail_impl * get_impl() const;
};

Description

Usage example:

ui::list_box list_box = ui::list_box(parent,
    { "Option 1", "Option 2", "Option 3" })
    .on_select_event([&](ui::index_event& e)
    {
        ui::log::info() << "Selected option index: " << e.index();
    })
    .on_activate_event([&](ui::index_event& e)
    {
        ui::log::info() << "Activated option index: " << e.index();
    })
    ;

See Also:

List box (Wikipedia)

list_box public construct/copy/destruct

  1. explicit list_box(widget & parent);
    Creates empty list_box widget.
  2. explicit list_box(widget & parent, const std::vector< uistring > & options);
    Creates list_box widget with options.
  3. template<typename Iterator> 
      explicit list_box(widget & parent, Iterator first, Iterator last);
    Creates list_box widget with options.
  4. template<typename Range> explicit list_box(widget & parent, const Range & r);
    Creates list_box widget with options.
  5. template<typename T> 
      explicit list_box(widget & parent, std::initializer_list< T > list);
    Creates list_box widget with options.
  6. list_box();

list_box public member functions

  1. bool has_selection() const;
    Returns true if list_box has selected options, false otherwise.
  2. size_type selected_index() const;
    Returns index of the selected option. If list_box has no selected options then returns npos.
  3. uistring selected_string() const;
    Returns selected option string.

list_box private member functions

  1. void on_select_raw(const boost::function< void()> & handler);
  2. void on_select_event_raw(const boost::function< void(index_event &)> & handler);
  3. void on_activate_raw(const boost::function< void()> & handler);
  4. void on_activate_event_raw(const boost::function< void(index_event &)> & handler);
  5. detail_impl * get_impl();
  6. const detail_impl * get_impl() const;

PrevUpHomeNext