#include "GuiWindowControls.h"
#include "GuiApplication.h"
#include "../GraphicsHost/GuiGraphicsHost.h"
namespace
{
namespace
{
namespace
{
using
namespace
elements
;
using
namespace
compositions
;
using
namespace
collections
;
using
namespace
reflection
::
description
;
void
::
()
{
}
void
::
()
{
}
controls
::
*
::
GetControlHostForInstance
()
{
return
this
;
}
*
::
(
)
{
*
=
this
->
()->
(
,
true
);
if
(
composition
)
{
*
=
composition
->
();
while
(
control
)
{
if
(
control
->
())
{
return
control
;
}
control
=
control
->
();
}
}
return
nullptr
;
}
void
::
(
*
,
)
{
if
(
)
{
;
{
*
=
()->
();
if
(
currentOwner
&&
currentOwner
!=
)
{
if
(
)
{
();
0
;
}
()->
([=]()
{
currentOwner
->
();
},
);
}
}
if
(!
)
{
if
(
)
{
();
0
;
}
}
else
if
(
)
{
(
);
}
else
if
(
()->
() !=
)
{
()->
([
this
]()
{
*
=
(
);
if
(
owner
)
{
=
owner
->
()->
().
();
(
.
-
offset
.
,
.
-
offset
.
+
24
);
owner
->
(
p
);
0
;
()->
([
this
, owner]()
{
owner
->
();
},
);
}
},
);
}
}
}
void
::
(
const
&
)
{
if
(!
.
&& !
.
&& !
.
)
{
*
=
(
);
(
tooltipControl
,
(
->
()->
(
(
.
,
.
))));
}
}
void
::
()
{
(
0
,
(-
1
, -
1
));
}
void
::
()
{
();
}
void
::
()
{
::
(
true
);
();
}
void
::
()
{
::
(
false
);
();
}
void
::
()
{
.
(
());
();
}
void
::
()
{
.
(
());
();
}
void
::
()
{
.
(
());
();
}
void
::
()
{
.
(
());
();
}
void
::
()
{
.
(
());
}
void
::
(
bool
&
)
{
(
);
arguments
.
=
;
.
(
arguments
);
if
(!
arguments
.
)
{
=
arguments
.
;
}
}
void
::
()
{
.
(
());
}
void
::
()
{
.
(
());
=
true
;
if
(
)
{
()->
(
this
, [=]()
{
delete
this
;
});
}
(
nullptr
);
}
void
::
UpdateClientSizeAfterRendering
(
,
)
{
auto
=
();
if
(
size
)
{
(
);
}
}
::
(
theme
::
,
::
)
:
(
)
, windowMode(
)
{
->
(
(
0
,
0
,
0
,
0
));
.
(
);
.
(
);
.
(
);
.
(
);
.
(
);
.
(
);
.
(
);
.
(
);
=
new
(
this
,
);
=
0
;
}
::
()
{
FinalizeInstanceRecursively
(
this
);
OnBeforeReleaseGraphicsHost
();
delete
;
}
void
::
DeleteAfterProcessingAllEvents
()
{
auto
=
->
();
if
(
|| !
window
)
{
delete
this
;
}
else
{
=
true
;
()->
()->
(
window
);
}
}
compositions
::
*
::
()
{
return
;
}
compositions
::
*
::
()
{
return
->
();
}
*
::
()
{
return
->
();
}
void
::
(
*
)
{
if
(
->
())
{
->
()->
(
this
);
}
if
(
)
{
if
(
!=
->
())
{
CHECK_FAIL(L"GuiControlHost::SetNativeWindow(INativeWindow*)#Window mode does not match.");
do
{
throw
(
L"GuiControlHost::SetNativeWindow(INativeWindow*)#Window mode does not match."
);}
while
(
0
);
}
}
->
(
);
if
(
->
())
{
->
()->
(
this
);
}
();
}
void
::
()
{
auto
=
();
->
ForceCalculateSizeImmediately
();
(
size
);
}
bool
::
()
{
if
(
->
())
{
return
->
()->
();
}
else
{
return
false
;
}
}
void
::
(
bool
)
{
if
(
->
())
{
if
(
)
{
->
()->
();
}
else
{
->
()->
();
}
}
}
bool
::
()
{
if
(
->
())
{
return
->
()->
();
}
else
{
return
false
;
}
}
void
::
()
{
if
(
->
())
{
->
()->
();
}
}
bool
::
()
{
if
(
->
())
{
return
->
()->
();
}
else
{
return
false
;
}
}
void
::
()
{
if
(
->
())
{
->
()->
();
}
}
bool
::
()
{
if
(
->
())
{
return
->
()->
();
}
else
{
return
false
;
}
}
void
::
(
bool
)
{
if
(
->
())
{
if
(
)
{
->
()->
();
}
else
{
->
()->
();
}
}
}
bool
::
()
{
if
(
->
())
{
return
->
()->
();
}
else
{
return
false
;
}
}
void
::
(
bool
)
{
if
(
->
())
{
if
(
)
{
->
()->
();
}
else
{
->
()->
();
}
}
}
bool
::
()
{
if
(
->
())
{
return
->
()->
();
}
else
{
return
false
;
}
}
void
::
(
bool
)
{
if
(
->
())
{
->
()->
(
);
}
}
compositions
::
*
::
()
{
return
->
();
}
void
::
(
compositions
::
*
)
{
->
(
);
}
compositions
::
*
::
()
{
return
->
();
}
::
()
{
if
(
auto
=
->
())
{
return
window
->
(
window
->
());
}
else
{
return
(
0
,
0
);
}
}
void
::
(
)
{
if
(
auto
=
->
())
{
->
()->
(
window
->
(
));
}
}
::
()
{
if
(
auto
=
->
())
{
return
window
->
().
();
}
else
{
return
();
}
}
void
::
(
)
{
if
(
auto
=
->
())
{
auto
=
window
->
();
window
->
(
(
,
bounds
.
()));
}
}
void
::
(
,
)
{
if
(
auto
=
->
())
{
window
->
(
(
,
window
->
(
)));
}
}
*
::
()
{
return
this
;
}
const
&
::
()
{
;
if
(
->
())
{
result
->
()->
();
}
if
(
result
!=
::
())
{
::
(
result
);
}
return
::
();
}
void
::
(
const
&
)
{
if
(
->
())
{
->
()->
(
);
::
(
);
}
}
*
::
()
{
if
(
->
())
{
return
()->
()->
(
->
());
}
else
{
return
0
;
}
}
void
::
()
{
if
(
->
())
{
->
()->
();
}
}
void
::
()
{
if
(
->
())
{
->
()->
();
}
}
void
::
()
{
if
(
->
())
{
->
()->
();
}
}
void
::
()
{
if
(
->
())
{
->
()->
();
}
}
void
::
()
{
if
(
->
())
{
->
()->
();
}
}
void
::
()
{
if
(
->
())
{
->
()->
(
false
);
}
}
void
::
()
{
if
(
auto
=
->
())
{
auto
=
()->
()->
();
if
(
mainWindow
==
window
)
{
(
nullptr
);
()->
()->
(
window
);
}
else
{
window
->
(
false
);
}
}
}
bool
::
()
{
*
=
->
();
if
(
window
)
{
return
window
->
();
}
return
false
;
}
void
::
BeforeControlTemplateUninstalled_
()
{
}
void
::
AfterControlTemplateInstalled_
(
bool
)
{
auto
=
TypedControlTemplateObject
(
true
);
#define FIX_WINDOW_PROPERTY(VARIABLE, NAME) \
switch (ct->Get ## NAME ## Option()) \
{ \
case templates::BoolOption::AlwaysTrue: \
VARIABLE = true; \
break; \
case templates::BoolOption::AlwaysFalse: \
VARIABLE = false; \
break; \
default:; \
} \
FIX_WINDOW_PROPERTY(hasMaximizedBox, MaximizedBox)
switch
(
ct
->
()) {
case
templates
::
::
:
=
true
;
break
;
case
templates
::
::
:
=
false
;
break
;
default
:; }
FIX_WINDOW_PROPERTY(hasMinimizedBox, MinimizedBox)
switch
(
ct
->
()) {
case
templates
::
::
:
=
true
;
break
;
case
templates
::
::
:
=
false
;
break
;
default
:; }
FIX_WINDOW_PROPERTY(hasBorder, Border)
switch
(
ct
->
()) {
case
templates
::
::
:
=
true
;
break
;
case
templates
::
::
:
=
false
;
break
;
default
:; }
FIX_WINDOW_PROPERTY(hasSizeBox, SizeBox)
switch
(
ct
->
()) {
case
templates
::
::
:
=
true
;
break
;
case
templates
::
::
:
=
false
;
break
;
default
:; }
FIX_WINDOW_PROPERTY(isIconVisible, IconVisible)
switch
(
ct
->
()) {
case
templates
::
::
:
=
true
;
break
;
case
templates
::
::
:
=
false
;
break
;
default
:; }
FIX_WINDOW_PROPERTY(hasTitleBar, TitleBar)
switch
(
ct
->
()) {
case
templates
::
::
:
=
true
;
break
;
case
templates
::
::
:
=
false
;
break
;
default
:; }
#undef FIX_WINDOW_PROPERTY
ct
->
(
);
ct
->
(
);
ct
->
(
);
ct
->
(
);
ct
->
(
);
ct
->
(
);
ct
->
(
()->
() !=
::
);
ct
->
(
());
auto
=
();
if
(
window
)
{
window
->
(
);
}
(
window
,
ct
);
ct
->
(
?
:
window
?
window
->
() :
nullptr
);
SyncNativeWindowProperties
();
}
void
::
(
*
,
templates
::
*
)
{
if
(
auto
=
())
{
->
(
window
->
(
window
->
()));
}
else
{
->
({
8
,
8
,
8
,
8
});
}
}
void
::
SyncNativeWindowProperties
()
{
if
(
auto
=
())
{
if
(
TypedControlTemplateObject
(
true
)->
())
{
window
->
();
window
->
(
false
);
}
else
{
window
->
();
window
->
(
);
}
window
->
(
);
window
->
(
);
window
->
(
);
window
->
(
);
window
->
(
);
}
}
void
::
()
{
::
();
TypedControlTemplateObject
(
true
)->
(
()->
() !=
::
);
}
void
::
()
{
if
(
auto
=
TypedControlTemplateObject
(
false
))
{
(
(),
ct
);
}
}
void
::
()
{
SyncNativeWindowProperties
();
::
();
}
void
::
()
{
::
();
}
void
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(
auto
=
TypedControlTemplateObject
(
false
))
{
ct
->
(
true
);
}
}
void
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(
auto
=
TypedControlTemplateObject
(
false
))
{
ct
->
(
false
);
}
}
::
(
theme
::
,
::
)
:
(
,
)
{
(
);
(
this
,
true
);
*
=
()->
()->
(
);
(
window
);
()->
(
this
);
.
(
);
.
(
this
, &
::
);
.
(
this
, &
::
);
}
::
(
theme
::
)
:
(
,
::
)
{
}
::
()
{
();
()->
(
this
);
*
=
->
();
if
(
window
)
{
(
nullptr
);
()->
()->
(
window
);
}
}
*
::
(
const
&
)
{
if
(
==
::
)
{
return
(
*)
this
;
}
else
{
return
::
(
);
}
}
void
::
()
{
(
());
}
void
::
(
*
)
{
if
(
)
{
if
(
auto
=
->
())
{
=
->
();
=
window
->
().
();
(
(
screenBounds
.
()
(
screenBounds
.
()
windowSize
.
)
2
,
screenBounds
.
()
(
screenBounds
.
()
windowSize
.
)
2
)
);
}
}
}
#define IMPL_WINDOW_PROPERTY(VARIABLE, NAME, CONDITION_BREAK) \
bool GuiWindow::Get ## NAME() \
{ \
return VARIABLE; \
} \
void GuiWindow::Set ## NAME(bool visible) \
{ \
auto ct = TypedControlTemplateObject(true); \
if (ct->Get ## NAME ## Option() == templates::BoolOption::Customizable) \
{ \
VARIABLE = visible; \
ct->Set ## NAME(visible); \
auto window = GetNativeWindow(); \
if (window) \
{ \
CONDITION_BREAK \
window->Set ## NAME(visible); \
} \
UpdateCustomFramePadding(window, ct); \
} \
} \
#define IMPL_WINDOW_PROPERTY_EMPTY_CONDITION
#define IMPL_WINDOW_PROPERTY_BORDER_CONDITION if (!ct->GetCustomFrameEnabled())
IMPL_WINDOW_PROPERTY(hasMaximizedBox, MaximizedBox, IMPL_WINDOW_PROPERTY_EMPTY_CONDITION)
bool
::
() {
return
; }
void
::
(
bool
) {
auto
=
TypedControlTemplateObject
(
true
);
if
(
ct
->
() ==
templates
::
::
) {
=
;
ct
->
(
);
auto
=
();
if
(
window
) {
window
->
(
); }
(
window
,
ct
); } }
IMPL_WINDOW_PROPERTY(hasMinimizedBox, MinimizedBox, IMPL_WINDOW_PROPERTY_EMPTY_CONDITION)
bool
::
() {
return
; }
void
::
(
bool
) {
auto
=
TypedControlTemplateObject
(
true
);
if
(
ct
->
() ==
templates
::
::
) {
=
;
ct
->
(
);
auto
=
();
if
(
window
) {
window
->
(
); }
(
window
,
ct
); } }
IMPL_WINDOW_PROPERTY(hasBorder, Border, IMPL_WINDOW_PROPERTY_BORDER_CONDITION)
bool
::
() {
return
; }
void
::
(
bool
) {
auto
=
TypedControlTemplateObject
(
true
);
if
(
ct
->
() ==
templates
::
::
) {
=
;
ct
->
(
);
auto
=
();
if
(
window
) {
if
(!
ct
->
())
window
->
(
); }
(
window
,
ct
); } }
IMPL_WINDOW_PROPERTY(hasSizeBox, SizeBox, IMPL_WINDOW_PROPERTY_EMPTY_CONDITION)
bool
::
() {
return
; }
void
::
(
bool
) {
auto
=
TypedControlTemplateObject
(
true
);
if
(
ct
->
() ==
templates
::
::
) {
=
;
ct
->
(
);
auto
=
();
if
(
window
) {
window
->
(
); }
(
window
,
ct
); } }
IMPL_WINDOW_PROPERTY(isIconVisible, IconVisible, IMPL_WINDOW_PROPERTY_EMPTY_CONDITION)
bool
::
() {
return
; }
void
::
(
bool
) {
auto
=
TypedControlTemplateObject
(
true
);
if
(
ct
->
() ==
templates
::
::
) {
=
;
ct
->
(
);
auto
=
();
if
(
window
) {
window
->
(
); }
(
window
,
ct
); } }
IMPL_WINDOW_PROPERTY(hasTitleBar, TitleBar, IMPL_WINDOW_PROPERTY_EMPTY_CONDITION)
bool
::
() {
return
; }
void
::
(
bool
) {
auto
=
TypedControlTemplateObject
(
true
);
if
(
ct
->
() ==
templates
::
::
) {
=
;
ct
->
(
);
auto
=
();
if
(
window
) {
window
->
(
); }
(
window
,
ct
); } }
<
>
::
()
{
return
;
}
void
::
(
<
>
)
{
if
(
)
{
;
auto
=
();
if
(
window
)
{
window
->
(
);
}
if
(
auto
=
TypedControlTemplateObject
(
false
))
{
ct
->
(
?
:
window
?
window
->
() :
nullptr
);
}
}
}
#undef IMPL_WINDOW_PROPERTY_BORDER_CONDITION
#undef IMPL_WINDOW_PROPERTY_EMPTY_CONDITION
#undef IMPL_WINDOW_PROPERTY
void
::
(
*
,
const
<
void
()>&
)
{
->
(
false
);
()->
(
->
());
auto
=
<
::
>();
container
.
([=](
*
,
&
)
{
()->
(
this
, [=]()
{
.
(
container
);
container
nullptr
;
()->
(
nullptr
);
);
->
(
true
);
->
();
});
});
();
}
void
::
(
*
,
const
<
void
()>&
)
{
(
, [=]()
{
);
DeleteAfterProcessingAllEvents
();
});
}
<
reflection
::
description
::
>
::
(
*
)
{
auto
=
::
();
(
, [
=
future
()]()
{
promise
({});
});
return
future
;
}
void
::(
,
)
{
if
(
== -
1
)
{
::
UpdateClientSizeAfterRendering
(
,
);
}
else
{
auto
=
->
();
auto
=
window
->
();
auto
=
window
->
().
();
auto
=
currentWindowSize
.
currentClientSize
.
;
auto
=
currentWindowSize
.
currentClientSize
.
;
auto
=
window
->
(
);
auto
=
(
(
nativeClientSize
.
offsetX
,
nativeClientSize
.
offsetY
),
,
);
if
(
position
() ||
!=
())
{
(
position
,
);
}
}
}
void
::(
compositions
::
* ,
compositions
::
& )
{
()->
(
this
);
}
void
::(
compositions
::
* ,
compositions
::
& )
{
= -
1
;
()->
(
this
);
if
(
auto
=
())
{
window
->
(
nullptr
);
}
}
void
::(
compositions
::
* ,
compositions
::
& )
{
if
(!
.
)
{
();
}
}
bool
::(
,
,
* )
{
=
->
();
(
,
);
return
!
screenBounds
.
(
windowBounds
.
()) || !
screenBounds
.
(
windowBounds
.
());
}
::(
,
,
* )
{
=
->
();
if
(
.
screenBounds
.
)
{
.
screenBounds
.
;
}
else
if
(
.
.
screenBounds
.
)
{
.
screenBounds
.
.
;
}
if
(
.
screenBounds
.
)
{
.
screenBounds
.
;
}
else
if
(
.
.
screenBounds
.
)
{
.
screenBounds
.
.
;
}
return
;
}
::(
,
* ,
* ,
,
bool
)
{
=
->
(
->
()->
().
());
=
->
().
();
(
->
(
.
()),
->
(
.
()));
targetBounds
.
controlClientOffset
.
controlWindowOffset
.
;
targetBounds
.
controlClientOffset
.
controlWindowOffset
.
;
targetBounds
.
controlClientOffset
.
controlWindowOffset
.
;
targetBounds
.
controlClientOffset
.
controlWindowOffset
.
;
[
4
];
if
(
)
{
locations
[
0
]
(
targetBounds
.
,
targetBounds
.
);
locations
[
1
]
(
targetBounds
.
.
,
targetBounds
.
);
locations
[
2
]
(
targetBounds
.
,
targetBounds
.
.
);
locations
[
3
]
(
targetBounds
.
.
,
targetBounds
.
.
);
}
else
{
locations
[
0
]
(
targetBounds
.
,
targetBounds
.
);
locations
[
1
]
(
targetBounds
.
,
targetBounds
.
.
);
locations
[
2
]
(
targetBounds
.
.
,
targetBounds
.
);
locations
[
3
]
(
targetBounds
.
.
,
targetBounds
.
.
);
}
auto
=
()->
()->
(
);
for
(
=
0
;
i
<
4
;
i
++)
{
if
(!
(
,
locations
[
i
],
screen
))
{
return
(
,
locations
[
i
],
screen
);
}
}
return
(
,
locations
[
0
],
screen
);
}
::(
,
* ,
* ,
)
{
=
->
(
->
()->
().
());
=
->
().
();
=
->
(
);
=
controlClientOffset
.
controlWindowOffset
.
targetLocation
.
;
=
controlClientOffset
.
controlWindowOffset
.
targetLocation
.
;
return
(
,
(
x
,
y
),
()->
()->
(
));
}
::(
,
* ,
* ,
bool
)
{
(
(
0
,
0
),
->
()->
().
());
return
(
,
,
,
bounds
,
);
}
::(
,
,
const
& )
{
switch
(
)
{
case
1
:
return
(
,
.
.
,
.
.
);
case
2
:
return
(
,
.
.
,
.
.
,
.
.
,
.
.
);
case
3
:
return
(
,
.
.
,
.
.
,
.
.
);
case
4
:
return
(
,
.
.
,
.
.
,
.
.
);
default
:
CHECK_FAIL(L"vl::presentation::controls::GuiPopup::CalculatePopupPosition(Size, const PopupInfo&)#Internal error.");
do
{
throw
(
L"vl::presentation::controls::GuiPopup::CalculatePopupPosition(Size, const PopupInfo&)#Internal error."
);}
while
(
0
);
}
}
void
::()
{
auto
=
();
auto
=
window
->
(
window
->
());
UpdateClientSizeAfterRendering
(
clientSize
,
clientSize
);
* =
nullptr
;
switch
(
)
{
case
2
:
controlWindow
=
.
.
;
break
;
case
3
:
controlWindow
=
.
.
;
break
;
case
4
:
controlWindow
=
.
.
;
break
;
}
if
(
controlWindow
)
{
window
->
(
controlWindow
);
(
controlWindow
->
());
}
else
{
(
true
);
}
(
false
);
();
}
::(
theme
::
,
::
)
:
(
,
)
{
(
false
);
(
false
);
(
false
);
(
false
);
(
false
);
.
(
this
, &
::
);
.
(
this
, &
::
);
->
()->
.
(
this
, &
::
);
}
::(
theme
::
)
:
(
,
::
)
{
}
::()
{
()->
(
this
);
}
void
::(
,
* )
{
if
(
auto
=
())
{
if
(!
)
{
(
,
());
=
()->
()->
(
window
);
}
=
1
;
.
.
;
.
.
=
;
();
}
}
void
::(
* ,
,
bool
)
{
if
(
auto
=
())
{
if
(
auto
=
->
()->
())
{
if
(
auto
=
controlHost
->
())
{
=
2
;
.
.
=
;
.
.
=
controlWindow
;
.
.
;
.
.
=
;
();
}
}
}
}
void
::(
* ,
)
{
if
(
auto
=
())
{
if
(
auto
=
->
()->
())
{
if
(
auto
=
controlHost
->
())
{
=
3
;
.
.
=
;
.
.
=
controlWindow
;
.
.
;
();
}
}
}
}
void
::(
* ,
bool
)
{
if
(
auto
=
())
{
if
(
auto
=
->
()->
())
{
if
(
auto
=
controlHost
->
())
{
=
4
;
.
.
=
;
.
.
=
controlWindow
;
.
.
=
;
();
}
}
}
}
void
::
()
{
(
());
}
void
::
(
compositions
::
*
,
compositions
::
&
)
{
}
void
::
(
compositions
::
*
,
compositions
::
&
)
{
SetTemporaryContentControl
(
0
);
}
::
(
theme
::
)
:
(
,
::
)
{
->
(
::
LimitToElementAndChildren
);
->
(
(
20
,
10
));
()->
()->
(
this
);
.
(
this
, &
::
);
.
(
this
, &
::
);
}
::
()
{
()->
()->
(
this
);
}
::
()
{
return
->
().
;
}
void
::
(
)
{
->
(
(
,
10
));
}
*
::
GetTemporaryContentControl
()
{
return
;
}
void
::
SetTemporaryContentControl
(
*
)
{
if
(
&&
(
))
{
->
(
->
());
=
0
;
}
=
;
if
(
)
{
->
()->
(
(
0
,
0
,
0
,
0
));
(
);
}
}
}
}
}