cxcheckcombobox.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,557 行 · 第 1/4 页
PAS
1,557 行
{********************************************************************}
{ }
{ 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 cxCheckComboBox;
interface
{$I cxVer.inc}
uses
{$IFDEF DELPHI6}
Variants,
{$ENDIF}
Windows, Messages, SysUtils, Classes, Controls, Graphics, StdCtrls,
Forms, Math, cxClasses, cxControls, cxContainer, cxGraphics,
cxDataStorage, cxDataUtils, cxVariants, cxEdit, cxEditUtils,
cxTextEdit, cxMaskEdit, cxDropDownEdit, cxImageComboBox,
cxExtEditUtils, cxCheckBox, cxLookAndFeels, cxExtEditConsts,
cxGroupBox, cxFilterControlUtils, cxLookAndFeelPainters;
type
{ TcxCheckComboBoxItem }
TcxCheckComboBoxItem = class(TcxButtonGroupItem)
private
FShortDescription: TCaption;
function GetDescription: TCaption;
procedure SetDescription(const Value: TCaption);
procedure SetShortDescription(const Value: TCaption);
protected
function GetDisplayDescription: string; virtual;
public
procedure Assign(Source: TPersistent); override;
published
property Description: TCaption read GetDescription write SetDescription;
property Enabled;
property ShortDescription: TCaption read FShortDescription
write SetShortDescription;
property Tag;
end;
{ TcxCheckComboBoxItems }
TcxCheckComboBoxItems = class(TcxButtonGroupItems)
private
function GetItems(Index: Integer): TcxCheckComboBoxItem;
procedure SetItems(Index: Integer; const Value: TcxCheckComboBoxItem);
public
function Add: TcxCheckComboBoxItem;
function AddCheckItem(const ADescription: TCaption;
const AShortDescription: TCaption = ''): TcxCheckComboBoxItem;
property Items[Index: Integer]: TcxCheckComboBoxItem read GetItems write SetItems; default;
end;
{ TcxCustomCheckComboBoxViewData }
TcxCustomCheckComboBoxProperties = class;
TcxCustomCheckComboBoxViewData = class(TcxCustomDropDownEditViewData)
protected
function GetProperties: TcxCustomCheckComboBoxProperties;
function InternalEditValueToDisplayText(AEditValue: TcxEditValue): string; override;
function IsComboBoxStyle: Boolean; override;
public
procedure Calculate(ACanvas: TcxCanvas; const ABounds: TRect;
const P: TPoint; Button: TcxMouseButton; Shift: TShiftState;
AViewInfo: TcxCustomEditViewInfo; AIsMouseEvent: Boolean); override;
property Properties: TcxCustomCheckComboBoxProperties read GetProperties;
end;
{ TcxCheckComboBoxListBox }
TcxCustomCheckComboBox = class;
TcxCustomCheckComboBoxListBox = class(TcxCustomComboBoxListBox,
IUnknown, IcxMouseTrackingCaller)
private
FCapturedCheckIndex: Integer;
FCheckBorderOffset: Integer;
FCheckSize: TSize;
FHotCheckIndex: Integer;
FInternalUpdate: Boolean;
FPressedCheckIndex: Integer;
function GetEdit: TcxCustomCheckComboBox;
procedure LBGetTextLen(var Message: TMessage); message LB_GETTEXTLEN;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
protected
// IcxMouseTrackingCaller
procedure IcxMouseTrackingCaller.MouseLeave = MouseTrackingMouseLeave;
procedure MouseTrackingMouseLeave;
procedure CheckHotTrack;
function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;
MousePos: TPoint): Boolean; override;
procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override;
procedure FullRepaint;
function GetCheckAt(X, Y: Integer): Integer;
function GetCheckRect(const R: TRect; AReturnFullRect: Boolean): TRect;
procedure InternalMouseMove(Shift: TShiftState; X, Y: Integer);
procedure InvalidateCheck(Index: Integer);
procedure KeyPress(var Key: Char); override;
procedure LookAndFeelChanged(Sender: TcxLookAndFeel;
AChangedValues: TcxLookAndFeelValues); override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure RecreateWindow; override;
procedure SetItemIndex(const Value: Integer); override;
procedure SynchronizeCheckStates(ANewHotCheckIndex, ANewPressedIndex: Integer);
procedure UpdateItemState(const AIndex: Integer); virtual;
property Edit: TcxCustomCheckComboBox read GetEdit;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetItemHeight(AIndex: Integer = -1): Integer; override;
function GetItemWidth(AIndex: Integer): Integer; override;
end;
{ TcxCheckComboBoxLookupData }
TcxCheckComboBoxLookupData = class(TcxComboBoxLookupData)
protected
function GetListBoxClass: TcxCustomEditListBoxClass; override;
function GetItem(Index: Integer): string; override;
function GetItemCount: Integer; override;
public
procedure TextChanged; override;
end;
{ TcxCheckPaintHelper }
TcxCheckPaintHelper = class(TcxOwnedPersistent)
private
FStyle: TcxCustomEditStyle;
FGlyph: TBitmap;
FGlyphCount: Integer;
procedure SetStyle(Value: TcxCustomEditStyle);
protected
function GetNextState(Value: TcxCheckBoxState): TcxCheckBoxState; virtual;
property Style: TcxCustomEditStyle read FStyle write SetStyle;
property Glyph: TBitmap read FGlyph write FGlyph;
property GlyphCount: Integer read FGlyphCount write FGlyphCount;
function CalcTextRect(const ARect: TRect; const ACheckState: TcxCheckBoxState): TRect; virtual;
function CalcCheckPoint(const ARect: TRect; const ACheckState: TcxCheckBoxState): TPoint; virtual;
function IsClickInCheck(const AItemRect: TRect; const ACheckState: TcxCheckBoxState;
X, Y: Integer; const AUseRightToLeftAlignment: Boolean = False): Boolean;
function GetCheckWidth: Integer; virtual;
public
constructor Create(AOwner : TPersistent); override;
destructor Destroy; override;
end;
{ TcxCustomCheckComboBoxProperties }
TcxCheckComboClickCheckEvent = procedure(Sender: TObject; ItemIndex: Integer;
var AllowToggle: Boolean) of object;
TcxCustomCheckComboBoxProperties = class(TcxCustomComboBoxProperties)
private
FAllowGrayed: Boolean; // deprecated
FCheckPaintHelper : TcxCheckPaintHelper;
FDelimiter: string;
FEditValueFormat: TcxCheckStatesValueFormat;
FEmptySelectionText: string;
FGlyph: TBitmap;
FGlyphCount: Integer;
FItems : TcxCheckComboBoxItems;
FShowEmptyText: Boolean;
FOnClickCheck: TcxCheckComboClickCheckEvent;
FOnEditValueToStates: TcxValueToCheckStatesEvent;
FOnStatesToEditValue: TcxCheckStatesToValueEvent;
function GetGlyph: TBitmap;
procedure GlyphChanged(Sender: TObject);
function IsDelimiterStored: Boolean;
function IsEmptySelectionTextStored: Boolean;
procedure SetGlyph(Value: TBitmap);
procedure SetGlyphCount(Value: Integer);
procedure SetDelimiter(Value: string);
procedure SetEditValueFormat(Value: TcxCheckStatesValueFormat);
procedure SetEmptySelectionText(Value: string);
procedure SetShowEmptyText(Value: Boolean);
procedure SetItems(const Value: TcxCheckComboBoxItems);
protected
class function GetLookupDataClass: TcxInterfacedPersistentClass; override;
class function GetPopupWindowClass: TcxCustomEditPopupWindowClass; override;
class function GetViewDataClass: TcxCustomEditViewDataClass; override;
function HasDisplayValue: Boolean; override;
procedure CalculateCheckStatesByEditValue(Sender: TObject;
const AEditValue: TcxEditValue; var ACheckStates: TcxCheckStates); virtual;
function CalculateDisplayValueByCheckStates(
const ACheckStates: TcxCheckStates): string; virtual;
function CalculateEditValueByCheckStates(Sender: TObject;
const ACheckStates: TcxCheckStates): TcxEditValue; virtual;
property AllowGrayed: Boolean read FAllowGrayed write FAllowGrayed
stored False; // deprecated
public
constructor Create(AOwner: TPersistent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
class function GetContainerClass: TcxContainerClass; override;
function GetEditValueSource(AEditFocused: Boolean): TcxDataEditValueSource; override;
function GetSupportedOperations: TcxEditSupportedOperations; override;
procedure PrepareDisplayValue(const AEditValue: TcxEditValue;
var DisplayValue: TcxEditValue; AEditFocused: Boolean); override;
function IsEditValueValid(var EditValue: TcxEditValue; AEditFocused: Boolean): Boolean; override;
// !!!
property EditValueFormat: TcxCheckStatesValueFormat
read FEditValueFormat write SetEditValueFormat default cvfInteger;
property Glyph: TBitmap read GetGlyph write SetGlyph;
property GlyphCount: Integer read FGlyphCount write SetGlyphCount default 6;
property Delimiter: string read FDelimiter write SetDelimiter
stored IsDelimiterStored;
property EmptySelectionText : string read FEmptySelectionText
write SetEmptySelectionText stored IsEmptySelectionTextStored;
property Items: TcxCheckComboBoxItems read FItems write SetItems;
property ShowEmptyText: Boolean read FShowEmptyText write SetShowEmptyText default True;
property OnClickCheck: TcxCheckComboClickCheckEvent read FOnClickCheck
write FOnClickCheck;
property OnEditValueToStates: TcxValueToCheckStatesEvent
read FOnEditValueToStates write FOnEditValueToStates;
property OnStatesToEditValue: TcxCheckStatesToValueEvent
read FOnStatesToEditValue write FOnStatesToEditValue;
end;
{ TcxCheckComboBoxProperties }
TcxCheckComboBoxProperties = class(TcxCustomCheckComboBoxProperties)
published
property AllowGrayed; // deprecated
property AssignedValues;
property Delimiter;
property EmptySelectionText;
property ShowEmptyText;
property Alignment;
property BeepOnError;
property ButtonGlyph;
property CharCase;
property ClearKey;
property DropDownAutoWidth;
property DropDownRows;
property DropDownSizeable;
property DropDownWidth;
property EditValueFormat;
property Glyph;
property GlyphCount;
property ImeMode;
property ImeName;
property ImmediateDropDown;
property ImmediatePopup;
property ImmediatePost;
property Items;
property PopupAlignment;
property ReadOnly;
property ValidateOnEnter;
property OnChange;
property OnClickCheck;
property OnCloseUp;
property OnEditValueChanged;
property OnEditValueToStates;
property OnInitPopup;
property OnPopup;
property OnStatesToEditValue;
end;
{ TcxCheckComboBoxPopupWindow }
TcxCheckComboBoxPopupWindow = class(TcxComboBoxPopupWindow)
public
property ViewInfo;
property SysPanelStyle;
end;
{ TcxCustomCheckComboBox }
TcxCustomCheckComboBox = class(TcxCustomComboBox)
private
FCheckBorderStyle: TcxEditCheckBoxBorderStyle;
FNativeStyle: Boolean;
FStates: TcxCheckStates;
FStatesItems: Boolean;
function GetActiveProperties: TcxCustomCheckComboBoxProperties;
function GetLookupData: TcxCheckComboBoxLookupData;
function GetProperties: TcxCustomCheckComboBoxProperties;
procedure SetProperties(Value: TcxCustomCheckComboBoxProperties);
protected
procedure CalculateDrawCheckParams;
function GetValue: Variant; virtual; // deprecated
procedure PopupControlsLookAndFeelChanged(Sender: TcxLookAndFeel;
AChangedValues: TcxLookAndFeelValues); override;
procedure PopupWindowShowed(Sender: TObject); override;
procedure PropertiesChanged(Sender: TObject); override;
function RefreshContainer(const P: TPoint; Button: TcxMouseButton;
Shift: TShiftState; AIsMouseEvent: Boolean): Boolean; override;
procedure SetItemIndex(Value: Integer); override;
procedure SetValue(const AValue: Variant); virtual; // deprecated
procedure SynchronizeDisplayValue; override;
procedure SynchronizeEditValue; override;
procedure UpdateDrawValue; override;
function ClickCheck(AItemIndex: Integer): Boolean; virtual;
function DoClickCheck(AItemIndex: Integer): Boolean;
function GetEditingValue: TcxEditValue; override;
procedure HandleSelectItem(Sender: TObject); override;
procedure Initialize; override;
procedure InitializePopupWindow; override;
function InternalGetText: string; override;
function InternalSetText(const Value: string): Boolean; override;
procedure InternalValidateDisplayValue(const ADisplayValue: TcxEditValue); override;
function IsEditValueStored: Boolean; override;
procedure KeyPress(var Key: Char); override;
property LookupData: TcxCheckComboBoxLookupData read GetLookupData;
property Value: Variant read GetValue write SetValue stored False; // deprecated
procedure CloseUp(AReason: TcxEditCloseUpReason); override;
property StatesItems: Boolean read FStatesItems write FStatesItems stored False;
public
class function GetPropertiesClass: TcxCustomEditPropertiesClass; override;
function GetItemState(AIndex: Integer): TcxCheckBoxState; // deprecated
procedure SetItemState(AIndex: Integer; AState: TcxCheckBoxState); // deprecated
property ActiveProperties: TcxCustomCheckComboBoxProperties
read GetActiveProperties;
property Properties: TcxCustomCheckComboBoxProperties read GetProperties
write SetProperties;
property States[AIndex: Integer]: TcxCheckBoxState read GetItemState
write SetItemState;
end;
{ TcxCheckComboBox }
TcxCheckComboBox = class(TcxCustomCheckComboBox)
private
function GetActiveProperties: TcxCheckComboBoxProperties;
function GetProperties: TcxCheckComboBoxProperties;
procedure SetProperties(Value: TcxCheckComboBoxProperties);
public
class function GetPropertiesClass: TcxCustomEditPropertiesClass; override;
property ActiveProperties: TcxCheckComboBoxProperties
read GetActiveProperties;
published
property Anchors;
property AutoSize;
property BeepOnEnter;
property Constraints;
property DragCursor;
property DragKind;
property DragMode;
property EditValue;
property Enabled;
property ImeMode;
property ImeName;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property Properties: TcxCheckComboBoxProperties read GetProperties
write SetProperties;
property ShowHint;
property StatesItems;
property Style;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?