The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
drop_down_list.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include "gui/dialogs/dialog.hpp"
18 #include "sdl/rect.hpp"
19 
20 namespace gui2
21 {
22 ///Used by the combobox widget.
23 class tdrop_down_list : public tdialog
24 {
25 public:
26  tdrop_down_list(SDL_Rect button_pos, const std::vector<std::string>& items, int selected_item, bool use_markup)
27  : button_pos_(button_pos)
28  , items_(items)
29  , selected_item_(selected_item)
30  , use_markup_(use_markup)
31  {
32  }
33  int selected_item() const { return selected_item_; }
34 private:
35  /// The screen location of the combobox button that triggred this droplist.
36  /// Note: we don't adjust the location of this dialog to when resizing the window.
37  /// Instead this dialog automatically closes itself on resizing.
38  SDL_Rect button_pos_;
39  std::vector<std::string> items_;
42  /** Inherited from tdialog, implemented by REGISTER_DIALOG. */
43  virtual const std::string& window_id() const;
44 
45  /** Inherited from tdialog. */
46  void pre_show(twindow& window);
47 
48  /** Inherited from tdialog. */
49  void post_show(twindow& window);
50 
51  void item_change_callback(twindow& window, size_t item);
52 };
53 
54 } // namespace gui2
std::vector< std::string > items_
void item_change_callback(twindow &window, size_t item)
SDL_Rect button_pos_
The screen location of the combobox button that triggred this droplist.
tdrop_down_list(SDL_Rect button_pos, const std::vector< std::string > &items, int selected_item, bool use_markup)
Used by the combobox widget.
const std::vector< std::string > items
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
Abstract base class for all dialogs.
Definition: dialog.hpp:121
virtual const std::string & window_id() const
Inherited from tdialog, implemented by REGISTER_DIALOG.
void pre_show(twindow &window)
Inherited from tdialog.
void post_show(twindow &window)
Inherited from tdialog.
Contains the SDL_Rect helper code.
int selected_item() const
GLsizei const GLcharARB ** string
Definition: glew.h:4503