Debian Codegraph @

Server/Web/HtmlTagLayoutItem.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 "DataModel/LayoutItem.h"
26 #include "DataModel/ObjectIdentifier.h"
27 #include "Server/Web/HtmlTag.h"
28
29 using std::string;
30 using std::to_string;
31
32 namespace Server { namespace Web
33 {
34 class HtmlTagLayoutItem : public HtmlTag
35 {
36 protected:
37 HtmlTagLayoutItem() = delete;
38 HtmlTagLayoutItem(const HtmlTagLayoutItem&) = delete;
39 HtmlTagLayoutItem& operator=(const HtmlTagLayoutItem&) = delete;
40
41 inline HtmlTagLayoutItem(const DataModel::LayoutItem* layout)
42 : HtmlTagLayoutItem(layout, layout->GetPosX(), layout->GetPosY())
43 {
44 }
45
46 HtmlTagLayoutItem(const DataModel::LayoutItem* layout,
47 const DataModel::LayoutItem::LayoutPosition posX,
48 const DataModel::LayoutItem::LayoutPosition posY);
49
50 virtual ~HtmlTagLayoutItem()
51 {
52 }
53
54 void FinishInit();
55
56 inline void AddOnClickMenuEntry(const std::string& text)
57 {
58 AddMenuTitle(onClickMenuContentDiv, text);
59 }
60
61 inline void AddOnClickMenuEntry(const Languages::TextSelector text, const std::string& onClick, const std::string& className = "")
62 {
63 AddOnClickMenuEntry(Languages::GetText(text), onClick, className);
64 }
65
66 inline void AddOnClickMenuEntry(const std::string& text, const std::string& onClick, const std::string& className = "")
67 {
68 AddMenuEntry(onClickMenuContentDiv, text, onClick, className);
69 }
70
71 inline void AddContextMenuEntry(const std::string& text)
72 {
73 AddMenuTitle(contextMenuContentDiv, text);
74 }
75
76 inline void AddContextMenuEntry(const Languages::TextSelector text, const std::string& onClick, const std::string& className = "")
77 {
78 AddMenuEntry(contextMenuContentDiv, text, onClick, className);
79 }
80
81 void AddToolTip(const std::string& toolTip)
82 {
83 imageDiv.AddChildTag(HtmlTag("span").AddClass("tooltip").AddContent(toolTip));
84 }
85
86 static const unsigned char EdgeLength = 36;
87 static const std::string EdgeLengthString;
88
89 const DataModel::LayoutItem* layout;
90
91 string identifier;
92 std::string image;
93 HtmlTag imageDiv;
94 HtmlTag onClickMenuDiv;
95 HtmlTag onClickMenuContentDiv;
96 HtmlTag contextMenuDiv;
97 HtmlTag contextMenuContentDiv;
98
99 unsigned int layoutPosX;
100 unsigned int layoutPosY;
101
102 private:
103 static void AddMenuTitle(HtmlTag& menu,
104 const std::string& text);
105
106 static inline void AddMenuEntry(HtmlTag& menu,
107 const Languages::TextSelector text,
108 const std::string& onClick,
109 const std::string& className = "")
110 {
111 AddMenuEntry(menu, Languages::GetText(text), onClick, className);
112 }
113
114 static void AddMenuEntry(HtmlTag& menu,
115 const std::string& text,
116 const std::string& onClick,
117 const std::string& className = "");
118 };
119 }} // namespace Server::Web
120