/usr/lib/lazarus/0.9.30.4/ideintf/lazstringgridedit.pas is in lazarus-src-0.9.30.4 0.9.30.4-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | {
*****************************************************************************
* *
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
*****************************************************************************
}
unit LazStringGridEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
Arrow, StdCtrls, Buttons, Grids, ExtCtrls,
ObjInspStrConsts;
type
{ TStringGridEditorDlg }
TStringGridEditorDlg = class(TForm)
ArrowLeft: TArrow;
ArrowRight: TArrow;
ArrowDown: TArrow;
ArrowUp: TArrow;
BtnOK: TBitBtn;
BtnCancel: TBitBtn;
BtnApply: TBitBtn;
BtnHelp: TBitBtn;
BtnLoad: TButton;
BtnSave: TButton;
BtnClean: TButton;
GroupBox: TGroupBox;
LabelMove: TLabel;
OpenDialog: TOpenDialog;
BtnPanel: TPanel;
LoadSavePanel: TPanel;
SaveDialog: TSaveDialog;
StringGrid: TStringGrid;
procedure BtnApplyClick(Sender: TObject);
procedure BtnCleanClick(Sender: TObject);
procedure BtnLoadClick(Sender: TObject);
procedure BtnSaveClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure StringGridPrepareCanvas(sender: TObject; Col, Row: Integer;
aState: TGridDrawState);
procedure SwapRowCol(Sender:TObject);
private
FModified: Boolean;
FStringGrid: TStringGrid;
public
property Modified: Boolean read FModified;
procedure LoadFromGrid(AStringGrid: TStringGrid);
procedure SaveToGrid;
end;
implementation
{$R *.lfm}
procedure AssignGrid(Dest, Src: TStringGrid; Full: Boolean);
var
I, J: Integer;
begin
Dest.BeginUpdate;
try
if Full then
begin
Dest.Clear;
Dest.ColCount := Src.ColCount;
Dest.RowCount := Src.RowCount;
end;
for I := 0 to Src.RowCount - 1 do
Dest.RowHeights[I] := Src.RowHeights[I];
for I := 0 to Src.ColCount - 1 do
Dest.ColWidths[I] := Src.ColWidths[I];
for I := 0 to Src.ColCount - 1 do
for J := 0 to Src.RowCount - 1 do
Dest.Cells[I, J] := Src.Cells[I, J];
finally
Dest.EndUpdate;
end;
end;
{ TStringGridEditorDlg }
procedure TStringGridEditorDlg.BtnApplyClick(Sender: TObject);
begin
SaveToGrid;
end;
procedure TStringGridEditorDlg.BtnCleanClick(Sender: TObject);
begin
StringGrid.Clean;
end;
procedure TStringGridEditorDlg.BtnLoadClick(Sender: TObject);
begin
if OpenDialog.Execute then
begin
StringGrid.LoadFromFile(OpenDialog.FileName);
end;
end;
procedure TStringGridEditorDlg.BtnSaveClick(Sender: TObject);
begin
if SaveDialog.Execute then
begin
StringGrid.SaveToFile(SaveDialog.FileName);
end;
end;
procedure TStringGridEditorDlg.FormCreate(Sender: TObject);
begin
Caption := sccsSGEdtCaption;
GroupBox.Caption := sccsSGEdtGrp;
BtnClean.Caption := sccsSGEdtClean;
BtnApply.Caption := sccsSGEdtApply;
BtnLoad.Caption := sccsSGEdtLoad;
BtnSave.Caption := sccsSGEdtSave;
LabelMove.Caption := sccsSGEdtMoveRowsCols;
BtnHelp.Caption:=cActionListEditorHelpCategory;
BtnCancel.Caption:=oiStdActDataSetCancel1Hint;
BtnOK.Caption:=oisOk2;
OpenDialog.Title := sccsSGEdtOpenDialog;
SaveDialog.Title := sccsSGEdtSaveDialog;
StringGrid.ExtendedColSizing := True;
end;
procedure TStringGridEditorDlg.StringGridPrepareCanvas(sender: TObject; Col,
Row: Integer; aState: TGridDrawState);
begin
if (Col < FStringGrid.FixedCols) or (Row < FStringGrid.FixedRows) then
StringGrid.Canvas.Brush.Color := FStringGrid.FixedColor;
end;
procedure TStringGridEditorDlg.SwapRowCol(Sender:TObject);
begin
if TObject(Sender)=ArrowLeft then begin
try
StringGrid.ExchangeColRow(true,StringGrid.Col,StringGrid.Col-1);
StringGrid.Col:=StringGrid.Col-1;
except
end;
end;
if TObject(Sender)=ArrowUp then begin
try
StringGrid.ExchangeColRow(false,StringGrid.Row,StringGrid.Row-1);
StringGrid.Row:=StringGrid.Row-1;
except
end;
end;
if TObject(Sender)=ArrowRight then begin
try
StringGrid.ExchangeColRow(true,StringGrid.Col,StringGrid.Col+1);
StringGrid.Col:=StringGrid.Col+1;
except
end;
end;
if TObject(Sender)=ArrowDown then begin
try
StringGrid.ExchangeColRow(false,StringGrid.Row,StringGrid.Row+1);
StringGrid.Row:=StringGrid.Row+1;
except
end;
end;
end;
procedure TStringGridEditorDlg.LoadFromGrid(AStringGrid: TStringGrid);
begin
if Assigned(AStringGrid) then
begin
FStringGrid := AStringGrid;
AssignGrid(StringGrid, AStringGrid, True);
FModified := False;
end;
end;
procedure TStringGridEditorDlg.SaveToGrid;
begin
if Assigned(FStringGrid) then
begin
AssignGrid(FStringGrid, StringGrid, False);
FModified := True;
end;
end;
end.
|