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

📄 aqdockinguistandard.pas

📁 AutomatedDocking Library 控件源代码修改 适合Delphi 2009 和C++ Builder 20009 使用。 修正汉字不能正确显示问题
💻 PAS
字号:
{*******************************************************************}
{                                                                   }
{       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 aqDockingUIStandard;

{$I aqDockingVer.inc}

interface

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

type
  TaqStandardUIStyle = class(TaqDefaultUIStyle)
  protected
    { TaqDockingUIStyle }
    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;
  public
    constructor Create(AOwner: TComponent); override;
  end;

implementation

uses
  SysUtils,
{$IFDEF VCL}
  Windows,
{$ENDIF}
  Math;

{ TaqStandardUIStyle }

procedure TaqStandardUIStyle.DoDrawCaptionButton(ACanvas: TCanvas;
  ARect: TRect; AState: TaqDockButtonState; ACaptionState: TaqDockCaptionState;
  AKind: TaqDockButtonKind);
const
  EdgeStyles: array [Boolean, TaqDockButtonState] of TaqEdgeStyle = (
    // inner
    // tbsNormal, tbsHot, tbsPressed, tbsDisabled
    (esRaised, esRaised, esLowered, esRaised),
    // outer
    (esNone, esNone, esNone, esNone));
begin
  ACanvas.Pen.Style := psSolid;
  aqUIHelpers.DrawEdge(ACanvas, ARect, EdgeStyles[False, AState], EdgeStyles[True, AState],
    ebRect);
  InflateRect(ARect, -1, -1);

  DoDrawCaptionButtonWidget(ACanvas, ARect, AState, ACaptionState, AKind);
end;

procedure TaqStandardUIStyle.DoDrawCaption(ACanvas: TCanvas;
  ARect: TRect; const ACaption: string; AState: TaqDockCaptionState;
  AMaxCaptionWidth: Integer; var AFitCaption: Boolean; ADrawImage: Boolean;
  AImages: TCustomImageList; AImageIndex: Integer);
begin
  inherited DoDrawCaption(ACanvas, ARect, ACaption, AState, AMaxCaptionWidth,
    AFitCaption, ADrawImage, AImages, AImageIndex);
end;

procedure TaqStandardUIStyle.DoDrawTabButton(ACanvas: TCanvas;
  ARect: TRect; AState: TaqTabButtonState;
  AKind: TaqTabButtonKind);
const
  BtnEdgeStyles: array [Boolean, TaqTabButtonState] of TaqEdgeStyle = (
    // inner
    // tbsNormal, tbsHot, tbsPressed, tbsDisabled
    (esRaised, esRaised, esLowered, esRaised),
    // outer
    (esRaised, esRaised, esLowered, esRaised));
begin
  if AKind = tbkClose then
  begin
    if FLastTabState in [tisSelected, tisFocused] then
      OffsetRect(ARect, -1, 0); // raise active tab
    ARect.Top := FLastTabTextRect.Top;
    ARect.Bottom := FLastTabTextRect.Bottom;
  end
  else
  begin
    with ACanvas do
    begin
      Brush.Style := bsSolid;
      Brush.Color := TabPaneColor.StartColor;
      FillRect(ARect);
    end;
    aqUIHelpers.DrawEdge(ACanvas, ARect, BtnEdgeStyles[False, AState],
      BtnEdgeStyles[True, AState], ebRect);
    InflateRect(ARect, -2, -2);
  end;
  DoDrawTabButtonWidget(ACanvas, ARect, AState, AKind);
end;

procedure TaqStandardUIStyle.DoDrawTabItem(ACanvas: TCanvas;
  ARect: TRect; const ACaption: string; AState: TaqTabItemState;
  APosition: TaqTabItemPosition; AOrientation: TaqOrientation;
  AButtonAreaWidthBefore: Integer; AButtonAreaWidthAfter: Integer;
  ADrawImage: Boolean; AImages: TCustomImageList; AImageIndex: Integer);
var
  Pad: Integer;
  pts: array[0..4] of TPoint;
  SwapColors: Boolean;
  TbColor: TGradient;
  FillRect: TRect;
  ActiveTab: Boolean;
begin
  Pad := Metrics[dumTabPadding];
  ActiveTab := AState in [tisSelected, tisFocused];

  if AOrientation = orTop then
  begin
    if ActiveTab then
    begin
      Inc(ARect.Top);
      Dec(ARect.Left, 2) // raise active tab
    end
    else
    begin
      Dec(ARect.Bottom, Pad);
      Inc(ARect.Top, FMetrics[dumTabTopOffset]);
      Dec(ARect.Bottom);
    end;
  end
  else
  begin
    if ActiveTab then
    begin
      Dec(ARect.Bottom);
      Dec(ARect.Left, 2);
    end
    else
    begin
      Inc(ARect.Top, Pad);
      Dec(ARect.Bottom, FMetrics[dumTabTopOffset]);
    end;
  end;

  FillRect := ARect;
  Inc(FillRect.Left, 2); Dec(FillRect.Right);
  if AOrientation = orTop then
  begin
    Inc(FillRect.Top);
    if ActiveTab then
      Inc(FillRect.Bottom);
  end
  else
    Dec(FillRect.Bottom);

  if ActiveTab then
    TbColor := ActiveTabColor
  else
    TbColor := TabColor;
  if AOrientation = orTop then
    SwapColors := False
  else
    SwapColors := TbColor.FillType = gtVertical;
  TbColor.Fill(ACanvas, FillRect, FillRect, SwapColors);

  ACanvas.Brush.Style := bsClear;
  ACanvas.Pen.Style := psSolid;
  ACanvas.Pen.Width := 1;

  if AOrientation = orTop then
  begin
    ACanvas.Pen.Color := LightColor(TbColor.StartColor);
    pts[0].X := ARect.Left + 1;
    pts[0].Y := ARect.Bottom;
    if ActiveTab then
      Dec(pts[0].Y, Pad);
    pts[1].X := ARect.Left + 1;
    pts[1].Y := ARect.Top + 1;
    pts[2].X := ARect.Right - 1;
    pts[2].Y := ARect.Top + 1;
    ACanvas.Polyline(Slice(pts, 3));

    ACanvas.Pen.Color := LightLightColor(TbColor.StartColor);
    pts[0].X := ARect.Left;
    pts[0].Y := ARect.Bottom;
    if ActiveTab then
      Dec(pts[0].Y, Pad);
    pts[1].X := ARect.Left;
    pts[1].Y := ARect.Top + 2;
    pts[2].X := ARect.Left + 2;
    pts[2].Y := ARect.Top;
    pts[3].X := ARect.Right - 2;
    pts[3].Y := ARect.Top;
    pts[4].X := ARect.Right;
    pts[4].Y := ARect.Top + 2;
    ACanvas.Polyline(pts);

    ACanvas.Pen.Color := DarkDarkColor(TbColor.StartColor);
    ACanvas.MoveTo(ARect.Right, ARect.Top + 2);
    if ActiveTab then
      ACanvas.LineTo(ARect.Right, ARect.Bottom - Pad + 1)
    else ACanvas.LineTo(ARect.Right, ARect.Bottom + 1);

    ACanvas.Pen.Color := DarkColor(TbColor.StartColor);
    ACanvas.MoveTo(ARect.Right - 1, ARect.Top + 1);
    if ActiveTab then
      ACanvas.LineTo(ARect.Right - 1, ARect.Bottom - Pad + 1)
    else ACanvas.LineTo(ARect.Right - 1, ARect.Bottom + 1);
  end
  else
  begin
    ACanvas.Pen.Color := LightLightColor(TbColor.StartColor);
    if ActiveTab then
      ACanvas.MoveTo(ARect.Left, ARect.Top + Pad - 1)
    else ACanvas.MoveTo(ARect.Left, ARect.Top);
    ACanvas.LineTo(ARect.Left, ARect.Bottom - 2);
    ACanvas.Pen.Color := LightColor(TbColor.StartColor);
    if ActiveTab then
      ACanvas.MoveTo(ARect.Left + 1, ARect.Top + Pad - 1)
    else ACanvas.MoveTo(ARect.Left + 1, ARect.Top);
    ACanvas.LineTo(ARect.Left + 1, ARect.Bottom - 2);

    ACanvas.Pen.Color := DarkDarkColor(TbColor.StartColor);
    pts[0].X := ARect.Left;
    pts[0].Y := ARect.Bottom - 2;
    pts[1].X := ARect.Left + 2;
    pts[1].Y := ARect.Bottom;
    pts[2].X := ARect.Right - 2;
    pts[2].Y := ARect.Bottom;
    pts[3].X := ARect.Right;
    pts[3].Y := ARect.Bottom - 2;
    pts[4].X := ARect.Right;
    if ActiveTab then
      pts[4].Y := ARect.Top + Pad - 1
    else pts[4].Y := ARect.Top - 1;
    ACanvas.Polyline(pts);

    ACanvas.Pen.Color := DarkColor(TbColor.StartColor);
    pts[0].X := ARect.Left + 1;
    pts[0].Y := ARect.Bottom - 2;
    pts[1].X := ARect.Left + 2;
    pts[1].Y := ARect.Bottom - 1;
    pts[2].X := ARect.Right - 2;
    pts[2].Y := ARect.Bottom - 1;
    pts[3].X := ARect.Right - 1;
    pts[3].Y := ARect.Bottom - 2;
    pts[4].X := ARect.Right - 1;
    if ActiveTab then
      pts[4].Y := ARect.Top
    else pts[4].Y := ARect.Top - 1;
    ACanvas.Polyline(pts);
  end;

  Inc(FillRect.Left, AButtonAreaWidthBefore);
  Dec(FillRect.Right, AButtonAreaWidthAfter);
  DoDrawTabItemContent(ACanvas, FillRect, ACaption, AState,
    AOrientation, ADrawImage, True, TabFont, ActiveTabFont, AImages, AImageIndex, True);
end;

procedure TaqStandardUIStyle.DoDrawTabPane(ACanvas: TCanvas;
  ARect: TRect; AOrientation: TaqTabOrientation);
begin
  inherited;

end;

constructor TaqStandardUIStyle.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FMetrics[dumTabTopOffset] :=  3;
  FMetrics[dumTabItemBorderX] := 2;
  FMetrics[dumTabItemBorderY] := 2;

  TabPaneColor.StartColor := clBtnFace;
  TabPaneColor.FillType := gtSolid;

  TabColor.StartColor := clBtnFace;
  TabColor.FillType := gtSolid;
end;

procedure TaqStandardUIStyle.DoDrawSplitter(ACanvas: TCanvas;
  ARect: TRect; AOrientation: TaqSplitterOrientation);
begin
  ACanvas.Brush.Style := bsSolid;
  ACanvas.Brush.Color := SplitterColor;
  ACanvas.FillRect(ARect);
end;

end.

⌨️ 快捷键说明

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