?? bsskingrids.pas
字號:
procedure TbsSkinCustomGrid.ChangeSkinData;
var
i, Old: Integer;
begin
GetSkinData;
if FIndex > -1
then
begin
Old := DefaultRowHeight;
i := RectHeight(SelectCellRect);
if i <> Old
then
DefaultRowHeight := i
else
Invalidate;
end
else
begin
DefaultRowHeight := FDefaultCellHeight;
Invalidate;
end;
UpDateScrollRange(True);
if FVScrollBar <> nil then FVScrollBar.Align := FVScrollBar.Align;
if FHScrollBar <> nil then FHScrollBar.Align := FHScrollBar.Align;
end;
procedure TbsSkinCustomGrid.GetSkinData;
begin
Picture := nil;
FIndex := -1;
inherited;
if FIndex > -1
then
if TbsDataSkinControl(FSD.CtrlList.Items[FIndex]) is TbsDataSkinGridControl
then
with TbsDataSkinGridControl(FSD.CtrlList.Items[FIndex]) do
begin
//
if (PictureIndex <> -1) and (PictureIndex < FSD.FActivePictures.Count)
then
Picture := TBitMap(FSD.FActivePictures.Items[PictureIndex])
else
Picture := nil;
//
Self.FixedCellRect := FixedCellRect;
Self.SelectCellRect := SelectCellRect;
Self.FocusCellRect := FocusCellRect;
Self.FixedCellLeftOffset := FixedCellLeftOffset;
Self.FixedCellRightOffset := FixedCellRightOffset;
Self.FixedCellTextRect := FixedCellTextRect;
Self.CellLeftOffset := CellLeftOffset;
Self.CellRightOffset := CellRightOffset;
Self.CellTextRect := CellTextRect;
Self.LinesColor := LinesColor;
Self.BGColor := BGColor;
//
Self.FontName := FontName;
Self.FontStyle := FontStyle;
Self.FontHeight := FontHeight;
Self.FontColor := FontColor;
Self.SelectFontColor := SelectFontColor;
Self.FocusFontColor := FocusFontColor;
Self.FixedFontName := FixedFontName;
Self.FixedFontStyle := FixedFontStyle;
Self.FixedFontHeight := FixedFontHeight;
Self.FixedFontColor := FixedFontColor;
if IsNullRect(Self.SelectCellRect)
then
Self.SelectCellRect := Self.FocusCellRect;
if IsNullRect(Self.FocusCellRect)
then
Self.FocusCellRect := Self.SelectCellRect;
if IsNullRect(Self.FixedCellRect)
then
begin
FIndex := -1;
Picture := nil;
end;
end;
end;
procedure TbsSkinCustomGrid.AdjustSize(Index, Amount: Longint; Rows: Boolean);
var
NewCur: TGridCoord;
OldRows, OldCols: Longint;
MovementX, MovementY: Longint;
MoveRect: TGridRect;
ScrollArea: TRect;
AbsAmount: Longint;
function DoSizeAdjust(var Count: Longint; var Extents: Pointer;
DefaultExtent: Integer; var Current: Longint): Longint;
var
I: Integer;
NewCount: Longint;
begin
NewCount := Count + Amount;
if NewCount < Index then InvalidOp(STooManyDeleted);
if (Amount < 0) and Assigned(Extents) then
begin
Result := 0;
for I := Index to Index - Amount - 1 do
Inc(Result, PIntArray(Extents)^[I]);
end
else
Result := Amount * DefaultExtent;
if Extents <> nil then
ModifyExtents(Extents, Index, Amount, DefaultExtent);
Count := NewCount;
if Current >= Index then
if (Amount < 0) and (Current < Index - Amount) then Current := Index
else Inc(Current, Amount);
end;
begin
if Amount = 0 then Exit;
NewCur := FCurrent;
OldCols := ColCount;
OldRows := RowCount;
MoveRect.Left := FixedCols;
MoveRect.Right := ColCount - 1;
MoveRect.Top := FixedRows;
MoveRect.Bottom := RowCount - 1;
MovementX := 0;
MovementY := 0;
AbsAmount := Amount;
if AbsAmount < 0 then AbsAmount := -AbsAmount;
if Rows then
begin
MovementY := DoSizeAdjust(FRowCount, FRowHeights, DefaultRowHeight, NewCur.Y);
MoveRect.Top := Index;
if Index + AbsAmount <= TopRow then MoveRect.Bottom := TopRow - 1;
end
else
begin
MovementX := DoSizeAdjust(FColCount, FColWidths, DefaultColWidth, NewCur.X);
MoveRect.Left := Index;
if Index + AbsAmount <= LeftCol then MoveRect.Right := LeftCol - 1;
end;
GridRectToScreenRect(MoveRect, ScrollArea, True);
if not IsRectEmpty(ScrollArea) then
begin
ScrollWindow(Handle, MovementX, MovementY, @ScrollArea, @ScrollArea);
UpdateWindow(Handle);
end;
SizeChanged(OldCols, OldRows);
if (NewCur.X <> FCurrent.X) or (NewCur.Y <> FCurrent.Y) then
MoveCurrent(NewCur.X, NewCur.Y, True, True);
end;
function TbsSkinCustomGrid.BoxRect(ALeft, ATop, ARight, ABottom: Longint): TRect;
var
GridRect: TGridRect;
begin
GridRect.Left := ALeft;
GridRect.Right := ARight;
GridRect.Top := ATop;
GridRect.Bottom := ABottom;
GridRectToScreenRect(GridRect, Result, False);
end;
procedure TbsSkinCustomGrid.DoExit;
begin
inherited DoExit;
if not (goAlwaysShowEditor in Options) then HideEditor;
end;
function TbsSkinCustomGrid.CellRect(ACol, ARow: Longint): TRect;
begin
Result := BoxRect(ACol, ARow, ACol, ARow);
end;
function TbsSkinCustomGrid.CanEditAcceptKey(Key: Char): Boolean;
begin
Result := True;
end;
function TbsSkinCustomGrid.CanGridAcceptKey(Key: Word; Shift: TShiftState): Boolean;
begin
Result := True;
end;
function TbsSkinCustomGrid.CanEditModify: Boolean;
begin
Result := FCanEditModify;
end;
function TbsSkinCustomGrid.CanEditShow: Boolean;
begin
Result := ([goRowSelect, goEditing] * Options = [goEditing]) and
FEditorMode and not (csDesigning in ComponentState) and HandleAllocated and
((goAlwaysShowEditor in Options) or IsActiveControl);
end;
function TbsSkinCustomGrid.IsActiveControl: Boolean;
var
H: Hwnd;
ParentForm: TCustomForm;
begin
Result := False;
ParentForm := GetParentForm(Self);
if Assigned(ParentForm) then
begin
if (ParentForm.ActiveControl = Self) then
Result := True
end
else
begin
H := GetFocus;
while IsWindow(H) and (Result = False) do
begin
if H = WindowHandle then
Result := True
else
H := GetParent(H);
end;
end;
end;
function TbsSkinCustomGrid.GetEditMask(ACol, ARow: Longint): string;
begin
Result := '';
end;
function TbsSkinCustomGrid.GetEditText(ACol, ARow: Longint): string;
begin
Result := '';
end;
procedure TbsSkinCustomGrid.SetEditText(ACol, ARow: Longint; const Value: string);
begin
end;
function TbsSkinCustomGrid.GetEditLimit: Integer;
begin
Result := 0;
end;
procedure TbsSkinCustomGrid.HideEditor;
begin
FEditorMode := False;
HideEdit;
end;
procedure TbsSkinCustomGrid.ShowEditor;
begin
FEditorMode := True;
UpdateEdit;
end;
procedure TbsSkinCustomGrid.ShowEditorChar(Ch: Char);
begin
ShowEditor;
if FInplaceEdit <> nil then
PostMessage(FInplaceEdit.Handle, WM_CHAR, Word(Ch), 0);
end;
procedure TbsSkinCustomGrid.InvalidateEditor;
begin
FInplaceCol := -1;
FInplaceRow := -1;
UpdateEdit;
end;
procedure TbsSkinCustomGrid.ReadColWidths(Reader: TReader);
var
I: Integer;
begin
with Reader do
begin
ReadListBegin;
for I := 0 to ColCount - 1 do ColWidths[I] := ReadInteger;
ReadListEnd;
end;
end;
procedure TbsSkinCustomGrid.ReadRowHeights(Reader: TReader);
var
I: Integer;
begin
with Reader do
begin
ReadListBegin;
for I := 0 to RowCount - 1 do RowHeights[I] := ReadInteger;
ReadListEnd;
end;
end;
procedure TbsSkinCustomGrid.WriteColWidths(Writer: TWriter);
var
I: Integer;
begin
with Writer do
begin
WriteListBegin;
for I := 0 to ColCount - 1 do WriteInteger(ColWidths[I]);
WriteListEnd;
end;
end;
procedure TbsSkinCustomGrid.WriteRowHeights(Writer: TWriter);
var
I: Integer;
begin
with Writer do
begin
WriteListBegin;
for I := 0 to RowCount - 1 do WriteInteger(RowHeights[I]);
WriteListEnd;
end;
end;
procedure TbsSkinCustomGrid.DefineProperties(Filer: TFiler);
function DoColWidths: Boolean;
begin
if Filer.Ancestor <> nil then
Result := not CompareExtents(TbsSkinCustomGrid(Filer.Ancestor).FColWidths, FColWidths)
else
Result := FColWidths <> nil;
end;
function DoRowHeights: Boolean;
begin
if Filer.Ancestor <> nil then
Result := not CompareExtents(TbsSkinCustomGrid(Filer.Ancestor).FRowHeights, FRowHeights)
else
Result := FRowHeights <> nil;
end;
begin
inherited DefineProperties(Filer);
if FSaveCellExtents then
with Filer do
begin
DefineProperty('ColWidths', ReadColWidths, WriteColWidths, DoColWidths);
DefineProperty('RowHeights', ReadRowHeights, WriteRowHeights, DoRowHeights);
end;
end;
procedure TbsSkinCustomGrid.MoveColumn(FromIndex, ToIndex: Longint);
var
Rect: TGridRect;
begin
if FromIndex = ToIndex then Exit;
if Assigned(FColWidths) then
begin
MoveExtent(FColWidths, FromIndex + 1, ToIndex + 1);
MoveExtent(FTabStops, FromIndex + 1, ToIndex + 1);
end;
MoveAdjust(FCurrent.X, FromIndex, ToIndex);
MoveAdjust(FAnchor.X, FromIndex, ToIndex);
MoveAdjust(FInplaceCol, FromIndex, ToIndex);
Rect.Top := 0;
Rect.Bottom := VisibleRowCount;
if FromIndex < ToIndex then
begin
Rect.Left := FromIndex;
Rect.Right := ToIndex;
end
else
begin
Rect.Left := ToIndex;
Rect.Right := FromIndex;
end;
InvalidateRect(Rect);
ColumnMoved(FromIndex, ToIndex);
if Assigned(FColWidths) then
ColWidthsChanged;
UpdateEdit;
end;
procedure TbsSkinCustomGrid.ColumnMoved(FromIndex, ToIndex: Longint);
begin
end;
procedure TbsSkinCustomGrid.MoveRow(FromIndex, ToIndex: Longint);
begin
if Assigned(FRowHeights) then
MoveExtent(FRowHeights, FromIndex + 1, ToIndex + 1);
MoveAdjust(FCurrent.Y, FromIndex, ToIndex);
MoveAdjust(FAnchor.Y, FromIndex, ToIndex);
MoveAdjust(FInplaceRow, FromIndex, ToIndex);
RowMoved(FromIndex, ToIndex);
if Assigned(FRowHeights) then
RowHeightsChanged;
UpdateEdit;
end;
procedure TbsSkinCustomGrid.RowMoved(FromIndex, ToIndex: Longint);
begin
end;
function TbsSkinCustomGrid.MouseCoord(X, Y: Integer): TGridCoord;
var
DrawInfo: TbsGridDrawInfo;
begin
CalcDrawInfo(DrawInfo);
Result := CalcCoordFromPoint(X, Y, DrawInfo);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -