mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 10:39:09 +02:00
Columns property in TCustomGrid by Jesus
git-svn-id: trunk@6485 -
This commit is contained in:
parent
f85854acac
commit
6334f891ba
@ -26,7 +26,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, TypInfo,
|
Classes, SysUtils, TypInfo,
|
||||||
LCLProc, Forms, Controls, Menus, ExtCtrls, Grids, Buttons, ComCtrls,
|
LCLProc, Forms, Controls, Menus, ExtCtrls, Graphics, Grids, Buttons, ComCtrls,
|
||||||
PropEdits, ObjInspStrConsts;
|
PropEdits, ObjInspStrConsts;
|
||||||
|
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ type
|
|||||||
TStringGridComponentEditor = class(TDefaultComponentEditor)
|
TStringGridComponentEditor = class(TDefaultComponentEditor)
|
||||||
protected
|
protected
|
||||||
procedure DoShowEditor;
|
procedure DoShowEditor;
|
||||||
procedure AssignGrid(dstGrid, srcGrid: TStringGrid);
|
procedure AssignGrid(dstGrid, srcGrid: TStringGrid; Full: boolean);
|
||||||
public
|
public
|
||||||
procedure ExecuteVerb(Index: Integer); override;
|
procedure ExecuteVerb(Index: Integer); override;
|
||||||
function GetVerb(Index: Integer): string; override;
|
function GetVerb(Index: Integer): string; override;
|
||||||
@ -303,7 +303,6 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ RegisterComponentEditor }
|
{ RegisterComponentEditor }
|
||||||
type
|
type
|
||||||
PComponentClassRec = ^TComponentClassRec;
|
PComponentClassRec = ^TComponentClassRec;
|
||||||
@ -742,12 +741,19 @@ Type
|
|||||||
TStringGridEditorDlg=Class(TForm)
|
TStringGridEditorDlg=Class(TForm)
|
||||||
private
|
private
|
||||||
FGrid: TStringGrid;
|
FGrid: TStringGrid;
|
||||||
procedure OnFixedRows(Sender: TObject);
|
FFixedColor: TColor;
|
||||||
procedure OnFixedCols(Sender: TObject);
|
FFixedRows,FFixedCols: Integer;
|
||||||
|
//procedure OnFixedRows(Sender: TObject);
|
||||||
|
//procedure OnFixedCols(Sender: TObject);
|
||||||
|
procedure OnPrepareCanvas(Sender: TObject; Col,Row:Integer; aState: TGridDrawState);
|
||||||
public
|
public
|
||||||
constructor create(AOwner: TComponent); override;
|
constructor create(AOwner: TComponent); override;
|
||||||
|
property Grid: TStringGrid read FGrid write FGrid;
|
||||||
|
property FixedColor: TColor read FFixedColor write FFixedColor;
|
||||||
|
property FixedRows: Integer read FFixedRows write FFixedRows;
|
||||||
|
property FixedCols: Integer read FFixedCols write FFixedCols;
|
||||||
end;
|
end;
|
||||||
|
{
|
||||||
procedure TStringGridEditorDlg.OnFixedRows(Sender: TObject);
|
procedure TStringGridEditorDlg.OnFixedRows(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FGrid.FixedRows := FGrid.FixedRows + 1 - 2 * (Sender as TComponent).Tag;
|
FGrid.FixedRows := FGrid.FixedRows + 1 - 2 * (Sender as TComponent).Tag;
|
||||||
@ -757,6 +763,13 @@ procedure TStringGridEditorDlg.OnFixedCols(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
FGrid.FixedCols := FGrid.FixedCols + 1 - 2 * (Sender as TComponent).Tag;
|
FGrid.FixedCols := FGrid.FixedCols + 1 - 2 * (Sender as TComponent).Tag;
|
||||||
end;
|
end;
|
||||||
|
}
|
||||||
|
procedure TStringGridEditorDlg.OnPrepareCanvas(Sender: TObject;
|
||||||
|
Col,Row: Integer; aState: TGridDrawState);
|
||||||
|
begin
|
||||||
|
if (Col<FFixedCols) or (Row<FFixedRows) then
|
||||||
|
FGrid.Canvas.Brush.Color := FFixedColor
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TStringGridEditorDlg.create(AOwner: TComponent);
|
constructor TStringGridEditorDlg.create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
@ -772,7 +785,9 @@ begin
|
|||||||
FGrid.FixedCols:=0;
|
FGrid.FixedCols:=0;
|
||||||
FGrid.FixedRows:=0;
|
FGrid.FixedRows:=0;
|
||||||
FGrid.Options:=Fgrid.Options + [goEditing,goColSizing,goRowSizing];
|
FGrid.Options:=Fgrid.Options + [goEditing,goColSizing,goRowSizing];
|
||||||
|
FGrid.OnPrepareCanvas := @OnPrepareCanvas;
|
||||||
|
FGrid.ExtendedColSizing := True;
|
||||||
|
{
|
||||||
With TButton.Create(Self) do begin
|
With TButton.Create(Self) do begin
|
||||||
parent:=self;
|
parent:=self;
|
||||||
SetBounds(5, FGrid.Top + Fgrid.Height + 10, 80, 18);
|
SetBounds(5, FGrid.Top + Fgrid.Height + 10, 80, 18);
|
||||||
@ -802,7 +817,7 @@ begin
|
|||||||
Caption:='- FixedCols';
|
Caption:='- FixedCols';
|
||||||
OnClick:=@OnFixedCols;
|
OnClick:=@OnFixedCols;
|
||||||
end;
|
end;
|
||||||
|
}
|
||||||
//Bnt Ok
|
//Bnt Ok
|
||||||
With TBitBtn.Create(self) do
|
With TBitBtn.Create(self) do
|
||||||
begin
|
begin
|
||||||
@ -829,23 +844,27 @@ end;
|
|||||||
{ TStringGridComponentEditor }
|
{ TStringGridComponentEditor }
|
||||||
|
|
||||||
procedure TStringGridComponentEditor.DoShowEditor;
|
procedure TStringGridComponentEditor.DoShowEditor;
|
||||||
Var Dlg : TStringGridEditorDlg;
|
var Dlg : TStringGridEditorDlg;
|
||||||
Hook: TPropertyEditorHook;
|
Hook: TPropertyEditorHook;
|
||||||
aGrid: TStringGrid;
|
aGrid: TStringGrid;
|
||||||
begin
|
begin
|
||||||
Dlg:=TStringGridEditorDlg.Create(nil);
|
Dlg:=TStringGridEditorDlg.Create(nil);
|
||||||
try
|
try
|
||||||
If GetComponent is TStringGrid then
|
if GetComponent is TStringGrid then begin
|
||||||
begin
|
|
||||||
aGrid:=TStringGrid(GetComponent);
|
aGrid:=TStringGrid(GetComponent);
|
||||||
GetHook(Hook);
|
GetHook(Hook);
|
||||||
AssignGrid(Dlg.FGrid, aGrid);
|
|
||||||
|
|
||||||
|
Dlg.FixedRows := AGrid.FixedRows;
|
||||||
|
Dlg.FixedCols := AGrid.FixedCols;
|
||||||
|
Dlg.FixedColor := AGrid.FixedColor;
|
||||||
|
|
||||||
|
AssignGrid(Dlg.FGrid, aGrid, true);
|
||||||
|
|
||||||
//ShowEditor
|
//ShowEditor
|
||||||
if Dlg.ShowModal=mrOK then
|
if Dlg.ShowModal=mrOK then
|
||||||
begin
|
begin
|
||||||
//Apply the modifications
|
//Apply the modifications
|
||||||
AssignGrid(aGrid, Dlg.FGrid);
|
AssignGrid(aGrid, Dlg.FGrid, false);
|
||||||
//not work :o( aImg.AddImages(Dlg.fGrid);
|
//not work :o( aImg.AddImages(Dlg.fGrid);
|
||||||
Modified;
|
Modified;
|
||||||
end;
|
end;
|
||||||
@ -855,22 +874,31 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TStringGridComponentEditor.AssignGrid(dstGrid, srcGrid: TStringGrid);
|
procedure TStringGridComponentEditor.AssignGrid(dstGrid, srcGrid: TStringGrid;
|
||||||
|
Full: boolean);
|
||||||
var
|
var
|
||||||
i,j: integer;
|
i,j: integer;
|
||||||
begin
|
begin
|
||||||
DstGrid.BeginUpdate;
|
DstGrid.BeginUpdate;
|
||||||
DstGrid.Clear;
|
try
|
||||||
Dstgrid.ColCount:=srcGrid.ColCount;
|
if Full then begin
|
||||||
DstGrid.RowCount:=srcGrid.RowCount;
|
DstGrid.Clear;
|
||||||
DstGrid.FixedRows:=srcGrid.FixedRows;
|
Dstgrid.ColCount:=srcGrid.ColCount;
|
||||||
Dstgrid.FixedCols:=srcGrid.FixedCols;
|
DstGrid.RowCount:=srcGrid.RowCount;
|
||||||
for i:=0 to srcGrid.RowCount-1 do DstGrid.RowHeights[i]:=srcGrid.RowHeights[i];
|
//DstGrid.FixedRows:=srcGrid.FixedRows;
|
||||||
for i:=0 to srcGrid.ColCount-1 do DstGrid.ColWidths[i]:=srcGrid.ColWidths[i];
|
//Dstgrid.FixedCols:=srcGrid.FixedCols;
|
||||||
for i:=0 to srcGrid.ColCount-1 do
|
end;
|
||||||
for j:=0 to srcGrid.RowCount-1 do
|
for i:=0 to srcGrid.RowCount-1 do
|
||||||
if srcGrid.Cells[i,j]<>'' then dstGrid.Cells[i,j]:=srcGrid.Cells[i,j];
|
DstGrid.RowHeights[i]:=srcGrid.RowHeights[i];
|
||||||
DstGrid.EndUpdate(uoFull);
|
for i:=0 to srcGrid.ColCount-1 do
|
||||||
|
DstGrid.ColWidths[i]:=srcGrid.ColWidths[i];
|
||||||
|
for i:=0 to srcGrid.ColCount-1 do
|
||||||
|
for j:=0 to srcGrid.RowCount-1 do
|
||||||
|
if srcGrid.Cells[i,j]<>'' then
|
||||||
|
dstGrid.Cells[i,j]:=srcGrid.Cells[i,j];
|
||||||
|
finally
|
||||||
|
Dstgrid.EndUpdate(uoFull);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TStringGridComponentEditor.ExecuteVerb(Index: Integer);
|
procedure TStringGridComponentEditor.ExecuteVerb(Index: Integer);
|
||||||
|
1303
lcl/dbgrids.pas
1303
lcl/dbgrids.pas
File diff suppressed because it is too large
Load Diff
@ -288,7 +288,8 @@ type
|
|||||||
|
|
||||||
{ TDateEdit }
|
{ TDateEdit }
|
||||||
|
|
||||||
TAcceptDateEvent = Procedure (Sender : TObject; Var ADate : TDateTime; Var Action : Boolean) of Object;
|
TAcceptDateEvent = Procedure (Sender : TObject; Var ADate : TDateTime;
|
||||||
|
Var AcceptDate: Boolean) of Object;
|
||||||
TDateEdit = Class(TCustomEditButton)
|
TDateEdit = Class(TCustomEditButton)
|
||||||
private
|
private
|
||||||
FDialogTitle: String;
|
FDialogTitle: String;
|
||||||
|
1591
lcl/grids.pas
1591
lcl/grids.pas
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user