-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
Copy pathCGUIButton_Impl.cpp
53 lines (42 loc) · 1.52 KB
/
CGUIButton_Impl.cpp
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
43
44
45
46
47
48
49
50
51
52
53
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* LICENSE: See LICENSE in the top level directory
* FILE: gui/CGUIButton_Impl.cpp
* PURPOSE: Button widget class
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/
#include "StdInc.h"
#define CGUIBUTTON_NAME "CGUI/Button"
CGUIButton_Impl::CGUIButton_Impl(CGUI_Impl* pGUI, CGUIElement* pParent, const char* szCaption)
{
m_pManager = pGUI;
// Get an unique identifier for CEGUI (gah, there's gotta be an another way)
char szUnique[CGUI_CHAR_SIZE];
pGUI->GetUniqueName(szUnique);
// Create the window and set default settings
m_pWindow = pGUI->GetWindowManager()->createWindow(pGUI->ResolveModernName(CGUIBUTTON_NAME), szUnique);
m_pWindow->setDestroyedByParent(false);
m_pWindow->setText(CGUI_Impl::GetUTFString(szCaption));
m_pWindow->setSize(CEGUI::Absolute, CEGUI::Size(128.0f, 24.0f));
m_pWindow->setVisible(true);
// Store the pointer to this CGUI element in the CEGUI element
m_pWindow->setUserData(reinterpret_cast<void*>(this));
AddEvents();
// If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
if (pParent)
{
SetParent(pParent);
}
else
{
pGUI->AddChild(this);
SetParent(NULL);
}
}
CGUIButton_Impl::~CGUIButton_Impl()
{
DestroyElement();
}