{********************************************************************} { } { 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 dxSkinsdxStatusBarPainter; interface uses Windows, SysUtils, Classes, dxSkinsCore, cxLookAndFeels, dxSkinsLookAndFeelPainter, dxStatusBar, cxGraphics, Graphics, cxLookAndFeelPainters; type { TdxStatusBarSkinPainter } TdxStatusBarSkinPainter = class(TdxStatusBarStandardPainter) protected class function CheckStatusBarRect(AFormStatusBar: TdxSkinElement; const R: TRect): TRect; class function GetSkinInfo(AStatusBar: TdxCustomStatusBar; out ASkinInfo: TdxSkinLookAndFeelPainterInfo): Boolean; class function IsSizeGripExists(AStatusBar: TdxCustomStatusBar; APanel: TdxStatusBarPanel): Boolean; class function IsSkinAvailable(AStatusBar: TdxCustomStatusBar): Boolean; public class procedure AdjustTextColor(AStatusBar: TdxCustomStatusBar; var AColor: TColor; Active: Boolean); override; class function DrawSizeGripFirst: Boolean; override; class function SeparatorSize: Integer; override; class function TopBorderSize: Integer; override; class procedure DrawClippedElement(AElement: TdxSkinElement; ACanvas: TcxCanvas; const ARect, AClipRegion: TRect; ARegionOperation: TcxRegionOperation = roSet); class procedure DrawEmptyPanel(AStatusBar: TdxCustomStatusBar; ACanvas: TcxCanvas; R: TRect); override; class procedure DrawPanelBorder(AStatusBar: TdxCustomStatusBar; ABevel: TdxStatusBarPanelBevel; ACanvas: TcxCanvas; var R: TRect); override; class procedure DrawPanelSeparator(AStatusBar: TdxCustomStatusBar; ACanvas: TcxCanvas; const R: TRect); override; class procedure DrawTopBorder(AStatusBar: TdxCustomStatusBar; ACanvas: TcxCanvas; const R: TRect); override; class procedure DrawSizeGrip(AStatusBar: TdxCustomStatusBar; ACanvas: TcxCanvas; R: TRect; AOverlapped: Boolean); override; class procedure FillBackground(AStatusBar: TdxCustomStatusBar; APanel: TdxStatusBarPanel; ACanvas: TcxCanvas; const R: TRect); override; class function ValidatePanelTextRect(AStatusBar: TdxCustomStatusBar; APanel: TdxStatusBarPanel; const R: TRect): TRect; override; end; implementation uses cxGeometry; type TdxCustomStatusBarAccess = class(TdxCustomStatusBar); { TdxStatusBarSkinPainter } class procedure TdxStatusBarSkinPainter.AdjustTextColor(AStatusBar: TdxCustomStatusBar; var AColor: TColor; Active: Boolean); var ASkinInfo: TdxSkinLookAndFeelPainterInfo; begin inherited AdjustTextColor(AStatusBar, AColor, Active); if AColor = clWindowText then if GetSkinInfo(AStatusBar, ASkinInfo) then begin if Active then begin if ASkinInfo.FormStatusBar <> nil then AColor := ASkinInfo.FormStatusBar.TextColor; end else if ASkinInfo.BarDisabledTextColor <> nil then AColor := ASkinInfo.BarDisabledTextColor.Value; end; end; class function TdxStatusBarSkinPainter.CheckStatusBarRect(AFormStatusBar: TdxSkinElement; const R: TRect): TRect; begin Result := R; if Assigned(AFormStatusBar) then with AFormStatusBar.ContentOffset do begin Dec(Result.Left, Left); Inc(Result.Right, Right); Inc(Result.Bottom, Bottom); end; end; class function TdxStatusBarSkinPainter.DrawSizeGripFirst: Boolean; begin Result := False; end; class function TdxStatusBarSkinPainter.SeparatorSize: Integer; begin Result := 0; end; class function TdxStatusBarSkinPainter.TopBorderSize: Integer; begin Result := 2; end; class procedure TdxStatusBarSkinPainter.DrawClippedElement(AElement: TdxSkinElement; ACanvas: TcxCanvas; const ARect: TRect; const AClipRegion: TRect; ARegionOperation: TcxRegionOperation = roSet); begin ACanvas.SaveClipRegion; try ACanvas.SetClipRegion(TcxRegion.Create(AClipRegion), ARegionOperation); AElement.Draw(ACanvas.Handle, ARect); finally ACanvas.RestoreClipRegion; end; end; class procedure TdxStatusBarSkinPainter.DrawEmptyPanel(AStatusBar: TdxCustomStatusBar; ACanvas: TcxCanvas; R: TRect); var ASkinInfo: TdxSkinLookAndFeelPainterInfo; begin if not GetSkinInfo(AStatusBar, ASkinInfo) or (ASkinInfo.FormStatusBar = nil) then inherited DrawEmptyPanel(AStatusBar, ACanvas, R) else DrawClippedElement(ASkinInfo.FormStatusBar, ACanvas, CheckStatusBarRect(ASkinInfo.FormStatusBar, AStatusBar.Bounds), R); end; class procedure TdxStatusBarSkinPainter.DrawPanelBorder(AStatusBar: TdxCustomStatusBar; ABevel: TdxStatusBarPanelBevel; ACanvas: TcxCanvas; var R: TRect); begin if not IsSkinAvailable(AStatusBar) then inherited DrawPanelBorder(AStatusBar, ABevel, ACanvas, R); end; class procedure TdxStatusBarSkinPainter.DrawPanelSeparator(AStatusBar: TdxCustomStatusBar; ACanvas: TcxCanvas; const R: TRect); begin if not IsSkinAvailable(AStatusBar) then inherited DrawPanelSeparator(AStatusBar, ACanvas, R); end; class procedure TdxStatusBarSkinPainter.DrawTopBorder(AStatusBar: TdxCustomStatusBar; ACanvas: TcxCanvas; const R: TRect); var ANeedCustomDraw: Boolean; ASkinInfo: TdxSkinLookAndFeelPainterInfo; begin ANeedCustomDraw := True; if GetSkinInfo(AStatusBar, ASkinInfo) then begin ANeedCustomDraw := ASkinInfo.FormStatusBar = nil; if not ANeedCustomDraw then DrawClippedElement(ASkinInfo.FormStatusBar, ACanvas, CheckStatusBarRect(ASkinInfo.FormStatusBar, AStatusBar.Bounds), R); end; if ANeedCustomDraw then inherited DrawTopBorder(AStatusBar, ACanvas, R); end; class procedure TdxStatusBarSkinPainter.DrawSizeGrip(AStatusBar: TdxCustomStatusBar; ACanvas: TcxCanvas; R: TRect; AOverlapped: Boolean); var ANeedCustomDraw: Boolean; ARect: TRect; ASkinInfo: TdxSkinLookAndFeelPainterInfo; begin ANeedCustomDraw := True; if GetSkinInfo(AStatusBar, ASkinInfo) then begin ANeedCustomDraw := ASkinInfo.SizeGrip = nil; if not ANeedCustomDraw then begin with ASkinInfo.FormStatusBar.ContentOffset.Rect do ARect := Rect(R.Right - ASkinInfo.SizeGrip.Size.cx - Right, R.Top, R.Right - Right, R.Bottom - Bottom); ASkinInfo.SizeGrip.Draw(ACanvas.Handle, ARect); end; end; if ANeedCustomDraw then inherited DrawSizeGrip(AStatusBar, ACanvas, R, AOverlapped); end; class procedure TdxStatusBarSkinPainter.FillBackground( AStatusBar: TdxCustomStatusBar; APanel: TdxStatusBarPanel; ACanvas: TcxCanvas; const R: TRect); var ADone: Boolean; ARect: TRect; ASkinInfo: TdxSkinLookAndFeelPainterInfo; begin ADone := False; if GetSkinInfo(AStatusBar, ASkinInfo) then begin ADone := (ASkinInfo.FormStatusBar <> nil) and (ASkinInfo.LinkBorderPainter <> nil); if ADone then begin DrawClippedElement(ASkinInfo.FormStatusBar, ACanvas, CheckStatusBarRect(ASkinInfo.FormStatusBar, AStatusBar.Bounds), R, roIntersect); ARect := cxRectInflate(R, -1, 0, -1, -1); if IsSizeGripExists(AStatusBar, APanel) then Dec(ARect.Right, GripAreaSize.cx); ASkinInfo.LinkBorderPainter.Draw(ACanvas.Handle, ARect); end; end; if not ADone then inherited FillBackground(AStatusBar, APanel, ACanvas, R); end; class function TdxStatusBarSkinPainter.GetSkinInfo(AStatusBar: TdxCustomStatusBar; out ASkinInfo: TdxSkinLookAndFeelPainterInfo): Boolean; begin with TdxCustomStatusBarAccess(AStatusBar) do Result := GetExtendedStylePainters.GetPainterData(LookAndFeel.SkinPainter, ASkinInfo); end; class function TdxStatusBarSkinPainter.IsSkinAvailable( AStatusBar: TdxCustomStatusBar): Boolean; begin with TdxCustomStatusBarAccess(AStatusBar) do Result := LookAndFeel.SkinPainter <> nil; end; class function TdxStatusBarSkinPainter.IsSizeGripExists(AStatusBar: TdxCustomStatusBar; APanel: TdxStatusBarPanel): Boolean; begin with TdxCustomStatusBarAccess(AStatusBar) do Result := (APanel <> nil) and (APanel.Index = Panels.Count - 1) and SizeGrip; end; class function TdxStatusBarSkinPainter.ValidatePanelTextRect(AStatusBar: TdxCustomStatusBar; APanel: TdxStatusBarPanel; const R: TRect): TRect; begin Result := R; if IsSizeGripExists(AStatusBar, APanel) then Dec(Result.Right, GripAreaSize.cx); end; initialization dxStatusBarSkinPainterClass := TdxStatusBarSkinPainter; finalization dxStatusBarSkinPainterClass := nil; end.