The Battle for Wesnoth  1.19.10+dev
scroll_label.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2025
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
19 #include "gui/widgets/label.hpp"
20 
23 
24 namespace gui2
25 {
26 
27 // ------------ WIDGET -----------{
28 
29 class label;
30 class spacer;
31 
32 namespace implementation
33 {
34 struct builder_scroll_label;
35 }
36 
38 {
40 
41 public:
42  explicit scroll_label(const implementation::builder_scroll_label& builder);
43 
44  /** See @ref styled_widget::set_label. */
45  virtual void set_label(const t_string& label) override;
46 
47  /** See @ref styled_widget::set_text_alignment. */
48  virtual void set_text_alignment(const PangoAlignment text_alignment) override;
49 
50  /** See @ref styled_widget::set_use_markup. */
51  virtual void set_use_markup(bool use_markup) override;
52 
53  /** See @ref container_base::set_self_active. */
54  virtual void set_self_active(const bool active) override;
55 
56  /***** ***** ***** setters / getters for members ***** ****** *****/
57 
58  /** See @ref styled_widget::get_active. */
59  virtual bool get_active() const override;
60 
61  /** See @ref styled_widget::get_state. */
62  virtual unsigned get_state() const override;
63 
64  bool can_wrap() const override;
65  void set_can_wrap(bool can_wrap);
66 
67  void set_text_alpha(unsigned short alpha);
68 
69  /** See @ref styled_widget::get_link_aware. */
70  virtual bool get_link_aware() const override
71  {
72  return link_aware_;
73  }
74 
75  void set_link_aware(bool l);
76 
77 private:
78  /**
79  * Possible states of the widget.
80  *
81  * Note the order of the states must be the same as defined in settings.hpp.
82  */
83  enum state_t {
86  };
87 
88  // It's not needed for now so keep it disabled, no definition exists yet.
89  // void set_state(const state_t state);
90 
91  /**
92  * Current state of the widget.
93  *
94  * The state of the widget determines what to render and how the widget
95  * reacts to certain 'events'.
96  */
98 
99  bool wrap_on_;
100 
101  PangoAlignment text_alignment_;
102 
104 
105  void finalize_subclass() override;
106 
108 
109 public:
110  /** Static type getter that does not rely on the widget being constructed. */
111  static const std::string& type();
112 
113 private:
114  /***** ***** ***** inherited ****** *****/
115 
116  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
117  virtual const std::string& get_control_type() const override;
118 
119  /***** ***** ***** signal handlers ***** ****** *****/
120 
122 };
123 
124 // }---------- DEFINITION ---------{
125 
127 {
128  explicit scroll_label_definition(const config& cfg);
129 
131  {
132  explicit resolution(const config& cfg);
133 
135  };
136 };
137 
138 // }---------- BUILDER -----------{
139 
140 namespace implementation
141 {
142 
144 {
145  explicit builder_scroll_label(const config& cfg);
146 
148 
149  virtual std::unique_ptr<widget> build() const override;
150 
153  bool wrap_on;
154  const PangoAlignment text_alignment;
156 };
157 
158 } // namespace implementation
159 
160 // }------------ END --------------
161 
162 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:158
virtual bool get_active() const override
See styled_widget::get_active.
void set_can_wrap(bool can_wrap)
void signal_handler_left_button_down(const event::ui_event event)
bool can_wrap() const override
See widget::can_wrap.
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
virtual void set_label(const t_string &label) override
See styled_widget::set_label.
virtual void set_text_alignment(const PangoAlignment text_alignment) override
See styled_widget::set_text_alignment.
state_t
Possible states of the widget.
virtual bool get_link_aware() const override
See styled_widget::get_link_aware.
void set_text_alpha(unsigned short alpha)
virtual void set_use_markup(bool use_markup) override
See styled_widget::set_use_markup.
void finalize_subclass() override
Function for the subclasses to do their setup.
label * get_internal_label()
scroll_label(const implementation::builder_scroll_label &builder)
void set_link_aware(bool l)
state_t state_
Current state of the widget.
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
virtual unsigned get_state() const override
See styled_widget::get_state.
PangoAlignment text_alignment_
virtual void set_self_active(const bool active) override
See container_base::set_self_active.
Base class for creating containers with one or two scrollbar(s).
scrollbar_mode
The way to handle the showing or hiding of the scrollbar.
std::string label
What to show in the filter's drop-down list.
Definition: manager.cpp:201
ui_event
The event sent to the dispatcher.
Definition: handler.hpp:115
Generic file dialog.
std::shared_ptr< builder_grid > builder_grid_ptr
Contains the implementation details for lexical_cast and shouldn't be used directly.
scrollbar_container::scrollbar_mode vertical_scrollbar_mode
scrollbar_container::scrollbar_mode horizontal_scrollbar_mode
virtual std::unique_ptr< widget > build() const override
virtual std::unique_ptr< widget > build() const=0
scroll_label_definition(const config &cfg)