The Battle for Wesnoth  1.15.2+dev
scroll_label.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://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 
21 
22 namespace gui2
23 {
24 
25 // ------------ WIDGET -----------{
26 
27 class label;
28 class spacer;
29 
30 namespace implementation
31 {
32 struct builder_scroll_label;
33 }
34 
35 /**
36  * Label showing a text.
37  *
38  * This version shows a scrollbar if the text gets too long and has some
39  * scrolling features. In general this widget is slower as the normal label so
40  * the normal label should be preferred.
41  */
43 {
45 
46 public:
47  explicit scroll_label(const implementation::builder_scroll_label& builder);
48 
49  /** See @ref styled_widget::set_label. */
50  virtual void set_label(const t_string& label) override;
51 
52  /** See @ref styled_widget::set_text_alignment. */
53  virtual void set_text_alignment(const PangoAlignment text_alignment) override;
54 
55  /** See @ref styled_widget::set_use_markup. */
56  virtual void set_use_markup(bool use_markup) override;
57 
58  /** See @ref container_base::set_self_active. */
59  virtual void set_self_active(const bool active) override;
60 
61  /***** ***** ***** setters / getters for members ***** ****** *****/
62 
63  /** See @ref styled_widget::get_active. */
64  virtual bool get_active() const override;
65 
66  /** See @ref styled_widget::get_state. */
67  virtual unsigned get_state() const override;
68 
69  bool can_wrap() const override;
70  void set_can_wrap(bool can_wrap);
71 
72  void set_text_alpha(unsigned short alpha);
73 
74  void set_link_aware(bool l);
75 
76 private:
77  /**
78  * Possible states of the widget.
79  *
80  * Note the order of the states must be the same as defined in settings.hpp.
81  */
82  enum state_t {
85  };
86 
87  // It's not needed for now so keep it disabled, no definition exists yet.
88  // void set_state(const state_t state);
89 
90  /**
91  * Current state of the widget.
92  *
93  * The state of the widget determines what to render and how the widget
94  * reacts to certain 'events'.
95  */
97 
98  bool wrap_on_;
99 
100  PangoAlignment text_alignment_;
101 
102  void finalize_subclass() override;
103 
104  label* get_internal_label();
105 
106 public:
107  /** Static type getter that does not rely on the widget being constructed. */
108  static const std::string& type();
109 
110 private:
111  /***** ***** ***** inherited ****** *****/
112 
113  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
114  virtual const std::string& get_control_type() const override;
115 
116  /***** ***** ***** signal handlers ***** ****** *****/
117 
118  void signal_handler_left_button_down(const event::ui_event event);
119 };
120 
121 // }---------- DEFINITION ---------{
122 
124 {
125  explicit scroll_label_definition(const config& cfg);
126 
128  {
129  explicit resolution(const config& cfg);
130 
132  };
133 };
134 
135 // }---------- BUILDER -----------{
136 
137 namespace implementation
138 {
139 
141 {
142  explicit builder_scroll_label(const config& cfg);
143 
145 
146  widget* build() const;
147 
150  bool wrap_on;
151  const PangoAlignment text_alignment;
152 };
153 
154 } // namespace implementation
155 
156 // }------------ END --------------
157 
158 } // namespace gui2
Base class of a resolution, contains the common keys for a resolution.
virtual widget * build() const =0
PangoAlignment text_alignment_
Base class for all widgets.
Definition: widget.hpp:47
Label showing a text.
Definition: label.hpp:32
state_t
Possible states of the widget.
Generic file dialog.
Definition: field-fwd.hpp:22
state_t state_
Current state of the widget.
Label showing a text.
Base class for creating containers with one or two scrollbar(s).
window * build(const builder_window::window_resolution *definition)
Builds a window.
scrollbar_mode
The way to handle the showing or hiding of the scrollbar.
scrollbar_container::scrollbar_mode vertical_scrollbar_mode
point resolution()
Definition: general.cpp:373
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
scrollbar_container::scrollbar_mode horizontal_scrollbar_mode
std::shared_ptr< builder_grid > builder_grid_ptr
Contains the implementation details for lexical_cast and shouldn&#39;t be used directly.
ui_event
The event send to the dispatcher.
Definition: handler.hpp:55