mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 18:59:19 +02:00
fixed grids.pas
git-svn-id: trunk@4390 -
This commit is contained in:
parent
b371e11fc9
commit
991c3e7ba5
342
lcl/grids.pas
342
lcl/grids.pas
@ -968,35 +968,32 @@ begin
|
|||||||
result:=fTopLeft.x;
|
result:=fTopLeft.x;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TCustomGrid.Getcolcount: Integer;
|
function TCustomGrid.Getcolcount: Integer;
|
||||||
Begin
|
begin
|
||||||
Result:=FCols.Count;
|
Result:=FCols.Count;
|
||||||
End;
|
end;
|
||||||
|
|
||||||
Function TCustomGrid.Getrowcount: Integer;
|
function TCustomGrid.Getrowcount: Integer;
|
||||||
Begin
|
begin
|
||||||
Result:=FRows.Count;
|
Result:=FRows.Count;
|
||||||
End;
|
end;
|
||||||
|
|
||||||
Function TCustomGrid.Getcolwidths(Acol: Integer): Integer;
|
function TCustomGrid.Getcolwidths(Acol: Integer): Integer;
|
||||||
Begin
|
begin
|
||||||
if aCol<ColCount then begin
|
Result:=Integer(FCols[aCol]);
|
||||||
Result:=Integer(FCols[aCol]);
|
if result<0 then Result:=fDefColWidth;
|
||||||
if result<0 then Result:=fDefColWidth;
|
end;
|
||||||
end else
|
|
||||||
Result:=0;
|
|
||||||
End;
|
|
||||||
|
|
||||||
procedure TCustomGrid.SetEditor(AValue: TWinControl);
|
procedure TCustomGrid.SetEditor(AValue: TWinControl);
|
||||||
Var
|
var
|
||||||
Msg: TGridMessage;
|
Msg: TGridMessage;
|
||||||
begin
|
begin
|
||||||
if FEditor=AValue then exit;
|
if FEditor=AValue then exit;
|
||||||
FEditor:=AValue;
|
FEditor:=AValue;
|
||||||
if FEditor<>nil Then Begin
|
if FEditor<>nil then begin
|
||||||
//FEditor.ControlStyle:=FEditor.ControlStyle - [csCaptureMouse];
|
|
||||||
If FEditor.Parent=nil Then FEditor.Visible:=False;
|
if FEditor.Parent=nil then FEditor.Visible:=False;
|
||||||
If FEditor.Parent<>Self Then FEditor.Parent:=Self;
|
if FEditor.Parent<>Self then FEditor.Parent:=Self;
|
||||||
FEditor.TabStop:=False;
|
FEditor.TabStop:=False;
|
||||||
|
|
||||||
Msg.MsgID:=GM_SETGRID;
|
Msg.MsgID:=GM_SETGRID;
|
||||||
@ -1393,7 +1390,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// The visible grid Depends on TopLeft and ClientWidht,ClientHeight,
|
// The visible grid Depends on TopLeft and ClientWidht,ClientHeight,
|
||||||
// Col/Row Count, So it Should be called immediately after any change
|
// Col/Row Count, So it Should be called inmediately after any change
|
||||||
// like that
|
// like that
|
||||||
function TCustomGrid.GetVisibleGrid: TRect;
|
function TCustomGrid.GetVisibleGrid: TRect;
|
||||||
var
|
var
|
||||||
@ -1657,7 +1654,7 @@ var
|
|||||||
Rs: Boolean;
|
Rs: Boolean;
|
||||||
R: TRect;
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
if (RowCount=0) or (ColCount=0) then exit;
|
|
||||||
ColRowToOffSet(False, True, aRow, R.Top, R.Bottom);
|
ColRowToOffSet(False, True, aRow, R.Top, R.Bottom);
|
||||||
|
|
||||||
// Draw columns in this row
|
// Draw columns in this row
|
||||||
@ -2023,58 +2020,56 @@ begin
|
|||||||
// Adjust ScrollBar Positions
|
// Adjust ScrollBar Positions
|
||||||
// Special condition only When scrolling by draging
|
// Special condition only When scrolling by draging
|
||||||
// the scrollbars see: WMHScroll and WVHScroll
|
// the scrollbars see: WMHScroll and WVHScroll
|
||||||
If FUpdateScrollBarsCount=0 Then begin
|
if FUpdateScrollBarsCount=0 then begin
|
||||||
|
|
||||||
if (Which=HorzScrollBar)or(Which=nil) Then
|
if (Which=HorzScrollBar)or(Which=nil) then
|
||||||
If (FScrollBars in [ssAutoHorizontal, ssAutoBoth]) And
|
if (FScrollBars in [ssAutoHorizontal, ssAutoBoth]) and
|
||||||
HorzScrolLBar.Visible Then begin
|
HorzScrolLBar.Visible then begin
|
||||||
With FGCache do
|
with FGCache do
|
||||||
HorzScrollBar.Position:=
|
HorzScrollBar.Position:=
|
||||||
Integer(AccumWidth[FTopLeft.x])-TLColOff-FixedWidth;
|
Integer(AccumWidth[FTopLeft.x])-TLColOff-FixedWidth;
|
||||||
End;
|
end;
|
||||||
|
|
||||||
If (Which=VertScrollBar)Or(Which=nil) Then
|
if (Which=VertScrollBar)Or(Which=nil) then
|
||||||
If (FScrolLBars in [ssAutoVertical, ssAutoBoth]) And
|
if (FScrolLBars in [ssAutoVertical, ssAutoBoth]) and
|
||||||
VertScrolLBar.Visible Then begin
|
VertScrolLBar.Visible then begin
|
||||||
With FGCache do
|
with FGCache do
|
||||||
VertScrollBar.Position:=
|
VertScrollBar.Position:=
|
||||||
Integer(AccumHeight[FTopLeft.y])-TLRowOff-FixedHeight;
|
Integer(AccumHeight[FTopLeft.y])-TLRowOff-FixedHeight;
|
||||||
End;
|
end;
|
||||||
End; {If FUpd...}
|
end; {if FUpd...}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.CheckFixedCount(aCol,aRow,aFCol,aFRow: Integer);
|
procedure TCustomGrid.CheckFixedCount(aCol,aRow,aFCol,aFRow: Integer);
|
||||||
begin
|
begin
|
||||||
If AFRow<0 Then
|
if AFRow<0 then
|
||||||
Raise EGridException.Create('FixedRows<0');
|
Raise EGridException.Create('FixedRows<0');
|
||||||
If AFCol<0 Then
|
if AFCol<0 then
|
||||||
Raise EGridException.Create('FixedCols<0');
|
Raise EGridException.Create('FixedCols<0');
|
||||||
If (ACol>0)And(aFCol>=ACol) Then
|
|
||||||
|
if (aCol=0)And(aFCol=0) then // invalid grid, ok
|
||||||
|
else if (aFCol>=aCol) Then
|
||||||
raise EGridException.Create(rsFixedColsTooBig);
|
raise EGridException.Create(rsFixedColsTooBig);
|
||||||
If (ARow>0)And(aFRow>=ARow) Then
|
if (aRow=0)and(aFRow=0) then // Invalid grid, ok
|
||||||
|
else if (aFRow>=aRow) then
|
||||||
raise EGridException.Create(rsFixedRowsTooBig);
|
raise EGridException.Create(rsFixedRowsTooBig);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Save to the cache the current visible grid (excluding fixed cells) }
|
{ Save to the cache the current visible grid (excluding fixed cells) }
|
||||||
procedure TCustomGrid.CacheVisibleGrid;
|
procedure TCustomGrid.CacheVisibleGrid;
|
||||||
Var
|
var
|
||||||
R: TRect;
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
With FGCache do begin
|
with FGCache do begin
|
||||||
VisibleGrid:=GetVisibleGrid;
|
VisibleGrid:=GetVisibleGrid;
|
||||||
With VisibleGrid do
|
with VisibleGrid do
|
||||||
ValidGrid:=(Left>=0)And(Top>=0)And(Right>=Left)And(Bottom>=Top);
|
ValidGrid:=(Left>=0)and(Top>=0)and(Right>=Left)and(Bottom>=Top);
|
||||||
If Not ValidGrid Then MaxClientXY:=Point(0,0)
|
if not ValidGrid then MaxClientXY:=Point(0,0)
|
||||||
Else begin
|
else begin
|
||||||
if (VisibleGrid.Right<ColCount)
|
R:=ColRowToClientCellrect(VisibleGrid.Right, VisibleGrid.Bottom);
|
||||||
and (VisibleGrid.Bottom<RowCount) then begin
|
MaxClientXY:=R.BottomRight;
|
||||||
R:=ColRowToClientCellrect(VisibleGrid.Right, VisibleGrid.Bottom);
|
end;
|
||||||
MaxClientXY:=R.BottomRight;
|
end;
|
||||||
end else begin
|
|
||||||
MaxClientXY:=Point(0,0);
|
|
||||||
end;
|
|
||||||
End;
|
|
||||||
End;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomGrid.GetSelection: TGridRect;
|
function TCustomGrid.GetSelection: TGridRect;
|
||||||
@ -2106,255 +2101,255 @@ end;
|
|||||||
procedure TCustomGrid.SetSelectActive(const AValue: Boolean);
|
procedure TCustomGrid.SetSelectActive(const AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
if FSelectActive=AValue then exit;
|
if FSelectActive=AValue then exit;
|
||||||
FSelectActive:=AValue and Not(goEditing in Options);
|
FSelectActive:=AValue and not(goEditing in Options);
|
||||||
If FSelectActive Then FPivot:=Point(FCol,FRow);
|
if FSelectActive then FPivot:=Point(FCol,FRow);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.SetSelection(const AValue: TGridRect);
|
procedure TCustomGrid.SetSelection(const AValue: TGridRect);
|
||||||
begin
|
begin
|
||||||
If goRangeSelect in Options Then begin
|
if goRangeSelect in Options then begin
|
||||||
fRange:=NormalizarRect(aValue);
|
fRange:=NormalizarRect(aValue);
|
||||||
Invalidate;
|
Invalidate;
|
||||||
End;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomGrid.doColSizing(X, Y: Integer): Boolean;
|
function TCustomGrid.doColSizing(X, Y: Integer): Boolean;
|
||||||
Var
|
var
|
||||||
R: TRect;
|
R: TRect;
|
||||||
Loc: Integer;
|
Loc: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
If gsColSizing = fGridState Then begin
|
if gsColSizing = fGridState then begin
|
||||||
If x>FSplitter.y Then
|
if x>FSplitter.y then
|
||||||
ColWidths[FSplitter.x]:=x-FSplitter.y
|
ColWidths[FSplitter.x]:=x-FSplitter.y
|
||||||
Else
|
else
|
||||||
if ColWidths[FSplitter.x]>0 Then ColWidths[FSplitter.X]:=0;
|
if ColWidths[FSplitter.x]>0 then ColWidths[FSplitter.X]:=0;
|
||||||
Result:=True;
|
Result:=True;
|
||||||
End Else
|
end else
|
||||||
If (fGridState=gsNormal)And(Y<FGCache.FixedHeight)And(X>FGCache.FixedWidth) Then
|
if (fGridState=gsNormal)and(Y<FGCache.FixedHeight)and(X>FGCache.FixedWidth) then
|
||||||
begin
|
begin
|
||||||
FSplitter.X:= OffsetToColRow(True, True, X, Loc);
|
FSplitter.X:= OffsetToColRow(True, True, X, Loc);
|
||||||
FSplitter.Y:=0;
|
FSplitter.Y:=0;
|
||||||
If FSplitter.X>=0 Then begin
|
if FSplitter.X>=0 then begin
|
||||||
R:=ColRowToClientCellRect(FSplitter.x, FSplitter.y);
|
R:=ColRowToClientCellRect(FSplitter.x, FSplitter.y);
|
||||||
FSplitter.y:=X; // Resizing X reference
|
FSplitter.y:=X; // Resizing X reference
|
||||||
If (R.Right-X)<(X-R.Left) then Loc:=R.Right
|
if (R.Right-X)<(X-R.Left) then Loc:=R.Right
|
||||||
Else begin
|
else begin
|
||||||
Loc:=R.Left;
|
Loc:=R.Left;
|
||||||
Dec(FSplitter.x); // Resizing col is the previous
|
Dec(FSplitter.x); // Resizing col is the previous
|
||||||
End;
|
end;
|
||||||
IF (Abs(Loc-x)<=2)And(FSplitter.X>=FFixedCols) then Cursor:=crHSplit
|
IF (Abs(Loc-x)<=2)and(FSplitter.X>=FFixedCols) then Cursor:=crHSplit
|
||||||
Else Cursor:=crDefault;
|
else Cursor:=crDefault;
|
||||||
Result:=True;
|
Result:=True;
|
||||||
End;
|
end;
|
||||||
End
|
end
|
||||||
Else
|
else
|
||||||
If (cursor=crHSplit) Then Cursor:=crDefault;
|
if (cursor=crHSplit) then Cursor:=crDefault;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomGrid.doRowSizing(X, Y: Integer): Boolean;
|
function TCustomGrid.doRowSizing(X, Y: Integer): Boolean;
|
||||||
Var
|
var
|
||||||
OffTop,OffBottom: Integer;
|
OffTop,OffBottom: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
If gsRowSizing = fGridState Then begin
|
if gsRowSizing = fGridState then begin
|
||||||
If y>FSplitter.x Then
|
if y>FSplitter.x then
|
||||||
RowHeights[FSplitter.y]:=y-FSplitter.x
|
RowHeights[FSplitter.y]:=y-FSplitter.x
|
||||||
Else
|
else
|
||||||
if RowHeights[FSplitter.y]>0 Then RowHeights[FSplitter.Y]:=0;
|
if RowHeights[FSplitter.y]>0 then RowHeights[FSplitter.Y]:=0;
|
||||||
Result:=True;
|
Result:=True;
|
||||||
End Else
|
end else
|
||||||
If (fGridState=gsNormal)And(X<FGCache.FixedWidth)And(Y>FGCache.FixedHeight) Then
|
if (fGridState=gsNormal)and(X<FGCache.FixedWidth)and(Y>FGCache.FixedHeight) then
|
||||||
begin
|
begin
|
||||||
fSplitter.Y:=OffsetToColRow(False, True, Y, OffTop{dummy});
|
fSplitter.Y:=OffsetToColRow(False, True, Y, OffTop{dummy});
|
||||||
If Fsplitter.Y>=0 Then begin
|
if Fsplitter.Y>=0 then begin
|
||||||
ColRowToOffset(False, True, FSplitter.Y, OffTop, OffBottom);
|
ColRowToOffset(False, True, FSplitter.Y, OffTop, OffBottom);
|
||||||
FSplitter.X:=Y;
|
FSplitter.X:=Y;
|
||||||
If (OffBottom-Y)<(Y-OffTop) Then SwapInt(OffTop, OffBottom)
|
if (OffBottom-Y)<(Y-OffTop) then SwapInt(OffTop, OffBottom)
|
||||||
Else Dec(FSplitter.y);
|
else Dec(FSplitter.y);
|
||||||
IF (Abs(OffTop-y)<=2)And(FSplitter.Y>=FFixedRows) then Cursor:=crVSplit
|
IF (Abs(OffTop-y)<=2)and(FSplitter.Y>=FFixedRows) then Cursor:=crVSplit
|
||||||
Else Cursor:=crDefault;
|
else Cursor:=crDefault;
|
||||||
Result:=True;
|
Result:=True;
|
||||||
End;
|
end;
|
||||||
End
|
end
|
||||||
Else
|
else
|
||||||
If Cursor=crVSplit Then Cursor:=crDefault;
|
if Cursor=crVSplit then Cursor:=crDefault;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.doColMoving(X, Y: Integer);
|
procedure TCustomGrid.doColMoving(X, Y: Integer);
|
||||||
Var
|
var
|
||||||
P: TPoint;
|
P: TPoint;
|
||||||
R: TRect;
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
P:=MouseToCell(Point(X,Y));
|
P:=MouseToCell(Point(X,Y));
|
||||||
If (Abs(FSplitter.Y-X)>fDragDx)And(Cursor<>crMultiDrag) Then begin
|
if (Abs(FSplitter.Y-X)>fDragDx)and(Cursor<>crMultiDrag) then begin
|
||||||
Cursor:=crMultiDrag;
|
Cursor:=crMultiDrag;
|
||||||
FMoveLast:=Point(-1,-1);
|
FMoveLast:=Point(-1,-1);
|
||||||
ResetOffset(True, False);
|
ResetOffset(True, False);
|
||||||
End;
|
end;
|
||||||
if (Cursor=crMultiDrag)And
|
if (Cursor=crMultiDrag)and
|
||||||
(P.x>=FFixedCols) And
|
(P.x>=FFixedCols) and
|
||||||
((P.X<=FSplitter.X)or(P.X>FSplitter.X))And
|
((P.X<=FSplitter.X)or(P.X>FSplitter.X))and
|
||||||
(P.X<>FMoveLast.X) Then begin
|
(P.X<>FMoveLast.X) then begin
|
||||||
R:=ColRowToClientCellRect(P.x, P.y);
|
R:=ColRowToClientCellRect(P.x, P.y);
|
||||||
If P.x<=FSplitter.X Then fMoveLast.Y:=R.left
|
if P.x<=FSplitter.X then fMoveLast.Y:=R.left
|
||||||
Else FMoveLast.Y:=R.Right;
|
else FMoveLast.Y:=R.Right;
|
||||||
fMoveLast.X:=P.X;
|
fMoveLast.X:=P.X;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
End;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.doRowMoving(X, Y: Integer);
|
procedure TCustomGrid.doRowMoving(X, Y: Integer);
|
||||||
Var
|
var
|
||||||
P: TPoint;
|
P: TPoint;
|
||||||
R: TRect;
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
P:=MouseToCell(Point(X,Y));
|
P:=MouseToCell(Point(X,Y));
|
||||||
If (Cursor<>crMultiDrag)And(Abs(FSplitter.X-Y)>fDragDx) Then begin
|
if (Cursor<>crMultiDrag)and(Abs(FSplitter.X-Y)>fDragDx) then begin
|
||||||
Cursor:=crMultiDrag;
|
Cursor:=crMultiDrag;
|
||||||
FMoveLast:=Point(-1,-1);
|
FMoveLast:=Point(-1,-1);
|
||||||
ResetOffset(False, True);
|
ResetOffset(False, True);
|
||||||
End;
|
end;
|
||||||
if (Cursor=crMultiDrag)And
|
if (Cursor=crMultiDrag)and
|
||||||
(P.y>=FFixedRows) And
|
(P.y>=FFixedRows) and
|
||||||
((P.y<=FSplitter.Y)or(P.Y>FSplitter.Y))And
|
((P.y<=FSplitter.Y)or(P.Y>FSplitter.Y))and
|
||||||
(P.y<>FMoveLast.Y) Then begin
|
(P.y<>FMoveLast.Y) then begin
|
||||||
R:=ColRowToClientCellRect(P.x, P.y);
|
R:=ColRowToClientCellRect(P.x, P.y);
|
||||||
If P.y<=FSplitter.y Then fMoveLast.X:=R.Top
|
if P.y<=FSplitter.y then fMoveLast.X:=R.Top
|
||||||
Else FMoveLast.X:=R.Bottom;
|
else FMoveLast.X:=R.Bottom;
|
||||||
fMoveLast.Y:=P.Y;
|
fMoveLast.Y:=P.Y;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
End;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function TCustomGrid.OffsetToColRow(IsCol, Fisical: Boolean; Offset: Integer;
|
function TCustomGrid.OffsetToColRow(IsCol, Fisical: Boolean; Offset: Integer;
|
||||||
var Rest: Integer): Integer;
|
var Rest: Integer): Integer;
|
||||||
begin
|
begin
|
||||||
Result:=0; //Result:=-1;
|
Result:=0; //Result:=-1;
|
||||||
Rest:=0;
|
Rest:=0;
|
||||||
If Offset<0 Then Exit; // Out of Range;
|
if Offset<0 then Exit; // Out of Range;
|
||||||
With FGCache do
|
|
||||||
If IsCol Then begin
|
with FGCache do
|
||||||
|
if IsCol then begin
|
||||||
// Begin to count Cols from 0 but ...
|
|
||||||
If Fisical And (Offset>FixedWidth-1) Then begin
|
// begin to count Cols from 0 but ...
|
||||||
Result:=FTopLeft.X; // In scrolled view, then Begin from FtopLeft col
|
if Fisical and (Offset>FixedWidth-1) then begin
|
||||||
|
Result:=FTopLeft.X; // In scrolled view, then begin from FtopLeft col
|
||||||
Offset:=Offset-FixedWidth+Integer(AccumWidth[Result])+TLColOff;
|
Offset:=Offset-FixedWidth+Integer(AccumWidth[Result])+TLColOff;
|
||||||
If Offset>GridWidth-1 Then Begin
|
if Offset>GridWidth-1 then begin
|
||||||
Result:=ColCount-1;
|
Result:=ColCount-1;
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
end;
|
||||||
End;
|
end;
|
||||||
While Offset>(Integer(AccumWidth[Result])+GetColWidths(Result)-1) do Inc(Result);
|
while Offset>(Integer(AccumWidth[Result])+GetColWidths(Result)-1) do Inc(Result);
|
||||||
Rest:=Offset;
|
Rest:=Offset;
|
||||||
If Result<>0 Then Rest:=Offset-Integer(AccumWidth[Result]);
|
if Result<>0 then Rest:=Offset-Integer(AccumWidth[Result]);
|
||||||
|
|
||||||
End Else Begin
|
end else begin
|
||||||
|
|
||||||
If Fisical And (Offset>FixedHeight-1) Then begin
|
if Fisical and (Offset>FixedHeight-1) then begin
|
||||||
Result:=FTopLeft.Y;
|
Result:=FTopLeft.Y;
|
||||||
Offset:=Offset-FixedHeight+Integer(AccumHeight[Result])+TLRowOff;
|
Offset:=Offset-FixedHeight+Integer(AccumHeight[Result])+TLRowOff;
|
||||||
If Offset>GridHeight-1 Then Begin
|
if Offset>GridHeight-1 then begin
|
||||||
Result:=RowCount-1;
|
Result:=RowCount-1;
|
||||||
Exit; // Out of Range
|
Exit; // Out of Range
|
||||||
End;
|
end;
|
||||||
End;
|
end;
|
||||||
While Offset>(Integer(AccumHeight[Result])+GetRowHeights(Result)-1) do Inc(Result);
|
while Offset>(Integer(AccumHeight[Result])+GetRowHeights(Result)-1) do Inc(Result);
|
||||||
Rest:=Offset;
|
Rest:=Offset;
|
||||||
If Result<>0 Then Rest:=Offset-Integer(AccumHeight[Result]);
|
if Result<>0 then Rest:=Offset-Integer(AccumHeight[Result]);
|
||||||
|
|
||||||
End;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomGrid.ColRowToOffset(IsCol,Fisical:Boolean; Index:Integer;
|
function TCustomGrid.ColRowToOffset(IsCol,Fisical:Boolean; Index:Integer; var Ini,Fin:Integer): Boolean;
|
||||||
Var Ini,Fin:Integer): Boolean;
|
var
|
||||||
Var
|
|
||||||
Dim: Integer;
|
Dim: Integer;
|
||||||
begin
|
begin
|
||||||
With FGCache do begin
|
with FGCache do begin
|
||||||
If IsCol Then begin
|
if IsCol then begin
|
||||||
Ini:=Integer(AccumWidth[Index]);
|
Ini:=Integer(AccumWidth[Index]);
|
||||||
Dim:=GetColWidths(Index);
|
Dim:=GetColWidths(Index);
|
||||||
End Else begin
|
end else begin
|
||||||
Ini:=Integer(AccumHeight[Index]);
|
Ini:=Integer(AccumHeight[Index]);
|
||||||
Dim:= GetRowheights(Index);
|
Dim:= GetRowheights(Index);
|
||||||
End;
|
end;
|
||||||
if Not Fisical Then begin
|
if not Fisical then begin
|
||||||
Fin:=Ini + Dim;
|
Fin:=Ini + Dim;
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
end;
|
||||||
If IsCol Then Begin
|
if IsCol then begin
|
||||||
If index>=FFixedCols Then
|
if index>=FFixedCols then
|
||||||
Ini:=Ini-Integer(AccumWidth[FTopLeft.X]) + FixedWidth - TLColOff;
|
Ini:=Ini-Integer(AccumWidth[FTopLeft.X]) + FixedWidth - TLColOff;
|
||||||
End Else begin
|
end else begin
|
||||||
if Index>=FFixedRows then
|
if Index>=FFixedRows then
|
||||||
Ini:=Ini-Integer(AccumHeight[FTopLeft.Y]) + FixedHeight - TLRowOff;
|
Ini:=Ini-Integer(AccumHeight[FTopLeft.Y]) + FixedHeight - TLRowOff;
|
||||||
End;
|
end;
|
||||||
Fin:=Ini + Dim;
|
Fin:=Ini + Dim;
|
||||||
End;
|
end;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomGrid.MouseToGridZone(X, Y: Integer; CellCoords: Boolean): TGridZone;
|
function TCustomGrid.MouseToGridZone(X, Y: Integer; CellCoords: Boolean): TGridZone;
|
||||||
begin
|
begin
|
||||||
Result:=gzNormal;
|
Result:=gzNormal;
|
||||||
If CellCoords Then Begin
|
if CellCoords then begin
|
||||||
If (X<fFixedCols) then
|
if (X<fFixedCols) then
|
||||||
If Y<FFixedRows Then Result:= gzFixedCells
|
if Y<FFixedRows then Result:= gzFixedCells
|
||||||
Else Result:= gzFixedRows
|
else Result:= gzFixedRows
|
||||||
Else
|
else
|
||||||
If (Y<fFixedRows) Then
|
if (Y<fFixedRows) then
|
||||||
If X<FFixedCols Then Result:= gzFixedCells
|
if X<FFixedCols then Result:= gzFixedCells
|
||||||
Else Result:= gzFixedCols;
|
else Result:= gzFixedCols;
|
||||||
End Else begin
|
end else begin
|
||||||
If X<=FGCache.FixedWidth Then
|
if X<=FGCache.FixedWidth then
|
||||||
If Y<=FGcache.FixedHeight Then Result:=gzFixedCells
|
if Y<=FGcache.FixedHeight then Result:=gzFixedCells
|
||||||
Else Result:=gzFixedRows
|
else Result:=gzFixedRows
|
||||||
Else
|
else
|
||||||
If Y<=FGCache.FixedHeight Then
|
if Y<=FGCache.FixedHeight then
|
||||||
if X<=FGCache.FixedWidth Then Result:=gzFixedCells
|
if X<=FGCache.FixedWidth then Result:=gzFixedCells
|
||||||
Else Result:=gzFixedCols;
|
else Result:=gzFixedCols;
|
||||||
End;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.ExchangeColRow(IsColumn: Boolean; Index, WithIndex: Integer
|
procedure TCustomGrid.ExchangeColRow(IsColumn: Boolean; Index, WithIndex: Integer
|
||||||
);
|
);
|
||||||
begin
|
begin
|
||||||
If IsColumn Then FCols.Exchange(Index, WithIndex)
|
if IsColumn then FCols.Exchange(Index, WithIndex)
|
||||||
Else FRows.Exchange(Index, WithIndex);
|
else FRows.Exchange(Index, WithIndex);
|
||||||
ColRowExchanged(IsColumn, Index, WithIndex);
|
ColRowExchanged(IsColumn, Index, WithIndex);
|
||||||
VisualChange;
|
VisualChange;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.MoveColRow(IsColumn: Boolean; FromIndex, ToIndex: Integer);
|
procedure TCustomGrid.MoveColRow(IsColumn: Boolean; FromIndex, ToIndex: Integer);
|
||||||
begin
|
begin
|
||||||
If IsColumn then FCols.Move(FromIndex, ToIndex)
|
if IsColumn then FCols.Move(FromIndex, ToIndex)
|
||||||
Else FRows.Move(FromIndex, ToIndex);
|
else FRows.Move(FromIndex, ToIndex);
|
||||||
ColRowMoved(IsColumn, FromIndex, ToIndex);
|
ColRowMoved(IsColumn, FromIndex, ToIndex);
|
||||||
VisualChange;
|
VisualChange;
|
||||||
End;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.SortColRow(IsColumn: Boolean; Index: Integer);
|
procedure TCustomGrid.SortColRow(IsColumn: Boolean; Index: Integer);
|
||||||
begin
|
begin
|
||||||
If IsColumn Then SortColRow(IsColumn, Index, FFixedRows, RowCount-1)
|
if IsColumn then SortColRow(IsColumn, Index, FFixedRows, RowCount-1)
|
||||||
Else SortColRow(IsColumn, Index, FFixedCols, ColCount-1);
|
else SortColRow(IsColumn, Index, FFixedCols, ColCount-1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.SortColRow(IsColumn: Boolean; Index, FromIndex,
|
procedure TCustomGrid.SortColRow(IsColumn: Boolean; Index, FromIndex,
|
||||||
ToIndex: Integer);
|
ToIndex: Integer);
|
||||||
begin
|
begin
|
||||||
If Assigned(OnCompareCells) Then begin
|
if Assigned(OnCompareCells) then begin
|
||||||
BeginUpdate;
|
BeginUpdate;
|
||||||
Sort(IsColumn, Index, FromIndex, ToIndex);
|
Sort(IsColumn, Index, FromIndex, ToIndex);
|
||||||
EndUpdate(true);
|
EndUpdate(true);
|
||||||
End;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.DeleteColRow(IsColumn: Boolean; Index: Integer);
|
procedure TCustomGrid.DeleteColRow(IsColumn: Boolean; Index: Integer);
|
||||||
begin
|
begin
|
||||||
If IsColumn Then FCols.Delete(Index)
|
if IsColumn then FCols.Delete(Index)
|
||||||
Else FRows.Delete(Index);
|
else FRows.Delete(Index);
|
||||||
ColRowDeleted(IsColumn, Index);
|
ColRowDeleted(IsColumn, Index);
|
||||||
VisualChange;
|
VisualChange;
|
||||||
end;
|
end;
|
||||||
@ -2670,7 +2665,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ Returns a rectangle corresponding to a fisical cell[aCol,aRow] }
|
{ Returns a reactagle corresponding to a fisical cell[aCol,aRow] }
|
||||||
function TCustomGrid.ColRowToClientCellRect(aCol, aRow: Integer): TRect;
|
function TCustomGrid.ColRowToClientCellRect(aCol, aRow: Integer): TRect;
|
||||||
begin
|
begin
|
||||||
ColRowToOffset(True, True, ACol, Result.Left, Result.Right);
|
ColRowToOffset(True, True, ACol, Result.Left, Result.Right);
|
||||||
@ -4847,7 +4842,6 @@ end.
|
|||||||
|
|
||||||
{ The_Log
|
{ The_Log
|
||||||
|
|
||||||
|
|
||||||
VERSION: 0.8.4:
|
VERSION: 0.8.4:
|
||||||
---------------
|
---------------
|
||||||
Date: 21-JAN-2003
|
Date: 21-JAN-2003
|
||||||
|
Loading…
Reference in New Issue
Block a user