#include "GuiGraphicsTableComposition.h"
#include <math.h>
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
controls
;
using
namespace
elements
;
namespace
update_cell_bounds_helpers
{
(
,
)
{
return
;
}
(
,
)
{
return
;
}
(
)
{
return
.
;
}
(
)
{
return
.
;
}
(
*
)
{
return
->
();
}
(
*
)
{
return
->
();
}
(
*
)
{
return
->
();
}
(
*
)
{
return
->
();
}
}
using
namespace
update_cell_bounds_helpers
;
::
(
,
,
,
)
{
return
*
+
;
}
void
::
(
,
,
*
)
{
(
,
,
,
)] =
;
}
void
::
(
collections
::
<
>&
,
&
,
&
,
collections
::
<
>&
,
::*
,
::*
,
(*
)(
),
(*
)(
*),
(*
)(
*),
(*
)(
,
),
(*
)(
,
),
)
{
for
(
=
0
;
pass
<
;
pass
++)
{
for
(
=
0
;
i
<
this
->*
;
i
++)
{
=
i
];
if
(
pass
==
0
)
{
i
] =
0
;
}
switch
(
option
.
)
{
case
::
:
{
i
] =
option
.
;
}
break
;
case
::
:
{
for
(
=
0
;
j
<
this
->*
;
j
++)
{
*
=
(
(
i
,
j
),
(
i
,
j
));
if
(
cell
)
{
bool
=
false
;
if
(
pass
==
0
)
{
accept
=
(
cell
) ==
1
;
}
else
{
accept
=
(
cell
) +
(
cell
) ==
i
+
1
;
}
if
(
accept
)
{
=
(
cell
->
().
());
=
(
cell
);
for
(
=
1
;
k
<
span
;
k
++)
{
size
-=
i
-
k
] +
;
}
if
(
i
] <
size
)
{
i
] =
size
;
}
}
}
}
}
break
;
default
:;
}
}
}
bool
=
false
;
for
(
=
0
;
i
<
this
->*
;
i
++)
{
=
i
];
if
(
option
.
==
::
)
{
if
(
0.001
<
option
.
)
{
percentageExists
=
true
;
}
}
}
if
(
percentageExists
)
{
for
(
=
0
;
i
<
this
->*
;
i
++)
{
=
i
];
if
(
option
.
==
::
)
{
if
(
0.001
<
option
.
)
{
for
(
=
0
;
j
<
this
->*
;
j
++)
{
*
=
(
(
i
,
j
),
(
i
,
j
));
if
(
cell
)
{
=
(
cell
->
().
());
=
(
cell
);
=
(
cell
);
size
-= (
span
-
1
)*
;
double
=
0
;
for
(
=
start
;
k
<
start
+
span
;
k
++)
{
if
(
k
].
==
::
)
{
if
(
0.001
<
k
].
)
{
totalPercentage
+=
k
].
;
}
}
else
{
size
-=
k
];
}
}
size
= (
)
(
size
*
option
.
/
totalPercentage
);
if
(
i
] <
size
)
{
i
] =
size
;
}
}
}
}
}
}
=
0
;
for
(
=
0
;
i
<
this
->*
;
i
++)
{
=
i
];
if
(
option
.
==
::
)
{
if
(
0.001
<
option
.
)
{
= (
)
(
i
] /
option
.
);
if
(
percentageTotalSize
<
size
)
{
percentageTotalSize
=
size
;
}
}
}
}
double
=
0
;
for
(
=
0
;
i
<
this
->*
;
i
++)
{
=
i
];
if
(
option
.
==
::
)
{
if
(
0.001
<
option
.
)
{
totalPercentage
+=
option
.
;
}
}
}
for
(
=
0
;
i
<
this
->*
;
i
++)
{
=
i
];
if
(
option
.
==
::
)
{
if
(
0.001
<
option
.
)
{
= (
)
(
percentageTotalSize
*
option
.
/
totalPercentage
);
if
(
i
] <
size
)
{
i
] =
size
;
}
}
}
}
}
for
(
=
0
;
i
<
this
->*
;
i
++)
{
if
(
i
].
!=
::
)
{
+=
i
];
}
+=
i
];
}
}
void
::
UpdateCellBoundsPercentages
(
collections
::
<
>&
,
,
,
collections
::
<
>&
)
{
if
(
>
)
{
double
=
0
;
=
0
;
for
(
=
0
;
i
<
.
();
i
++)
{
=
i
];
if
(
option
.
==
::
)
{
totalPercentage
+=
option
.
;
percentageCount
++;
}
}
if
(
percentageCount
>
0
&&
totalPercentage
>
0.001
)
{
for
(
=
0
;
i
<
.
();
i
++)
{
=
i
];
if
(
option
.
==
::
)
{
i
] = (
)((
-
)*
option
.
/
totalPercentage
);
}
}
}
}
}
::
(
collections
::
<
>&
,
collections
::
<
>&
,
{
0
] =
0
;
for
(
=
1
;
i
<
.
();
i
++)
{
i
] =
i
-
1
] +
+
i
-
1
];
}
=
.
() -
1
;
=
last
] +
last
];
return
-
right
;
}
void
::
()
{
if
(
())
{
();
}
}
::
()
:rows(
0
)
, columns(
0
)
, cellPadding(
0
)
, borderVisible(
true
)
, rowExtending(
0
)
, columnExtending(
0
)
{
.
(
this
);
(
1
,
1
);
}
::
()
{
}
::
()
{
return
;
}
::
()
{
return
;
}
bool
::
(
,
)
{
if
(
<=
0
||
<=
0
)
return
false
;
.
(
);
.
(
);
.
(
*
);
.
(
*
);
for
(
=
0
;
i
<
*
;
i
++)
{
i
] =
0
;
i
]
();
}
=
;
=
;
=
().
();
for
(
=
0
;
i
<
childCount
;
i
++)
{
*
=
dynamic_cast
<
*>(
().
(
i
));
if
(
cell
)
{
cell
->
OnTableRowsAndColumnsChanged
();
}
}
.
(
(
this
));
();
return
true
;
}
*
::
(
,
)
{
return
(
,
,
,
)];
}
::
(
)
{
return
];
}
void
::
(
,
)
{
]
;
();
.
(
(
this
));
}
::
(
)
{
return
];
}
void
::
(
,
)
{
]
;
();
.
(
(
this
));
}
::
()
{
return
;
}
void
::
(
)
{
if
(
<
0
)
=
0
;
=
;
();
}
bool
::
()
{
return
;
}
void
::
(
bool
)
{
if
(
!=
)
{
=
;
();
}
}
::
()
{
(
(
0
,
0
),
::
().
());
=
?
:
0
;
bounds
.
+=
.
+
.
+
borderThickness
;
bounds
.
+=
.
+
.
+
borderThickness
;
bounds
.
-=
.
+
.
+
borderThickness
;
bounds
.
-=
.
+
.
+
borderThickness
;
if
(
bounds
.
<
bounds
.
)
bounds
.
=
bounds
.
;
if
(
bounds
.
<
bounds
.
)
bounds
.
=
bounds
.
;
return
bounds
;
}
void
::
()
{
.
(
);
.
(
);
.
(
);
.
(
);
= (
-
1
) *
;
= (
-
1
) *
;
=
rowTotal
;
columnTotalWithPercentage
=
columnTotal
;
(
,
rowTotal
,
rowTotalWithPercentage
,
,
&
::
,
&
::
,
&
,
&
,
&
,
&
,
&
,
1
);
(
,
columnTotal
,
columnTotalWithPercentage
,
,
&
::
,
&
::
,
&
,
&
,
&
,
&
,
&
,
1
);
=
();
UpdateCellBoundsPercentages
(
,
rowTotal
,
area
.
(),
);
UpdateCellBoundsPercentages
(
,
columnTotal
,
area
.
(),
);
=
(
,
,
area
.
());
=
(
,
,
area
.
());
for
(
=
0
;
i
<
;
i
++)
{
for
(
=
0
;
j
<
;
j
++)
{
=
(
,
,
i
,
j
);
index
]
(
(
j
],
i
]),
(
j
],
i
]));
}
}
(
columnTotalWithPercentage
,
rowTotalWithPercentage
);
InvokeOnCompositionStateChanged
();
}
void
::
()
{
::
ForceCalculateSizeImmediately
();
();
();
}
::
GetMinPreferredClientSize
()
{
= (
?
2
*
:
0
);
return
(
.
+
offset
,
.
+
offset
);
}
::
()
{
=
;
=
::
();
bool
=
false
;
<
*>
;
FOREACH(GuiCellComposition*, cell, cellCompositions)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
cell
);)
{
if
(
cell
&& !
cells
.
(
cell
))
{
cells
.
(
cell
);
=
cell
->
().
();
if
(
cell
->
newSize
)
{
cell
->
newSize
;
cellMinSizeModified
=
true
;
}
}
}
if
(
cached
result
||
cellMinSizeModified
)
{
();
}
return
result
;
}
void
::
(
*
)
{
if
(
!= -
1
&&
!= -
1
)
{
for
(
=
0
;
r
<
;
r
++)
{
for
(
=
0
;
c
<
;
c
++)
{
->
(
+
r
,
+
c
,
0
);
}
}
}
}
void
::
(
*
)
{
for
(
=
0
;
r
<
;
r
++)
{
for
(
=
0
;
c
<
;
c
++)
{
->
(
+
r
,
+
c
,
this
);
}
}
}
void
::
()
{
= -
1
;
= -
1
;
=
1
;
=
1
;
}
bool
::
(
,
,
,
)
{
if
(
)
{
if
(
<
0
||
>=
->
||
<
0
||
>=
->
)
return
false
;
if
(
<
1
||
+
>
->
||
<
1
||
+
>
->
)
return
false
;
for
(
=
0
;
r
<
;
r
++)
{
for
(
=
0
;
c
<
;
c
++)
{
*
=
->
(
+
r
,
+
c
);
if
(
cell
&&
cell
!=
this
)
{
return
false
;
}
}
}
(
);
}
=
;
=
;
=
;
=
;
if
(
)
{
(
);
}
return
true
;
}
void
::
(
*
,
*
)
{
::
(
,
);
if
(
)
{
(
);
}
=
dynamic_cast
<
*>(
);
if
(!
|| !
(
,
,
,
))
{
();
}
if
(
)
{
if
(
!= -
1
&&
!= -
1
)
{
(
,
,
,
);
}
->
();
}
}
void
::
OnTableRowsAndColumnsChanged
()
{
if
(!
(
,
,
,
))
{
();
}
}
::
()
:row(-
1
)
,column(-
1
)
,rowSpan(
1
)
,columnSpan(
1
)
,tableParent(
0
)
{
(
::
LimitToElementAndChildren
);
}
::
()
{
}
*
::
()
{
return
;
}
::
()
{
return
;
}
::
()
{
return
;
}
::
()
{
return
;
}
::
()
{
return
;
}
bool
::
(
,
,
,
)
{
if
(!
(
,
,
,
))
{
return
false
;
}
if
(
)
{
->
();
}
return
true
;
}
::
()
{
;
if
(
&&
!=-
1
&&
!=-
1
)
{
,
;
{
=
->
(
->
,
->
,
,
);
bounds1
->
index
];
}
{
=
->
(
->
,
->
,
+
-
1
,
+
-
1
);
bounds2
->
index
];
if
(
->
()==
::
)
{
if
(
+
==
->
)
{
bounds2
.
+=
->
;
}
if
(
+
==
->
)
{
bounds2
.
+=
->
;
}
}
}
=
->
?
->
:
0
;
result
(
bounds1
.
+
offset
,
bounds1
.
+
offset
,
bounds2
.
+
offset
,
bounds2
.
+
offset
);
}
else
{
result
();
}
(
result
);
return
result
;
}
void
GuiTableSplitterCompositionBase
::
(
*
,
*
)
{
::
(
,
);
=
dynamic_cast
<
*>(
);
}
void
GuiTableSplitterCompositionBase
::
(
*
,
&
)
{
=
true
;
(
.
,
.
);
}
void
GuiTableSplitterCompositionBase
::
(
*
,
&
)
{
=
false
;
}
void
GuiTableSplitterCompositionBase
::
(
,
::*
,
collections
::
<
>&
,
,
(
::*
)(
),
void
(
::*
)(
,
)
)
{
if
(
)
{
if
(
)
{
if
(
0
<
&&
<
->*
)
{
auto
= (
->*
)(
-
1
);
auto
= (
->*
)(
);
= -
1
;
= -
1
;
= -
1
;
=
0
;
if
(
<
0
)
{
indexStart
=
-
1
;
indexEnd
= -
1
;
indexStep
= -
1
;
}
else
if
(
>
0
)
{
indexStart
=
;
indexEnd
=
->*
;
indexStep
=
1
;
}
else
{
return
;
}
{
auto
= (
->*
)(
indexStart
);
if
(
o
.
==
::
)
{
max
=
o
.
-
1
;
}
else
{
for
(
=
indexStart
;
i
!=
indexEnd
;
i
+=
indexStep
)
{
o
(
->*
)(
i
);
if
(
o
.
==
::
)
{
break
;
}
else
if
(
o
.
==
::
)
{
max
+=
i
] -
1
;
}
}
}
if
(
max
<=
0
)
{
return
;
}
}
if
(
<
0
)
{
if
(
max
< -
)
{
= -
max
;
}
}
else
{
if
(
max
<
)
{
=
max
;
}
}
if
(
o1
.
==
::
)
{
o1
.
+=
;
(
->*
)(
-
1
,
o1
);
}
if
(
o2
.
==
::
)
{
o2
.
-=
;
(
->*
)(
,
o2
);
}
->
ForceCalculateSizeImmediately
();
}
}
}
}
GuiTableSplitterCompositionBase
::
(
,
::*
,
(
::*
)()
const
,
collections
::
<
>&
,
::*
,
::*
,
::*
,
::*
)
{
(
0
,
0
,
0
,
0
);
if
(
)
{
if
(
0
<
&&
<
->*
)
{
=
->
?
->
:
0
;
result
.*
=
offset
;
result
.*
=
offset
+ (
->
().*
)();
result
.*
=
offset
+
] -
->
;
result
.*
= (
result
.*
) +
->
;
}
}
(
result
);
return
result
;
}
GuiTableSplitterCompositionBase
::
GuiTableSplitterCompositionBase
()
:tableParent(
0
)
, dragging(
false
)
{
(
()->
()->
(
::
));
()->
.
(
this
, &
GuiTableSplitterCompositionBase
::
);
()->
.
(
this
, &
GuiTableSplitterCompositionBase
::
);
}
GuiTableSplitterCompositionBase
::
~
GuiTableSplitterCompositionBase
()
{
}
*
GuiTableSplitterCompositionBase
::
()
{
return
;
}
void
GuiRowSplitterComposition
::
(
*
,
&
)
{
(
,
&
::
,
->
,
.
-
.
,
&
::
,
&
::
);
}
GuiRowSplitterComposition
::
GuiRowSplitterComposition
()
:rowsToTheTop(
0
)
{
(
()->
()->
(
::
));
()->
.
(
this
, &
GuiRowSplitterComposition
::
);
}
GuiRowSplitterComposition
::
~
GuiRowSplitterComposition
()
{
}
GuiRowSplitterComposition
::
()
{
return
;
}
void
GuiRowSplitterComposition
::
(
)
{
=
;
InvokeOnCompositionStateChanged
();
}
GuiRowSplitterComposition
::
()
{
return
(
,
&
::
,
&
::
,
->
,
&
::
,
&
::
,
&
::
,
&
::
);
}
void
GuiColumnSplitterComposition
::
(
*
,
&
)
{
(
,
&
::
,
->
,
.
-
.
,
&
::
,
&
::
);
}
GuiColumnSplitterComposition
::
GuiColumnSplitterComposition
()
:columnsToTheLeft(
0
)
{
(
()->
()->
(
::
));
()->
.
(
this
, &
GuiColumnSplitterComposition
::
);
}
GuiColumnSplitterComposition
::
~
GuiColumnSplitterComposition
()
{
}
GuiColumnSplitterComposition
::
()
{
return
;
}
void
GuiColumnSplitterComposition
::
(
)
{
=
;
InvokeOnCompositionStateChanged
();
}
GuiColumnSplitterComposition
::
()
{
return
(
,
&
::
,
&
::
,
->
,
&
::
,
&
::
,
&
::
,
&
::
);
}
}
}
}