⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dxbarreg.pas

📁 胜天进销存源码,国产优秀的进销存
💻 PAS
📖 第 1 页 / 共 2 页
字号:
end;

procedure TdxBarManagerEditor.InternalExecuteVerb(AIndex: Integer);
begin
  case AIndex of
    0: BarManager.Customizing(True);
    1: BarManager.AddToolBar;
    2: BarManager.AddToolBar(True)
  end;
end;

{ TdxBarPopupMenuEditor }

function TdxBarPopupMenuEditor.InternalGetVerb(AIndex: Integer): string;
begin
  Result := cxGetResourceString(@dxSBAR_POPUPMENUEDITOR);
end;

function TdxBarPopupMenuEditor.InternalGetVerbCount: Integer;
begin
  Result := 1;
end;

procedure TdxBarPopupMenuEditor.InternalExecuteVerb(AIndex: Integer);
begin
  ShowdxBarSubMenuEditor(TdxBarCustomPopupMenu(Component).ItemLinks);
end;

{ TdxBarsPropertyEditor }

type
  TdxBarsPropertyEditor = class(TPropertyEditor)
  public
    procedure Edit; override;
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: string; override;
  end;

procedure TdxBarsPropertyEditor.Edit;
var
  BarManager: TdxBarManager;
begin
  BarManager := TdxBarManager(GetComponent(0));
  BarManager.Customizing(True);
  if BarManager.IsCustomizing then
    dxBarCustomizingForm.SelectPage(0);
end;

function TdxBarsPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog, paReadOnly];
end;

function TdxBarsPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [TdxBars.ClassName]);
end;

{ TdxCategoriesPropertyEditor }

type
  TdxCategoriesPropertyEditor = class(TPropertyEditor)
  public
    procedure Edit; override;
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: string; override;
  end;

procedure TdxCategoriesPropertyEditor.Edit;
var
  BarManager: TdxBarManager;
begin
  BarManager := TdxBarManager(GetComponent(0));
  BarManager.Customizing(True);
  if BarManager.IsCustomizing then
    dxBarCustomizingForm.SelectPage(1);
end;

function TdxCategoriesPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog, paReadOnly];
end;

function TdxCategoriesPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [TStrings.ClassName]);
end;

{ TdxRegistryPathProperty }

type
  TdxRegistryPathProperty = class(TStringProperty)
  public
    procedure Edit; override;
    function GetAttributes: TPropertyAttributes; override;
  end;

procedure TdxRegistryPathProperty.Edit;
var
  BarManager: TdxBarManager;
  S: string;
begin
  BarManager := TdxBarManager(GetComponent(0));
  S := BarManager.RegistryPath;
  if dxGetRegistryPath(S) then
  begin
    BarManager.RegistryPath := S;
    Designer.Modified;
  end;
end;

function TdxRegistryPathProperty.GetAttributes: TPropertyAttributes;
begin
  Result := inherited GetAttributes + [paDialog];
end;

{ TDetachingBarPropertyEditor }

const
  NoneBarCaption = '<none>';

type
  TDetachingBarPropertyEditor = class(TPropertyEditor)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure GetValues(Proc: TGetStrProc); override;
    function GetValue: string; override;
    procedure SetValue(const Value: string); override;
  end;

function TDetachingBarPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList{$IFNDEF DELPHI6}, paReadOnly{$ENDIF}];
end;

procedure TDetachingBarPropertyEditor.GetValues(Proc: TGetStrProc);
var
  I: Integer;
begin
  Proc(NoneBarCaption);
  with TdxBarItem(GetComponent(0)).BarManager do
    for I := 0 to Bars.Count - 1 do
      Proc(Bars[I].Caption);
end;

function TDetachingBarPropertyEditor.GetValue: string;
begin
  with TCustomdxBarSubItem(GetComponent(0)) do
    if GetDetachingBar = nil then
      Result := NoneBarCaption
    else
      Result := GetDetachingBar.Caption;
end;

procedure TDetachingBarPropertyEditor.SetValue(const Value: string); 
begin
  with TCustomdxBarSubItem(GetComponent(0)) do
    if (Value = NoneBarCaption) or (BarManager.BarByCaption(Value) = nil) then
      DetachingBar := -1
    else
      DetachingBar := BarManager.BarByCaption(Value).Index;
  Modified;    
end;

{ TdxBarItemImageIndexProperty  }

function TdxBarItemImageIndexProperty.GetImages: TCustomImageList;
begin
  Result := BarManager.Images;
end;

function TdxBarItemImageIndexProperty.GetBarManager: TdxBarManager;
begin
  Result := (GetComponent(0) as TdxBarItem).BarManager;
end;

{ TdxBarItemLargeImageIndexProperty }

function TdxBarItemLargeImageIndexProperty.GetImages: TCustomImageList;
begin
  Result := BarManager.LargeImages;
end;

{ TdxBarItemLinksPropertyEditor }

procedure TdxBarItemLinksPropertyEditor.Edit;
begin
  if not (GetComponent(0) is TdxBar) then
    ShowdxBarSubMenuEditor(TdxBarItemLinks(GetOrdValue));
end;

function TdxBarItemLinksPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paReadOnly];
  if not (GetComponent(0) is TdxBar) then Include(Result, paDialog);
end;

function TdxBarItemLinksPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [TdxBarItemLinks.ClassName]);
end;

{ TdxBarScreenTipRepositoryEditor }

type
  TdxBarScreenTipRepositoryEditor = class(TdxBarComponentEditor)
  private
    function GetRepository: TdxBarScreenTipRepository;
  protected
    function InternalGetVerb(AIndex: Integer): string; override;
    function InternalGetVerbCount: Integer; override;
    procedure InternalExecuteVerb(AIndex: Integer); override;
  public
    property Repository: TdxBarScreenTipRepository read GetRepository;
  end;

function TdxBarScreenTipRepositoryEditor.InternalGetVerb(AIndex: Integer): string;
begin
  Result := 'Items Editor...';
end;

function TdxBarScreenTipRepositoryEditor.InternalGetVerbCount: Integer;
begin
  Result := 1
end;

procedure TdxBarScreenTipRepositoryEditor.InternalExecuteVerb(AIndex: Integer);
begin
  ShowFormEditorClass(Designer, Component, Repository.Items, 'Items', TfrmComponentCollectionEditor);
end;

function TdxBarScreenTipRepositoryEditor.GetRepository: TdxBarScreenTipRepository;
begin
  Result := Component as TdxBarScreenTipRepository;
end;

{ TdxBarItemLinksSprig }

type
  TdxBarItemLinksSprig = class(TCollectionSprig)
  public
    function AddTypeCount: Integer; override;
  end;

function TdxBarItemLinksSprig.AddTypeCount: Integer;
begin
  Result := 0;
end;

{ register }

procedure Register;
begin
{$IFDEF DELPHI9}
  ForceDemandLoadState(dlDisable);
{$ENDIF}

  RegisterComponents('ExpressBars', [TdxBarManager,
    TdxBarPopupMenu, TdxBarDockControl, TdxBarScreenTipRepository]);
  RegisterNoIcon([
    TdxBarGroup, TdxBarButton,
    TdxBarEdit, TCustomdxBarCombo, TdxBarCombo, TdxBarSeparator,
    TdxBarSubItem, TdxBarListItem, TdxBarContainerItem, TdxBar, TdxBarScreenTip]);

  RegisterComponentEditor(TdxBarManager, TdxBarManagerEditor);
  RegisterComponentEditor(TdxBarCustomPopupMenu, TdxBarPopupMenuEditor);
  RegisterComponentEditor(TdxBarScreenTipRepository, TdxBarScreenTipRepositoryEditor);

{$IFDEF DELPHI6}
  RegisterPropertyEditor(TypeInfo(TShortCut), TdxBarButton, 'ShortCut', TShortCutProperty);
{$ENDIF}

  RegisterPropertyEditor(TypeInfo(TdxBars), TdxBarManager, 'Bars',
    TdxBarsPropertyEditor);
  RegisterPropertyEditor(TypeInfo(TStrings), TdxBarManager, 'Categories',
    TdxCategoriesPropertyEditor);
  RegisterPropertyEditor(TypeInfo(string), TdxBarManager, 'RegistryPath',
    TdxRegistryPathProperty);
  RegisterPropertyEditor(TypeInfo(TdxBarItemLinks), TdxBar, 'ItemLinks',
    TdxBarItemLinksPropertyEditor);
  RegisterPropertyEditor(TypeInfo(TdxBarItemLinks), TdxBarCustomPopupMenu, 'ItemLinks',
    TdxBarItemLinksPropertyEditor);
  RegisterPropertyEditor(TypeInfo(TdxBarItemLinks), TdxBarSubItem, 'ItemLinks',
    TdxBarItemLinksPropertyEditor);
  RegisterPropertyEditor(TypeInfo(TdxBarItemLinks), TdxBarContainerItem, 'ItemLinks',
    TdxBarItemLinksPropertyEditor);
  RegisterPropertyEditor(TypeInfo(Integer), TCustomdxBarSubItem, 'DetachingBar',
    TDetachingBarPropertyEditor);
  RegisterPropertyEditor(TypeInfo(Integer), TdxBarItem, 'ImageIndex',
    TdxBarItemImageIndexProperty);
  RegisterPropertyEditor(TypeInfo(Integer), TdxBarItem, 'LargeImageIndex',
    TdxBarItemLargeImageIndexProperty);

  RegisterPropertyEditor(TypeInfo(TBitmap), TdxBarItem, 'Glyph', TcxBitmapProperty);
  RegisterPropertyEditor(TypeInfo(TBitmap), TdxBarItem, 'LargeGlyph', TcxBitmapProperty);
  RegisterPropertyEditor(TypeInfo(TBitmap), TdxBarItemLink, 'UserGlyph', TcxBitmapProperty);

  RegisterSprigType(TdxBarItemLinks, TdxBarItemLinksSprig);

  // ImageOptions
  HideClassProperties(TdxBarManager, ['DisabledImages', 'DisabledLargeImages',
    'HotImages', 'Images', 'LargeImages', 'ImageListBkColor', 'LargeIcons',
    'MakeDisabledImagesFaded', 'StretchGlyphs', 'UseLargeImagesForLargeIcons']);

  HideClassProperties(TdxBarSeparator, ['Action', 'Align', 'Category',
    'Description', 'Enabled', 'HelpContext', 'Hint', 'MergeKind', 'MergeOrder',
    'Style', 'ScreenTip', 'OnDestroy']);
end;

procedure DesignSelectionChanged(ASender: TObject);
begin
  if dxBarCustomizingForm <> nil then
    dxBarCustomizingForm.DesignSelectionChanged(ASender);
end;

procedure RegisterBarManager(ASender: TObject);
begin
  if dxBarManagerList.Count = 1 then
  begin
    FdxBarDesignWindow := TdxBarDesignWindow.Create(nil);
    FdxBarDesignWindow.OnSelectionChanged := DesignSelectionChanged;
  end;
  TdxBarManagerAccess(ASender).FdxBarDesignHelper := TdxBarDesignHelper.Create(TComponent(ASender));
end;

procedure UnregisterBarManager(ASender: TObject);
begin
  if (FdxBarDesignWindow <> nil) and ((dxBarManagerList = nil) or (dxBarManagerList.Count = 0)) then
  begin
    FdxBarDesignWindow.Release;
    FdxBarDesignWindow := nil;
  end;
  TdxBarManagerAccess(ASender).FdxBarDesignHelper := nil;
end;

initialization
  FOnRegisterBarManager := RegisterBarManager;
  FOnUnregisterBarManager := UnregisterBarManager;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -