The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
location_palette.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[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 
18 #include "common_palette.hpp"
19 #include "tristate_button.hpp"
20 
23 
24 namespace editor {
25 
27 
28 public:
29 
30  location_palette(editor_display &gui, const config& /*cfg*/, mouse_action** active_mouse_action);
31 
32 
34 
35  void set_start_item(size_t index) { items_start_ = index; }
36 
37  size_t start_num(void) { return items_start_; }
38 
39  /** Menu expanding for palette group list */
40  void expand_palette_groups_menu(std::vector< std::pair<std::string, std::string> >&) override {}
41  void expand_palette_groups_menu(std::vector<std::string>&) override {}
42 
43  virtual void set_group(size_t /*index*/) override {}
44  virtual void next_group() override {}
45  virtual void prev_group() override {}
46  virtual const std::vector<item_group>& get_groups() const override { static const std::vector<item_group> empty; return empty; }
47 
48  virtual void draw() {
49  widget::draw();
50  }
51  virtual void draw_contents();
52 
53  /**
54  * Update the size of this widget.
55  *
56  * Use if the size_specs have changed.
57  */
58  void adjust_size(const SDL_Rect& target);
59 
60  virtual bool scroll_up();
61  virtual bool can_scroll_up();
62  virtual bool scroll_down();
63  virtual bool can_scroll_down();
64 
65  void swap() override {}
66  bool can_swap() { return false; }
67 
68  virtual std::string get_help_string() { return ""; }
69 
70  /** Return the currently selected item. */
71  const std::string& selected_item() const { return selected_item_; }
72 
73  virtual void select_item(const std::string& item_id);
74  virtual std::vector<std::string> action_pressed() const override;
75  void add_item(const std::string& id);
77  void hide(bool hidden) override;
78 
79 private:
80 
81  /** Scroll the editor-palette to the top. */
82  void scroll_top();
83 
84  /** Scroll the editor-palette to the bottom. */
85  void scroll_bottom();
86 
87  virtual bool is_selected_item(const std::string& id);
88 
89  /** Return the number of items in the palette. */
90  int num_items();
91  /** Return the maximum number of items shown at the same time. */
92  int num_visible_items();
93 protected:
94 
96 
98  // the heigh of a row, the size of an item including borders.
100 
101 private:
102  unsigned int palette_y_;
103  unsigned int palette_x_;
104 
105 protected:
106  //the current scrolling position
108 
109 private:
111  std::vector<std::string> items_;
113  boost::ptr_vector<location_palette_item> buttons_;
114  std::unique_ptr<location_palette_button> button_add_;
115  std::unique_ptr<location_palette_button> button_delete_;
116  std::unique_ptr<location_palette_button> button_goto_;
119 };
120 
121 
122 } //end namespace editor
123 
void scroll_bottom()
Scroll the editor-palette to the bottom.
void set_start_item(size_t index)
void expand_palette_groups_menu(std::vector< std::pair< std::string, std::string > > &) override
Menu expanding for palette group list.
std::vector< events::sdl_handler * > sdl_handler_vector
Definition: events.hpp:163
void expand_palette_groups_menu(std::vector< std::string > &) override
Menu expanding for palette group list.
virtual bool scroll_up()
Scroll the editor-palette up one step if possible.
boost::ptr_vector< location_palette_item > buttons_
General purpose widgets.
virtual bool is_selected_item(const std::string &id)
virtual std::vector< std::string > action_pressed() const override
mouse_action ** active_mouse_action_
std::unique_ptr< location_palette_button > button_goto_
const std::string & selected_item() const
Return the currently selected item.
bool hidden() const
Definition: widget.cpp:198
virtual const std::vector< item_group > & get_groups() const override
location_palette(editor_display &gui, const config &, mouse_action **active_mouse_action)
void adjust_size(const SDL_Rect &target)
Update the size of this widget.
virtual sdl_handler_vector handler_members()
void draw(surface screen)
virtual std::string get_help_string()
Manage the empty-palette in the editor.
Definition: action.cpp:28
int num_visible_items()
Return the maximum number of items shown at the same time.
virtual void prev_group() override
void add_item(const std::string &id)
GLuint index
Definition: glew.h:1782
std::unique_ptr< location_palette_button > button_add_
virtual void next_group() override
std::unique_ptr< location_palette_button > button_delete_
void scroll_top()
Scroll the editor-palette to the top.
virtual bool scroll_down()
Scroll the editor-palette down one step if possible.
virtual void select_item(const std::string &item_id)
virtual void set_group(size_t) override
A mouse action receives events from the controller, and responds to them by creating an appropriate e...
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
int num_items()
Return the number of items in the palette.
GLsizei const GLcharARB ** string
Definition: glew.h:4503
void hide(bool hidden) override
std::vector< std::string > items_
GLenum target
Definition: glew.h:5190