Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class choice

boost::ui::choice — Widget to select string from popup list of strings.

Synopsis

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


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

  // public member functions
  uistring text() const;
  index_type current_selection_index() const;

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

Description

Usage example:

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

See Also:

Drop-down list (Wikipedia)

choice public construct/copy/destruct

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

choice public member functions

  1. uistring text() const;
    Returns text that is associated this widget.
  2. index_type current_selection_index() const;
    Returns index of the selected text item. If widget has no items then returns npos.

choice 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. detail_impl * get_impl();
  4. const detail_impl * get_impl() const;

PrevUpHomeNext