GUIFramework
1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
IMenuItem.cpp
Go to the documentation of this file.
1
#include "
IMenuItem.h
"
2
3
#include "
Utility/Utility.h
"
4
5
using namespace
std;
6
7
namespace
gui_framework
8
{
9
namespace
interfaces
10
{
11
IMenuItem::IMenuItem
(
const
wstring& text,
const
string
& type) :
12
text(text),
13
type(type),
14
parent(nullptr),
15
index(0)
16
{
17
18
}
19
20
void
IMenuItem::createMenuItem
(HMENU parent)
21
{
22
this->
setParent
(parent);
23
24
auto
[styles, value] = this->
getCreationData
();
25
26
AppendMenuW(
parent
, styles | MF_STRING, value,
text
.data());
27
}
28
29
void
IMenuItem::setParent
(HMENU parent)
30
{
31
this->parent =
parent
;
32
}
33
34
void
IMenuItem::setIndex
(uint32_t index)
35
{
36
this->index =
index
;
37
}
38
39
const
wstring&
IMenuItem::getText
()
const
40
{
41
return
text
;
42
}
43
44
const
string
&
IMenuItem::getType
()
const
45
{
46
return
type
;
47
}
48
49
json::JSONBuilder
IMenuItem::getStructure
()
const
50
{
51
uint32_t codepage =
ISerializable::getCodepage
();
52
json::JSONBuilder builder(codepage);
53
54
builder.
55
append(
"itemText"
s,
utility::to_string
(
text
, codepage)).
56
append(
"itemType"
s,
type
);
57
58
return
builder;
59
}
60
61
IMenuItem::~IMenuItem
()
62
{
63
DeleteMenu(
parent
,
index
, MF_BYPOSITION);
64
}
65
}
66
}
IMenuItem.h
Utility.h
gui_framework::interfaces::IMenuItem::type
std::string type
Definition
IMenuItem.h:14
gui_framework::interfaces::IMenuItem::getStructure
virtual json::JSONBuilder getStructure() const override
Definition
IMenuItem.cpp:49
gui_framework::interfaces::IMenuItem::createMenuItem
virtual void createMenuItem(HMENU parent) final
Definition
IMenuItem.cpp:20
gui_framework::interfaces::IMenuItem::getType
virtual const std::string & getType() const final
Definition
IMenuItem.cpp:44
gui_framework::interfaces::IMenuItem::getCreationData
virtual std::tuple< uint32_t, uint64_t > getCreationData() const =0
gui_framework::interfaces::IMenuItem::~IMenuItem
virtual ~IMenuItem()
Definition
IMenuItem.cpp:61
gui_framework::interfaces::IMenuItem::setIndex
virtual void setIndex(uint32_t index) final
Definition
IMenuItem.cpp:34
gui_framework::interfaces::IMenuItem::text
std::wstring text
Definition
IMenuItem.h:13
gui_framework::interfaces::IMenuItem::index
uint32_t index
Definition
IMenuItem.h:16
gui_framework::interfaces::IMenuItem::getText
virtual const std::wstring & getText() const final
Definition
IMenuItem.cpp:39
gui_framework::interfaces::IMenuItem::parent
HMENU parent
Definition
IMenuItem.h:15
gui_framework::interfaces::IMenuItem::IMenuItem
IMenuItem(const std::wstring &text, const std::string &type)
Definition
IMenuItem.cpp:11
gui_framework::interfaces::IMenuItem::setParent
virtual void setParent(HMENU parent) final
Definition
IMenuItem.cpp:29
gui_framework::interfaces::ISerializable::getCodepage
static uint32_t getCodepage()
Definition
ISerializable.h:25
gui_framework::utility::to_string
string to_string(wstring_view stringToConvert, uint32_t codepage)
Definition
Utility.cpp:41
gui_framework
Definition
BaseComponent.cpp:21
GUIFramework
src
Interfaces
Menu
IMenuItem.cpp
Generated by
1.12.0