#include "GuiTextCommonInterface.h"
#include "../../GraphicsHost/GuiGraphicsHost.h"
#include <math.h>
namespace
{
namespace
{
namespace
{
using
namespace
elements
;
using
namespace
elements
::
text
;
using
namespace
compositions
;
GuiTextBoxCommonInterface
::
::
(
elements
::
*
,
compositions
::
*
)
:textElement(
)
,textComposition(
)
{
}
GuiTextBoxCommonInterface
::
::
()
{
}
GuiTextBoxCommonInterface
::
::
(
)
{
return
;
}
GuiTextBoxCommonInterface
::
::
(
)
{
return
;
}
void
GuiTextBoxCommonInterface
::
::
(
,
&
,
&
)
{
;
;
}
GuiTextBoxCommonInterface
::
::()
{
return
->
().
()/
->
().
();
}
bool
GuiTextBoxCommonInterface
::
::
(
,
,
const
&
,
&
)
{
return
true
;
}
void
GuiTextBoxCommonInterface
::
()
{
.
(
->
());
}
void
GuiTextBoxCommonInterface
::
()
{
.
(
->
());
}
void
GuiTextBoxCommonInterface
::
()
{
*
=
->
();
if
(
host
)
{
=
->
().
(
->
());
=
->
();
=
caret
.
-
view
.
;
=
caret
.
-
view
.
;
host
->
(
(
x
,
y
),
);
}
}
void
GuiTextBoxCommonInterface
::
(
,
bool
)
{
=
->
();
=
->
();
#if defined VCZH_MSVC
if
(
0
<=
.
&&
.
<
->
().
())
{
&
=
->
().
(
.
);
if
(
.
>
0
&&
(
line
.
text
[
.
-
1
]) &&
(
line
.
text
[
.
]))
{
if
(
oldBegin
)
{
.
--;
}
else
if
(
oldBegin
)
{
.
++;
}
}
}
#endif
->
().
(
);
if
(!
)
{
->
(
);
}
->
(
);
if
(
)
{
*
=
->
();
if
(
host
)
{
if
(
host
->
() ==
->
())
{
->
(
true
);
}
}
}
=
->
().
(
);
=
(
->
(),
->
().
());
=
view
.
();
if
(
view
.
>
view
.
&&
view
.
>
view
.
)
{
if
(
bounds
.
<
view
.
)
{
viewPoint
.
=
bounds
.
;
}
else
if
(
bounds
.
>
view
.
)
{
viewPoint
.
=
bounds
.
-
view
.
();
}
if
(
bounds
.
<
view
.
)
{
viewPoint
.
=
bounds
.
;
}
else
if
(
bounds
.
>
view
.
)
{
viewPoint
.
=
bounds
.
-
view
.
();
}
}
->
(
viewPoint
);
();
=
->
();
=
->
();
if
(
oldBegin
newBegin
||
oldEnd
!=
newEnd
)
{
::
;
arguments
.
oldBegin
;
arguments
.
oldEnd
;
arguments
.
newBegin
;
arguments
.
newEnd
;
arguments
.
=
;
for
(
=
0
;
i
<
.
();
i
++)
{
i
]
(
arguments
);
}
.
(
->
());
}
}
void
GuiTextBoxCommonInterface
::
(
,
,
const
&
,
bool
)
{
if
(
)
{
=
;
;
temp
;
}
=
;
=
;
=
->
().
(
,
);
=
;
if
(
->
(
,
,
originalText
,
inputText
))
{
{
::
;
arguments
.
originalStart
;
arguments
.
originalEnd
;
arguments
.
originalText
;
arguments
.
inputText
;
arguments
.
=
;
arguments
.
=
;
for
(
=
0
;
i
<
.
();
i
++)
{
i
]
(
arguments
);
}
inputText
arguments
.
;
if
(
originalStart
arguments
.
||
originalEnd
!=
arguments
.
)
{
originalStart
arguments
.
;
originalEnd
arguments
.
;
originalText
->
().
(
originalStart
,
originalEnd
);
originalStart
;
originalEnd
;
}
}
SPIN_LOCK(elementModifyLock)
if
(
bool
=
true
)
for
(
const
::
&
=
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
->
().
(
,
,
inputText
);
}
->
(
originalStart
,
originalEnd
,
originalText
,
,
,
inputText
);
++;
{
::
;
arguments
.
originalStart
;
arguments
.
originalEnd
;
arguments
.
originalText
;
arguments
.
;
arguments
.
;
arguments
.
inputText
;
arguments
.
=
;
arguments
.
=
;
for
(
=
0
;
i
<
.
();
i
++)
{
i
]
(
arguments
);
}
}
(
,
false
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]
(
);
}
->
.
(
->
());
}
}
bool
GuiTextBoxCommonInterface
::
(
,
bool
,
bool
)
{
if
(
*
=
internalShortcutKeyManager
(
,
,
false
,
))
{
(
->
());
item
->
.
(
arguments
);
return
true
;
}
=
->
();
=
->
();
switch
(
)
{
case
::
:
if
(
&&
() && !
&& !
)
{
();
return
true
;
}
break
;
case
::
:
if
(
&&
() && !
&& !
)
{
if
(
())
{
preventEnterDueToAutoComplete
=
true
;
return
true
;
}
}
break
;
case
::
:
if
(
&&
() && !
&& !
)
{
();
}
else
{
end
.
--;
(
end
,
);
}
return
true
;
case
::
:
if
(
&&
() && !
&& !
)
{
();
}
else
{
end
.
++;
(
end
,
);
}
return
true
;
case
::
:
{
if
(
)
{
(
->
(
end
),
);
}
else
{
if
(
end
.
==
0
)
{
if
(
end
.
>
0
)
{
end
.
--;
end
->
().
(
end
);
end
.
=
->
().
(
end
.
).
;
}
}
else
{
end
.
--;
}
(
end
,
);
}
}
return
true
;
case
::
:
{
if
(
)
{
(
->
(
end
),
);
}
else
{
if
(
end
.
==
->
().
(
end
.
).
)
{
if
(
end
.
<
->
().
()-
1
)
{
end
.
++;
end
.
=
0
;
}
}
else
{
end
.
++;
}
(
end
,
);
}
}
return
true
;
case
::
:
{
if
(
)
{
(
(
0
,
0
),
);
}
else
{
end
.
=
0
;
(
end
,
);
}
}
return
true
;
case
::
:
{
if
(
)
{
end
.
=
->
().
()-
1
;
}
end
.
=
->
().
(
end
.
).
;
(
end
,
);
}
return
true
;
case
::
:
{
end
.
-=
->
();
(
end
,
);
}
return
true
;
case
::
:
{
end
.
+=
->
();
(
end
,
);
}
return
true
;
case
::
:
if
(!
)
{
if
(
&& !
)
{
(
::
,
true
,
true
);
(
::
,
false
,
false
);
}
else
if
(!
&&
)
{
(
::
,
true
,
false
);
(
::
,
false
,
false
);
}
else
{
if
(
begin
end
)
{
(
::
,
true
,
false
);
}
SetSelectionTextAsKeyInput
(
L""
);
}
return
true
;
}
break
;
case
::
:
if
(!
)
{
if
(
&& !
)
{
(
::
,
true
,
true
);
(
::
,
false
,
false
);
}
else
if
(!
&&
)
{
(
::
,
true
,
false
);
(
::
,
false
,
false
);
}
else
{
if
(
begin
end
)
{
(
::
,
true
,
false
);
}
SetSelectionTextAsKeyInput
(
L""
);
}
return
true
;
}
break
;
default
:;
}
return
false
;
}
void
GuiTextBoxCommonInterface
::
(
compositions
::
*
,
compositions
::
&
)
{
->
(
true
);
->
(
true
);
();
}
void
GuiTextBoxCommonInterface
::
(
compositions
::
*
,
compositions
::
&
)
{
->
(
false
);
->
(
false
);
}
void
GuiTextBoxCommonInterface
::
(
compositions
::
*
,
compositions
::
&
)
{
->
(!
->
());
}
void
GuiTextBoxCommonInterface
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(
->
() &&
.
==
.
)
{
=
true
;
=
(
(
.
,
.
));
(
pos
,
.
);
}
}
void
GuiTextBoxCommonInterface
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(
->
() &&
.
==
.
)
{
=
false
;
}
}
void
GuiTextBoxCommonInterface
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(
->
() &&
.
==
.
)
{
if
(
)
{
=
(
(
.
,
.
));
(
pos
,
true
);
}
}
}
void
GuiTextBoxCommonInterface
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(
->
() &&
.
==
.
)
{
if
(
(
.
,
.
,
.
))
{
.
=
true
;
}
}
}
void
GuiTextBoxCommonInterface
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(
preventEnterDueToAutoComplete
)
{
preventEnterDueToAutoComplete
=
false
;
if
(
.
== (
wchar_t
)
::
)
{
return
;
}
}
if
(
->
() &&
.
==
.
)
{
if
(!
&&
.
!= (
wchar_t
)
::
&&
.
!= (
wchar_t
)
::
&&
(
.
!= (
wchar_t
)
::
||
->
()) &&
!
.
)
{
SetSelectionTextAsKeyInput
(
(
.
));
}
}
}
void
GuiTextBoxCommonInterface
::
(
elements
::
*
,
compositions
::
*
,
*
,
compositions
::
*
,
compositions
::
*
)
{
=
;
=
;
=
;
->
(
()->
()->
(
::
));
.
(
);
.
(
);
.
(
);
.
(
this
, &
GuiTextBoxCommonInterface
::
);
.
(
this
, &
GuiTextBoxCommonInterface
::
);
->
()->
.
(
this
, &
GuiTextBoxCommonInterface
::
);
->
()->
.
(
this
, &
GuiTextBoxCommonInterface
::
);
->
()->
.
(
this
, &
GuiTextBoxCommonInterface
::
);
->
()->
.
(
this
, &
GuiTextBoxCommonInterface
::
);
->
()->
.
(
this
, &
GuiTextBoxCommonInterface
::
);
->
()->
.
(
this
, &
GuiTextBoxCommonInterface
::
);
->
()->
.
(
this
, &
GuiTextBoxCommonInterface
::
);
->
()->
.
(
this
, &
GuiTextBoxCommonInterface
::
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]
(
,
,
,
);
}
}
GuiTextBoxCommonInterface
::
*
GuiTextBoxCommonInterface
::
()
{
return
;
}
void
GuiTextBoxCommonInterface
::
(
*
)
{
=
;
}
bool
GuiTextBoxCommonInterface
::
(
<
>
)
{
if
(
.
(
.
()))
{
return
false
;
}
else
{
.
(
);
if
(
)
{
(
,
,
,
);
}
return
true
;
}
}
bool
GuiTextBoxCommonInterface
::
(
<
>
)
{
if
(
.
(
.
()))
{
();
return
true
;
}
else
{
return
false
;
}
}
void
GuiTextBoxCommonInterface
::
(
,
const
<
void
()>&
)
{
*
=
internalShortcutKeyManager
(
true
,
false
,
false
,
);
item
->
.
([=](
*
,
&
)
{
);
});
}
elements
::
*
GuiTextBoxCommonInterface
::
()
{
return
;
}
void
GuiTextBoxCommonInterface
::
(
const
&
)
{
if
(
)
{
;
if
(
->
().
()>
0
)
{
end
.
=
->
().
()-
1
;
end
.
=
->
().
(
end
.
).
;
}
(
(),
end
,
,
false
);
}
}
GuiTextBoxCommonInterface
::
GuiTextBoxCommonInterface
()
:textElement(
0
)
,textComposition(
0
)
,editVersion(
0
)
,textControl(
0
)
,callback(
0
)
,dragging(
false
)
,readonly(
false
)
,preventEnterDueToAutoComplete(
false
)
{
new
GuiTextBoxUndoRedoProcessor
;
(
);
internalShortcutKeyManager
new
;
(
::
,
<
bool
()>(
this
, &
GuiTextBoxCommonInterface
::
));
(
::
,
<
bool
()>(
this
, &
GuiTextBoxCommonInterface
::
));
(
::
,
<
void
()>(
this
, &
GuiTextBoxCommonInterface
::
));
(
::
,
<
bool
()>(
this
, &
GuiTextBoxCommonInterface
::
));
(
::
,
<
bool
()>(
this
, &
GuiTextBoxCommonInterface
::
));
(
::
,
<
bool
()>(
this
, &
GuiTextBoxCommonInterface
::
));
}
GuiTextBoxCommonInterface
::
~
GuiTextBoxCommonInterface
()
{
if
(
)
{
(
);
0
;
}
if
(
)
{
(
);
0
;
}
for
(
=
0
;
i
<
.
();
i
++)
{
i
]
();
}
.
();
}
bool
GuiTextBoxCommonInterface
::
()
{
return
!
&&
->
()!=
->
() &&
->
()==
L'\0'
;
}
bool
GuiTextBoxCommonInterface
::
()
{
return
->
()
->
() &&
->
()==
L'\0'
;
}
bool
GuiTextBoxCommonInterface
::
()
{
if
(!
&&
->
() ==
L'\0'
)
{
auto
=
()->
()->
();
return
reader
();
}
return
false
;
}
bool
GuiTextBoxCommonInterface
::
()
{
if
(!
())
return
false
;
auto
=
()->
()->
();
writer
(
());
writer
();
(
L""
);
return
true
;
}
bool
GuiTextBoxCommonInterface
::
()
{
if
(!
())
return
false
;
auto
=
()->
()->
();
writer
(
());
writer
();
return
true
;
}
bool
GuiTextBoxCommonInterface
::
()
{
if
(!
())
return
false
;
auto
=
()->
()->
();
(
reader
());
return
true
;
}
bool
GuiTextBoxCommonInterface
::
()
{
return
;
}
void
GuiTextBoxCommonInterface
::
(
bool
)
{
=
;
}
void
GuiTextBoxCommonInterface
::
(
,
)
{
(
,
false
);
(
,
true
);
}
void
GuiTextBoxCommonInterface
::
()
{
=
->
().
()-
1
;
(
(
0
,
0
),
false
);
(
(
row
,
->
().
(
row
).
),
true
);
}
GuiTextBoxCommonInterface
::
()
{
=
->
()
->
()?
->
():
->
();
=
->
()
->
()?
->
():
->
();
return
->
().
(
selectionBegin
,
selectionEnd
);
}
void
GuiTextBoxCommonInterface
::
(
const
&
)
{
(
->
(),
->
(),
,
false
);
}
void
GuiTextBoxCommonInterface
::
SetSelectionTextAsKeyInput
(
const
&
)
{
(
->
(),
->
(),
,
true
);
}
GuiTextBoxCommonInterface
::
(
)
{
=
->
().
(
(
,
0
));
=
(
start
.
,
->
().
(
start
.
).
);
return
(
start
,
end
);
}
GuiTextBoxCommonInterface
::
()
{
return
->
().
();
}
GuiTextBoxCommonInterface
::
(
,
)
{
->
().
(
);
->
().
(
);
return
->
().
(
,
);
}
GuiTextBoxCommonInterface
::
()
{
return
->
();
}
GuiTextBoxCommonInterface
::
()
{
return
->
();
}
GuiTextBoxCommonInterface
::
()
{
=
();
=
();
return
c1
c2
?
c1
:
c2
;
}
GuiTextBoxCommonInterface
::
()
{
=
();
=
();
return
c1
c2
?
c1
:
c2
;
}
GuiTextBoxCommonInterface
::
(
)
{
return
->
().
(
);
}
GuiTextBoxCommonInterface
::
()
{
return
->
().
();
}
GuiTextBoxCommonInterface
::
()
{
return
->
().
();
}
GuiTextBoxCommonInterface
::
()
{
return
->
().
();
}
GuiTextBoxCommonInterface
::
(
)
{
=
->
();
return
->
().
(
(
.
+
view
.
,
.
+
view
.
));
}
GuiTextBoxCommonInterface
::
(
)
{
=
->
();
=
->
().
(
);
return
(
result
.
-
view
.
,
result
.
-
view
.
);
}
GuiTextBoxCommonInterface
::
(
)
{
=
->
();
=
->
().
(
);
return
(
(
result
.
-
view
.
,
result
.
-
view
.
),
result
.
());
}
GuiTextBoxCommonInterface
::
(
)
{
=
->
();
=
(
.
+
viewPosition
.
,
.
+
viewPosition
.
);
=
->
().
(
mousePosition
);
if
(
pos
.
<
->
().
(
pos
.
).
)
{
=
->
().
(
pos
);
if
(
((
int
)(
rect
.
-
mousePosition
.
))>=
((
int
)(
rect
.
-
1
-
mousePosition
.
)))
{
pos
.
++;
}
}
return
pos
;
}
<
>
GuiTextBoxCommonInterface
::
()
{
return
;
}
void
GuiTextBoxCommonInterface
::
(
<
>
)
{
if
(!
)
{
=
true
;
(
,
()->
());
}
if
(
)
{
(
);
}
;
if
(
)
{
(
);
()->
(
());
}
else
{
()->
(
);
()->
(
0
);
}
}
<
GuiTextBoxAutoCompleteBase
>
GuiTextBoxCommonInterface
::
()
{
return
;
}
void
GuiTextBoxCommonInterface
::
(
<
GuiTextBoxAutoCompleteBase
>
)
{
if
(
)
{
(
);
}
;
if
(
)
{
(
);
}
}
GuiTextBoxCommonInterface
::
()
{
return
;
}
bool
GuiTextBoxCommonInterface
::
()
{
return
!
&&
();
}
bool
GuiTextBoxCommonInterface
::
()
{
return
!
&&
();
}
void
GuiTextBoxCommonInterface
::
()
{
();
}
bool
GuiTextBoxCommonInterface
::
()
{
return
();
}
void
GuiTextBoxCommonInterface
::
()
{
();
}
bool
GuiTextBoxCommonInterface
::
()
{
if
(
())
{
return
();
}
else
{
return
false
;
}
}
bool
GuiTextBoxCommonInterface
::
()
{
if
(
())
{
return
();
}
else
{
return
false
;
}
}
}
}
}