📄 aqdockinguiflat.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 aqDockingUIFlat;
{$I aqDockingVer.inc}
interface
uses
Types, Classes,
{$IFDEF VCL}
Windows, Graphics, ImgList,
{$ELSE}
QGraphics, QImgList,
{$ENDIF}
aqUIHelpers, aqDockingUI, aqDockingUIDefault;
type
TaqFlatUIStyle = class(TaqDefaultUIStyle)
protected
function GetCaptionButtonSelColor: TColorRef; 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 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
Math;
{ TaqFlatUIStyle }
constructor TaqFlatUIStyle.Create(AOwner: TComponent);
begin
inherited;
ActiveCaptionFont.Color := clCaptionText;
ActiveCaptionColor.StartColor := clActiveCaption;
TabPaneColor.StartColor := NETBackColor(ActiveTabColor.StartColor);
TabColor.StartColor := TabPaneColor.StartColor;
end;
procedure TaqFlatUIStyle.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);
if AState <> dcsFocused then
begin
Dec(ARect.Bottom); Dec(ARect.Right);
ACanvas.Pen.Style := psSolid;
ACanvas.Pen.Color := DarkColor(Color.StartColor);
ACanvas.MoveTo(ARect.Left + 1, ARect.Top);
ACanvas.LineTo(ARect.Right, ARect.Top);
ACanvas.MoveTo(ARect.Right, ARect.Top + 1);
ACanvas.LineTo(ARect.Right, ARect.Bottom);
ACanvas.MoveTo(ARect.Right - 1, ARect.Bottom);
ACanvas.LineTo(ARect.Left, ARect.Bottom);
ACanvas.MoveTo(ARect.Left, ARect.Bottom - 1);
ACanvas.LineTo(ARect.Left, ARect.Top);
Inc(ARect.Bottom); Inc(ARect.Right);
end;
InflateRect(ARect, -1, -1);
DoDrawCaptionContent(ACanvas, ARect, ACaption, AState, AMaxCaptionWidth, AFitCaption,
ADrawImage, AImages, AImageIndex);
end;
procedure TaqFlatUIStyle.DoDrawCaptionButton(ACanvas: TCanvas;
ARect: TRect; AState: TaqDockButtonState;
ACaptionState: TaqDockCaptionState; AKind: TaqDockButtonKind);
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 := 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 TaqFlatUIStyle.DoDrawSplitter(ACanvas: TCanvas;
ARect: TRect; AOrientation: TaqSplitterOrientation);
begin
ACanvas.Brush.Style := bsSolid;
ACanvas.Brush.Color := SplitterColor;
ACanvas.FillRect(ARect);
end;
procedure TaqFlatUIStyle.DoDrawTabButton(ACanvas: TCanvas;
ARect: TRect; AState: TaqTabButtonState;
AKind: TaqTabButtonKind);
const
EdgeStyles: array [TaqTabButtonState] of TaqEdgeStyle = (
// tbsNormal, tbsHot, tbsPressed, tbsDisabled
esNone, esFlat, esFlat, esNone);
begin
if AKind = tbkClose then
begin
OffsetRect(ARect, 1, 0);
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;
DrawEdge(ACanvas, ARect, EdgeStyles[AState], esNone, ebRect);
InflateRect(ARect, -1, -1);
end;
DoDrawTabButtonWidget(ACanvas, ARect, AState, AKind);
end;
procedure TaqFlatUIStyle.DoDrawTabItem(ACanvas: TCanvas;
ARect: TRect; const ACaption: string; AState: TaqTabItemState;
APosition: TaqTabItemPosition; AOrientation: TaqOrientation;
AButtonAreaWidthBefore: Integer; AButtonAreaWidthAfter: Integer;
ADrawImage: Boolean; AImages: TCustomImageList; AImageIndex: Integer);
const
Borders: array [TaqOrientation] of TaqEdgeBorders = (
[], [ebTop, ebLeft, ebRight], [], [ebBottom, ebLeft, ebRight]
);
var
ActiveTab, SwapColors: Boolean;
Pad: Integer;
TbColor: TGradient;
FillRect: TRect;
begin
Pad := Metrics[dumTabPadding];
ActiveTab := AState in [tisSelected, tisFocused];
if AOrientation = orTop then
begin
if ActiveTab then
begin
Inc(ARect.Top, 2);
Dec(ARect.Left);
Dec(ARect.Bottom, Pad - 1);
end
else
begin
Dec(ARect.Bottom, Pad + 1);
Inc(ARect.Top, FMetrics[dumTabTopOffset]);
end;
end
else
begin
if ActiveTab then
begin
Inc(ARect.Top, Pad - 1);
Dec(ARect.Bottom, 2);
Dec(ARect.Left);
end
else
begin
Inc(ARect.Top, Pad);
Dec(ARect.Bottom, FMetrics[dumTabTopOffset]);
end;
end;
FillRect := ARect;
Inc(FillRect.Left); Dec(FillRect.Right);
if AOrientation = orTop then
begin
Inc(FillRect.Top);
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.Pen.Style := psSolid;
if ActiveTab then
DrawEdge(ACanvas, ARect, esNone, esRaised, Borders[AOrientation], TbColor.StartColor)
else
begin
ACanvas.Pen.Color := DarkColor(TbColor.StartColor);
ACanvas.MoveTo(ARect.Right, ARect.Top + 2);
ACanvas.LineTo(ARect.Right, ARect.Bottom - 1);
end;
if ActiveTab then
Inc(FillRect.Left);
Inc(FillRect.Left, AButtonAreaWidthBefore);
Dec(FillRect.Right, AButtonAreaWidthAfter);
DoDrawTabItemContent(ACanvas, FillRect, ACaption, AState,
AOrientation, ADrawImage, True, TabFont, ActiveTabFont, AImages, AImageIndex, True);
end;
procedure TaqFlatUIStyle.DoDrawTabPane(ACanvas: TCanvas;
ARect: TRect; AOrientation: TaqTabOrientation);
const
PaddingEdges: array [TaqTabOrientation, Boolean] of TaqEdgeStyle = (
// Inner, Outer
(esNone, esRaised), // dtoTop
(esNone, esRaised)); // dtoBottom
PaddingBorders: array [TaqTabOrientation] of TaqEdgeBorders = (
[ebTop], // dtoTop
[ebBottom] // dtoBottom
);
PaneEdges: array [Boolean] of TaqEdgeStyle = (
// Inner, Outer
esLowered, esNone);
PaneBorders: array [TaqTabOrientation] of TaqEdgeBorders = (
[ebTop, ebLeft, ebRight], // dtoTop
[ebBottom, ebLeft, ebRight] // dtoBottom
);
var
PadArea, PaneArea: TRect;
begin
// Draw padding area.
PadArea := ARect;
case AOrientation of
dtoTop: PadArea.Top := ARect.Bottom - Metrics[dumTabPadding];
dtoBottom: PadArea.Bottom := ARect.Top + Metrics[dumTabPadding];
end;
if ActiveTabColor.FillType = gtHorizontal then
ACanvas.Brush.Color := ActiveTabColor.EndColor
else
ACanvas.Brush.Color := ActiveTabColor.StartColor;
ACanvas.Brush.Style := bsSolid;
ACanvas.FillRect(PadArea);
DrawEdge(ACanvas, PadArea, PaddingEdges[AOrientation, False],
PaddingEdges[AOrientation, True], PaddingBorders[AOrientation], ACanvas.Brush.Color);
// Draw tab pane.
SubtractRect(PaneArea, ARect, PadArea);
DrawEdge(ACanvas, PaneArea, PaneEdges[False],
PaneEdges[True], PaneBorders[AOrientation], TabPaneColor.StartColor);
InflateRect(PaneArea, -1, -1);
case AOrientation of
dtoTop: Inc(PaneArea.Bottom, 1);
dtoBottom: Dec(PaneArea.Top, 1);
end;
DoDrawTabPaneContent(ACanvas, PaneArea, Orientations[AOrientation]);
end;
function TaqFlatUIStyle.GetCaptionButtonSelColor: TColorRef;
begin
Result := GetRealColor(GetComplexColor(CaptionColor.StartColor, clHighlight, clWindow, -2, 30, 72));
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -