Webdar 1.0.0
Web user interface to libdar
html_double_button.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef HTML_DOUBLE_BUTTON_HPP
25#define HTML_DOUBLE_BUTTON_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include <string>
36
37 // webdar headers
38#include "events.hpp"
39#include "actor.hpp"
40#include "html_static_url.hpp"
41#include "html_div.hpp"
42#include "css_class_group.hpp"
43#include "html_button.hpp"
44
46
47class html_double_button : public body_builder, public events, public actor
48{
49public:
50 html_double_button(const std::string & label, const std::string & x_event_name);
51 html_double_button(const html_double_button & ref) = delete;
52 html_double_button(html_double_button && ref) noexcept = delete;
53 html_double_button & operator = (const html_double_button & ref) = delete;
54 html_double_button & operator = (html_double_button && ref) noexcept = delete;
55 ~html_double_button() = default;
56
58 void url_add_css_class(const std::string & name) { one.url_add_css_class(name); two.url_add_css_class(name); };
59
62
64 void url_remove_css_class(const std::string & name) { one.url_remove_css_class(name); two.url_remove_css_class(name); };
65
68
70 void change_label(const std::string & label) { one.change_label(label); two.change_label(label); };
71
72 std::string get_label() const { return one.get_label(); };
73
75 std::string get_url() const { return one.get_url(); };
76
78
80 void change_event_name_to(const std::string & x_event_name) { one.change_event_name_to(x_event_name); two.change_event_name_to(x_event_name); };
81
83 const std::string & get_event_name() const { return one.get_event_name(); };
84
86 void set_download(bool mode) { one.set_download(mode); two.set_download(mode); };
87
90 void set_filename(const std::string & name) { one.set_filename(name); two.set_filename(name); };
91
93 virtual void on_event(const std::string & event_name) override;
94
96 virtual void bind_to_anchor(const std::string & val) override { one.bind_to_anchor(val); two.bind_to_anchor(val); };
97
98protected:
99
101 virtual std::string inherited_get_body_part(const chemin & path,
102 const request & req) override;
103
105 virtual void css_classes_have_changed() override;
106
107
108private:
109 static const std::string event_one;
110 static const std::string event_two;
111
112 std::string my_event_name;
113 html_button one;
114 html_button two;
115
116 void swap(bool show_one);
117};
118
119#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class body_builder is the root class of object generating HTML body
Definition: body_builder.hpp:99
class chemin definition
Definition: chemin.hpp:51
manages a set of css class names
Definition: css_class_group.hpp:46
class events
Definition: events.hpp:52
simple html component providing the usual button feature of GUIs, better using html_double_button ins...
Definition: html_button.hpp:48
void set_filename(const std::string &name)
Definition: html_button.hpp:93
void change_label(const std::string &x_label)
the label is the text show for the URL
Definition: html_button.cpp:58
void url_clear_css_classes()
the inherited add_css_class() applies to the html_div around, this one to the url inside
Definition: html_button.hpp:67
void url_add_css_class(const std::string &name)
the inherited add_css_class() applies to the html_div around, this one to the url inside
Definition: html_button.hpp:58
void url_remove_css_class(const std::string &name)
the inherited add_css_class() applies to the html_div around, this one to the url inside
Definition: html_button.hpp:64
void set_download(bool mode)
whether to download or display the URL target
Definition: html_button.hpp:86
virtual void bind_to_anchor(const std::string &val) override
inherited from body_builder
Definition: html_button.hpp:96
void change_event_name_to(const std::string &x_event_name)
change the name of the event generating by a click on the html_button
Definition: html_button.hpp:80
std::string get_url() const
get the URL that will lead this button to be clicked
Definition: html_button.hpp:75
const std::string & get_event_name() const
get the name of the event generated by this object
Definition: html_button.hpp:83
html_button equivalent with changing path to trigger the button event
Definition: html_double_button.hpp:48
virtual void on_event(const std::string &event_name) override
inherited from actor
Definition: html_double_button.cpp:60
virtual void css_classes_have_changed() override
inheroted from body_builder
Definition: html_double_button.cpp:86
void url_clear_css_classes()
the inherited add_css_class() applies to the html_div around, this one to the url inside
Definition: html_double_button.hpp:67
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder
Definition: html_double_button.cpp:80
void url_add_css_class(const std::string &name)
the inherited add_css_class() applies to the html_div around, this one to the url inside
Definition: html_double_button.hpp:58
virtual void bind_to_anchor(const std::string &val) override
inherited from body_builder
Definition: html_double_button.hpp:96
std::string get_url() const
get the URL that will lead this double_button to be clicked
Definition: html_double_button.hpp:75
void change_event_name_to(const std::string &x_event_name)
change the name of the event generating by a click on the html_double_button
Definition: html_double_button.hpp:80
void url_remove_css_class(const std::string &name)
the inherited add_css_class() applies to the html_div around, this one to the url inside
Definition: html_double_button.hpp:64
void set_filename(const std::string &name)
Definition: html_double_button.hpp:90
void url_add_css_class(const css_class_group &cg)
add a several CSS classes at once for the url inside the double_button
Definition: html_double_button.hpp:61
void set_download(bool mode)
whether to download or display the URL target
Definition: html_double_button.hpp:86
void change_label(const std::string &label)
the label is the text show for the URL
Definition: html_double_button.hpp:70
const std::string & get_event_name() const
get the name of the event generated by this object
Definition: html_double_button.hpp:83
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
defines the event class