📄 dxbarreg.pas
字号:
{*******************************************************************}
{ }
{ Developer Express Visual Component Library }
{ ExpressBars registring unit }
{ }
{ Copyright (c) 1998-2008 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 EXPRESSBARS 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 dxBarReg;
{$I cxVer.inc}
interface
uses
ImgList,
{$IFDEF DELPHI6}
DesignEditors, DesignIntf, DesignMenus, VCLEditors,
{$ELSE}
DsgnIntf, Menus,
{$ENDIF}
Windows, Classes, Controls, Graphics, cxDesignWindows, dxBar, Contnrs, cxLibraryReg, cxPropEditors;
const
dxBarMajorVersion = '6';
dxBarProductName = 'ExpressBars';
type
TdxBarComponentEditor = class(TcxComponentEditor)
protected
function GetProductMajorVersion: string; override;
function GetProductName: string; override;
end;
TdxBarItemImageIndexProperty = class(TImageIndexProperty)
private
function GetBarManager: TdxBarManager;
protected
property BarManager: TdxBarManager read GetBarManager;
public
function GetImages: TCustomImageList; override;
end;
TdxBarItemLargeImageIndexProperty = class(TdxBarItemImageIndexProperty)
public
function GetImages: TCustomImageList; override;
end;
TdxBarItemLinksPropertyEditor = class(TPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
procedure Register;
implementation
uses
Messages, SysUtils, Forms, Dialogs,
TypInfo, EditIntf, TreeIntf,
dxBarCustForm, dxBarPopupMenuEd, dxBarStrs, dxRegEd, cxClasses, cxComponentCollectionEditor;
type
TdxBarManagerAccess = class(TdxBarManager);
{ TdxBarDesignHelper }
TdxBarDesignHelper = class(TcxDesignHelper, IdxBarDesigner)
public
// IdxBarDesigner
function CanDeleteComponent(AComponent: TComponent): Boolean;
function GetSelectionStatus(AComponent: TPersistent): TdxBarSelectionStatus;
function IdxBarDesigner.IsComponentSelected = IsObjectSelected;
procedure SelectComponent(AComponent: TPersistent; ASelectionOperation: TdxBarSelectionOperation = soExclusive);
procedure ShowDefaultEventHandler(AItem: TdxBarItem);
end;
{ TdxBarDesignWindow }
TdxBarDesignWindow = class(TcxDesignWindow)
private
FActiveDesigner: IDesigner;
// FCurrentSelectionList: TComponentList;
FCurrentSelectionList: TObjectList;
FOnSelectionChanged: TcxNotifyProcedure;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function IsComponentSelected(AComponent: TPersistent): Boolean;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
{$IFNDEF DELPHI6}
procedure ComponentDeleted(Component: IPersistent); override;
procedure SelectionChanged(ASelection: TDesignerSelectionList); override;
{$ELSE}
procedure ItemDeleted(const ADesigner: IDesigner; Item: TPersistent); override;
procedure SelectionChanged(const ADesigner: IDesigner; const ASelection: TDesignerSelectionList); override;
{$ENDIF}
procedure SelectionsChanged(const ASelection: TDesignerSelectionList); override;
property ActiveDesigner: IDesigner read FActiveDesigner;
property OnSelectionChanged: TcxNotifyProcedure read FOnSelectionChanged write FOnSelectionChanged;
end;
var
FdxBarDesignWindow: TdxBarDesignWindow;
{ TdxBarDesignHelper }
function TdxBarDesignHelper.CanDeleteComponent(AComponent: TComponent): Boolean;
begin
Result := cxDesignWindows.CanDeleteComponent(Component, AComponent, Designer);
end;
function TdxBarDesignHelper.GetSelectionStatus(AComponent: TPersistent): TdxBarSelectionStatus;
begin
if FdxBarDesignWindow.IsComponentSelected(AComponent) then
Result := ssActiveSelected
else
if IsObjectSelected(AComponent) then
Result := ssInactiveSelected
else
Result := ssUnselected;
end;
procedure TdxBarDesignHelper.SelectComponent(AComponent: TPersistent; ASelectionOperation: TdxBarSelectionOperation = soExclusive);
begin
case ASelectionOperation of
soAdd: SelectObject(AComponent, False);
soExclude: UnselectObject(AComponent);
soExclusive: SelectObject(AComponent, True, False);
end;
end;
procedure TdxBarDesignHelper.ShowDefaultEventHandler(AItem: TdxBarItem);
begin
ShowComponentDefaultEventHandler(AItem);
end;
{ TdxBarDesignWindow }
constructor TdxBarDesignWindow.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
// FCurrentSelectionList := TComponentList.Create(False);
FCurrentSelectionList := TObjectList.Create(False);
end;
destructor TdxBarDesignWindow.Destroy;
begin
FreeAndNil(FCurrentSelectionList);
inherited;
end;
function TdxBarDesignWindow.IsComponentSelected(AComponent: TPersistent): Boolean;
begin
Result := FCurrentSelectionList.IndexOf(TComponent(AComponent)) <> -1;
end;
procedure TdxBarDesignWindow.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited;
if Operation = opRemove then
FCurrentSelectionList.Remove(AComponent);
end;
{$IFNDEF DELPHI6}
procedure TdxBarDesignWindow.ComponentDeleted(Component: IPersistent);
function Item: TPersistent;
begin
Result := ExtractPersistent(Component);
end;
begin
FCurrentSelectionList.Remove(Item);
end;
{$ELSE}
procedure TdxBarDesignWindow.ItemDeleted(const ADesigner: IDesigner; Item: TPersistent);
begin
FCurrentSelectionList.Remove(Item);
end;
{$ENDIF}
{$IFNDEF DELPHI6}
procedure TdxBarDesignWindow.SelectionChanged(ASelection: TDesignerSelectionList);
begin
if LockCount = 0 then
SelectionsChanged(ASelection);
end;
{$ELSE}
procedure TdxBarDesignWindow.SelectionChanged(const ADesigner: IDesigner;
const ASelection: TDesignerSelectionList);
begin
if LockCount = 0 then
SelectionsChanged(ASelection);
end;
{$ENDIF}
procedure TdxBarDesignWindow.SelectionsChanged(const ASelection: TDesignerSelectionList);
var
I: Integer;
ANewSelection, AOldSelection, ASelectionChanges: TdxObjectList;
ASelectableItem: IdxBarSelectableItem;
begin
inherited;
ASelectionChanges := TdxObjectList.Create(False);
AOldSelection := TdxObjectList.Create(False);
ANewSelection := TdxObjectList.Create(False);
try
AOldSelection.CopyFrom(FCurrentSelectionList);
ConvertSelectionToList(ASelection, ANewSelection);
CleanSelectableItems(ANewSelection);
ANewSelection.CopyTo(FCurrentSelectionList);
ASelectionChanges.XorList(FCurrentSelectionList, AOldSelection);
// add to invalidation single selected object
if ASelectionChanges.Count > 0 then
begin
if AOldSelection.Count = 1 then
ASelectionChanges.Add(AOldSelection[0]);
if ANewSelection.Count = 1 then
ASelectionChanges.Add(ANewSelection[0]);
end;
for I := ASelectionChanges.Count - 1 downto 0 do
begin
if IsSelectableItem(ASelectionChanges[I], ASelectableItem) then
ASelectableItem.SelectionChanged;
end;
for I := 0 to AOldSelection.Count - 1 do
if AOldSelection[I] is TComponent then
TComponent(AOldSelection[I]).RemoveFreeNotification(Self);
for I := 0 to FCurrentSelectionList.Count - 1 do
if FCurrentSelectionList[I] is TComponent then
TComponent(FCurrentSelectionList[I]).FreeNotification(Self);
finally
ANewSelection.Free;
AOldSelection.Free;
ASelectionChanges.Free;
end;
if Assigned(OnSelectionChanged) then
OnSelectionChanged(Self);
end;
{ TdxBarManagerEditor }
type
TdxBarManagerEditor = class(TdxBarComponentEditor)
protected
function InternalGetVerb(AIndex: Integer): string; override;
function InternalGetVerbCount: Integer; override;
procedure InternalExecuteVerb(AIndex: Integer); override;
public
procedure PrepareItem(Index: Integer; const AItem: TDesignMenuItem); override;
// routines
function BarManager: TdxBarManager;
end;
TdxBarPopupMenuEditor = class(TdxBarComponentEditor)
protected
function InternalGetVerb(AIndex: Integer): string; override;
function InternalGetVerbCount: Integer; override;
procedure InternalExecuteVerb(AIndex: Integer); override;
end;
{ TdxBarComponentEditor }
function TdxBarComponentEditor.GetProductMajorVersion: string;
begin
Result := dxBarMajorVersion;
end;
function TdxBarComponentEditor.GetProductName: string;
begin
Result := dxBarProductName;
end;
{ TdxBarManagerEditor }
procedure TdxBarManagerEditor.PrepareItem(Index: Integer; const AItem: TDesignMenuItem);
begin
inherited PrepareItem(Index, AItem);
if Index in [1, 2] then
AItem.Enabled := TdxBarManagerAccess(BarManager).CanAddComponents;
if Index = 2 then
AItem.Enabled := AItem.Enabled and (BarManager.MainMenuBar = nil);
end;
function TdxBarManagerEditor.BarManager: TdxBarManager;
begin
Result := TdxBarManager(Component);
end;
function TdxBarManagerEditor.InternalGetVerb(AIndex: Integer): string;
begin
case AIndex of
0: Result := cxGetResourceString(@dxSBAR_CUSTOMIZINGFORM);
1: Result := 'Add Toolbar';
2: Result := 'Add MainMenu';
else
Result := inherited InternalGetVerb(AIndex);
end;
end;
function TdxBarManagerEditor.InternalGetVerbCount: Integer;
begin
Result := 3;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -