cxtrackbar.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,699 行 · 第 1/5 页
PAS
1,699 行
{********************************************************************}
{ }
{ Developer Express Visual Component Library }
{ ExpressEditors }
{ }
{ Copyright (c) 1998-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 EXPRESSEDITORS 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 cxTrackBar;
{$I cxVer.inc}
interface
uses
{$IFDEF DELPHI6}
Types, Variants,
{$ENDIF}
Windows, Classes, Controls, Forms, Graphics, Messages, SysUtils, cxClasses,
cxContainer, cxControls, cxCustomData, cxEdit, cxExtEditConsts, cxLookAndFeelPainters,
cxFilterControlUtils, cxGraphics, cxLookAndFeels, cxTextEdit, cxVariants, Math;
type
TcxTrackBarOrientation = (tboHorizontal, tboVertical);
TcxTrackBarTextOrientation = (tbtoHorizontal, tbtoVertical);
TcxTrackBarTickMarks = (cxtmBoth, cxtmTopLeft, cxtmBottomRight);
TcxTrackBarTickType = (tbttTicks, tbttNumbers, tbttValueNumber);
TcxTrackBarMouseState = (tbmpInControl, tbmpUnderThumb, tbmpSliding);
TcxTrackBarMouseStates = set of TcxTrackBarMouseState;
TcxTrackBarSlideState = (tbksNormal, tbksIncludeSelection);
TcxTrackBarThumbType = (cxttNone, cxttRegular, cxttCustom);
TcxTrackBarThumbStep = (cxtsNormal, cxtsJump);
TcxGetThumbRectEvent = procedure(Sender: TObject; var ARect: TRect) of object;
TcxDrawThumbEvent = procedure(Sender: TObject; ACanvas: TcxCanvas;
const ARect: TRect) of object;
{ TcxTrackBarStyle }
TcxTrackBarStyle = class(TcxEditStyle)
protected
function DefaultBorderStyle: TcxContainerBorderStyle; override;
function DefaultHotTrack: Boolean; override;
end;
{ TcxCustomTrackBarViewInfo }
TcxCustomTrackBar = class;
TcxCustomTrackBarViewInfo = class(TcxCustomTextEditViewInfo)
private
FLookAndFeel: TcxLookAndFeel;
FPosition: Integer;
FSelectionEnd: Integer;
FSelectionStart: Integer;
FShowSelection: Boolean;
FTBBitmap: TBitmap;
FTBCanvas: TcxCanvas;
FThumbHeight: Integer;
FThumbWidth: Integer;
FTrackBarState: Integer;
FTrackSize: Integer;
function GetEdit: TcxCustomTrackBar;
protected
RealTrackBarRect: TRect;
TrackBarRect: TRect;
TrackZoneRect: TRect;
TrackRect: TRect;
ThumbRect: TRect;
SelectionRect: TRect;
FromBorderIndent: Integer;
procedure DrawTrack(ACanvas: TcxCanvas); virtual;
procedure DrawSelection(ACanvas: TcxCanvas); virtual;
procedure DrawTicks(ACanvas: TcxCanvas); virtual;
procedure DrawThumb(ACanvas: TcxCanvas); virtual;
function DrawingThumbRectToRealThumbRect(ACanvas: TcxCanvas): TRect; virtual;
function GetThumbThemeType: Byte; virtual;
procedure PaintTrackBar(ACanvas: TcxCanvas); virtual;
public
FocusRect: TRect;
HasForegroundImage: Boolean;
MouseStates: TcxTrackBarMouseStates;
NeedPointer: Boolean;
ThumbLargeSize, ThumbSize, TrackRectDelta: Integer;
TickColor: TColor;
TickOffset: Double;
TrackBarBorderWidth: Integer;
TrackHeight, TrackWidth: Integer;
procedure Assign(Source: TObject); override;
procedure DrawText(ACanvas: TcxCanvas); override;
function GetUpdateRegion(AViewInfo: TcxContainerViewInfo): TcxRegion; override;
function IsHotTrack: Boolean; overload; override;
function IsHotTrack(P: TPoint): Boolean; overload; override;
function NeedShowHint(ACanvas: TcxCanvas; const P: TPoint; out AText: TCaption;
out AIsMultiLine: Boolean; out ATextRect: TRect): Boolean; override;
procedure Offset(DX, DY: Integer); override;
procedure Paint(ACanvas: TcxCanvas); override;
constructor Create; override;
destructor Destroy; override;
property Edit: TcxCustomTrackBar read GetEdit;
property LookAndFeel: TcxLookAndFeel read FLookAndFeel write FLookAndFeel;
property Position: Integer read FPosition write FPosition;
property SelectionEnd: Integer read FSelectionEnd write FSelectionEnd;
property SelectionStart: Integer read FSelectionStart write FSelectionStart;
property ThumbHeight: Integer read FThumbHeight write FThumbHeight;
property ThumbWidth: Integer read FThumbWidth write FThumbWidth;
property TrackBarState: Integer read FTrackBarState write FTrackBarState;
property TrackSize: Integer read FTrackSize write FTrackSize;
end;
{ TcxCustomTrackBarViewData }
TcxCustomTrackBarProperties = class;
TcxCustomTrackBarViewData = class(TcxCustomEditViewData)
private
procedure GetOnGetThumbRect(out AValue: TcxGetThumbRectEvent);
function GetProperties: TcxCustomTrackBarProperties;
protected
procedure CalculateCustomTrackBarRects(ACanvas: TcxCanvas;
AViewInfo: TcxCustomTrackBarViewInfo); virtual;
function InternalGetEditConstantPartSize(ACanvas: TcxCanvas; AIsInplace: Boolean;
AEditSizeProperties: TcxEditSizeProperties;
var MinContentSize: TSize; AViewInfo: TcxCustomEditViewInfo): TSize; override;
function GetTopLeftTickSize(ACanvas: TcxCanvas;
AViewInfo: TcxCustomTrackBarViewInfo; ALeftTop: Boolean): Integer; virtual;
procedure CalculateTBViewInfoProps(AViewInfo: TcxCustomEditViewInfo); virtual;
procedure CalculateTrackBarRect(AViewInfo: TcxCustomTrackBarViewInfo); virtual;
procedure CalculateTrackZoneRect(ACanvas: TcxCanvas;
AViewInfo: TcxCustomTrackBarViewInfo); virtual;
procedure CalculateTrackRect(AViewInfo: TcxCustomTrackBarViewInfo); virtual;
procedure CalculateThumbSize(AViewInfo: TcxCustomTrackBarViewInfo); virtual;
procedure CalculateThumbRect(ACanvas: TcxCanvas;
AViewInfo: TcxCustomTrackBarViewInfo); virtual;
procedure CalculateSelectionRect(AViewInfo: TcxCustomTrackBarViewInfo); virtual;
procedure DoOnGetThumbRect(var ARect: TRect);
function IsOnGetThumbRectEventAssigned: Boolean;
public
procedure Calculate(ACanvas: TcxCanvas; const ABounds: TRect; const P: TPoint;
Button: TcxMouseButton; Shift: TShiftState; AViewInfo: TcxCustomEditViewInfo;
AIsMouseEvent: Boolean); override;
procedure EditValueToDrawValue(ACanvas: TcxCanvas; const AEditValue: TcxEditValue;
AViewInfo: TcxCustomEditViewInfo); override;
property Properties: TcxCustomTrackBarProperties read GetProperties;
end;
{ TcxCustomTrackBarProperties }
TcxCustomTrackBarProperties = class(TcxCustomEditProperties)
private
FAutoSize: Boolean;
FBorderWidth: Integer;
FFrequency: Integer;
FMin: Integer;
FMax: Integer;
FOrientation: TcxTrackBarOrientation;
FTextOrientation: TcxTrackBarTextOrientation;
FPageSize: TcxNaturalNumber;
FSelectionStart: Integer;
FSelectionEnd: Integer;
FSelectionColor: TColor;
FShowTicks: Boolean;
FThumbType: TcxTrackBarThumbType;
FShowTrack: Boolean;
FTickColor: TColor;
FTickType: TcxTrackBarTickType;
FTickMarks: TcxTrackBarTickMarks;
FTickSize: TcxNaturalNumber;
FTrackColor: TColor;
FTrackSize: Integer;
FTrackRect: TRect;
FThumbRect: TRect;
FThumbHeight: Integer;
FThumbWidth: Integer;
FThumbColor: TColor;
FThumbHighlightColor: TColor;
FThumbStep: TcxTrackBarThumbStep;
FTickOffset: Double;
FOnGetThumbRect: TcxGetThumbRectEvent;
FOnDrawThumb: TcxDrawThumbEvent;
procedure SetAutoSize(Value: Boolean);
procedure SetBorderWidth(Value: Integer);
procedure SetFrequency(Value: Integer);
procedure SetMin(Value: Integer);
procedure SetMax(Value: Integer);
procedure SetOrientation(Value: TcxTrackBarOrientation);
procedure SetTextOrientation(Value: TcxTrackBarTextOrientation);
procedure SetPageSize(Value: TcxNaturalNumber);
procedure SetSelectionStart(Value: Integer);
procedure SetSelectionEnd(Value: Integer);
procedure SetSelectionColor(Value: TColor);
procedure SetShowTicks(Value: Boolean);
procedure SetThumbType(Value: TcxTrackBarThumbType);
procedure SetShowTrack(Value: Boolean);
procedure SetTickColor(Value: TColor);
procedure SetTickType(Value: TcxTrackBarTickType);
procedure SetTickMarks(Value: TcxTrackBarTickMarks);
procedure SetTickSize(Value: TcxNaturalNumber);
procedure SetTrackColor(Value: TColor);
procedure SetTrackSize(Value: Integer);
procedure SetThumbHeight(Value: Integer);
procedure SetThumbWidth(Value: Integer);
procedure SetThumbColor(Value: TColor);
procedure SetThumbHighlightColor(Value: TColor);
procedure DoDrawThumb(Sender: TObject; ACanvas: TcxCanvas; const ARect: TRect);
protected
class function GetViewDataClass: TcxCustomEditViewDataClass; override;
function HasDisplayValue: Boolean; override;
function FixPosition(const APosition: Integer): Integer; virtual;
function EditValueToPosition(const AEditValue: TcxEditValue): Integer;
public
constructor Create(AOwner: TPersistent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function CanCompareEditValue: Boolean; override;
class function GetContainerClass: TcxContainerClass; override;
function GetDisplayText(const AEditValue: TcxEditValue;
AFullText: Boolean = False; AIsInplace: Boolean = True): WideString; override;
class function GetStyleClass: TcxCustomEditStyleClass; override;
function GetSupportedOperations: TcxEditSupportedOperations; override;
class function GetViewInfoClass: TcxContainerViewInfoClass; override;
function IsEditValueValid(var EditValue: TcxEditValue; AEditFocused: Boolean): Boolean; override;
procedure PrepareDisplayValue(const AEditValue: TcxEditValue;
var DisplayValue: TcxEditValue; AEditFocused: Boolean); override;
// !!!
property AutoSize: Boolean read FAutoSize write SetAutoSize default True;
property BorderWidth: Integer read FBorderWidth write SetBorderWidth
default 0;
property Frequency: Integer read FFrequency write SetFrequency default 1;
property Max: Integer read FMax write SetMax default 10;
property Min: Integer read FMin write SetMin default 0;
property Orientation: TcxTrackBarOrientation read FOrientation
write SetOrientation default tboHorizontal;
property PageSize: TcxNaturalNumber read FPageSize write SetPageSize
default 1;
property SelectionColor: TColor read FSelectionColor write SetSelectionColor
default clHighlight;
property SelectionEnd: Integer read FSelectionEnd write SetSelectionEnd
default 0;
property SelectionStart: Integer read FSelectionStart
write SetSelectionStart default 0;
property ShowTicks: Boolean read FShowTicks write SetShowTicks default True;
property ShowTrack: Boolean read FShowTrack write SetShowTrack default True;
property TextOrientation: TcxTrackBarTextOrientation read FTextOrientation
write SetTextOrientation default tbtoHorizontal;
property ThumbColor: TColor read FThumbColor write SetThumbColor
default clBtnFace;
property ThumbHeight: Integer read FThumbHeight write SetThumbHeight
default 12;
property ThumbHighlightColor: TColor read FThumbHighlightColor
write SetThumbHighlightColor default clSilver;
property ThumbStep: TcxTrackBarThumbStep read FThumbStep write FThumbStep
default cxtsNormal;
property ThumbType: TcxTrackBarThumbType read FThumbType write SetThumbType
default cxttRegular;
property ThumbWidth: Integer read FThumbWidth write SetThumbWidth default 7;
property TickColor: TColor read FTickColor write SetTickColor
default clWindowText;
property TickMarks: TcxTrackBarTickMarks read FTickMarks write SetTickMarks
default cxtmBottomRight;
property TickSize: TcxNaturalNumber read FTickSize write SetTickSize
default 3;
property TickType: TcxTrackBarTickType read FTickType write SetTickType
default tbttTicks;
property TrackColor: TColor read FTrackColor write SetTrackColor
default clWindow;
property TrackSize : Integer read FTrackSize write SetTrackSize default 5;
property OnDrawThumb: TcxDrawThumbEvent read FOnDrawThumb
write FOnDrawThumb;
property OnGetThumbRect: TcxGetThumbRectEvent read FOnGetThumbRect
write FOnGetThumbRect;
end;
{ TcxTrackBarProperties }
TcxTrackBarProperties = class(TcxCustomTrackBarProperties)
published
property AutoSize;
property BorderWidth;
property ClearKey;
property Frequency;
property Max;
property Min;
property Orientation;
property PageSize;
property SelectionColor;
property SelectionEnd;
property SelectionStart;
property ShowTicks;
property ShowTrack;
property TextOrientation;
property ThumbColor;
property ThumbHeight;
property ThumbHighlightColor;
property ThumbStep;
property ThumbType;
property ThumbWidth;
property TickColor;
property TickMarks;
property TickSize;
property TickType;
property TrackColor;
property TrackSize;
property OnChange;
property OnDrawThumb;
property OnGetThumbRect;
end;
{ TcxCustomTrackBar }
TcxCustomTrackBar = class(TcxCustomEdit)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?