cxshellcombobox.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,877 行 · 第 1/5 页
PAS
1,877 行
{********************************************************************}
{ }
{ 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 cxShellComboBox;
{$I cxVer.inc}
interface
uses
Windows, Messages, Classes, ComCtrls, Controls, ImgList, ShlObj, cxClasses,
cxContainer, cxDataUtils, cxDropDownEdit, cxEdit, cxGraphics, cxTextEdit,
cxShellListView, cxShellTreeView, cxShellCommon, cxShellControls;
type
TcxShellComboBoxViewOption = (scvoShowFiles, scvoShowHidden);
TcxShellComboBoxViewOptions = set of TcxShellComboBoxViewOption;
TcxPopupShellTreeViewOption = (tvoContextMenus, tvoHotTrack, tvoShowButtons,
tvoShowInfoTips, tvoShowLines, tvoShowRoot, tvoShowToolTip,
tvoRightClickSelect);
TcxPopupShellTreeViewOptions = set of TcxPopupShellTreeViewOption;
TcxShellComboBoxShowFullPath = (sfpNever, sfpAlways, sfpNotFocused);
{ TcxShellComboBoxViewInfo }
TcxShellComboBoxViewInfo = class(TcxCustomTextEditViewInfo)
public
ShellIconPosition: TPoint;
ShellSysIconIndex: Integer;
ShellSysIconOverlayIndex: Integer;
procedure Offset(DX, DY: Integer); override;
procedure Paint(ACanvas: TcxCanvas); override;
end;
{ TcxShellComboBoxViewData }
TcxCustomShellComboBoxProperties = class;
TcxShellComboBoxViewData = class(TcxCustomDropDownEditViewData)
private
function GetProperties: TcxCustomShellComboBoxProperties;
protected
function InternalEditValueToDisplayText(AEditValue: TcxEditValue): string; override;
function InternalGetEditConstantPartSize(ACanvas: TcxCanvas; AIsInplace: Boolean;
AEditSizeProperties: TcxEditSizeProperties; var MinContentSize: TSize;
AViewInfo: TcxCustomEditViewInfo): TSize; override;
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;
function GetClientExtent(ACanvas: TcxCanvas;
AViewInfo: TcxCustomEditViewInfo): TRect; override;
property Properties: TcxCustomShellComboBoxProperties read GetProperties;
end;
{ TcxShellComboBoxRoot }
TcxShellComboBoxRoot = class(TcxCustomShellRoot)
private
FOnChange: TNotifyEvent;
protected
procedure RootUpdated; override;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
{ TcxShellComboBoxLookupData }
TcxCustomShellComboBox = class;
TcxShellComboBoxLookupData = class(TcxCustomTextEditLookupData)
private
function GetEdit: TcxCustomShellComboBox;
protected
function GetItem(Index: Integer): string; override;
function GetItemCount: Integer; override;
procedure ListChanged; override;
property Edit: TcxCustomShellComboBox read GetEdit;
end;
{ TcxCustomShellComboBoxProperties }
TcxCustomShellComboBoxProperties = class(TcxCustomPopupEditProperties)
private
FFastSearch: Boolean;
FIncrementalSearch: Boolean;
FRoot: TcxShellComboBoxRoot;
FShowFullPath: TcxShellComboBoxShowFullPath;
FStoreRelativePath: Boolean;
FTreeViewOptions: TcxPopupShellTreeViewOptions;
FViewOptions: TcxShellComboBoxViewOptions;
FOnAddFolder: TcxShellAddFolderEvent;
FOnRootSettingsChanged: TNotifyEvent;
procedure DoRootSettingsChanged;
function GetDropDownSizeable: Boolean;
function GetDropDownWidth: Integer;
procedure RootChangeHandler(Sender: TObject);
procedure RootSettingsChanged(Sender: TObject);
procedure SetDropDownSizeable(Value: Boolean);
procedure SetDropDownWidth(Value: Integer);
procedure SetFastSearch(Value: Boolean);
procedure SetIncrementalSearch(Value: Boolean);
procedure SetShowFullPath(Value: TcxShellComboBoxShowFullPath);
procedure SetStoreRelativePath(Value: Boolean);
procedure SetTreeViewOptions(Value: TcxPopupShellTreeViewOptions);
procedure SetViewOptions(Value: TcxShellComboBoxViewOptions);
protected
class function GetPopupWindowClass: TcxCustomEditPopupWindowClass; override;
class function GetViewDataClass: TcxCustomEditViewDataClass; override;
procedure CheckRoot;
function EditValueToPIDL(const AEditValue: TcxEditValue): PItemIDList; virtual;
function GetShellViewOptions: TcxShellViewOptions;
procedure RootChanged; virtual;
property OnRootSettingsChanged: TNotifyEvent read FOnRootSettingsChanged
write FOnRootSettingsChanged;
public
constructor Create(AOwner: TPersistent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function CompareDisplayValues(
const AEditValue1, AEditValue2: TcxEditValue): Boolean; override;
class function GetContainerClass: TcxContainerClass; override;
function GetDisplayText(const AEditValue: TcxEditValue;
AFullText: Boolean = False; AIsInplace: Boolean = True): WideString; override;
function GetEditValueSource(AEditFocused: Boolean): TcxDataEditValueSource; override;
class function GetLookupDataClass: TcxInterfacedPersistentClass; override;
procedure GetShellDisplayValue(const AEditValue: TcxEditValue;
AFocused: Boolean; out AText: string;
out AShellSysIconIndex, AShellSysIconOverlayIndex: Integer);
class function GetViewInfoClass: TcxContainerViewInfoClass; override;
function IsEditValueValid(var EditValue: TcxEditValue;
AEditFocused: Boolean): Boolean; override;
// !!!
property DropDownSizeable: Boolean read GetDropDownSizeable write SetDropDownSizeable default True;
property DropDownWidth: Integer read GetDropDownWidth write SetDropDownWidth
default 250;
property FastSearch: Boolean read FFastSearch write SetFastSearch default False;
property IncrementalSearch: Boolean read FIncrementalSearch
write SetIncrementalSearch default False;
property Root: TcxShellComboBoxRoot read FRoot write FRoot;
property ShowFullPath: TcxShellComboBoxShowFullPath read FShowFullPath
write SetShowFullPath default sfpNever;
property StoreRelativePath: Boolean read FStoreRelativePath write SetStoreRelativePath default True;
property TreeViewOptions: TcxPopupShellTreeViewOptions read FTreeViewOptions
write SetTreeViewOptions default [tvoContextMenus, tvoHotTrack,
tvoShowButtons, tvoShowLines, tvoShowRoot, tvoShowToolTip];
property ViewOptions: TcxShellComboBoxViewOptions read FViewOptions
write SetViewOptions default [];
property OnAddFolder: TcxShellAddFolderEvent read FOnAddFolder
write FOnAddFolder;
end;
{ TcxShellComboBoxProperties }
TcxShellComboBoxProperties = class(TcxCustomShellComboBoxProperties)
published
property Alignment;
property AssignedValues;
property AutoSelect;
property ButtonGlyph;
property ClearKey;
property DropDownSizeable;
property DropDownWidth;
property FastSearch;
property HideSelection;
property ImeMode;
property ImeName;
property IncrementalSearch;
property PopupAlignment;
property ReadOnly;
property Root;
property ShowFullPath;
property StoreRelativePath;
property TreeViewOptions;
property UseLeftAlignmentOnEditing;
property ValidateOnEnter;
property ViewOptions;
property OnAddFolder;
property OnChange;
property OnCloseUp;
property OnEditValueChanged;
property OnPopup;
end;
{ TcxPopupShellTreeView }
TcxPopupShellTreeView = class(TcxShellTreeView)
private
function GetEdit: TcxCustomShellComboBox;
protected
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure DoSelectNode(AClosePopupReason: TcxEditCloseUpReason); virtual;
property Edit: TcxCustomShellComboBox read GetEdit;
end;
TcxPopupShellTreeViewClass = class of TcxPopupShellTreeView;
{ TcxShellComboBoxPopupWindow }
TcxShellComboBoxPopupWindow = class(TcxPopupEditPopupWindow)
private
procedure WMEnable(var Message: TMessage); message WM_ENABLE;
end;
{ TcxCustomShellComboBox }
TcxCustomShellComboBox = class(TcxCustomPopupEdit)
private
FAbsolutePIDL: PItemIDList;
FIsDependentShellControlsNotification, FNotificationFromDependentShellControls: Boolean;
FIsSelectedNodeChangeEventLocked: Boolean;
FPopupShellTreeView: TcxPopupShellTreeView;
FPopupWindowShowing: Boolean;
FShellListView: TcxCustomShellListView;
FShellTreeView: TcxCustomShellTreeView;
procedure AddFolderHandler(Sender: TObject; AFolder: TcxShellFolder;
var ACanAdd: Boolean);
function GetAbsolutePIDL: PItemIDList;
function GetActiveProperties: TcxCustomShellComboBoxProperties;
function GetPath: string;
function GetProperties: TcxCustomShellComboBoxProperties;
// function GetRelativePath: string;
function GetViewInfo: TcxShellComboBoxViewInfo;
procedure RootChangeHandler(Sender: TObject);
procedure RootSettingsChanged(Sender: TObject);
procedure SetAbsolutePIDL(Value: PItemIDList);
procedure SetPath(const Value: string);
procedure SetProperties(Value: TcxCustomShellComboBoxProperties);
procedure SetRelativePIDL(Value: PItemIDList);
// procedure SetRelativePath(const Value: string);
procedure SetShellListView(Value: TcxCustomShellListView);
procedure SetShellTreeView(Value: TcxCustomShellTreeView);
procedure DSMDoNavigate(var Message: TMessage); message DSM_DONAVIGATE;
procedure DSMSynchronizeRoot(var Message: TMessage); message DSM_SYNCHRONIZEROOT;
protected
function CanDropDown: Boolean; override;
procedure CloseUp(AReason: TcxEditCloseUpReason); override;
procedure CreatePopupWindow; override;
procedure DoInitPopup; override;
procedure DropDown; override;
procedure HandleSelectItem(Sender: TObject); override;
procedure Initialize; override;
procedure InitializePopupWindow; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure PopupWindowShowed(Sender: TObject); override;
procedure PopupWindowShowing(Sender: TObject); override;
procedure PropertiesChanged(Sender: TObject); override;
procedure SynchronizeDisplayValue; override;
procedure SynchronizeEditValue; override;
function CheckAbsolutePIDL(var APIDL: PItemIDList;
ACheckObjectExistence: Boolean): Boolean;
procedure CheckPopupShellTreeView;
function FindNodeAmongExpandedNodes(ANodeText: string): TTreeNode;
function GetPopupShellTreeViewClass: TcxPopupShellTreeViewClass; virtual;
procedure InternalSetAbsolutePIDL(Value: PItemIDList);
procedure InternalSynchronizeEditValue(APIDL: PItemIDList;
const ADisplayText: string = ''); virtual;
procedure InvalidateShellIconRect;
procedure SelectedNodeChangeHandler(Sender: TObject; ANode: TTreeNode); virtual;
procedure SynchronizeDependentShellControls;
procedure SynchronizePopupShellTreeView;
function TraverseAllVisibleNodes(var ANodeIndex: Integer;
ATreeNode: TTreeNode = nil): TTreeNode;
property ShellListView: TcxCustomShellListView read FShellListView write SetShellListView;
property ShellTreeView: TcxCustomShellTreeView read FShellTreeView write SetShellTreeView;
property ViewInfo: TcxShellComboBoxViewInfo read GetViewInfo;
public
destructor Destroy; override;
function CanHide: Boolean; override;
class function GetPropertiesClass: TcxCustomEditPropertiesClass; override;
property AbsolutePIDL: PItemIDList read GetAbsolutePIDL write SetAbsolutePIDL;
property AbsolutePath: string read GetPath write SetPath; // deprecated
property ActiveProperties: TcxCustomShellComboBoxProperties
read GetActiveProperties;
property Path: string read GetPath write SetPath;
property PopupShellTreeView: TcxPopupShellTreeView read FPopupShellTreeView;
property Properties: TcxCustomShellComboBoxProperties read GetProperties
write SetProperties;
property RelativePIDL: PItemIDList write SetRelativePIDL; // TODO
// property RelativePath: string read GetRelativePath write SetRelativePath;
end;
{ TcxShellComboBox }
TcxShellComboBox = class(TcxCustomShellComboBox)
private
function GetActiveProperties: TcxShellComboBoxProperties;
function GetProperties: TcxShellComboBoxProperties;
procedure SetProperties(Value: TcxShellComboBoxProperties);
public
class function GetPropertiesClass: TcxCustomEditPropertiesClass; override;
property ActiveProperties: TcxShellComboBoxProperties
read GetActiveProperties;
published
property Align;
property Anchors;
property AutoSize;
property BeepOnEnter;
property Constraints;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property ImeMode;
property ImeName;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property Properties: TcxShellComboBoxProperties read GetProperties
write SetProperties;
property ShellListView;
property ShellTreeView;
property ShowHint;
property Style;
property StyleDisabled;
property StyleFocused;
property StyleHot;
property TabOrder;
property TabStop;
property Visible;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEditing;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?