The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
image.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2016 by Mark de Wever <[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 GUI_WIDGETS_IMAGE_HPP_INCLUDED
16 #define GUI_WIDGETS_IMAGE_HPP_INCLUDED
17 
18 #include "gui/widgets/control.hpp"
19 
22 
23 namespace gui2
24 {
25 
26 // ------------ WIDGET -----------{
27 
28 /** An image. */
29 class timage : public tcontrol
30 {
31 public:
33  {
34  }
35 
36  /**
37  * Wrapper for set_label.
38  *
39  * Some people considered this function missing and confusing so added
40  * this forward version.
41  *
42  * @param label The filename image to show.
43  */
44  void set_image(const t_string& label)
45  {
46  set_label(label);
47  }
48 
49  /**
50  * Wrapper for label.
51  *
52  * Some people considered this function missing and confusing so added
53  * this forward version.
54  *
55  * @returns The filename of the image shown.
56  */
58  {
59  return label();
60  }
61 
62  virtual bool can_mouse_focus() const override { return false; }
63 
64  /***** ***** ***** ***** layout functions ***** ***** ***** *****/
65 
66 private:
67  /** See @ref twidget::calculate_best_size. */
68  virtual tpoint calculate_best_size() const override;
69 
70 public:
71  /***** ***** ***** ***** Inherited ***** ***** ***** *****/
72 
73  /** See @ref tcontrol::set_active. */
74  virtual void set_active(const bool active) override;
75 
76  /** See @ref tcontrol::get_active. */
77  virtual bool get_active() const override;
78 
79  /** See @ref tcontrol::get_state. */
80  virtual unsigned get_state() const override;
81 
82  /** See @ref twidget::disable_click_dismiss. */
83  bool disable_click_dismiss() const override;
84 
85 private:
86  /**
87  * Possible states of the widget.
88  *
89  * Note the order of the states must be the same as defined in settings.hpp.
90  */
91  enum tstate {
94  };
95 
96  /** See @ref tcontrol::get_control_type. */
97  virtual const std::string& get_control_type() const override;
98 };
99 
100 // }---------- DEFINITION ---------{
101 
103 {
104  explicit timage_definition(const config& cfg);
105 
107  {
108  explicit tresolution(const config& cfg);
109  };
110 };
111 
112 // }---------- BUILDER -----------{
113 
114 namespace implementation
115 {
116 
118 {
119  explicit tbuilder_image(const config& cfg);
120 
122 
123  twidget* build() const;
124 };
125 
126 } // namespace implementation
127 
128 // }------------ END --------------
129 
130 } // namespace gui2
131 
132 #endif
tstate
Possible states of the widget.
Definition: image.hpp:91
void set_image(const t_string &label)
Wrapper for set_label.
Definition: image.hpp:44
tresolution(const config &cfg)
Definition: image.cpp:132
Base class of a resolution, contains the common keys for a resolution.
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
timage_definition(const config &cfg)
Definition: image.cpp:101
virtual twidget * build() const =0
const t_string & label() const
Definition: control.hpp:248
t_string get_image() const
Wrapper for label.
Definition: image.hpp:57
virtual bool can_mouse_focus() const override
Whether the mouse move/click event go 'through' this widget.
Definition: image.hpp:62
Holds a 2D point.
Definition: point.hpp:24
Base class for all visible items.
Definition: control.hpp:34
tbuilder_image(const config &cfg)
Definition: image.cpp:165
Base class for all widgets.
Definition: widget.hpp:49
static void set_label(twindow &window, const std::string &id, const std::string &label)
Definition: unit_attack.cpp:89
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
Contains the implementation details for lexical_cast and shouldn't be used directly.