mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: refactoring to eliminate duplicate doCellEnhancedDraw() in FileView
This commit is contained in:
parent
5fd8496570
commit
e69d6ee4c2
4 changed files with 35 additions and 39 deletions
|
|
@ -507,12 +507,11 @@ begin
|
|||
FileSourceDirectAccess:= fspDirectAccess in FBriefView.FileSource.Properties;
|
||||
|
||||
params:= Default( TFileSourceUIParams );
|
||||
params.sender:= FBriefView;
|
||||
params.fs:= FBriefView.FileSource;
|
||||
params.multiColumns:= False;
|
||||
params.col:= aCol;
|
||||
params.row:= aRow;
|
||||
params.displayFile:= aFile;
|
||||
params.drawingRect:= aRect;
|
||||
params.focused:= (gdSelected in aState) and FBriefView.Active;
|
||||
|
||||
if AFile.DisplayStrings.Count = 0 then
|
||||
FBriefView.MakeColumnsStrings(AFile);
|
||||
|
|
@ -522,12 +521,7 @@ begin
|
|||
iTextTop := aRect.Top + (RowHeights[aRow] - self.calcTextHeight) div 2;
|
||||
|
||||
DrawIconCell;
|
||||
|
||||
params.drawingRect:= aRect;
|
||||
params.decorationRect:= self.ConvertToDecorationRect( params.drawingRect );
|
||||
params.focused:= (gdSelected in aState) and FBriefView.Active;
|
||||
self.doFileSourceDrawCell( params );
|
||||
self.doOnDrawCell( params );
|
||||
self.doCellEnhancedDraw( params );
|
||||
end
|
||||
else
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -1960,12 +1960,11 @@ begin
|
|||
FileSourceDirectAccess := fspDirectAccess in ColumnsView.FileSource.Properties;
|
||||
|
||||
params:= Default( TFileSourceUIParams );
|
||||
params.sender:= Self.ColumnsView;
|
||||
params.fs:= Self.ColumnsView.FileSource;
|
||||
params.multiColumns:= True;
|
||||
params.col:= aCol;
|
||||
params.row:= aRow;
|
||||
params.displayFile:= aFile;
|
||||
params.drawingRect:= aRect;
|
||||
params.focused:= (gdSelected in aState) and ColumnsView.Active;
|
||||
|
||||
if AFile.DisplayStrings.Count = 0 then
|
||||
ColumnsView.MakeColumnsStrings(AFile, ColumnsSet);
|
||||
|
|
@ -1984,11 +1983,7 @@ begin
|
|||
DrawOtherCell;
|
||||
end;
|
||||
|
||||
params.drawingRect:= aRect;
|
||||
params.decorationRect:= self.ConvertToDecorationRect( params.drawingRect );
|
||||
params.focused:= (gdSelected in aState) and ColumnsView.Active;
|
||||
self.doFileSourceDrawCell( params );
|
||||
self.doOnDrawCell( params );
|
||||
self.doCellEnhancedDraw( params );
|
||||
|
||||
DrawCellGrid(aCol,aRow,aRect,aState);
|
||||
DrawLines;
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@ type
|
|||
_onDrawCell: TFileViewOnDrawCell;
|
||||
property OnDrawCell: TFileViewOnDrawCell read _onDrawCell write _onDrawCell;
|
||||
protected
|
||||
procedure doCellEnhancedDraw( var params: TFileSourceUIParams );
|
||||
function doCellClick( const Shift: TShiftState; const X, Y: Integer ): Boolean;
|
||||
procedure doFileSourceDrawCell( var params: TFileSourceUIParams );
|
||||
procedure doOnDrawCell( var params: TFileSourceUIParams );
|
||||
protected
|
||||
function getFileView: TFileView; virtual; abstract;
|
||||
function isMultiColumns: Boolean; virtual;
|
||||
|
|
@ -71,21 +70,35 @@ begin
|
|||
Result:= handler.click( params );
|
||||
end;
|
||||
|
||||
procedure TFileViewBaseGrid.doFileSourceDrawCell( var params: TFileSourceUIParams );
|
||||
procedure TFileViewBaseGrid.doCellEnhancedDraw( var params: TFileSourceUIParams );
|
||||
|
||||
procedure doFileSourceDrawCell( var params: TFileSourceUIParams );
|
||||
var
|
||||
handler: TFileSourceUIHandler;
|
||||
begin
|
||||
handler:= params.fs.GetUIHandler;
|
||||
if handler = nil then
|
||||
Exit;
|
||||
|
||||
handler.draw( params );
|
||||
end;
|
||||
|
||||
procedure doOnDrawCell( var params: TFileSourceUIParams );
|
||||
begin
|
||||
if Assigned(_onDrawCell) and not(CsDesigning in self.ComponentState) then
|
||||
_onDrawCell( params );
|
||||
end;
|
||||
|
||||
var
|
||||
handler: TFileSourceUIHandler;
|
||||
fileView: TFileView;
|
||||
begin
|
||||
handler:= params.fs.GetUIHandler;
|
||||
if handler = nil then
|
||||
Exit;
|
||||
|
||||
handler.draw( params );
|
||||
end;
|
||||
|
||||
procedure TFileViewBaseGrid.doOnDrawCell( var params: TFileSourceUIParams );
|
||||
begin
|
||||
if Assigned(_onDrawCell) and not(CsDesigning in self.ComponentState) then
|
||||
_onDrawCell( params );
|
||||
fileView:= self.getFileView;
|
||||
params.sender:= fileView;
|
||||
params.fs:= fileView.FileSource;
|
||||
params.multiColumns:= self.isMultiColumns;
|
||||
params.decorationRect:= self.ConvertToDecorationRect( params.drawingRect );
|
||||
doFileSourceDrawCell( params );
|
||||
doOnDrawCell( params );
|
||||
end;
|
||||
|
||||
function TFileViewBaseGrid.MouseOnGrid(X, Y: LongInt): Boolean;
|
||||
|
|
|
|||
|
|
@ -556,12 +556,10 @@ begin
|
|||
FileSourceDirectAccess:= fspDirectAccess in FFileView.FileSource.Properties;
|
||||
|
||||
params:= Default( TFileSourceUIParams );
|
||||
params.sender:= FThumbView;
|
||||
params.fs:= FThumbView.FileSource;
|
||||
params.multiColumns:= False;
|
||||
params.col:= aCol;
|
||||
params.row:= aRow;
|
||||
params.displayFile:= aFile;
|
||||
params.focused:= (gdSelected in aState) and FThumbView.Active;
|
||||
|
||||
if AFile.DisplayStrings.Count = 0 then
|
||||
FThumbView.MakeColumnsStrings(AFile);
|
||||
|
|
@ -575,13 +573,9 @@ begin
|
|||
end else begin
|
||||
params.drawingRect:= aRect;
|
||||
end;
|
||||
params.decorationRect:= self.ConvertToDecorationRect( params.drawingRect );
|
||||
|
||||
DrawIconCell;
|
||||
|
||||
params.focused:= (gdSelected in aState) and FThumbView.Active;
|
||||
self.doFileSourceDrawCell( params );
|
||||
self.doOnDrawCell( params );
|
||||
self.doCellEnhancedDraw( params );
|
||||
end
|
||||
else
|
||||
begin
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue