cody: ppu list: jump to unit

git-svn-id: trunk@29516 -
This commit is contained in:
mattias 2011-02-13 12:20:30 +00:00
parent bba3e2b3fc
commit 63f43459ae
2 changed files with 48 additions and 5 deletions

View File

@ -114,9 +114,9 @@ object PPUListDialog: TPPUListDialog
Height = 167
Top = 0
Width = 720
ActivePage = UsesPathTabSheet
ActivePage = UsesTabSheet
Align = alClient
TabIndex = 3
TabIndex = 1
TabOrder = 0
object InfoTabSheet: TTabSheet
Caption = 'InfoTabSheet'
@ -162,6 +162,7 @@ object PPUListDialog: TPPUListDialog
FixedCols = 0
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
TabOrder = 0
OnMouseDown = UnitStringGridMouseDown
ColWidths = (
714
)
@ -187,6 +188,7 @@ object PPUListDialog: TPPUListDialog
FixedCols = 0
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
TabOrder = 0
OnMouseDown = UnitStringGridMouseDown
ColWidths = (
714
)
@ -204,9 +206,14 @@ object PPUListDialog: TPPUListDialog
Align = alClient
AutoFillColumns = True
ColCount = 1
Columns = <
item
Title.Caption = 'Unit'
Width = 714
end>
FixedCols = 0
FixedRows = 0
TabOrder = 0
OnMouseDown = UnitStringGridMouseDown
ColWidths = (
714
)

View File

@ -101,6 +101,8 @@ type
Shift: TShiftState; X, Y: Integer);
procedure UnitsStringGridSelectCell(Sender: TObject; {%H-}aCol, aRow: Integer;
var {%H-}CanSelect: Boolean);
procedure UnitStringGridMouseDown(Sender: TObject;
{%H-}Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
private
FMainItem: TPPUListItem;
FProject: TLazProject;
@ -124,6 +126,7 @@ type
// grid
procedure UpdateUnitsGrid;
function CompareUnits({%H-}Tree: TAvgLvlTree; Data1, Data2: Pointer): integer;
procedure JumpToUnit(TheUnitName: string);
// units info
procedure FillUnitsInfo(AnUnitName: string);
@ -296,6 +299,27 @@ begin
FillUnitsInfo(AnUnitName);
end;
procedure TPPUListDialog.UnitStringGridMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
Grid: TStringGrid;
Col: Longint;
Row: Longint;
AnUnitName: string;
begin
Grid:=TStringGrid(Sender);
if Shift=[ssLeft,ssDouble] then begin
Col:=0;
Row:=0;
Grid.MouseToCell(X,Y,Col,Row);
if (Row<1) or (Row>=Grid.RowCount) then exit;
if (Col=0) then begin
AnUnitName:=Grid.Cells[0,Row];
JumpToUnit(AnUnitName);
end;
end;
end;
procedure TPPUListDialog.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
@ -560,6 +584,18 @@ begin
end;
end;
procedure TPPUListDialog.JumpToUnit(TheUnitName: string);
var
i: Integer;
begin
for i:=2 to UnitsStringGrid.RowCount-1 do begin
if SysUtils.CompareText(UnitsStringGrid.Cells[0,i],TheUnitName)<>0 then
continue;
UnitsStringGrid.Row:=i;
exit;
end;
end;
procedure TPPUListDialog.FillUnitsInfo(AnUnitName: string);
var
Item: TPPUListItem;
@ -601,9 +637,9 @@ begin
// uses path
UsesPath:=FindUsesPath(MainItem,Item);
try
UsesPathStringGrid.RowCount:=UsesPath.Count;
UsesPathStringGrid.RowCount:=UsesPath.Count+1;
for i:=0 to UsesPath.Count-1 do begin
UsesPathStringGrid.Cells[0,i]:=TPPUListItem(UsesPath[i]).TheUnitName;
UsesPathStringGrid.Cells[0,i+1]:=TPPUListItem(UsesPath[i]).TheUnitName;
end;
finally
UsesPath.Free;