📄 dxpagecontrol.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 dxPageControl;
{$I cxPCVer.inc}
interface
uses
{$IFDEF VCL}
Windows, Messages, dxThemeConsts,
{$ELSE}
Qt, Types, QTypes,
{$ENDIF}
Classes, Controls, ExtCtrls, Forms, Graphics, ImgList, SysUtils, cxClasses,
cxContainer, cxControls, cxGraphics, cxLookAndFeels, cxPCGoDialog;
const
cxPCNoStyle = -1;
cxPCDefaultStyle = 0;
cxPCDefaultStyleName = 'Default';
type
TcxPCStyleID = -1 .. High(Integer);
TcxPCStandardStyle = (tsTabs, tsButtons, tsFlatButtons{$IFNDEF VCL}, tsNoTabs{$ENDIF});
TcxPCOption = (pcoGoDialog, pcoNoArrows,
pcoSort, pcoTopToBottomText);
TcxPCOptions = set of TcxPCOption;
TcxTabPosition = (tpTop, tpBottom, tpLeft, tpRight);
TcxCustomTabControl = class;
TcxTab = class;
TdxTabSheet = class;
TcxDrawTabEvent = procedure(AControl: TcxCustomTabControl; ATab: TcxTab;
var DefaultDraw: Boolean) of object;
TcxDrawTabExEvent = procedure(AControl: TcxCustomTabControl; ATab: TcxTab;
Font: TFont) of object;
TcxGetTabImageEvent = procedure(Sender: TObject; TabIndex: Integer;
var ImageIndex: Integer) of object;
TcxPageChangingEvent = procedure(Sender: TObject; NewPage: TdxTabSheet; var AllowChange: Boolean) of object;
TcxTabChangedEvent = procedure(Sender: TObject; TabID: Integer) of object;
TcxTabChangingEvent = procedure(Sender: TObject; var AllowChange: Boolean) of object;
TcxPCNavigatorButton = (nbTopLeft, nbBottomRight, nbGoDialog);
TcxPCNavigatorButtons = set of TcxPCNavigatorButton;
TcxPCNavigatorButtonIndex = TcxPCNavigatorButtons;
TcxPCNavigatorButtonState = (nbsNormal, nbsPressed, nbsHotTrack, nbsDisabled);
TcxPCNavigatorPosition = (npLeftTop, npLeftBottom, npRightTop, npRightBottom);
TcxPCTabsPosition = record
ExtendedTabsRect: TRect;
ExtendedTopOrLeftTabsRectBottomOrRightBorderOffset: Integer;
ExtendedBottomOrRightTabsRectTopOrLeftBorderOffset: Integer;
MinDistanceBetweenTopOrLeftAndBottomOrRightExtendedTabsRects: Integer;
NormalRowWidth: Integer;
NormalTabsRect: TRect;
end;
TcxPCDistance = record
dw, dh: Integer;
end;
TcxPCRectCorrection = record
dLeft, dTop, dRight, dBottom: Integer;
end;
TcxPCTabPosition = record
TabNormalPosition: TPoint;
TabNormalWidth: Integer; // Height is in TcxTabs
TabRectCorrection: TcxPCRectCorrection;
end;
TcxPCTabPaintingPosition = (tppTop, tppBottom, tppLeft, tppRight);
TcxPCIndexInterval = record
Left, Right: Integer;
end;
TcxPCLineIndexBoundsArray = array of TcxPCIndexInterval;
TcxPCTabIndex = Integer;
TcxPCTabPropertyChanged = (tpcNotSpecified, tpcEnabled, tpcFocused,
tpcHighlighted, tpcHotTrack, tpcIsMainTab, tpcLayout, tpcPressed,
tpcSelected, tpcTracking);
TcxPCTabNotification = (tnDeleting);
TcxPCOutTabImageAndTextData = record
TabImageRect: TRect;
TabTextRect: TRect;
TabVisibleIndex: Integer;
VisibleText: TCaption;
end;
TcxPCRotationAngle = (ra0, raPlus90, raMinus90{$IFDEF VCL}, ra180{$ENDIF});
PcxPCImageListRotatedImagesElement =
^TcxPCImageListRotatedImagesElement;
TcxPCImageListRotatedImagesElement = record
BackgroundColor: TColor;
Bitmap: TBitmap;
IsBackgroundColorSpecified: Boolean;
end;
TcxTabs = class;
TcxTab = class(TPersistent)
private
FCaption: string; // type of TStrings' item
FEnabled: Boolean;
FHighlighted: Boolean;
FImageIndex: {$IFDEF DELPHI5}TImageIndex{$ELSE}Integer{$ENDIF};
FIndex: Integer;
FObject: TObject;
FPaintBitmap: TBitmap;
FRow: Integer;
FSelected: Boolean;
FTabPosition: TcxPCTabPosition;
FTabs: TcxTabs;
FVerticalTextBitmap: TBitmap;
FVisible: Boolean;
FVisibleCaption: string;
FVisibleRow: Integer;
procedure CalculateVisibleCaption;
function GetFullRect: TRect;
function GetHotTrack: Boolean;
function GetImageIndex: {$IFDEF DELPHI5}TImageIndex{$ELSE}Integer{$ENDIF};
function GetIsMainTab: Boolean;
function GetNormalLongitudinalSize: Integer;
function GetNormalRect: TRect;
function GetPaintingPosition: TcxPCTabPaintingPosition;
function GetPaintingPositionIndex: Integer;
function GetParentControl: TcxCustomTabControl;
function GetPressed: Boolean;
function GetRealEnabled: Boolean;
function GetRealVisible: Boolean;
function GetTracking: Boolean;
function GetVisibleIndex: Integer;
function GetVisibleRect: TRect;
procedure InternalSetCaption(const Value: string);
function IsImageIndexStored: Boolean;
procedure SetCaption(const Value: string);
procedure SetEnabled(const Value: Boolean);
procedure SetHighlighted(const Value: Boolean);
procedure SetImageIndex(Value: {$IFDEF DELPHI5}TImageIndex{$ELSE}Integer{$ENDIF});
procedure SetSelected(const Value: Boolean);
procedure SetVisible(const Value: Boolean);
protected
procedure AssignTo(Dest: TPersistent); override;
procedure Changed(ATabPropertyChanged: TcxPCTabPropertyChanged);
procedure InitializePaintBitmap;
procedure ResetPaintBitmap;
procedure ValidateImageIndex;
property NormalLongitudinalSize: Integer read GetNormalLongitudinalSize;
property ParentControl: TcxCustomTabControl read GetParentControl;
property PaintBitmap: TBitmap read FPaintBitmap;
property Tabs: TcxTabs read FTabs;
property VerticalTextBitmap: TBitmap read FVerticalTextBitmap;
public
constructor Create(ATabs: TcxTabs; AIndex: Integer);
destructor Destroy; override;
procedure ResetVerticalTextBitmap;
property FullRect: TRect read GetFullRect;
property HotTrack: Boolean read GetHotTrack;
property Index: Integer read FIndex;
property IsMainTab: Boolean read GetIsMainTab;
property NormalRect: TRect read GetNormalRect;
property PaintingPosition: TcxPCTabPaintingPosition read GetPaintingPosition;
property PaintingPositionIndex: Integer read GetPaintingPositionIndex;
property Pressed: Boolean read GetPressed;
property RealEnabled: Boolean read GetRealEnabled;
property RealVisible: Boolean read GetRealVisible;
property Tracking: Boolean read GetTracking;
property VisibleCaption: string read FVisibleCaption;
property VisibleIndex: Integer read GetVisibleIndex;
property VisibleRect: TRect read GetVisibleRect;
property VisibleRow: Integer read FVisibleRow;
published
property Caption: string read FCaption write SetCaption;
property Enabled: Boolean read FEnabled write SetEnabled default True;
property Highlighted: Boolean read FHighlighted write SetHighlighted;
property ImageIndex: {$IFDEF DELPHI5}TImageIndex{$ELSE}Integer{$ENDIF}
read GetImageIndex write SetImageIndex stored IsImageIndexStored;
property Selected: Boolean read FSelected write SetSelected;
property Visible: Boolean read FVisible write SetVisible default True;
end;
TcxTabs = class(TStrings)
private
FNotification: Boolean;
FParent: TcxCustomTabControl;
FTabNormalHeight: Integer;
FTabsItemA: array of TcxTab;
FUpdating: Boolean;
function GetTab(TabIndex: Integer): TcxTab;
function GetVisibleTab(TabVisibleIndex: Integer): TcxTab;
procedure SetTab(Index: Integer; const Value: TcxTab);
function GetVisibleTabsCount: Integer;
protected
function Get(Index: Integer): string; override;
function GetCount: Integer; override;
function GetObject(Index: Integer): TObject; override;
procedure PutObject(Index: Integer; AObject: TObject); override;
procedure Changed(VisibleIndex: Integer = -1; TabPropertyChanged: TcxPCTabPropertyChanged = tpcLayout);
procedure Notify(Index: Integer; Action: TcxPCTabNotification); virtual;
class procedure OutError(SourceMethodName: TCaption; Index: Integer); virtual;
procedure SetHotTrack(VisibleIndex: Integer);
procedure SetMainTab;
procedure SetTracking(NewTracking: Integer);
procedure UpdateTabIndexes(FirstIndex, LastIndex: Integer);
procedure ValidateImageIndexes;
property Parent: TcxCustomTabControl read FParent;
public
constructor Create(AParent: TcxCustomTabControl);
destructor Destroy; override;
procedure Clear; override;
procedure Delete(Index: Integer); override;
procedure Insert(Index: Integer; const S: string); override;
procedure ResetTabVerticalTextBitmaps;
public
property TabNormalHeight: Integer read FTabNormalHeight;
property Tabs[TabIndex: Integer]: TcxTab read GetTab write SetTab; default;
property VisibleTabsCount: Integer read GetVisibleTabsCount;
property VisibleTabs[TabVisibleIndex: Integer]: TcxTab read GetVisibleTab;
end;
TcxVisibleTabList = class
private
FParent: TcxCustomTabControl;
TabIndexA: array of TcxPCTabIndex;
function GetCount: Integer;
function GetTab(TabVisibleIndex: Integer): TcxTab;
procedure OutError(SourceMethodName: TCaption; Msg: string);
public
constructor Create(AParent: TcxCustomTabControl);
destructor Destroy; override;
function FindVisibleTab(TabIndex: TcxPCTabIndex; var TabVisibleIndex: Integer): Boolean;
procedure HideTab(TabIndex: TcxPCTabIndex);
procedure ShowTab(TabIndex: TcxPCTabIndex);
procedure Update;
function TabVisibleIndexOf(TabIndex: TcxPCTabIndex): Integer;
property Count: Integer read GetCount;
property Tabs[TabVisibleIndex: Integer]: TcxTab read GetTab; default;
end;
TcxPCPainterParentInfo = class
private
FParent: TcxCustomTabControl;
function GetCanvas: TcxCanvas;
function GetTabPosition: TcxTabPosition;
function GetNavigatorPositione: TcxPCNavigatorPosition;
function GetMultiLine: Boolean;
function GetNavigatorButtonState(
Index: TcxPCNavigatorButton): TcxPCNavigatorButtonState;
function GetVisibleTab(TabVisibleIndex: Integer): TcxTab;
function GetTabHeight: Smallint;
function GetTabWidth: Smallint;
function GetMainTabVisibleIndex: Integer;
function GetOptions: TcxPCOptions;
function GetFont: TFont;
function GetNavigatorButtons: TcxPCNavigatorButtons;
function GetHeight: Integer;
function GetWidth: Integer;
function GetExtendedBottomOrRightTabsRect: TRect;
function GetExtendedTopOrLeftTabsRect: TRect;
function GetRowCount: Integer;
function GetTopOrLeftPartRowCount: Integer;
function GetColor: TColor;
function GetHideTabs: Boolean;
function GetShowFrame: Boolean;
function GetRotate: Boolean;
function GetImageBorder: Integer;
function GetHotTrackColor: TColor;
function GetTextColor: TColor;
public
constructor Create(AParent: TcxCustomTabControl);
property Canvas: TcxCanvas read GetCanvas;
property Color: TColor read GetColor;
property ExtendedBottomOrRightTabsRect: TRect read GetExtendedBottomOrRightTabsRect;
property ExtendedTopOrLeftTabsRect: TRect read GetExtendedTopOrLeftTabsRect;
property Font: TFont read GetFont;
property Height: Integer read GetHeight;
property HideTabs: Boolean read GetHideTabs;
property HotTrackColor: TColor read GetHotTrackColor;
property ImageBorder: Integer read GetImageBorder;
property MultiLine: Boolean read GetMultiLine;
property NavigatorButtonsState[Index: TcxPCNavigatorButton]: TcxPCNavigatorButtonState read GetNavigatorButtonState;
property NavigatorButtons: TcxPCNavigatorButtons read GetNavigatorButtons;
property NavigatorPosition: TcxPCNavigatorPosition read GetNavigatorPositione;
property Options: TcxPCOptions read GetOptions;
property MainTabVisibleIndex: Integer read GetMainTabVisibleIndex;
property Rotate: Boolean read GetRotate;
property RowCount: Integer read GetRowCount;
property ShowFrame: Boolean read GetShowFrame;
property TabHeight: Smallint read GetTabHeight;
property TabPosition: TcxTabPosition read GetTabPosition;
property TabWidth: Smallint read GetTabWidth;
property TextColor: TColor read GetTextColor;
property TopOrLeftPartRowCount: Integer read GetTopOrLeftPartRowCount;
property VisibleTabs[TabVisibleIndex: Integer]: TcxTab read GetVisibleTab;
property Width: Integer read GetWidth;
end;
TcxPCCustomPainter = class
private
FParentInfo: TcxPCPainterParentInfo;
FParentControl: TcxCustomTabControl;
FSavedClipRgns: TList;
procedure DestroySavedClipRgns;
function GetDisabledTextFaceColor: TColor;
function GetDisabledTextShadowColor: TColor;
function GetHighlightedTabBodyColor: TColor;
protected
FOutTabImageAndTextData: TcxPCOutTabImageAndTextData;
function CalculateTabNormalHeight: Integer; virtual; abstract;
function CalculateTabNormalWidth(Tab: TcxTab): Integer; virtual; abstract;
procedure CorrectTabRect(TabVisibleIndex: Integer; var TabRectCorrection: TcxPCRectCorrection); virtual;
function CreateNewTabVerticalTextBitmap(TabVisibleIndex: Integer): TBitmap;
function DoCustomDraw(TabVisibleIndex: Integer): Boolean;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -