#include <math.h>
#include "GuiGraphicsRenderersWindowsDirect2D.h"
#include "..\..\NativeWindow\Windows\Direct2D\WinDirect2DApplication.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
#define IMPLEMENT_BRUSH_ELEMENT_RENDERER(TRENDERER)\
void TRENDERER::InitializeInternal()\
{\
}\
void TRENDERER::FinalizeInternal()\
{\
DestroyBrush(renderTarget);\
}\
void TRENDERER::RenderTargetChangedInternal(IWindowsDirect2DRenderTarget* oldRenderTarget, IWindowsDirect2DRenderTarget* newRenderTarget)\
{\
DestroyBrush(oldRenderTarget);\
CreateBrush(newRenderTarget);\
}\
TRENDERER::TRENDERER()\
{\
}\
void TRENDERER::Render(Rect bounds)\
#define IMPLEMENT_BRUSH_ELEMENT_RENDERER_SOLID_COLOR_BRUSH(TRENDERER)\
void TRENDERER::CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget)\
{\
if(_renderTarget)\
{\
oldColor=element->GetColor();\
brush=_renderTarget->CreateDirect2DBrush(oldColor);\
}\
}\
void TRENDERER::DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget)\
{\
if(_renderTarget && brush)\
{\
_renderTarget->DestroyDirect2DBrush(oldColor);\
brush=0;\
}\
}\
void TRENDERER::OnElementStateChanged()\
{\
if(renderTarget)\
{\
Color color=element->GetColor();\
if(oldColor!=color)\
{\
DestroyBrush(renderTarget);\
CreateBrush(renderTarget);\
}\
}\
}\
#define IMPLEMENT_BRUSH_ELEMENT_RENDERER_LINEAR_GRADIENT_BRUSH(TRENDERER)\
void TRENDERER::CreateBrush(IWindowsDirect2DRenderTarget* _renderTarget)\
{\
if(_renderTarget)\
{\
oldColor=Pair<Color, Color>(element->GetColor1(), element->GetColor2());\
brush=_renderTarget->CreateDirect2DLinearBrush(oldColor.key, oldColor.value);\
}\
}\
void TRENDERER::DestroyBrush(IWindowsDirect2DRenderTarget* _renderTarget)\
{\
if(_renderTarget && brush)\
{\
_renderTarget->DestroyDirect2DLinearBrush(oldColor.key, oldColor.value);\
brush=0;\
}\
}\
void TRENDERER::OnElementStateChanged()\
{\
if(renderTarget)\
{\
Pair<Color, Color> color=Pair<Color, Color>(element->GetColor1(), element->GetColor2());\
if(oldColor!=color)\
{\
DestroyBrush(renderTarget);\
CreateBrush(renderTarget);\
}\
}\
}\
void
GuiFocusRectangleElementRenderer
::
()
{
}
void
GuiFocusRectangleElementRenderer
::
()
{
=
nullptr
;
}
void
GuiFocusRectangleElementRenderer
::
RenderTargetChangedInternal
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
)
{
=
nullptr
;
if
(
)
{
=
->
();
}
}
void
GuiFocusRectangleElementRenderer
::
(
)
{
if
(
)
{
*
=
->
();
*
=
nullptr
;
=
d2dRenderTarget
->
(&
d2dDeviceContext
);
{
= (
)
.
();
= (
)
.
();
= (
)
.
() -
1
;
= (
)
.
() -
1
;
= (
)
.
();
= (
)
.
();
d2dDeviceContext
->
(
,
D2D1
::
(
x
,
y
),
D2D1
::
(
0
,
0
,
w
,
1
),
D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR
,
D2D1_COMPOSITE_MODE_MASK_INVERT
);
d2dDeviceContext
->
(
,
D2D1
::
(
x
,
y2
),
D2D1
::
(
0
,
y2
-
y
,
w
,
h
),
D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR
,
D2D1_COMPOSITE_MODE_MASK_INVERT
);
d2dDeviceContext
->
(
,
D2D1
::
(
x
,
y
+
1
),
D2D1
::
(
0
,
1
,
1
,
h
-
1
),
D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR
,
D2D1_COMPOSITE_MODE_MASK_INVERT
);
d2dDeviceContext
->
(
,
D2D1
::
(
x2
,
y
+
1
),
D2D1
::
(
x2
-
x
,
1
,
w
,
h
-
1
),
D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR
,
D2D1_COMPOSITE_MODE_MASK_INVERT
);
}
if
(
d2dDeviceContext
)
{
d2dDeviceContext
->
();
}
}
}
void
GuiFocusRectangleElementRenderer
::
()
{
}
IMPLEMENT_BRUSH_ELEMENT_RENDERER_SOLID_COLOR_BRUSH(GuiSolidBorderElementRenderer)
void
GuiSolidBorderElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
) {
if
(
) {
->
();
=
->
(
); } }
void
GuiSolidBorderElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
) {
if
(
&&
) {
->
(
);
=
0
; } }
void
GuiSolidBorderElementRenderer
::
() {
if
(
) {
=
->
();
if
(
color
) {
(
);
(
); } } }
IMPLEMENT_BRUSH_ELEMENT_RENDERER(GuiSolidBorderElementRenderer)
void
GuiSolidBorderElementRenderer
::
() { }
void
GuiSolidBorderElementRenderer
::
() {
(
); }
void
GuiSolidBorderElementRenderer
::
RenderTargetChangedInternal
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
) {
(
);
(
); }
GuiSolidBorderElementRenderer
::
GuiSolidBorderElementRenderer
() { }
void
GuiSolidBorderElementRenderer
::
(
)
{
*
=
->
();
auto
=
->
();
switch
(
shape
.
)
{
case
::
:
d2dRenderTarget
->
(
D2D1
::
((
)
.
+
0.5f
, (
)
.
+
0.5f
, (
)
.
-
0.5f
, (
)
.
-
0.5f
),
);
break
;
case
::
:
d2dRenderTarget
->
(
D2D1
::
(
D2D1
::
((
.
+
.
) /
2.0f
, (
.
+
.
) /
2.0f
),
.
() /
2.0f
,
.
() /
2.0f
),
);
break
;
case
::
:
d2dRenderTarget
->
(
D2D1
::
(
D2D1
::
((
)
.
+
0.5f
, (
)
.
+
0.5f
, (
)
.
-
0.5f
, (
)
.
-
0.5f
),
(
)
shape
.
,
(
)
shape
.
),
);
break
;
}
}
void
Gui3DBorderElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
)
{
->
();
->
();
=
->
(
);
=
->
(
);
}
}
void
Gui3DBorderElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
)
{
if
(
)
{
->
(
);
=
nullptr
;
}
if
(
)
{
->
(
);
=
nullptr
;
}
}
}
void
Gui3DBorderElementRenderer
::
()
{
}
void
Gui3DBorderElementRenderer
::
()
{
(
);
}
void
Gui3DBorderElementRenderer
::
RenderTargetChangedInternal
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
)
{
(
);
(
);
}
Gui3DBorderElementRenderer
::
Gui3DBorderElementRenderer
()
{
}
void
Gui3DBorderElementRenderer
::
(
)
{
=
D2D1
::
((
)
.
+
0.5f
, (
)
.
+
0.5f
, (
)
.
-
0.5f
, (
)
.
-
0.5f
);
*
=
->
();
d2dRenderTarget
->
(
D2D1
::
(
rect
.
,
rect
.
),
D2D1
::
(
rect
.
,
rect
.
),
);
d2dRenderTarget
->
(
D2D1
::
(
rect
.
,
rect
.
),
D2D1
::
(
rect
.
,
rect
.
),
);
d2dRenderTarget
->
(
D2D1
::
(
rect
.
,
rect
.
),
D2D1
::
(
rect
.
,
rect
.
),
);
d2dRenderTarget
->
(
D2D1
::
(
rect
.
,
rect
.
),
D2D1
::
(
rect
.
,
rect
.
),
);
}
void
Gui3DBorderElementRenderer
::
()
{
if
(
)
{
=
->
();
=
->
();
if
(
color1
||
!=
color2
)
{
(
);
(
);
}
}
}
void
Gui3DSplitterElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
)
{
->
();
->
();
=
->
(
);
=
->
(
);
}
}
void
Gui3DSplitterElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
)
{
if
(
)
{
->
(
);
=
nullptr
;
}
if
(
)
{
->
(
);
=
nullptr
;
}
}
}
void
Gui3DSplitterElementRenderer
::
()
{
}
void
Gui3DSplitterElementRenderer
::
()
{
(
);
}
void
Gui3DSplitterElementRenderer
::
RenderTargetChangedInternal
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
)
{
(
);
(
);
}
Gui3DSplitterElementRenderer
::
Gui3DSplitterElementRenderer
()
{
}
void
Gui3DSplitterElementRenderer
::
(
)
{
,
,
,
;
switch
(
->
())
{
case
::
:
{
=
.
+
.
()/
2
-
1
;
p11
D2D1
::
((
)
.
, (
)
y
+
0.5f
);
p12
D2D1
::
((
)
.
, (
)
y
+
0.5f
);
p21
D2D1
::
((
)
.
, (
)
y
+
1.5f
);
p22
D2D1
::
((
)
.
, (
)
y
+
1.5f
);
}
break
;
case
::
:
{
=
.
+
.
()/
2
-
1
;
p11
D2D1
::
((
)
x
+
0.5f
, (
)
.
-
0.0f
);
p12
D2D1
::
((
)
x
+
0.5f
, (
)
.
+
0.0f
);
p21
D2D1
::
((
)
x
+
1.5f
, (
)
.
-
0.0f
);
p22
D2D1
::
((
)
x
+
1.5f
, (
)
.
+
0.0f
);
}
break
;
}
*
=
->
();
d2dRenderTarget
->
(
p11
,
p12
,
);
d2dRenderTarget
->
(
p21
,
p22
,
);
}
void
Gui3DSplitterElementRenderer
::
()
{
if
(
)
{
=
->
();
=
->
();
if
(
color1
||
!=
color2
)
{
(
);
(
);
}
}
}
IMPLEMENT_BRUSH_ELEMENT_RENDERER_SOLID_COLOR_BRUSH(GuiSolidBackgroundElementRenderer)
void
GuiSolidBackgroundElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
) {
if
(
) {
->
();
=
->
(
); } }
void
GuiSolidBackgroundElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
) {
if
(
&&
) {
->
(
);
=
0
; } }
void
GuiSolidBackgroundElementRenderer
::
() {
if
(
) {
=
->
();
if
(
color
) {
(
);
(
); } } }
IMPLEMENT_BRUSH_ELEMENT_RENDERER(GuiSolidBackgroundElementRenderer)
void
GuiSolidBackgroundElementRenderer
::
() { }
void
GuiSolidBackgroundElementRenderer
::
() {
(
); }
void
GuiSolidBackgroundElementRenderer
::
RenderTargetChangedInternal
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
) {
(
);
(
); }
GuiSolidBackgroundElementRenderer
::
GuiSolidBackgroundElementRenderer
() { }
void
GuiSolidBackgroundElementRenderer
::
(
)
{
*
=
->
();
auto
=
->
();
switch
(
shape
.
)
{
case
::
:
d2dRenderTarget
->
(
D2D1
::
((
)
.
, (
)
.
, (
)
.
, (
)
.
),
);
break
;
case
::
:
d2dRenderTarget
->
(
D2D1
::
(
D2D1
::
((
.
+
.
)/
2.0f
, (
.
+
.
)/
2.0f
),
.
()/
2.0f
,
.
()/
2.0f
),
);
break
;
case
::
:
d2dRenderTarget
->
(
D2D1
::
(
D2D1
::
((
)
.
+
0.5f
, (
)
.
+
0.5f
, (
)
.
-
0.5f
, (
)
.
-
0.5f
),
(
)
shape
.
,
(
)
shape
.
),
);
break
;
}
}
IMPLEMENT_BRUSH_ELEMENT_RENDERER_LINEAR_GRADIENT_BRUSH(GuiGradientBackgroundElementRenderer)
void
GuiGradientBackgroundElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
) {
if
(
) {
<
,
>(
->
(),
->
());
=
->
CreateDirect2DLinearBrush
(
.
,
.
); } }
void
GuiGradientBackgroundElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
) {
if
(
&&
) {
->
DestroyDirect2DLinearBrush
(
.
,
.
);
=
0
; } }
void
GuiGradientBackgroundElementRenderer
::
() {
if
(
) {
<
,
>
=
<
,
>(
->
(),
->
());
if
(
color
) {
(
);
(
); } } }
IMPLEMENT_BRUSH_ELEMENT_RENDERER(GuiGradientBackgroundElementRenderer)
void
GuiGradientBackgroundElementRenderer
::
() { }
void
GuiGradientBackgroundElementRenderer
::
() {
(
); }
void
GuiGradientBackgroundElementRenderer
::
RenderTargetChangedInternal
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
) {
(
);
(
); }
GuiGradientBackgroundElementRenderer
::
GuiGradientBackgroundElementRenderer
() { }
void
GuiGradientBackgroundElementRenderer
::
(
)
{
[
2
];
switch
(
->
())
{
case
GuiGradientBackgroundElement
::
:
{
points
[
0
].
=(
)
.
;
points
[
0
].
=(
)
.
;
points
[
1
].
=(
)
.
;
points
[
1
].
=(
)
.
;
}
break
;
case
GuiGradientBackgroundElement
::
:
{
points
[
0
].
=(
)
.
;
points
[
0
].
=(
)
.
;
points
[
1
].
=(
)
.
;
points
[
1
].
=(
)
.
;
}
break
;
case
GuiGradientBackgroundElement
::
:
{
points
[
0
].
=(
)
.
;
points
[
0
].
=(
)
.
;
points
[
1
].
=(
)
.
;
points
[
1
].
=(
)
.
;
}
break
;
case
GuiGradientBackgroundElement
::
:
{
points
[
0
].
=(
)
.
;
points
[
0
].
=(
)
.
;
points
[
1
].
=(
)
.
;
points
[
1
].
=(
)
.
;
}
break
;
}
->
(
points
[
0
]);
->
(
points
[
1
]);
*
=
->
();
auto
=
->
();
switch
(
shape
.
)
{
case
::
:
d2dRenderTarget
->
(
D2D1
::
((
)
.
, (
)
.
, (
)
.
, (
)
.
),
);
break
;
case
::
:
d2dRenderTarget
->
(
D2D1
::
(
D2D1
::
((
.
+
.
)/
2.0f
, (
.
+
.
)/
2.0f
),
.
()/
2.0f
,
.
()/
2.0f
),
);
break
;
case
::
:
d2dRenderTarget
->
(
D2D1
::
(
D2D1
::
((
)
.
+
0.5f
, (
)
.
+
0.5f
, (
)
.
-
0.5f
, (
)
.
-
0.5f
),
(
)
shape
.
,
(
)
shape
.
),
);
break
;
}
}
void
GuiInnerShadowElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
)
{
->
();
(
.
,
.
,
.
,
0
);
=
->
CreateDirect2DLinearBrush
(
,
);
=
->
CreateDirect2DRadialBrush
(
,
);
}
}
void
GuiInnerShadowElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
)
{
->
DestroyDirect2DLinearBrush
(
,
);
->
DestroyDirect2DRadialBrush
(
,
);
=
nullptr
;
=
nullptr
;
}
}
void
GuiInnerShadowElementRenderer
::
()
{
}
void
GuiInnerShadowElementRenderer
::
()
{
(
);
}
void
GuiInnerShadowElementRenderer
::
RenderTargetChangedInternal
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
)
{
(
);
(
);
}
GuiInnerShadowElementRenderer
::
GuiInnerShadowElementRenderer
()
{
}
void
GuiInnerShadowElementRenderer
::
(
)
{
=
.
();
=
.
();
=
->
();
=
w
-
2
*
t
;
=
h
-
2
*
t
;
if
(
bW
>
0
&&
bH
>
0
)
{
=
.
();
=
.
();
=
x1
+
t
;
=
x4
-
t
;
=
.
();
=
.
();
=
y1
+
t
;
=
y4
-
t
;
auto
=
->
();
{
->
(
D2D1
::
((
)
x2
, (
)
y2
));
->
(
D2D1
::
((
)
x2
, (
)
y1
));
d2dRenderTarget
->
(
D2D1
::
((
)
x2
, (
)
y1
, (
)
x3
, (
)
y2
),
);
}
{
->
(
D2D1
::
((
)
x2
, (
)
y3
));
->
(
D2D1
::
((
)
x2
, (
)
y4
));
d2dRenderTarget
->
(
D2D1
::
((
)
x2
, (
)
y3
, (
)
x3
, (
)
y4
),
);
}
{
->
(
D2D1
::
((
)
x2
, (
)
y2
));
->
(
D2D1
::
((
)
x1
, (
)
y2
));
d2dRenderTarget
->
(
D2D1
::
((
)
x1
, (
)
y2
, (
)
x2
, (
)
y3
),
);
}
{
->
(
D2D1
::
((
)
x3
, (
)
y2
));
->
(
D2D1
::
((
)
x4
, (
)
y2
));
d2dRenderTarget
->
(
D2D1
::
((
)
x3
, (
)
y2
, (
)
x4
, (
)
y3
),
);
}
->
((
)
t
);
->
((
)
t
);
{
->
(
D2D1
::
((
)
x2
, (
)
y2
));
d2dRenderTarget
->
(
D2D1
::
((
)
x1
, (
)
y1
, (
)
x2
, (
)
y2
),
);
}
{
->
(
D2D1
::
((
)
x3
, (
)
y2
));
d2dRenderTarget
->
(
D2D1
::
((
)
x3
, (
)
y1
, (
)
x4
, (
)
y2
),
);
}
{
->
(
D2D1
::
((
)
x2
, (
)
y3
));
d2dRenderTarget
->
(
D2D1
::
((
)
x1
, (
)
y3
, (
)
x2
, (
)
y4
),
);
}
{
->
(
D2D1
::
((
)
x3
, (
)
y3
));
d2dRenderTarget
->
(
D2D1
::
((
)
x3
, (
)
y3
, (
)
x4
, (
)
y4
),
);
}
}
}
void
GuiInnerShadowElementRenderer
::
()
{
if
(
)
{
if
(
->
())
{
(
);
(
);
}
}
}
void
GuiSolidLabelElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
)
{
->
();
=
->
(
);
}
}
void
GuiSolidLabelElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
&&
)
{
->
(
);
=
nullptr
;
}
}
void
GuiSolidLabelElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
)
{
IWindowsDirect2DResourceManager
*
=
GetWindowsDirect2DResourceManager
();
->
();
if
(
.
==
L""
)
.
()->
()->
().
;
if
(
.
==
0
)
.
=
12
;
=
resourceManager
->
(
);
}
}
void
GuiSolidLabelElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
&&
)
{
IWindowsDirect2DResourceManager
*
=
GetWindowsDirect2DResourceManager
();
resourceManager
->
DestroyDirect2DTextFormat
(
);
=
nullptr
;
}
}
void
GuiSolidLabelElementRenderer
::
()
{
if
(
)
{
=
GetWindowsDirect2DObjectProvider
()->
()->
(
.
(),
(
int
)
.
(),
->
.
(),
0
,
0
,
&
);
CHECK_ERROR(SUCCEEDED(hr), L"You should check HRESULT to see why it failed.");
do
{
if
(!((((
)(
hr
)) >=
0
)))
throw
(
L"You should check HRESULT to see why it failed."
);}
while
(
0
);
if
(
.
)
{
;
textRange
.
=
0
;
textRange
.
= (
int
)
.
();
textLayout->SetUnderline(TRUE, textRange);
}
if
(
.
)
{
;
textRange
.
=
0
;
textRange
.
= (
int
)
.
();
textLayout->SetStrikethrough(TRUE, textRange);
}
}
}
void
GuiSolidLabelElementRenderer
::
()
{
if
(
)
{
->
();
=
nullptr
;
}
}
void
GuiSolidLabelElementRenderer
::
()
{
float
=
0
;
();
bool
calculateSizeFromTextLayout
=
false
;
if
(
)
{
if
(
->
())
{
if
(
->
GetWrapLineHeightCalculation
())
{
();
if
(
)
{
maxWidth
=
->
();
if
(
!=-
1
)
{
->
(
DWRITE_WORD_WRAPPING_WRAP
);
->
((
float
)
);
}
calculateSizeFromTextLayout
=
true
;
}
}
}
else
{
();
if
(
)
{
maxWidth
=
->
();
calculateSizeFromTextLayout
=
true
;
}
}
}
if
(
calculateSizeFromTextLayout
)
{
;
=
->
(&
metrics
);
{
=
0
;
if
(!
->
() && !
->
() && !
->
())
{
width
=(
)
(
metrics
.
widthIncludingTrailingWhitespace
);
}
(
width
, (
)
(
metrics
.
));
}
->
(
maxWidth
);
}
else
{
();
}
}
void
GuiSolidLabelElementRenderer
::
()
{
}
void
GuiSolidLabelElementRenderer
::
()
{
();
(
);
(
);
}
void
GuiSolidLabelElementRenderer
::
RenderTargetChangedInternal
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
)
{
(
);
(
);
(
);
(
);
();
}
GuiSolidLabelElementRenderer
::
GuiSolidLabelElementRenderer
()
{
}
void
GuiSolidLabelElementRenderer
::
(
)
{
if
(!
)
{
();
}
=
0
;
=
0
;
switch
(
->
())
{
case
::
:
x
=
.
();
break
;
case
::
:
x
=
.
()+(
.
()-
.
)/
2
;
break
;
case
::
:
x
=
.
()-
.
;
break
;
}
switch
(
->
())
{
case
::
:
y
=
.
();
break
;
case
::
:
y
=
.
()+(
.
()-
.
)/
2
;
break
;
case
::
:
y
=
.
()-
.
;
break
;
}
->
(
.
,
.
);
if
(!
->
() && !
->
() && !
->
())
{
*
=
->
();
d2dRenderTarget
->
(
D2D1
::
((
)
x
, (
)
y
),
,
,
D2D1_DRAW_TEXT_OPTIONS_NO_SNAP
);
}
else
{
*
=
GetWindowsDirect2DObjectProvider
()->
();
;
*
;
{
=
->
(&
trimming
, &
inlineObject
);
CHECK_ERROR(SUCCEEDED(hr), L"You should check HRESULT to see why it failed.");
do
{
if
(!((((
)(
hr
)) >=
0
)))
throw
(
L"You should check HRESULT to see why it failed."
);}
while
(
0
);
}
->
(
->
()?
DWRITE_WORD_WRAPPING_WRAP
:
DWRITE_WORD_WRAPPING_NO_WRAP
);
if
(
->
())
{
->
(&
->
,
->
.
());
}
switch
(
->
())
{
case
::
:
->
(
DWRITE_TEXT_ALIGNMENT_LEADING
);
break
;
case
::
:
->
(
DWRITE_TEXT_ALIGNMENT_CENTER
);
break
;
case
::
:
->
(
DWRITE_TEXT_ALIGNMENT_TRAILING
);
break
;
}
if
(!
->
() && !
->
())
{
switch
(
->
())
{
case
::
:
->
(
DWRITE_PARAGRAPH_ALIGNMENT_NEAR
);
break
;
case
::
:
->
(
DWRITE_PARAGRAPH_ALIGNMENT_CENTER
);
break
;
case
::
:
->
(
DWRITE_PARAGRAPH_ALIGNMENT_FAR
);
break
;
}
}
=
;
if
(
->
() && !
->
() && !
->
())
{
textBounds
(
(
textBounds
.
,
y
),
(
.
(),
.
));
}
->
((
)
textBounds
.
());
->
((
)
textBounds
.
());
*
=
->
();
d2dRenderTarget
->
(
D2D1
::
((
)
textBounds
.
(), (
)
textBounds
.
()),
,
,
D2D1_DRAW_TEXT_OPTIONS_NO_SNAP
);
->
(&
trimming
,
inlineObject
);
if
(
!=
textBounds
.
())
{
=
textBounds
.
();
();
}
}
}
void
GuiSolidLabelElementRenderer
::
()
{
if
(
)
{
=
->
();
if
(
color
)
{
(
);
(
);
}
=
->
();
if
(
font
)
{
(
);
(
);
}
}
->
();
();
}
void
GuiImageFrameElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
&&
->
())
{
*
=
->
()
(
->
());
->
(
frame
,
->
());
if
(
->
())
{
(
0
,
0
);
}
else
{
frame
->
();
}
}
else
{
0
;
(
0
,
0
);
}
}
void
GuiImageFrameElementRenderer
::
()
{
}
void
GuiImageFrameElementRenderer
::
()
{
}
void
GuiImageFrameElementRenderer
::
RenderTargetChangedInternal
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
)
{
(
);
}
GuiImageFrameElementRenderer
::
GuiImageFrameElementRenderer
()
{
}
void
GuiImageFrameElementRenderer
::
(
)
{
if
(
)
{
*
=
->
();
=
D2D1
::
(
0
,
0
, (
)
.
, (
)
.
);
;
if
(
->
())
{
*
=
->
()
(
->
());
auto
=
frame
->
();
source
D2D1
::
(
0
,
0
, (
)
size
.
, (
)
size
.
);
destination
D2D1
::
((
)
.
, (
)
.
, (
)
.
, (
)
.
);
}
else
{
=
0
;
=
0
;
switch
(
->
())
{
case
::
:
x
=
.
();
break
;
case
::
:
x
=
.
()+(
.
()-
.
)/
2
;
break
;
case
::
:
x
=
.
()-
.
;
break
;
}
switch
(
->
())
{
case
::
:
y
=
.
();
break
;
case
::
:
y
=
.
()+(
.
()-
.
)/
2
;
break
;
case
::
:
y
=
.
()-
.
;
break
;
}
destination
D2D1
::
((
)
x
, (
)
y
, (
)(
x
+
.
), (
)(
y
+
.
));
}
*
=
nullptr
;
{
=
d2dRenderTarget
->
(&
d2dDeviceContext
);
{
if
(
d2dDeviceContext
)
{
d2dDeviceContext
->
();
}
d2dDeviceContext
=
nullptr
;
}
}
if
(
->
()
()==
::
&&
->
()>
0
)
{
=
->
();
for
(
=
0
;
i
<=
max
;
i
++)
{
<
>
=
->
(
->
()
(
i
),
->
());
if
(
d2dDeviceContext
)
{
d2dDeviceContext
->
(
frameBitmap
.
(),
destination
,
1.0f
,
D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC
,
source
);
}
else
{
d2dRenderTarget
->
(
frameBitmap
.
(),
destination
,
1.0f
,
D2D1_BITMAP_INTERPOLATION_MODE_LINEAR
,
source
);
}
}
}
else
{
if
(
d2dDeviceContext
)
{
d2dDeviceContext
->
(
.
(),
destination
,
1.0f
,
D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC
,
source
);
}
else
{
d2dRenderTarget
->
(
.
(),
destination
,
1.0f
,
D2D1_BITMAP_INTERPOLATION_MODE_LINEAR
,
source
);
}
}
if
(
d2dDeviceContext
)
{
d2dDeviceContext
->
();
}
}
}
void
GuiImageFrameElementRenderer
::
()
{
(
);
}
void
GuiPolygonElementRenderer
::
()
{
.
(
->
());
if
(
.
() >
0
)
{
(&
0
], &
->
(
0
),
sizeof
(
)*
->
());
}
if
(
.
() >=
3
)
{
*
=
0
;
=
GetWindowsDirect2DObjectProvider
()->
()->
(&
pg
);
CHECK_ERROR(SUCCEEDED(hr), L"You should check HRESULT to see why it failed.");
do
{
if
(!((((
)(
hr
)) >=
0
)))
throw
(
L"You should check HRESULT to see why it failed."
);}
while
(
0
);
pg
;
(
(
0
,
0
));
}
}
void
GuiPolygonElementRenderer
::
()
{
if
(
)
{
nullptr
;
}
}
void
GuiPolygonElementRenderer
::
(
)
{
if
(
)
{
*
=
0
;
=
(&
pgs
);
CHECK_ERROR(SUCCEEDED(hr), L"You should check HRESULT to see why it failed.");
do
{
if
(!((((
)(
hr
)) >=
0
)))
throw
(
L"You should check HRESULT to see why it failed."
);}
while
(
0
);
;
p
.
= (
)(
0
].
+
.
) +
0.5f
;
p
.
= (
)(
0
].
+
.
) +
0.5f
;
pgs
->
(
p
,
);
for
(
=
1
;
i
<
.
();
i
++)
{
p
.
= (
)(
i
].
+
.
) +
0.5f
;
p
.
= (
)(
i
].
+
.
) +
0.5f
;
pgs
->
(
p
);
}
pgs
->
(
);
pgs
->
();
pgs
->
();
}
}
void
GuiPolygonElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
)
{
if
(
==
)
{
if
(
)
{
if
(
->
())
{
->
(
);
->
();
=
->
(
);
}
if
(
->
())
{
->
(
);
->
();
=
->
(
);
}
}
}
else
{
if
(
)
{
->
(
);
->
(
);
}
if
(
)
{
->
();
->
();
=
->
(
);
=
->
(
);
}
}
}
void
GuiPolygonElementRenderer
::
()
{
->
();
->
();
(
0
,
);
();
}
void
GuiPolygonElementRenderer
::
()
{
();
(
,
0
);
}
void
GuiPolygonElementRenderer
::
RenderTargetChangedInternal
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
)
{
(
,
);
}
GuiPolygonElementRenderer
::
GuiPolygonElementRenderer
()
{
}
void
GuiPolygonElementRenderer
::
(
)
{
if
(
&&
)
{
*
=
->
();
=(
.
()-
.
)/
2
+
.
;
=(
.
()-
.
)/
2
+
.
;
,
;
d2dRenderTarget
->
(&
oldT
);
newT
D2D1
::
::
((
)
offsetX
, (
)
offsetY
);
d2dRenderTarget
->
(&
newT
);
d2dRenderTarget
->
(
.
(),
);
d2dRenderTarget
->
(
.
(),
);
d2dRenderTarget
->
(&
oldT
);
}
}
void
GuiPolygonElementRenderer
::
()
{
->
();
(
,
);
bool
=
false
;
if
(
.
()!=
->
())
{
polygonModified
=
true
;
}
else
{
for
(
=
0
;
i
<
.
();
i
++)
{
if
(
i
]
->
(
i
))
{
polygonModified
=
true
;
break
;
}
}
}
if
(
polygonModified
)
{
();
();
}
}
void
GuiColorizedTextElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
)
{
.
(
->
().
());
for
(
=
0
;
i
<
.
();
i
++)
{
text
::
=
->
().
(
i
);
;
newEntry
.
.
text
entry
.
.
text
;
newEntry
.
.
=
->
(
newEntry
.
.
text
);
newEntry
.
.
entry
.
.
;
newEntry
.
.
=
->
(
newEntry
.
.
);
newEntry
.
.
text
entry
.
.
text
;
newEntry
.
.
=
->
(
newEntry
.
.
text
);
newEntry
.
.
entry
.
.
;
newEntry
.
.
=
->
(
newEntry
.
.
);
newEntry
.
.
text
entry
.
.
text
;
newEntry
.
.
=
->
(
newEntry
.
.
text
);
newEntry
.
.
entry
.
.
;
newEntry
.
.
=
->
(
newEntry
.
.
);
i
]
newEntry
;
}
}
}
void
GuiColorizedTextElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
)
{
for
(
=
0
;
i
<
.
();
i
++)
{
->
(
i
].
.
text
);
->
(
i
].
.
);
->
(
i
].
.
text
);
->
(
i
].
.
);
->
(
i
].
.
text
);
->
(
i
].
.
);
}
.
(
0
);
}
}
void
GuiColorizedTextElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
)
{
->
();
=
->
(
);
}
}
void
GuiColorizedTextElementRenderer
::
(
IWindowsDirect2DRenderTarget
*
)
{
if
(
)
{
if
(
)
{
->
(
);
=
0
;
}
}
}
void
GuiColorizedTextElementRenderer
::
()
{
(
);
(
);
}
void
GuiColorizedTextElementRenderer
::
()
{
IWindowsDirect2DResourceManager
*
=
GetWindowsDirect2DResourceManager
();
if
(
)
{
->
().
(
nullptr
);
resourceManager
->
DestroyDirect2DTextFormat
(
);
resourceManager
->
DestroyDirect2DCharMeasurer
(
);
}
->
();
if
(
.
==
L""
)
.
()->
()->
().
;
if
(
.
==
0
)
.
=
12
;
=
resourceManager
->
(
);
->
().
(
resourceManager
->
CreateDirect2DCharMeasurer
(
).
());
}
text
::
*
GuiColorizedTextElementRenderer
::
()
{
return
0
;
}
void
GuiColorizedTextElementRenderer
::
()
{
=
0
;
=
0
;
->
(
this
);
}
void
GuiColorizedTextElementRenderer
::
()
{
(
);
(
);
IWindowsDirect2DResourceManager
*
=
GetWindowsDirect2DResourceManager
();
if
(
)
{
resourceManager
->
DestroyDirect2DTextFormat
(
);
resourceManager
->
DestroyDirect2DCharMeasurer
(
);
}
}
void
GuiColorizedTextElementRenderer
::
RenderTargetChangedInternal
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
)
{
(
);
(
);
(
);
(
);
->
().
(
);
}
void
GuiColorizedTextElementRenderer
::
(
)
{
if
(
)
{
*
=
->
();
wchar_t
=
->
();
=
->
();
(
viewPosition
,
.
());
=
->
().
(
(
viewBounds
.
,
viewBounds
.
)).
;
=
->
().
(
(
viewBounds
.
,
viewBounds
.
)).
;
=
->
()
->
() ?
->
() :
->
();
=
->
()
->
() ?
->
() :
->
();
bool
=
->
();
->
(
.
,
.
);
for
(
=
startRow
;
row
<=
endRow
;
row
++)
{
=
->
().
(
(
row
,
0
));
=
startRect
.
();
=
->
().
(
(
viewBounds
.
,
startPoint
.
)).
;
=
->
().
(
(
viewBounds
.
,
startPoint
.
)).
;
text
::
&
=
->
().
(
row
);
if
(
endColumn
+
1
<
line
.
&&
text
::
(
line
.
text
[
endColumn
]) &&
text
::
(
line
.
text
[
startColumn
+
1
]))
{
endColumn
++;
}
=
startColumn
==
0
?
0
:
line
.
[
startColumn
-
1
].
;
for
(
=
startColumn
;
column
<=
endColumn
;
column
++)
{
bool
=
false
;
if
(
selectionBegin
.
==
selectionEnd
.
)
{
inSelection
= (
row
==
selectionBegin
.
&&
selectionBegin
.
<=
column
&&
column
<
selectionEnd
.
);
}
else
if
(
row
==
selectionBegin
.
)
{
inSelection
=
selectionBegin
.
<=
column
;
}
else
if
(
row
==
selectionEnd
.
)
{
inSelection
=
column
<
selectionEnd
.
;
}
else
{
inSelection
=
selectionBegin
.
<
row
&&
row
<
selectionEnd
.
;
}
bool
=
column
==
line
.
;
=
crlf
?
0
:
line
.
[
column
].
;
if
(
colorIndex
>=
.
())
{
colorIndex
=
0
;
}
&
=
!
inSelection
?
colorIndex
].
:
focused
?
colorIndex
].
:
colorIndex
].
;
=
crlf
?
x
+
startRect
.
() /
2
:
line
.
[
column
].
;
=
x
-
viewPosition
.
+
.
;
=
startPoint
.
-
viewPosition
.
+
.
;
if
(
color
.
.
>
0
)
{
d2dRenderTarget
->
(
D2D1
::
((
)
tx
, (
)
ty
, (
)(
tx
+ (
x2
-
x
)), (
)(
ty
+
startRect
.
())),
color
.
);
}
if
(!
crlf
)
{
=
text
::
(
line
.
text
[
column
]) &&
column
+
1
<
line
.
&&
text
::
(
line
.
text
[
column
+
1
]) ?
2
:
1
;
d2dRenderTarget->DrawText(
(
passwordChar
? &
passwordChar
: &
line
.
text
[
column
]),
count
,
->
.
(),
D2D1
::
((
)
tx
, (
)
ty
, (
)
tx
+
1
, (
)
ty
+
1
),
color
.
,
D2D1_DRAW_TEXT_OPTIONS_NO_SNAP
,
DWRITE_MEASURING_MODE_GDI_NATURAL
);
if
(
count
==
2
)
column
++;
}
x
=
x2
;
}
}
if
(
->
() &&
->
().
(
->
()))
{
=
->
().
(
->
());
=
->
().
();
(
caretPoint
.
-
viewPosition
.
+
.
,
caretPoint
.
-
viewPosition
.
+
.
+
1
);
(
caretPoint
.
-
viewPosition
.
+
.
,
caretPoint
.
+
height
-
viewPosition
.
+
.
-
1
);
d2dRenderTarget
->
(
D2D1
::
((
)
p1
.
+
0.5f
, (
)
p1
.
),
D2D1
::
((
)
p2
.
+
0.5f
, (
)
p2
.
),
);
d2dRenderTarget
->
(
D2D1
::
((
)
p1
.
-
0.5f
, (
)
p1
.
),
D2D1
::
((
)
p2
.
-
0.5f
, (
)
p2
.
),
);
}
}
}
void
GuiColorizedTextElementRenderer
::
()
{
if
(
)
{
=
->
();
if
(
caretColor
)
{
(
);
(
);
}
}
}
void
GuiDirect2DElementRenderer
::
()
{
}
void
GuiDirect2DElementRenderer
::
()
{
}
void
GuiDirect2DElementRenderer
::
RenderTargetChangedInternal
(
IWindowsDirect2DRenderTarget
*
,
IWindowsDirect2DRenderTarget
*
)
{
*
=
GetWindowsDirect2DObjectProvider
()->
();
*
=
GetWindowsDirect2DObjectProvider
()->
();
if
(
)
{
GuiDirect2DElementEventArgs
(
,
->
(),
fdw
,
fd2d
,
());
->
BeforeRenderTargetChanged
.
(
arguments
);
}
if
(
)
{
GuiDirect2DElementEventArgs
(
,
->
(),
fdw
,
fd2d
,
());
->
.
(
arguments
);
}
}
GuiDirect2DElementRenderer
::
GuiDirect2DElementRenderer
()
{
}
GuiDirect2DElementRenderer
::
~
GuiDirect2DElementRenderer
()
{
}
void
GuiDirect2DElementRenderer
::
(
)
{
if
(
)
{
*
=
GetWindowsDirect2DObjectProvider
()->
();
*
=
GetWindowsDirect2DObjectProvider
()->
();
->
(
);
if
(!
->
IsClipperCoverWholeTarget
())
{
*
=
->
();
GuiDirect2DElementEventArgs
(
,
rt
,
fdw
,
fd2d
,
);
->
.
(
arguments
);
}
->
();
}
}
void
GuiDirect2DElementRenderer
::
()
{
}
}
}
}