{********************************************************************} { } { Developer Express Visual Component Library } { ExpressSkins Library } { } { Copyright (c) 2006-2008 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, dxSkinInfo, Types; type { TdxDockControlSkinPainter } TdxDockControlSkinPainter = class(TdxDockControlXPPainter) private FButtonsCache: TdxSkinElementCache; FHideBarElementCache: array[TdxAutoHidePosition] of TdxSkinElementCache; FPanelsBackgroundCache: TdxSkinElementCacheList; procedure DrawClippedElement(ACanvas: TCanvas; const ARect, AClipRect: TRect; AElement: TdxSkinElement; AState: TdxSkinElementState = esNormal; AOperation: TcxRegionOperation = roSet); protected function DrawCaptionFirst: Boolean; override; function GetCaptionFontColor(IsActive: Boolean): TColor; override; function GetCaptionRect(const ARect: TRect; AIsVertical: Boolean): TRect; override; function GetElementState(IsActive, IsDown, IsHot: Boolean): TdxSkinElementState; 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; AState: TdxSkinElementState): Boolean; function InternalDrawTabButton(ACanvas: TCanvas; ARect: TRect; IsDown, IsHot, IsEnable, IsNextButton: Boolean): Boolean; public constructor Create(ADockControl: TdxCustomDockControl); override; destructor Destroy; override; // 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 DrawClientEx(ACanvas: TCanvas; AWindowRect, 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 } constructor TdxDockControlSkinPainter.Create(ADockControl: TdxCustomDockControl); var ASide: TdxAutoHidePosition; begin inherited Create(ADockControl); FPanelsBackgroundCache := TdxSkinElementCacheList.Create; FButtonsCache := TdxSkinElementCache.Create; for ASide := Low(TdxAutoHidePosition) to High(TdxAutoHidePosition) do FHideBarElementCache[ASide] := TdxSkinElementCache.Create; end; destructor TdxDockControlSkinPainter.Destroy; var ASide: TdxAutoHidePosition; begin FButtonsCache.Free; FPanelsBackgroundCache.Free; for ASide := Low(TdxAutoHidePosition) to High(TdxAutoHidePosition) do FHideBarElementCache[ASide].Free; inherited Destroy; end; 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; 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 FPanelsBackgroundCache.DrawElement(ACanvas.Handle, ABorder, ARect); DrawClippedElement(ACanvas, cxRectSetHeight(ARect, ACaption.Size.cy), cxRectSetHeight(ARect, GetBorderWidth), ACaption); end; end; procedure TdxDockControlSkinPainter.DrawCaption(ACanvas: TCanvas; ARect: TRect; IsActive: Boolean); const AStates: array[Boolean] of TdxSkinElementState = (esNormal, esActive); var AElement: TdxSkinElement; ASkinInfo: TdxSkinLookAndFeelPainterInfo; R: TRect; begin AElement := nil; if GetSkinPainterData(ASkinInfo) then AElement := ASkinInfo.DockControlCaption; if AElement = nil then inherited DrawCaption(ACanvas, ARect, IsActive) else begin R := ARect; Dec(R.Top, GetTopBorderSize); DrawClippedElement(ACanvas, R, ARect, AElement, AStates[IsActive]); end; end; procedure TdxDockControlSkinPainter.DrawCaptionCloseButton(ACanvas: TCanvas; ARect: TRect; IsActive, IsDown, IsHot, IsSwitched: Boolean); begin if not InternalDrawCaptionButton(ACanvas, 2, ARect, GetElementState(IsActive, IsDown, IsHot)) 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, GetElementState(IsActive, IsDown, IsHot)) 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, GetElementState(IsActive, IsDown, IsHot)) 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.DrawClientEx(ACanvas: TCanvas; AWindowRect, ARect: TRect); var ABorderWidth: Integer; AElement: TdxSkinElement; ASkinInfo: TdxSkinLookAndFeelPainterInfo; begin if GetSkinPainterData(ASkinInfo) then AElement := ASkinInfo.DockControlBorder else AElement := nil; if AElement = nil then inherited DrawClientEx(ACanvas, AWindowRect, ARect) else if cxRectIsEqual(AWindowRect, ARect) then begin ABorderWidth := GetBorderWidth; InflateRect(ARect, ABorderWidth, ABorderWidth); DrawClippedElement(ACanvas, ARect, AWindowRect, AElement, esNormal, roIntersect); end else FPanelsBackgroundCache.DrawElement(ACanvas.Handle, AElement, AWindowRect); 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 begin FHideBarElementCache[APosition].CheckCacheState(AElement, ARect); FHideBarElementCache[APosition].Draw(ACanvas.Handle, ARect); end; 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 if IsRectEmpty(ARect) then Exit; 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.GetElementState(IsActive: Boolean; IsDown: Boolean; IsHot: Boolean): TdxSkinElementState; begin if IsDown then Result := esPressed else if IsHot then Result := esHot else if IsActive then Result := esActive else Result := esNormal; 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; procedure TdxDockControlSkinPainter.DrawClippedElement(ACanvas: TCanvas; const ARect, AClipRect: TRect; AElement: TdxSkinElement; AState: TdxSkinElementState = esNormal; AOperation: TcxRegionOperation = roSet); var ATempCanvas: TcxCanvas; begin ATempCanvas := TcxCanvas.Create(ACanvas); try ATempCanvas.SaveClipRegion; try ATempCanvas.SetClipRegion(TcxRegion.Create(AClipRect), AOperation); AElement.Draw(ACanvas.Handle, ARect, 0, AState); finally ATempCanvas.RestoreClipRegion; end; finally ATempCanvas.Free; end; end; function TdxDockControlSkinPainter.InternalDrawCaptionButton(ACanvas: TCanvas; AGlyphIndex: Integer; ARect: TRect; AState: TdxSkinElementState): Boolean; var AElement: TdxSkinElement; AGlyph: TdxSkinElement; ASkinInfo: TdxSkinLookAndFeelPainterInfo; 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 FButtonsCache.CheckCacheState(AElement, ARect, AState); FButtonsCache.Draw(ACanvas.Handle, ARect); AGlyph.Draw(ACanvas.Handle, cxRectContent(ARect, AElement.ContentOffset.Rect), AGlyphIndex, AState); 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.