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

📄 aqdockinguivs2005.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 aqDockingUIVS2005;


{$I aqDockingVer.inc}

interface

uses
  Windows, Classes, Graphics, ImgList,
  aqDockingUI, aqDockingUtils, aqUIHelpers, aqDockingUIDefault;

type
  TaqVS2005UIDockingStyle = class(TaqDefaultUIStyle)
  private
    FActiveTriangleTabFont: TFont;
    FActiveTriangleTabColor: TGradient;
    FTriangleTabFont: TFont;
    FTriangleTabColor: TGradient;
    procedure SetActiveTriangleTabFont(const Value: TFont);
    procedure SetActiveTriangleTabColor(const Value: TGradient);
    procedure SetTriangleTabFont(const Value: TFont);
    procedure SetTriangleTabColor(const Value: TGradient);
    function GetGradientColor(const Gradient: TGradient): TColor;
    procedure GradientChange(Sender: TObject);
    procedure FontChange(Sender: TObject);
  protected
    function GetCaptionButtonSelColor: TColorRef; virtual;
    procedure AssignTo(Dest: TPersistent); override;

    { TaqDockingUIStyle }
    function GetCaptionButtonsPosition: TaqCaptionButtonPostions; override;

     // High-level drawing routines
    procedure DoDrawControl(ACanvas: TCanvas; ARect: TRect;
      AKind: TaqDockControlDrawKind); override;
    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 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 DoDrawHiddenTabItem(ACanvas: TCanvas; ARect: TRect;
      const AText: string; AState: TaqTabItemState;
      AOrientation: TaqHideZoneOrientation; APosition: TaqTabItemPosition; ADrawImage, ADrawText: Boolean;
      AImages: TCustomImageList; AImageIndex: Integer); override;

    function DoGetTabWidth(const AText: string; AState: TaqTabItemState;
      APosition: TaqTabItemPosition; AOrientation: TaqTabOrientation; AButtonAreaWidth: Integer;
      ADrawImage: Boolean; AImages: TCustomImageList; AImageIndex: Integer): Integer; override;
    function DoGetTabHeight(AState: TaqTabItemState;
      AOrientation: TaqTabOrientation; ADrawImage: Boolean;
      AImages: TCustomImageList; AImageIndex: Integer): Integer; override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property ActiveTriangleTabFont: TFont read FActiveTriangleTabFont write SetActiveTriangleTabFont;
    property ActiveTriangleTabColor: TGradient read FActiveTriangleTabColor write SetActiveTriangleTabColor;
    property TriangleTabFont: TFont read FTriangleTabFont write SetTriangleTabFont;
    property TriangleTabColor: TGradient read FTriangleTabColor write SetTriangleTabColor;
  end;

implementation

uses
  Menus,
  Math,
  SysUtils,
  Types;

{ TaqVS2005UIDockingStyle }

constructor TaqVS2005UIDockingStyle.Create(AOwner: TComponent);
const
  LightPercent = 87;
begin
  inherited;
  ActiveCaptionFont.Color := clCaptionText;
  ActiveCaptionColor.StartColor := clActiveCaption;
  ActiveCaptionColor.EndColor := LightColorBy(clActiveCaption, LightPercent);
  ActiveCaptionColor.FillType := gtVertical;
  CaptionFont.Color := clInactiveCaptionText;
  CaptionColor.StartColor := clInactiveCaption;
  CaptionColor.EndColor := LightColorBy(clInactiveCaption, LightPercent);
  CaptionColor.FillType := gtVertical;
  TabPaneColor.StartColor := clBtnFace;
  TabPaneColor.EndColor := LightColorBy(clBtnFace, LightPercent);
  TabPaneColor.FillType := gtHorizontal;
  FTriangleTabColor := TGradient.Create;
  FTriangleTabColor.StartColor := clBtnHighlight;
  FTriangleTabColor.EndColor := LightColorBy(clBtnFace, LightPercent);
  FTriangleTabColor.FillType := gtVertical;
  FTriangleTabColor.OnChange := GradientChange;
  FActiveTriangleTabColor := TGradient.Create;
  FActiveTriangleTabColor.StartColor := clBtnHighlight;
  FActiveTriangleTabColor.EndColor := clBtnHighlight;
  FActiveTriangleTabColor.FillType := gtSolid;
  FActiveTriangleTabColor.OnChange := GradientChange;

  TabIndent := 5;
  TabColor.StartColor := clBtnFace;
  TabFont.Size := 6;
  TabFont.Color := clGrayText;
  ActiveTabColor.StartColor := clBtnHighlight;
  ActiveTabFont.Size := 6;
  ActiveTabFont.Color := clBtnText;
  ActiveTabFont.Style := [];
  FActiveTriangleTabFont := TFont.Create;
  FActiveTriangleTabFont.Assign(ActiveTabFont);
  FActiveTriangleTabFont.Style := [fsBold];
  FActiveTriangleTabFont.OnChange := FontChange;
  FTriangleTabFont := TFont.Create;
  FTriangleTabFont.Assign(ActiveTabFont);
  FTriangleTabFont.OnChange := FontChange;
  FHotTrack := False;
end;

destructor TaqVS2005UIDockingStyle.Destroy;
begin
  Images := nil;
  FreeAndNil(FActiveTriangleTabColor);
  FreeAndNil(FActiveTriangleTabFont);
  FreeAndNil(FTriangleTabColor);
  FreeAndNil(FTriangleTabFont);
  inherited;
end;

procedure TaqVS2005UIDockingStyle.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);
  InflateRect(ARect, 0, -1);
  if AState = dcsFocused then
    Color := ActiveCaptionColor
  else
    Color := CaptionColor;
  Color.Fill(ACanvas, ARect, ARect);

  Dec(ARect.Bottom);
  Dec(ARect.Right);
  ACanvas.Pen.Style := psSolid;
  ACanvas.Pen.Color := clBtnShadow;

  ACanvas.MoveTo(ARect.Left, ARect.Top);
  ACanvas.LineTo(ARect.Right, ARect.Top);
  ACanvas.MoveTo(ARect.Right, ARect.Top);
  ACanvas.LineTo(ARect.Right, ARect.Bottom + 2);
  ACanvas.MoveTo(ARect.Left, ARect.Bottom + 2);
  ACanvas.LineTo(ARect.Left, ARect.Top);
  Inc(ARect.Bottom);
  Inc(ARect.Right);

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

procedure TaqVS2005UIDockingStyle.DoDrawCaptionButton(ACanvas: TCanvas;
  ARect: TRect; AState: TaqDockButtonState;
  ACaptionState: TaqDockCaptionState; AKind: TaqDockButtonKind);
begin
  if AKind = dbkCustom then
  begin
    inherited;
    exit;
  end;

  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 := GetCaptionButtonSelColor;
    end
    else
      ACanvas.Brush.Style := bsClear;
    ACanvas.Pen.Style := psSolid;
    ACanvas.Rectangle(ARect);
  end;

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

procedure TaqVS2005UIDockingStyle.DoDrawControl(ACanvas: TCanvas; ARect: TRect;
  AKind: TaqDockControlDrawKind);
begin
  ACanvas.Brush.Style := bsSolid;
  ACanvas.Brush.Color := clBtnHighlight;
  ACanvas.Pen.Style := psSolid;
  ACanvas.Pen.Color := clBtnShadow;
  ACanvas.Rectangle(ARect.Left, ARect.Top - 2, ARect.Right, ARect.Bottom);
end;

procedure TaqVS2005UIDockingStyle.DoDrawHiddenTabItem(ACanvas: TCanvas;
  ARect: TRect; const AText: string; AState: TaqTabItemState;
  AOrientation: TaqHideZoneOrientation; APosition: TaqTabItemPosition;
  ADrawImage, ADrawText: Boolean; AImages: TCustomImageList;
  AImageIndex: Integer);
const
  TabStates                                                 : array[TaqTabItemState] of TaqTabItemState =
    // htsNormal, htsHot, htsSelected, htsDisabled, htsFocused
  (tisNormal, tisHot, tisSelected, tisDisabled, tisFocused);
var
  TopIndent                                                 : Integer;
  FillRect                                                  : TRect;
  SwapColors                                                : Boolean;
  TbColor                                                   : TGradient;
  ActiveTab                                                 : Boolean;
begin
  TopIndent := 2;
  ActiveTab := AState in [tisSelected, tisFocused];
  if ActiveTab then
    TbColor := ActiveHiddenTabColor
  else
    TbColor := HiddenTabColor;
  ACanvas.Pen.Style := psSolid;
  if ActiveTab then
  begin
    FillRect := ARect;
    ACanvas.Pen.Color := clBtnShadow;
    ACanvas.Brush.Color := clBtnFace;
    case AOrientation of
      hzoTop:
        begin
          Dec(FillRect.Bottom, TopIndent);
          ACanvas.RoundRect(FillRect.Left, FillRect.Top, FillRect.Right, FillRect.Bottom, 2, 2);
          Dec(FillRect.Bottom);
        end;
      hzoBottom:
        begin
          Inc(FillRect.Top, TopIndent);
          ACanvas.RoundRect(FillRect.Left, FillRect.Top, FillRect.Right, FillRect.Bottom, 2, 2);
          Inc(FillRect.Top);
        end;
      hzoLeft:
        begin
          Dec(FillRect.Right, TopIndent);
          ACanvas.RoundRect(FillRect.Left - 2, FillRect.Top, FillRect.Right, FillRect.Bottom, 2, 2);
          Dec(FillRect.Right);
        end;
      hzoRight:
        begin
          Inc(FillRect.Left, TopIndent);
          ACanvas.RoundRect(FillRect.Left, FillRect.Top, FillRect.Right + 2, FillRect.Bottom, 2, 2);
          Inc(FillRect.Left);
        end;
    end;
    if AOrientation in [hzoTop, hzoBottom] then
      InflateRect(FillRect, -1, 0)
    else
      InflateRect(FillRect, 0, -1);
  end
  else
  begin
    ACanvas.Pen.Color := DarkColor(TbColor.StartColor);
    case AOrientation of
      hzoTop:
        FillRect := Rect(ARect.Left - 1, ARect.Top, ARect.Right, ARect.Bottom - TopIndent);
      hzoBottom:
        FillRect := Rect(ARect.Left - 1, ARect.Top + TopIndent, ARect.Right, ARect.Bottom);
      hzoLeft:
        FillRect := Rect(ARect.Left, ARect.Top - 1, ARect.Right - TopIndent, ARect.Bottom);
      hzoRight:
        FillRect := Rect(ARect.Left + TopIndent, ARect.Top - 1, ARect.Right, ARect.Bottom);
    end;
    if AOrientation in [hzoTop, hzoBottom] then
    begin
      ACanvas.MoveTo(FillRect.Right - 1, FillRect.Top);
      ACanvas.LineTo(FillRect.Right - 1, FillRect.Bottom);
      Dec(FillRect.Right);
    end
    else
    begin
      ACanvas.MoveTo(FillRect.Left, FillRect.Bottom - 1);
      ACanvas.LineTo(FillRect.Right, FillRect.Bottom - 1);
      Dec(FillRect.Bottom);
    end;
  end;
  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);

⌨️ 快捷键说明

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