Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
4256b47e
Commit
4256b47e
authored
Feb 08, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
break and change function for draw autoFilter buttons(af_drawButtons)
parent
f43279c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
216 additions
and
130 deletions
+216
-130
cell/view/WorksheetView.js
cell/view/WorksheetView.js
+216
-130
No files found.
cell/view/WorksheetView.js
View file @
4256b47e
...
@@ -11942,143 +11942,34 @@
...
@@ -11942,143 +11942,34 @@
return
false
;
return
false
;
}
}
var
_drawFilterMark
=
function
(
x
,
y
,
height
,
index
)
{
var
drawCurrentFilterButtons
=
function
(
filter
)
{
var
size
=
5.25
*
index
;
var
autoFilter
=
filter
.
isAutoFilter
()
?
filter
:
filter
.
AutoFilter
;
var
halfSize
=
Math
.
round
((
size
/
2
)
/
0.75
)
*
0.75
;
var
meanLine
=
Math
.
round
((
size
*
Math
.
sqrt
(
3
)
/
3
)
/
0.75
)
*
0.75
;
//длина биссектрисы равностороннего треугольника
//округляем + смещаем
x
=
Math
.
round
((
x
)
/
0.75
)
*
0.75
;
y
=
Math
.
round
((
y
)
/
0.75
)
*
0.75
;
var
y1
=
y
-
height
;
ws
.
drawingCtx
.
beginPath
()
.
moveTo
(
x
,
y
)
.
lineTo
(
x
,
y1
)
.
setStrokeStyle
(
m_oColor
)
.
stroke
();
ws
.
drawingCtx
.
beginPath
()
.
moveTo
(
x
+
halfSize
,
y1
)
.
lineTo
(
x
+
halfSize
,
y1
)
.
lineTo
(
x
,
y1
+
meanLine
)
.
lineTo
(
x
-
halfSize
,
y1
)
.
lineTo
(
x
,
y1
)
.
setFillStyle
(
m_oColor
)
.
fill
();
};
var
_drawFilterDreieck
=
function
(
x
,
y
,
index
)
{
var
size
=
5.25
*
index
;
//сюда приходят координаты центра кнопки
//чтобы кнопка была в центре, необходимо сместить
var
leftDiff
=
size
/
2
;
var
upDiff
=
Math
.
round
(((
size
*
Math
.
sqrt
(
3
))
/
6
)
/
0.75
)
*
0.75
;
//радиус вписанной окружности в треугольник
//округляем + смещаем
x
=
Math
.
round
((
x
-
leftDiff
)
/
0.75
)
*
0.75
;
y
=
Math
.
round
((
y
-
upDiff
)
/
0.75
)
*
0.75
;
var
meanLine
=
Math
.
round
((
size
*
Math
.
sqrt
(
3
)
/
3
)
/
0.75
)
*
0.75
;
//длина биссектрисы равностороннего треугольника
var
halfSize
=
Math
.
round
((
size
/
2
)
/
0.75
)
*
0.75
;
//рисуем
ws
.
drawingCtx
.
beginPath
()
.
moveTo
(
x
,
y
)
.
lineTo
(
x
+
size
,
y
)
.
lineTo
(
x
+
halfSize
,
y
+
meanLine
)
.
lineTo
(
x
,
y
)
.
setFillStyle
(
m_oColor
)
.
fill
();
};
var
_drawButton
=
function
(
x1
,
y1
,
options
)
{
var
isSet
=
options
.
isSetFilter
;
var
height
=
11.25
;
var
width
=
11.25
;
var
rowHeight
=
ws
.
rows
[
options
.
row
].
height
;
var
colWidth
=
ws
.
cols
[
options
.
col
].
width
;
var
index
=
1
;
var
diffX
=
0
;
var
diffY
=
0
;
if
((
colWidth
-
2
)
<
width
&&
rowHeight
<
(
height
+
2
))
{
if
(
rowHeight
<
colWidth
)
{
index
=
rowHeight
/
height
;
width
=
width
*
index
;
height
=
rowHeight
;
}
else
{
index
=
colWidth
/
width
;
diffY
=
width
-
colWidth
;
diffX
=
width
-
colWidth
;
width
=
colWidth
;
height
=
height
*
index
;
}
}
else
if
((
colWidth
-
2
)
<
width
)
{
index
=
colWidth
/
width
;
//смещения по x и y
diffY
=
width
-
colWidth
;
diffX
=
width
-
colWidth
+
2
;
width
=
colWidth
;
height
=
height
*
index
;
}
else
if
(
rowHeight
<
height
)
{
index
=
rowHeight
/
height
;
width
=
width
*
index
;
height
=
rowHeight
;
}
//квадрат кнопки рисуем
ws
.
drawingCtx
.
setFillStyle
(
ws
.
settings
.
cells
.
defaultState
.
background
)
.
setLineWidth
(
1
)
.
setStrokeStyle
(
ws
.
settings
.
cells
.
defaultState
.
border
)
.
fillRect
(
x1
+
diffX
,
y1
+
diffY
,
width
,
height
)
.
strokeRect
(
x1
+
diffX
,
y1
+
diffY
,
width
,
height
);
//координаты левого верхнего угла кнопки
var
upLeftXButton
=
x1
+
diffX
;
var
upLeftYButton
=
y1
+
diffY
;
var
centerX
,
centerY
;
if
(
isSet
)
{
centerX
=
upLeftXButton
+
(
width
/
2
);
var
heigthObj
=
Math
.
ceil
((
height
/
2
)
/
0.75
)
*
0.75
;
var
marginTop
=
Math
.
floor
(((
height
-
heigthObj
)
/
2
)
/
0.75
)
*
0.75
;
centerY
=
upLeftYButton
+
heigthObj
+
marginTop
;
_drawFilterMark
(
centerX
,
centerY
,
heigthObj
,
index
);
}
else
{
//центр кнопки
centerX
=
upLeftXButton
+
(
width
/
2
);
centerY
=
upLeftYButton
+
(
height
/
2
);
_drawFilterDreieck
(
centerX
,
centerY
,
index
);
}
};
var
drawCurrentFilterButton
=
function
(
filter
,
isTablePart
)
{
var
range
=
new
Asc
.
Range
(
filter
.
Ref
.
c1
,
filter
.
Ref
.
r1
,
filter
.
Ref
.
c2
,
filter
.
Ref
.
r1
);
var
range
=
new
Asc
.
Range
(
filter
.
Ref
.
c1
,
filter
.
Ref
.
r1
,
filter
.
Ref
.
c2
,
filter
.
Ref
.
r1
);
if
(
range
.
isIntersect
(
updatedRange
))
{
if
(
range
.
isIntersect
(
updatedRange
))
{
//TODO сделать isSetFilter
var
isSetFilter
=
false
;
var
isShowButton
=
true
;
var
row
=
range
.
r1
;
var
row
=
range
.
r1
;
var
sortCondition
=
filter
.
isApplySortConditions
()
?
filter
.
SortState
.
SortConditions
[
0
]
:
null
;
for
(
var
col
=
range
.
c1
;
col
<=
range
.
c2
;
col
++
)
{
for
(
var
col
=
range
.
c1
;
col
<=
range
.
c2
;
col
++
)
{
if
(
col
>=
updatedRange
.
c1
&&
col
<=
updatedRange
.
c2
)
{
if
(
col
>=
updatedRange
.
c1
&&
col
<=
updatedRange
.
c2
)
{
isSetFilter
=
false
;
var
isSetFilter
=
false
;
isShowButton
=
true
;
var
isShowButton
=
true
;
var
isSortState
=
null
;
//true - ascending, false - descending
if
(
filter
.
FilterColumns
&&
filter
.
FilterColumns
.
length
)
{
var
colId
=
filter
.
isAutoFilter
()
?
t
.
model
.
autoFilters
.
_getTrueColId
(
autoFilter
,
col
-
range
.
c1
)
:
col
-
range
.
c1
;
var
colId
=
!
isTablePart
?
t
.
model
.
autoFilters
.
_getTrueColId
(
filter
,
col
-
range
.
c1
)
:
if
(
autoFilter
.
FilterColumns
&&
autoFilter
.
FilterColumns
.
length
)
{
col
-
range
.
c1
;
var
filterColumn
=
null
,
filterColumnWithMerge
=
null
;
var
filterColumn
=
null
,
filterColumnWithMerge
=
null
;
for
(
var
i
=
0
;
i
<
f
ilter
.
FilterColumns
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
autoF
ilter
.
FilterColumns
.
length
;
i
++
)
{
if
(
f
ilter
.
FilterColumns
[
i
].
ColId
===
col
-
range
.
c1
)
{
if
(
autoF
ilter
.
FilterColumns
[
i
].
ColId
===
col
-
range
.
c1
)
{
filterColumn
=
f
ilter
.
FilterColumns
[
i
];
filterColumn
=
autoF
ilter
.
FilterColumns
[
i
];
}
}
if
(
colId
===
col
-
range
.
c1
&&
filterColumn
!==
null
)
{
if
(
colId
===
col
-
range
.
c1
&&
filterColumn
!==
null
)
{
filterColumnWithMerge
=
filterColumn
;
filterColumnWithMerge
=
filterColumn
;
break
;
break
;
}
else
if
(
f
ilter
.
FilterColumns
[
i
].
ColId
===
colId
)
{
}
else
if
(
autoF
ilter
.
FilterColumns
[
i
].
ColId
===
colId
)
{
filterColumnWithMerge
=
f
ilter
.
FilterColumns
[
i
];
filterColumnWithMerge
=
autoF
ilter
.
FilterColumns
[
i
];
}
}
}
}
...
@@ -12091,7 +11982,15 @@
...
@@ -12091,7 +11982,15 @@
}
}
}
}
if
(
sortCondition
&&
sortCondition
.
Ref
)
{
if
(
colId
===
sortCondition
.
Ref
.
c1
-
range
.
c1
)
{
isSortState
=
sortCondition
.
ConditionDescending
;
}
}
if
(
isShowButton
===
false
)
{
if
(
isShowButton
===
false
)
{
continue
;
continue
;
}
}
...
@@ -12107,28 +12006,215 @@
...
@@ -12107,28 +12006,215 @@
var
x1
=
ws
.
cols
[
col
].
left
+
ws
.
cols
[
col
].
width
-
width
-
0.5
;
var
x1
=
ws
.
cols
[
col
].
left
+
ws
.
cols
[
col
].
width
-
width
-
0.5
;
var
y1
=
ws
.
rows
[
row
].
top
+
ws
.
rows
[
row
].
height
-
height
-
0.5
;
var
y1
=
ws
.
rows
[
row
].
top
+
ws
.
rows
[
row
].
height
-
height
-
0.5
;
_drawButton
(
x1
-
offsetX
,
y1
-
offsetY
,
t
.
af_drawCurrentButton
(
x1
-
offsetX
,
y1
-
offsetY
,
{
isSortState
:
isSortState
,
isSetFilter
:
isSetFilter
,
row
:
row
,
col
:
col
});
{
sortState
:
false
,
isSetFilter
:
isSetFilter
,
row
:
row
,
col
:
col
});
}
}
}
}
}
}
};
};
if
(
aWs
.
AutoFilter
)
{
if
(
aWs
.
AutoFilter
)
{
drawCurrentFilterButton
(
aWs
.
AutoFilter
);
drawCurrentFilterButton
s
(
aWs
.
AutoFilter
);
}
}
if
(
aWs
.
TableParts
&&
aWs
.
TableParts
.
length
)
{
if
(
aWs
.
TableParts
&&
aWs
.
TableParts
.
length
)
{
for
(
var
i
=
0
;
i
<
aWs
.
TableParts
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
aWs
.
TableParts
.
length
;
i
++
)
{
if
(
aWs
.
TableParts
[
i
].
AutoFilter
&&
aWs
.
TableParts
[
i
].
HeaderRowCount
!==
0
)
{
if
(
aWs
.
TableParts
[
i
].
AutoFilter
&&
aWs
.
TableParts
[
i
].
HeaderRowCount
!==
0
)
{
drawCurrentFilterButton
(
aWs
.
TableParts
[
i
].
AutoFilter
,
true
);
drawCurrentFilterButton
s
(
aWs
.
TableParts
[
i
]
,
true
);
}
}
}
}
}
}
return
true
;
return
true
;
};
};
WorksheetView
.
prototype
.
af_drawCurrentButton
=
function
(
x1
,
y1
,
props
)
{
var
isApplyAutoFilter
=
props
.
isSetFilter
;
var
isApplySortState
=
props
.
isSortState
;
var
ws
=
this
;
var
aWs
=
this
.
model
;
var
t
=
this
;
var
width_1px
=
t
.
width_1px
;
var
height_1px
=
t
.
height_1px
;
var
height
=
15
*
width_1px
;
var
width
=
15
*
height_1px
;
var
m_oColor
=
new
CColor
(
120
,
120
,
120
);
var
rowHeight
=
ws
.
rows
[
props
.
row
].
height
;
var
colWidth
=
ws
.
cols
[
props
.
col
].
width
;
var
scaleIndex
=
1
;
var
_drawButtonBorder
=
function
(
startX
,
startY
,
width
,
height
)
{
ws
.
drawingCtx
.
setFillStyle
(
ws
.
settings
.
cells
.
defaultState
.
background
)
.
setLineWidth
(
1
)
.
setStrokeStyle
(
ws
.
settings
.
cells
.
defaultState
.
border
)
.
fillRect
(
startX
,
startY
,
width
,
height
)
.
strokeRect
(
startX
,
startY
,
width
,
height
);
};
var
_drawSortArrow
=
function
(
startX
,
startY
,
isDescending
,
heightArrow
)
{
heightArrow
=
heightArrow
*
0.75
*
scaleIndex
;
var
widthArrow
=
3
*
0.75
*
scaleIndex
;
var
widthLine
=
1
*
0.75
*
scaleIndex
;
//isDescending = true - стрелочка смотрит вниз
//рисуем сверху вниз
var
ctx
=
ws
.
drawingCtx
;
ctx
.
beginPath
();
ctx
.
lineVer
(
startX
,
startY
,
startY
+
heightArrow
);
if
(
isDescending
)
{
ctx
.
lineHor
(
startX
-
widthLine
,
startY
+
heightArrow
-
2
*
0.75
*
scaleIndex
,
startX
-
widthLine
+
widthArrow
);
}
else
{
ctx
.
lineHor
(
startX
-
widthLine
,
startY
+
1
*
0.75
*
scaleIndex
,
startX
-
widthLine
+
widthArrow
);
}
ctx
.
setLineWidth
(
t
.
width_1px
);
ctx
.
setStrokeStyle
(
m_oColor
);
ctx
.
stroke
();
};
var
_drawFilterMark
=
function
(
x
,
y
,
height
)
{
var
size
=
5.25
*
scaleIndex
;
var
halfSize
=
Math
.
round
((
size
/
2
)
/
0.75
)
*
0.75
;
var
meanLine
=
Math
.
round
((
size
*
Math
.
sqrt
(
3
)
/
3
)
/
0.75
)
*
0.75
;
//длина биссектрисы равностороннего треугольника
//округляем + смещаем
x
=
Math
.
round
((
x
)
/
0.75
)
*
0.75
;
y
=
Math
.
round
((
y
)
/
0.75
)
*
0.75
;
var
y1
=
y
-
height
;
ws
.
drawingCtx
.
beginPath
()
.
moveTo
(
x
,
y
)
.
lineTo
(
x
,
y1
)
.
setStrokeStyle
(
m_oColor
)
.
stroke
();
ws
.
drawingCtx
.
beginPath
()
.
moveTo
(
x
+
halfSize
,
y1
)
.
lineTo
(
x
+
halfSize
,
y1
)
.
lineTo
(
x
,
y1
+
meanLine
)
.
lineTo
(
x
-
halfSize
,
y1
)
.
lineTo
(
x
,
y1
)
.
setFillStyle
(
m_oColor
)
.
fill
();
};
var
_drawFilterDreieck
=
function
(
x
,
y
,
index
)
{
var
size
=
5.25
*
index
;
//сюда приходят координаты центра кнопки
//чтобы кнопка была в центре, необходимо сместить
var
leftDiff
=
size
/
2
;
var
upDiff
=
Math
.
round
(((
size
*
Math
.
sqrt
(
3
))
/
6
)
/
0.75
)
*
0.75
;
//радиус вписанной окружности в треугольник
//округляем + смещаем
x
=
Math
.
round
((
x
-
leftDiff
)
/
0.75
)
*
0.75
;
y
=
Math
.
round
((
y
-
upDiff
)
/
0.75
)
*
0.75
;
var
meanLine
=
Math
.
round
((
size
*
Math
.
sqrt
(
3
)
/
3
)
/
0.75
)
*
0.75
;
//длина биссектрисы равностороннего треугольника
var
halfSize
=
Math
.
round
((
size
/
2
)
/
0.75
)
*
0.75
;
//рисуем
ws
.
drawingCtx
.
beginPath
()
.
moveTo
(
x
,
y
)
.
lineTo
(
x
+
size
,
y
)
.
lineTo
(
x
+
halfSize
,
y
+
meanLine
)
.
lineTo
(
x
,
y
)
.
setFillStyle
(
m_oColor
)
.
fill
();
};
var
diffX
=
0
;
var
diffY
=
0
;
if
((
colWidth
-
2
)
<
width
&&
rowHeight
<
(
height
+
2
))
{
if
(
rowHeight
<
colWidth
)
{
scaleIndex
=
rowHeight
/
height
;
width
=
width
*
scaleIndex
;
height
=
rowHeight
;
}
else
{
scaleIndex
=
colWidth
/
width
;
diffY
=
width
-
colWidth
;
diffX
=
width
-
colWidth
;
width
=
colWidth
;
height
=
height
*
scaleIndex
;
}
}
else
if
((
colWidth
-
2
)
<
width
)
{
scaleIndex
=
colWidth
/
width
;
//смещения по x и y
diffY
=
width
-
colWidth
;
diffX
=
width
-
colWidth
+
2
;
width
=
colWidth
;
height
=
height
*
scaleIndex
;
}
else
if
(
rowHeight
<
height
)
{
scaleIndex
=
rowHeight
/
height
;
width
=
width
*
scaleIndex
;
height
=
rowHeight
;
}
//квадрат кнопки рисуем
_drawButtonBorder
(
x1
+
diffX
,
y1
+
diffY
,
width
,
height
);
//координаты левого верхнего угла кнопки
var
upLeftXButton
=
x1
+
diffX
;
var
upLeftYButton
=
y1
+
diffY
;
var
centerX
,
centerY
;
/*if(null !== isApplySortState && isApplyAutoFilter)
{
centerX = upLeftXButton + (width / 2);
var heigthObj = Math.ceil((height / 2) / 0.75) * 0.75 + 1 * 0.75;
var marginTop = Math.floor(((height - heigthObj) / 2) / 0.75) * 0.75;
centerY = upLeftYButton + heigthObj + marginTop;
_drawSortArrow(upLeftXButton + 4 * 0.75, upLeftYButton + 5 * 0.75, isApplySortState, 8);
_drawFilterMark(centerX + 2 * 0.75, centerY, heigthObj);
}
else if(null !== isApplySortState)
{
centerX = upLeftXButton + (width / 2);
centerY = upLeftYButton + (height / 2);
_drawSortArrow(centerX + 2 * 0.75, upLeftYButton + 3 * 0.75, isApplySortState, 10);
_drawFilterDreieck(centerX - 3 * 0.75, centerY + 2 * 0.75, scaleIndex * 0.75);
}
else */
if
(
isApplyAutoFilter
)
{
centerX
=
upLeftXButton
+
(
width
/
2
);
var
heigthObj
=
Math
.
ceil
((
height
/
2
)
/
0.75
)
*
0.75
+
1
*
0.75
;
var
marginTop
=
Math
.
floor
(((
height
-
heigthObj
)
/
2
)
/
0.75
)
*
0.75
;
centerY
=
upLeftYButton
+
heigthObj
+
marginTop
;
_drawFilterMark
(
centerX
,
centerY
,
heigthObj
);
}
else
{
//центр кнопки
centerX
=
upLeftXButton
+
(
width
/
2
);
centerY
=
upLeftYButton
+
(
height
/
2
);
_drawFilterDreieck
(
centerX
,
centerY
,
scaleIndex
);
}
};
WorksheetView
.
prototype
.
af_checkCursor
=
function
(
x
,
y
,
offsetX
,
offsetY
,
frozenObj
,
r
,
c
)
{
WorksheetView
.
prototype
.
af_checkCursor
=
function
(
x
,
y
,
offsetX
,
offsetY
,
frozenObj
,
r
,
c
)
{
var
ws
=
this
;
var
ws
=
this
;
var
aWs
=
this
.
model
;
var
aWs
=
this
.
model
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment