lecui 1.0.0-alpha.20
lecui C++ user interface library
html_editor.h
1//
2// html_editor.h - html editor widget interface
3//
4// lecui user interface library, part of the liblec library
5// Copyright (c) 2019 Alec Musasa (alecmus at live dot com)
6//
7// Released under the MIT license. For full details see the
8// file LICENSE.txt
9//
10
11#pragma once
12
13#if defined(LECUI_EXPORTS)
14#include "widget.h"
15#else
16#include <liblec/lecui/widgets/widget.h>
17#endif
18
19namespace liblec {
20 namespace lecui {
21 namespace widgets {
24 class lecui_api html_editor : public widget {
25 float _border = .5f;
26 float _control_border = .5f;
27 color _color_border;
28 float _corner_radius_x = 3.f;
29 float _corner_radius_y = 3.f;
30 color _color_caret;
31 color _color_control_border;
32
34 color _color_control_fill;
35
37
38 void* _p_controls_pane_specs = nullptr;
39 void* _p_html_pane_specs = nullptr;
40 lecui::rect _rect_widget_overall = { 0, 0, 0, 0 };
41 resize_params _on_resize_overall = { 0.f, 0.f, 0.f, 0.f };
42
43 public:
46 _cursor = cursor_type::caret;
47 _rect.size({ 320.f, 215.f });
48 }
49
54 bool operator==(const html_editor& param);
55
60 bool operator!=(const html_editor& param);
61
62 // generic widget
63
66 std::string& text() override;
67
71 html_editor& text(const std::string& text);
72
76 std::string& tooltip() override;
77
82 html_editor& tooltip(const std::string& tooltip);
83
87 lecui::rect& rect() override;
88
93
97
102
105 cursor_type& cursor() override;
106
111
114 std::string& font() override;
115
119 html_editor& font(const std::string& font);
120
123 float& font_size() override;
124
128 html_editor& font_size(const float& font_size);
129
132 color& color_text() override;
133
137 html_editor& color_text(const color& color_text);
138
141 color& color_fill() override;
142
146 html_editor& color_fill(const color& color_fill);
147
151 color& color_hot() override;
152
157 html_editor& color_hot(const color& color_hot);
158
162
166 html_editor& color_selected(const color& color_selected);
167
171
175 html_editor& color_disabled(const color& color_disabled);
176
177 // widget specific widget
178
181 float& border();
182
186 html_editor& border(const float& border);
187
191
195 html_editor& control_border(const float& control_border);
196
200
204 html_editor& color_border(const color& color_border);
205
209
213 html_editor& corner_radius_x(const float& corner_radius_x);
214
218
222 html_editor& corner_radius_y(const float& corner_radius_y);
223
227
231 html_editor& color_caret(const color& color_caret);
232
236
240 html_editor& color_control_border(const color& color_control_border);
241
245
249 html_editor& color_control_fill(const color& color_control_fill);
250
254
259
260 public:
267 [[nodiscard]]
268 static html_editor& add(containers::page& page, const std::string& alias = std::string());
269
276 [[nodiscard]]
277 static html_editor& get(form& fm, const std::string& path);
278
279 private:
281 bool _view_only = false;
282
283#if defined(LECUI_EXPORTS)
284 friend class html_view_builder;
285 friend class html_editor_impl;
286 friend class form;
287#endif
288 };
289 }
290 }
291}
292
293#if defined(lecui_helper)
295#define get_html_editor(path) liblec::lecui::widgets::html_editor::get(*this, path)
296#endif
RGBA color on a standard 0 to 255 scale. For the alpha channel 0 is transparent and 255 is opaque.
Definition: lecui.h:583
Page container.
Definition: page.h:32
Form base class. The user must inherit from this class and call one of the two constructors from its ...
Definition: form.h:122
Rectangle class.
Definition: lecui.h:158
Resize parameters.
Definition: lecui.h:363
HTML editor widget. To instantiate and add to a container use the add static method.
Definition: html_editor.h:24
std::string & font() override
Get or set the default widget font, e.g. "Georgia".
color & color_selected() override
Get or set the widget's color when selected.
html_editor & on_resize(const resize_params &on_resize)
Set the behaviour of the widget when its container is resized.
std::string & text() override
Get or set the widget text.
html_editor & font(const std::string &font)
Set the default widget font.
color & color_control_border()
Get or set the color of the html control pane border.
float & corner_radius_y()
Get or set the vertical radius of the corners.
html_editor & color_hot(const color &color_hot)
Set the widget's color when the mouse is hovered over it.
static html_editor & add(containers::page &page, const std::string &alias=std::string())
Add an html editor to a container.
resize_params & on_resize() override
Get or set the behaviour of the widget when its container is resized.
html_editor & color_control_fill(const color &color_control_fill)
Set the fill color of the control.
html_editor & color_text(const color &color_text)
Set the color of the widget's text.
float & control_border()
Get or set the thickness of the control pane border.
html_editor()
Constructor.
Definition: html_editor.h:45
html_editor & color_selected(const color &color_selected)
Set the widget's color when selected.
html_editor & rect(const lecui::rect &rect)
Set the position and dimensions of the widget.
html_editor & corner_radius_x(const float &corner_radius_x)
Set the horizontal radius of the corners.
html_editor & border(const float &border)
Set the thickness of the border.
color & color_disabled() override
Get or set the widget's color when it is disabled.
color & color_hot() override
Get or set the widget's color when the mouse is hovered over it.
html_editor & alignment(const text_alignment &alignment)
Set the text alignment.
html_editor & tooltip(const std::string &tooltip)
Set the tooltip text.
text_alignment & alignment()
Get or set the text alignment.
html_editor & control_border(const float &control_border)
Set the thickness of the control border.
html_editor & text(const std::string &text)
Set the widget's text.
bool operator==(const html_editor &param)
Check whether widget specs are equal. Only those properties that require the widget resources to be r...
html_editor & color_fill(const color &color_fill)
Set the fill color of the widget.
html_editor & corner_radius_y(const float &corner_radius_y)
Set the vertical radius of the corners.
std::string & tooltip() override
Get or set the widget's tooltip text.
color & color_control_fill()
Get or set the fill color of the control.
float & font_size() override
Get or set the default widget font size in points, e.g. 9.0f.
lecui::rect & rect() override
Get or set the position and dimensions of the widget.
cursor_type & cursor() override
Get or set the mouse cursor to use then over the widget.
html_editor & color_caret(const color &color_caret)
Set the color of the caret.
color & color_fill() override
Get or set the fill color of the widget.
html_editor & color_control_border(const color &color_control_border)
Set the color of the html control pane border.
color & color_border()
Get or set the color of the border.
bool operator!=(const html_editor &param)
Check whether widget specs are NOT equal. Only those properties that require the widget resources to ...
float & corner_radius_x()
Get or set the horizontal radius of the corners.
html_editor & cursor(const cursor_type cursor)
Set the mouse cursor to use when over the widget.
color & color_caret()
Get or set the color of the caret.
html_editor & font_size(const float &font_size)
Set the widget's font size.
html_editor & color_border(const color &color_border)
Set the color of the border.
float & border()
Get or set the thickness of the border.
html_editor & color_disabled(const color &color_disabled)
Set the widget's color when it is disabled.
static html_editor & get(form &fm, const std::string &path)
Get the specifications of an html editor.
color & color_text() override
Get or set the color of the widget's text.
Base class for all widgets.
Definition: widget.h:24
cursor_type
Mouse cursor type.
Definition: widget.h:27
text_alignment
Text alignment.
Definition: lecui.h:951
@ left
Align text to the left edge.
Top level namespace for the liblec libraries.
Definition: appearance.h:19