{********************************************************************} { } { 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 dxSkinsdxStatusBarPainter; interface uses Windows, SysUtils, Classes, dxSkinsCore, cxLookAndFeels, dxSkinsLookAndFeelPainter, dxStatusBar, cxGraphics, Graphics, cxLookAndFeelPainters; type { TdxStatusBarSkinPainter } TdxStatusBarSkinPainter = class(TdxStatusBarStandardPainter) protected class function GetSkinInfo(AStatusBar: TdxCustomStatusBar): TdxSkinLookAndFeelPainterInfo; class function IsSizeGripExists(AStatusBar: TdxCustomStatusBar; APanel: TdxStatusBarPanel): Boolean; class function IsSkinAvailable(AStatusBar: TdxCustomStatusBar): Boolean; class procedure DrawBackground(ACanvas: TcxCanvas; const R: TRect; ASkinInfo: TdxSkinLookAndFeelPainterInfo); 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: TRect; const AClipRegion: TRect); 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); begin if IsSkinAvailable(AStatusBar) then with GetSkinInfo(AStatusBar) do if Active then begin if FormStatusBar <> nil then AColor := FormStatusBar.TextColor; end else if BarDisabledTextColor <> nil then AColor := BarDisabledTextColor.Value; 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); begin ACanvas.SaveClipRegion; try ACanvas.SetClipRegion(TcxRegion.Create(AClipRegion), roSet); AElement.Draw(ACanvas.Handle, ARect); finally ACanvas.RestoreClipRegion; end; end; class procedure TdxStatusBarSkinPainter.DrawEmptyPanel(AStatusBar: TdxCustomStatusBar; ACanvas: TcxCanvas; R: TRect); var ANeedCustomDraw: Boolean; ARect: TRect; begin ANeedCustomDraw := True; if IsSkinAvailable(AStatusBar) then with GetSkinInfo(AStatusBar) do begin ANeedCustomDraw := FormStatusBar = nil; if not ANeedCustomDraw then begin with FormStatusBar.ContentOffset do ARect := Classes.Rect(R.Left - Left, R.Top - Top, R.Right + Right, R.Bottom + Bottom); DrawClippedElement(FormStatusBar, ACanvas, ARect, R); end; end; if ANeedCustomDraw then inherited DrawEmptyPanel(AStatusBar, ACanvas, 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; ARect: TRect; begin ANeedCustomDraw := True; if IsSkinAvailable(AStatusBar) then with GetSkinInfo(AStatusBar) do begin ANeedCustomDraw := FormStatusBar = nil; if not ANeedCustomDraw then begin ARect := R; with FormStatusBar.ContentOffset.Rect do begin Dec(ARect.Left, Left); Inc(ARect.Right, Right); end; DrawClippedElement(FormStatusBar, ACanvas, ARect, R); end; 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 IsSkinAvailable(AStatusBar) then begin ASkinInfo := GetSkinInfo(AStatusBar); 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.DrawBackground(ACanvas: TcxCanvas; const R: TRect; ASkinInfo: TdxSkinLookAndFeelPainterInfo); var ARect: TRect; begin if Assigned(ASkinInfo.FormStatusBar) then begin with ASkinInfo.FormStatusBar.ContentOffset do ARect := Classes.Rect(R.Left - Left, R.Top - Top, R.Right + Right, R.Bottom + Bottom); ACanvas.SaveClipRegion; try ACanvas.SetClipRegion(TcxRegion.Create(R), roIntersect); ASkinInfo.FormStatusBar.Draw(ACanvas.Handle, ARect); finally ACanvas.RestoreClipRegion; end; end; end; class procedure TdxStatusBarSkinPainter.FillBackground( AStatusBar: TdxCustomStatusBar; APanel: TdxStatusBarPanel; ACanvas: TcxCanvas; const R: TRect); var ANeedCustomDraw: Boolean; ARect: TRect; ASkinInfo: TdxSkinLookAndFeelPainterInfo; begin ANeedCustomDraw := True; if IsSkinAvailable(AStatusBar) then begin ASkinInfo := GetSkinInfo(AStatusBar); ANeedCustomDraw := (ASkinInfo.FormStatusBar = nil) or (ASkinInfo.LinkBorderPainter = nil); if not ANeedCustomDraw then begin DrawBackground(ACanvas, R, ASkinInfo); ARect := cxRectInflate(R, -1, -1); if IsSizeGripExists(AStatusBar, APanel) then Dec(ARect.Right, GripAreaSize.cx); ASkinInfo.LinkBorderPainter.Draw(ACanvas.Handle, ARect); end; end; if ANeedCustomDraw then inherited FillBackground(AStatusBar, APanel, ACanvas, R); 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; class function TdxStatusBarSkinPainter.GetSkinInfo( AStatusBar: TdxCustomStatusBar): TdxSkinLookAndFeelPainterInfo; begin with TdxCustomStatusBarAccess(AStatusBar) do GetExtendedStylePainters.GetPainterData(LookAndFeel.SkinPainter, Result); 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; initialization dxStatusBarSkinPainterClass := TdxStatusBarSkinPainter; finalization dxStatusBarSkinPainterClass := nil; end.