Debian Codegraph @

Server/Web/HtmlTagInputIntegerWithLabel.h

raw symbols SCIP
1 /*
2 RailControl - Model Railway Control Software
3
4 Copyright (c) 2017-2025 by Teddy / Dominik Mahrer - www.railcontrol.org
5
6 RailControl is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
10
11 RailControl is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with RailControl; see the file LICENCE. If not see
18 <http://www.gnu.org/licenses/>.
19 */
20
21 #pragma once
22
23 #include <string>
24
25 #include "Languages.h"
26 #include "Server/Web/HtmlTag.h"
27 #include "Server/Web/HtmlTagLabel.h"
28 #include "Server/Web/HtmlTagInputInteger.h"
29
30 namespace Server { namespace Web
31 {
32 class HtmlTagInputIntegerWithLabel : public HtmlTag
33 {
34 public:
35 HtmlTagInputIntegerWithLabel() = delete;
36
37 HtmlTagInputIntegerWithLabel(const std::string& name,
38 const Languages::TextSelector label,
39 const int min,
40 const int max)
41 : HtmlTagInputIntegerWithLabel(name, label, 0, min, max)
42 {}
43
44 HtmlTagInputIntegerWithLabel(const std::string& name,
45 const Languages::TextSelector label,
46 const Languages::TextSelector tooltip,
47 const int min,
48 const int max)
49 : HtmlTagInputIntegerWithLabel(name, label, tooltip, 0, min, max)
50 {}
51
52 template<typename... TextArgs>
53 HtmlTagInputIntegerWithLabel(const std::string& name,
54 const Languages::TextSelector label,
55 const int value,
56 const int min,
57 const int max,
58 TextArgs... textArgs)
59 : HtmlTag("div")
60 {
61 HtmlTag::AddClass("input_integer_with_label");
62 AddChildTag(HtmlTagLabel(label, name, textArgs...));
63 AddChildTag(HtmlTagInputInteger(name, value, min, max));
64 }
65
66 template<typename... TextArgs>
67 HtmlTagInputIntegerWithLabel(const std::string& name,
68 const Languages::TextSelector label,
69 const Languages::TextSelector tooltip,
70 const int value,
71 const int min,
72 const int max,
73 TextArgs... textArgs)
74 : HtmlTag("div")
75 {
76 HtmlTag::AddClass("input_integer_with_label");
77 AddChildTag(HtmlTagLabel(label, tooltip, name, textArgs...));
78 AddChildTag(HtmlTagInputInteger(name, value, min, max));
79 }
80
81 virtual ~HtmlTagInputIntegerWithLabel()
82 {
83 }
84
85 inline virtual HtmlTag AddAttribute(const std::string& name, const std::string& value) override
86 {
87 childTags[1].AddAttribute(name, value);
88 return *this;
89 }
90
91 inline virtual HtmlTag AddClass(const std::string& _class) override
92 {
93 childTags[1].AddClass(_class);
94 return *this;
95 }
96 };
97 }} // namespace Server::Web
98