IDE: mode matrix: new target

git-svn-id: trunk@40944 -
This commit is contained in:
mattias 2013-04-29 23:06:59 +00:00
parent 3ca47329ed
commit b5991e8bb6
2 changed files with 37 additions and 2 deletions

View File

@ -99,8 +99,37 @@ begin
end;
procedure TFrame1.BMMNewTargetToolButtonClick(Sender: TObject);
var
aRow: Integer;
MatRow: TGroupedMatrixRow;
Group: TGroupedMatrixGroup;
begin
aRow:=Grid.Row;
if aRow<Grid.FixedRows then aRow:=Grid.FixedRows;
Grid.MatrixChanging;
try
Grid.StoreUndo;
MatRow:=Grid.Matrix[aRow-1];
if MatRow is TGroupedMatrixGroup then
Group:=TGroupedMatrixGroup(MatRow)
else
Group:=MatRow.Group;
if Group.Group=nil then begin
// Group is a storage group
// => add as first target of storage group
Grid.Matrix.AddGroup(Group,'Target: *');
Group.Move(Group.Count-1,0);
end else begin
// Group is a target
// => add target behind current target
Grid.Matrix.AddGroup(Group.Group,'Target: *');
Group.Group.Move(Group.Group.Count-1,Group.GetGroupIndex+1);
end;
Grid.Matrix.RebuildRows;
finally
Grid.MatrixChanged;
end;
UpdateButtons;
end;
procedure TFrame1.BMMMoveDownToolButtonClick(Sender: TObject);

View File

@ -67,6 +67,7 @@ type
property Count: integer read GetCount;
property Items[Index: integer]: TGroupedMatrixRow read GetItems; default;
function IndexOfRow(aRow: TGroupedMatrixRow): integer;
procedure Move(CurIndex, NewIndex: integer);
function GetNext: TGroupedMatrixRow; override;
function GetLastLeaf: TGroupedMatrixRow; override;
property Color: TColor read FColor write SetColor;
@ -141,13 +142,13 @@ type
function GetTopLvlCount: integer;
function GetTopLvlItems(Index: integer): TGroupedMatrixRow;
procedure InternalAdd(Group: TGroupedMatrixGroup; Row: TGroupedMatrixRow);
procedure RebuildRows;
public
procedure Assign(Source: TPersistent); override;
constructor Create(aControl: TGroupedMatrixControl);
destructor Destroy; override;
procedure Clear;
function Equals(Obj: TObject): boolean; override;
procedure RebuildRows;
property RowCount: integer read GetRowCount;
property Rows[Index: integer]: TGroupedMatrixRow read GetRows; default;
procedure DeleteRow(Index: integer);
@ -731,6 +732,11 @@ begin
Result:=-1;
end;
procedure TGroupedMatrixGroup.Move(CurIndex, NewIndex: integer);
begin
FItems.Move(CurIndex,NewIndex);
end;
function TGroupedMatrixGroup.GetNext: TGroupedMatrixRow;
begin
if Count>0 then