blob: 9eddb7f87dace8ed5f08178b7a5358c588013478 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "../include/GlobalContextMenu.hpp"
namespace dchat
{
static ContextMenu *editMessageContextMenu = nullptr;
ContextMenu* GlobalContextMenu::getEditMessageContextMenu()
{
if(!editMessageContextMenu)
{
editMessageContextMenu = new ContextMenu();
editMessageContextMenu->setVisible(false);
ContextMenuItem editMessageItem("Edit message", nullptr);
ContextMenuItem deleteMessageItem("Delete message", nullptr);
deleteMessageItem.text.setFillColor(sf::Color::Red);
editMessageContextMenu->addItem(editMessageItem);
editMessageContextMenu->addItem(deleteMessageItem);
}
return editMessageContextMenu;
}
void GlobalContextMenu::setClickEditMessageCallbackFunc(MenuItemClickCallbackFunc callbackFunc)
{
getEditMessageContextMenu()->getItemByIndex(0).clickCallbackFunc = callbackFunc;
}
void GlobalContextMenu::setClickDeleteMessageCallbackFunc(MenuItemClickCallbackFunc callbackFunc)
{
getEditMessageContextMenu()->getItemByIndex(1).clickCallbackFunc = callbackFunc;
}
void GlobalContextMenu::processEvent(const sf::Event &event)
{
getEditMessageContextMenu()->processEvent(event);
}
void GlobalContextMenu::draw(sf::RenderWindow &window)
{
getEditMessageContextMenu()->draw(window);
}
}
|