git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.DevExpressVCL@21 05c56307-c608-d34a-929d-697000501d7a
793 lines
27 KiB
ObjectPascal
793 lines
27 KiB
ObjectPascal
{********************************************************************}
|
|
{ }
|
|
{ Developer Express Visual Component Library }
|
|
{ ExpressSkins Library }
|
|
{ }
|
|
{ Copyright (c) 2006-2007 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 EXPRESSSKINS 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 dxSkinsdxDockControlPainter;
|
|
|
|
{$I cxVer.inc}
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Classes, Graphics, cxGraphics, dxDockControl, dxDockControlXPView,
|
|
dxSkinsCore, dxSkinsLookAndFeelPainter, cxLookAndFeels, cxLookAndFeelPainters,
|
|
Math, cxGeometry, dxDockControlOfficeView;
|
|
|
|
type
|
|
|
|
{ TdxDockControlSkinPainter }
|
|
|
|
TdxDockControlSkinPainter = class(TdxDockControlXPPainter)
|
|
protected
|
|
function DrawCaptionFirst: Boolean; override;
|
|
function GetCaptionFontColor(IsActive: Boolean): TColor; override;
|
|
function GetCaptionRect(const ARect: TRect; AIsVertical: Boolean): TRect; override;
|
|
function GetHideBarButtonFontColor: TColor; override;
|
|
function GetSkinLookAndFeelPainter: TcxCustomLookAndFeelPainterClass;
|
|
function GetSkinPainterData(var AData: TdxSkinLookAndFeelPainterInfo): Boolean;
|
|
function GetTabFontColor(IsActive: Boolean): TColor; override;
|
|
function GetTopBorderSize: Integer;
|
|
function InternalDrawCaptionButton(ACanvas: TCanvas; AGlyphIndex: Integer;
|
|
ARect: TRect; IsActive, IsDown, IsHot, IsSwitched: Boolean): Boolean;
|
|
function InternalDrawTabButton(ACanvas: TCanvas; ARect: TRect;
|
|
IsDown, IsHot, IsEnable, IsNextButton: Boolean): Boolean;
|
|
public
|
|
// Custom
|
|
function CanVerticalCaption: Boolean; override;
|
|
procedure DrawBorder(ACanvas: TCanvas; ARect: TRect); override;
|
|
procedure DrawCaption(ACanvas: TCanvas; ARect: TRect; IsActive: Boolean); override;
|
|
procedure DrawCaptionCloseButton(ACanvas: TCanvas; ARect: TRect; IsActive,
|
|
IsDown, IsHot, IsSwitched: Boolean); override;
|
|
procedure DrawCaptionHideButton(ACanvas: TCanvas; ARect: TRect;IsActive,
|
|
IsDown, IsHot, IsSwitched: Boolean); override;
|
|
procedure DrawCaptionMaximizeButton(ACanvas: TCanvas; ARect: TRect; IsActive,
|
|
IsDown, IsHot, IsSwitched: Boolean); override;
|
|
procedure DrawCaptionSeparator(ACanvas: TCanvas; ARect: TRect); override;
|
|
procedure DrawCaptionText(ACanvas: TCanvas; ARect: TRect; IsActive: Boolean); override;
|
|
procedure DrawClient(ACanvas: TCanvas; ARect: TRect); override;
|
|
function GetBorderWidth: Integer; override;
|
|
function GetCaptionButtonSize: Integer; override;
|
|
function GetCaptionHorizInterval: Integer; override;
|
|
// TabContainer
|
|
procedure CorrectTabRect(var ATab: TRect; APosition: TdxTabContainerTabsPosition;
|
|
AIsActive: Boolean); override;
|
|
function DrawActiveTabLast: Boolean; override;
|
|
procedure DrawTab(ACanvas: TCanvas; AControl: TdxCustomDockControl;
|
|
ARect: TRect; IsActive: Boolean; APosition: TdxTabContainerTabsPosition); override;
|
|
procedure DrawTabContent(ACanvas: TCanvas; AControl: TdxCustomDockControl;
|
|
ARect: TRect; IsActive: Boolean; APosition: TdxTabContainerTabsPosition); override;
|
|
procedure DrawTabs(ACanvas: TCanvas; ARect, AActiveTabRect: TRect;
|
|
APosition: TdxTabContainerTabsPosition); override;
|
|
procedure DrawTabsNextTabButton(ACanvas: TCanvas; ARect: TRect;
|
|
IsDown, IsHot, IsEnable: Boolean; APosition: TdxTabContainerTabsPosition); override;
|
|
procedure DrawTabsPrevTabButton(ACanvas: TCanvas; ARect: TRect;
|
|
IsDown, IsHot, IsEnable: Boolean; APosition: TdxTabContainerTabsPosition); override;
|
|
function GetTabHorizInterval: Integer; override;
|
|
function GetTabHorizOffset: Integer; override;
|
|
function GetTabsHeight: Integer; override;
|
|
function GetTabVertInterval: Integer; override;
|
|
function GetTabVertOffset: Integer; override;
|
|
// AutoHideContainer
|
|
procedure DrawHideBar(ACanvas: TCanvas; ARect: TRect; APosition: TdxAutoHidePosition); override;
|
|
procedure DrawHideBarButton(ACanvas: TCanvas; AControl: TdxCustomDockControl;
|
|
ARect: TRect; APosition: TdxAutoHidePosition); override;
|
|
end;
|
|
|
|
TdxDockControlAccess = class(TdxCustomDockControl);
|
|
|
|
implementation
|
|
|
|
{ TdxDockControlSkinPainter }
|
|
|
|
function TdxDockControlSkinPainter.CanVerticalCaption: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.CorrectTabRect(var ATab: TRect;
|
|
APosition: TdxTabContainerTabsPosition; AIsActive: Boolean);
|
|
var
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
if not GetSkinPainterData(ASkinInfo) then
|
|
inherited CorrectTabRect(ATab, APosition, AIsActive)
|
|
else
|
|
begin
|
|
if AIsActive then
|
|
begin
|
|
InflateRect(ATab, ASkinInfo.DockControlIndents[1], 0);
|
|
if APosition = tctpTop then
|
|
Dec(ATab.Top, ASkinInfo.DockControlIndents[2])
|
|
else
|
|
Inc(ATab.Bottom, ASkinInfo.DockControlIndents[2]);
|
|
end;
|
|
|
|
if APosition = tctpTop then
|
|
Inc(ATab.Bottom, ASkinInfo.DockControlIndents[0] - 1)
|
|
else
|
|
Dec(ATab.Top, ASkinInfo.DockControlIndents[0] + 1);
|
|
end;
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawBorder(ACanvas: TCanvas; ARect: TRect);
|
|
var
|
|
ABorder: TdxSkinElement;
|
|
ACaption: TdxSkinElement;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
R: TRect;
|
|
begin
|
|
ABorder := nil;
|
|
ACaption := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
begin
|
|
ABorder := ASkinInfo.DockControlBorder;
|
|
ACaption := ASkinInfo.DockControlCaption;
|
|
end;
|
|
if (ABorder = nil) or (ACaption = nil) then
|
|
inherited DrawBorder(ACanvas, ARect)
|
|
else
|
|
begin
|
|
ABorder.Draw(ACanvas.Handle, ARect);
|
|
R := ARect;
|
|
R.Bottom := R.Top + ACaption.Image.Margins.Top;
|
|
ACaption.Draw(ACanvas.Handle, R);
|
|
end;
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawCaption(ACanvas: TCanvas; ARect: TRect;
|
|
IsActive: Boolean);
|
|
const
|
|
AStates: array[Boolean] of TdxSkinElementState = (esNormal, esActive);
|
|
var
|
|
AcxCanvas: TcxCanvas;
|
|
AElement: TdxSkinElement;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
AElement := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
AElement := ASkinInfo.DockControlCaption;
|
|
if AElement = nil then
|
|
inherited DrawCaption(ACanvas, ARect, IsActive)
|
|
else
|
|
begin
|
|
AcxCanvas := TcxCanvas.Create(ACanvas);
|
|
try
|
|
AcxCanvas.SaveClipRegion;
|
|
AcxCanvas.SetClipRegion(TcxRegion.Create(ARect), roSet);
|
|
try
|
|
Dec(ARect.Top, GetTopBorderSize);
|
|
AElement.Draw(ACanvas.Handle, ARect, 0, AStates[IsActive]);
|
|
finally
|
|
AcxCanvas.RestoreClipRegion;
|
|
end;
|
|
finally
|
|
AcxCanvas.Free;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawCaptionCloseButton(ACanvas: TCanvas;
|
|
ARect: TRect; IsActive, IsDown, IsHot, IsSwitched: Boolean);
|
|
begin
|
|
if not InternalDrawCaptionButton(ACanvas, 2, ARect, IsActive, IsDown, IsHot,
|
|
IsSwitched)
|
|
then
|
|
inherited DrawCaptionCloseButton(ACanvas, ARect, IsActive, IsDown, IsHot,
|
|
IsSwitched);
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawCaptionHideButton(ACanvas: TCanvas;
|
|
ARect: TRect; IsActive, IsDown, IsHot, IsSwitched: Boolean);
|
|
const
|
|
AGlyphMap: array[Boolean] of Integer = (3, 4);
|
|
begin
|
|
if not InternalDrawCaptionButton(ACanvas, AGlyphMap[IsSwitched], ARect,
|
|
IsActive, IsDown, IsHot, IsSwitched)
|
|
then
|
|
inherited DrawCaptionHideButton(ACanvas, ARect, IsActive, IsDown, IsHot,
|
|
IsSwitched);
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawCaptionMaximizeButton(ACanvas: TCanvas;
|
|
ARect: TRect; IsActive, IsDown, IsHot, IsSwitched: Boolean);
|
|
const
|
|
AGlyphs: array[Boolean] of Integer = (1, 0);
|
|
begin
|
|
if not InternalDrawCaptionButton(ACanvas, AGlyphs[IsSwitched], ARect, IsActive,
|
|
IsDown, IsHot, IsSwitched)
|
|
then
|
|
inherited DrawCaptionMaximizeButton(ACanvas, ARect, IsActive, IsDown, IsHot,
|
|
IsSwitched);
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawCaptionSeparator(ACanvas: TCanvas; ARect: TRect);
|
|
var
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
if not GetSkinPainterData(ASkinInfo) then
|
|
inherited DrawCaptionSeparator(ACanvas, ARect);
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawCaptionText(ACanvas: TCanvas; ARect: TRect;
|
|
IsActive: Boolean);
|
|
var
|
|
R: TRect;
|
|
begin
|
|
if IsValidImageIndex(DockControl.ImageIndex) then
|
|
begin
|
|
R.Left := ARect.Left + 2 * GetCaptionHorizInterval;
|
|
R.Top := ARect.Top + (ARect.Bottom - ARect.Top - GetImageHeight) div 2;
|
|
R.Right := R.Left + GetImageWidth;
|
|
R.Bottom := R.Top + GetImageHeight;
|
|
if RectInRect(R, ARect) then
|
|
begin
|
|
DrawImage(ACanvas, DockControl.Images, DockControl.ImageIndex, R);
|
|
ARect.Left := R.Right + 2 * GetCaptionHorizInterval;
|
|
end;
|
|
end;
|
|
|
|
ACanvas.Brush.Style := bsClear;
|
|
ACanvas.Font := GetFont;
|
|
ACanvas.Font.Color := GetCaptionFontColor(IsActive);
|
|
cxDrawText(ACanvas.Handle, DockControl.Caption, ARect,
|
|
DT_SINGLELINE or DT_LEFT or DT_VCENTER or DT_END_ELLIPSIS);
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawClient(ACanvas: TCanvas; ARect: TRect);
|
|
var
|
|
AElement: TdxSkinElement;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
AElement := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
AElement := ASkinInfo.DockControlBorder;
|
|
if AElement = nil then
|
|
inherited DrawClient(ACanvas, ARect)
|
|
else
|
|
begin
|
|
with AElement.Image.Margins.Rect do
|
|
ARect := Rect(ARect.Left - Left, ARect.Top - Top, ARect.Right + Right,
|
|
ARect.Bottom + Bottom);
|
|
AElement.Draw(ACanvas.Handle, ARect);
|
|
end;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetBorderWidth: Integer;
|
|
var
|
|
AElement: TdxSkinElement;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
AElement := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
AElement := ASkinInfo.DockControlBorder;
|
|
if AElement = nil then
|
|
Result := inherited GetBorderWidth
|
|
else
|
|
with AElement.Image.Margins do
|
|
Result := Max(Max(Left, Top), Max(Right, Bottom));
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetCaptionButtonSize: Integer;
|
|
var
|
|
AElement: TdxSkinElement;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
AElement := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
AElement := ASkinInfo.DockControlWindowButton;
|
|
if AElement = nil then
|
|
Result := inherited GetCaptionButtonSize
|
|
else
|
|
Result := AElement.Size.cy;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetCaptionHorizInterval: Integer;
|
|
begin
|
|
Result := 2;
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawHideBar(ACanvas: TCanvas; ARect: TRect;
|
|
APosition: TdxAutoHidePosition);
|
|
var
|
|
AElement: TdxSkinElement;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
AElement := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
case APosition of
|
|
ahpTop, ahpUndefined:
|
|
AElement := ASkinInfo.DockControlHideBar;
|
|
ahpLeft:
|
|
AElement := ASkinInfo.DockControlHideBarLeft;
|
|
ahpRight:
|
|
AElement := ASkinInfo.DockControlHideBarRight;
|
|
ahpBottom:
|
|
AElement := ASkinInfo.DockControlHideBarBottom;
|
|
end;
|
|
|
|
if AElement = nil then
|
|
inherited DrawHideBar(ACanvas, ARect, APosition)
|
|
else
|
|
AElement.Draw(ACanvas.Handle, ARect);
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawHideBarButton(ACanvas: TCanvas;
|
|
AControl: TdxCustomDockControl; ARect: TRect; APosition: TdxAutoHidePosition);
|
|
var
|
|
ABitmap: TBitmap;
|
|
AElement: TdxSkinElement;
|
|
ALine: TdxSkinElement;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
R: TRect;
|
|
Temp: Integer;
|
|
begin
|
|
AElement := nil;
|
|
ALine := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
begin
|
|
AElement := ASkinInfo.DockControlHideBarButtons;
|
|
ALine := ASkinInfo.DockControlTabHeaderLine;
|
|
end;
|
|
if (AElement = nil) or (ALine = nil) then
|
|
inherited DrawHideBarButton(ACanvas, AControl, ARect, APosition)
|
|
else
|
|
begin
|
|
ABitmap := TBitmap.Create;
|
|
try
|
|
ABitmap.PixelFormat := pf32bit;
|
|
R := ARect;
|
|
OffsetRect(R, -R.Left, -R.Top);
|
|
if APosition in [ahpLeft, ahpRight] then
|
|
begin
|
|
Temp := R.Right;
|
|
R.Right := R.Left + (R.Bottom - R.Top);
|
|
R.Bottom := R.Top + (Temp - R.Left);
|
|
end;
|
|
ABitmap.Width := R.Right - R.Left;
|
|
ABitmap.Height := R.Bottom - R.Top;
|
|
if APosition in [ahpLeft, ahpRight] then
|
|
begin
|
|
case APosition of
|
|
ahpLeft: RotateBitmap(ABitmap, raMinus90);
|
|
ahpRight: RotateBitmap(ABitmap, raPlus90);
|
|
end;
|
|
BitBlt(ABitmap.Canvas.Handle, 0, 0, ABitmap.Width, ABitmap.Height,
|
|
ACanvas.Handle, ARect.Left, ARect.Top, SRCCOPY);
|
|
case APosition of
|
|
ahpLeft: RotateBitmap(ABitmap, raPlus90);
|
|
ahpRight: RotateBitmap(ABitmap, raMinus90);
|
|
end;
|
|
end
|
|
else
|
|
BitBlt(ABitmap.Canvas.Handle, 0, 0, ABitmap.Width, ABitmap.Height,
|
|
ACanvas.Handle, ARect.Left, ARect.Top, SRCCOPY);
|
|
AElement.Draw(ABitmap.Canvas.Handle, R);
|
|
ALine.Draw(ABitmap.Canvas.Handle, Rect(1, R.Bottom - 1, R.Right - 1, R.Bottom));
|
|
case APosition of
|
|
ahpTop: RotateBitmap(ABitmap, ra180);
|
|
ahpLeft: RotateBitmap(ABitmap, raMinus90);
|
|
ahpRight: RotateBitmap(ABitmap, raPlus90);
|
|
end;
|
|
BitBlt(ACanvas.Handle, ARect.Left, ARect.Top, ARect.Right - ARect.Left,
|
|
ARect.Bottom - ARect.Top, ABitmap.Canvas.Handle, 0, 0, SRCCOPY);
|
|
finally
|
|
ABitmap.Free;
|
|
end;
|
|
DrawHideBarButtonContent(ACanvas, AControl, ARect, APosition);
|
|
end;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.DrawActiveTabLast: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawTab(ACanvas: TCanvas;
|
|
AControl: TdxCustomDockControl; ARect: TRect; IsActive: Boolean;
|
|
APosition: TdxTabContainerTabsPosition);
|
|
const
|
|
AStates: array[Boolean] of TdxSkinElementState = (esNormal, esPressed);
|
|
var
|
|
ABitmap: TcxBitmap;
|
|
ABitmapCanvas: TcxCanvas;
|
|
AElement: TdxSkinElement;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
AElement := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
AElement := ASkinInfo.DockControlTabHeader;
|
|
|
|
if AElement = nil then
|
|
inherited DrawTab(ACanvas, AControl, ARect, IsActive, APosition)
|
|
else
|
|
begin
|
|
ABitmap := TcxBitmap.CreateSize(ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
|
|
try
|
|
ABitmap.PixelFormat := pf32bit;
|
|
BitBlt(ABitmap.Canvas.Handle, 0, 0, ABitmap.Width, ABitmap.Height,
|
|
ACanvas.Handle, ARect.Left, ARect.Top, SRCCOPY);
|
|
|
|
ABitmapCanvas := TcxCanvas.Create(ACanvas);
|
|
try
|
|
if APosition = tctpBottom then
|
|
ABitmapCanvas.RotateBitmap(ABitmap, ra0, True);
|
|
AElement.Draw(ABitmap.Canvas.Handle,
|
|
Rect(0, 0, ABitmap.Width, ABitmap.Height), 0, AStates[IsActive]);
|
|
if APosition = tctpBottom then
|
|
ABitmapCanvas.RotateBitmap(ABitmap, ra0, True);
|
|
finally
|
|
ABitmapCanvas.Free;
|
|
end;
|
|
|
|
with ARect do
|
|
BitBlt(ACanvas.Handle, Left, Top, Right - Left, Bottom - Top,
|
|
ABitmap.Canvas.Handle, 0, 0, SRCCOPY);
|
|
finally
|
|
ABitmap.Free;
|
|
end;
|
|
with AElement.ContentOffset.Rect do
|
|
begin
|
|
Inc(ARect.Left, Left);
|
|
Inc(ARect.Top, Top);
|
|
Dec(ARect.Right, Right);
|
|
Dec(ARect.Bottom, Bottom);
|
|
end;
|
|
if APosition = tctpBottom then
|
|
Inc(ARect.Top, ASkinInfo.DockControlIndents[0]);
|
|
DrawTabContent(ACanvas, AControl, ARect, IsActive, APosition);
|
|
end;
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawTabContent(ACanvas: TCanvas;
|
|
AControl: TdxCustomDockControl; ARect: TRect; IsActive: Boolean;
|
|
APosition: TdxTabContainerTabsPosition);
|
|
var
|
|
R: TRect;
|
|
begin
|
|
if IsValidImageIndex(AControl.ImageIndex) then
|
|
begin
|
|
R.Left := ARect.Left;
|
|
R.Top := ARect.Top + (ARect.Bottom - ARect.Top - GetImageHeight) div 2;
|
|
R.Right := R.Left + GetImageWidth;
|
|
R.Bottom := R.Top + GetImageHeight;
|
|
if RectInRect(R, ARect) then
|
|
begin
|
|
DrawImage(ACanvas, AControl.Images, AControl.ImageIndex, R);
|
|
ARect.Left := R.Right + GetTabHorizInterval;
|
|
end;
|
|
end;
|
|
|
|
ACanvas.Brush.Style := bsClear;
|
|
ACanvas.Font := GetTabFont(IsActive);
|
|
ACanvas.Font.Color := ColorToRGB(GetTabFontColor(IsActive));
|
|
DrawText(ACanvas.Handle, PChar(AControl.Caption), Length(AControl.Caption), ARect,
|
|
DT_SINGLELINE or DT_CENTER or DT_VCENTER or DT_END_ELLIPSIS);
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawTabs(ACanvas: TCanvas;
|
|
ARect, AActiveTabRect: TRect; APosition: TdxTabContainerTabsPosition);
|
|
var
|
|
ABitmap: TBitmap;
|
|
AElement: TdxSkinElement;
|
|
ALine: TdxSkinElement;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
R: TRect;
|
|
begin
|
|
AElement := nil;
|
|
ALine := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
begin
|
|
AElement := ASkinInfo.DockControlTabHeaderBackground;
|
|
ALine := ASkinInfo.DockControlTabHeaderLine;
|
|
end;
|
|
if (AElement = nil) or (ALine = nil) then
|
|
inherited DrawTabs(ACanvas, ARect, AActiveTabRect, APosition)
|
|
else
|
|
begin
|
|
AElement.Draw(ACanvas.Handle, ARect);
|
|
R := ARect;
|
|
|
|
if APosition = tctpBottom then
|
|
R.Bottom := R.Top + 1
|
|
else
|
|
R.Top := R.Bottom - 1;
|
|
|
|
if APosition = tctpTop then
|
|
ALine.Draw(ACanvas.Handle, R)
|
|
else
|
|
begin
|
|
ABitmap := TBitmap.Create;
|
|
try
|
|
ABitmap.PixelFormat := pf32bit;
|
|
ABitmap.Width := R.Right - R.Left;
|
|
ABitmap.Height := R.Bottom - R.Top;
|
|
ALine.Draw(ABitmap.Canvas.Handle, Rect(0, 0, ABitmap.Width, ABitmap.Height));
|
|
RotateBitmap(ABitmap, ra180);
|
|
BitBlt(ACanvas.Handle, R.Left, R.Top, ABitmap.Width, ABitmap.Height,
|
|
ABitmap.Canvas.Handle, 0, 0, SRCCOPY);
|
|
finally
|
|
ABitmap.Free;
|
|
end;
|
|
end;
|
|
|
|
with AActiveTabRect do
|
|
begin
|
|
ExcludeClipRect(ACanvas.Handle, R.Left, R.Top, Left, R.Bottom);
|
|
ExcludeClipRect(ACanvas.Handle, Right, R.Top, R.Right, R.Bottom);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawTabsNextTabButton(ACanvas: TCanvas;
|
|
ARect: TRect; IsDown, IsHot, IsEnable: Boolean;
|
|
APosition: TdxTabContainerTabsPosition);
|
|
begin
|
|
if not InternalDrawTabButton(ACanvas, ARect, IsDown, IsHot, IsEnable, True) then
|
|
inherited DrawTabsNextTabButton(ACanvas, ARect, IsDown, IsHot, IsEnable,
|
|
APosition);
|
|
end;
|
|
|
|
procedure TdxDockControlSkinPainter.DrawTabsPrevTabButton(ACanvas: TCanvas;
|
|
ARect: TRect; IsDown, IsHot, IsEnable: Boolean; APosition: TdxTabContainerTabsPosition);
|
|
begin
|
|
if not InternalDrawTabButton(ACanvas, ARect, IsDown, IsHot, IsEnable, False) then
|
|
inherited DrawTabsNextTabButton(ACanvas, ARect, IsDown, IsHot, IsEnable,
|
|
APosition);
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetCaptionFontColor(IsActive: Boolean): TColor;
|
|
var
|
|
AColor: TColor;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
AColor := clDefault;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
if not IsActive then
|
|
AColor := ASkinInfo.DockControlCaptionNonFocusedTextColor
|
|
else
|
|
if ASkinInfo.DockControlCaption <> nil then
|
|
AColor := ASkinInfo.DockControlCaption.TextColor;
|
|
|
|
if AColor = clDefault then
|
|
Result := inherited GetCaptionFontColor(IsActive)
|
|
else
|
|
Result := AColor;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetCaptionRect(const ARect: TRect;
|
|
AIsVertical: Boolean): TRect;
|
|
var
|
|
ABorder: Integer;
|
|
ACaptionButtonSize: Integer;
|
|
ACaptionHeight: Integer;
|
|
begin
|
|
ABorder := GetBorderWidth;
|
|
Result := inherited GetCaptionRect(ARect, AIsVertical);
|
|
InflateRect(Result, ABorder, ABorder);
|
|
Inc(Result.Top, GetTopBorderSize);
|
|
ACaptionButtonSize := GetCaptionButtonSize;
|
|
ACaptionHeight := Max(GetCaptionHeight, ACaptionButtonSize + 4);
|
|
ACaptionHeight := ACaptionHeight + Integer(Odd(ACaptionHeight + ACaptionButtonSize));
|
|
if AIsVertical then
|
|
Result.Right := Result.Left + ACaptionHeight
|
|
else
|
|
Result.Bottom := Result.Top + ACaptionHeight;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetHideBarButtonFontColor: TColor;
|
|
var
|
|
AColor: TdxSkinColor;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
AColor := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
AColor := ASkinInfo.DockControlHideBarTextColor;
|
|
if AColor = nil then
|
|
Result := inherited GetHideBarButtonFontColor
|
|
else
|
|
Result := AColor.Value;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetTabFontColor(IsActive: Boolean): TColor;
|
|
var
|
|
AColor: TdxSkinColor;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
AColor := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
AColor := ASkinInfo.DockControlTabTextColor[IsActive];
|
|
if AColor = nil then
|
|
Result := inherited GetTabFontColor(IsActive)
|
|
else
|
|
Result := AColor.Value;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetTopBorderSize: Integer;
|
|
begin
|
|
Result := 2;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetTabHorizInterval: Integer;
|
|
var
|
|
AElement: TdxSkinElement;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
AElement := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
AElement := ASkinInfo.DockControlTabHeader;
|
|
if (AElement = nil) then
|
|
Result := inherited GetTabHorizInterval
|
|
else
|
|
Result := AElement.ContentOffset.Left;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetTabHorizOffset: Integer;
|
|
var
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
Result := inherited GetTabHorizOffset;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
Inc(Result, ASkinInfo.DockControlIndents[1]);
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetTabsHeight: Integer;
|
|
var
|
|
AElement: TdxSkinElement;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
AElement := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
AElement := ASkinInfo.DockControlTabHeader;
|
|
if (AElement = nil) then
|
|
Result := inherited GetTabsHeight
|
|
else
|
|
with AElement.ContentOffset do
|
|
Result := Top + Bottom + Max(GetImageHeight + 4, GetFont.Size + 10);
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetTabVertInterval: Integer;
|
|
begin
|
|
Result := 0;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetTabVertOffset: Integer;
|
|
var
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
begin
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
Result := ASkinInfo.DockControlIndents[2]
|
|
else
|
|
Result := inherited GetTabVertOffset;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetSkinLookAndFeelPainter: TcxCustomLookAndFeelPainterClass;
|
|
var
|
|
I: Integer;
|
|
begin
|
|
Result := nil;
|
|
with DockControl.Controller do
|
|
for I := 0 to DockManagerCount - 1 do
|
|
begin
|
|
Result := DockManagers[I].LookAndFeel.SkinPainter;
|
|
if Result <> nil then Break;
|
|
end;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.GetSkinPainterData(
|
|
var AData: TdxSkinLookAndFeelPainterInfo): Boolean;
|
|
begin
|
|
Result := GetExtendedStylePainters.GetPainterData(GetSkinLookAndFeelPainter,
|
|
AData);
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.DrawCaptionFirst: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.InternalDrawCaptionButton(ACanvas: TCanvas;
|
|
AGlyphIndex: Integer; ARect: TRect; IsActive, IsDown, IsHot,
|
|
IsSwitched: Boolean): Boolean;
|
|
var
|
|
AElement: TdxSkinElement;
|
|
AGlyph: TdxSkinElement;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
AState: TdxSkinElementState;
|
|
R: TRect;
|
|
begin
|
|
AElement := nil;
|
|
AGlyph := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
begin
|
|
AElement := ASkinInfo.DockControlWindowButton;
|
|
AGlyph := ASkinInfo.DockControlWindowButtonGlyphs;
|
|
end;
|
|
Result := (AElement <> nil) and (AGlyph <> nil);
|
|
if Result then
|
|
begin
|
|
if IsDown then
|
|
AState := esPressed
|
|
else
|
|
if IsHot then
|
|
AState := esHot
|
|
else
|
|
if IsActive then
|
|
AState := esActive
|
|
else
|
|
AState := esNormal;
|
|
R := ARect;
|
|
AElement.Draw(ACanvas.Handle, R, 0, AState);
|
|
AGlyph.Draw(ACanvas.Handle, cxRectContent(R, AElement.ContentOffset.Rect),
|
|
AGlyphIndex);
|
|
end;
|
|
end;
|
|
|
|
function TdxDockControlSkinPainter.InternalDrawTabButton(ACanvas: TCanvas;
|
|
ARect: TRect; IsDown, IsHot, IsEnable, IsNextButton: Boolean): Boolean;
|
|
const
|
|
AScrollPart: array[Boolean] of TcxScrollBarPart = (sbpLineUp, sbpLineDown);
|
|
var
|
|
AElementInfo: TdxSkinScrollInfo;
|
|
ASkinInfo: TdxSkinLookAndFeelPainterInfo;
|
|
AState: TdxSkinElementState;
|
|
begin
|
|
AElementInfo := nil;
|
|
if GetSkinPainterData(ASkinInfo) then
|
|
AElementInfo := ASkinInfo.ScrollBar_Elements[True, AScrollPart[IsNextButton]];
|
|
Result := (AElementInfo <> nil) and (AElementInfo.Element <> nil);
|
|
if Result then
|
|
begin
|
|
if IsEnable then
|
|
begin
|
|
AState := esNormal;
|
|
if IsDown then
|
|
AState := esPressed
|
|
else
|
|
if IsHot then
|
|
AState := esHot
|
|
end
|
|
else
|
|
AState := esDisabled;
|
|
with AElementInfo do
|
|
Element.Draw(ACanvas.Handle, ARect, ImageIndex, AState);
|
|
end;
|
|
end;
|
|
|
|
initialization
|
|
CustomSkinPainterClass := TdxDockControlSkinPainter;
|
|
|
|
finalization
|
|
CustomSkinPainterClass := nil;
|
|
|
|
end.
|