The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
empty_palette.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2016 by Fabian Mueller <[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  * Manage the empty-palette in the editor.
17  */
18 
19 #ifndef EMPTY_PALETTE_H_INCLUDED
20 #define EMPTY_PALETTE_H_INCLUDED
21 
22 #include "editor_palettes.hpp"
23 
24 namespace editor {
25 
26 /** Empty palette */
27 class empty_palette : public common_palette {
28 
29 public:
30 
32  common_palette(gui),
33  gui_(gui), empty_() {}
34 
35  //event handling
36  virtual bool mouse_click() { return false;}
37 
38  virtual bool scroll_up() { return false;}
39  virtual bool can_scroll_up() { return false;}
40  virtual bool scroll_down() { return false;}
41  virtual bool can_scroll_down() { return false;}
42 
43  //drawing
44  virtual void adjust_size(const SDL_Rect& /*target*/) {}
45  virtual void draw() {}
46 
47  void hide(bool hidden) {
48  if (!hidden) {
49  std::shared_ptr<gui::button> upscroll_button = gui_.find_action_button("upscroll-button-editor");
50  upscroll_button->enable(false);
51  std::shared_ptr<gui::button> downscroll_button = gui_.find_action_button("downscroll-button-editor");
52  downscroll_button->enable(false);
53  std::shared_ptr<gui::button> palette_menu_button = gui_.find_menu_button("menu-editor-terrain");
54  palette_menu_button->set_overlay("");
55  palette_menu_button->enable(false);
56  } else {
57  std::shared_ptr<gui::button> upscroll_button = gui_.find_action_button("upscroll-button-editor");
58  upscroll_button->enable(true);
59  std::shared_ptr<gui::button> downscroll_button = gui_.find_action_button("downscroll-button-editor");
60  downscroll_button->enable(true);
61  std::shared_ptr<gui::button> palette_menu_button = gui_.find_menu_button("menu-editor-terrain");
62  palette_menu_button->enable(true);
63  }
64  }
65 
66  std::vector<gui::widget>* get_widgets() { return nullptr; }
67 
68  //group
69  virtual void set_group(size_t /*index*/) {}
70  virtual void next_group() {}
71  virtual void prev_group() {}
72  virtual const std::vector<item_group>& get_groups() const { return empty_; }
73 
74  /** Menu expanding for palette group list */
75  virtual void expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& /*items*/) {}
76  virtual void expand_palette_groups_menu(std::vector< std::string> & /*items*/) {}
77 
78  //item
79  virtual int num_items() {return 0;}
80  virtual size_t start_num() {return 0;}
81  virtual void set_start_item(size_t /*index*/) {}
82  virtual bool supports_swap() { return false; }
83  virtual void swap() {}
84 
85 private:
87  std::vector<item_group> empty_;
88 };
89 
90 
91 }
92 #endif
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
Definition: display.cpp:826
virtual bool supports_swap()
std::vector< gui::widget > * get_widgets()
virtual int num_items()
virtual size_t start_num()
virtual bool can_scroll_down()
virtual void set_group(size_t)
General purpose widgets.
virtual void expand_palette_groups_menu(std::vector< std::string > &)
Menu expanding for palette group list.
virtual bool scroll_up()
Scroll the editor-palette up one step if possible.
virtual void adjust_size(const SDL_Rect &)
void hide(bool hidden)
bool hidden() const
Definition: widget.cpp:198
virtual void prev_group()
virtual void expand_palette_groups_menu(std::vector< std::pair< std::string, std::string > > &)
Menu expanding for palette group list.
virtual bool mouse_click()
Manage the empty-palette in the editor.
Definition: action.cpp:28
virtual const std::vector< item_group > & get_groups() const
virtual void set_start_item(size_t)
std::vector< item_group > empty_
virtual bool scroll_down()
Scroll the editor-palette down one step if possible.
empty_palette(display &gui)
virtual bool can_scroll_up()
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
Definition: display.cpp:836
virtual void next_group()