The Battle for Wesnoth  1.19.4+dev
scroll_label.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
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  void set_link_aware(bool l);
70 
71  void set_text_max_width(int max_width) {
72  label* text_label = get_internal_label();
73  if (text_label) {
74  text_label->set_text_maximum_width(max_width);
75  }
76  }
77 
78 private:
79  /**
80  * Possible states of the widget.
81  *
82  * Note the order of the states must be the same as defined in settings.hpp.
83  */
84  enum state_t {
87  };
88 
89  // It's not needed for now so keep it disabled, no definition exists yet.
90  // void set_state(const state_t state);
91 
92  /**
93  * Current state of the widget.
94  *
95  * The state of the widget determines what to render and how the widget
96  * reacts to certain 'events'.
97  */
99 
100  bool wrap_on_;
101 
102  PangoAlignment text_alignment_;
103 
105 
106  void finalize_subclass() override;
107 
109 
110 public:
111  /** Static type getter that does not rely on the widget being constructed. */
112  static const std::string& type();
113 
114 private:
115  /***** ***** ***** inherited ****** *****/
116 
117  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
118  virtual const std::string& get_control_type() const override;
119 
120  /***** ***** ***** signal handlers ***** ****** *****/
121 
123 };
124 
125 // }---------- DEFINITION ---------{
126 
128 {
129  explicit scroll_label_definition(const config& cfg);
130 
132  {
133  explicit resolution(const config& cfg);
134 
136  };
137 };
138 
139 // }---------- BUILDER -----------{
140 
141 namespace implementation
142 {
143 
145 {
146  explicit builder_scroll_label(const config& cfg);
147 
149 
150  virtual std::unique_ptr<widget> build() const override;
151 
154  bool wrap_on;
155  const PangoAlignment text_alignment;
157 };
158 
159 } // namespace implementation
160 
161 // }------------ END --------------
162 
163 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
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.
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.
void set_text_max_width(int max_width)
Base class for creating containers with one or two scrollbar(s).
scrollbar_mode
The way to handle the showing or hiding of the scrollbar.
void set_text_maximum_width(int max_width)
Set how wide the text can become.
std::string label
What to show in the filter's drop-down list.
Definition: manager.cpp:199
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)