The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
common_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 #ifndef COMMON_PALETTES_H_INCLUDED
16 #define COMMON_PALETTES_H_INCLUDED
17 
18 #include "display.hpp"
19 #include "gui/widgets/widget.hpp"
20 
21 struct SDL_Rect;
22 class config;
23 namespace editor {
24 class editor_display;
25 
26 /**
27  * Stores the info about the groups in a nice format.
28  */
29 struct item_group
30 {
31  item_group(const config& cfg):
32  id(cfg["id"]), name(cfg["name"].t_str()),
33  icon(cfg["icon"]), core(cfg["core"].to_bool()) {}
34 
38  bool core;
39 };
40 
41 
42 class common_palette : public gui::widget {
43 
44 public:
45 
46  common_palette(display& gui) : gui::widget(gui.video(), true) {}
47 
48  virtual ~common_palette() {}
49 
50  //event handling
51 
53 
54 
55  /** Scroll the editor-palette up one step if possible. */
56  virtual bool scroll_up() = 0;
57  virtual bool can_scroll_up() = 0;
58 
59  /** Scroll the editor-palette down one step if possible. */
60  virtual bool scroll_down() = 0;
61  virtual bool can_scroll_down() = 0;
62 
63  //drawing
64  virtual void adjust_size(const SDL_Rect& target) = 0;
65  virtual void draw() = 0;
66 
67  //group
68  virtual void set_group(size_t index) = 0;
69  virtual void next_group() = 0;
70  virtual void prev_group() = 0;
71  virtual const std::vector<item_group>& get_groups() const = 0;
72 
73  /** Menu expanding for palette group list */
74  virtual void expand_palette_groups_menu(std::vector<std::string>& items) = 0;
75  virtual void expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& items) = 0;
76 
77  //item
78  virtual int num_items() = 0;
79  virtual size_t start_num() = 0;
80  virtual void set_start_item(size_t index) = 0;
81 
82  virtual bool supports_swap() { return true; }
83  virtual void swap() = 0;
84 
85  virtual std::vector<std::string> action_pressed() const { return std::vector<std::string>(); }
86 };
87 
88 // a palette containing tristtate buttons.
90 {
91 public:
93  : common_palette(gui)
94  {
95  }
96  virtual void select_fg_item(const std::string& item_id) = 0;
97  virtual void select_bg_item(const std::string& item_id) = 0;
98 };
99 
100 }
101 
102 #endif
virtual bool supports_swap()
virtual void draw()=0
std::vector< events::sdl_handler * > sdl_handler_vector
Definition: events.hpp:163
Stores the info about the groups in a nice format.
virtual void prev_group()=0
virtual void select_bg_item(const std::string &item_id)=0
virtual bool can_scroll_down()=0
CVideo & video() const
Definition: widget.hpp:83
General purpose widgets.
virtual void next_group()=0
const std::vector< std::string > items
common_palette(display &gui)
virtual void swap()=0
virtual void select_fg_item(const std::string &item_id)=0
virtual const std::vector< item_group > & get_groups() const =0
item_group(const config &cfg)
virtual bool scroll_up()=0
Scroll the editor-palette up one step if possible.
virtual bool can_scroll_up()=0
GLuint id
Definition: glew.h:1647
virtual int num_items()=0
map_display and display: classes which take care of displaying the map and game-data on the screen...
Manage the empty-palette in the editor.
Definition: action.cpp:28
virtual sdl_handler_vector handler_members()
virtual void expand_palette_groups_menu(std::vector< std::string > &items)=0
Menu expanding for palette group list.
virtual void adjust_size(const SDL_Rect &target)=0
GLuint index
Definition: glew.h:1782
GLuint const GLchar * name
Definition: glew.h:1782
virtual bool scroll_down()=0
Scroll the editor-palette down one step if possible.
tristate_palette(display &gui)
virtual void set_start_item(size_t index)=0
virtual std::vector< std::string > action_pressed() const
virtual void set_group(size_t index)=0
widget(widget const &o)
Definition: widget.cpp:35
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503
virtual size_t start_num()=0
GLenum target
Definition: glew.h:5190