You've already forked lazarus-ccr
tvplanit: Use resource description if resourcegroup caption is empty.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5150 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -405,12 +405,14 @@ end;
|
|||||||
|
|
||||||
// Creates a resource group at runtime
|
// Creates a resource group at runtime
|
||||||
procedure TMainForm.CreateResourceGroup;
|
procedure TMainForm.CreateResourceGroup;
|
||||||
|
const
|
||||||
|
NAME_OF_GROUP = ''; // empty --> use resource description
|
||||||
var
|
var
|
||||||
datastore: TVpCustomDatastore;
|
datastore: TVpCustomDatastore;
|
||||||
grp: TVpResourceGroup;
|
grp: TVpResourceGroup;
|
||||||
begin
|
begin
|
||||||
datastore := VpControlLink1.Datastore;
|
datastore := VpControlLink1.Datastore;
|
||||||
grp := datastore.Resources.AddResourceGroup('Res2 overlayed', [1, 2]);
|
grp := datastore.Resources.AddResourceGroup([1, 2], NAME_OF_GROUP);
|
||||||
grp.ReadOnly := true;
|
grp.ReadOnly := true;
|
||||||
grp.Pattern := opDiagCross;
|
grp.Pattern := opDiagCross;
|
||||||
if datastore.Resource <> nil then
|
if datastore.Resource <> nil then
|
||||||
|
@ -88,7 +88,8 @@ type
|
|||||||
constructor Create(Owner: TObject);
|
constructor Create(Owner: TObject);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function AddResource(ResID: Integer): TVpResource;
|
function AddResource(ResID: Integer): TVpResource;
|
||||||
function AddResourceGroup(ACaption: String; const AResIDs: array of Integer): TVpResourceGroup;
|
function AddResourceGroup(const AResIDs: array of Integer;
|
||||||
|
ACaption: String = ''): TVpResourceGroup;
|
||||||
procedure ClearResources;
|
procedure ClearResources;
|
||||||
procedure ClearResourceGroups;
|
procedure ClearResourceGroups;
|
||||||
function FindResourceByName(AName : string) : TVpResource;
|
function FindResourceByName(AName : string) : TVpResource;
|
||||||
@ -194,7 +195,7 @@ type
|
|||||||
function GetItem(AIndex: Integer): TVpResource;
|
function GetItem(AIndex: Integer): TVpResource;
|
||||||
procedure SetPattern(AValue: TVpOverlayPattern);
|
procedure SetPattern(AValue: TVpOverlayPattern);
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TVpResources; ACaption: String; AResourceID: Integer);
|
constructor Create(AOwner: TVpResources; AResourceID: Integer; ACaption: String);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function AddID(AResourceID: Integer): Integer;
|
function AddID(AResourceID: Integer): Integer;
|
||||||
function AsString(ASeparator: Char = ';'): String;
|
function AsString(ASeparator: Char = ';'): String;
|
||||||
@ -730,23 +731,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TVpResources.AddResourceGroup(ACaption: String;
|
function TVpResources.AddResourceGroup(const AResIDs: Array of Integer;
|
||||||
const AResIDs: Array of Integer): TVpResourceGroup;
|
ACaption: String = ''): TVpResourceGroup;
|
||||||
var
|
var
|
||||||
grp: TVpResourceGroup;
|
grp: TVpResourceGroup;
|
||||||
|
res: TVpResource;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if (ACaption = '') then
|
|
||||||
raise Exception.Create('Caption of resource group must not be empty');
|
|
||||||
|
|
||||||
if Length(AResIDs) < 2 then
|
if Length(AResIDs) < 2 then
|
||||||
raise Exception.Create('Resource group must contain at least one additional resource.');
|
raise Exception.Create('Resource group must contain at least one additional resource.');
|
||||||
|
|
||||||
|
// Use resource descriptions if ACaption is not specified or empty.
|
||||||
|
if ACaption = '' then begin
|
||||||
|
for i:=Low(AResIDs) + 1 to High(AResIDs) do begin
|
||||||
|
res := GetResource(AResIDs[i]);
|
||||||
|
ACaption := ACaption + ', ' + res.Description;
|
||||||
|
end;
|
||||||
|
if ACaption <> '' then Delete(ACaption, 1, 2);
|
||||||
|
end;
|
||||||
|
|
||||||
// Enforce unique group name.
|
// Enforce unique group name.
|
||||||
grp := FindResourceGroupByName(ACaption);
|
grp := FindResourceGroupByName(ACaption);
|
||||||
if grp = nil then begin
|
if grp = nil then begin
|
||||||
// Index 0 refers to the resource to which the other resources are added.
|
// Index 0 refers to the resource to which the other resources are added.
|
||||||
Result := TVpResourceGroup.Create(Self, ACaption, AResIDs[0]);
|
Result := TVpResourceGroup.Create(Self, AResIDs[0], ACaption);
|
||||||
FResourceGroups.Add(Result);
|
FResourceGroups.Add(Result);
|
||||||
end else begin
|
end else begin
|
||||||
grp.Clear; // Make sure that the group is empty before adding overlayed resources
|
grp.Clear; // Make sure that the group is empty before adding overlayed resources
|
||||||
@ -984,14 +992,15 @@ end;
|
|||||||
(*****************************************************************************)
|
(*****************************************************************************)
|
||||||
{ TVpResourceGroup }
|
{ TVpResourceGroup }
|
||||||
(*****************************************************************************)
|
(*****************************************************************************)
|
||||||
constructor TVpResourceGroup.Create(AOwner: TVpResources; ACaption: String;
|
constructor TVpResourceGroup.Create(AOwner: TVpResources; AResourceID: Integer;
|
||||||
AResourceID: Integer);
|
ACaption: String);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FOwner := AOwner;
|
FOwner := AOwner;
|
||||||
FResourceID := AResourceID;
|
FResourceID := AResourceID;
|
||||||
FCaption := ACaption;
|
FCaption := ACaption;
|
||||||
FPattern := opBDiagonal;
|
FPattern := opBDiagonal;
|
||||||
|
FReadOnly := true;
|
||||||
Clear;
|
Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user