cxtextedit.pas

来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,593 行 · 第 1/5 页

PAS
1,593
字号
    function FindLookupText(const AText: string): Boolean; virtual;
    function GetDefaultDisplayFormat: string; virtual;
    function GetDefaultDisplayValue(const AEditValue: TcxEditValue; AEditFocused: Boolean): TcxEditValue;
    function GetDefaultMaxLength: Integer; virtual;
    function GetDropDownPageRowCount: Integer; virtual;
    function GetEditingStyle: TcxEditEditingStyle; virtual;
    class function GetLookupDataClass: TcxInterfacedPersistentClass; virtual;
    function HasDigitGrouping(AIsDisplayValueSynchronizing: Boolean): Boolean; virtual;
    function InternalGetEditFormat(out AIsCurrency, AIsOnGetTextAssigned: Boolean;
      AEdit: TcxCustomTextEdit = nil): string; virtual;
    function IsEditValueNumeric: Boolean; virtual;
    function IsLookupDataVisual: Boolean; virtual;
    function IsMultiLine: Boolean; virtual;
    function IsPopupKey(Key: Word; Shift: TShiftState): Boolean; virtual;
    function IsValueBoundDefined(ABound: TcxEditValueBound): Boolean; virtual;
    function IsValueBoundsDefined: Boolean; virtual;
    procedure LookupDataChanged(Sender: TObject); virtual;
    procedure MaxLengthChanged; virtual;
    procedure SetCharCase(Value: TEditCharCase); virtual;
    function UseLookupData: Boolean; virtual;
    property AssignedValues: TcxTextEditPropertiesValues read GetAssignedValues
      write SetAssignedValues;
    property EditingStyle: TcxEditEditingStyle read GetEditingStyle;
    property FixedListSelection: Boolean read FFixedListSelection
      write SetFixedListSelection default True;
    property FormatChanging: Boolean read FFormatChanging;
    property HideCursor: Boolean read FHideCursor write SetHideCursor
      stored False;
    property MRUMode: Boolean read FMRUMode write SetMRUMode default False;
  public
    constructor Create(AOwner: TPersistent); override;
    destructor Destroy; override;
    procedure Assign(Source: TPersistent); override;
    function CanCompareEditValue: Boolean; 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;
    function GetSupportedOperations: TcxEditSupportedOperations; override;
    class function GetViewInfoClass: TcxContainerViewInfoClass; override;
    function IsEditValueValid(var EditValue: TcxEditValue; AEditFocused: Boolean): Boolean; override;
    function IsResetEditClass: Boolean; override;
    procedure PrepareDisplayValue(const AEditValue: TcxEditValue;
      var DisplayValue: TcxEditValue; AEditFocused: Boolean); override;
    procedure ValidateDisplayValue(var DisplayValue: TcxEditValue; var ErrorText: TCaption;
      var Error: Boolean; AEdit: TcxCustomEdit); override;
    procedure DisplayValueToDisplayText(var ADisplayValue: string); virtual;
    function IsDisplayValueValid(var DisplayValue: TcxEditValue; AEditFocused: Boolean): Boolean; virtual;
    procedure SetMinMaxValues(AMinValue, AMaxValue: Double);
    property ValidChars: TcxTextEditChars read FValidChars write FValidChars;
    // !!!
    property CharCase: TEditCharCase read FCharCase write SetCharCase default ecNormal;
    property DisplayFormat: string read GetDisplayFormat write SetDisplayFormat
       stored IsDisplayFormatStored;
    property EchoMode: TcxEditEchoMode read FEchoMode write SetEchoMode default eemNormal;
    property EditFormat: string read GetEditFormat write SetEditFormat
       stored IsEditFormatStored;
    property HideSelection: Boolean read FHideSelection write SetHideSelection default True;
    property ImeMode: TImeMode read FImeMode write SetImeMode default imDontCare;
    property ImeName: TImeName read FImeName write SetImeName;
    property ImmediateUpdateText: Boolean read FImmediateUpdateText write FImmediateUpdateText default False;
    property IncrementalSearch: Boolean read FIncrementalSearch
      write SetIncrementalSearch default True;
    property LookupItems: TStrings read GetLookupItems write SetLookupItems;
    property LookupItemsSorted: Boolean read GetLookupItemsSorted write
      SetLookupItemsSorted default False;
    property MaxLength: Integer read GetMaxLength write SetMaxLength stored IsMaxLengthStored;
    property MaxValue;
    property MinValue;
    property OEMConvert: Boolean read FOEMConvert write SetOEMConvert default False;
    property PasswordChar: TCaptionChar read FPasswordChar write SetPasswordChar
      default #0;
    property UseDisplayFormatWhenEditing: Boolean
      read FUseDisplayFormatWhenEditing write SetUseDisplayFormatWhenEditing
      default False;
    property ViewStyle: TcxTextEditViewStyle read GetViewStyle write SetViewStyle default vsNormal;
    property OnNewLookupDisplayText: TcxNewLookupDisplayTextEvent read
      FOnNewLookupDisplayText write FOnNewLookupDisplayText;
  end;

  { TcxTextEditProperties }

  TcxTextEditProperties = class(TcxCustomTextEditProperties)
  published
    property Alignment;
    property AssignedValues;
    property AutoSelect;
    property BeepOnError;
    property CharCase;
    property ClearKey;
    property EchoMode;
    property HideSelection;
    property ImeMode;
    property ImeName;
    property IncrementalSearch;
    property LookupItems;
    property LookupItemsSorted;
    property MaxLength;
    property OEMConvert;
    property PasswordChar;
    property ReadOnly;
    property UseLeftAlignmentOnEditing;
    property ValidateOnEnter;
    property OnChange;
    property OnEditValueChanged;
    property OnNewLookupDisplayText;
    property OnValidate;
  end;

  { TcxCustomTextEdit }

  TcxCustomTextEdit = class(TcxCustomEdit, IcxFormatControllerListener)
  private
    FBeepOnEnter: Boolean;
    FDisableRefresh: Boolean;
    FFindSelection: Boolean;
    FHideInnerEdit: Boolean;
    FInternalTextSetting: Boolean;
    FIsDisplayValueSynchronizing: Boolean;
    FLastFirstVisibleCharIndex: Integer;
    FLastSelLength: Integer;
    FLastSelPosition: Integer;
    FLookupItemsScrolling: Boolean;
    FShowInnerEdit: Boolean;
    FTesting: Boolean;
    FText: TCaption;
    function GetCursorPos: Integer;
    function GetEditingText: TCaption;
    function GetInnerTextEdit: IcxInnerTextEdit;
    function GetILookupData: IcxTextEditLookupData;
    function GetLookupData: TcxCustomTextEditLookupData;
    function GetProperties: TcxCustomTextEditProperties;
    function GetActiveProperties: TcxCustomTextEditProperties;
    function GetSelLength: Integer;
    function GetSelStart: Integer;
    function GetSelText: TCaption;
    function GetViewInfo: TcxCustomTextEditViewInfo;
    procedure SetFindSelection(Value: Boolean);
    procedure SetHideInnerEdit(Value: Boolean);
    procedure SetItemObject(Value: TObject);
    procedure SetProperties(Value: TcxCustomTextEditProperties);
    procedure SetSelLength(Value: Integer);
    procedure SetSelStart(Value: Integer);
    procedure SetShowInnerEdit(Value: Boolean);
    procedure SetTesting(Value: Boolean);
    procedure WMClear(var Message: TMessage); message WM_CLEAR;
    procedure WMCommand(var Message: TWMCommand); message WM_COMMAND;
    procedure WMGetText(var Message: TWMGetText); message WM_GETTEXT;
    procedure WMGetTextLength(var Message: TWMGetTextLength); message WM_GETTEXTLENGTH;
    procedure WMSetText(var Message: TWMSetText); message WM_SETTEXT;
  protected
    FInnerEditPositionAdjusting: Boolean;
    FIsPopupWindowJustClosed: Boolean;
    FLookupData: TcxInterfacedPersistent;
    FLookupDataTextChangedLocked: Boolean;
    procedure AdjustInnerEditPosition; override;
    function CanKeyDownModifyEdit(Key: Word; Shift: TShiftState): Boolean; override;
    function CanKeyPressModifyEdit(Key: Char): Boolean; override;
    procedure ChangeHandler(Sender: TObject); override;
    procedure DoEditKeyDown(var Key: Word; Shift: TShiftState); override;
    procedure DoEditKeyPress(var Key: Char); override;
    procedure DoExit; override;
    function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;
       MousePos: TPoint): Boolean; override;
    procedure FillSizeProperties(var AEditSizeProperties: TcxEditSizeProperties); override;
    function GetDisplayValue: string; override;
    function GetInnerControlBounds(const AInnerControlsRegion: TRect;
      AInnerControl: TControl): TcxContainerInnerControlBounds; override;
    function GetInnerEditClass: TControlClass; override;
    procedure Initialize; override;
    function InternalDoEditing: Boolean; override;
    function InternalGetEditingValue: TcxEditValue; override;
    procedure InternalSetDisplayValue(const Value: TcxEditValue); override;
    procedure InternalValidateDisplayValue(const ADisplayValue: TcxEditValue); override;
    function IsTextInputMode: Boolean; virtual;
    function IsValidChar(AChar: Char): Boolean; override;
    procedure KeyPress(var Key: Char); override;
    procedure Loaded; override;
    procedure PropertiesChanged(Sender: TObject); override;
    function RefreshContainer(const P: TPoint; Button: TcxMouseButton; Shift: TShiftState;
      AIsMouseEvent: Boolean): Boolean; override;
    function SetDisplayText(const Value: string): Boolean; override;
    procedure SetInternalDisplayValue(Value: TcxEditValue); override;
    function WantNavigationKeys: Boolean; override;
    procedure LockedInnerEditWindowProc(var Message: TMessage); override;
    procedure UnlockInnerEditRepainting; override;
    // IcxFormatControllerListener
    procedure FormatChanged; virtual;

    // SpellChecking
    procedure DoDrawMisspelleds; virtual;
    procedure DoLayoutChanged; virtual;
    procedure DoSelectionChanged; virtual;
    procedure DoTextChanged; virtual;
    procedure InternalCheckSelection;
    procedure InternalSpellCheckerHandler(var Message: TMessage); virtual;
    procedure SpellCheckerSetSelText(const AValue: string); override;

    procedure AdjustInnerEdit; virtual;
    function CanChangeSelText(const Value: string; out ANewText: string;
      out ANewSelStart: Integer): Boolean; virtual;
    procedure CheckEditValue; virtual;
    procedure CheckEditorValueBounds; virtual;
    procedure DoOnNewLookupDisplayText(const AText: string); virtual;
    function GetInnerEditHeight: Integer; virtual;
    function GetItemIndex: Integer; virtual;
    function GetItemObject: TObject; virtual;
    function GetScrollLookupDataList(AScrollCause: TcxEditScrollCause): Boolean; virtual;
    procedure HandleSelectItem(Sender: TObject); virtual;
    function InternalGetText: string; virtual;
    function InternalSetText(const Value: string): Boolean; virtual;
    function ItemIndexToLookupKey(AItemIndex: Integer): TcxEditValue; virtual;
    procedure LockLookupDataTextChanged;
    function LookupKeyToEditValue(const AKey: TcxEditValue): TcxEditValue; virtual;
    function LookupKeyToItemIndex(const AKey: TcxEditValue): Integer; virtual;
    function NeedResetInvalidTextWhenPropertiesChanged: Boolean; virtual;
    procedure ResetOnNewDisplayValue; virtual;
    procedure SelChange(Sender: TObject); virtual;
    procedure SetEditingText(const Value: TCaption); virtual;
    procedure SetItemIndex(Value: Integer); virtual;
    procedure SetSelText(const Value: TCaption); virtual;
    procedure SynchronizeDisplayValue; override;
    procedure SynchronizeEditValue; override;
    procedure UndoPerformed; virtual;
    procedure UnlockLookupDataTextChanged;
    procedure UpdateDrawValue; override;
    procedure UpdateDisplayValue; virtual;

    property BeepOnEnter: Boolean read FBeepOnEnter write FBeepOnEnter default True;
    property HideInnerEdit: Boolean read FHideInnerEdit write SetHideInnerEdit; // for test
    property InnerTextEdit: IcxInnerTextEdit read GetInnerTextEdit;
    property ItemIndex: Integer read GetItemIndex write SetItemIndex stored False;
    property ItemObject: TObject read GetItemObject write SetItemObject;
    property LookupData: TcxCustomTextEditLookupData read GetLookupData;
    property LookupItemsScrolling: Boolean read FLookupItemsScrolling write FLookupItemsScrolling;
    property ParentColor default False;
    property ShowInnerEdit: Boolean read FShowInnerEdit write SetShowInnerEdit; // for test
    property Testing: Boolean read FTesting write SetTesting; // for test
    property ViewInfo: TcxCustomTextEditViewInfo read GetViewInfo;
  public
  {$IFDEF CBUILDER10}
    constructor Create(AOwner: TComponent); override;
  {$ENDIF}
    destructor Destroy; override;
    procedure Activate(var AEditData: TcxCustomEditData); override;
    class function GetPropertiesClass: TcxCustomEditPropertiesClass; override;
    procedure CopyToClipboard; override;
    procedure CutToClipboard; override;
    function IsEditClass: Boolean; override;
    procedure PasteFromClipboard; override;
    procedure PrepareEditValue(const ADisplayValue: TcxEditValue;
      out EditValue: TcxEditValue; AEditFocused: Boolean); override;
    procedure SelectAll; override;
  {$IFDEF DELPHI10}
    function GetTextBaseLine: Integer; override;
    function HasTextBaseLine: Boolean; override;
  {$ENDIF}
    procedure ClearSelection; virtual;
    function IsChildWindow(AWnd: THandle): Boolean; override;
    procedure SetScrollBarsParameters(AIsScrolling: Boolean = False); override;
    procedure SetSelection(ASelStart: Integer; ASelLength: Integer);
    procedure Undo; virtual;
    property ActiveProperties: TcxCustomTextEditProperties read GetActiveProperties;
    property CursorPos: Integer read GetCursorPos;
    property EditingText: TCaption read GetEditingText write SetEditingText;
    property FindSelection: Boolean read FFindSelection write SetFindSelection;
    property ILookupData: IcxTextEditLookupData read GetILookupData;
    property Properties: TcxCustomTextEditProperties read GetProperties
      write SetProperties;
    property SelLength: Integer read GetSelLength write SetSelLength;
    property SelStart: Integer read GetSelStart write SetSelStart;
    property SelText: TCaption read GetSelText write SetSelText;
    property Text;
  end;

  { TcxTextEdit }

  TcxTextEdit = class(TcxCustomTextEdit)
  private
    function GetActiveProperties: TcxTextEditProperties;
    function GetProperties: TcxTextEditProperties;
    procedure SetProperties(Value: TcxTextEditProperties);
  protected
    function IsCheckAsYouTypeSupports: Boolean; override;
  public
    class function GetPropertiesClass: TcxCustomEditPropertiesClass; override;
    property ActiveProperties: TcxTextEditProperties 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: TcxTextEditProperties read GetProperties write SetProperties;
    property ShowHint;
    property Style;
    property StyleDisabled;
    property StyleFocused;
    property StyleHot;
    property TabOrder;
    property TabStop;
    property Text;
    property Visible;
    property OnClick;
    property OnContextPopup;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?