From f7eabc067996402155f0317a818ee8efadaaee3a Mon Sep 17 00:00:00 2001 From: juha Date: Tue, 8 Jun 2010 21:46:29 +0000 Subject: [PATCH] Converter: Improve StringGrid's popup menu behavior. Make grid's name shorter. git-svn-id: trunk@25997 - --- converter/convertsettings.pas | 4 ++-- converter/replacenamesunit.lfm | 11 ++++++----- converter/replacenamesunit.pas | 25 ++++++++++++++++++------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/converter/convertsettings.pas b/converter/convertsettings.pas index 3cd1e8ca8d..dd1dfb0fbc 100644 --- a/converter/convertsettings.pas +++ b/converter/convertsettings.pas @@ -423,7 +423,7 @@ var GridUpdater: TGridUpdater; begin RNForm:=TReplaceNamesForm.Create(nil); - GridUpdater:=TGridUpdater.Create(fSettings.ReplaceUnits, RNForm.NamePairGrid); + GridUpdater:=TGridUpdater.Create(fSettings.ReplaceUnits, RNForm.Grid); try RNForm.Caption:=lisConvUnitsToReplace; GridUpdater.MapToGrid; @@ -441,7 +441,7 @@ var GridUpdater: TGridUpdater; begin RNForm:=TReplaceNamesForm.Create(nil); - GridUpdater:=TGridUpdater.Create(fSettings.ReplaceTypes, RNForm.NamePairGrid); + GridUpdater:=TGridUpdater.Create(fSettings.ReplaceTypes, RNForm.Grid); try RNForm.Caption:=lisConvTypesToReplace; GridUpdater.MapToGrid; diff --git a/converter/replacenamesunit.lfm b/converter/replacenamesunit.lfm index 582243fb9e..4d0993ff78 100644 --- a/converter/replacenamesunit.lfm +++ b/converter/replacenamesunit.lfm @@ -3,14 +3,14 @@ object ReplaceNamesForm: TReplaceNamesForm Height = 472 Top = 438 Width = 343 - ActiveControl = NamePairGrid + ActiveControl = Grid Caption = 'Properties and Types to replace' ClientHeight = 472 ClientWidth = 343 OnCreate = FormCreate Position = poScreenCenter LCLVersion = '0.9.29' - object NamePairGrid: TStringGrid + object Grid: TStringGrid Left = 0 Height = 434 Top = 0 @@ -28,12 +28,12 @@ object ReplaceNamesForm: TReplaceNamesForm Width = 170 end> FixedCols = 0 - Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll] + Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goDrawFocusSelected, goEditing, goSmoothScroll] PopupMenu = PopupMenu1 RowCount = 2 TabOrder = 0 - OnEditingDone = NamePairGridEditingDone - OnSetEditText = NamePairGridSetEditText + OnEditingDone = GridEditingDone + OnSetEditText = GridSetEditText ColWidths = ( 169 170 @@ -103,6 +103,7 @@ object ReplaceNamesForm: TReplaceNamesForm end end object PopupMenu1: TPopupMenu + OnPopup = PopupMenu1Popup left = 131 top = 91 object InsertRow1: TMenuItem diff --git a/converter/replacenamesunit.pas b/converter/replacenamesunit.pas index d26ff13407..d3fd4ff376 100644 --- a/converter/replacenamesunit.pas +++ b/converter/replacenamesunit.pas @@ -47,15 +47,16 @@ type HelpButton: TBitBtn; InsertRow1: TMenuItem; DeleteRow1: TMenuItem; - NamePairGrid: TStringGrid; + Grid: TStringGrid; PopupMenu1: TPopupMenu; procedure FormCreate(Sender: TObject); procedure InsertRow1Click(Sender: TObject); procedure DeleteRow1Click(Sender: TObject); - procedure NamePairGridEditingDone(Sender: TObject); - procedure NamePairGridSetEditText(Sender: TObject; ACol, ARow: Integer; + procedure GridEditingDone(Sender: TObject); + procedure GridSetEditText(Sender: TObject; ACol, ARow: Integer; const Value: string); procedure btnOKClick(Sender: TObject); + procedure PopupMenu1Popup(Sender: TObject); private IsLasRow: Boolean; public @@ -203,19 +204,29 @@ begin IsLasRow:=false; end; +procedure TReplaceNamesForm.PopupMenu1Popup(Sender: TObject); +var + ControlCoord, NewCell: TPoint; +begin + ControlCoord := Grid.ScreenToControl(PopupMenu1.PopupPoint); + NewCell:=Grid.MouseToCell(ControlCoord); + Grid.Col:=NewCell.X; + Grid.Row:=NewCell.Y; +end; + procedure TReplaceNamesForm.InsertRow1Click(Sender: TObject); begin - NamePairGrid.InsertColRow(False, NamePairGrid.Row); + Grid.InsertColRow(False, Grid.Row); end; procedure TReplaceNamesForm.DeleteRow1Click(Sender: TObject); begin - NamePairGrid.DeleteColRow(False, NamePairGrid.Row); + Grid.DeleteColRow(False, Grid.Row); end; // Add rows automatically to the end of the grid // using OnSetEditText and OnEditingDone handlers and IsLasRow flag. -procedure TReplaceNamesForm.NamePairGridEditingDone(Sender: TObject); +procedure TReplaceNamesForm.GridEditingDone(Sender: TObject); var sg: TStringGrid; begin @@ -226,7 +237,7 @@ begin end; end; -procedure TReplaceNamesForm.NamePairGridSetEditText(Sender: TObject; ACol, +procedure TReplaceNamesForm.GridSetEditText(Sender: TObject; ACol, ARow: Integer; const Value: string); begin if ARow = (Sender as TStringGrid).RowCount-1 then