* Refactoring

git-svn-id: https://svn.code.sf.net/p/kolmck/code@164 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
This commit is contained in:
dkolmck
2017-09-20 09:42:57 +00:00
parent 7020f027c5
commit 7c9fe13a5a
5 changed files with 161 additions and 167 deletions

View File

@@ -38,11 +38,16 @@ requires
vclx; vclx;
contains contains
KolZLibBzip in 'KolZLibBzip.pas',
tinyPNG in 'tinyPNG.pas',
tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas',
KOLFontEditor in 'KOLFontEditor.pas',
mckWebBrowser in 'mckWebBrowser.pas',
mckDHTML in 'mckDHTML.pas',
KOLCCtrls in 'KOLCCtrls.pas', KOLCCtrls in 'KOLCCtrls.pas',
mckCCtrls in 'mckCCtrls.pas', mckCCtrls in 'mckCCtrls.pas',
KOLHashs in 'KOLHashs.PAS', KOLHashs in 'KOLHashs.PAS',
mckHashs in 'mckHashs.pas', mckHashs in 'mckHashs.pas',
KOLFontEditor in 'KOLFontEditor.pas',
KOLmhxp in 'KOLmhxp.pas', KOLmhxp in 'KOLmhxp.pas',
MCKMHXP in 'MCKMHXP.pas', MCKMHXP in 'MCKMHXP.pas',
mckEcmListEdit in 'mckEcmListEdit.pas', mckEcmListEdit in 'mckEcmListEdit.pas',
@@ -50,11 +55,6 @@ contains
mckBlockCipher in 'mckBlockCipher.pas', mckBlockCipher in 'mckBlockCipher.pas',
KOLBlockCipher in 'KOLBlockCipher.pas', KOLBlockCipher in 'KOLBlockCipher.pas',
mckXPMenus in 'mckXPMenus.pas', mckXPMenus in 'mckXPMenus.pas',
XPMenus in 'XPMenus.pas', XPMenus in 'XPMenus.pas';
tinyPNG in 'tinyPNG.pas',
tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas',
mckWebBrowser in 'mckWebBrowser.pas',
mckDHTML in 'mckDHTML.pas',
KolZLibBzip in 'KolZLibBzip.pas';
end. end.

View File

@@ -39,11 +39,16 @@ requires
vclx; vclx;
contains contains
KolZLibBzip in 'KolZLibBzip.pas',
tinyPNG in 'tinyPNG.pas',
tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas',
KOLFontEditor in 'KOLFontEditor.pas',
mckWebBrowser in 'mckWebBrowser.pas',
mckDHTML in 'mckDHTML.pas',
KOLCCtrls in 'KOLCCtrls.pas', KOLCCtrls in 'KOLCCtrls.pas',
mckCCtrls in 'mckCCtrls.pas', mckCCtrls in 'mckCCtrls.pas',
KOLHashs in 'KOLHashs.PAS', KOLHashs in 'KOLHashs.PAS',
mckHashs in 'mckHashs.pas', mckHashs in 'mckHashs.pas',
KOLFontEditor in 'KOLFontEditor.pas',
KOLmhxp in 'KOLmhxp.pas', KOLmhxp in 'KOLmhxp.pas',
MCKMHXP in 'MCKMHXP.pas', MCKMHXP in 'MCKMHXP.pas',
mckEcmListEdit in 'mckEcmListEdit.pas', mckEcmListEdit in 'mckEcmListEdit.pas',
@@ -51,11 +56,6 @@ contains
mckBlockCipher in 'mckBlockCipher.pas', mckBlockCipher in 'mckBlockCipher.pas',
KOLBlockCipher in 'KOLBlockCipher.pas', KOLBlockCipher in 'KOLBlockCipher.pas',
mckXPMenus in 'mckXPMenus.pas', mckXPMenus in 'mckXPMenus.pas',
XPMenus in 'XPMenus.pas', XPMenus in 'XPMenus.pas';
tinyPNG in 'tinyPNG.pas',
tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas',
mckWebBrowser in 'mckWebBrowser.pas',
mckDHTML in 'mckDHTML.pas',
KolZLibBzip in 'KolZLibBzip.pas';
end. end.

View File

@@ -39,11 +39,16 @@ requires
vclx; vclx;
contains contains
KolZLibBzip in 'KolZLibBzip.pas',
tinyPNG in 'tinyPNG.pas',
tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas',
KOLFontEditor in 'KOLFontEditor.pas',
mckWebBrowser in 'mckWebBrowser.pas',
mckDHTML in 'mckDHTML.pas',
KOLCCtrls in 'KOLCCtrls.pas', KOLCCtrls in 'KOLCCtrls.pas',
mckCCtrls in 'mckCCtrls.pas', mckCCtrls in 'mckCCtrls.pas',
KOLHashs in 'KOLHashs.PAS', KOLHashs in 'KOLHashs.PAS',
mckHashs in 'mckHashs.pas', mckHashs in 'mckHashs.pas',
KOLFontEditor in 'KOLFontEditor.pas',
KOLmhxp in 'KOLmhxp.pas', KOLmhxp in 'KOLmhxp.pas',
MCKMHXP in 'MCKMHXP.pas', MCKMHXP in 'MCKMHXP.pas',
mckEcmListEdit in 'mckEcmListEdit.pas', mckEcmListEdit in 'mckEcmListEdit.pas',
@@ -51,11 +56,6 @@ contains
mckBlockCipher in 'mckBlockCipher.pas', mckBlockCipher in 'mckBlockCipher.pas',
KOLBlockCipher in 'KOLBlockCipher.pas', KOLBlockCipher in 'KOLBlockCipher.pas',
mckXPMenus in 'mckXPMenus.pas', mckXPMenus in 'mckXPMenus.pas',
XPMenus in 'XPMenus.pas', XPMenus in 'XPMenus.pas';
tinyPNG in 'tinyPNG.pas',
tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas',
mckWebBrowser in 'mckWebBrowser.pas',
mckDHTML in 'mckDHTML.pas',
KolZLibBzip in 'KolZLibBzip.pas';
end. end.

View File

@@ -36,11 +36,16 @@ requires
vclx; vclx;
contains contains
KolZLibBzip in 'KolZLibBzip.pas',
tinyPNG in 'tinyPNG.pas',
tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas',
KOLFontEditor in 'KOLFontEditor.pas',
mckWebBrowser in 'mckWebBrowser.pas',
mckDHTML in 'mckDHTML.pas',
KOLCCtrls in 'KOLCCtrls.pas', KOLCCtrls in 'KOLCCtrls.pas',
mckCCtrls in 'mckCCtrls.pas', mckCCtrls in 'mckCCtrls.pas',
KOLHashs in 'KOLHashs.PAS', KOLHashs in 'KOLHashs.PAS',
mckHashs in 'mckHashs.pas', mckHashs in 'mckHashs.pas',
KOLFontEditor in 'KOLFontEditor.pas',
KOLmhxp in 'KOLmhxp.pas', KOLmhxp in 'KOLmhxp.pas',
MCKMHXP in 'MCKMHXP.pas', MCKMHXP in 'MCKMHXP.pas',
mckEcmListEdit in 'mckEcmListEdit.pas', mckEcmListEdit in 'mckEcmListEdit.pas',
@@ -48,11 +53,6 @@ contains
mckBlockCipher in 'mckBlockCipher.pas', mckBlockCipher in 'mckBlockCipher.pas',
KOLBlockCipher in 'KOLBlockCipher.pas', KOLBlockCipher in 'KOLBlockCipher.pas',
mckXPMenus in 'mckXPMenus.pas', mckXPMenus in 'mckXPMenus.pas',
XPMenus in 'XPMenus.pas', XPMenus in 'XPMenus.pas';
tinyPNG in 'tinyPNG.pas',
tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas',
mckWebBrowser in 'mckWebBrowser.pas',
mckDHTML in 'mckDHTML.pas',
KolZLibBzip in 'KolZLibBzip.pas';
end. end.

View File

@@ -144,7 +144,7 @@ type
Options: TEditOptions; Options: TEditOptions;
end; end;
TOnEditText = procedure(Sender: PControl; ACol, ARow: Integer; var Value: string) of object; TOnEditText = procedure(Sender: PControl; ACol, ARow: Integer; var Value: KOLString) of object;
TOnEditChar = procedure(Sender: PControl; ACol, ARow: Integer; var Key: KOLChar; Shift: DWORD) of object; TOnEditChar = procedure(Sender: PControl; ACol, ARow: Integer; var Key: KOLChar; Shift: DWORD) of object;
TOnEndEdit = procedure(Sender: PControl; ACol, ARow: Integer; CellChanged: Boolean) of object; TOnEndEdit = procedure(Sender: PControl; ACol, ARow: Integer; CellChanged: Boolean) of object;
TOnCreateEdit = procedure(Sender: PControl; ACol: Integer; var Editor: PControl; var ReadOnly: Boolean; var AutoHide: Boolean) of object; TOnCreateEdit = procedure(Sender: PControl; ACol: Integer; var Editor: PControl; var ReadOnly: Boolean; var AutoHide: Boolean) of object;
@@ -170,20 +170,20 @@ type
procedure EditOnChar(Sender: PControl; var Key: KOLChar; Shift: DWORD); procedure EditOnChar(Sender: PControl; var Key: KOLChar; Shift: DWORD);
procedure SetCurIdx(const Value: Integer); procedure SetCurIdx(const Value: Integer);
protected protected
fOwner: PControl; fOwner: PControl;
fColOptions: PList; fColOptions: PList;
fCurIdx: Integer; fCurIdx: Integer;
fCurLine: Integer; fCurLine: Integer;
fScroll: Integer; fScroll: Integer;
fOnPutText: TOnEditText; fOnPutText: TOnEditText;
fOnGetText: TOnEditText; fOnGetText: TOnEditText;
fOnEndEdit: TOnEndEdit; fOnEndEdit: TOnEndEdit;
FOnColAdjust: TOnColAdjust; FOnColAdjust: TOnColAdjust;
fStarted: Boolean; fStarted: Boolean;
fOnEditChar: TOnEditChar; fOnEditChar: TOnEditChar;
fShift: Integer; fShift: Integer;
fEmbedEd: Boolean; fEmbedEd: Boolean;
fAutoHide: Boolean; fAutoHide: Boolean;
function NewInPlaceEdit(Options: TEditOptions; Align: TTextAlign): PControl; function NewInPlaceEdit(Options: TEditOptions; Align: TTextAlign): PControl;
procedure DestroyInPlaceEditor; procedure DestroyInPlaceEditor;
procedure SetEditPos; procedure SetEditPos;
@@ -192,7 +192,7 @@ type
procedure DoColAdjust(ColCount: Integer); procedure DoColAdjust(ColCount: Integer);
procedure InternalStopEdit(const Store: Boolean); procedure InternalStopEdit(const Store: Boolean);
procedure HideInplaceEd(ActivateOwner: Boolean); procedure HideInplaceEd(ActivateOwner: Boolean);
function LVDrawItem(Sender: PObj; DC: HDC; const Rect: TRect; ItemIdx: Integer; DrawAction: TDrawAction; ItemState: TDrawState): Boolean; function LVDrawItem(Sender: PObj; DC: HDC; const Rect: TRect; ItemIdx: Integer; DrawAction: TDrawAction; ItemState: TDrawState): Boolean;
procedure ComboBox_CloseUp(Sender: PObj); procedure ComboBox_CloseUp(Sender: PObj);
public public
fInPlaceEd: PControl; fInPlaceEd: PControl;
@@ -304,11 +304,13 @@ begin
with PEcmListEdit(Sender.CustomObj)^ do begin with PEcmListEdit(Sender.CustomObj)^ do begin
case Msg.message of case Msg.message of
LVM_INSERTCOLUMNA, LVM_INSERTCOLUMNW, LVM_DELETECOLUMN: LVM_INSERTCOLUMNA, LVM_INSERTCOLUMNW, LVM_DELETECOLUMN:
begin
PostMessage(Msg.hwnd, LEN_COL_ADJUST, 0, 0); PostMessage(Msg.hwnd, LEN_COL_ADJUST, 0, 0);
end;
LEN_COL_ADJUST: LEN_COL_ADJUST:
begin
DoColAdjust(Sender.LVColCount); DoColAdjust(Sender.LVColCount);
end;
WM_LBUTTONDOWN{$IFDEF rbutton_sel}, WM_RBUTTONDOWN{$ENDIF}: WM_LBUTTONDOWN{$IFDEF rbutton_sel}, WM_RBUTTONDOWN{$ENDIF}:
begin begin
NewLine := GetLVItemAtPos(TSmallPoint(Msg.lParam), NewCurIdx); NewLine := GetLVItemAtPos(TSmallPoint(Msg.lParam), NewCurIdx);
@@ -316,16 +318,15 @@ begin
Sender.Focused := True; Sender.Focused := True;
Result := True; Result := True;
end; end;
WM_LBUTTONDBLCLK{$IFDEF rbutton_sel}, WM_RBUTTONDBLCLK{$ENDIF}: WM_LBUTTONDBLCLK{$IFDEF rbutton_sel}, WM_RBUTTONDBLCLK{$ENDIF}:
begin begin
NewLine := GetLVItemAtPos(TSmallPoint(Msg.lParam), NewCurIdx); NewLine := GetLVItemAtPos(TSmallPoint(Msg.lParam), NewCurIdx);
SetCurLVPos(NewLine, NewCurIdx); SetCurLVPos(NewLine, NewCurIdx);
if (NewLine <> -1) and (NewCurIdx <> -1) then StartEdit; if (NewLine <> -1) and (NewCurIdx <> -1) then
StartEdit;
Sender.Tabstop := False; Sender.Tabstop := False;
Result := True; Result := True;
end; end;
WM_KEYDOWN: WM_KEYDOWN:
begin begin
if (Msg.WParam = VK_RETURN) then if (Msg.WParam = VK_RETURN) then
@@ -340,25 +341,23 @@ begin
end; end;
SetEditPos; SetEditPos;
end; end;
//fInPlaceEd.Click; //.DroppedDown := True;
end; end;
WM_CHAR: // by SeM
// by SeM begin
WM_CHAR: if (GetKeyState(VK_CONTROL) >= 0) then begin // ! by Matveev Dmitry
if (GetKeyState(VK_CONTROL) >= 0) then begin // ! by Matveev Dmitry case Msg.wParam of
case Msg.wParam of VK_ESCAPE, VK_RETURN, VK_TAB:
VK_ESCAPE, VK_RETURN, VK_TAB: ;
; else begin
else begin StartEdit;
StartEdit; Sender.Tabstop := False;
Sender.Tabstop := False; if Assigned(fInPlaceEd) then
if Assigned(fInPlaceEd) then fInPlaceEd.Postmsg(Msg.message, Msg.wParam, Msg.lParam);
PostMessage(fInPlaceEd.Handle, Msg.message, Msg.wParam, Msg.lParam); Result := True;
Result := True; end;
end; end;
end; end;
end; end;
WM_NCPAINT, WM_PAINT: WM_NCPAINT, WM_PAINT:
begin begin
{$IFDEF _LE_DEBUG_} {$IFDEF _LE_DEBUG_}
@@ -366,9 +365,6 @@ begin
{$ENDIF} {$ENDIF}
SetEditPos(); SetEditPos();
end; end;
// WM_ERASEBKGND: Result := True;
// �����-�� ���� � ����������� ����� � ������ lvoGridLines ��� ������������� // �����-�� ���� � ����������� ����� � ������ lvoGridLines ��� �������������
// ���� XP - ��� ��������� ScrollBar(������ �������� "�����","����") ���������� // ���� XP - ��� ��������� ScrollBar(������ �������� "�����","����") ����������
// ������ ���������� ����� - � ���������� �������� ������ ���������� �������������� // ������ ���������� ����� - � ���������� �������� ������ ���������� ��������������
@@ -390,8 +386,8 @@ begin
{$IFDEF _LE_DEBUG_} {$IFDEF _LE_DEBUG_}
AddLog(Sender, 'ListEdit:NM_KILLFOCUS'); AddLog(Sender, 'ListEdit:NM_KILLFOCUS');
{$ENDIF} {$ENDIF}
R := fOwner.ClientRect; R := fOwner.ClientRect;
InvalidateRect(fOwner.Handle, @R, False); //UpdateRow(fCurLine); InvalidateRect(fOwner.Handle, @R, False); //UpdateRow(fCurLine);
end; end;
NM_SETFOCUS: NM_SETFOCUS:
begin begin
@@ -423,22 +419,20 @@ begin
case Msg.message of case Msg.message of
WM_KEYDOWN: WM_KEYDOWN:
begin begin
if Msg.wParam = VK_ESCAPE then if (Msg.wParam = VK_ESCAPE) then
PEcmListEdit(Sender.Parent.CustomObj).StopEdit(False); PEcmListEdit(Sender.Parent.CustomObj).StopEdit(False);
end; end;
WM_KILLFOCUS: WM_KILLFOCUS:
begin begin
pLE := PEcmListEdit(Sender.Parent.CustomObj); pLE := PEcmListEdit(Sender.Parent.CustomObj);
if Assigned(pLE) then begin if Assigned(pLE) then begin
with pLE^ do if pLE.fEmbedEd and pLE.fAutoHide then begin
if (fEmbedEd and fAutoHide) then begin pLE.InternalStopEdit(True);
InternalStopEdit(True); pLE.HideInPlaceEd(True);
HideInPlaceEd(True); end;
end;
end; end;
end; end;
// D[u]fa WM_CHAR: //+dufa
WM_CHAR:
if (Msg.wParam = VK_RETURN) then begin if (Msg.wParam = VK_RETURN) then begin
Msg.message := WM_KILLFOCUS; Msg.message := WM_KILLFOCUS;
WndProcInPlaceEd(Sender, Msg, Rslt); WndProcInPlaceEd(Sender, Msg, Rslt);
@@ -447,7 +441,7 @@ begin
end; end;
end; end;
// ��������� � ������� ������� ���������� �� ������� "��������" ��� ��������� // ��������� � ������� ������� ���������� �� ������� "��������" ��� ���������
// ��������. ����� �������������� ��� ������������ KOLListView. // ��������. ����� �������������� ��� ������������ KOLListView.
// ��� ���������� ����� �������� ListView-� (ListEdit-�) ���������� ������������ // ��� ���������� ����� �������� ListView-� (ListEdit-�) ���������� ������������
// ������ ������� ������� ListViewXXX.AttachProc(@WndProcListViewWOResizeFlicks); // ������ ������� ������� ListViewXXX.AttachProc(@WndProcListViewWOResizeFlicks);
@@ -471,6 +465,7 @@ begin
FillRect(Msg.wParam, rRight, Sender.Canvas.Brush.Handle); FillRect(Msg.wParam, rRight, Sender.Canvas.Brush.Handle);
end else end else
rUnder := rClient; rUnder := rClient;
FillRect(Msg.wParam, rUnder, Sender.Canvas.Brush.Handle); FillRect(Msg.wParam, rUnder, Sender.Canvas.Brush.Handle);
Result := True; Result := True;
end; end;
@@ -484,7 +479,9 @@ var
mOpt: TListViewOptions; mOpt: TListViewOptions;
begin begin
mOpt := Options + [lvoHideSel, lvoOwnerDrawFixed]; mOpt := Options + [lvoHideSel, lvoOwnerDrawFixed];
if ((Style <> lvsDetail) and (Style <> lvsDetailNoHeader)) then Style := lvsDetail; if ((Style <> lvsDetail) and (Style <> lvsDetailNoHeader)) then
Style := lvsDetail;
Result := NewListView(AParent, Style, mOpt, ImageListSmall, ImageListNormal, ImageListState); Result := NewListView(AParent, Style, mOpt, ImageListSmall, ImageListNormal, ImageListState);
New(pLD, Create); New(pLD, Create);
pLD.fOwner := Result; pLD.fOwner := Result;
@@ -512,7 +509,8 @@ end;
procedure TEcmListEdit.EditOnKeyDown(Sender: PControl; var Key: Longint; Shift: DWORD); procedure TEcmListEdit.EditOnKeyDown(Sender: PControl; var Key: Longint; Shift: DWORD);
begin begin
if (fScroll <> 0) then if (fScroll <> 0) then
PostMessage(fOwner.Handle, LVM_SCROLL, fScroll, 0); fOwner.Postmsg(LVM_SCROLL, fScroll, 0);
case key of case key of
// VK_RETURN: // VK_RETURN:
// StoreEditValues; // StoreEditValues;
@@ -541,8 +539,7 @@ begin
AddLog(Self.fOwner, 'DestroyInPlaceEditor'); AddLog(Self.fOwner, 'DestroyInPlaceEditor');
{$ENDIF} {$ENDIF}
if fEmbedEd and Assigned(fInPlaceEd) then if fEmbedEd and Assigned(fInPlaceEd) then
fInPlaceEd.Free; Free_And_Nil(fInPlaceEd);
fInPlaceEd := nil;
end; end;
procedure TEcmListEdit.SetEditPos; procedure TEcmListEdit.SetEditPos;
@@ -564,13 +561,13 @@ begin
GetWindowRect(Header, Re); GetWindowRect(Header, Re);
HeaderHeight := Re.Bottom - Re.Top; HeaderHeight := Re.Bottom - Re.Top;
if (R.Top >= HeaderHeight) then begin if (R.Top >= HeaderHeight) then begin
if fEmbedEd and (fInPlaceEd.Perform(EM_GETRECT, 0, Integer(@Re)) > 0) then begin if fEmbedEd and (fInPlaceEd.Perform(EM_GETRECT, 0, LPARAM(@Re)) > 0) then begin
if (R.Bottom - R.Top) > (Re.Bottom - Re.Top) then begin if (R.Bottom - R.Top) > (Re.Bottom - Re.Top) then begin
cw := ((R.Bottom - R.Top) - (Re.Bottom - Re.Top)) div 2; cw := ((R.Bottom - R.Top) - (Re.Bottom - Re.Top)) div 2;
Inc(R.Top, cw); Inc(R.Top, cw);
Dec(R.Bottom, cw); Dec(R.Bottom, cw);
end; end;
Inc(R.Left, fShift - Re.Left); Inc(R.Left, fShift - Re.Left);
Dec(R.Right, fShift - Re.Left); Dec(R.Right, fShift - Re.Left);
end; end;
pEO := fColOptions.Items[fCurIdx]; pEO := fColOptions.Items[fCurIdx];
@@ -579,8 +576,7 @@ begin
Dec(R.Right, Right); Dec(R.Right, Right);
Inc(R.Top, Top); Inc(R.Top, Top);
Dec(R.Bottom, Bottom); Dec(R.Bottom, Bottom);
// if fEmbedEd then //?
if fEmbedEd then
Dec(R.Left, 2); Dec(R.Left, 2);
end; end;
end else end else
@@ -604,8 +600,8 @@ end;
procedure TEcmListEdit.LoadEditValues; procedure TEcmListEdit.LoadEditValues;
var var
i: Integer; i: Integer;
S: String; S: KOLString;
V: String; V: KOLString;
begin begin
{$IFDEF _LE_DEBUG_} {$IFDEF _LE_DEBUG_}
AddLog(Self.fOwner, 'LoadEditValues'); AddLog(Self.fOwner, 'LoadEditValues');
@@ -617,7 +613,7 @@ begin
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; <-- unfortunly don'work... combobox force close after open
end else begin //if fEmbedEd then begin end else begin //if fEmbedEd then begin
if (fInPlaceEd.SubClassName = 'obj_COMBOBOX') then begin if (fInPlaceEd.SubClassName = 'obj_COMBOBOX') then begin
i := fInPlaceEd.IndexOf(S); i := fInPlaceEd.IndexOf(S);
@@ -671,7 +667,7 @@ begin
Result.OnKeyDown := EditOnKeyDown; Result.OnKeyDown := EditOnKeyDown;
Result.AttachProc(WndProcInPlaceEd); //by Matveev Dmitry Result.AttachProc(WndProcInPlaceEd); //by Matveev Dmitry
end else begin end else begin
Result.Parent := fOwner; Result.Parent := fOwner;
//Result.Focused := True; //Result.Focused := True;
Result.Visible := True; Result.Visible := True;
end; end;
@@ -690,25 +686,28 @@ begin
{$IFDEF _LE_DEBUG_} {$IFDEF _LE_DEBUG_}
AddLog(Self.fOwner, 'StartEdit'); AddLog(Self.fOwner, 'StartEdit');
{$ENDIF} {$ENDIF}
if (fOwner.LVColCount = 0) or (fOwner.LVCount = 0) or fStarted or (fCurIdx = -1) then Exit; if (fOwner.LVColCount = 0) or (fOwner.LVCount = 0) or fStarted or (fCurIdx = -1) then
Exit;
fCurLine := fOwner.LVCurItem; fCurLine := fOwner.LVCurItem;
if (fCurLine = -1) then begin if (fCurLine = -1) then begin
fCurLine := 0; fCurLine := 0;
fOwner.LVCurItem := 0; fOwner.LVCurItem := 0;
end; end;
//CreateInPlaceEditor(fOwner.LVColCount);
if not fStarted then begin if not fStarted then begin
DestroyInPlaceEditor; DestroyInPlaceEditor;
if (fOwner.LVColCount > 0) then begin if (fOwner.LVColCount > 0) then begin
pEO := fColOptions.Items[fCurIdx]; pEO := fColOptions.Items[fCurIdx];
fInPlaceEd := NewInPlaceEdit(pEO.Options, pEO.TextAlign); fInPlaceEd := NewInPlaceEdit(pEO.Options, pEO.TextAlign);
end; end;
end; end;
if Assigned(fInPlaceEd) then begin if Assigned(fInPlaceEd) then begin
fStarted := True; fStarted := True;
SetEditPos; SetEditPos;
LoadEditValues; LoadEditValues;
fOwner.Tabstop := False; fOwner.Tabstop := False;
fInPlaceEd.Visible := True; fInPlaceEd.Visible := True;
fInPlaceEd.Focused := True; fInPlaceEd.Focused := True;
UpdateRow(fCurLine); UpdateRow(fCurLine);
@@ -734,7 +733,7 @@ begin
HTI.pt.x := Pt.X; HTI.pt.x := Pt.X;
HTI.pt.y := Pt.Y; HTI.pt.y := Pt.Y;
fOwner.Perform(LVM_SUBITEMHITTEST, 0, Integer(@HTI)); fOwner.Perform(LVM_SUBITEMHITTEST, 0, Integer(@HTI));
Result := HTI.iItem; Result := HTI.iItem;
SubItem := HTI.iSubItem; SubItem := HTI.iSubItem;
end; end;
@@ -748,11 +747,9 @@ begin
end; end;
end; end;
if Assigned(fOnEditChar) then begin if Assigned(fOnEditChar) then begin
case Key of // BackSpace! - ������ ������������
#08: // BackSpace! - ������ ������������ if (Key <> #08) then // wtf? backspace is 9!
else
fOnEditChar(fInPlaceEd, fCurIdx, fOwner.LVCurItem, Key, Shift); fOnEditChar(fInPlaceEd, fCurIdx, fOwner.LVCurItem, Key, Shift);
end;
end; end;
end; end;
@@ -761,83 +758,79 @@ var
fBr: HBRUSH; fBr: HBRUSH;
cBr: TColor; cBr: TColor;
i: Integer; i: Integer;
S: String; S: KOLString;
P: TPoint; P: TPoint;
R: TRect; R: TRect;
dt: DWORD; dt: DWORD;
pEO: PEditorOptions; pEO: PEditorOptions;
begin begin
with fOwner^ do begin fShift := 0;
fShift := 0; for i := 0 to fOwner.LVColCount - 1 do begin
for i := 0 to LVColCount - 1 do begin R := fOwner.LVSubItemRect(ItemIdx, i);
R := LVSubItemRect(ItemIdx, i); P := fOwner.LVItemPos[i];
P := LVItemPos[i]; if (i = 0) then begin
if (i = 0) then begin R.Right := R.Left + fOwner.LVColWidth[0];
R.Right := R.Left + LVColWidth[0]; fShift := P.X - R.Left + 1; // dufa. 9.05.13, ������ ���� 2. � 1 ����� ListView + LVSCW_AUTOSIZE �������� ��� ����;
fShift := P.X - R.Left + 1; // dufa. 9.05.13, ������ ���� 2. � 1 ����� ListView + LVSCW_AUTOSIZE �������� ��� ����; end;
end; if (fOwner.Perform(LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) and LVS_EX_GRIDLINES) <> 0 then begin
if (Perform(LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) and LVS_EX_GRIDLINES) <> 0 then begin Inc(R.Left);
Inc(R.Left); Dec(R.Bottom);
Dec(R.Bottom); end;
end; if Assigned(FOnDrawCell) then
if Assigned(FOnDrawCell) then if FOnDrawCell(Sender, DC, R, i, ItemIdx, DrawAction, ItemState) then Continue; //by Matveev Dmitry
if FOnDrawCell(Sender, DC, R, i, ItemIdx, DrawAction, ItemState) then Continue; //by Matveev Dmitry
if fOwner.Enabled then if fOwner.Enabled then
cBr := fOwner.LVTextBkColor cBr := fOwner.LVTextBkColor
else else
cBr := clBtnFace; cBr := clBtnFace;
if (ItemIdx = fCurLine) then begin if (ItemIdx = fCurLine) then begin
if (fOwner.Focused or (Assigned(fInPlaceEd) and fInPlaceEd.Visible)) and Enabled then begin if (fOwner.Focused or (Assigned(fInPlaceEd) and fInPlaceEd.Visible)) and fOwner.Enabled then begin
if (i = fCurIdx) then begin
if fStarted then
cBr := fOwner.LVTextBkColor
else
cBr := clHighlight;
SetTextColor(DC, Color2RGB(clHighlightText));
end else begin
if (fOwner.Perform(LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) and LVS_EX_FULLROWSELECT) <> 0 then
cBr := $F3E6CD;
SetTextColor(DC, Color2RGB(fOwner.Font.Color));
end
end else begin
SetTextColor(DC, Color2RGB(fOwner.Font.Color));
if fOwner.Enabled then begin
if (i = fCurIdx) then begin if (i = fCurIdx) then begin
if fStarted then if fStarted then
cBr := fOwner.LVTextBkColor cBr := fOwner.LVTextBkColor
else else
cBr := clHighlight; cBr := clInactiveBorder;
SetTextColor(DC, Color2RGB(clHighlightText));
end else begin end else begin
if (Perform(LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) and LVS_EX_FULLROWSELECT) <> 0 then cBr := $F0F0F0;
cBr := $F3E6CD;
SetTextColor(DC, Color2RGB(fOwner.Font.Color));
end end
end else begin
SetTextColor(DC, Color2RGB(fOwner.Font.Color));
if Enabled then begin
if (i = fCurIdx) then begin
if fStarted then
cBr := fOwner.LVTextBkColor
else
cBr := clInactiveBorder;
end else begin
cBr := $F0F0F0;
end
end;
end; end;
end else
SetTextColor(DC, Color2RGB(fOwner.Font.Color));
fBr := CreateSolidBrush(Color2RGB(cBr));
FillRect(DC, R, fBr);
DeleteObject(fBr);
if not ((ItemIdx = LVCurItem) and (fStarted) and (i = fCurIdx)) then begin
S := fOwner.LVItems[ItemIdx, i];
dt := DT_END_ELLIPSIS or DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX;
if (fColOptions.Count <> LVColCount) then
DoColAdjust(LVColCount);
pEO := fColOptions.Items[i];
case pEO.TextAlign of
taRight:
dt := dt or DT_RIGHT;
taCenter:
dt := dt or DT_CENTER;
end;
Dec(R.Right, fShift);
Inc(R.Left, fShift);
DrawText(DC, @S[1], Length(S), R, dt);
end; end;
end else
SetTextColor(DC, Color2RGB(fOwner.Font.Color));
fBr := CreateSolidBrush(Color2RGB(cBr));
FillRect(DC, R, fBr);
DeleteObject(fBr);
if not ((ItemIdx = fOwner.LVCurItem) and (fStarted) and (i = fCurIdx)) then begin
S := fOwner.LVItems[ItemIdx, i];
dt := DT_END_ELLIPSIS or DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX;
if (fColOptions.Count <> fOwner.LVColCount) then
DoColAdjust(fOwner.LVColCount);
pEO := fColOptions.Items[i];
case pEO.TextAlign of
taRight: dt := dt or DT_RIGHT;
taCenter: dt := dt or DT_CENTER;
end;
Dec(R.Right, fShift);
Inc(R.Left, fShift);
DrawText(DC, @S[1], Length(S), R, dt);
end; end;
end; end;
Result := True; Result := True;
@@ -849,11 +842,12 @@ var
pEO: PEditorOptions; pEO: PEditorOptions;
begin begin
if (ColCount <> fColOptions.Count) then begin if (ColCount <> fColOptions.Count) then begin
for i := fColOptions.Count - 1 downto 0 do // downto - for what? //for i := fColOptions.Count - 1 downto 0 do // downto - for what?
FreeMem(fColOptions.Items[i]); // FreeMem(fColOptions.Items[i]);
fColOptions.Clear; //fColOptions.Clear;
fColOptions.ReleaseItems;
for i := 0 to ColCount - 1 do begin for i := 0 to Pred(ColCount) do begin
New(pEO); New(pEO);
ZeroMemory(pEO, SizeOf(TEditorOptions)); ZeroMemory(pEO, SizeOf(TEditorOptions));
pEO.TextAlign := fOwner.LVColAlign[i]; pEO.TextAlign := fOwner.LVColAlign[i];
@@ -904,7 +898,7 @@ end;
procedure TEcmListEdit.InternalStopEdit(const Store: Boolean); procedure TEcmListEdit.InternalStopEdit(const Store: Boolean);
var var
i: Integer; i: Integer;
newValue: String; newValue: KOLString;
fCellChanged: Boolean; fCellChanged: Boolean;
begin begin
if fStarted then begin if fStarted then begin