-
-
Notifications
You must be signed in to change notification settings - Fork 990
/
wmi_pager.hpp
51 lines (39 loc) · 1.91 KB
/
wmi_pager.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Copyright (C) 2014 by Chris Beck <render787@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
/** This class manages the paging of WML menu items results, from a
* container. It is an adapter, managing the production of items lists
* from the container, and screening the "fire" signals coming back
* in to intercept the paging signals.
*
* TODO: Implement this as a helper class for menu perhaps, so that it
* can interact with the gui layout algorithm.
*/
struct map_location;
namespace game_events { class wml_menu_item; }
namespace game_events { class wmi_container; }
#include "global.hpp"
#include <boost/shared_ptr.hpp>
#include <string>
#include <vector>
class wmi_pager {
private:
int page_num_; //!< Current page number
const game_events::wmi_container * foo_; //!< Internal pointer to the collection of wml menu items
public:
wmi_pager() : page_num_(0), foo_(NULL) {}
void update_ref(game_events::wmi_container * ptr) { foo_ = ptr; } //!< Updates the internal wmi_container pointer
/** Adds the currently paged range of menu items to the given lists */
void get_items(const map_location& hex, //!< Game hex related to this context menu
std::vector<boost::shared_ptr<const game_events::wml_menu_item> > & items, //!< List of accumulated menu items so far.
std::vector<std::string> & descriptions); //!< List of menu item descriptions
bool capture(const game_events::wml_menu_item & item); //!< Captures a page up / page down event in the case that it is fired.
};