mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: refactoring to eliminate duplicate onDrawCell() in FileView
(cherry picked from commit 3fa8359330)
This commit is contained in:
parent
7d9592a473
commit
5015b769f5
4 changed files with 14 additions and 30 deletions
|
|
@ -22,7 +22,6 @@ type
|
|||
TBriefDrawGrid = class(TFileViewGrid)
|
||||
protected
|
||||
FBriefView: TBriefFileView;
|
||||
FOnDrawCell: TFileViewOnDrawCell;
|
||||
protected
|
||||
procedure UpdateView; override;
|
||||
procedure CalculateColRowCount; override;
|
||||
|
|
@ -40,8 +39,6 @@ type
|
|||
function CellToIndex(ACol, ARow: Integer): Integer; override;
|
||||
procedure IndexToCell(Index: Integer; out ACol, ARow: Integer); override;
|
||||
procedure DrawCell(aCol, aRow: Integer; aRect: TRect; aState: TGridDrawState); override;
|
||||
|
||||
property OnDrawCell: TFileViewOnDrawCell read FOnDrawCell write FOnDrawCell;
|
||||
end;
|
||||
|
||||
{ TBriefFileView }
|
||||
|
|
@ -509,12 +506,6 @@ var
|
|||
handler.draw( params );
|
||||
end;
|
||||
|
||||
procedure callOnDrawCell;
|
||||
begin
|
||||
if Assigned(OnDrawCell) and not(CsDesigning in ComponentState) then
|
||||
OnDrawCell( params );
|
||||
end;
|
||||
|
||||
//------------------------------------------------------
|
||||
//end of subprocedures
|
||||
//------------------------------------------------------
|
||||
|
|
@ -547,7 +538,7 @@ begin
|
|||
params.decorationRect:= self.ConvertToDecorationRect( params.drawingRect );
|
||||
params.focused:= (gdSelected in aState) and FBriefView.Active;
|
||||
callFileSourceDrawCell;
|
||||
callOnDrawCell;
|
||||
self.doOnDrawCell( params );
|
||||
end
|
||||
else
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -39,8 +39,6 @@ type
|
|||
FLastMouseScrollTime: QWord;
|
||||
ColumnsView: TColumnsFileView;
|
||||
|
||||
FOnDrawCell: TFileViewOnDrawCell;
|
||||
|
||||
function GetGridHorzLine: Boolean;
|
||||
function GetGridVertLine: Boolean;
|
||||
procedure SetGridHorzLine(const AValue: Boolean);
|
||||
|
|
@ -94,7 +92,6 @@ type
|
|||
|
||||
function CellToIndex(ACol, ARow: Integer): Integer; override;
|
||||
function isMultiColumns: Boolean; override;
|
||||
property OnDrawCell: TFileViewOnDrawCell read FOnDrawCell write FOnDrawCell;
|
||||
end;
|
||||
|
||||
TColumnResized = procedure (Sender: TObject; ColumnIndex: Integer; ColumnNewsize: integer) of object;
|
||||
|
|
@ -1952,12 +1949,6 @@ var
|
|||
handler.draw( params );
|
||||
end;
|
||||
|
||||
procedure callOnDrawCell;
|
||||
begin
|
||||
if Assigned(OnDrawCell) and not(CsDesigning in ComponentState) then
|
||||
OnDrawCell( params );
|
||||
end;
|
||||
|
||||
//------------------------------------------------------
|
||||
//end of subprocedures
|
||||
//------------------------------------------------------
|
||||
|
|
@ -2008,7 +1999,7 @@ begin
|
|||
params.decorationRect:= self.ConvertToDecorationRect( params.drawingRect );
|
||||
params.focused:= (gdSelected in aState) and ColumnsView.Active;
|
||||
callFileSourceDrawCell;
|
||||
callOnDrawCell;
|
||||
self.doOnDrawCell( params );
|
||||
|
||||
DrawCellGrid(aCol,aRow,aRect,aState);
|
||||
DrawLines;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ interface
|
|||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
uFileSource, uFileView,
|
||||
uFileSource, uFileView, uFileViewWithMainCtrl,
|
||||
uSmoothScrollingGrid;
|
||||
|
||||
type
|
||||
|
|
@ -14,8 +14,12 @@ type
|
|||
{ TFileViewBaseGrid }
|
||||
|
||||
TFileViewBaseGrid = class( TSmoothScrollingGrid )
|
||||
protected
|
||||
_onDrawCell: TFileViewOnDrawCell;
|
||||
property OnDrawCell: TFileViewOnDrawCell read _onDrawCell write _onDrawCell;
|
||||
protected
|
||||
function doCellClick( const Shift: TShiftState; const X, Y: Integer ): Boolean;
|
||||
procedure doOnDrawCell( var params: TFileSourceUIParams );
|
||||
function getFileView: TFileView; virtual; abstract;
|
||||
public
|
||||
function MouseOnGrid(X, Y: LongInt): Boolean;
|
||||
|
|
@ -64,6 +68,12 @@ begin
|
|||
Result:= handler.click( params );
|
||||
end;
|
||||
|
||||
procedure TFileViewBaseGrid.doOnDrawCell( var params: TFileSourceUIParams );
|
||||
begin
|
||||
if Assigned(_onDrawCell) and not(CsDesigning in self.ComponentState) then
|
||||
_onDrawCell( params );
|
||||
end;
|
||||
|
||||
function TFileViewBaseGrid.MouseOnGrid(X, Y: LongInt): Boolean;
|
||||
var
|
||||
bTemp: Boolean;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ type
|
|||
FMouseDownY: Integer;
|
||||
FThumbView: TThumbFileView;
|
||||
FUpdateColCount: Integer;
|
||||
FOnDrawCell: TFileViewOnDrawCell;
|
||||
protected
|
||||
procedure KeyDown(var Key : Word; Shift : TShiftState); override;
|
||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||
|
|
@ -80,7 +79,6 @@ type
|
|||
procedure DrawCell(aCol, aRow: Integer; aRect: TRect; aState: TGridDrawState); override;
|
||||
|
||||
function ConvertToDecorationRect(const drawingRect: TRect): TRect; override;
|
||||
property OnDrawCell: TFileViewOnDrawCell read FOnDrawCell write FOnDrawCell;
|
||||
end;
|
||||
|
||||
|
||||
|
|
@ -563,12 +561,6 @@ var
|
|||
handler.draw( params );
|
||||
end;
|
||||
|
||||
procedure callOnDrawCell;
|
||||
begin
|
||||
if Assigned(OnDrawCell) and not(CsDesigning in ComponentState) then
|
||||
OnDrawCell( params );
|
||||
end;
|
||||
|
||||
//------------------------------------------------------
|
||||
//end of subprocedures
|
||||
//------------------------------------------------------
|
||||
|
|
@ -606,7 +598,7 @@ begin
|
|||
|
||||
params.focused:= (gdSelected in aState) and FThumbView.Active;
|
||||
callFileSourceDrawCell;
|
||||
callOnDrawCell;
|
||||
self.doOnDrawCell( params );
|
||||
end
|
||||
else
|
||||
begin
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue