#include "GuiDataGridControls.h"
#include "GuiDataGridExtensions.h"
#include "../../GraphicsComposition/GuiGraphicsTableComposition.h"
#include "../../GraphicsHost/GuiGraphicsHost.h"
namespace
{
namespace
{
namespace
{
namespace
{
using
namespace
compositions
;
using
namespace
collections
;
using
namespace
description
;
using
namespace
templates
;
const
wchar_t
*
const
::
=
L"vl::presentation::controls::list::IDataGridView"
;
*
DefaultDataGridItemTemplate
::
(
,
)
{
if
(
auto
=
dynamic_cast
<
*>(
))
{
if
(
auto
=
dataGrid
->
->
GetCellDataVisualizerFactory
(
,
))
{
return
factory
;
}
if
(
==
0
)
{
return
dataGrid
->
defaultMainColumnVisualizerFactory
.
();
}
else
{
return
dataGrid
->
defaultSubColumnVisualizerFactory
.
();
}
}
return
nullptr
;
}
*
DefaultDataGridItemTemplate
::
(
,
)
{
if
(
auto
=
dynamic_cast
<
*>(
))
{
return
dataGrid
->
->
(
,
);
}
return
nullptr
;
}
DefaultDataGridItemTemplate
::
(
compositions
::
*
)
{
for
(
=
0
;
i
<
->
();
i
++)
{
auto
=
->
(
0
,
i
);
if
(
==
cell
)
{
return
i
;
}
}
return
-
1
;
}
bool
DefaultDataGridItemTemplate
::
(
*
,
compositions
::
&
)
{
if
(!
->
)
return
false
;
auto
=
->
();
auto
=
.
;
while
(
currentComposition
)
{
if
(
currentComposition
==
editorComposition
)
{
return
true
;
}
else
if
(
currentComposition
==
this
)
{
break
;
}
else
{
currentComposition
=
currentComposition
->
();
}
}
return
false
;
}
void
DefaultDataGridItemTemplate
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(
auto
=
dynamic_cast
<
*>(
))
{
if
(
(
dataGrid
,
))
{
.
=
true
;
}
}
}
void
DefaultDataGridItemTemplate
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(
auto
=
dynamic_cast
<
*>(
))
{
if
(
(
dataGrid
,
))
{
.
=
true
;
}
else
if
(
dataGrid
->
())
{
=
(
);
if
(
index
!= -
1
)
{
=
();
dataGrid
->
({
currentRow
,
index
},
true
);
}
}
}
}
void
DefaultDataGridItemTemplate
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(
auto
=
dynamic_cast
<
*>(
))
{
if
(
(
dataGrid
,
))
{
.
=
true
;
}
else
if
(
dataGrid
->
())
{
=
(
);
if
(
index
!= -
1
)
{
=
();
dataGrid
->
({
currentRow
,
index
},
false
);
}
}
}
}
void
DefaultDataGridItemTemplate
::
()
{
();
}
void
DefaultDataGridItemTemplate
::
()
{
DefaultListViewItemTemplate
::
();
{
=
new
;
->
(
(
0
,
0
,
0
,
0
));
->
(
1
,
1
);
->
(
0
,
::
());
->
(
0
,
::
(
0
));
(
);
}
if
(
auto
=
dynamic_cast
<
*>(
))
{
=
dataGrid
->
->
();
=
();
.
(
columnCount
);
for
(
=
0
;
i
<
.
();
i
++)
{
auto
=
(
itemIndex
,
i
);
i
]
factory
->
(
dataGrid
);
}
->
(
1
,
columnCount
);
for
(
=
0
;
i
<
columnCount
;
i
++)
{
auto
=
new
;
->
(
cell
);
cell
->
(
0
,
i
,
1
,
1
);
cell
->
()->
.
(
this
, &
DefaultDataGridItemTemplate
::
);
cell
->
()->
.
(
this
, &
DefaultDataGridItemTemplate
::
);
cell
->
()->
.
(
this
, &
DefaultDataGridItemTemplate
::
);
cell
->
()->
.
(
this
, &
DefaultDataGridItemTemplate
::
);
auto
=
i
]
();
composition
->
(
(
0
,
0
,
0
,
0
));
cell
->
(
composition
);
}
for
(
=
0
;
i
<
.
();
i
++)
{
i
]
(
dataGrid
->
(),
itemIndex
,
i
);
}
=
dataGrid
->
();
if
(
selectedCell
.
==
itemIndex
)
{
(
selectedCell
.
);
}
else
{
(-
1
);
}
();
}
.
(
this
, &
DefaultDataGridItemTemplate
::
);
.
(
this
, &
DefaultDataGridItemTemplate
::
);
.
(
this
, &
DefaultDataGridItemTemplate
::
);
.
(
this
, &
DefaultDataGridItemTemplate
::
);
.
(
compositions
::
(
this
));
.
(
compositions
::
(
this
));
.
(
compositions
::
(
this
));
.
(
compositions
::
(
this
));
}
void
DefaultDataGridItemTemplate
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(!
())
{
(-
1
);
}
}
void
DefaultDataGridItemTemplate
::
(
compositions
::
*
,
compositions
::
&
)
{
FOREACH(Ptr<IDataVisualizer>, visualizer, dataVisualizers)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
visualizer
);)
{
visualizer
()->
(
());
}
if
(
)
{
->
()->
(
());
}
}
void
DefaultDataGridItemTemplate
::
(
compositions
::
*
,
compositions
::
&
)
{
FOREACH(Ptr<IDataVisualizer>, visualizer, dataVisualizers)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
visualizer
);)
{
visualizer
()->
(
());
}
if
(
)
{
->
()->
(
());
}
}
void
DefaultDataGridItemTemplate
::
(
compositions
::
*
,
compositions
::
&
)
{
FOREACH(Ptr<IDataVisualizer>, visualizer, dataVisualizers)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
visualizer
);)
{
visualizer
()->
(
());
}
if
(
)
{
->
()->
(
());
}
}
DefaultDataGridItemTemplate
::
DefaultDataGridItemTemplate
()
{
}
DefaultDataGridItemTemplate
::
~
DefaultDataGridItemTemplate
()
{
FOREACH(Ptr<IDataVisualizer>, visualizer, dataVisualizers)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
visualizer
);)
{
visualizer
();
}
if
(
)
{
->
();
}
}
void
DefaultDataGridItemTemplate
::
()
{
if
(
auto
=
dynamic_cast
<
*>(
))
{
=
dataGrid
->
->
();
if
(
columnCount
>
->
())
{
columnCount
=
->
();
}
for
(
=
0
;
i
<
columnCount
;
i
++)
{
->
(
i
,
::
(
dataGrid
->
->
(
i
)));
}
->
();
}
}
bool
DefaultDataGridItemTemplate
::
()
{
return
!=
nullptr
;
}
void
DefaultDataGridItemTemplate
::
(
,
*
)
{
=
;
if
(
)
{
auto
=
->
(
0
,
);
auto
*
=
->
();
editorBounds
->
(
());
editorBounds
->
(
());
if
(
editorBounds
->
() &&
editorBounds
->
() !=
cell
)
{
editorBounds
->
()->
(
editorBounds
);
}
editorBounds
->
(
(
0
,
0
,
0
,
0
));
cell
->
(
editorBounds
);
if
(
auto
=
->
()->
())
{
focusControl
->
();
}
]
()->
(
false
);
}
}
void
DefaultDataGridItemTemplate
::
()
{
if
(
)
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]
()->
(
true
);
}
auto
=
->
();
if
(
composition
->
())
{
composition
->
()->
(
composition
);
}
=
nullptr
;
}
}
void
DefaultDataGridItemTemplate
::
(
)
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]
(
i
==
);
}
}
void
DefaultDataGridItemTemplate
::
()
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]
(
->
(),
(),
i
);
}
}
}
using
namespace
list
;
compositions
::
*
::
()
{
if
(
)
{
if
(
auto
=
()->
())
{
if
(
auto
=
focusControl
->
<
>())
{
if
(
action
->
() &&
action
->
())
{
(
());
(
focusControl
,
true
);
return
this
;
}
}
}
}
(
nullptr
);
(
nullptr
,
false
);
return
::
();
}
void
::
(
,
,
)
{
::
(
,
,
);
if
(!
()->
())
{
();
}
}
void
::
(
,
*
)
{
::
(
,
);
if
(
auto
=
dynamic_cast
<
DefaultDataGridItemTemplate
*>(
))
{
if
(
.
==
&&
.
!= -
1
)
{
itemStyle
->
(
.
);
}
}
}
void
::
(
*
)
{
::
(
);
if
(
auto
=
dynamic_cast
<
DefaultDataGridItemTemplate
*>(
))
{
if
(
itemStyle
->
())
{
itemStyle
->
();
nullptr
;
{ -
1
,-
1
};
}
}
}
void
::
()
{
if
(
.
!= -
1
&&
())
{
auto
=
()->
(
.
);
if
(
auto
=
dynamic_cast
<
DefaultDataGridItemTemplate
*>(
style
))
{
itemStyle
->
();
}
}
}
void
::
(
,
)
{
if
(
.
!=
||
.
!=
)
{
{
,
};
.
(
());
auto
=
()->
(
);
if
(
auto
=
dynamic_cast
<
DefaultDataGridItemTemplate
*>(
style
))
{
itemStyle
->
(
);
}
}
}
bool
::
(
,
)
{
();
(
,
);
auto
=
()->
(
);
if
(
auto
=
dynamic_cast
<
DefaultDataGridItemTemplate
*>(
style
))
{
if
(
auto
=
->
(
,
))
{
currentEditorOpeningEditor
=
true
;
{
,
};
factory
->
(
this
);
if
(
auto
=
()->
())
{
focusControl
->
(
L"E"
);
}
(
(),
,
);
itemStyle
->
(
,
.
());
currentEditorOpeningEditor
=
false
;
return
true
;
}
}
return
false
;
}
void
::
()
{
if
(
()->
())
{
();
}
else
{
if
(
{-
1
, -
1
})
{
if
(
)
{
();
}
}
}
(
nullptr
);
(
nullptr
,
false
);
nullptr
;
{ -
1
,-
1
};
}
templates
::
*
::
GetListViewControlTemplate
()
{
return
TypedControlTemplateObject
(
true
);
}
void
::
()
{
if
(
&& !
currentEditorOpeningEditor
)
{
*
=
nullptr
;
if
(
auto
=
())
{
if
(
auto
=
controlHost
->
())
{
if
(
auto
=
graphicsHost
->
())
{
focusedControl
=
focusComposition
->
();
}
}
}
()->
();
->
(
.
,
.
,
()->
());
()->
();
auto
=
()->
(
.
);
if
(
auto
=
dynamic_cast
<
DefaultDataGridItemTemplate
*>(
style
))
{
itemStyle
->
();
}
if
(
&&
focusedControl
)
{
focusedControl
->
();
}
}
}
void
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(
->
(
.
))
{
switch
(
->
(
.
))
{
case
::
:
->
(
.
,
true
);
break
;
case
::
:
->
(
.
,
false
);
break
;
case
::
:
->
(-
1
,
false
);
break
;
}
}
}
void
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(!
)
{
=
();
if
(
row
!= -
1
)
{
if
(
.
!=
row
&&
.
!= -
1
)
{
({
row
,
.
},
false
);
}
else
{
({
row
,
0
},
false
);
}
}
else
{
();
(-
1
, -
1
);
}
}
}
void
::
(
compositions
::
*
,
compositions
::
&
)
{
if
(
.
!= -
1
)
{
if
(
.
::
)
{
();
(
, !
);
.
=
true
;
if
(!
)
{
();
}
.
=
true
;
}
else
if
(
.
::
)
{
if
(
)
{
(
,
false
);
();
.
=
true
;
}
}
else
{
=
0
;
switch
(
.
)
{
case
::
:
columnOffset
= -
1
;
.
=
true
;
break
;
case
::
:
columnOffset
=
1
;
.
=
true
;
break
;
default
:
return
;
}
=
.
+
columnOffset
;
if
(
column
<
0
)
{
column
=
0
;
}
else
if
(
column
>=
->
())
{
column
=
->
();
}
({
.
,
column
},
false
);
}
}
}
void
::
(
compositions
::
*
,
compositions
::
&
)
{
}
::
(
theme
::
,
::
*
)
:
(
,
)
{
=
dynamic_cast
<
*>(
->
(
::
));
=
dynamic_cast
<
ListViewColumnItemArranger
::
*>(
->
(
ListViewColumnItemArranger
::
::
));
=
dynamic_cast
<
*>(
->
(
::
));
{
auto
= [](
const
&) {
return
new
MainColumnVisualizerTemplate
; };
auto
= [](
const
&) {
return
new
SubColumnVisualizerTemplate
; };
auto
= [](
const
&) {
return
new
FocusRectangleVisualizerTemplate
; };
auto
= [](
const
&) {
return
new
CellBorderVisualizerTemplate
; };
defaultMainColumnVisualizerFactory
<
>(
cellBorderProperty
,
<
>(
focusRectangleProperty
,
<
>(
mainProperty
)
));
defaultSubColumnVisualizerFactory
<
>(
cellBorderProperty
,
<
>(
focusRectangleProperty
,
<
>(
subProperty
)
));
}
CHECK_ERROR(listViewItemView != nullptr, L"GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleController*, GuiListControl::IItemProvider*)#Missing IListViewItemView from item provider.");
do
{
if
(!(
!=
nullptr
))
throw
(
L"GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleController*, GuiListControl::IItemProvider*)#Missing IListViewItemView from item provider."
);}
while
(
0
);
CHECK_ERROR(columnItemView != nullptr, L"GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleController*, GuiListControl::IItemProvider*)#Missing ListViewColumnItemArranger::IColumnItemView from item provider.");
do
{
if
(!(
!=
nullptr
))
throw
(
L"GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleController*, GuiListControl::IItemProvider*)#Missing ListViewColumnItemArranger::IColumnItemView from item provider."
);}
while
(
0
);
CHECK_ERROR(dataGridView != nullptr, L"GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleController*, GuiListControl::IItemProvider*)#Missing IDataGridView from item provider.");
do
{
if
(!(
!=
nullptr
))
throw
(
L"GuiVirtualDataGrid::GuiVirtualDataGrid(IStyleController*, GuiListControl::IItemProvider*)#Missing IDataGridView from item provider."
);}
while
(
0
);
();
.
(
this
, &
::
);
.
(
this
, &
::
);
->
()->
.
(
this
, &
::
);
->
()->
.
(
this
, &
::
);
.
(
);
}
::
()
{
}
::
*
::
()
{
return
::
();
}
void
::
()
{
(
[](
const
&) {
return
new
list
::
DefaultDataGridItemTemplate
; },
new
list
::
ListViewColumnItemArranger
);
}
::
()
{
return
;
}
bool
::
(
const
&
,
bool
)
{
bool
=
0
<=
.
&&
.
<
()->
() &&
0
<=
.
&&
.
<
->
();
if
(
validPos
&&
==
)
{
if
(
&& !
)
{
();
}
else
if
(!
&&
)
{
(
.
,
.
);
}
return
nullptr
;
}
();
if
(
validPos
)
{
(
.
,
.
);
if
(
)
{
(
.
);
if
(
())
{
();
}
=
true
;
(
.
,
true
);
=
false
;
return
(
.
,
.
);
}
}
else
{
(-
1
, -
1
);
();
}
return
false
;
}
}
}
}