The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
scroll_label.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_SCROLL_LABEL_HPP_INCLUDED
16 #define GUI_WIDGETS_SCROLL_LABEL_HPP_INCLUDED
17 
19 
22 
23 namespace gui2
24 {
25 
26 // ------------ WIDGET -----------{
27 
28 class tlabel;
29 class tspacer;
30 
31 namespace implementation
32 {
33 struct tbuilder_scroll_label;
34 }
35 
36 /**
37  * Label showing a text.
38  *
39  * This version shows a scrollbar if the text gets too long and has some
40  * scrolling features. In general this widget is slower as the normal label so
41  * the normal label should be preferred.
42  */
44 {
46 
47 public:
48  tscroll_label(bool wrap);
49 
50  /** See @ref tcontrol::set_label. */
51  virtual void set_label(const t_string& label) override;
52 
53  /** See @ref tcontrol::set_use_markup. */
54  virtual void set_use_markup(bool use_markup) override;
55 
56  /** See @ref tcontainer_::set_self_active. */
57  virtual void set_self_active(const bool active) override;
58 
59  /***** ***** ***** setters / getters for members ***** ****** *****/
60 
61  /** See @ref tcontrol::get_active. */
62  virtual bool get_active() const override;
63 
64  /** See @ref tcontrol::get_state. */
65  virtual unsigned get_state() const override;
66 
67  bool can_wrap() const;
68  void set_can_wrap(bool can_wrap);
69 
70 private:
71  /**
72  * Possible states of the widget.
73  *
74  * Note the order of the states must be the same as defined in settings.hpp.
75  */
76  enum tstate {
80  };
81 
82  // It's not needed for now so keep it disabled, no definition exists yet.
83  // void set_state(const tstate state);
84 
85  /**
86  * Current state of the widget.
87  *
88  * The state of the widget determines what to render and how the widget
89  * reacts to certain 'events'.
90  */
92  bool wrap_on;
93 
94  void finalize_subclass();
95 
96  /***** ***** ***** inherited ****** *****/
97 
98  /** See @ref tcontrol::get_control_type. */
99  virtual const std::string& get_control_type() const override;
100 
101  /***** ***** ***** signal handlers ***** ****** *****/
102 
104 };
105 
106 // }---------- DEFINITION ---------{
107 
109 {
110  explicit tscroll_label_definition(const config& cfg);
111 
113  {
114  explicit tresolution(const config& cfg);
115 
117  };
118 };
119 
120 // }---------- BUILDER -----------{
121 
122 namespace implementation
123 {
124 
126 {
127  explicit tbuilder_scroll_label(const config& cfg);
128 
130 
131  twidget* build() const;
132 
135  bool wrap_on;
136 };
137 
138 } // namespace implementation
139 
140 // }------------ END --------------
141 
142 } // namespace gui2
143 
144 #endif
tscroll_label(bool wrap)
virtual bool get_active() const override
See tcontrol::get_active.
void signal_handler_left_button_down(const event::tevent event)
tscrollbar_container::tscrollbar_mode vertical_scrollbar_mode
void set_can_wrap(bool can_wrap)
tscrollbar_container::tscrollbar_mode horizontal_scrollbar_mode
tscroll_label_definition(const config &cfg)
tstate state_
Current state of the widget.
virtual void set_use_markup(bool use_markup) override
See tcontrol::set_use_markup.
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
virtual twidget * build() const =0
virtual void set_label(const t_string &label) override
See tcontrol::set_label.
tstate
Possible states of the widget.
tscrollbar_mode
The way to handle the showing or hiding of the scrollbar.
const t_string & label() const
Definition: control.hpp:248
tevent
The event send to the dispatcher.
Definition: handler.hpp:54
Label showing a text.
virtual const std::string & get_control_type() const override
See tcontrol::get_control_type.
cl_event event
Definition: glew.h:3070
void finalize_subclass()
Function for the subclasses to do their setup.
Base class for all widgets.
Definition: widget.hpp:49
virtual unsigned get_state() const override
See tcontrol::get_state.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
bool can_wrap() const
See twidget::can_wrap.
virtual void set_self_active(const bool active) override
See tcontainer_::set_self_active.
GLsizei const GLcharARB ** string
Definition: glew.h:4503
Contains the implementation details for lexical_cast and shouldn't be used directly.
Base class for creating containers with one or two scrollbar(s).