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

📄 aqdockinguiofficexp.pas

📁 AutomatedDocking Library 控件源代码修改 适合Delphi 2009 和C++ Builder 20009 使用。 修正汉字不能正确显示问题
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{*******************************************************************}
{                                                                   }
{       AutomatedDocking Library (Cross-Platform Edition)           }
{                                                                   }
{       Copyright (c) 1999-2008 AutomatedQA Corp.                   }
{       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 AUTOMATEDQA CORP. THE REGISTERED DEVELOPER IS        }
{   LICENSED TO DISTRIBUTE THE AUTOMATEDDOCKING LIBRARY AND ALL     }
{   ACCOMPANYING VCL AND CLX 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 WRITTEN CONSENT          }
{   AND PERMISSION FROM AUTOMATEDQA CORP.                           }
{                                                                   }
{   CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON       }
{   ADDITIONAL RESTRICTIONS.                                        }
{                                                                   }
{*******************************************************************}

unit aqDockingUIOfficeXP;

{$I aqDockingVer.inc}

interface

uses
  Types, Classes,
{$IFDEF VCL}
  Windows, Graphics, ImgList,
{$ELSE}
  QGraphics, QImgList,
{$ENDIF}
  aqDockingUtils, aqUIHelpers, aqDockingUI, aqDockingUIDefault;

type
  TaqOfficeXPScheme = (ofsSystem, ofsBlue, ofsOlive, ofsSilver, ofsDefault);
  TaqOfficeXPSchemeTint = (ostFancy, ostModest);

  TaqOfficeXPUIStyle = class(TaqCustomDefaultUIStyle)
  private
    FThemeAvailable: Boolean;
    FScheme: TaqOfficeXPScheme;
    FSchemeTint: TaqOfficeXPSchemeTint;
    FDownColor: TGradient;
    FToolbarStartColor: TColorRef;
    FCaptionButtonSelColor: TColorRef;
    FDownStartColor: TColorRef;
    // notifiers
    FThemeNotifier: TObject;
    FAppEvents: TaqApplicationEvents;

    procedure CheckTheme;
    procedure DoAppSettingChange(Sender: TObject; Flag: Integer; const Section: string; var Result: Longint);
    procedure ThemeChange(Sender: TObject);
    procedure SetScheme(const Value: TaqOfficeXPScheme);
    procedure SetSchemeTint(const Value: TaqOfficeXPSchemeTint);
    procedure SetDownColor(const Value: TGradient);
  protected
    procedure SetColors; virtual;

    { TaqDockingUIStyle }
     // High-level drawing routines
    procedure DoDrawTabButton(ACanvas: TCanvas; ARect: TRect;
      AState: TaqTabButtonState; AKind: TaqTabButtonKind); override;
    procedure DoDrawTabPane(ACanvas: TCanvas; ARect: TRect;
      AOrientation: TaqTabOrientation); override;
    procedure DoDrawTabItem(ACanvas: TCanvas; ARect: TRect;
      const ACaption: string; AState: TaqTabItemState;
      APosition: TaqTabItemPosition; AOrientation: TaqOrientation;
      AButtonAreaWidthBefore: Integer; AButtonAreaWidthAfter: Integer;
      ADrawImage: Boolean; AImages: TCustomImageList; AImageIndex: Integer); override;
    procedure DoDrawTabTarget(ACanvas: TCanvas; ARect: TRect); override;
    procedure DoDrawCaptionButton(ACanvas: TCanvas; ARect: TRect;
      AState: TaqDockButtonState; ACaptionState: TaqDockCaptionState; AKind: TaqDockButtonKind); override;
    procedure DoDrawCaption(ACanvas: TCanvas; ARect: TRect; const ACaption: string;
      AState: TaqDockCaptionState; AMaxCaptionWidth: Integer; var AFitCaption: Boolean; ADrawImage: Boolean;
      AImages: TCustomImageList; AImageIndex: Integer); override;
    procedure DoDrawSplitter(ACanvas: TCanvas; ARect: TRect;
      AOrientation: TaqSplitterOrientation); override;

    procedure DoDrawHideZone(ACanvas: TCanvas; ASiteRect, ARect: TRect;
      AOrientation: TaqHideZoneOrientation); override;
    procedure DoDrawHiddenTabItem(ACanvas: TCanvas; ARect: TRect;
      const AText: string; AState: TaqTabItemState;
      AOrientation: TaqHideZoneOrientation; APosition: TaqTabItemPosition;
      ADrawImage, ADrawText: Boolean; AImages: TCustomImageList; AImageIndex: Integer); override;
      
    property DownColor: TGradient read FDownColor write SetDownColor;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

    function GetOfficeXPScheme: TaqOfficeXPScheme;
  published
    property CaptionButtons;
    property Images;
    property Scheme: TaqOfficeXPScheme read FScheme write SetScheme default ofsSystem;
    property SchemeTint: TaqOfficeXPSchemeTint read FSchemeTint write SetSchemeTint default ostFancy;
    property TabIndent;

    property OnGetTabWidth;
    property OnDrawTabButton;
    property OnDrawTabPane;
    property OnDrawTabItem;
    property OnDrawTabTarget;
    property OnDrawCaptionButton;
    property OnDrawCaption;
    property OnDrawControl;
    property OnDrawSplitter;
    property OnChange;
  end;

type
  TaqOfficeXPSchemeColor = ofsBlue..ofsSilver;

const
  xpToolbarStartColor = 0;
  xpToolbarEndColor   = 1;
  xpBarMarkStartColor = 2;
  xpBarMarkEndColor   = 3;
  xpSelectedStartColor= 4;
  xpSelectedEndColor  = 5;
  xpDownStartColor    = 6;
  xpDownEndColor      = 7;

  xpStartColor = xpToolbarStartColor;
  xpEndColor   = xpDownEndColor;

  OfficeXPColors: array[TaqOfficeXPSchemeColor, xpStartColor..xpEndColor] of TColorRef = (
    ($FEECDD, $E2A981, $913500, $F1A675, $CCF4FF, $91D0FF, $8ED3FF, $4E91FE),
    ($DEF7F4, $91C6B7, $6B7760, $8CC2B0, $CCF4FF, $91D0FF, $8ED3FF, $4E91FE),
    ($FAF4F3, $B59799, $927476, $C8B2B3, $CCF4FF, $91D0FF, $8ED3FF, $4E91FE)
  );

implementation

uses
  SysUtils, Math,

  UxTheme;


{ TaqOfficeXPUIStyle }

procedure TaqOfficeXPUIStyle.CheckTheme;
begin
  FThemeAvailable := InitThemeLibrary and IsAppThemed;
end;

constructor TaqOfficeXPUIStyle.Create(AOwner: TComponent);
begin
  inherited;
  FAppEvents := TaqApplicationEvents.Create(Self);
  FAppEvents.OnSettingChange := DoAppSettingChange;
  FThemeNotifier := TaqThemeNotifier.Create;
  TaqThemeNotifier(FThemeNotifier).OnThemeChange := ThemeChange;

  FHotTrack := False;
  FDownColor := TGradient.Create;
  CheckTheme;

  SetColors;
  FMetrics[dumTabPadding] := 0;
  TabIndent := 0;
end;

destructor TaqOfficeXPUIStyle.Destroy;
begin
  FreeAndNil(FThemeNotifier);
  FreeAndNil(FDownColor);
  if FThemeAvailable then
    FreeThemeLibrary;
  inherited;
end;

procedure TaqOfficeXPUIStyle.DoAppSettingChange(Sender: TObject;
  Flag: Integer; const Section: string; var Result: Integer);
begin
  SetColors;
end;

procedure TaqOfficeXPUIStyle.DoDrawCaption(ACanvas: TCanvas; ARect: TRect;
  const ACaption: string; AState: TaqDockCaptionState;
  AMaxCaptionWidth: Integer; var AFitCaption: Boolean; ADrawImage: Boolean;
  AImages: TCustomImageList; AImageIndex: Integer);
var
  Color: TGradient;
begin
  ACanvas.Brush.Color := SplitterColor;
  ACanvas.Brush.Style := bsSolid;
  ACanvas.FillRect(ARect);
  if AState = dcsFocused then
    Color := ActiveCaptionColor
  else
    Color := CaptionColor;

  Color.Fill(ACanvas, ARect, ARect);

  InflateRect(ARect, -1, -1);
  DoDrawCaptionContent(ACanvas, ARect, ACaption, AState, AMaxCaptionWidth, AFitCaption,
    ADrawImage, AImages, AImageIndex);
end;

procedure TaqOfficeXPUIStyle.DoDrawCaptionButton(ACanvas: TCanvas;
  ARect: TRect; AState: TaqDockButtonState;
  ACaptionState: TaqDockCaptionState; AKind: TaqDockButtonKind);
begin
  if FSchemeTint = ostFancy then
  begin
    if (AState = dbsHot) and (ACaptionState <> dcsFocused) then
      ActiveCaptionColor.Fill(ACanvas, ARect, ARect)
    else if AState = dbsPressed then
      DownColor.Fill(ACanvas, ARect, ARect);

    ACanvas.Brush.Style := bsClear;
    if AState in [dbsHot, dbsPressed] then
    begin
      if ACaptionState = dcsFocused then
        ACanvas.Pen.Color := ActiveCaptionFont.Color
      else
        ACanvas.Pen.Color := CaptionFont.Color;
      ACanvas.Pen.Style := psSolid;
      ACanvas.Rectangle(ARect);
    end;
  end
  else
  begin
    if ACaptionState = dcsFocused then
      ACanvas.Pen.Color := ActiveCaptionFont.Color
    else
      ACanvas.Pen.Color := clActiveCaption;

    if AState in [dbsHot, dbsPressed] then
    begin
      if ACaptionState <> dcsFocused then
      begin
        ACanvas.Brush.Style := bsSolid;
        ACanvas.Brush.Color := FCaptionButtonSelColor;
      end
      else
        ACanvas.Brush.Style := bsClear;
      ACanvas.Pen.Style := psSolid;
      ACanvas.Rectangle(ARect);
    end;
  end;

  InflateRect(ARect, -1, -1);
  DoDrawCaptionButtonWidget(ACanvas, ARect, AState, ACaptionState, AKind);
end;

procedure TaqOfficeXPUIStyle.DoDrawHiddenTabItem(ACanvas: TCanvas;
  ARect: TRect; const AText: string; AState: TaqTabItemState;
  AOrientation: TaqHideZoneOrientation; APosition: TaqTabItemPosition;
  ADrawImage, ADrawText: Boolean; AImages: TCustomImageList;
  AImageIndex: Integer);
const
  Borders: array [TaqHideZoneOrientation] of TaqEdgeBorders = (
    // hzoLeft, hzoTop, hzoRight, hzoBottom, hzoDefault
    [ebTop, ebRight, ebBottom], [ebBottom, ebLeft, ebRight],
    [ebTop, ebLeft, ebBottom], [ebTop, ebLeft, ebRight], []
  );
  Orientations: array [TaqHideZoneOrientation] of TaqOrientation =
    // hzoLeft, hzoTop, hzoRight, hzoBottom, hzoDefault
    (orLeft, orBottom, orRight, orTop, orLeft);
var
  SwapColors: Boolean;
  FillRect: TRect;
  TabBorders: TaqEdgeBorders;
  TbColor: TGradient;
begin
  case AOrientation of
    hzoTop:
      Dec(ARect.Bottom, FMetrics[dumTabTopOffset]);
    hzoBottom:
      Inc(ARect.Top, FMetrics[dumTabTopOffset]);
    hzoLeft:
      Dec(ARect.Right, FMetrics[dumTabTopOffset]);
    hzoRight:
      Inc(ARect.Left, FMetrics[dumTabTopOffset]);
  end;

  FillRect := ARect;
  if (APosition = tipFirst) or (AState in [tisFocused, tisSelected]) then
    if AOrientation in [hzoTop, hzoBottom] then
      Inc(FillRect.Left)
    else
      Inc(FillRect.Top);

  case AOrientation of
    hzoTop:
      Dec(FillRect.Bottom);
    hzoBottom:
      Inc(FillRect.Top);
    hzoLeft:
      Dec(FillRect.Right);
    hzoRight:
      Inc(FillRect.Left);
  end;

  if AState in [tisSelected, tisFocused] then
    TbColor := ActiveHiddenTabColor
  else
    TbColor := HiddenTabColor;
  if AOrientation in [hzoTop, hzoLeft] then
    SwapColors := False
  else if AOrientation = hzoBottom then
    SwapColors := TbColor.FillType = gtVertical
  else
    SwapColors := TbColor.FillType = gtHorizontal;
  TbColor.Fill(ACanvas, FillRect, FillRect, SwapColors);

  if AOrientation in [hzoTop, hzoBottom] then
    Inc(ARect.Right)
  else
    Inc(ARect.Bottom);
  DoDrawTabItemContent(ACanvas, FillRect, AText, AState,
    Orientations[AOrientation], ADrawImage, ADrawText, HiddenTabFont,
    ActiveHiddenTabFont, AImages, AImageIndex, False);
  ACanvas.Pen.Style := psSolid;

  TabBorders := Borders[AOrientation];
  if (APosition <> tipFirst) and (not (AState in [tisFocused, tisSelected])) then
  begin
    case AOrientation of
      hzoTop:
      begin
        Exclude(TabBorders, ebLeft);
        Inc(ARect.Left);
        ACanvas.Pixels[ARect.Left - 1, ARect.Top + 1] := DarkColor(TabColor.StartColor);
      end;
      hzoBottom:
      begin
        Exclude(TabBorders, ebLeft);
        Inc(ARect.Left);
        ACanvas.Pixels[ARect.Left - 1, ARect.Bottom - 1] := DarkColor(TabColor.StartColor);
      end;

⌨️ 快捷键说明

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