mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 04:29:25 +02:00
separated TStringGridEditorDlg from Salvatore
git-svn-id: trunk@9514 -
This commit is contained in:
parent
6a42932b68
commit
7e84661561
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1377,6 +1377,7 @@ ideintf/propedits.pp svneol=native#text/pascal
|
||||
ideintf/srceditorintf.pas svneol=native#text/pascal
|
||||
ideintf/stringgriddlg.lfm svneol=native#text/plain
|
||||
ideintf/stringgriddlg.lrs svneol=native#text/plain
|
||||
ideintf/stringgriddlg.pas svneol=native#text/plain
|
||||
ideintf/stringspropeditdlg.lfm svneol=native#text/plain
|
||||
ideintf/stringspropeditdlg.lrs svneol=native#text/plain
|
||||
ideintf/stringspropeditdlg.pas svneol=native#text/plain
|
||||
|
@ -50,6 +50,7 @@ uses
|
||||
PropEdits,
|
||||
SrcEditorIntf,
|
||||
StringsPropEditDlg,
|
||||
StringGridDlg,
|
||||
TextTools,
|
||||
TreeViewPropEdit;
|
||||
|
||||
|
@ -360,6 +360,8 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
uses StringGridDlg;
|
||||
|
||||
{ RegisterComponentEditor }
|
||||
type
|
||||
PComponentClassRec = ^TComponentClassRec;
|
||||
@ -794,36 +796,6 @@ begin
|
||||
Result:=TCustomPage(GetComponent);
|
||||
end;
|
||||
|
||||
{ TStringGridEditorDlg }
|
||||
|
||||
type
|
||||
TStringGridEditorDlg = class(TForm)
|
||||
BtnApply: TBitBtn;
|
||||
BtnCancel: TBitBtn;
|
||||
BtnHelp: TBitBtn;
|
||||
BtnOK: TBitBtn;
|
||||
BtnLoad: TButton;
|
||||
BtnSave: TButton;
|
||||
BtnClean: TButton;
|
||||
GroupBox: TGroupBox;
|
||||
OpenDialog: TOpenDialog;
|
||||
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);
|
||||
private
|
||||
FModified: Boolean;
|
||||
FStringGrid: TStringGrid;
|
||||
public
|
||||
property Modified: Boolean read FModified;
|
||||
procedure LoadFromGrid(AStringGrid: TStringGrid);
|
||||
procedure SaveToGrid;
|
||||
end;
|
||||
|
||||
function EditStringGrid(AStringGrid: TStringGrid): Boolean;
|
||||
var
|
||||
@ -842,104 +814,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
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(uoFull);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TStringGridEditorDlg }
|
||||
|
||||
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.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;
|
||||
|
||||
procedure TStringGridEditorDlg.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Caption := sccsSGEdtCaption;
|
||||
|
||||
GroupBox.Caption := sccsSGEdtGrp;
|
||||
BtnClean.Caption := sccsSGEdtClean;
|
||||
BtnApply.Caption := sccsSGEdtApply;
|
||||
BtnLoad.Caption := sccsSGEdtLoad;
|
||||
BtnSave.Caption := sccsSGEdtSave;
|
||||
|
||||
OpenDialog.Title := sccsSGEdtOpenDialog;
|
||||
SaveDialog.Title := sccsSGEdtSaveDialog;
|
||||
|
||||
StringGrid.ExtendedColSizing := True;
|
||||
end;
|
||||
|
||||
procedure TStringGridEditorDlg.BtnLoadClick(Sender: TObject);
|
||||
begin
|
||||
if OpenDialog.Execute then
|
||||
begin
|
||||
StringGrid.LoadFromFile(OpenDialog.FileName);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TStringGridEditorDlg.BtnCleanClick(Sender: TObject);
|
||||
begin
|
||||
StringGrid.Clean;
|
||||
end;
|
||||
|
||||
procedure TStringGridEditorDlg.BtnApplyClick(Sender: TObject);
|
||||
begin
|
||||
SaveToGrid;
|
||||
end;
|
||||
|
||||
procedure TStringGridEditorDlg.BtnSaveClick(Sender: TObject);
|
||||
begin
|
||||
if SaveDialog.Execute then
|
||||
begin
|
||||
StringGrid.SaveToFile(SaveDialog.FileName);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TStringGridComponentEditor }
|
||||
|
||||
procedure TStringGridComponentEditor.ExecuteVerb(Index: Integer);
|
||||
@ -1532,8 +1406,7 @@ end;
|
||||
initialization
|
||||
{$I checklistboxeditordlg.lrs}
|
||||
{$I checkgroupeditordlg.lrs}
|
||||
{$I stringgriddlg.lrs}
|
||||
|
||||
|
||||
RegisterComponentEditorProc:=@DefaultRegisterComponentEditorProc;
|
||||
RegisterComponentEditor(TCustomNotebook,TNotebookComponentEditor);
|
||||
RegisterComponentEditor(TCustomPage,TPageComponentEditor);
|
||||
|
@ -132,6 +132,7 @@ resourcestring
|
||||
sccsSGEdtSave = 'Save...';
|
||||
sccsSGEdtOpenDialog = 'Open';
|
||||
sccsSGEdtSaveDialog = 'Save';
|
||||
sccsSGEdtMoveRowsCols = 'Move Rows/Cols';
|
||||
|
||||
// component editors
|
||||
nbcesAddPage = 'Add page';
|
||||
|
@ -1,32 +1,142 @@
|
||||
object StringGridEditorDlg: TStringGridEditorDlg
|
||||
ActiveControl = StringGrid
|
||||
Caption = 'StringGridEditorDlg'
|
||||
ClientHeight = 296
|
||||
ClientWidth = 394
|
||||
Constraints.MinHeight = 250
|
||||
ClientHeight = 270
|
||||
ClientWidth = 520
|
||||
Constraints.MinHeight = 270
|
||||
Constraints.MinWidth = 340
|
||||
OnCreate = FormCreate
|
||||
PixelsPerInch = 96
|
||||
Position = poScreenCenter
|
||||
HorzScrollBar.Page = 393
|
||||
VertScrollBar.Page = 295
|
||||
Left = 340
|
||||
Height = 296
|
||||
Top = 251
|
||||
Width = 394
|
||||
HorzScrollBar.Page = 519
|
||||
VertScrollBar.Page = 269
|
||||
Left = 259
|
||||
Height = 270
|
||||
Top = 167
|
||||
Width = 520
|
||||
object GroupBox: TGroupBox
|
||||
Align = alTop
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
BorderSpacing.InnerBorder = 6
|
||||
Caption = 'String Grid'
|
||||
ClientHeight = 235
|
||||
ClientWidth = 378
|
||||
ClientHeight = 209
|
||||
ClientWidth = 504
|
||||
TabOrder = 0
|
||||
AnchorSideBottom.Control = BtnOK
|
||||
Left = 6
|
||||
Height = 253
|
||||
Height = 227
|
||||
Top = 6
|
||||
Width = 382
|
||||
Width = 508
|
||||
object LabelMove: TLabel
|
||||
Caption = 'Move Cols/Rows'
|
||||
Color = clNone
|
||||
ParentColor = False
|
||||
AnchorSideLeft.Control = ArrowDown
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = ArrowDown
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 414
|
||||
Height = 14
|
||||
Top = 181
|
||||
Width = 83
|
||||
end
|
||||
object ArrowLeft: TArrow
|
||||
Anchors = [akTop, akRight]
|
||||
OnClick = SwapRowCol
|
||||
AnchorSideLeft.Control = ArrowUp
|
||||
AnchorSideTop.Control = ArrowRight
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = ArrowUp
|
||||
Left = 416
|
||||
Height = 26
|
||||
Top = 129
|
||||
Width = 26
|
||||
end
|
||||
object ArrowRight: TArrow
|
||||
ArrowType = atRight
|
||||
OnClick = SwapRowCol
|
||||
AnchorSideLeft.Control = ArrowUp
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = ArrowUp
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 468
|
||||
Height = 26
|
||||
Top = 129
|
||||
Width = 26
|
||||
end
|
||||
object ArrowDown: TArrow
|
||||
ArrowType = atDown
|
||||
OnClick = SwapRowCol
|
||||
AnchorSideLeft.Control = ArrowLeft
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = ArrowLeft
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 442
|
||||
Height = 26
|
||||
Top = 155
|
||||
Width = 26
|
||||
end
|
||||
object ArrowUp: TArrow
|
||||
ArrowType = atUp
|
||||
BorderSpacing.Top = 10
|
||||
OnClick = SwapRowCol
|
||||
AnchorSideLeft.Control = BtnClean
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = BtnClean
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 442
|
||||
Height = 26
|
||||
Top = 103
|
||||
Width = 26
|
||||
end
|
||||
object BtnLoad: TButton
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Around = 6
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Load...'
|
||||
OnClick = BtnLoadClick
|
||||
TabOrder = 0
|
||||
AnchorSideLeft.Control = StringGrid
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = GroupBox
|
||||
AnchorSideRight.Control = GroupBox
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 413
|
||||
Height = 25
|
||||
Top = 6
|
||||
Width = 85
|
||||
end
|
||||
object BtnSave: TButton
|
||||
BorderSpacing.Around = 6
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'BtnSave'
|
||||
OnClick = BtnSaveClick
|
||||
TabOrder = 1
|
||||
AnchorSideLeft.Control = BtnLoad
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = BtnLoad
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 413
|
||||
Height = 25
|
||||
Top = 37
|
||||
Width = 85
|
||||
end
|
||||
object BtnClean: TButton
|
||||
BorderSpacing.Around = 6
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'BtnClean'
|
||||
OnClick = BtnCleanClick
|
||||
TabOrder = 2
|
||||
AnchorSideLeft.Control = BtnSave
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = BtnSave
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 413
|
||||
Height = 25
|
||||
Top = 68
|
||||
Width = 85
|
||||
end
|
||||
object StringGrid: TStringGrid
|
||||
Align = alLeft
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
@ -39,125 +149,94 @@ object StringGridEditorDlg: TStringGridEditorDlg
|
||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRowSizing, goColSizing, goRowMoving, goColMoving, goEditing, goSmoothScroll]
|
||||
RowCount = 5
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 0
|
||||
TabOrder = 3
|
||||
TabStop = True
|
||||
VisibleColCount = 5
|
||||
VisibleRowCount = 5
|
||||
OnPrepareCanvas = StringGridPrepareCanvas
|
||||
AnchorSideRight.Control = BtnLoad
|
||||
Left = 6
|
||||
Height = 223
|
||||
Height = 197
|
||||
Top = 6
|
||||
Width = 286
|
||||
Width = 401
|
||||
end
|
||||
object BtnLoad: TButton
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Around = 6
|
||||
|
||||
Caption = 'Load...'
|
||||
OnClick = BtnLoadClick
|
||||
TabOrder = 1
|
||||
Left = 298
|
||||
Height = 25
|
||||
Top = 6
|
||||
Width = 75
|
||||
end
|
||||
object BtnSave: TButton
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Around = 6
|
||||
|
||||
Caption = 'Save...'
|
||||
OnClick = BtnSaveClick
|
||||
TabOrder = 2
|
||||
Left = 298
|
||||
Height = 25
|
||||
Top = 37
|
||||
Width = 75
|
||||
end
|
||||
object BtnClean: TButton
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Around = 6
|
||||
|
||||
Caption = 'Clean'
|
||||
OnClick = BtnCleanClick
|
||||
TabOrder = 3
|
||||
Left = 298
|
||||
Height = 25
|
||||
Top = 68
|
||||
Width = 75
|
||||
end
|
||||
end
|
||||
object BtnHelp: TBitBtn
|
||||
Align = alRight
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
|
||||
Caption = '&Help'
|
||||
Kind = bkHelp
|
||||
NumGlyphs = 0
|
||||
TabOrder = 1
|
||||
Left = 313
|
||||
Height = 25
|
||||
Top = 265
|
||||
Width = 75
|
||||
end
|
||||
object BtnApply: TBitBtn
|
||||
Align = alRight
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
|
||||
Caption = '&Apply'
|
||||
NumGlyphs = 0
|
||||
OnClick = BtnApplyClick
|
||||
TabOrder = 2
|
||||
Left = 232
|
||||
Height = 25
|
||||
Top = 265
|
||||
Width = 75
|
||||
end
|
||||
object BtnCancel: TBitBtn
|
||||
Align = alRight
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
|
||||
Cancel = True
|
||||
Caption = 'Cancel'
|
||||
Kind = bkCancel
|
||||
ModalResult = 2
|
||||
NumGlyphs = 0
|
||||
TabOrder = 3
|
||||
Left = 151
|
||||
Height = 25
|
||||
Top = 265
|
||||
Width = 75
|
||||
end
|
||||
object BtnOK: TBitBtn
|
||||
Align = alRight
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
|
||||
Caption = '&OK'
|
||||
Default = True
|
||||
Kind = bkOK
|
||||
ModalResult = 1
|
||||
NumGlyphs = 0
|
||||
TabOrder = 4
|
||||
Left = 70
|
||||
TabOrder = 1
|
||||
AnchorSideRight.Control = BtnCancel
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 196
|
||||
Height = 25
|
||||
Top = 265
|
||||
Top = 239
|
||||
Width = 75
|
||||
end
|
||||
object BtnCancel: TBitBtn
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Cancel'
|
||||
Kind = bkCancel
|
||||
ModalResult = 2
|
||||
NumGlyphs = 0
|
||||
TabOrder = 2
|
||||
AnchorSideRight.Control = BtnApply
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 277
|
||||
Height = 25
|
||||
Top = 239
|
||||
Width = 75
|
||||
end
|
||||
object BtnApply: TBitBtn
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
Caption = '&Apply'
|
||||
NumGlyphs = 0
|
||||
OnClick = BtnApplyClick
|
||||
TabOrder = 3
|
||||
AnchorSideRight.Control = BtnHelp
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 358
|
||||
Height = 25
|
||||
Top = 239
|
||||
Width = 75
|
||||
end
|
||||
object BtnHelp: TBitBtn
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
Caption = '&Help'
|
||||
Kind = bkHelp
|
||||
NumGlyphs = 0
|
||||
TabOrder = 4
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 439
|
||||
Height = 25
|
||||
Top = 239
|
||||
Width = 75
|
||||
end
|
||||
object OpenDialog: TOpenDialog
|
||||
Title = 'Open'
|
||||
FilterIndex = 0
|
||||
Title = 'Open'
|
||||
left = 132
|
||||
top = 312
|
||||
left = 135
|
||||
top = 343
|
||||
end
|
||||
object SaveDialog: TSaveDialog
|
||||
Title = 'Save'
|
||||
FilterIndex = 0
|
||||
Title = 'Save'
|
||||
left = 132
|
||||
top = 348
|
||||
left = 168
|
||||
top = 343
|
||||
end
|
||||
end
|
||||
|
@ -1,47 +1,84 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TStringGridEditorDlg','FORMDATA',[
|
||||
'TPF0'#20'TStringGridEditorDlg'#19'StringGridEditorDlg'#13'ActiveControl'#7#10
|
||||
+'StringGrid'#7'Caption'#6#19'StringGridEditorDlg'#12'ClientHeight'#3'('#1#11
|
||||
+'ClientWidth'#3#138#1#21'Constraints.MinHeight'#3#250#0#20'Constraints.MinWi'
|
||||
+'dth'#3'T'#1#8'OnCreate'#7#10'FormCreate'#13'PixelsPerInch'#2'`'#8'Position'
|
||||
+#7#14'poScreenCenter'#18'HorzScrollBar.Page'#3#137#1#18'VertScrollBar.Page'#3
|
||||
+''''#1#4'Left'#3'T'#1#6'Height'#3'('#1#3'Top'#3#251#0#5'Width'#3#138#1#0#9'T'
|
||||
+'GroupBox'#8'GroupBox'#5'Align'#7#5'alTop'#7'Anchors'#11#5'akTop'#6'akLeft'#7
|
||||
+'akRight'#8'akBottom'#0#20'BorderSpacing.Around'#2#6#25'BorderSpacing.InnerB'
|
||||
+'order'#2#6#7'Caption'#6#11'String Grid'#12'ClientHeight'#3#235#0#11'ClientW'
|
||||
+'idth'#3'z'#1#8'TabOrder'#2#0#4'Left'#2#6#6'Height'#3#253#0#3'Top'#2#6#5'Wid'
|
||||
+'th'#3'~'#1#0#11'TStringGrid'#10'StringGrid'#5'Align'#7#6'alLeft'#7'Anchors'
|
||||
+#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#20'BorderSpacing.Around'#2#6
|
||||
+#8'ColCount'#2#5#10'FixedColor'#7#9'clBtnFace'#9'FixedCols'#2#0#9'FixedRows'
|
||||
+#2#0#13'GridLineWidth'#2#0#7'Options'#11#15'goFixedVertLine'#15'goFixedHorzL'
|
||||
+'ine'#10'goVertLine'#10'goHorzLine'#11'goRowSizing'#11'goColSizing'#11'goRow'
|
||||
+'Moving'#11'goColMoving'#9'goEditing'#14'goSmoothScroll'#0#8'RowCount'#2#5#10
|
||||
+'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#0#7'TabStop'#9#15'VisibleColCoun'
|
||||
+'t'#2#5#15'VisibleRowCount'#2#5#15'OnPrepareCanvas'#7#23'StringGridPrepareCa'
|
||||
+'nvas'#4'Left'#2#6#6'Height'#3#223#0#3'Top'#2#6#5'Width'#3#30#1#0#0#7'TButto'
|
||||
+'n'#7'BtnLoad'#7'Anchors'#11#5'akTop'#7'akRight'#0#20'BorderSpacing.Around'#2
|
||||
+#6#7'Caption'#6#7'Load...'#7'OnClick'#7#12'BtnLoadClick'#8'TabOrder'#2#1#4'L'
|
||||
+'eft'#3'*'#1#6'Height'#2#25#3'Top'#2#6#5'Width'#2'K'#0#0#7'TButton'#7'BtnSav'
|
||||
+'e'#7'Anchors'#11#5'akTop'#7'akRight'#0#20'BorderSpacing.Around'#2#6#7'Capti'
|
||||
+'on'#6#7'Save...'#7'OnClick'#7#12'BtnSaveClick'#8'TabOrder'#2#2#4'Left'#3'*'
|
||||
+#1#6'Height'#2#25#3'Top'#2'%'#5'Width'#2'K'#0#0#7'TButton'#8'BtnClean'#7'Anc'
|
||||
+'hors'#11#5'akTop'#7'akRight'#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#5
|
||||
+'Clean'#7'OnClick'#7#13'BtnCleanClick'#8'TabOrder'#2#3#4'Left'#3'*'#1#6'Heig'
|
||||
+'ht'#2#25#3'Top'#2'D'#5'Width'#2'K'#0#0#0#7'TBitBtn'#7'BtnHelp'#5'Align'#7#7
|
||||
+'alRight'#7'Anchors'#11#7'akRight'#8'akBottom'#0#20'BorderSpacing.Around'#2#6
|
||||
+#7'Caption'#6#5'&Help'#4'Kind'#7#6'bkHelp'#9'NumGlyphs'#2#0#8'TabOrder'#2#1#4
|
||||
+'Left'#3'9'#1#6'Height'#2#25#3'Top'#3#9#1#5'Width'#2'K'#0#0#7'TBitBtn'#8'Btn'
|
||||
+'Apply'#5'Align'#7#7'alRight'#7'Anchors'#11#7'akRight'#8'akBottom'#0#20'Bord'
|
||||
+'erSpacing.Around'#2#6#7'Caption'#6#6'&Apply'#9'NumGlyphs'#2#0#7'OnClick'#7
|
||||
+#13'BtnApplyClick'#8'TabOrder'#2#2#4'Left'#3#232#0#6'Height'#2#25#3'Top'#3#9
|
||||
+#1#5'Width'#2'K'#0#0#7'TBitBtn'#9'BtnCancel'#5'Align'#7#7'alRight'#7'Anchors'
|
||||
+#11#7'akRight'#8'akBottom'#0#20'BorderSpacing.Around'#2#6#6'Cancel'#9#7'Capt'
|
||||
+'ion'#6#6'Cancel'#4'Kind'#7#8'bkCancel'#11'ModalResult'#2#2#9'NumGlyphs'#2#0
|
||||
+#8'TabOrder'#2#3#4'Left'#3#151#0#6'Height'#2#25#3'Top'#3#9#1#5'Width'#2'K'#0
|
||||
+#0#7'TBitBtn'#5'BtnOK'#5'Align'#7#7'alRight'#7'Anchors'#11#7'akRight'#8'akBo'
|
||||
+'ttom'#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#3'&OK'#7'Default'#9#4'Kin'
|
||||
+'d'#7#4'bkOK'#11'ModalResult'#2#1#9'NumGlyphs'#2#0#8'TabOrder'#2#4#4'Left'#2
|
||||
+'F'#6'Height'#2#25#3'Top'#3#9#1#5'Width'#2'K'#0#0#11'TOpenDialog'#10'OpenDia'
|
||||
+'log'#5'Title'#6#4'Open'#11'FilterIndex'#2#0#5'Title'#6#4'Open'#4'left'#3#132
|
||||
+#0#3'top'#3'8'#1#0#0#11'TSaveDialog'#10'SaveDialog'#5'Title'#6#4'Save'#11'Fi'
|
||||
+'lterIndex'#2#0#5'Title'#6#4'Save'#4'left'#3#132#0#3'top'#3'\'#1#0#0#0
|
||||
+'StringGrid'#7'Caption'#6#19'StringGridEditorDlg'#12'ClientHeight'#3#14#1#11
|
||||
+'ClientWidth'#3#8#2#21'Constraints.MinHeight'#3#14#1#20'Constraints.MinWidth'
|
||||
+#3'T'#1#8'OnCreate'#7#10'FormCreate'#13'PixelsPerInch'#2'`'#8'Position'#7#14
|
||||
+'poScreenCenter'#18'HorzScrollBar.Page'#3#7#2#18'VertScrollBar.Page'#3#13#1#4
|
||||
+'Left'#3#3#1#6'Height'#3#14#1#3'Top'#3#167#0#5'Width'#3#8#2#0#9'TGroupBox'#8
|
||||
+'GroupBox'#5'Align'#7#5'alTop'#7'Anchors'#11#7'akRight'#8'akBottom'#0#20'Bor'
|
||||
+'derSpacing.Around'#2#6#25'BorderSpacing.InnerBorder'#2#6#7'Caption'#6#11'St'
|
||||
+'ring Grid'#12'ClientHeight'#3#209#0#11'ClientWidth'#3#248#1#8'TabOrder'#2#0
|
||||
+#24'AnchorSideBottom.Control'#7#5'BtnOK'#4'Left'#2#6#6'Height'#3#227#0#3'Top'
|
||||
+#2#6#5'Width'#3#252#1#0#6'TLabel'#9'LabelMove'#7'Caption'#6#14'Move Cols/Row'
|
||||
+'s'#5'Color'#7#6'clNone'#11'ParentColor'#8#22'AnchorSideLeft.Control'#7#9'Ar'
|
||||
+'rowDown'#19'AnchorSideLeft.Side'#7#9'asrCenter'#21'AnchorSideTop.Control'#7
|
||||
+#9'ArrowDown'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#3#158#1#6'Height'
|
||||
+#2#14#3'Top'#3#181#0#5'Width'#2'S'#0#0#6'TArrow'#9'ArrowLeft'#7'Anchors'#11#5
|
||||
+'akTop'#7'akRight'#0#7'OnClick'#7#10'SwapRowCol'#22'AnchorSideLeft.Control'#7
|
||||
+#7'ArrowUp'#21'AnchorSideTop.Control'#7#10'ArrowRight'#18'AnchorSideTop.Side'
|
||||
+#7#9'asrCenter'#23'AnchorSideRight.Control'#7#7'ArrowUp'#4'Left'#3#160#1#6'H'
|
||||
+'eight'#2#26#3'Top'#3#129#0#5'Width'#2#26#0#0#6'TArrow'#10'ArrowRight'#9'Arr'
|
||||
+'owType'#7#7'atRight'#7'OnClick'#7#10'SwapRowCol'#22'AnchorSideLeft.Control'
|
||||
+#7#7'ArrowUp'#19'AnchorSideLeft.Side'#7#9'asrBottom'#21'AnchorSideTop.Contro'
|
||||
+'l'#7#7'ArrowUp'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#3#212#1#6'Hei'
|
||||
+'ght'#2#26#3'Top'#3#129#0#5'Width'#2#26#0#0#6'TArrow'#9'ArrowDown'#9'ArrowTy'
|
||||
+'pe'#7#6'atDown'#7'OnClick'#7#10'SwapRowCol'#22'AnchorSideLeft.Control'#7#9
|
||||
+'ArrowLeft'#19'AnchorSideLeft.Side'#7#9'asrBottom'#21'AnchorSideTop.Control'
|
||||
+#7#9'ArrowLeft'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#3#186#1#6'Heig'
|
||||
+'ht'#2#26#3'Top'#3#155#0#5'Width'#2#26#0#0#6'TArrow'#7'ArrowUp'#9'ArrowType'
|
||||
+#7#4'atUp'#17'BorderSpacing.Top'#2#10#7'OnClick'#7#10'SwapRowCol'#22'AnchorS'
|
||||
+'ideLeft.Control'#7#8'BtnClean'#19'AnchorSideLeft.Side'#7#9'asrCenter'#21'An'
|
||||
+'chorSideTop.Control'#7#8'BtnClean'#18'AnchorSideTop.Side'#7#9'asrBottom'#4
|
||||
+'Left'#3#186#1#6'Height'#2#26#3'Top'#2'g'#5'Width'#2#26#0#0#7'TButton'#7'Btn'
|
||||
+'Load'#7'Anchors'#11#5'akTop'#7'akRight'#0#20'BorderSpacing.Around'#2#6#25'B'
|
||||
+'orderSpacing.InnerBorder'#2#4#7'Caption'#6#7'Load...'#7'OnClick'#7#12'BtnLo'
|
||||
+'adClick'#8'TabOrder'#2#0#22'AnchorSideLeft.Control'#7#10'StringGrid'#19'Anc'
|
||||
+'horSideLeft.Side'#7#9'asrBottom'#21'AnchorSideTop.Control'#7#8'GroupBox'#23
|
||||
+'AnchorSideRight.Control'#7#8'GroupBox'#20'AnchorSideRight.Side'#7#9'asrBott'
|
||||
+'om'#4'Left'#3#157#1#6'Height'#2#25#3'Top'#2#6#5'Width'#2'U'#0#0#7'TButton'#7
|
||||
+'BtnSave'#20'BorderSpacing.Around'#2#6#25'BorderSpacing.InnerBorder'#2#4#7'C'
|
||||
+'aption'#6#7'BtnSave'#7'OnClick'#7#12'BtnSaveClick'#8'TabOrder'#2#1#22'Ancho'
|
||||
+'rSideLeft.Control'#7#7'BtnLoad'#19'AnchorSideLeft.Side'#7#9'asrCenter'#21'A'
|
||||
+'nchorSideTop.Control'#7#7'BtnLoad'#18'AnchorSideTop.Side'#7#9'asrBottom'#4
|
||||
+'Left'#3#157#1#6'Height'#2#25#3'Top'#2'%'#5'Width'#2'U'#0#0#7'TButton'#8'Btn'
|
||||
+'Clean'#20'BorderSpacing.Around'#2#6#25'BorderSpacing.InnerBorder'#2#4#7'Cap'
|
||||
+'tion'#6#8'BtnClean'#7'OnClick'#7#13'BtnCleanClick'#8'TabOrder'#2#2#22'Ancho'
|
||||
+'rSideLeft.Control'#7#7'BtnSave'#19'AnchorSideLeft.Side'#7#9'asrCenter'#21'A'
|
||||
+'nchorSideTop.Control'#7#7'BtnSave'#18'AnchorSideTop.Side'#7#9'asrBottom'#4
|
||||
+'Left'#3#157#1#6'Height'#2#25#3'Top'#2'D'#5'Width'#2'U'#0#0#11'TStringGrid'
|
||||
+#10'StringGrid'#5'Align'#7#6'alLeft'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRi'
|
||||
+'ght'#8'akBottom'#0#20'BorderSpacing.Around'#2#6#8'ColCount'#2#5#10'FixedCol'
|
||||
+'or'#7#9'clBtnFace'#9'FixedCols'#2#0#9'FixedRows'#2#0#13'GridLineWidth'#2#0#7
|
||||
+'Options'#11#15'goFixedVertLine'#15'goFixedHorzLine'#10'goVertLine'#10'goHor'
|
||||
+'zLine'#11'goRowSizing'#11'goColSizing'#11'goRowMoving'#11'goColMoving'#9'go'
|
||||
+'Editing'#14'goSmoothScroll'#0#8'RowCount'#2#5#10'ScrollBars'#7#10'ssAutoBot'
|
||||
+'h'#8'TabOrder'#2#3#7'TabStop'#9#15'VisibleColCount'#2#5#15'VisibleRowCount'
|
||||
+#2#5#15'OnPrepareCanvas'#7#23'StringGridPrepareCanvas'#23'AnchorSideRight.Co'
|
||||
+'ntrol'#7#7'BtnLoad'#4'Left'#2#6#6'Height'#3#197#0#3'Top'#2#6#5'Width'#3#145
|
||||
+#1#0#0#0#7'TBitBtn'#5'BtnOK'#7'Anchors'#11#7'akRight'#8'akBottom'#0#20'Borde'
|
||||
+'rSpacing.Around'#2#6#7'Caption'#6#3'&OK'#7'Default'#9#4'Kind'#7#4'bkOK'#11
|
||||
+'ModalResult'#2#1#9'NumGlyphs'#2#0#8'TabOrder'#2#1#23'AnchorSideRight.Contro'
|
||||
+'l'#7#9'BtnCancel'#24'AnchorSideBottom.Control'#7#5'Owner'#21'AnchorSideBott'
|
||||
+'om.Side'#7#9'asrBottom'#4'Left'#3#196#0#6'Height'#2#25#3'Top'#3#239#0#5'Wid'
|
||||
+'th'#2'K'#0#0#7'TBitBtn'#9'BtnCancel'#7'Anchors'#11#7'akRight'#8'akBottom'#0
|
||||
+#20'BorderSpacing.Around'#2#6#7'Caption'#6#6'Cancel'#4'Kind'#7#8'bkCancel'#11
|
||||
+'ModalResult'#2#2#9'NumGlyphs'#2#0#8'TabOrder'#2#2#23'AnchorSideRight.Contro'
|
||||
,'l'#7#8'BtnApply'#24'AnchorSideBottom.Control'#7#5'Owner'#21'AnchorSideBotto'
|
||||
+'m.Side'#7#9'asrBottom'#4'Left'#3#21#1#6'Height'#2#25#3'Top'#3#239#0#5'Width'
|
||||
+#2'K'#0#0#7'TBitBtn'#8'BtnApply'#7'Anchors'#11#7'akRight'#8'akBottom'#0#20'B'
|
||||
+'orderSpacing.Around'#2#6#7'Caption'#6#6'&Apply'#9'NumGlyphs'#2#0#7'OnClick'
|
||||
+#7#13'BtnApplyClick'#8'TabOrder'#2#3#23'AnchorSideRight.Control'#7#7'BtnHelp'
|
||||
+#24'AnchorSideBottom.Control'#7#5'Owner'#21'AnchorSideBottom.Side'#7#9'asrBo'
|
||||
+'ttom'#4'Left'#3'f'#1#6'Height'#2#25#3'Top'#3#239#0#5'Width'#2'K'#0#0#7'TBit'
|
||||
+'Btn'#7'BtnHelp'#7'Anchors'#11#7'akRight'#8'akBottom'#0#20'BorderSpacing.Aro'
|
||||
+'und'#2#6#7'Caption'#6#5'&Help'#4'Kind'#7#6'bkHelp'#9'NumGlyphs'#2#0#8'TabOr'
|
||||
+'der'#2#4#23'AnchorSideRight.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9
|
||||
+'asrBottom'#24'AnchorSideBottom.Control'#7#5'Owner'#21'AnchorSideBottom.Side'
|
||||
+#7#9'asrBottom'#4'Left'#3#183#1#6'Height'#2#25#3'Top'#3#239#0#5'Width'#2'K'#0
|
||||
+#0#11'TOpenDialog'#10'OpenDialog'#5'Title'#6#4'Open'#11'FilterIndex'#2#0#5'T'
|
||||
+'itle'#6#4'Open'#4'left'#3#135#0#3'top'#3'W'#1#0#0#11'TSaveDialog'#10'SaveDi'
|
||||
+'alog'#5'Title'#6#4'Save'#11'FilterIndex'#2#0#5'Title'#6#4'Save'#4'left'#3
|
||||
+#168#0#3'top'#3'W'#1#0#0#0
|
||||
]);
|
||||
|
205
ideintf/stringgriddlg.pas
Normal file
205
ideintf/stringgriddlg.pas
Normal file
@ -0,0 +1,205 @@
|
||||
{
|
||||
*****************************************************************************
|
||||
* *
|
||||
* See the file COPYING.modifiedLGPL, 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 StringGridDlg;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
Arrow, StdCtrls, Buttons, Grids;
|
||||
|
||||
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;
|
||||
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
|
||||
|
||||
uses ObjInspStrConsts;
|
||||
|
||||
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(uoFull);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
initialization
|
||||
{$I stringgriddlg.lrs}
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user