Converter: Improve StringGrid's popup menu behavior. Make grid's name shorter.

git-svn-id: trunk@25997 -
This commit is contained in:
juha 2010-06-08 21:46:29 +00:00
parent 919e928e2c
commit f7eabc0679
3 changed files with 26 additions and 14 deletions

View File

@ -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;

View File

@ -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

View File

@ -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