The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
wmi_pager.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by Chris Beck <[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 
16 /** This class manages the paging of WML menu items results, from a
17  * container. It is an adapter, managing the production of items lists
18  * from the container, and screening the "fire" signals coming back
19  * in to intercept the paging signals.
20  *
21  * TODO: Implement this as a helper class for menu perhaps, so that it
22  * can interact with the gui layout algorithm.
23  */
24 
25 class filter_context;
26 class game_data;
27 class game_state;
28 struct map_location;
29 class unit_map;
30 namespace game_events { class wml_menu_item; }
31 namespace game_events { class wmi_container; }
32 
33 #include "global.hpp"
34 
35 #include <boost/shared_ptr.hpp>
36 #include <string>
37 #include <vector>
38 
39 class wmi_pager {
40 private:
41  int page_num_; //!< Current page number
42  const game_events::wmi_container * wmi_container_; //!< Internal pointer to the collection of wml menu items
43 
44 public:
45  wmi_pager() : page_num_(0), wmi_container_(nullptr) {}
46 
47  void update_ref(game_events::wmi_container * ptr) { wmi_container_ = ptr; } //!< Updates the internal wmi_container pointer
48 
49  /** Adds the currently paged range of menu items to the given lists */
50  void get_items(const map_location& hex, //!< Game hex related to this context menu
51  game_data & gamedata, filter_context & fc, unit_map & units, //!< Data needed to create scoped objects when evaluating wml filters
52  std::vector<boost::shared_ptr<const game_events::wml_menu_item> > & items, //!< List of accumulated menu items so far.
53  std::vector<std::string> & descriptions); //!< List of menu item descriptions
54 
55  bool capture(const game_events::wml_menu_item & item); //!< Captures a page up / page down event in the case that it is fired.
56 };
const std::vector< std::string > items
game_data * gamedata
Definition: resources.cpp:22
const game_events::wmi_container * wmi_container_
Internal pointer to the collection of wml menu items.
Definition: wmi_pager.hpp:42
void update_ref(game_events::wmi_container *ptr)
Updates the internal wmi_container pointer.
Definition: wmi_pager.hpp:47
int page_num_
Current page number.
Definition: wmi_pager.hpp:41
Encapsulates the map of the game.
Definition: location.hpp:38
Domain specific events.
Definition: action_wml.cpp:93
void get_items(const map_location &hex, game_data &gamedata, filter_context &fc, unit_map &units, std::vector< boost::shared_ptr< const game_events::wml_menu_item > > &items, std::vector< std::string > &descriptions)
Adds the currently paged range of menu items to the given lists.
Definition: wmi_pager.cpp:84
A container of wml_menu_item.
Container associating units to locations.
Definition: map.hpp:90
bool capture(const game_events::wml_menu_item &item)
Captures a page up / page down event in the case that it is fired.
Definition: wmi_pager.cpp:58
unit_map * units
Definition: resources.cpp:35