git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.DevExpressVCL@7 05c56307-c608-d34a-929d-697000501d7a
183 lines
5.7 KiB
ObjectPascal
183 lines
5.7 KiB
ObjectPascal
{*******************************************************************}
|
|
{ }
|
|
{ Developer Express Visual Component Library }
|
|
{ ExpressNavBar }
|
|
{ }
|
|
{ Copyright (c) 2002-2006 Developer Express Inc. }
|
|
{ ALL RIGHTS RESERVED }
|
|
{ }
|
|
{ The entire contents of this file is protected by U.S. and }
|
|
{ International Copyright Laws. Unauthorized reproduction, }
|
|
{ reverse-engineering, and distribution of all or any portion of }
|
|
{ the code contained in this file is strictly prohibited and may }
|
|
{ result in severe civil and criminal penalties and will be }
|
|
{ prosecuted to the maximum extent possible under the law. }
|
|
{ }
|
|
{ RESTRICTIONS }
|
|
{ }
|
|
{ THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES }
|
|
{ (DCU, OBJ, DLL, ETC.) ARE CONFIDENTIAL AND PROPRIETARY TRADE }
|
|
{ SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS }
|
|
{ LICENSED TO DISTRIBUTE THE EXPRESSNAVBAR AND ALL ACCOMPANYING }
|
|
{ VCL CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY. }
|
|
{ }
|
|
{ THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED }
|
|
{ FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE }
|
|
{ COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE }
|
|
{ AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT }
|
|
{ AND PERMISSION FROM DEVELOPER EXPRESS INC. }
|
|
{ }
|
|
{ CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON }
|
|
{ ADDITIONAL RESTRICTIONS. }
|
|
{ }
|
|
{*******************************************************************}
|
|
|
|
unit dxNavBarViewsFact;
|
|
|
|
{$I cxVer.inc}
|
|
|
|
interface
|
|
|
|
uses
|
|
Contnrs, dxNavBar;
|
|
|
|
type
|
|
TdxNavBarViewsFactory = class
|
|
private
|
|
FViews: TObjectList;
|
|
|
|
function GetCount: Integer;
|
|
function GetNames(ID: Integer): string;
|
|
function GetPainterClass(ID: Integer): TdxNavBarPainterClass;
|
|
protected
|
|
procedure Clear;
|
|
function IndexOfID(const ID: Integer): Integer;
|
|
public
|
|
constructor Create;
|
|
destructor Destroy; override;
|
|
procedure RegisterView(AID: Integer; AName: string; APainterClass: TdxNavBarPainterClass);
|
|
procedure UnRegisterView(AID: Integer);
|
|
function IndexOfName(const Name: string): Integer;
|
|
|
|
property Count: Integer read GetCount;
|
|
property Names[ID: Integer]: string read GetNames;
|
|
property PainterClasses[ID: Integer]: TdxNavBarPainterClass read GetPainterClass;
|
|
end;
|
|
|
|
function dxNavBarViewsFactory: TdxNavBarViewsFactory;
|
|
|
|
implementation
|
|
|
|
uses
|
|
SysUtils, cxClasses, dxNavBarConsts;
|
|
|
|
type
|
|
TdxNavBarPainterFactItem = class
|
|
ID: Integer;
|
|
Name: string;
|
|
PainterClass: TdxNavBarPainterClass;
|
|
end;
|
|
|
|
var
|
|
FNavBarViewsFactory: TdxNavBarViewsFactory;
|
|
|
|
function dxNavBarViewsFactory: TdxNavBarViewsFactory;
|
|
begin
|
|
if FNavBarViewsFactory = nil then
|
|
FNavBarViewsFactory := TdxNavBarViewsFactory.Create;
|
|
Result := FNavBarViewsFactory;
|
|
end;
|
|
|
|
{ TdxNavBarViewsFactory }
|
|
|
|
constructor TdxNavBarViewsFactory.Create;
|
|
begin
|
|
inherited Create;
|
|
FViews := TObjectList.Create;
|
|
end;
|
|
|
|
destructor TdxNavBarViewsFactory.Destroy;
|
|
begin
|
|
FreeAndNil(FViews);
|
|
inherited Destroy;
|
|
end;
|
|
|
|
function TdxNavBarViewsFactory.GetCount: Integer;
|
|
begin
|
|
Result := FViews.Count;
|
|
end;
|
|
|
|
function TdxNavBarViewsFactory.GetNames(ID: Integer): string;
|
|
begin
|
|
if IndexOfID(ID) < 0 then
|
|
raise Exception.CreateFmt(cxGetResourceStringNet(sdxCannotFindView), [ID]);
|
|
Result := TdxNavBarPainterFactItem(FViews.Items[IndexOfID(ID)]).Name
|
|
end;
|
|
|
|
function TdxNavBarViewsFactory.GetPainterClass(ID: Integer): TdxNavBarPainterClass;
|
|
begin
|
|
if IndexOfID(ID) < 0 then
|
|
raise Exception.CreateFmt(cxGetResourceStringNet(sdxCannotFindView), [ID]);
|
|
Result := TdxNavBarPainterFactItem(FViews.Items[IndexOfID(ID)]).PainterClass
|
|
end;
|
|
|
|
procedure TdxNavBarViewsFactory.Clear;
|
|
begin
|
|
FViews.Clear;
|
|
end;
|
|
|
|
function TdxNavBarViewsFactory.IndexOfID(const ID: Integer): Integer;
|
|
var
|
|
I: Integer;
|
|
begin
|
|
Result := -1;
|
|
for I := 0 to FViews.Count - 1 do
|
|
if TdxNavBarPainterFactItem(FViews.Items[I]).ID = ID then
|
|
begin
|
|
Result := I;
|
|
break;
|
|
end;
|
|
end;
|
|
|
|
procedure TdxNavBarViewsFactory.RegisterView(AID: Integer; AName: string; APainterClass: TdxNavBarPainterClass);
|
|
var
|
|
Item: TdxNavBarPainterFactItem;
|
|
begin
|
|
if IndexOfID(AID) <> -1 then
|
|
raise Exception.CreateFmt(cxGetResourceStringNet(sdxViewAlreadyExists), [AID]);
|
|
Item := TdxNavBarPainterFactItem.Create;
|
|
with Item do
|
|
begin
|
|
ID := AID;
|
|
Name := AName;
|
|
PainterClass := APainterClass
|
|
end;
|
|
FViews.Add(Item);
|
|
end;
|
|
|
|
procedure TdxNavBarViewsFactory.UnRegisterView(AID: Integer);
|
|
begin
|
|
if IndexOfID(AID) <> -1 then
|
|
FViews.Delete(IndexOfID(AID));
|
|
end;
|
|
|
|
function TdxNavBarViewsFactory.IndexOfName(const Name: string): Integer;
|
|
var
|
|
I: Integer;
|
|
begin
|
|
Result := -1;
|
|
for I := 0 to Count - 1 do
|
|
if Names[I] = Name then
|
|
begin
|
|
Result := I;
|
|
break;
|
|
end;
|
|
end;
|
|
|
|
initialization
|
|
|
|
finalization
|
|
FreeAndNil(FNavBarViewsFactory);
|
|
|
|
end.
|