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

📄 dxribbon.pas

📁 胜天进销存源码,国产优秀的进销存
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{*******************************************************************}
{                                                                   }
{       Developer Express Visual Component Library                  }
{       ExpressBars components                                      }
{                                                                   }
{       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 dxRibbon;

{$I cxVer.inc}

interface

uses
  Windows, Messages, Classes, SysUtils, Graphics, Controls, cxClasses,
  cxGraphics, cxControls, dxBar, dxRibbonSkins, dxRibbonFormCaptionHelper,
  dxRibbonForm, dxBarSkin, dxFading, ExtCtrls, ImgList, cxContainer, Forms,
  cxAccessibility, dxBarAccessibility, IniFiles, Contnrs, cxLookAndFeels;
  
const
  dxRibbonFormCaptionMinWidth         = 50;
  dxRibbonFormCaptionTextSpace        = 4;
  dxRibbonTabMinWidth                 = 28;
  dxRibbonTabTextOffset               = 5;
  dxRibbonTabIndent                   = 17;
  dxRibbonOptimalTabSpace             = dxRibbonTabTextOffset * 2 + dxRibbonTabIndent;
  dxRibbonTabSeparatorVisibilityLimit = dxRibbonTabMinWidth div 2;
  dxRibbonApplicationButtonIndent     = 4;
  dxRibbonOwnerMinimalWidth: Integer  = 300;
  dxRibbonOwnerMinimalHeight: Integer = 250;
  dxRibbonScrollDelay                 = 400;
  dxRibbonScrollInterval              = 20;

  dxRibbonGroupRowCount = 3;

  CM_SELECTAPPMENUFIRSTITEMCONTROL = WM_DX + 25;
  CM_SHOWKEYTIPS = WM_DX + 26;

type
  TdxBarApplicationMenu = class;
  TdxCustomRibbon = class;
  TdxRibbonApplicationButtonFadingHelper = class;
  TdxRibbonElementCustomFadingHelper = class;
  TdxRibbonGroupBarControl = class;
  TdxRibbonGroupBarControlViewInfo = class;
  TdxRibbonGroupsDockControl = class;
  TdxRibbonGroupsDockControlSite = class;
  TdxRibbonGroupsDockControlSiteViewInfo = class;
  TdxRibbonGroupsDockControlViewInfo = class;
  TdxRibbonGroupsDockControlViewInfoClass = class of TdxRibbonGroupsDockControlViewInfo;
  TdxRibbonGroupsScrollButtonFadingHelper = class;
  TdxRibbonHelpButtonFadingHelper = class;
  TdxRibbonMDIButtonFadingHelper = class;
  TdxRibbonQuickAccessBarControlViewInfo = class;
  TdxRibbonQuickAccessDockControl = class;
  TdxRibbonQuickAccessToolbar = class;
  TdxRibbonTab = class;
  TdxRibbonCollapsedGroupPopupBarControl = class;
  TdxRibbonTabGroup = class;
  TdxRibbonTabPainterClass = class of TdxRibbonTabPainter;
  TdxRibbonTabScrollButtonFadingHelper = class;
  TdxRibbonTabViewInfo = class;
  TdxRibbonViewInfo = class;

  EdxRibbonException = class(Exception);

  IdxRibbonFormStatusBarDraw = interface
    ['{E6AA56DF-B87A-4D98-98CF-B41BA751594D}']
    function GetActive(AForm: TCustomForm): Boolean;
    function GetHeight: Integer;
    function GetIsRaised(ALeft: Boolean): Boolean;
  end;

  IdxRibbonFormNonClientDraw = interface
    ['{0A28260B-C352-4704-A88B-44DD8461955C}']
    procedure Add(AObject: TObject);
    procedure Remove(AObject: TObject);
  end;

  { TdxDesignSelectionHelper }

  TdxDesignSelectionHelper = class(TInterfacedObject,
    IdxBarSelectableItem
  )
  private
    FOwner: TPersistent;
    FRibbon: TdxCustomRibbon;
    FParent: TPersistent;
  protected
    //IdxBarSelectableItem
    function CanDelete(ADestruction: Boolean = False): Boolean;
    procedure DeleteSelection(var AReference: IdxBarSelectableItem; ADestruction: Boolean);
    procedure ExecuteCustomizationAction(ABasicAction: TdxBarCustomizationAction);
    function GetBarManager: TdxBarManager;
    function GetInstance: TPersistent;
    procedure GetMasterObjects(AList: TdxObjectList);
    function GetNextSelectableItem: IdxBarSelectableItem;
    function GetSelectableParent: TPersistent;
    function GetSelectionStatus: TdxBarSelectionStatus;
    function GetSupportedActions: TdxBarCustomizationActions;
    procedure Invalidate;
    function IsComplex: Boolean;
    function IsComponentSelected: Boolean;
    procedure SelectComponent(ASelectionOperation: TdxBarSelectionOperation = soExclusive);
    function SelectParentComponent: Boolean;
    procedure SelectionChanged;
  public
    constructor Create(ARibbon: TdxCustomRibbon; AOwner: TPersistent; AParent: TPersistent);
  end;

  { TdxRibbonTabPainter }

  TdxRibbonTabPainter = class
  private
    FColorScheme: TdxCustomRibbonSkin;
  protected
    procedure DrawBackground(ACanvas: TcxCanvas; const ABounds: TRect;
      AState: TdxRibbonTabState); virtual;
    procedure DrawTabSeparator(ACanvas: TcxCanvas; const ABounds: TRect;
      Alpha: Byte); virtual;
    procedure DrawText(ACanvas: TcxCanvas; const ABounds: TRect;
      const AText: string; AHasSeparator: Boolean); virtual;
  public
    constructor Create(AColorScheme: TdxCustomRibbonSkin);
    property ColorScheme: TdxCustomRibbonSkin read FColorScheme;
  end;

  { TdxRibbonPainter }

  TdxRibbonPainterClass = class of TdxRibbonPainter;

  TdxRibbonPainter = class
  private
    FRibbon: TdxCustomRibbon;
    function GetViewInfo: TdxRibbonViewInfo;
    function GetColorScheme: TdxCustomRibbonSkin;
  protected
    procedure DrawEmptyRibbon(ACanvas: TcxCanvas);
    function GetFormIconHandle: HICON;
  public
    constructor Create(ARibbon: TdxCustomRibbon); virtual;

    //non-client routines
    procedure DrawRibbonFormCaption(ACanvas: TcxCanvas; const ABounds: TRect;
      const AData: TdxRibbonFormData); virtual;
    procedure DrawRibbonFormBorderIcon(ACanvas: TcxCanvas; const ABounds: TRect;
      AIcon: TdxBorderDrawIcon; AState: TdxBorderIconState); virtual;
    procedure DrawRibbonFormBorders(ACanvas: TcxCanvas;
      const ABordersWidth: TRect; const AData: TdxRibbonFormData); virtual;
    //client routines
    procedure DrawApplicationButton(ACanvas: TcxCanvas; const ABounds: TRect; AState: TdxApplicationButtonState); virtual;
    procedure DrawApplicationButtonGlyph(ACanvas: TcxCanvas; const ABounds: TRect; AGlyph: TBitmap; AStretch: Boolean); virtual;
    procedure DrawBackground(ACanvas: TcxCanvas; const ABounds: TRect); virtual;
    procedure DrawBottomBorder(ACanvas: TcxCanvas);
    procedure DrawDefaultFormIcon(ACanvas: TcxCanvas; const ABounds: TRect);
    procedure DrawGlowingText(DC: HDC; const AText: string;
      AFont: TFont; const ABounds: TRect; AColor: TColor; AFlags: DWORD);

    procedure DrawGroupsArea(ACanvas: TcxCanvas; const ABounds: TRect); virtual;
    procedure DrawGroupsScrollButton(ACanvas: TcxCanvas; const ABounds: TRect;
      ALeft, APressed, AHot: Boolean); virtual;
    procedure DrawGroupsScrollButtonArrow(ACanvas: TcxCanvas;
      const ABounds: TRect; ALeft: Boolean); virtual;
    procedure DrawRibbonFormCaptionText(ACanvas: TcxCanvas; const ABounds: TRect;
      const ADocumentName, ACaption: string; const AData: TdxRibbonFormData); virtual;
    procedure DrawRibbonGlassFormCaptionText(ACanvas: TcxCanvas; const ABounds: TRect;
      const ADocumentName, ACaption: string; AIsActive: Boolean); virtual;
    procedure DrawQuickAccessToolbar(ACanvas: TcxCanvas; const ABounds: TRect;
      AIsActive: Boolean); virtual;
    procedure DrawTabScrollButton(ACanvas: TcxCanvas; const ABounds: TRect;
      ALeft, APressed, AHot: Boolean); virtual;
    procedure DrawTabScrollButtonGlyph(ACanvas: TcxCanvas;
      const ABounds: TRect; ALeft: Boolean); virtual;
    procedure DrawHelpButton(ACanvas: TcxCanvas; const ABounds: TRect;
      AState: TdxBorderIconState);
    procedure DrawMDIButton(ACanvas: TcxCanvas; const ABounds: TRect;
      AButton: TdxBarMDIButton; AState: TdxBorderIconState); virtual;

    property ColorScheme: TdxCustomRibbonSkin read GetColorScheme;
    property Ribbon: TdxCustomRibbon read FRibbon;
    property ViewInfo: TdxRibbonViewInfo read GetViewInfo;
  end;

  { TdxRibbonTabViewInfo }

  TdxRibbonTabViewInfoClass = class of TdxRibbonTabViewInfo;

  TdxRibbonTabViewInfo = class
  private
    FPainter: TdxRibbonTabPainter;
    FTab: TdxRibbonTab;
    function GetCanvas: TcxCanvas;
    function GetFont: TFont;
  protected
    FCanHasSeparator: Boolean;
    FMinWidth: Integer;
    FOptimalWidth: Integer;
    FSeparatorAlphaValue: Integer;
    FSeparatorBounds: TRect;
    FTextBounds: TRect;
    FTextWidth: Integer;
    FWidth: Integer;
    procedure DrawBackground(ACanvas: TcxCanvas);
    procedure CalculateWidths; virtual;
    function GetTextBounds: TRect; virtual;
    function GetSeparatorBounds: TRect; virtual;
    function GetState: TdxRibbonTabState; virtual;
    function GetPainterClass: TdxRibbonTabPainterClass; virtual;
    function IsSelected: Boolean;
    function PrepareFadeImage(ADrawHot: Boolean): TcxBitmap;

    property Canvas: TcxCanvas read GetCanvas;
    property Painter: TdxRibbonTabPainter read FPainter;
    property Width: Integer read FWidth;
  public
    Bounds: TRect;
    constructor Create(ATab: TdxRibbonTab); virtual;
    destructor Destroy; override;
    procedure Calculate(const ABounds: TRect; ASeparatorAlpha: Byte); virtual;
    function HasSeparator: Boolean;
    procedure Paint(ACanvas: TcxCanvas);
    property Font: TFont read GetFont;
    property MinWidth: Integer read FMinWidth;
    property OptimalWidth: Integer read FOptimalWidth;
    property SeparatorAlphaValue: Integer read FSeparatorAlphaValue;
    property SeparatorBounds: TRect read FSeparatorBounds;
    property State: TdxRibbonTabState read GetState;
    property Tab: TdxRibbonTab read FTab;
    property TextBounds: TRect read FTextBounds;
    property TextWidth: Integer read FTextWidth;
  end;

  { TdxRibbonTabViewInfos }

  TdxRibbonViewInfoClass = class of TdxRibbonViewInfo;

  TdxRibbonHitTest = (rhtNone, rhtTab, rhtApplicationMenu,
    rhtTabScrollLeft, rhtTabScrollRight, rhtGroupScrollLeft, rhtGroupScrollRight, //keep order
    rhtHelpButton, rhtMDIMinimizeButton, rhtMDIRestoreButton, rhtMDICloseButton); //keep order

  TdxRibbonHitInfo = record
    HitTest: TdxRibbonHitTest;
    Tab: TdxRibbonTab;
  end;

  TdxRibbonScrollButton = (rsbLeft, rsbRight);
  TdxRibbonScrollButtons = set of TdxRibbonScrollButton;

  TdxRibbonTabsViewInfo = class(TList)
  private
    FBounds: TRect;
    FHasButtonOnRight: Boolean;
    FNeedShowHint: Boolean;
    FOwner: TdxRibbonViewInfo;
    FScrollButtonBounds: array[TdxRibbonScrollButton] of TRect;
    FScrollButtonFadingHelpers: array[TdxRibbonScrollButton] of TdxRibbonTabScrollButtonFadingHelper;
    FScrollButtons: TdxRibbonScrollButtons;
    FScrollPosition: Integer;
    FScrollWidth: Integer;
    FSeparatorAlpha: Byte;
    FTotalMinimalWidth: Integer;
    FTotalOptimalWidth: Integer;
    procedure CalculateScrollButtons;
    procedure CheckScrollPosition(var Value: Integer);
    function GetLongestTabWidth: Integer;
    function GetPainter: TdxRibbonPainter;
    function GetRealMinItemWidth(Index: Integer): Integer;
    function GetScrollButtonBounds(Index: TdxRibbonScrollButton): TRect;
    function GetScrollButtonHot(Index: TdxRibbonScrollButton): Boolean;
    function GetScrollButtonPressed(Index: TdxRibbonScrollButton): Boolean;

⌨️ 快捷键说明

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