-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCUIElement.cpp
106 lines (78 loc) · 1.97 KB
/
CUIElement.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/** $VER: CUIElement.cpp (2024.07.03) P. Stuer **/
#include "pch.h"
#include "CUIElement.h"
#pragma hdrstop
namespace uie
{
#pragma region CUIElement
/// <summary>
/// Initializes a new instance.
/// </summary>
CUIElement::CUIElement()
{
GetColors();
}
/// <summary>
/// Destroys this instance.
/// </summary>
CUIElement::~CUIElement()
{
}
/// <summary>
/// Creates or transfers the window.
/// </summary>
HWND CUIElement::create_or_transfer_window(HWND hParent, const window_host_ptr & newHost, const ui_helpers::window_position_t & position)
{
_hParent = hParent;
if (*this == nullptr)
{
_Host = newHost;
CRect r;
position.convert_to_rect(r);
Create(hParent, r, 0, WS_CHILD, 0);
}
else
{
ShowWindow(SW_HIDE);
SetParent(hParent);
_Host->relinquish_ownership(*this);
_Host = newHost;
SetWindowPos(NULL, position.x, position.y, (int) position.cx, (int) position.cy, SWP_NOZORDER);
}
CUIColorClient::Register(this);
return *this;
}
/// <summary>
/// Destroys the window.
/// </summary>
void CUIElement::destroy_window()
{
CUIColorClient::Unregister(this);
::DestroyWindow(*this);
_Host.release();
}
/// <summary>
/// Gets the colors.
/// </summary>
void CUIElement::GetColors() noexcept
{
cui::colours::helper Helper(pfc::guid_null);
_ForegroundColor = Helper.get_colour(cui::colours::colour_text);
_BackgroundColor = Helper.get_colour(cui::colours::colour_background);
}
static uie::window_factory<CUIElement> _WindowFactory;
#pragma endregion
#pragma region CUIColorClient
void CUIColorClient::on_colour_changed(uint32_t changed_items_mask) const
{
for (auto Iter : _Elements)
Iter->OnColorsChanged();
}
void CUIColorClient::on_bool_changed(uint32_t changed_items_mask) const
{
for (auto Iter : _Elements)
Iter->OnColorsChanged();
}
static cui::colours::client::factory<CUIColorClient> _CUIColorClientFactory;
#pragma endregion
}