2009-08-06 14:32:07 +00:00
|
|
|
unit mckEcmListEdit;
|
|
|
|
|
|
|
|
interface
|
|
|
|
{$I KOLDEF.INC}
|
|
|
|
|
|
|
|
uses
|
|
|
|
Windows, KOL, Classes, Messages, Forms, SysUtils, mirror,
|
2021-03-05 07:43:36 +00:00
|
|
|
mckCtrls, Graphics, KOLEcmListEdit, DesignIntf, DesignEditors, DesignConst, mckLVColumnsEditor;
|
2009-08-06 14:32:07 +00:00
|
|
|
|
|
|
|
type
|
2021-03-09 05:49:57 +00:00
|
|
|
{$IFDEF _DXE2orHigher}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}
|
2009-08-06 14:32:07 +00:00
|
|
|
TKOLEcmListEdit = class(TKOLListView)
|
2021-03-05 07:43:36 +00:00
|
|
|
protected
|
2009-08-06 14:32:07 +00:00
|
|
|
fDrawForbidden: TOnDrawItem;
|
2021-03-05 07:43:36 +00:00
|
|
|
fListData: Boolean;
|
|
|
|
fOnGetText: TOnEditText;
|
|
|
|
fOnPutText: TOnEditText;
|
|
|
|
fOnEndEdit: TOnEndEdit;
|
|
|
|
fOnCellAdjust: TOnCellAdjust;
|
|
|
|
fOnEditChar: TOnEditChar;
|
|
|
|
fOnCreateEdit: TOnCreateEdit;
|
|
|
|
fLimStyle: TKOLListViewStyle;
|
|
|
|
fOnDrawCell: TOnDrawCell;
|
2009-08-06 14:32:07 +00:00
|
|
|
procedure SetOnGetText(const Value: TOnEditText);
|
|
|
|
procedure SetOnPutText(const Value: TOnEditText);
|
|
|
|
procedure SetOnEndEdit(const Value: TOnEndEdit);
|
2021-03-05 07:43:36 +00:00
|
|
|
procedure SetOnCellAdjust(const Value: TOnCellAdjust);
|
2009-08-06 14:32:07 +00:00
|
|
|
procedure SetOnEditChar(const Value: TOnEditChar);
|
|
|
|
procedure SetOnCreateEdit(const Value: TOnCreateEdit);
|
|
|
|
procedure SetLimStyle(const Value: TKOLListViewStyle);
|
|
|
|
procedure SetOnDrawCell(const Value: TOnDrawCell);
|
|
|
|
function AdditionalUnits: string; override;
|
|
|
|
procedure SetupFirst( SL: TStringList; const AName, AParent, Prefix: String ); override;
|
2021-03-05 07:43:36 +00:00
|
|
|
procedure SetupLast(SL: TStringList; const AName, AParent, Prefix: String); override;
|
2009-08-06 14:32:07 +00:00
|
|
|
procedure AssignEvents( SL: TStringList; const AName: String ); override;
|
2014-12-03 16:20:28 +00:00
|
|
|
function SetupParams( const AName, AParent: TDelphiString ): TDelphiString; override;
|
2021-03-05 07:43:36 +00:00
|
|
|
function GetCaption: string;
|
2009-08-06 14:32:07 +00:00
|
|
|
function GetStyle: TKOLListViewStyle;
|
|
|
|
function GetOptions: TKOLListViewOptions;
|
|
|
|
procedure SetOptions(v: TKOLListViewOptions);
|
|
|
|
public
|
|
|
|
constructor Create(Owner: TComponent); override;
|
|
|
|
property IsListData: boolean read fListData write fListData;
|
|
|
|
procedure UpdateColumns; virtual;
|
|
|
|
published
|
|
|
|
property Caption: string Read GetCaption;
|
|
|
|
property Style: TKOLListViewStyle Read fLimStyle write SetLimStyle;
|
|
|
|
property Options: TKOLListViewOptions read GetOptions write SetOptions;
|
|
|
|
property OnGetEditText: TOnEditText read fOnGetText write SetOnGetText;
|
|
|
|
property OnPutEditText: TOnEditText read fOnPutText write SetOnPutText;
|
|
|
|
property OnStopEdit: TOnEndEdit read fOnEndEdit write SetOnEndEdit;
|
2021-03-05 07:43:36 +00:00
|
|
|
property OnCellAdjust: TOnCellAdjust read fOnCellAdjust write SetOnCellAdjust;
|
2009-08-06 14:32:07 +00:00
|
|
|
property OnEditChar: TOnEditChar read fOnEditChar write SetOnEditChar;
|
|
|
|
property OnCreateEdit: TOnCreateEdit read fOnCreateEdit write SetOnCreateEdit;
|
|
|
|
property OnDrawCell: TOnDrawCell read FOnDrawCell write SetOnDrawCell;
|
|
|
|
// Hide in Object Inspector property OnDrawItem (made read only)
|
|
|
|
property OnDrawItem: TOnDrawItem read fDrawForbidden;
|
|
|
|
end;
|
|
|
|
procedure Register;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
constructor TKOLEcmListEdit.Create;
|
|
|
|
begin
|
2021-03-05 07:43:36 +00:00
|
|
|
inherited;
|
|
|
|
inherited Style := lvsDetail;
|
|
|
|
inherited Options := [{lvoRowSelect,}lvoHideSel, lvoGridLines, lvoOwnerDrawFixed];
|
2009-08-06 14:32:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TKOLEcmListEdit.AdditionalUnits;
|
|
|
|
begin
|
2021-03-05 07:43:36 +00:00
|
|
|
Result := ', KOLEcmListEdit';
|
2009-08-06 14:32:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TKOLEcmListEdit.SetupFirst;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
2021-03-05 07:43:36 +00:00
|
|
|
procedure TKOLEcmListEdit.SetupLast(SL: TStringList; const AName, AParent, Prefix: String);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
// inherited AssignEvents(SL, AName);
|
|
|
|
//
|
|
|
|
// DoAssignEvents(SL, 'PEcmListEdit(' + AName + '.CustomObj)',
|
|
|
|
// ['OnGetEditText', 'OnPutEditText', 'OnStopEdit', 'OnCellAdjust', 'OnEditChar', 'OnCreateEdit', 'OnDrawCell'],
|
|
|
|
// [@OnGetEditText, @OnPutEditText, @OnStopEdit, @fOnCellAdjust, @OnEditChar, @OnCreateEdit, @OnDrawCell]);
|
|
|
|
|
|
|
|
// if Assigned(fOnGetText) then begin
|
|
|
|
// SL.Add( ' PEcmListEdit(' + AName + '.CustomObj).OnGetEditText := Result.' +
|
|
|
|
// ParentForm.MethodName(@OnGetEditText) + ';' );
|
|
|
|
// end;
|
|
|
|
// if @fOnPutText <> nil then
|
|
|
|
// SL.Add( ' PEcmListEdit(' + AName + '.CustomObj).OnPutEditText := Result.' +
|
|
|
|
// ParentForm.MethodName( @OnPutEditText ) + ';' );
|
|
|
|
// if @fOnEndEdit <> nil then
|
|
|
|
// SL.Add( ' PEcmListEdit(' + AName + '.CustomObj).OnStopEdit := Result.' +
|
|
|
|
// ParentForm.MethodName( @OnStopEdit ) + ';' );
|
|
|
|
// if @fOnCellAdjust <> nil then
|
|
|
|
// SL.Add( ' PEcmListEdit(' + AName + '.CustomObj).OnCellAdjust := Result.' +
|
|
|
|
// ParentForm.MethodName( @fOnCellAdjust ) + ';' );
|
|
|
|
// if @fOnEditChar <> nil then
|
|
|
|
// SL.Add( ' PEcmListEdit(' + AName + '.CustomObj).OnEditChar := Result.' +
|
|
|
|
// ParentForm.MethodName( @OnEditChar ) + ';' );
|
|
|
|
// if @fOnCreateEdit <> nil then
|
|
|
|
// SL.Add( ' PEcmListEdit(' + AName + '.CustomObj).OnCreateEdit := Result.' +
|
|
|
|
// ParentForm.MethodName( @OnCreateEdit ) + ';' );
|
|
|
|
// if (@fOnDrawCell <> nil) then
|
|
|
|
// SL.Add( ' PEcmListEdit(' + AName + '.CustomObj).OnDrawCell := Result.' +
|
|
|
|
// ParentForm.MethodName( @OnDrawCell ) + ';' );
|
2009-08-06 14:32:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TKOLEcmListEdit.AssignEvents;
|
|
|
|
begin
|
2021-03-05 07:43:36 +00:00
|
|
|
inherited;
|
|
|
|
|
|
|
|
DoAssignEvents(SL, 'PEcmListEdit(' + AName + '.CustomObj)',
|
|
|
|
['OnGetEditText', 'OnPutEditText', 'OnStopEdit', 'OnCellAdjust', 'OnEditChar', 'OnCreateEdit', 'OnDrawCell'],
|
|
|
|
[@OnGetEditText, @OnPutEditText, @OnStopEdit, @fOnCellAdjust, @OnEditChar, @OnCreateEdit, @OnDrawCell]);
|
2009-08-06 14:32:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TKOLEcmListEdit.GetCaption;
|
|
|
|
begin
|
2021-03-05 07:43:36 +00:00
|
|
|
Result := inherited Caption;
|
2009-08-06 14:32:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TKOLEcmListEdit.GetStyle;
|
|
|
|
begin
|
|
|
|
// Result := lvsDetail;
|
|
|
|
Result := fLimStyle;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TKOLEcmListEdit.GetOptions;
|
|
|
|
begin
|
2021-03-05 07:43:36 +00:00
|
|
|
Result := inherited Options;
|
2009-08-06 14:32:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TKOLEcmListEdit.SetOptions;
|
|
|
|
begin
|
2021-03-05 07:43:36 +00:00
|
|
|
inherited Options := v + [{lvoRowSelect,}lvoHideSel,lvoOwnerDrawFixed];
|
2009-08-06 14:32:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure Register;
|
|
|
|
begin
|
|
|
|
RegisterComponents('KOLAddons', [TKOLEcmListEdit]);
|
|
|
|
RegisterComponentEditor( TKOLEcmListEdit, TKOLLVColumnsEditor );
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TKOLEcmListEdit.UpdateColumns;
|
|
|
|
begin
|
|
|
|
Change;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TKOLEcmListEdit.SetOnGetText(const Value: TOnEditText);
|
|
|
|
begin
|
2021-03-05 07:43:36 +00:00
|
|
|
if (@fOnGetText <> @Value) then begin
|
2009-08-06 14:32:07 +00:00
|
|
|
fOnGetText := Value;
|
|
|
|
Change();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TKOLEcmListEdit.SetOnPutText(const Value: TOnEditText);
|
|
|
|
begin
|
2021-03-05 07:43:36 +00:00
|
|
|
if (@fOnPutText <> @Value) then begin
|
2009-08-06 14:32:07 +00:00
|
|
|
fOnPutText := Value;
|
|
|
|
Change();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TKOLEcmListEdit.SetOnEndEdit(const Value: TOnEndEdit);
|
|
|
|
begin
|
2021-03-05 07:43:36 +00:00
|
|
|
if (@fOnEndEdit <> @Value) then begin
|
2009-08-06 14:32:07 +00:00
|
|
|
fOnEndEdit := Value;
|
|
|
|
Change();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2021-03-05 07:43:36 +00:00
|
|
|
procedure TKOLEcmListEdit.SetOnCellAdjust(const Value: TOnCellAdjust);
|
2009-08-06 14:32:07 +00:00
|
|
|
begin
|
2021-03-05 07:43:36 +00:00
|
|
|
if (@fOnCellAdjust <> @Value) then begin
|
|
|
|
fOnCellAdjust := Value;
|
2009-08-06 14:32:07 +00:00
|
|
|
Change;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TKOLEcmListEdit.SetOnEditChar(const Value: TOnEditChar);
|
|
|
|
begin
|
2021-03-05 07:43:36 +00:00
|
|
|
if (@fOnEditChar <> @Value) then begin
|
2009-08-06 14:32:07 +00:00
|
|
|
fOnEditChar := Value;
|
2021-03-05 07:43:36 +00:00
|
|
|
Change;
|
2009-08-06 14:32:07 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TKOLEcmListEdit.SetOnDrawCell(const Value: TOnDrawCell);
|
|
|
|
begin
|
|
|
|
if @FOnDrawCell <> @Value then begin
|
|
|
|
FOnDrawCell:= Value;
|
2021-03-05 07:43:36 +00:00
|
|
|
Change;
|
2009-08-06 14:32:07 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2014-12-03 16:20:28 +00:00
|
|
|
function TKOLEcmListEdit.SetupParams(const AName, AParent: TDelphiString): TDelphiString;
|
2009-08-06 14:32:07 +00:00
|
|
|
begin
|
|
|
|
Result := inherited SetupParams(AName,AParent)
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TKOLEcmListEdit.SetOnCreateEdit(const Value: TOnCreateEdit);
|
|
|
|
begin
|
2021-03-05 07:43:36 +00:00
|
|
|
if (@fOnCreateEdit <> @Value) then begin
|
2009-08-06 14:32:07 +00:00
|
|
|
fOnCreateEdit := Value;
|
2021-03-05 07:43:36 +00:00
|
|
|
Change;
|
2009-08-06 14:32:07 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TKOLEcmListEdit.SetLimStyle(const Value: TKOLListViewStyle);
|
|
|
|
begin
|
|
|
|
if (Value <> fLimStyle) and ((Value = lvsDetail) or (Value = lvsDetailNoHeader)) then begin
|
|
|
|
fLimStyle := Value;
|
|
|
|
inherited Style := fLimStyle;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|
|
|
|
|