#include "GuiGraphicsWindowsGDI.h"
#include "GuiGraphicsRenderersWindowsGDI.h"
#include "GuiGraphicsLayoutProviderWindowsGDI.h"
#include "..\..\Controls\GuiApplication.h"
#include "..\..\GraphicsElement\GuiGraphicsDocumentElement.h"
namespace
{
namespace
{
namespace
{
::
()
{
}
}
namespace
{
using
namespace
windows
;
using
namespace
elements
;
using
namespace
collections
;
class
:
public
,
public
{
protected
:
*
;
*
;
<
>
;
clipperCoverWholeTargetCounter
;
void
()
{
if
(
clipperCoverWholeTargetCounter
==
0
)
{
if
(
.
()==
0
)
{
->
();
}
else
{
=
();
->
(
new
(
clipper
.
(),
clipper
.
(),
clipper
.
(),
clipper
.
(),
true
));
}
}
}
public
:
(
*
)
:window(
)
,dc(
0
)
,clipperCoverWholeTargetCounter(
0
)
{
}
*
()
override
{
return
?
:
GetWindowsGDIObjectProvider
()->
(
);
}
void
()
override
{
=
GetWindowsGDIObjectProvider
()->
(
);
}
()
override
{
=
0
;
return
::
;
}
void
(
)
override
{
if
(
clipperCoverWholeTargetCounter
>
0
)
{
clipperCoverWholeTargetCounter
++;
}
else
{
=
();
;
currentClipper
.
=(
previousClipper
.
>
.
?
previousClipper
.
:
.
);
currentClipper
.
=(
previousClipper
.
>
.
?
previousClipper
.
:
.
);
currentClipper
.
=(
previousClipper
.
<
.
?
previousClipper
.
:
.
);
currentClipper
.
=(
previousClipper
.
<
.
?
previousClipper
.
:
.
);
if
(
currentClipper
.
<
currentClipper
.
&&
currentClipper
.
<
currentClipper
.
)
{
.
(
currentClipper
);
}
else
{
clipperCoverWholeTargetCounter
++;
}
}
();
}
void
()
override
{
if
(
.
()>
0
)
{
if
(
clipperCoverWholeTargetCounter
>
0
)
{
clipperCoverWholeTargetCounter
--;
}
else
{
.
(
.
()-
1
);
}
();
}
}
()
override
{
if
(
.
() ==
0
)
{
return
(
(
0
,
0
),
->
(
->
()));
}
else
{
return
.
() -
1
];
}
}
bool
IsClipperCoverWholeTarget
()
override
{
return
clipperCoverWholeTargetCounter
>
0
;
}
};
class
{
DEFINE_CACHED_RESOURCE_ALLOCATOR(Color, Ptr<WinPen>)
public
:
static
const
=
32
;
struct
{
<
>
;
;
bool
(
const
&
)
const
{
return
false
;}
bool
(
const
&
)
const
{
return
true
;} };
struct
{
;
<
>
;
bool
(
const
&
)
const
{
return
false
;}
bool
(
const
&
)
const
{
return
true
;} };
<
,
>
;
<
>
;
public
:
<
>
(
const
&
) {
=
.
().
(
);
if
(
index
!=-
1
) {
=
.
().
(
index
);
package
.
++;
.
(
,
package
);
return
package
.
; }
<
>
;
for
(
=
0
;
i
<
.
();
i
++) {
if
(
i
].
) {
=
i
];
.
(
i
);
resource
deadPackage
.
;
break
; } }
if
(!
resource
) {
resource
(
); }
;
package
.
resource
;
package
.
=
1
;
.
(
,
package
);
return
package
.
; }
void
(
const
&
) {
=
.
().
(
);
if
(
index
!=-
1
) {
=
.
().
(
index
);
package
.
--;
if
(
package
.
==
0
) {
.
(
);
if
(
.
()==
) {
.
(
-
1
); }
;
deadPackage
.
;
deadPackage
.
package
.
;
.
(
0
,
deadPackage
); }
else
{
.
(
,
package
); } } }
public
:
<
>
(
)
{
return new WinPen(PS_SOLID, 1, RGB(color.r, color.g, color.b));
return
new
(
0
,
1
, ((
)(((
)(
.
)|((
)((
)(
.
))<<
8
))|(((
)(
)(
.
))<<
16
))));
}
};
class
{
DEFINE_CACHED_RESOURCE_ALLOCATOR(Color, Ptr<WinBrush>)
public
:
static
const
=
32
;
struct
{
<
>
;
;
bool
(
const
&
)
const
{
return
false
;}
bool
(
const
&
)
const
{
return
true
;} };
struct
{
;
<
>
;
bool
(
const
&
)
const
{
return
false
;}
bool
(
const
&
)
const
{
return
true
;} };
<
,
>
;
<
>
;
public
:
<
>
(
const
&
) {
=
.
().
(
);
if
(
index
!=-
1
) {
=
.
().
(
index
);
package
.
++;
.
(
,
package
);
return
package
.
; }
<
>
;
for
(
=
0
;
i
<
.
();
i
++) {
if
(
i
].
) {
=
i
];
.
(
i
);
resource
deadPackage
.
;
break
; } }
if
(!
resource
) {
resource
(
); }
;
package
.
resource
;
package
.
=
1
;
.
(
,
package
);
return
package
.
; }
void
(
const
&
) {
=
.
().
(
);
if
(
index
!=-
1
) {
=
.
().
(
index
);
package
.
--;
if
(
package
.
==
0
) {
.
(
);
if
(
.
()==
) {
.
(
-
1
); }
;
deadPackage
.
;
deadPackage
.
package
.
;
.
(
0
,
deadPackage
); }
else
{
.
(
,
package
); } } }
public
:
<
>
(
)
{
return color.a==0?new WinBrush:new WinBrush(RGB(color.r, color.g, color.b));
return
.
==
0
?
new
:
new
(((
)(((
)(
.
)|((
)((
)(
.
))<<
8
))|(((
)(
)(
.
))<<
16
))));
}
};
class
{
DEFINE_CACHED_RESOURCE_ALLOCATOR(FontProperties, Ptr<WinFont>)
public
:
static
const
=
32
;
struct
{
<
>
;
;
bool
(
const
&
)
const
{
return
false
;}
bool
(
const
&
)
const
{
return
true
;} };
struct
{
;
<
>
;
bool
(
const
&
)
const
{
return
false
;}
bool
(
const
&
)
const
{
return
true
;} };
<
,
>
;
<
>
;
public
:
<
>
(
const
&
) {
=
.
().
(
);
if
(
index
!=-
1
) {
=
.
().
(
index
);
package
.
++;
.
(
,
package
);
return
package
.
; }
<
>
;
for
(
=
0
;
i
<
.
();
i
++) {
if
(
i
].
) {
=
i
];
.
(
i
);
resource
deadPackage
.
;
break
; } }
if
(!
resource
) {
resource
(
); }
;
package
.
resource
;
package
.
=
1
;
.
(
,
package
);
return
package
.
; }
void
(
const
&
) {
=
.
().
(
);
if
(
index
!=-
1
) {
=
.
().
(
index
);
package
.
--;
if
(
package
.
==
0
) {
.
(
);
if
(
.
()==
) {
.
(
-
1
); }
;
deadPackage
.
;
deadPackage
.
package
.
;
.
(
0
,
deadPackage
); }
else
{
.
(
,
package
); } } }
public
:
static
<
>
(
const
&
)
{
=
.
<
0
?
.
:-
.
;
return new WinFont(value.fontFamily, size, 0, 0, 0, (value.bold?FW_BOLD:FW_NORMAL), value.italic, value.underline, value.strikeline, value.antialias);
return
new
(
.
,
size
,
0
,
0
,
0
, (
.
?
700
:
400
),
.
,
.
,
.
,
.
);
}
<
>
(
const
&
)
{
return
(
);
}
};
class
CachedCharMeasurerAllocator
{
DEFINE_CACHED_RESOURCE_ALLOCATOR(FontProperties, Ptr<text::CharMeasurer>)
public
:
static
const
=
32
;
struct
{
<
text
::
>
;
;
bool
(
const
&
)
const
{
return
false
;}
bool
(
const
&
)
const
{
return
true
;} };
struct
{
;
<
text
::
>
;
bool
(
const
&
)
const
{
return
false
;}
bool
(
const
&
)
const
{
return
true
;} };
<
,
>
;
<
>
;
public
:
<
text
::
>
(
const
&
) {
=
.
().
(
);
if
(
index
!=-
1
) {
=
.
().
(
index
);
package
.
++;
.
(
,
package
);
return
package
.
; }
<
text
::
>
;
for
(
=
0
;
i
<
.
();
i
++) {
if
(
i
].
) {
=
i
];
.
(
i
);
resource
deadPackage
.
;
break
; } }
if
(!
resource
) {
resource
(
); }
;
package
.
resource
;
package
.
=
1
;
.
(
,
package
);
return
package
.
; }
void
(
const
&
) {
=
.
().
(
);
if
(
index
!=-
1
) {
=
.
().
(
index
);
package
.
--;
if
(
package
.
==
0
) {
.
(
);
if
(
.
()==
) {
.
(
-
1
); }
;
deadPackage
.
;
deadPackage
.
package
.
;
.
(
0
,
deadPackage
); }
else
{
.
(
,
package
); } } }
protected
:
class
:
public
text
::
{
protected
:
<
>
;
;
(
text
::
,
*
)
{
if
(
)
{
*
=
dynamic_cast
<
*>(
);
*
=
gdiRenderTarget
->
();
dc
->
(
);
=
text
::
(
.
[
0
]) &&
text
::
(
.
[
1
]) ?
2
:
1
;
=
dc
->
(
.
,
count
, -
1
);
return
(
size
.
,
size
.
);
}
else
{
return
(
0
,
0
);
}
}
(
text
::
,
*
)
{
return
(
,
).
;
}
(
*
)
{
if
(
)
{
return
({
L' '
},
).
;
}
else
{
return
;
}
}
public
:
(
<
>
,
)
:
text
::
(
)
,size(
)
,font(
)
{
}
};
public
:
<
text
::
>
(
const
&
)
{
return
new
(
::
(
),
.
);
}
};
class
WindowsGDIImageFrameCache
:
public
,
public
{
protected
:
IWindowsGDIResourceManager
*
;
*
;
<
>
;
<
>
;
public
:
WindowsGDIImageFrameCache
(
IWindowsGDIResourceManager
*
)
:resourceManager(
)
{
}
~
WindowsGDIImageFrameCache
()
{
}
void
(
*
)
override
{
=
;
=
->
();
new
(
size
.
,
size
.
,
::
,
true
);
*
=
GetWindowsGDIObjectProvider
()->
(
);
;
rect
.
=
0
;
rect
.
=
0
;
rect
.
=(
)
size
.
;
rect
.
=(
)
size
.
;
wicBitmap
->
(&
rect
, (
)
(), (
)(
()*
size
.
), (
*)
()[
0
]);
(
false
);
}
void
(
*
)
override
{
->
(
);
}
*
()
{
return
;
}
<
>
(
bool
)
{
if
(
)
{
return
;
}
else
{
if
(!
)
{
=
();
=
();
new
(
w
,
h
,
::
,
true
);
for
(
=
0
;
y
<
h
;
y
++)
{
*
=
()[
y
];
*
=
()[
y
];
for
(
=
0
;
x
<
w
;
x
++)
{
=(
read
[
0
]+
read
[
1
]+
read
[
2
])/
6
+
read
[
3
]/
2
;
write
[
0
]=
g
;
write
[
1
]=
g
;
write
[
2
]=
g
;
write
[
3
]=
read
[
3
];
read
+=
4
;
write
+=
4
;
}
}
(
false
);
}
return
;
}
}
};
class
WindowsGDIResourceManager
:
public
GuiGraphicsResourceManager
,
public
IWindowsGDIResourceManager
,
public
INativeControllerListener
{
typedef
<
<
WindowsGDIImageFrameCache
>>
;
protected
:
<
<
>>
;
<
>
;
<
>
;
;
;
;
CachedCharMeasurerAllocator
;
;
public
:
WindowsGDIResourceManager
()
{
new
;
}
*
(
*
)
override
{
return
GetWindowsGDIObjectProvider
()->
(
);
}
void
(
*
)
override
{
}
void
(
*
)
override
{
}
IGuiGraphicsLayoutProvider
*
()
override
{
return
.
();
}
void
(
*
)
override
{
*
=
new
(
);
.
(
renderTarget
);
GetWindowsGDIObjectProvider
()->
(
,
renderTarget
);
}
void
(
*
)
override
{
*
=
dynamic_cast
<
*>(
GetWindowsGDIObjectProvider
()->
(
));
GetWindowsGDIObjectProvider
()->
(
,
0
);
.
(
renderTarget
);
}
<
windows
::
>
()
override
{
if
(!
)
{
[] = {
1
,
1
};
focusRectanglePen = new WinPen(PS_USERSTYLE, PS_ENDCAP_FLAT, PS_JOIN_BEVEL, 1, RGB(255, 255, 255), (DWORD)(sizeof(styleArray) / sizeof(*styleArray)), styleArray);
new
(
7
,
0x00000200
,
0x00001000
,
1
, ((
)(((
)(
255
)|((
)((
)(
255
))<<
8
))|(((
)(
)(
255
))<<
16
))), (
)(
sizeof
(
styleArray
) /
sizeof
(*
styleArray
)),
styleArray
);
}
return
;
}
<
windows
::
>
(
)
override
{
return
.
(
);
}
void
(
)
override
{
.
(
);
}
<
windows
::
>
(
)
override
{
return
.
(
);
}
void
(
)
override
{
.
(
);
}
<
windows
::
>
(
const
&
)
override
{
return
.
(
);
}
void
(
const
&
)
override
{
.
(
);
}
<
elements
::
text
::
>
(
const
&
)
override
{
return
.
(
);
}
void
(
const
&
)
override
{
.
(
);
}
<
windows
::
>
(
*
,
bool
)
override
{
<
>
=
->
(
this
);
if
(
cache
)
{
return
cache
.
<
WindowsGDIImageFrameCache
>()
(
);
}
else
{
WindowsGDIImageFrameCache
*
=
new
WindowsGDIImageFrameCache
(
this
);
if
(
->
(
this
,
gdiCache
))
{
return
gdiCache
->
(
);
}
else
{
return
0
;
}
}
}
void
(
*
)
override
{
WindowsGDIImageFrameCache
*
=
->
(
this
).
<
WindowsGDIImageFrameCache
>().
();
.
(
cache
);
}
};
}
namespace
{
IWindowsGDIResourceManager
*
windowsGDIResourceManager
=
0
;
IWindowsGDIResourceManager
*
GetWindowsGDIResourceManager
()
{
return
windowsGDIResourceManager
;
}
void
SetWindowsGDIResourceManager
(
IWindowsGDIResourceManager
*
)
{
windowsGDIResourceManager
=
;
}
IWindowsGDIObjectProvider
*
=
0
;
IWindowsGDIObjectProvider
*
GetWindowsGDIObjectProvider
()
{
return
windowsGDIObjectProvider
;
}
void
SetWindowsGDIObjectProvider
(
IWindowsGDIObjectProvider
*
)
{
windowsGDIObjectProvider
=
;
}
}
}
}
using
namespace
vl
::
presentation
;
using
namespace
vl
::
presentation
::
elements
;
void
()
{
elements_windows_gdi
::
WindowsGDIResourceManager
;
SetGuiGraphicsResourceManager
(&
resourceManager
);
elements_windows_gdi
::
SetWindowsGDIResourceManager
(&
resourceManager
);
()->
()->
(&
resourceManager
);
elements_windows_gdi
::
GuiFocusRectangleElementRenderer
::
();
elements_windows_gdi
::
GuiSolidBorderElementRenderer
::
();
elements_windows_gdi
::
Gui3DBorderElementRenderer
::
();
elements_windows_gdi
::
Gui3DSplitterElementRenderer
::
();
elements_windows_gdi
::
GuiSolidBackgroundElementRenderer
::
();
elements_windows_gdi
::
GuiGradientBackgroundElementRenderer
::
();
elements_windows_gdi
::
GuiInnerShadowElementRenderer
::
();
elements_windows_gdi
::
GuiSolidLabelElementRenderer
::
();
elements_windows_gdi
::
GuiImageFrameElementRenderer
::
();
elements_windows_gdi
::
GuiPolygonElementRenderer
::
();
elements_windows_gdi
::
GuiColorizedTextElementRenderer
::
();
elements_windows_gdi
::
::
();
elements
::
::
GuiDocumentElementRenderer
::
();
();
elements_windows_gdi
::
SetWindowsGDIResourceManager
(
0
);
SetGuiGraphicsResourceManager
(
0
);
}