📄 cxpcpainters.pas
字号:
{********************************************************************}
{ }
{ Developer Express Visual Component Library }
{ ExpressPageControl }
{ }
{ Copyright (c) 1998-2004 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 EXPRESSPAGECONTROL 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 cxPCPainters;
{$I cxPCVer.inc}
interface
uses
{$IFDEF VCL}
Windows,
{$ELSE}
Qt, Types, QTypes,
{$ENDIF}
Classes, Controls, Graphics, cxGraphics, cxLookAndFeels, dxPageControl, Forms, SysUtils;
const
cxPCTabsStyle = 1;
cxPCButtonsStyle = 2;
cxPCFlatButtonsStyle = 3;
cxPCFlatStyle = 5;
StandardPainterTabControlFrameBorderWidth = 2;
type
TcxPCNavigatorButtonPosition = record
Button: TcxPCNavigatorButton;
ButtonRect: TRect;
end;
TcxPCArrow = (aTop, aBottom, aLeft, aRight);
TcxPCWOffset = record
Left, Right: Integer;
end;
{ TcxPCStandardPainter }
TcxPCStandardPainter = class(TcxPCCustomPainter)
private
FButtonsQueue: array of TcxPCNavigatorButtonPosition;
FButtonsRegionRect: TRect;
protected
function CalculateTabNormalHeight: Integer; override;
function CalculateTabNormalWidth(Tab: TcxTab): Integer; override;
function GetClientRect: TRect; override;
function GetDisplayRect: TRect; override;
function GetGoDialogButtonBounds: TRect; override;
function GetGoDialogPosition(GoDialogSize: TSize): TPoint; override;
function GetMinTabNormalWidth: Integer; override;
function GetMinTabSelectionDistance: TcxPCDistance; override;
function GetTabsNormalDistance: TcxPCDistance; override;
function GetTabsPosition(NavigatorButtons: TcxPCNavigatorButtons): TcxPCTabsPosition; override;
function IsOverButton(X, Y: Integer; var Button: TcxPCNavigatorButton): Boolean; override;
procedure Paint; override;
procedure PaintButtonsRegion; override;
procedure PaintFrame; override;
procedure PaintTab(TabVisibleIndex: Integer); virtual;
procedure PaintTabsRegion; override;
procedure RepaintButton(Button: TcxPCNavigatorButton; OldButtonState: TcxPCNavigatorButtonState); override;
procedure RepaintButtonsRegion; override;
procedure RepaintTab(TabVisibleIndex: Integer; TabPropertyChanged: TcxPCTabPropertyChanged); override;
procedure CalculateButtonsRegion(NavigatorButtons: TcxPCNavigatorButtons); virtual;
procedure CalculateButtonsRegionRect(NavigatorButtons: TcxPCNavigatorButtons); virtual;
function CalculateButtonsWidth(NavigatorButtons: TcxPCNavigatorButtons): Integer; virtual;
procedure DrawArrowShape(Arrow: TcxPCArrow; ArrowRectLeftTopCorner: TPoint;
Size: Integer; Enabled: Boolean; ArrowShapeColor: TColor);
function GetButtonArrow(AButton: TcxPCNavigatorButton): TcxPCArrow;
function GetButtonHeight: Integer; virtual;
function GetButtonWidth(Button: TcxPCNavigatorButton): Integer; virtual;
function GetDefaultTabNormalHeight: Integer; virtual;
function GetDefaultTabNormalHTextOffset: Integer; virtual;
function GetDefaultTabNormalWidth: Integer; virtual;
function GetDefaultTabNormalWTextOffset: Integer; virtual;
function GetDrawImageOffset(TabVisibleIndex: Integer): TRect; virtual;
function GetDrawTextOffset(TabVisibleIndex: Integer): TRect; virtual;
function GetImageTextDistance: Integer; virtual;
function GetTabContentWOffset(ATabVisibleIndex: Integer): TcxPCWOffset; virtual;
function GetTabBodyColor(TabVisibleIndex: Integer): TColor; virtual; abstract;
function GetTabBorderWidth(Tab: TcxTab): Integer; virtual;
procedure GetTabClipRect(TabVisibleIndex: Integer; var ClipR: TRect; var IntersectClipRectWithCurrentClipRegion: Boolean); virtual;
function GetTooNarrowTabContentWOffset(ATabVisibleIndex: Integer): TcxPCWOffset; virtual;
procedure InternalCalculateButtonsRegion(NavigatorButtons: TcxPCNavigatorButtons; FirstButtonLeftTopCornerOffset: TSize; ButtonsDistance: Integer);
function InternalCalculateTabNormalHeight: Integer; virtual;
procedure InternalDrawEdge(const Rect: TRect; Sunken: Boolean; ThinFrame: Boolean = False);
procedure InternalDrawFocusRect(TabVisibleIndex: Integer; R: TRect);
function IsTabBorderThick(ATabVisibleIndex: Integer): Boolean; virtual;
procedure PaintButton(Button: TcxPCNavigatorButton; ButtonRect: TRect); virtual;
procedure PaintTabFrame(TabVisibleIndex: Integer); virtual; abstract;
procedure SetButtonsOrder(NavigatorButtons: TcxPCNavigatorButtons); virtual;
procedure StandardPainterPrepareOutTabImageAndTextData(TabVisibleIndex: Integer);
{$IFDEF VCL}
procedure PrepareTabBackground(ATabVisibleIndex: Integer); virtual; abstract;
{$ENDIF}
public
constructor Create(AParent: TcxCustomTabControl); override;
destructor Destroy; override;
class function IsMainTabBoundWithClient: boolean; override;
class function IsMultiSelectionAccepted: boolean; override;
class function IsStandardStyle: Boolean; override;
class function IsTabPressable: Boolean; override;
end;
{ TcxPCButtonedPainter }
TcxPCButtonedPainter = class(TcxPCStandardPainter)
private
MainTabBrushBitmap: TBitmap;
protected
function GetDisplayRect: TRect; override;
function GetTabBodyColor(TabVisibleIndex: Integer): TColor; override;
function IsTabBorderThick(ATabVisibleIndex: Integer): Boolean; override;
procedure PaintFrame; override;
public
constructor Create(AParent: TcxCustomTabControl); override;
destructor Destroy; override;
end;
{ TcxPCTabsPainter }
TcxPCTabsPainter = class(TcxPCStandardPainter)
private
FMDC: HDC;
FPrevMDCBitmap: HBITMAP;
protected
procedure CorrectTabRect(TabVisibleIndex: Integer;
var TabRectCorrection: TcxPCRectCorrection); override;
function GetButtonHeight: Integer; override;
function GetButtonWidth(Button: TcxPCNavigatorButton): Integer; override;
function GetClientRect: TRect; override;
function GetDisplayRect: TRect; override;
function GetDrawTextOffset(TabVisibleIndex: Integer): TRect; override;
function GetTabBodyColor(TabVisibleIndex: Integer): TColor; override;
procedure GetTabClipRect(TabVisibleIndex: Integer; var ClipR: TRect;
var IntersectClipRectWithCurrentClipRegion: Boolean); override;
{$IFDEF VCL}
procedure GetTabNativePartAndState(ATabVisibleIndex: Integer;
var PartId, StateId: Integer); override;
{$ENDIF}
function GetTabsPosition(NavigatorButtons: TcxPCNavigatorButtons): TcxPCTabsPosition; override;
function InternalCalculateTabNormalHeight: Integer; override;
function IsNativePainting: Boolean; override;
function IsOverTab(TabVisibleIndex: Integer; X, Y: Integer): Boolean; override;
procedure Paint; override;
procedure PaintButton(Button: TcxPCNavigatorButton; ButtonRect: TRect); override;
procedure PaintFrame; override;
procedure PaintTabFrame(TabVisibleIndex: Integer); override;
procedure PaintTabsRegion; override;
procedure RepaintTab(TabVisibleIndex: Integer; TabPropertyChanged: TcxPCTabPropertyChanged); override;
procedure RepaintTabsRegion; override;
{$IFDEF VCL}
procedure PrepareTabBackground(ATabVisibleIndex: Integer); override;
procedure InternalPaintFrame(ACanvas: TCanvas);
{$ENDIF}
public
class function GetStandardStyle: TcxPCStandardStyle; override;
class function GetStyleID: TcxPCStyleID; override;
class function GetStyleName: TCaption; override;
class function HasLookAndFeel(ALookAndFeel: TcxLookAndFeel): Boolean; override;
class function IsDefault(ALookAndFeel: TcxLookAndFeel): Boolean; override;
end;
{ TcxPCButtonsPainter }
TcxPCButtonsPainter = class(TcxPCButtonedPainter)
protected
procedure PaintTabFrame(TabVisibleIndex: Integer); override;
public
class function GetStandardStyle: TcxPCStandardStyle; override;
class function GetStyleID: TcxPCStyleID; override;
class function GetStyleName: TCaption; override;
end;
{ TcxPCFlatButtonsPainter }
TcxPCFlatButtonsPainter = class(TcxPCButtonedPainter)
protected
procedure PaintTab(TabVisibleIndex: Integer); override;
procedure PaintTabFrame(TabVisibleIndex: Integer); override;
public
class function GetStandardStyle: TcxPCStandardStyle; override;
class function GetStyleID: TcxPCStyleID; override;
class function GetStyleName: TCaption; override;
class function HasLookAndFeel(ALookAndFeel: TcxLookAndFeel): Boolean; override;
end;
{ TcxPCFlatPainter }
TcxPCFlatPainter = class(TcxPCStandardPainter)
protected
procedure CalculateButtonsRegion(NavigatorButtons: TcxPCNavigatorButtons); override;
procedure CalculateButtonsRegionRect(NavigatorButtons: TcxPCNavigatorButtons); override;
function CalculateButtonsWidth(NavigatorButtons: TcxPCNavigatorButtons): Integer; override;
function CalculateTabNormalHeight: Integer; override;
function CalculateTabNormalWidth(Tab: TcxTab): Integer; override;
procedure CorrectTabRect(TabVisibleIndex: Integer; var TabRectCorrection: TcxPCRectCorrection); override;
function GetButtonHeight: Integer; override;
function GetButtonWidth(Button: TcxPCNavigatorButton): Integer; override;
function GetDefaultTabNormalHeight: Integer; override;
function GetDefaultTabNormalHTextOffset: Integer; override;
function GetDefaultTabNormalWTextOffset: Integer; override;
function GetDisplayRect: TRect; override;
function GetDrawImageOffset(TabVisibleIndex: Integer): TRect; override;
function GetDrawTextOffset(TabVisibleIndex: Integer): TRect; override;
function GetImageTextDistance: Integer; override;
function GetMinTabNormalWidth: Integer; override;
function GetTabBodyColor(TabVisibleIndex: Integer): TColor; override;
function GetTabBorderWidth(Tab: TcxTab = nil): Integer; override;
function GetTabContentWOffset(ATabVisibleIndex: Integer): TcxPCWOffset; override;
function GetTabsNormalDistance: TcxPCDistance; override;
function GetTabsPosition(NavigatorButtons: TcxPCNavigatorButtons): TcxPCTabsPosition; override;
function GetTooNarrowTabContentWOffset(ATabVisibleIndex: Integer): TcxPCWOffset; override;
function InternalCalculateTabNormalHeight: Integer; override;
procedure PaintButton(Button: TcxPCNavigatorButton; ButtonRect: TRect); override;
procedure PaintFrame; override;
procedure PaintTabFrame(TabVisibleIndex: Integer); override;
procedure PaintTabsRegion; override;
procedure RepaintTab(TabVisibleIndex: Integer; TabPropertyChanged: TcxPCTabPropertyChanged); override;
public
class function GetStyleID: TcxPCStyleID; override;
class function GetStyleName: TCaption; override;
class function HasLookAndFeel(ALookAndFeel: TcxLookAndFeel): Boolean; override;
class function IsMainTabBoundWithClient: boolean; override;
class function IsMultiSelectionAccepted: boolean; override;
class function IsTabPressable: Boolean; override;
end;
var
cxPCLightBrushColor: TColor;
implementation
uses
{$IFDEF VCL}
dxThemeConsts, dxThemeManager, dxUxTheme,
{$ENDIF}
Math, cxPCPaintersFactory;
const
StandardNativePainterButtonHeight = 17;
StandardNativePainterButtonWidth = 17;
StandardPainterButtonHeight = 20;
StandardPainterButtonWidthA: array [Boolean, TcxPCNavigatorButton] of Integer = (
(20, 20, 12), // TabPosition in [tpLeft, tpRight]
(20, 20, 13) // TabPosition in [tpTop, tpBottom]
);
StandardPainterTabBorderWidth = 2;
StandardPainterDefaultTabNormalHeightA: array [TcxPCStandardStyle] of Integer = (18, 20, 20{$IFNDEF VCL}, 18{$ENDIF});
StandardPainterDefaultTabNormalHTextOffsetA: array [TcxPCStandardStyle] of Integer = (2, 4, 4{$IFNDEF VCL}, 0{$ENDIF});
StandardPainterDefaultTabNormalWidthA: array [TcxPCStandardStyle] of Integer = (42, 42, 42{$IFNDEF VCL}, 40{$ENDIF});
StandardPainterDefaultTabNormalWTextOffsetA: array [TcxPCStandardStyle] of Integer = (6, 8, 12{$IFNDEF VCL}, 0{$ENDIF});
StandardPainterDrawImageOffsetA: array [Boolean, TcxPCStandardStyle] of TRect = (
((Left: 6; Top: 1; Right: 0; Bottom: 0),
(Left: 6; Top: -1; Right: 0; Bottom: 1),
(Left: 6; Top: -1; Right: 0; Bottom: 1)
{$IFNDEF VCL}
,(Left: 0; Top: 0; Right: 0; Bottom: 0)
{$ENDIF}
),
((Left: 8; Top: 1; Right: 0; Bottom: 3),
(Left: 7; Top: 0; Right: 0; Bottom: 0),
(Left: 7; Top: 0; Right: 0; Bottom: 0)
{$IFNDEF VCL}
,(Left: 0; Top: 0; Right: 0; Bottom: 0)
{$ENDIF}
)
);
StandardPainterDrawTextOffsetA: array [Boolean, TcxPCStandardStyle] of TRect = (
((Left: 5; Top: 1; Right: 5; Bottom: -1),
(Left: 6; Top: 0; Right: 4; Bottom: 1),
(Left: 6; Top: 0; Right: 4; Bottom: 1)
{$IFNDEF VCL}
,(Left: 0; Top: 0; Right: 0; Bottom: 0)
{$ENDIF}
),
((Left: 5; Top: 1; Right: 5; Bottom: 2),
(Left: 6; Top: 0; Right: 4; Bottom: -1),
(Left: 6; Top: 0; Right: 4; Bottom: -1)
{$IFNDEF VCL}
,(Left: 0; Top: 0; Right: 0; Bottom: 0)
{$ENDIF}
)
);
StandardPainterImageTextDistanceA: array [TcxPCStandardStyle] of Integer = (6, 6, 6{$IFNDEF VCL}, 0{$ENDIF});
StandardPainterTabContentWOffsetA: array [Boolean, TcxPCStandardStyle] of TcxPCWOffset = (
((Left: 2; Right: 2),
(Left: 2; Right: 2),
(Left: 2; Right: 2)
{$IFNDEF VCL}
,(Left: 0; Right: 0)
{$ENDIF}
),
((Left: 4; Right: 4),
(Left: 4; Right: 2),
(Left: 4; Right: 2)
{$IFNDEF VCL}
,(Left: 0; Right: 0)
{$ENDIF}
)
);
StandardPainterTabsNormalDistanceA: array [TcxPCStandardStyle] of TcxPCDistance = (
(dw: 0; dh: 0),
(dw: 3; dh: 3),
(dw: 10; dh: 3)
{$IFNDEF VCL}
,(dw: 0; dh: 0)// TODO
{$ENDIF}
);
StandardPainterMaxTabBorderWidth = 2;
StandardPainterWDistanceBetweenImageBorderAndText = 1;
StandardPainterTooNarrowTabContentWOffsetA: array [Boolean, TcxPCStandardStyle] of TcxPCWOffset = (
((Left: 2; Right: 2),
(Left: 2; Right: 2),
(Left: 2; Right: 2)
{$IFNDEF VCL}
,(Left: 0; Right: 0)
{$ENDIF}
),
((Left: 4; Right: 4),
(Left: 3; Right: 2),
(Left: 3; Right: 2)
{$IFNDEF VCL}
,(Left: 0; Right: 0)
{$ENDIF}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -