Webdar 1.0.0
Web user interface to libdar
html_yes_no_box.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_YES_NO_BOX_HPP
25#define HTML_YES_NO_BOX_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 "exceptions.hpp"
39#include "body_builder.hpp"
40#include "events.hpp"
41#include "actor.hpp"
42#include "html_form.hpp"
43#include "html_form_radio.hpp"
44#include "html_form_fieldset.hpp"
45#include "html_popup.hpp"
46#include "html_text.hpp"
47
49
50class html_yes_no_box : public html_popup, public events, public actor
51{
52public:
53 static const std::string answer_yes;
54 static const std::string answer_no;
55
57 html_yes_no_box(const html_yes_no_box & ref) = delete;
58 html_yes_no_box(html_yes_no_box && ref) noexcept = delete;
59 html_yes_no_box & operator = (const html_yes_no_box & ref) = delete;
60 html_yes_no_box & operator = (html_yes_no_box && ref) noexcept = delete;
61 ~html_yes_no_box() = default;
62
64 void ask_question(const std::string & message, bool default_value);
65
67
70 bool get_value() const { return rd.get_selected_num() != 0; };
71
72 void set_value(bool val) { rd.set_selected_num(val ? 1 : 0); };
73
75 virtual void on_event(const std::string & event_name) override;
76
77protected:
78
80 virtual void new_css_library_available() override;
81
82private:
83 static constexpr const char* css_center = "html_ynb_center";
84
85 bool ignore_events;
86
87 html_form form;
88 html_form_fieldset form_fs;
90 html_text question;
91
92};
93
94#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class events
Definition: events.hpp:52
class html_form_fieldset implements HTML fieldset feature
Definition: html_form_fieldset.hpp:51
class html_form_radio implements HTML "input" of type "radio"
Definition: html_form_radio.hpp:53
void set_selected_num(unsigned int x)
set the radio buttons to item given in argument
Definition: html_form_radio.cpp:64
unsigned int get_selected_num() const
obtain the index (starts at zero) of the selected radio button
Definition: html_form_radio.hpp:93
class html_form implements HTML form feature
Definition: html_form.hpp:51
class html_popup is the implementation of
Definition: html_popup.hpp:50
class html_text manage text and header in html document
Definition: html_text.hpp:52
html component for user to answer by yes or no to a provided question
Definition: html_yes_no_box.hpp:51
virtual void new_css_library_available() override
inherited from body_builder
Definition: html_yes_no_box.cpp:120
void ask_question(const std::string &message, bool default_value)
make the question to appear to the user
Definition: html_yes_no_box.cpp:74
virtual void on_event(const std::string &event_name) override
inherited from actor parent class
Definition: html_yes_no_box.cpp:100
bool get_value() const
read the answer returned by the user
Definition: html_yes_no_box.hpp:70
defines the event class