cxhyperlinkedit.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 611 行 · 第 1/2 页
PAS
611 行
{********************************************************************}
{ }
{ 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 cxHyperLinkEdit;
{$I cxVer.inc}
interface
uses
Messages,
Windows,
{$IFDEF DELPHI6}
Types,
{$ENDIF}
SysUtils, Graphics, Classes, Controls, Menus, cxGraphics, cxContainer,
cxControls, cxEdit, cxTextEdit, cxEditConsts, cxFilterControlUtils;
const
cxHyperLinkEditDefaultLinkColor = clBlue;
type
{ TcxHyperLinkEditViewInfo }
TcxCustomHyperLinkEdit = class;
TcxHyperLinkEditViewInfo = class(TcxCustomTextEditViewInfo)
protected
procedure GetColorSettingsByPainter(out ABackground, ATextColor: TColor); override;
public
function IsHotTrack: Boolean; override;
function IsHotTrack(P: TPoint): Boolean; override;
procedure PrepareCanvasFont(ACanvas: TCanvas); override;
end;
{ TcxCustomHyperLinkEditProperties }
TcxHyperLinkEditUsePrefix = (upAlways, upOnlyOnExecute, upNever);
TcxCustomHyperLinkEditProperties = class(TcxCustomTextEditProperties)
private
FSingleClick: Boolean;
FLinkColor: TColor;
FOnStartClick: TNotifyEvent;
FPrefix: string;
FStartKey: TShortCut;
FUsePrefix: TcxHyperLinkEditUsePrefix;
function GetAutoComplete: Boolean;
function GetPrefixStored: Boolean;
procedure ReadPrefix(Reader: TReader);
procedure SetAutoComplete(Value: Boolean);
procedure SetLinkColor(const Value: TColor);
procedure SetSingleClick(Value: Boolean);
procedure WritePrefix(Writer: TWriter);
protected
procedure DefineProperties(AFiler: TFiler); override;
function AddPrefixTo(AStr: string): string; virtual;
public
constructor Create(AOwner: TPersistent); override;
procedure Assign(Source: TPersistent); override;
class function GetContainerClass: TcxContainerClass; override;
class function GetStyleClass: TcxCustomEditStyleClass; override;
function GetSupportedOperations: TcxEditSupportedOperations; override;
class function GetViewInfoClass: TcxContainerViewInfoClass; override;
procedure ValidateDisplayValue(var ADisplayValue: TcxEditValue;
var AErrorText: TCaption; var Error: Boolean; AEdit: TcxCustomEdit); override;
// !!!
property AutoComplete: Boolean read GetAutoComplete write SetAutoComplete
stored False; // deprecated
property AutoSelect default False;
property LinkColor: TColor read FLinkColor write SetLinkColor
default cxHyperLinkEditDefaultLinkColor;
property Prefix: string read FPrefix write FPrefix stored False;
property SingleClick: Boolean read FSingleClick write SetSingleClick
default False;
property StartKey: TShortCut read FStartKey write FStartKey
default VK_RETURN + scCtrl;
property UsePrefix: TcxHyperLinkEditUsePrefix read FUsePrefix
write FUsePrefix default upAlways;
property OnStartClick: TNotifyEvent read FOnStartClick write FOnStartClick;
end;
{ TcxHyperLinkEditProperties }
TcxHyperLinkEditProperties = class(TcxCustomHyperLinkEditProperties)
published
property Alignment;
property AssignedValues;
property AutoComplete; // deprecated
property AutoSelect;
property ClearKey;
property ImeMode;
property ImeName;
property IncrementalSearch;
property LinkColor;
property LookupItems;
property LookupItemsSorted;
property Prefix;
property ReadOnly;
property StartKey;
property SingleClick;
property UseLeftAlignmentOnEditing;
property UsePrefix;
property ValidateOnEnter;
property OnChange;
property OnEditValueChanged;
property OnStartClick;
property OnValidate;
end;
{ TcxHyperLinkStyle }
TcxHyperLinkStyle = class(TcxEditStyle)
protected
function GetTextColor: TColor; override;
function GetTextStyle: TFontStyles; override;
end;
{ TcxCustomHyperLinkEdit }
TcxCustomHyperLinkEdit = class(TcxCustomTextEdit)
private
FSaveCursor: TCursor;
function GetActiveProperties: TcxCustomHyperLinkEditProperties;
function GetProperties: TcxCustomHyperLinkEditProperties;
function GetStyle: TcxHyperLinkStyle;
procedure InternalSetCursor(ACursor: TCursor);
procedure SetProperties(const Value: TcxCustomHyperLinkEditProperties);
procedure SetStyle(Value: TcxHyperLinkStyle);
protected
function DoOnStartClick: Boolean;
procedure DoStart; virtual;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure MouseEnter(AControl: TControl); override;
procedure MouseLeave(AControl: TControl); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure PropertiesChanged(Sender: TObject); override;
public
procedure ActivateByMouse(Shift: TShiftState; X, Y: Integer;
var AEditData: TcxCustomEditData); override;
class function GetPropertiesClass: TcxCustomEditPropertiesClass; override;
procedure SelectAll; override;
property ActiveProperties: TcxCustomHyperLinkEditProperties read GetActiveProperties;
property Properties: TcxCustomHyperLinkEditProperties read GetProperties
write SetProperties;
property Style: TcxHyperLinkStyle read GetStyle write SetStyle;
end;
{ TcxHyperLinkEdit }
TcxHyperLinkEdit = class(TcxCustomHyperLinkEdit)
private
function GetActiveProperties: TcxHyperLinkEditProperties;
function GetProperties: TcxHyperLinkEditProperties;
procedure SetProperties(Value: TcxHyperLinkEditProperties);
public
class function GetPropertiesClass: TcxCustomEditPropertiesClass; override;
property ActiveProperties: TcxHyperLinkEditProperties read GetActiveProperties;
published
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: TcxHyperLinkEditProperties read GetProperties write SetProperties;
property ShowHint;
property Style;
property StyleDisabled;
property StyleFocused;
property StyleHot;
property TabOrder;
property TabStop;
property Text;
property Visible;
property OnClick;
{$IFDEF DELPHI5}
property OnContextPopup;
{$ENDIF}
property OnDblClick;
property OnEditing;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property BiDiMode;
property ParentBiDiMode;
property OnEndDock;
property OnStartDock;
end;
{ TcxFilterHyperLinkEditHelper }
TcxFilterHyperLinkEditHelper = class(TcxFilterTextEditHelper)
public
class function GetFilterEditClass: TcxCustomEditClass; override;
end;
implementation
uses
ShellAPI,
{$IFDEF DELPHI6}
Variants,
{$ENDIF}
Forms, cxVariants, cxClasses, cxLibraryConsts;
{ TcxHyperLinkEditViewInfo }
procedure TcxHyperLinkEditViewInfo.GetColorSettingsByPainter(
out ABackground, ATextColor: TColor);
begin
inherited GetColorSettingsByPainter(ABackground, ATextColor);
ATextColor := clDefault;
end;
function TcxHyperLinkEditViewInfo.IsHotTrack: Boolean;
begin
Result := inherited IsHotTrack or
TcxCustomHyperLinkEditProperties(EditProperties).SingleClick;
end;
function TcxHyperLinkEditViewInfo.IsHotTrack(P: TPoint): Boolean;
begin
Result := IsHotTrack;
end;
procedure TcxHyperLinkEditViewInfo.PrepareCanvasFont(ACanvas: TCanvas);
begin
inherited PrepareCanvasFont(ACanvas);
if Edit = nil then
begin
ACanvas.Font.Style := ACanvas.Font.Style + [fsUnderline];
if IsSelected then
ACanvas.Font.Color := TextColor
else
ACanvas.Font.Color := TcxCustomHyperLinkEditProperties(EditProperties).LinkColor;
end;
end;
{ TcxCustomHyperLinkEditProperties }
constructor TcxCustomHyperLinkEditProperties.Create(AOwner: TPersistent);
begin
inherited Create(AOwner);
AutoSelect := False;
FLinkColor := clBlue;
FPrefix := cxGetResourceString(@scxSHyperLinkPrefix);
FSingleClick := False;
FStartKey := VK_RETURN + scCtrl;
FUsePrefix := upAlways;
end;
function TcxCustomHyperLinkEditProperties.GetAutoComplete: Boolean;
begin
Result := not (UsePrefix = upNever);
end;
function TcxCustomHyperLinkEditProperties.GetPrefixStored: Boolean;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?