| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 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 |
}} |
| 120 |
|