mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 17:09:21 +02:00
IDE: mode matrix: started target editing
git-svn-id: trunk@40951 -
This commit is contained in:
parent
270b5eb2c5
commit
275c4838b6
@ -29,34 +29,55 @@ object Frame1: TFrame1
|
||||
OnClick = BMMMoveDownToolButtonClick
|
||||
end
|
||||
object BMMUndoToolButton: TToolButton
|
||||
Left = 70
|
||||
Left = 80
|
||||
Top = 2
|
||||
Caption = 'Undo'
|
||||
OnClick = BMMUndoToolButtonClick
|
||||
end
|
||||
object BMMRedoToolButton: TToolButton
|
||||
Left = 111
|
||||
Left = 121
|
||||
Top = 2
|
||||
Caption = 'Redo'
|
||||
OnClick = BMMRedoToolButtonClick
|
||||
end
|
||||
object BMMNewTargetToolButton: TToolButton
|
||||
Left = 151
|
||||
Left = 171
|
||||
Top = 2
|
||||
Caption = 'New Target'
|
||||
OnClick = BMMNewTargetToolButtonClick
|
||||
end
|
||||
object BMMNewOptionToolButton: TToolButton
|
||||
Left = 231
|
||||
Left = 251
|
||||
Top = 2
|
||||
Caption = 'New Option'
|
||||
OnClick = BMMNewOptionToolButtonClick
|
||||
end
|
||||
object BMMDeleteToolButton: TToolButton
|
||||
Left = 313
|
||||
Left = 343
|
||||
Top = 2
|
||||
Caption = 'Delete'
|
||||
OnClick = BMMDeleteToolButtonClick
|
||||
end
|
||||
object ToolButton1: TToolButton
|
||||
Left = 70
|
||||
Top = 2
|
||||
Width = 10
|
||||
Caption = 'ToolButton1'
|
||||
Style = tbsSeparator
|
||||
end
|
||||
object ToolButton2: TToolButton
|
||||
Left = 161
|
||||
Top = 2
|
||||
Width = 10
|
||||
Caption = 'ToolButton2'
|
||||
Style = tbsSeparator
|
||||
end
|
||||
object ToolButton3: TToolButton
|
||||
Left = 333
|
||||
Top = 2
|
||||
Width = 10
|
||||
Caption = 'ToolButton3'
|
||||
Style = tbsSeparator
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -42,6 +42,9 @@ type
|
||||
BMMNewTargetToolButton: TToolButton;
|
||||
BMMNewOptionToolButton: TToolButton;
|
||||
BMMDeleteToolButton: TToolButton;
|
||||
ToolButton1: TToolButton;
|
||||
ToolButton2: TToolButton;
|
||||
ToolButton3: TToolButton;
|
||||
procedure BMMDeleteToolButtonClick(Sender: TObject);
|
||||
procedure BMMMoveDownToolButtonClick(Sender: TObject);
|
||||
procedure BMMMoveUpToolButtonClick(Sender: TObject);
|
||||
@ -55,6 +58,7 @@ type
|
||||
FGrid: TGroupedMatrixControl;
|
||||
procedure MoveRow(Direction: integer);
|
||||
procedure UpdateButtons;
|
||||
function AddTarget(StorageGroup: TGroupedMatrixGroup): TGroupedMatrixGroup;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
property Grid: TGroupedMatrixControl read FGrid;
|
||||
@ -119,7 +123,7 @@ begin
|
||||
if Group.Group=nil then begin
|
||||
if Group.Count=0 then begin
|
||||
// storage group without target => add a target
|
||||
Group:=Grid.Matrix.AddGroup(Group,'Target: *');
|
||||
Group:=AddTarget(Group);
|
||||
end;
|
||||
end;
|
||||
// add option as first item of Group
|
||||
@ -160,12 +164,12 @@ begin
|
||||
if Group.Group=nil then begin
|
||||
// Group is a storage group
|
||||
// => add as first target of storage group
|
||||
NewRow:=Grid.Matrix.AddGroup(Group,'Target: *');
|
||||
NewRow:=AddTarget(Group);
|
||||
Group.Move(Group.Count-1,0);
|
||||
end else begin
|
||||
// Group is a target
|
||||
// => add target behind current target
|
||||
NewRow:=Grid.Matrix.AddGroup(Group.Group,'Target: *');
|
||||
NewRow:=AddTarget(Group.Group);
|
||||
Group.Group.Move(Group.Group.Count-1,Group.GetGroupIndex+1);
|
||||
end;
|
||||
Grid.Matrix.RebuildRows;
|
||||
@ -222,6 +226,14 @@ begin
|
||||
and (MatRow.GetNextSkipChildren<>nil);
|
||||
end;
|
||||
|
||||
function TFrame1.AddTarget(StorageGroup: TGroupedMatrixGroup
|
||||
): TGroupedMatrixGroup;
|
||||
begin
|
||||
Result:=Grid.Matrix.AddGroup(StorageGroup,'Targets: ');
|
||||
Result.Value:='*';
|
||||
Result.Writable:=true;
|
||||
end;
|
||||
|
||||
procedure TFrame1.MoveRow(Direction: integer);
|
||||
var
|
||||
MatRow: TGroupedMatrixRow;
|
||||
@ -264,7 +276,7 @@ begin
|
||||
TargetGroup:=TargetStorage[TargetStorage.Count-1] as TGroupedMatrixGroup;
|
||||
end else begin
|
||||
// add first target
|
||||
TargetGroup:=Grid.Matrix.AddGroup(TargetStorage,'target: *');
|
||||
TargetGroup:=AddTarget(TargetStorage);
|
||||
end;
|
||||
end else begin
|
||||
// this is already the first target of the first storage
|
||||
@ -300,7 +312,7 @@ begin
|
||||
TargetGroup:=TargetStorage[0] as TGroupedMatrixGroup;
|
||||
end else begin
|
||||
// add first target
|
||||
TargetGroup:=Grid.Matrix.AddGroup(TargetStorage,'target: *');
|
||||
TargetGroup:=AddTarget(TargetStorage);
|
||||
end;
|
||||
end else begin
|
||||
// this is already the last target of the last storage
|
||||
|
@ -53,24 +53,26 @@ type
|
||||
FCaption: TCaption;
|
||||
FColor: TColor;
|
||||
FItems: TFPList; // list of TGroupedMatrixRow
|
||||
FValue: string;
|
||||
FWritable: boolean;
|
||||
function GetCount: integer;
|
||||
function GetItems(Index: integer): TGroupedMatrixRow;
|
||||
procedure SetCaption(AValue: TCaption);
|
||||
procedure SetColor(AValue: TColor);
|
||||
public
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
constructor Create(aControl: TGroupedMatrix); override;
|
||||
destructor Destroy; override;
|
||||
procedure Clear; override;
|
||||
function Equals(Obj: TObject): boolean; override;
|
||||
property Caption: TCaption read FCaption write SetCaption;
|
||||
property Caption: TCaption read FCaption write FCaption;
|
||||
property Value: string read FValue write FValue;
|
||||
property Writable: boolean read FWritable write FWritable;
|
||||
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;
|
||||
property Color: TColor read FColor write FColor;
|
||||
function GetEffectiveColor: TColor;
|
||||
function AsString: string; override;
|
||||
end;
|
||||
@ -160,7 +162,7 @@ type
|
||||
function GetTopLvlGroup(aCaption: TCaption): TGroupedMatrixGroup;
|
||||
function GetMaxLevel: integer;
|
||||
function AddGroup(ParentGroup: TGroupedMatrixGroup;
|
||||
aCaption: TCaption): TGroupedMatrixGroup;
|
||||
aCaption: TCaption; aValue: string = ''): TGroupedMatrixGroup;
|
||||
function AddValue(ParentGroup: TGroupedMatrixGroup;
|
||||
ModesAsText, aType, AValue: string): TGroupedMatrixValue;
|
||||
property Modes: TGroupedMatrixModes read FModes;
|
||||
@ -523,10 +525,12 @@ begin
|
||||
end;
|
||||
|
||||
function TGroupedMatrix.AddGroup(ParentGroup: TGroupedMatrixGroup;
|
||||
aCaption: TCaption): TGroupedMatrixGroup;
|
||||
aCaption: TCaption; aValue: string): TGroupedMatrixGroup;
|
||||
begin
|
||||
Result:=TGroupedMatrixGroup.Create(Self);
|
||||
Result.Caption:=aCaption;
|
||||
Result.Value:=aValue;
|
||||
Result.Writable:=aValue<>'';
|
||||
InternalAdd(ParentGroup,Result);
|
||||
end;
|
||||
|
||||
@ -646,18 +650,6 @@ begin
|
||||
Result:=TGroupedMatrixRow(FItems[Index]);
|
||||
end;
|
||||
|
||||
procedure TGroupedMatrixGroup.SetCaption(AValue: TCaption);
|
||||
begin
|
||||
if FCaption=AValue then Exit;
|
||||
FCaption:=AValue;
|
||||
end;
|
||||
|
||||
procedure TGroupedMatrixGroup.SetColor(AValue: TColor);
|
||||
begin
|
||||
if FColor=AValue then Exit;
|
||||
FColor:=AValue;
|
||||
end;
|
||||
|
||||
procedure TGroupedMatrixGroup.Assign(Source: TPersistent);
|
||||
var
|
||||
SrcGroup: TGroupedMatrixGroup;
|
||||
@ -672,6 +664,8 @@ begin
|
||||
SrcGroup:=TGroupedMatrixGroup(Source);
|
||||
FColor:=SrcGroup.FColor;
|
||||
FCaption:=SrcGroup.FCaption;
|
||||
FValue:=SrcGroup.FValue;
|
||||
FWritable:=SrcGroup.FWritable;
|
||||
Clear;
|
||||
for i:=0 to SrcGroup.Count-1 do begin
|
||||
SrcItem:=SrcGroup[i];
|
||||
@ -720,6 +714,8 @@ begin
|
||||
if SrcGroup.Count<>Count then exit;
|
||||
if SrcGroup.Color<>Color then exit;
|
||||
if SrcGroup.Caption<>Caption then exit;
|
||||
if SrcGroup.Value<>Value then exit;
|
||||
if SrcGroup.Writable<>Writable then exit;
|
||||
for i:=0 to Count-1 do
|
||||
if not SrcGroup[i].Equals(Items[i]) then exit;
|
||||
Result:=true;
|
||||
@ -1077,7 +1073,7 @@ begin
|
||||
//Canvas.Brush.Color:=GroupRow.GetEffectiveColor;
|
||||
Canvas.GradientFill(Rect(x,aRect.Top-1,x+2*Indent,aRect.Bottom),GroupRow.GetEffectiveColor,Color,gdHorizontal);
|
||||
// draw group caption
|
||||
Canvas.TextRect(aRect,constCellPadding+x,aRect.Top,GroupRow.Caption);
|
||||
Canvas.TextRect(aRect,constCellPadding+x,aRect.Top,GroupRow.Caption+GroupRow.Value);
|
||||
// draw focus rect
|
||||
if aRow=Row then
|
||||
DrawFocusRect(0,aRow,Rect(x,aRect.Top,aRect.Right,aRect.Bottom));
|
||||
@ -1109,6 +1105,9 @@ begin
|
||||
if MatRow is TGroupedMatrixValue then begin
|
||||
if ACol<>ValueCol then exit;
|
||||
Result:=true;
|
||||
end else if MatRow is TGroupedMatrixGroup then begin
|
||||
if ACol<>ValueCol then exit;
|
||||
Result:=TGroupedMatrixGroup(MatRow).Writable;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1294,10 +1293,15 @@ begin
|
||||
end;
|
||||
|
||||
function TGroupedMatrixControl.GetEditText(aCol, aRow: Longint): string;
|
||||
var
|
||||
MatRow: TGroupedMatrixRow;
|
||||
begin
|
||||
if (aCol=ValueCol) and (aRow>0) and (Matrix[aRow-1] is TGroupedMatrixValue)
|
||||
then begin
|
||||
Result:=TGroupedMatrixValue(Matrix[aRow-1]).Value;
|
||||
if (aCol=ValueCol) and (aRow>=FixedRows) then begin
|
||||
MatRow:=Matrix[aRow-FixedRows];
|
||||
if MatRow is TGroupedMatrixValue then
|
||||
Result:=TGroupedMatrixValue(MatRow).Value
|
||||
else
|
||||
Result:=TGroupedMatrixGroup(MatRow).Caption;
|
||||
exit;
|
||||
end;
|
||||
Result:=inherited GetEditText(aCol, aRow);
|
||||
@ -1307,22 +1311,36 @@ procedure TGroupedMatrixControl.SetEditText(ACol, ARow: Longint;
|
||||
const Value: string);
|
||||
var
|
||||
ValueRow: TGroupedMatrixValue;
|
||||
MatRow: TGroupedMatrixRow;
|
||||
GroupRow: TGroupedMatrixGroup;
|
||||
begin
|
||||
if (aCol=ValueCol) and (aRow>0) and (Matrix[aRow-1] is TGroupedMatrixValue)
|
||||
then begin
|
||||
ValueRow:=TGroupedMatrixValue(Matrix[aRow-1]);
|
||||
if ValueRow.Value=Value then exit;
|
||||
StoreUndo;
|
||||
ValueRow.Value:=Value;
|
||||
if (aCol=ValueCol) and (aRow>0) then begin
|
||||
MatRow:=Matrix[aRow-FixedRows];
|
||||
if MatRow is TGroupedMatrixValue then begin
|
||||
ValueRow:=TGroupedMatrixValue(MatRow);
|
||||
if ValueRow.Value=Value then exit;
|
||||
StoreUndo;
|
||||
ValueRow.Value:=Value;
|
||||
end else begin
|
||||
GroupRow:=TGroupedMatrixGroup(MatRow);
|
||||
if GroupRow.Value=Value then exit;
|
||||
StoreUndo;
|
||||
GroupRow.Value:=Value;
|
||||
end;
|
||||
end;
|
||||
inherited SetEditText(ACol, ARow, Value);
|
||||
end;
|
||||
|
||||
function TGroupedMatrixControl.GetCells(ACol, ARow: Integer): string;
|
||||
var
|
||||
MatRow: TGroupedMatrixRow;
|
||||
begin
|
||||
if (aCol=ValueCol) and (aRow>0) and (Matrix[aRow-1] is TGroupedMatrixValue)
|
||||
then begin
|
||||
Result:=TGroupedMatrixValue(Matrix[aRow-1]).Value;
|
||||
if (aCol=ValueCol) and (aRow>0) then begin
|
||||
MatRow:=Matrix[ARow-FixedRows];
|
||||
if MatRow is TGroupedMatrixValue then
|
||||
Result:=TGroupedMatrixValue(MatRow).Value
|
||||
else
|
||||
Result:=TGroupedMatrixGroup(MatRow).Value;
|
||||
exit;
|
||||
end;
|
||||
Result:=inherited GetCells(ACol, ARow);
|
||||
|
Loading…
Reference in New Issue
Block a user