* KOLEcmListEdit - some fixes
git-svn-id: https://svn.code.sf.net/p/kolmck/code@154 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
This commit is contained in:
@@ -161,7 +161,7 @@ type
|
|||||||
|</p>
|
|</p>
|
||||||
}
|
}
|
||||||
private
|
private
|
||||||
fOnCreateEd: TOnCreateEdit;
|
FOnCreateEdit: TOnCreateEdit;
|
||||||
FOnDrawCell: TOnDrawCell;
|
FOnDrawCell: TOnDrawCell;
|
||||||
procedure EditOnKeyDown(Sender: PControl; var Key: Longint; Shift: DWORD);
|
procedure EditOnKeyDown(Sender: PControl; var Key: Longint; Shift: DWORD);
|
||||||
procedure EditOnChar(Sender: PControl; var Key: KOLChar; Shift: DWORD);
|
procedure EditOnChar(Sender: PControl; var Key: KOLChar; Shift: DWORD);
|
||||||
@@ -181,7 +181,7 @@ type
|
|||||||
fShift: Integer;
|
fShift: Integer;
|
||||||
fEmbedEd: Boolean;
|
fEmbedEd: Boolean;
|
||||||
fAutoHide: Boolean;
|
fAutoHide: Boolean;
|
||||||
function NewInPlaceEd(Options: TEditOptions; Align: TTextAlign): PControl;
|
function NewInPlaceEdit(Options: TEditOptions; Align: TTextAlign): PControl;
|
||||||
procedure DestroyInPlaceEditor;
|
procedure DestroyInPlaceEditor;
|
||||||
procedure SetEditPos;
|
procedure SetEditPos;
|
||||||
procedure LoadEditValues;
|
procedure LoadEditValues;
|
||||||
@@ -255,7 +255,7 @@ type
|
|||||||
������������� ����� �� ��������� �������.
|
������������� ����� �� ��������� �������.
|
||||||
|</p>
|
|</p>
|
||||||
}
|
}
|
||||||
property OnCreateEdit: TOnCreateEdit read fOnCreateEd write fOnCreateEd;
|
property OnCreateEdit: TOnCreateEdit read FOnCreateEdit write FOnCreateEdit;
|
||||||
{* ���������� ��� �������� ��������� ������. ����� �������������� ���
|
{* ���������� ��� �������� ��������� ������. ����� �������������� ���
|
||||||
���������� ����������� EditBox-� ������� ������������. }
|
���������� ����������� EditBox-� ������� ������������. }
|
||||||
|
|
||||||
@@ -366,9 +366,7 @@ begin
|
|||||||
SetEditPos();
|
SetEditPos();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// WM_ERASEBKGND: begin
|
// WM_ERASEBKGND: Result := True;
|
||||||
// Result := True;
|
|
||||||
// end;
|
|
||||||
|
|
||||||
// �����-�� ���� � ����������� ����� � ������ lvoGridLines ��� �������������
|
// �����-�� ���� � ����������� ����� � ������ lvoGridLines ��� �������������
|
||||||
// ���� XP - ��� ��������� ScrollBar(������ �������� "�����","����") ����������
|
// ���� XP - ��� ��������� ScrollBar(������ �������� "�����","����") ����������
|
||||||
@@ -600,28 +598,72 @@ end;
|
|||||||
|
|
||||||
procedure TEcmListEdit.LoadEditValues;
|
procedure TEcmListEdit.LoadEditValues;
|
||||||
var
|
var
|
||||||
S: string;
|
z: Integer;
|
||||||
|
S: String;
|
||||||
begin
|
begin
|
||||||
{$IFDEF _LE_DEBUG_}
|
{$IFDEF _LE_DEBUG_}
|
||||||
AddLog(Self.fOwner, 'LoadEditValues');
|
AddLog(Self.fOwner, 'LoadEditValues');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
with fOwner^ do begin
|
S := fOwner.LVItems[fOwner.LVCurItem, fCurIdx];
|
||||||
S := fOwner.LVItems[LVCurItem, fCurIdx];
|
|
||||||
if Assigned(fOnGetText) then
|
if Assigned(fOnGetText) then
|
||||||
fOnGetText(fOwner, fCurIdx, LVCurItem, S);
|
fOnGetText(fOwner, fCurIdx, fOwner.LVCurItem, S);
|
||||||
|
|
||||||
if IsComboEditor then begin
|
if IsComboEditor then begin
|
||||||
IsComboEditor := False; //
|
IsComboEditor := False; //
|
||||||
fInPlaceEd.CurIndex := fInPlaceEd.IndexOf(S);
|
fInPlaceEd.CurIndex := fInPlaceEd.IndexOf(S);
|
||||||
//fInPlaceEd.DroppedDown := True;
|
//fInPlaceEd.DroppedDown := True;
|
||||||
end else begin //if fEmbedEd then begin
|
end else begin //if fEmbedEd then begin
|
||||||
if (fInPlaceEd.SubClassName = 'obj_COMBOBOX') then
|
if (fInPlaceEd.SubClassName = 'obj_COMBOBOX') then begin
|
||||||
fInPlaceEd.CurIndex := fInPlaceEd.IndexOf(S)
|
z := fInPlaceEd.IndexOf(S);
|
||||||
else begin // 'obj_EDIT'
|
if (z = -1) then
|
||||||
|
fInPlaceEd.Text := S
|
||||||
|
else
|
||||||
|
fInPlaceEd.CurIndex := z;
|
||||||
|
end else begin // 'obj_EDIT'
|
||||||
fInPlaceEd.Text := S;
|
fInPlaceEd.Text := S;
|
||||||
fInPlaceEd.SelectAll;
|
fInPlaceEd.SelectAll;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TEcmListEdit.NewInPlaceEdit(Options: TEditOptions; Align: TTextAlign): PControl;
|
||||||
|
var
|
||||||
|
RO: Boolean; // readonly
|
||||||
|
AH: Boolean; // autohide
|
||||||
|
begin
|
||||||
|
Result := nil;
|
||||||
|
RO := False;
|
||||||
|
AH := True;
|
||||||
|
if Assigned(FOnCreateEdit) then
|
||||||
|
FOnCreateEdit(fOwner, fCurIdx, Result, RO, AH);
|
||||||
|
|
||||||
|
if not RO then begin
|
||||||
|
fEmbedEd := not Assigned(Result);
|
||||||
|
if fEmbedEd then begin
|
||||||
|
if IsComboEditor then begin
|
||||||
|
Result := NewCombobox(fOwner, ComboOptions);
|
||||||
|
Result.OnCloseUp := ComboBox_CloseUp;
|
||||||
|
repeat
|
||||||
|
Result.Add(Parse(ComboText, ';'));
|
||||||
|
until (ComboText = '');
|
||||||
|
end else
|
||||||
|
Result := NewEditBox(fOwner, Options);
|
||||||
|
Result.Font.Assign(fOwner.Font);
|
||||||
|
Result.Color := fOwner.LVTextBkColor;
|
||||||
|
Result.ExStyle := Result.ExStyle and not (WS_EX_DLGMODALFRAME or WS_EX_WINDOWEDGE or WS_EX_CLIENTEDGE);
|
||||||
|
Result.OnKeyDown := EditOnKeyDown;
|
||||||
|
Result.AttachProc(WndProcInPlaceEd); //by Matveev Dmitry
|
||||||
|
end else begin
|
||||||
|
Result.Parent := fOwner;
|
||||||
|
//Result.Focused := True;
|
||||||
|
Result.Visible := True;
|
||||||
|
end;
|
||||||
|
//Result.Tabstop := True;
|
||||||
|
fAutoHide := AH;
|
||||||
|
Result.OnChar := EditOnChar;
|
||||||
|
Result.TabOrder := fOwner.TabOrder;
|
||||||
|
Result.TextAlign := Align;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEcmListEdit.StartEdit;
|
procedure TEcmListEdit.StartEdit;
|
||||||
@@ -642,7 +684,7 @@ begin
|
|||||||
DestroyInPlaceEditor;
|
DestroyInPlaceEditor;
|
||||||
if (fOwner.LVColCount > 0) then begin
|
if (fOwner.LVColCount > 0) then begin
|
||||||
pEO := fColOptions.Items[fCurIdx];
|
pEO := fColOptions.Items[fCurIdx];
|
||||||
fInPlaceEd := NewInPlaceEd(pEO.Options, pEO.TextAlign);
|
fInPlaceEd := NewInPlaceEdit(pEO.Options, pEO.TextAlign);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if Assigned(fInPlaceEd) then begin
|
if Assigned(fInPlaceEd) then begin
|
||||||
@@ -697,45 +739,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TEcmListEdit.NewInPlaceEd(Options: TEditOptions; Align: TTextAlign): PControl;
|
|
||||||
var
|
|
||||||
RO: Boolean;
|
|
||||||
AH: Boolean;
|
|
||||||
begin
|
|
||||||
Result := nil;
|
|
||||||
RO := False;
|
|
||||||
AH := True;
|
|
||||||
if Assigned(fOnCreateEd) then
|
|
||||||
fOnCreateEd(fOwner, fCurIdx, Result, RO, AH);
|
|
||||||
if not RO then begin
|
|
||||||
fEmbedEd := not Assigned(Result);
|
|
||||||
if fEmbedEd then begin
|
|
||||||
if IsComboEditor then begin
|
|
||||||
Result := NewCombobox(fOwner, ComboOptions);
|
|
||||||
Result.OnCloseUp := ComboBox_CloseUp;
|
|
||||||
repeat
|
|
||||||
Result.Add(Parse(ComboText, ';'));
|
|
||||||
until (ComboText = '');
|
|
||||||
end else
|
|
||||||
Result := NewEditBox(fOwner, Options);
|
|
||||||
Result.Font.Assign(fOwner.Font);
|
|
||||||
Result.Color := fOwner.LVTextBkColor;
|
|
||||||
Result.ExStyle := Result.ExStyle and not (WS_EX_DLGMODALFRAME or WS_EX_WINDOWEDGE or WS_EX_CLIENTEDGE);
|
|
||||||
Result.OnKeyDown := EditOnKeyDown;
|
|
||||||
Result.AttachProc(WndProcInPlaceEd); //by Matveev Dmitry
|
|
||||||
end else begin
|
|
||||||
Result.Parent := fOwner;
|
|
||||||
//Result.Focused := True;
|
|
||||||
Result.Visible := True;
|
|
||||||
end;
|
|
||||||
//Result.Tabstop := True;
|
|
||||||
fAutoHide := AH;
|
|
||||||
Result.OnChar := EditOnChar;
|
|
||||||
Result.TabOrder := fOwner.TabOrder;
|
|
||||||
Result.TextAlign := Align;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TEcmListEdit.LVDrawItem(Sender: PObj; DC: HDC; const Rect: TRect; ItemIdx: Integer; DrawAction: TDrawAction; ItemState: TDrawState): Boolean;
|
function TEcmListEdit.LVDrawItem(Sender: PObj; DC: HDC; const Rect: TRect; ItemIdx: Integer; DrawAction: TDrawAction; ItemState: TDrawState): Boolean;
|
||||||
var
|
var
|
||||||
fBr: HBRUSH;
|
fBr: HBRUSH;
|
||||||
@@ -892,19 +895,17 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
fCellChanged := False;
|
fCellChanged := False;
|
||||||
if Store then begin
|
if Store then begin
|
||||||
with fOwner^ do begin
|
if (fOwner.LVItems[fOwner.LVCurItem, fCurIdx] <> fInPlaceEd.Text) then begin
|
||||||
if (fOwner.LVItems[LVCurItem, fCurIdx] <> fInPlaceEd.Text) then begin
|
|
||||||
S := fInPlaceEd.Text;
|
S := fInPlaceEd.Text;
|
||||||
if Assigned(fOnPutText) then
|
if Assigned(fOnPutText) then
|
||||||
fOnPutText(fOwner, fCurIdx, LVCurItem, S);
|
fOnPutText(fOwner, fCurIdx, fOwner.LVCurItem, S);
|
||||||
if (S <> fOwner.LVItems[LVCurItem, fCurIdx]) then begin
|
if (S <> fOwner.LVItems[fOwner.LVCurItem, fCurIdx]) then begin
|
||||||
fCellChanged := True;
|
fCellChanged := True;
|
||||||
fOwner.LVItems[LVCurItem, fCurIdx] := S;
|
fOwner.LVItems[fOwner.LVCurItem, fCurIdx] := S;
|
||||||
end;
|
end;
|
||||||
fInPlaceEd.Text := S;
|
fInPlaceEd.Text := S;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
fStarted := False;
|
fStarted := False;
|
||||||
if Assigned(fOnEndEdit) then
|
if Assigned(fOnEndEdit) then
|
||||||
fOnEndEdit(fOwner, fCurIdx, fOwner.LVCurItem, fCellChanged);
|
fOnEndEdit(fOwner, fCurIdx, fOwner.LVCurItem, fCellChanged);
|
||||||
@@ -954,5 +955,5 @@ begin
|
|||||||
InvalidateRect(fOwner.Handle, @R, False);
|
InvalidateRect(fOwner.Handle, @R, False);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
end.
|
||||||
|
Reference in New Issue
Block a user