#include "GuiGraphicsTextElement.h"
namespace
{
using
namespace
collections
;
namespace
{
namespace
{
namespace
{
::
()
:text(
0
)
,att(
0
)
,availableOffsetCount(
0
)
,bufferLength(
0
)
,dataLength(
0
)
,lexerFinalState(-
1
)
,contextFinalState(-
1
)
{
}
::
()
{
}
::
(
)
{
if
(
<
1
)
=
1
;
=
-
%
;
if
(
bufferLength
<
)
{
bufferLength
+=
;
}
return
bufferLength
;
}
void
::
()
{
();
=
new
wchar_t
[
];
=
new
[
];
=
;
(
,
0
,
sizeof
(
wchar_t
)*
);
(
,
0
,
sizeof
(
)*
);
}
void
::
()
{
if
(
)
{
delete
[]
;
=
0
;
}
if
(
)
{
delete
[]
;
=
0
;
}
=
0
;
=
0
;
=
0
;
}
bool
::
()
{
return
&&
;
}
bool
::
(
,
,
const
wchar_t
*
,
)
{
if
(!
|| !
||
<
0
||
<
0
||
+
>
||
<
0
)
return
false
;
=
-
+
;
=
(
newDataLength
);
if
(
newBufferLength
!=
)
{
wchar_t
*
=
new
wchar_t
[
newBufferLength
];
(
newText
,
,
*
sizeof
(
wchar_t
));
(
newText
+
,
,
*
sizeof
(
wchar_t
));
(
newText
+
+
,
+
+
, (
-
-
)*
sizeof
(
wchar_t
));
*
=
new
[
newBufferLength
];
(
newAtt
,
,
*
sizeof
(
));
(
newAtt
+
,
0
,
*
sizeof
(
));
(
newAtt
+
+
,
+
+
, (
-
-
)*
sizeof
(
));
delete
[]
;
delete
[]
;
=
newText
;
=
newAtt
;
}
else
{
(
+
+
,
+
+
, (
-
-
)*
sizeof
(
wchar_t
));
(
+
+
,
+
+
, (
-
-
)*
sizeof
(
));
(
+
,
,
*
sizeof
(
wchar_t
));
(
+
,
0
,
*
sizeof
(
));
}
=
newDataLength
;
=
newBufferLength
;
if
(
>
)
{
=
;
}
return
true
;
}
::
(
)
{
if
(
<
0
||
>
)
return
();
=
-
;
;
line
.
();
line
.
(
0
,
0
,
+
,
count
);
(
line
.
,
+
,
count
*
sizeof
(
));
(
,
count
,
L""
,
0
);
return
line
;
}
void
::
(
&
)
{
=
;
(
oldDataLength
,
0
,
.
,
.
);
(
+
oldDataLength
,
.
,
.
*
sizeof
(
));
.
();
}
::
(
)
:rowHeight(
)
{
(
,
0
,
sizeof
(
));
}
::
()
{
}
void
::
(
*
)
{
if
(
!=
)
{
=
;
=
(
);
(
,
0
,
sizeof
(
));
}
}
::
(
)
{
=
.
();
if
(
0
<=
index
&&
index
<
65536
)
{
=
[
index
];
if
(
w
==
0
)
{
[
index
] =
w
=
(
,
);
}
return
w
;
}
else
if
(
index
<
0x110000
)
{
return
(
,
);
}
else
{
return
0
;
}
}
::
()
{
return
;
}
::
(
*
)
:ownerElement(
)
,charMeasurer(
0
)
,renderTarget(
0
)
,tabWidth(
1
)
,tabSpaceCount(
4
)
,passwordChar(
L'\0'
)
{
;
line
.
();
.
(
line
);
}
::
()
{
(
0
,
.
());
}
::
()
{
return
.
();
}
&
::
(
)
{
return
];
}
*
::
()
{
return
;
}
void
::
(
*
)
{
=
;
if
(
)
->
(
);
();
}
*
::
()
{
return
;
}
void
::
(
*
)
{
=
;
if
(
)
->
(
);
();
}
::
(
,
)
{
if
(!
(
) || !
(
) ||
>
)
return
L""
;
if
(
.
==
.
)
{
return
(
.
].
text
+
.
,
.
-
.
);
}
=
0
;
for
(
=
.
+
1
;
i
<
.
;
i
++)
{
count
+=
i
].
;
}
count
+=
.
].
-
.
;
count
+=
.
;
<
wchar_t
>
;
buffer
.
(
count
+(
.
-
.
)*
2
);
wchar_t
*
=&
buffer
0
];
for
(
=
.
;
i
<=
.
;
i
++)
{
wchar_t
*
=
i
].
text
;
=
0
;
if
(
i
==
.
)
{
text
+=
.
;
chars
=
i
].
-
.
;
}
else
if
(
i
==
.
)
{
chars
=
.
;
}
else
{
chars
=
i
].
;
}
if
(
i
!=
.
)
{
*
writing
++=
L'\r'
;
*
writing
++=
L'\n'
;
}
(
writing
,
text
,
chars
*
sizeof
(
wchar_t
));
writing
+=
chars
;
}
return
(&
buffer
0
],
buffer
.
());
}
::
()
{
return
(
(
0
,
0
),
(
.
()-
1
,
.
()-
1
].
));
}
void
::
(
const
&
)
{
(
(
0
,
0
),
(
.
()-
1
,
.
()-
1
].
),
);
}
bool
::
(
,
)
{
if
(
<
0
||
<
0
||
+
>
.
())
return
false
;
for
(
=
+
-
1
;
i
>=
;
i
--)
{
i
].
();
}
.
(
,
);
return
true
;
}
bool
::
(
)
{
return
0
<=
.
&&
.
<
.
() &&
0
<=
.
&&
.
<=
.
].
;
}
::
(
)
{
if
(
.
<
0
)
{
return
(
0
,
0
);
}
else
if
(
.
>=
.
())
{
return
(
.
()-
1
,
.
()-
1
].
);
}
else
{
&
=
.
];
if
(
.
<
0
)
{
return
(
.
,
0
);
}
else
if
(
.
>
line
.
)
{
return
(
.
,
line
.
);
}
else
{
return
;
}
}
}
::
(
,
,
const
wchar_t
**
,
*
,
)
{
if
(!
(
) || !
(
) ||
>
)
return
(-
1
, -
1
);
if
(
)
{
->
InvokeOnElementStateChanged
();
}
if
(
==
1
)
{
if
(
.
==
.
)
{
.
].
(
.
,
.
-
.
,
[
0
],
[
0
]);
}
else
{
if
(
.
-
.
>
1
)
{
(
.
+
1
,
.
-
.
-
1
);
}
=
.
].
-
.
+
.
;
.
].
(
.
+
1
]);
.
(
.
+
1
);
.
].
(
.
,
modifyCount
,
[
0
],
[
0
]);
}
return
(
.
,
.
+
[
0
]);
}
if
(
.
==
.
)
{
=
.
].
(
.
);
.
(
.
+
1
,
newLine
);
(
.
+
1
,
0
);
}
=
.
-
.
-
1
;
=
-
2
;
if
(
oldMiddleLines
<
newMiddleLines
)
{
for
(
=
oldMiddleLines
;
i
<
newMiddleLines
;
i
++)
{
;
line
.
();
.
(
.
,
line
);
}
}
else
if
(
oldMiddleLines
>
newMiddleLines
)
{
(
.
+
newMiddleLines
+
1
,
oldMiddleLines
-
newMiddleLines
);
}
.
+=
newMiddleLines
-
oldMiddleLines
;
.
].
(
.
,
.
].
-
.
,
[
0
],
[
0
]);
.
].
(
0
,
.
,
[
-
1
],
[
-
1
]);
for
(
=
1
;
i
<
-
1
;
i
++)
{
.
+
i
].
(
0
,
.
+
i
].
,
[
i
],
[
i
]);
}
return
(
.
,
[
-
1
]);
}
::
(
,
,
const
wchar_t
*
,
)
{
<
const
wchar_t
*>
;
<
>
;
const
wchar_t
*
=
;
const
wchar_t
*
=
;
while
(
true
)
{
if
(
current
==
+
)
{
inputs
.
(
previous
);
inputCounts
.
(
current
-
previous
);
break
;
}
else
if
(*
current
==
L'\r'
|| *
current
==
L'\n'
)
{
inputs
.
(
previous
);
inputCounts
.
(
current
-
previous
);
previous
=
current
+(
current
[
1
]==
L'\n'
?
2
:
1
);
current
=
previous
;
}
else
{
current
++;
}
}
return
(
,
, &
inputs
0
], &
inputCounts
0
],
inputs
.
());
}
::
(
,
,
const
wchar_t
*
)
{
return
(
,
,
,
(
));
}
::
(
,
,
const
&
)
{
return
(
,
,
.
(),
.
());
}
void
::
()
{
(
0
,
.
());
;
line
.
();
.
(
line
);
if
(
)
{
->
InvokeOnElementStateChanged
();
}
}
void
::
()
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
].
=
0
;
}
=
* (
?
->
({
L' '
}) :
1
);
if
(
==
0
)
{
=
1
;
}
if
(
)
{
->
InvokeOnElementStateChanged
();
}
}
::
()
{
return
;
}
void
::
(
)
{
if
(
<
1
)
=
1
;
if
(
!=
)
{
=
;
();
}
}
void
::
(
)
{
&
=
];
=
0
;
if
(
line
.
)
{
offset
=
line
.
[
line
.
-
1
].
;
}
for
(
=
line
.
;
i
<
line
.
;
i
++)
{
&
=
line
.
[
i
];
wchar_t
=
line
.
text
[
i
];
=
0
;
=
0
;
if
(
)
{
passwordWidth
=
?
->
({
}) :
1
;
}
if
(
c
==
L'\t'
)
{
width
=
-
offset
%
;
}
#if defined VCZH_MSVC
else
if
(
(
c
) && (
i
+
1
<
line
.
) &&
(
line
.
text
[
i
+
1
]))
{
width
=
?
passwordWidth
: (
?
->
({
c
,
line
.
text
[
i
+
1
] }) :
1
);
offset
+=
width
;
att
.
= (
int
)
offset
;
line
.
[
i
+
1
].
= (
int
)
offset
;
i
++;
continue
;
}
#endif
else
{
width
=
?
passwordWidth
: (
?
->
({
c
}) :
1
);
}
offset
+=
width
;
att
.
= (
int
)
offset
;
}
line
.
=
line
.
;
}
::
(
)
{
if
(
<
0
||
>=
.
())
return
-
1
;
&
=
];
if
(
line
.
==
0
)
{
return
0
;
}
else
{
(
);
return
line
.
[
line
.
-
1
].
;
}
}
::
()
{
return
?
->
() :
1
;
}
::
()
{
=
0
;
for
(
=
0
;
i
<
.
();
i
++)
{
=
(
i
);
if
(
width
<
rowWidth
)
{
width
=
rowWidth
;
}
}
return
width
;
}
::
()
{
return
.
() *
();
}
::
(
)
{
=
();
if
(
.
<
0
)
{
.
=
0
;
}
else
if
(
.
>=
h
*
.
())
{
.
=
h
*
.
()-
1
;
}
=
.
/
h
;
if
(
.
<
0
)
{
return
(
row
,
0
);
}
else
if
(
.
>=
(
row
))
{
return
(
row
,
row
].
);
}
&
=
row
];
=
0
,
=
line
.
;
=
0
,
=
line
.
[
line
.
-
1
].
;
while
(
i2
-
i1
>
1
)
{
=(
i1
+
i2
)/
2
;
=
i
==
0
?
0
:
line
.
[
i
-
1
].
;
if
(
.
<
p
)
{
i2
=
i
;
p2
=
p
;
}
else
{
i1
=
i
;
p1
=
p
;
}
}
#if defined VCZH_MSVC
if
(
(
line
.
text
[
i1
]) &&
i1
>
0
&&
(
line
.
text
[
i1
-
1
]))
{
i1
--;
}
#endif
return
(
row
,
i1
);
}
::
(
)
{
if
(
(
))
{
=
.
*
();
if
(
.
==
0
)
{
return
(
0
,
y
);
}
else
{
(
.
);
&
=
.
];
return
(
line
.
[
.
-
1
].
,
y
);
}
}
else
{
return
(-
1
, -
1
);
}
}
::
(
)
{
=
(
);
if
(
point
(-
1
, -
1
))
{
return
(-
1
, -
1
, -
1
, -
1
);
}
else
{
=
();
&
=
.
];
if
(
.
==
line
.
)
{
return
(
point
,
(
h
/
2
,
h
));
}
else
{
return
(
point
,
(
line
.
[
.
].
-
point
.
,
h
));
}
}
}
wchar_t
::
()
{
return
;
}
void
::
(
wchar_t
)
{
=
;
();
}
}
using
namespace
text
;
::
()
:callback(
0
)
,isVisuallyEnabled(
true
)
,isFocused(
false
)
,caretVisible(
false
)
,lines(
this
)
{
}
text
::
&
::
()
{
return
;
}
::
*
::
()
{
return
;
}
void
::
(
*
)
{
=
;
if
(!
)
{
.
(
0
);
}
}
const
::
&
::
()
{
return
;
}
void
::
(
const
&
)
{
(
,
);
if
(
)
->
();
InvokeOnElementStateChanged
();
}
void
::
(
)
{
=
.
();
for
(
=
0
;
i
<
lineCount
;
i
++)
{
auto
&
=
.
(
i
);
line
.
= -
1
;
line
.
= -
1
;
for
(
=
0
;
j
<
line
.
;
j
++)
{
line
.
[
j
].
= (
)
;
}
}
}
const
&
::
()
{
return
;
}
void
::
(
const
&
)
{
if
(
)
{
;
if
(
)
{
->
();
}
InvokeOnElementStateChanged
();
}
}
wchar_t
::
()
{
return
.
();
}
void
::
(
wchar_t
)
{
if
(
.
()!=
)
{
.
(
);
InvokeOnElementStateChanged
();
}
}
::
()
{
return
;
}
void
::
(
)
{
if
(
)
{
;
InvokeOnElementStateChanged
();
}
}
bool
::
()
{
return
;
}
void
::
(
bool
)
{
if
(
!=
)
{
=
;
InvokeOnElementStateChanged
();
}
}
bool
::
()
{
return
;
}
void
::
(
bool
)
{
if
(
!=
)
{
=
;
InvokeOnElementStateChanged
();
}
}
::
()
{
return
;
}
void
::
(
)
{
;
InvokeOnElementStateChanged
();
}
::
()
{
return
;
}
void
::
(
)
{
;
InvokeOnElementStateChanged
();
}
bool
::
()
{
return
;
}
void
::
(
bool
)
{
=
;
InvokeOnElementStateChanged
();
}
::
()
{
return
;
}
void
::
(
)
{
if
(
)
{
;
InvokeOnElementStateChanged
();
}
}
}
}
}