cxdropdownedit.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,810 行 · 第 1/5 页
PAS
1,810 行
{********************************************************************}
{ }
{ 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 cxDropDownEdit;
{$I cxVer.inc}
interface
uses
Windows, Messages,
{$IFDEF DELPHI6}
Variants,
{$ENDIF}
Classes, Controls, Graphics, Forms, SysUtils, cxClasses, cxContainer, cxControls,
cxEdit, cxGraphics, cxLookAndFeelPainters, cxLookAndFeels, cxMaskEdit,
cxTextEdit, cxVariants, cxFilterControlUtils, StdCtrls;
const
CM_POPUPCONTROLKEY = WM_DX + 50;
CM_DROPDOWNBYPASTE = WM_DX + 51;
type
TcxEditDropDownListStyle = (lsEditFixedList, lsEditList, lsFixedList);
TcxEditCorner = (ecoTopLeft, ecoTopRight, ecoBottomLeft, ecoBottomRight);
TcxEditMouseSizingDirection = (mmdWE, mmdNS, mmdNWSE, mmdNESW, mmdNone);
TcxCustomComboBox = class;
TcxCustomDropDownEdit = class;
TcxCustomDrawBorderEvent = procedure(AViewInfo: TcxContainerViewInfo; ACanvas: TcxCanvas; const R: TRect; var AHandled: Boolean;
out ABorderWidth: Integer) of object;
TcxEditDrawItemEvent = procedure(AControl: TcxCustomComboBox; ACanvas: TcxCanvas;
AIndex: Integer; const ARect: TRect; AState: TOwnerDrawState) of object;
TMeasureItemEvent = procedure(AControl: TcxCustomComboBox; AIndex: Integer;
ACanvas: TcxCanvas; var AHeight: Integer) of object;
{ TcxCustomEditPopupWindowViewInfo }
TcxCustomEditPopupWindowViewInfo = class(TcxContainerViewInfo)
private
FOnCustomDrawBorder: TcxCustomDrawBorderEvent;
protected
function DrawCustomBorder(ACanvas: TcxCanvas; const R: TRect; out ABorderWidth: Integer): Boolean;
procedure InternalPaint(ACanvas: TcxCanvas); override;
public
BorderStyle: TcxEditPopupBorderStyle;
ClientEdge: Boolean;
CloseButton: Boolean;
CloseButtonRect: TRect;
CloseButtonStyle: TcxLookAndFeelKind;
CloseButtonNativeState: Integer;
CloseButtonState: TcxButtonState;
MinSysPanelHeight: Integer;
NativeStyle: Boolean;
Painter: TcxCustomLookAndFeelPainterClass;
Shadow: Boolean;
Sizeable: Boolean;
SizeGripCorner: TcxEditCorner;
SizeGripRect: TRect;
SizeGripSizingRect: TRect;
SizingRegionBounds: TRect;
SizingOffset: Integer;
SysPanelHeight: Integer;
SysPanelStyle: Boolean;
procedure Calculate; virtual;
procedure DrawBorder(ACanvas: TcxCanvas; var R: TRect); reintroduce; virtual;
function GetBorderExtent: TRect; virtual;
function GetClientExtent: TRect; virtual;
function GetSysPanelHeight: Integer; virtual;
function IsSizingPlace(X, Y: Integer): Boolean; virtual;
property OnCustomDrawBorder: TcxCustomDrawBorderEvent read FOnCustomDrawBorder write FOnCustomDrawBorder;
end;
{ TcxCustomEditPopupWindow }
TcxCustomEditPopupWindow = class(TcxCustomPopupWindow)
private
FLockCheckSize: Boolean;
FPopupAutoSize: Boolean;
FBorderStyle: TcxEditPopupBorderStyle;
FClientEdge: Boolean;
FCloseButton: Boolean;
FMinHeight: Integer;
FMinWidth: Integer;
FNativeStyle: Boolean;
FPopupHeight: Integer;
FPopupWidth: Integer;
FShadow: Boolean;
FShowContentWhileResize: Boolean;
FSizeable: Boolean;
FSizeFrame: TcxSizeFrame;
FSysPanelStyle: Boolean;
function GetEdit: TcxCustomDropDownEdit;
function GetMinSysPanelHeight: Integer;
function GetViewInfo: TcxCustomEditPopupWindowViewInfo;
procedure SetPopupAutoSize(Value: Boolean);
procedure SetBorderStyle(Value: TcxEditPopupBorderStyle);
procedure SetClientEdge(Value: Boolean);
procedure SetCloseButton(Value: Boolean);
procedure SetMinSysPanelHeight(Value: Integer);
procedure SetNativeStyle(Value: Boolean);
procedure SetShadow(Value: Boolean);
procedure SetSizeable(Value: Boolean);
procedure SetSysPanelStyle(Value: Boolean);
procedure CMPopupControlKey(var Message: TMessage); message CM_POPUPCONTROLKEY;
protected
function AcceptsAnySize: Boolean; override;
procedure AdjustClientRect(var Rect: TRect); override;
function CalculatePosition: TPoint; override;
procedure CalculateSize; override;
procedure CreateParams(var Params: TCreateParams); override;
procedure DoClosed; override;
procedure DoClosing; override;
procedure ModalCloseUp; override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure MouseLeave(AControl: TControl); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure Resize; override;
procedure CalculateViewInfo; virtual;
function CanResize(var NewWidth, NewHeight: Integer): Boolean; override;
procedure DoPopupControlKey(Key: Char); virtual;
procedure DrawSizeFrame(const R: TRect);
function GetMaxVisualAreaSize: TSize;
function GetMinSize: TSize; virtual;
procedure InternalInvalidateRect(const ARect: TRect);
procedure RefreshPopupWindow;
public
constructor Create(AOwnerControl: TWinControl); override;
destructor Destroy; override;
function GetViewInfoClass: TcxContainerViewInfoClass; override;
procedure Popup(AFocusedControl: TWinControl); override;
property BorderStyle: TcxEditPopupBorderStyle read FBorderStyle write SetBorderStyle;
property ClientEdge: Boolean read FClientEdge write SetClientEdge;
property CloseButton: Boolean read FCloseButton write SetCloseButton;
property Edit: TcxCustomDropDownEdit read GetEdit;
property MinHeight: Integer read FMinHeight write FMinHeight;
property MinSize: TSize read GetMinSize;
property MinSysPanelHeight: Integer read GetMinSysPanelHeight write SetMinSysPanelHeight;
property MinWidth: Integer read FMinWidth write FMinWidth;
property NativeStyle: Boolean read FNativeStyle write SetNativeStyle;
property PopupAutoSize: Boolean read FPopupAutoSize write SetPopupAutoSize;
property PopupHeight: Integer read FPopupHeight write FPopupHeight;
property PopupWidth: Integer read FPopupWidth write FPopupWidth;
property Shadow: Boolean read FShadow write SetShadow;
property ShowContentWhileResize: Boolean read FShowContentWhileResize
write FShowContentWhileResize default False;
property Sizeable: Boolean read FSizeable write SetSizeable;
property SysPanelStyle: Boolean read FSysPanelStyle write SetSysPanelStyle;
property ViewInfo: TcxCustomEditPopupWindowViewInfo read GetViewInfo;
property OnClosed;
end;
TcxCustomEditPopupWindowClass = class of TcxCustomEditPopupWindow;
{ TcxCustomDropDownEditProperties }
TcxCustomDropDownEditProperties = class(TcxCustomMaskEditProperties)
private
FGlyphButtonIndex: Integer;
FImmediateDropDown: Boolean;
FImmediatePopup: Boolean;
FInternalChanging: Boolean;
FKeepArrowButtonPressedWhenDroppedDown: Boolean;
FPopupAutoSize: Boolean;
FPopupClientEdge: Boolean;
FPopupDirection: TcxPopupDirection;
FPopupHeight: Integer;
FPopupHorzAlignment: TcxPopupAlignHorz;
FPopupMinHeight: Integer;
FPopupMinWidth: Integer;
FPopupSizeable: Boolean;
FPopupSysPanelStyle: Boolean;
FPopupVertAlignment: TcxPopupAlignVert;
FPopupWidth: Integer;
FPostPopupValueOnTab: Boolean;
FOnCloseQuery: TCloseQueryEvent;
FOnCloseUp: TNotifyEvent;
FOnFinalizePopup: TNotifyEvent;
FOnInitPopup: TNotifyEvent;
FOnPopup: TNotifyEvent;
function GetButtonGlyph: TBitmap;
function GetPopupAlignment: TAlignment;
procedure SetButtonGlyph(Value: TBitmap);
procedure SetGlyphButtonIndex(Value: Integer);
procedure SetKeepArrowButtonPressedWhenDroppedDown(Value: Boolean);
procedure SetPopupAlignment(Value: TAlignment);
procedure SetPopupClientEdge(Value: Boolean);
procedure SetPopupHeight(Value: Integer);
procedure SetPopupMinHeight(Value: Integer);
procedure SetPopupMinWidth(Value: Integer);
procedure SetPopupSizeable(Value: Boolean);
procedure SetPopupSysPanelStyle(Value: Boolean);
procedure SetPopupWidth(Value: Integer);
protected
class function GetViewDataClass: TcxCustomEditViewDataClass; override;
function IsLookupDataVisual: Boolean; override;
function DropDownButtonVisibleIndex: Integer; virtual;
function DropDownOnClick: Boolean; virtual;
function GetAlwaysPostEditValue: Boolean; virtual;
class function GetPopupWindowClass: TcxCustomEditPopupWindowClass; virtual;
function PopupWindowAcceptsAnySize: Boolean; virtual;
function PopupWindowCapturesFocus: Boolean; virtual;
property AlwaysPostEditValue: Boolean read GetAlwaysPostEditValue;
property GlyphButtonIndex: Integer read FGlyphButtonIndex write SetGlyphButtonIndex;
public
constructor Create(AOwner: TPersistent); override;
procedure Assign(Source: TPersistent); override;
procedure Changed; override;
class function GetContainerClass: TcxContainerClass; override;
// !!!
property ButtonGlyph: TBitmap read GetButtonGlyph write SetButtonGlyph;
property ImmediateDropDown: Boolean read FImmediateDropDown write FImmediateDropDown default True;
property ImmediatePopup: Boolean read FImmediatePopup write FImmediatePopup default False;
property KeepArrowButtonPressedWhenDroppedDown: Boolean
read FKeepArrowButtonPressedWhenDroppedDown
write SetKeepArrowButtonPressedWhenDroppedDown default False;
property PopupAlignment: TAlignment read GetPopupAlignment write SetPopupAlignment default taLeftJustify;
property PopupAutoSize: Boolean read FPopupAutoSize write FPopupAutoSize default True;
property PopupClientEdge: Boolean read FPopupClientEdge write SetPopupClientEdge default False;
property PopupDirection: TcxPopupDirection read FPopupDirection write FPopupDirection;
property PopupHeight: Integer read FPopupHeight write SetPopupHeight default 200;
property PopupHorzAlignment: TcxPopupAlignHorz read FPopupHorzAlignment write FPopupHorzAlignment;
property PopupMinHeight: Integer read FPopupMinHeight write SetPopupMinHeight default 100;
property PopupMinWidth: Integer read FPopupMinWidth write SetPopupMinWidth default 100;
property PopupSizeable: Boolean read FPopupSizeable write SetPopupSizeable default False;
property PopupSysPanelStyle: Boolean read FPopupSysPanelStyle write SetPopupSysPanelStyle default False;
property PopupVertAlignment: TcxPopupAlignVert read FPopupVertAlignment write FPopupVertAlignment;
property PopupWidth: Integer read FPopupWidth write SetPopupWidth default 250;
property PostPopupValueOnTab: Boolean read FPostPopupValueOnTab
write FPostPopupValueOnTab default False;
property OnCloseQuery: TCloseQueryEvent read FOnCloseQuery write FOnCloseQuery;
property OnCloseUp: TNotifyEvent read FOnCloseUp write FOnCloseUp;
property OnFinalizePopup: TNotifyEvent read FOnFinalizePopup write FOnFinalizePopup;
property OnInitPopup: TNotifyEvent read FOnInitPopup write FOnInitPopup;
property OnPopup: TNotifyEvent read FOnPopup write FOnPopup;
end;
TcxCustomDropDownEditPropertiesClass = class of TcxCustomDropDownEditProperties;
{ TcxCustomDropDownEditViewData }
TcxCustomDropDownEditViewData = class(TcxCustomTextEditViewData)
private
function GetProperties: TcxCustomDropDownEditProperties;
protected
function CanPressButton(AViewInfo: TcxCustomEditViewInfo; AButtonVisibleIndex: Integer): Boolean; override;
function GetEditNativeState(AViewInfo: TcxCustomEditViewInfo): Integer; override;
function IsButtonPressed(AViewInfo: TcxCustomEditViewInfo;
AButtonVisibleIndex: Integer): Boolean; override;
public
HasPopupWindow: Boolean;
IsHotAndPopup: Boolean;
KeepArrowButtonPressedWhenDroppedDown: Boolean;
procedure Calculate(ACanvas: TcxCanvas; const ABounds: TRect; const P: TPoint;
Button: TcxMouseButton; Shift: TShiftState; AViewInfo: TcxCustomEditViewInfo;
AIsMouseEvent: Boolean); override;
property Properties: TcxCustomDropDownEditProperties read GetProperties;
end;
{ TcxCustomDropDownEditData }
TcxCustomDropDownEditData = class(TcxCustomEditData)
protected
Initialized: Boolean;
Width, Height: Integer;
end;
TcxCustomDropDownEditDataClass = class of TcxCustomDropDownEditData;
{ TcxEditPopupControlLookAndFeel }
TcxEditPopupControlLookAndFeel = class(TcxLookAndFeel)
private
function GetEdit: TcxCustomDropDownEdit;
protected
procedure EditStyleChanged;
function InternalGetKind: TcxLookAndFeelKind; override;
function InternalGetNativeStyle: Boolean; override;
function InternalGetSkinName: string; override;
property Edit: TcxCustomDropDownEdit read GetEdit;
end;
{ TcxCustomDropDownInnerEdit }
TcxCustomDropDownInnerEdit = class(TcxCustomInnerTextEdit)
private
function GetContainer: TcxCustomDropDownEdit;
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
protected
property Container: TcxCustomDropDownEdit read GetContainer;
// TODO CLX
end;
{ TcxCustomDropDownEdit }
TcxCustomDropDownEdit = class(TcxCustomMaskEdit)
private
FIsActivatingByMouse: Boolean;
FIsHotAndPopup: Boolean;
FPopupControlsLookAndFeel: TcxEditPopupControlLookAndFeel;
FPopupInitialized: Boolean;
FPopupMouseMoveLocked: Boolean;
FPopupSizeChanged: Boolean;
FPopupSizeChangedByMouse: Boolean;
FSendChildrenStyle: Boolean;
procedure DropDownByPasteHandler;
function GetDroppedDown: Boolean;
function GetProperties: TcxCustomDropDownEditProperties;
function GetActiveProperties: TcxCustomDropDownEditProperties;
procedure SetDroppedDown(Value: Boolean);
procedure SetProperties(Value: TcxCustomDropDownEditProperties);
procedure CMBiDiModeChanged(var Message: TMessage); message CM_BIDIMODECHANGED;
procedure CMDropDownByPaste(var Message: TMessage); message CM_DROPDOWNBYPASTE;
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
protected
FCloseUpReason: TcxEditCloseUpReason;
FPopupWindow: TcxCustomEditPopupWindow;
procedure ContainerStyleChanged(Sender: TObject); override;
function CreateViewData: TcxCustomEditViewData; override;
procedure DestroyWnd; override;
procedure DoButtonDown(AButtonVisibleIndex: Integer); override;
procedure DoExit; override;
procedure DoEditKeyDown(var Key: Word; Shift: TShiftState); override;
procedure DoEditKeyPress(var Key: Char); override;
procedure DoEditProcessTab(Shift: TShiftState); override;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?