cxdropdownedit.pas

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

PAS
1,810
字号
    function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;
       MousePos: TPoint): Boolean; override;
    procedure FocusChanged; override;
    function GetEditDataClass: TcxCustomEditDataClass; override;
    function GetInnerEditClass: TControlClass; override;
    function GetScrollLookupDataList(AScrollCause: TcxEditScrollCause): Boolean; override;
    procedure Initialize; override;
    procedure InitializeEditData; override;
    function InternalGetNotPublishedStyleValues: TcxEditStyleValues; override;
    function IsEditorKey(Key: Word; Shift: TShiftState): Boolean; override;
    procedure PropertiesChanged(Sender: TObject); override;
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
    function RefreshContainer(const P: TPoint; Button: TcxMouseButton; Shift: TShiftState;
      AIsMouseEvent: Boolean): Boolean; override;
    function SendActivationKey(Key: Char): Boolean; override;
    function TabsNeeded: Boolean; override;
    procedure CreateHandle; override;
    procedure DoStartDock(var DragObject: TDragObject); override;
    function CanDropDown: Boolean; virtual;
    procedure CloseUp(AReason: TcxEditCloseUpReason); virtual;
    procedure CreatePopupWindow; virtual;
    procedure DeleteShowPopupWindowMessages;
    procedure DoCloseQuery(var CanClose: Boolean);
    procedure DoCloseUp; virtual;
    procedure DoFinalizePopup; virtual;
    procedure DoInitPopup; virtual;
    procedure DoPopup; virtual;
    procedure DropDown; virtual;
    procedure EditButtonClick; virtual;
    function GetPopupFocusedControl: TWinControl; virtual;
    function GetPopupWindowClientPreferredSize: TSize; virtual; abstract;
    function GetPopupWindowOwnerControlBounds: TRect;
    procedure InitializeLookupData; virtual;
    procedure InitializePopupWindow; virtual;
    procedure PopupControlsLookAndFeelChanged(Sender: TcxLookAndFeel;
      AChangedValues: TcxLookAndFeelValues); virtual;
    procedure PopupWindowClosed(Sender: TObject); dynamic;
    procedure PopupWindowCloseQuery(Sender: TObject; var CanClose: Boolean); dynamic;
    procedure PopupWindowClosing(Sender: TObject); dynamic;
    procedure PopupWindowShowing(Sender: TObject); dynamic;
    procedure PopupWindowShowed(Sender: TObject); dynamic;
    procedure PositionPopupWindowChilds(const AClientRect: TRect); virtual;
    procedure SetIsHotAndPopup;
    procedure SetupPopupWindow; virtual;
    procedure UpdatePopupWindow;
    property IsHotAndPopup: Boolean read FIsHotAndPopup;
    property PopupControlsLookAndFeel: TcxEditPopupControlLookAndFeel
      read FPopupControlsLookAndFeel;
    property PopupMouseMoveLocked: Boolean read FPopupMouseMoveLocked write FPopupMouseMoveLocked;
    property PopupSizeChanged: Boolean read FPopupSizeChanged;
    property SendChildrenStyle: Boolean read FSendChildrenStyle write FSendChildrenStyle;
  public
    destructor Destroy; override;
    procedure Activate(var AEditData: TcxCustomEditData); override;
    procedure ActivateByKey(Key: Char; var AEditData: TcxCustomEditData); override;
    procedure ActivateByMouse(Shift: TShiftState; X, Y: Integer;
      var AEditData: TcxCustomEditData); override;
    procedure BeforeDestruction; override;
    function Deactivate: Boolean; override;
    function Focused: Boolean; override;
    class function GetPropertiesClass: TcxCustomEditPropertiesClass; override;
    function HasPopupWindow: Boolean; override;
    procedure PasteFromClipboard; override;
    function CanHide: Boolean; virtual;
    property ActiveProperties: TcxCustomDropDownEditProperties
      read GetActiveProperties;
    property DroppedDown: Boolean read GetDroppedDown write SetDroppedDown;
    property PopupWindow: TcxCustomEditPopupWindow read FPopupWindow;
    property Properties: TcxCustomDropDownEditProperties read GetProperties
      write SetProperties;
  end;

  { TcxFilterDropDownEditHelper }

  TcxFilterDropDownEditHelper = class(TcxFilterMaskEditHelper)
  public
    class function EditPropertiesHasButtons: Boolean; override;
  end;

  { TcxComboBoxPopupWindow }

  TcxComboBoxPopupWindow = class(TcxCustomEditPopupWindow)
  protected
    procedure CalculateSize; override;
  end;

  { TcxCustomComboBoxListBox }

  TcxCustomComboBoxListBox = class(TcxCustomEditListBox)
  private
    function GetEdit: TcxCustomComboBox;
  protected
    procedure CreateParams(var Params: TCreateParams); override;
    function DoDrawItem(AIndex: Integer; const ARect: TRect;
      AState: TOwnerDrawState): Boolean; override;
    function GetItem(Index: Integer): string; override;
    procedure MeasureItem(Index: Integer; var Height: Integer); override;
    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
    procedure RecreateWindow; override;
    property Edit: TcxCustomComboBox read GetEdit;
  public
    constructor Create(AOwner: TComponent); override;
    function GetHeight(ARowCount: Integer; AMaxHeight: Integer): Integer; override;
  end;

  { TcxComboBoxListBox }

  TcxComboBoxListBox = class(TcxCustomComboBoxListBox)
  protected
    procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
    procedure RecreateWindow; override;
    procedure SetItemIndex(const Value: Integer); override;
    procedure Resize; override;
  public
    function GetItemHeight(AIndex: Integer = -1): Integer; override;
  end;

  { TcxComboBoxLookupData }

  TcxComboBoxLookupData = class(TcxCustomTextEditLookupData)
  protected
    function GetListBoxClass: TcxCustomEditListBoxClass; override;
  public
    function CanResizeVisualArea(var NewSize: TSize;
      AMaxHeight: Integer = 0; AMaxWidth: Integer = 0): Boolean; override;
    function GetVisualAreaPreferredSize(AMaxHeight: Integer; AWidth: Integer = 0): TSize; override;
    procedure Initialize(AVisualControlsParent: TWinControl); override;
  end;

  { TcxCustomComboBoxViewData }

  TcxCustomComboBoxProperties = class;

  TcxCustomComboBoxViewData = class(TcxCustomDropDownEditViewData)
  private
    function GetProperties: TcxCustomComboBoxProperties;
  protected
    function IsComboBoxStyle: Boolean; 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;
    property Properties: TcxCustomComboBoxProperties read GetProperties;
  end;

  { TcxCustomTextEditViewInfo }

  TcxCustomComboBoxViewInfo = class(TcxCustomTextEditViewInfo)
  private
    function GetEdit: TcxCustomComboBox;
  protected
    procedure DoCustomDraw(ACanvas: TcxCanvas; ARect: TRect); virtual;
  public
    ItemIndex: Integer;
    constructor Create; override;
    property Edit: TcxCustomComboBox read GetEdit;
  end;

  { TcxCustomComboBoxProperties }

  TcxCustomComboBoxProperties = class(TcxCustomDropDownEditProperties)
  private
    FDropDownListStyle: TcxEditDropDownListStyle;
    FDropDownRows: Integer;
    FItemHeight: Integer;
    FRevertable: Boolean;
    FOnDrawItem: TcxEditDrawItemEvent;
    FOnMeasureItem: TMeasureItemEvent;
    function GetDropDownAutoWidth: Boolean;
    function GetDropDownSizeable: Boolean;
    function GetDropDownWidth: Integer;
    function GetItems: TStrings;
    function GetSorted: Boolean;
    procedure SetDropDownAutoWidth(Value: Boolean);
    procedure SetDropDownListStyle(Value: TcxEditDropDownListStyle);
    procedure SetDropDownRows(Value: Integer);
    procedure SetDropDownSizeable(Value: Boolean);
    procedure SetDropDownWidth(Value: Integer);
    procedure SetItemHeight(Value: Integer);
    procedure SetItems(Value: TStrings);
    procedure SetSorted(Value: Boolean);
  protected
    function DropDownOnClick: Boolean; override;
    function GetDropDownPageRowCount: Integer; override;
    function GetEditingStyle: TcxEditEditingStyle; override;
    class function GetLookupDataClass: TcxInterfacedPersistentClass; override;
    class function GetPopupWindowClass: TcxCustomEditPopupWindowClass; override;
    class function GetViewDataClass: TcxCustomEditViewDataClass; override;
    function UseLookupData: Boolean; override;
  public
    constructor Create(AOwner: TPersistent); override;
    procedure Assign(Source: TPersistent); override;
    class function GetContainerClass: TcxContainerClass; override;
    class function GetViewInfoClass: TcxContainerViewInfoClass; override;
    // !!!
    property DropDownAutoWidth: Boolean read GetDropDownAutoWidth
      write SetDropDownAutoWidth default True;
    property DropDownListStyle: TcxEditDropDownListStyle read FDropDownListStyle
      write SetDropDownListStyle default lsEditList;
    property DropDownRows: Integer read FDropDownRows write SetDropDownRows
      default cxEditDefaultDropDownPageRowCount;
    property DropDownSizeable: Boolean read GetDropDownSizeable
      write SetDropDownSizeable default False;
    property DropDownWidth: Integer read GetDropDownWidth write SetDropDownWidth
      default 0;
    property ItemHeight: Integer read FItemHeight write SetItemHeight default 0;
    property Items: TStrings read GetItems write SetItems;
    property Revertable: Boolean read FRevertable write FRevertable default False;
    property Sorted: Boolean read GetSorted write SetSorted default False;
    property OnDrawItem: TcxEditDrawItemEvent read FOnDrawItem write FOnDrawItem;
    property OnMeasureItem: TMeasureItemEvent read FOnMeasureItem write FOnMeasureItem;
  end;

  { TcxComboBoxProperties }

  TcxComboBoxProperties = class(TcxCustomComboBoxProperties)
  published
    property Alignment;
    property AssignedValues;
    property AutoSelect;
    property BeepOnError;
    property ButtonGlyph;
    property CaseInsensitive;
    property CharCase;
    property ClearKey;
    property DropDownAutoWidth;
    property DropDownListStyle;
    property DropDownRows;
    property DropDownSizeable;
    property DropDownWidth;
    property HideSelection;
    property IgnoreMaskBlank;
    property ImeMode;
    property ImeName;
    property ImmediateDropDown;
    property ImmediatePost;
    property ImmediateUpdateText;
    property IncrementalSearch;
    property ItemHeight;
    property Items;
    property MaskKind;
    property EditMask;
    property MaxLength;
    property OEMConvert;
    property PopupAlignment;
    property PostPopupValueOnTab;
    property ReadOnly;
    property Revertable;
    property Sorted;
    property UseLeftAlignmentOnEditing;
    property ValidateOnEnter;
    property OnChange;
    property OnCloseUp;
    property OnDrawItem;
    property OnEditValueChanged;
    property OnInitPopup;
    property OnMeasureItem;
    property OnNewLookupDisplayText;
    property OnPopup;
    property OnValidate;
  end;

  { TcxCustomComboBoxInnerEdit }

  TcxCustomComboBoxInnerEdit = class(TcxCustomDropDownInnerEdit)
  private
    procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;
  protected
  end;

  { TcxCustomComboBox }

  TcxCustomComboBox = class(TcxCustomDropDownEdit)
  private
    function GetActiveProperties: TcxCustomComboBoxProperties;
    function GetLookupData: TcxComboBoxLookupData;
    function GetProperties: TcxCustomComboBoxProperties;
    function GetSelectedItem: Integer;
    procedure SetProperties(Value: TcxCustomComboBoxProperties);
    procedure SetSelectedItem(Value: Integer);
    procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;
  protected
    function CanDropDown: Boolean; override;
    procedure ChangeHandler(Sender: TObject); override;
    procedure DblClick; override;
    function GetInnerEditClass: TControlClass; override;
    function GetPopupWindowClientPreferredSize: TSize; override;
    procedure Initialize; override;
    procedure InitializePopupWindow; override;
    function IsTextInputMode: Boolean; override;
    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
    procedure PopupWindowShowed(Sender: TObject); override;
    procedure SetupPopupWindow; override;
    function CanSynchronizeLookupData: Boolean;
    procedure ResetPopupHeight;
    procedure SynchronizeItemIndex;
    procedure DoOnDrawItem(ACanvas: TcxCanvas; AIndex: Integer;
      const ARect: TRect; AState: TOwnerDrawState);
    procedure DoOnMeasureItem(AIndex: Integer; ACanvas: TcxCanvas;
      var AHeight: Integer);
    function IsOnDrawItemEventAssigned: Boolean;
    function IsOnMeasureItemEventAssigned: Boolean;
    property LookupData: TcxComboBoxLookupData read GetLookupData;
  public
    procedure Activate(var AEditData: TcxCustomEditData); override;
    class function GetPropertiesClass: TcxCustomEditPropertiesClass; override;
    property ActiveProperties: TcxCustomComboBoxProperties read GetActiveProperties;
    property ItemIndex;
    property ItemObject;
    property Properties: TcxCustomComboBoxProperties read GetProperties
      write SetProperties;
    property SelectedItem: Integer read GetSelectedItem write SetSelectedItem;
  end;

  { TcxComboBox }

  TcxComboBox = class(TcxCustomComboBox)
  private
    function GetActiveProperties: TcxComboBoxProperties;
    function GetProperties: TcxComboBoxProperties;
    procedure SetProperties(Value: TcxComboBoxProperties);
  protected
    function IsCheckAsYouTypeSupports: Boolean; override;
  public
    class function GetPropertiesClass: TcxCustomEditPropertiesClass; override;
    property ActiveProperties: TcxComboBoxProperties read GetActiveProperties;
  published
    property Anchors;
    property AutoSize;
    property BeepOnEnter;
    property Constraints;
    property DragCursor;
    property DragKind;
    property DragMode;
    property Enabled;
    property ImeMode;
    property ImeName;
    property ItemIndex;
    property ParentColor;
    property ParentFont;
    property ParentShowHint;
    property PopupMenu;
    property Properties: TcxComboBoxProperties 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;
    property OnEditing;
    property OnEndDock;

⌨️ 快捷键说明

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