mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-14 01:56:36 +08:00
Issue #139: use alternating row background in database tab, and in all sub tabs of the host tab
This commit is contained in:
@ -587,6 +587,7 @@ object MainForm: TMainForm
|
|||||||
TreeOptions.PaintOptions = [toHotTrack, toShowDropmark, toShowHorzGridLines, toShowVertGridLines, toThemeAware, toUseBlendedImages, toUseExplorerTheme]
|
TreeOptions.PaintOptions = [toHotTrack, toShowDropmark, toShowHorzGridLines, toShowVertGridLines, toThemeAware, toUseBlendedImages, toUseExplorerTheme]
|
||||||
TreeOptions.SelectionOptions = [toExtendedFocus, toFullRowSelect, toRightClickSelect]
|
TreeOptions.SelectionOptions = [toExtendedFocus, toFullRowSelect, toRightClickSelect]
|
||||||
OnAfterPaint = AnyGridAfterPaint
|
OnAfterPaint = AnyGridAfterPaint
|
||||||
|
OnBeforeCellPaint = ListStatusBeforeCellPaint
|
||||||
OnBeforePaint = HostListBeforePaint
|
OnBeforePaint = HostListBeforePaint
|
||||||
OnCompareNodes = AnyGridCompareNodes
|
OnCompareNodes = AnyGridCompareNodes
|
||||||
OnGetText = HostListGetText
|
OnGetText = HostListGetText
|
||||||
|
@ -1192,6 +1192,9 @@ type
|
|||||||
procedure menuTabsInMultipleLinesClick(Sender: TObject);
|
procedure menuTabsInMultipleLinesClick(Sender: TObject);
|
||||||
procedure actResetPanelDimensionsExecute(Sender: TObject);
|
procedure actResetPanelDimensionsExecute(Sender: TObject);
|
||||||
procedure menuAlwaysGenerateFilterClick(Sender: TObject);
|
procedure menuAlwaysGenerateFilterClick(Sender: TObject);
|
||||||
|
procedure ListStatusBeforeCellPaint(Sender: TBaseVirtualTree;
|
||||||
|
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
|
||||||
|
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
|
||||||
private
|
private
|
||||||
// Executable file details
|
// Executable file details
|
||||||
FAppVerMajor: Integer;
|
FAppVerMajor: Integer;
|
||||||
@ -1332,6 +1335,8 @@ type
|
|||||||
property Connections: TDBConnectionList read FConnections;
|
property Connections: TDBConnectionList read FConnections;
|
||||||
property Delimiter: String read FDelimiter write SetDelimiter;
|
property Delimiter: String read FDelimiter write SetDelimiter;
|
||||||
property FocusedTables: TDBObjectList read FFocusedTables;
|
property FocusedTables: TDBObjectList read FFocusedTables;
|
||||||
|
function GetAlternatingRowBackground(Node: PVirtualNode): TColor;
|
||||||
|
procedure PaintAlternatingRowBackground(TargetCanvas: TCanvas; Node: PVirtualNode; CellRect: TRect);
|
||||||
procedure PaintColorBar(Value, Max: Extended; TargetCanvas: TCanvas; CellRect: TRect);
|
procedure PaintColorBar(Value, Max: Extended; TargetCanvas: TCanvas; CellRect: TRect);
|
||||||
procedure CallSQLHelpWithKeyword( keyword: String );
|
procedure CallSQLHelpWithKeyword( keyword: String );
|
||||||
procedure AddOrRemoveFromQueryLoadHistory(Filename: String; AddIt: Boolean; CheckIfFileExists: Boolean);
|
procedure AddOrRemoveFromQueryLoadHistory(Filename: String; AddIt: Boolean; CheckIfFileExists: Boolean);
|
||||||
@ -8864,6 +8869,8 @@ procedure TMainForm.ListTablesBeforeCellPaint(Sender: TBaseVirtualTree; TargetCa
|
|||||||
var
|
var
|
||||||
Obj: PDBObject;
|
Obj: PDBObject;
|
||||||
begin
|
begin
|
||||||
|
PaintAlternatingRowBackground(TargetCanvas, Node, CellRect);
|
||||||
|
|
||||||
// Only paint bar in rows + size column
|
// Only paint bar in rows + size column
|
||||||
if Column in [1, 2] then begin
|
if Column in [1, 2] then begin
|
||||||
Obj := Sender.GetNodeData(Node);
|
Obj := Sender.GetNodeData(Node);
|
||||||
@ -8875,6 +8882,36 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TMainForm.GetAlternatingRowBackground(Node: PVirtualNode): TColor;
|
||||||
|
var
|
||||||
|
clEven, clOdd: TColor;
|
||||||
|
isEven: Boolean;
|
||||||
|
begin
|
||||||
|
// Alternating row background. See issue #139
|
||||||
|
Result := clNone;
|
||||||
|
clEven := AppSettings.ReadInt(asRowBackgroundEven);
|
||||||
|
clOdd := AppSettings.ReadInt(asRowBackgroundOdd);
|
||||||
|
isEven := Node.Index mod 2 = 0;
|
||||||
|
if IsEven and (clEven <> clNone) then
|
||||||
|
Result := clEven
|
||||||
|
else if (not IsEven) and (clOdd <> clNone) then
|
||||||
|
Result := clOdd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TMainForm.PaintAlternatingRowBackground(TargetCanvas: TCanvas; Node: PVirtualNode; CellRect: TRect);
|
||||||
|
var
|
||||||
|
BgColor: TColor;
|
||||||
|
begin
|
||||||
|
// Apply color
|
||||||
|
BgColor := GetAlternatingRowBackground(Node);
|
||||||
|
if BgColor <> clNone then begin
|
||||||
|
TargetCanvas.Brush.Color := BgColor;
|
||||||
|
TargetCanvas.FillRect(CellRect);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.PaintColorBar(Value, Max: Extended; TargetCanvas: TCanvas; CellRect: TRect);
|
procedure TMainForm.PaintColorBar(Value, Max: Extended; TargetCanvas: TCanvas; CellRect: TRect);
|
||||||
var
|
var
|
||||||
BarWidth, CellWidth: Integer;
|
BarWidth, CellWidth: Integer;
|
||||||
@ -8929,6 +8966,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TMainForm.ListStatusBeforeCellPaint(Sender: TBaseVirtualTree;
|
||||||
|
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
|
||||||
|
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
|
||||||
|
begin
|
||||||
|
PaintAlternatingRowBackground(TargetCanvas, Node, CellRect);
|
||||||
|
end;
|
||||||
|
|
||||||
{***
|
{***
|
||||||
Apply a filter to a Virtual Tree.
|
Apply a filter to a Virtual Tree.
|
||||||
}
|
}
|
||||||
@ -9120,6 +9164,7 @@ var
|
|||||||
SessionVal, GlobalVal: String;
|
SessionVal, GlobalVal: String;
|
||||||
vt: TVirtualStringTree;
|
vt: TVirtualStringTree;
|
||||||
begin
|
begin
|
||||||
|
PaintAlternatingRowBackground(TargetCanvas, Node, CellRect);
|
||||||
// Highlight cell if session variable is different to global variable
|
// Highlight cell if session variable is different to global variable
|
||||||
vt := Sender as TVirtualStringTree;
|
vt := Sender as TVirtualStringTree;
|
||||||
if Column = 1 then begin
|
if Column = 1 then begin
|
||||||
@ -10937,9 +10982,9 @@ procedure TMainForm.AnyGridBeforeCellPaint(Sender: TBaseVirtualTree;
|
|||||||
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
|
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
|
||||||
var
|
var
|
||||||
r: TDBQuery;
|
r: TDBQuery;
|
||||||
cl, clNull, clEven, clOdd, clSameData: TColor;
|
cl, clNull, clSameData: TColor;
|
||||||
RowNumber: PInt64;
|
RowNumber: PInt64;
|
||||||
isEven, FocusedIsNull, CurrentIsNull: Boolean;
|
FocusedIsNull, CurrentIsNull: Boolean;
|
||||||
FieldText, FocusedFieldText: String;
|
FieldText, FocusedFieldText: String;
|
||||||
VT: TVirtualStringTree;
|
VT: TVirtualStringTree;
|
||||||
ResultCol: Integer;
|
ResultCol: Integer;
|
||||||
@ -10968,15 +11013,7 @@ begin
|
|||||||
RowNumber := Sender.GetNodeData(Node);
|
RowNumber := Sender.GetNodeData(Node);
|
||||||
r.RecNo := RowNumber^;
|
r.RecNo := RowNumber^;
|
||||||
|
|
||||||
clEven := AppSettings.ReadInt(asRowBackgroundEven);
|
cl := GetAlternatingRowBackground(Node);
|
||||||
clOdd := AppSettings.ReadInt(asRowBackgroundOdd);
|
|
||||||
isEven := Node.Index mod 2 = 0;
|
|
||||||
if IsEven and (clEven <> clNone) then
|
|
||||||
cl := clEven
|
|
||||||
else if (not IsEven) and (clOdd <> clNone) then
|
|
||||||
cl := clOdd
|
|
||||||
else
|
|
||||||
cl := clNone;
|
|
||||||
|
|
||||||
if (vsSelected in Node.States) and (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then begin
|
if (vsSelected in Node.States) and (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then begin
|
||||||
// Focused cell
|
// Focused cell
|
||||||
@ -11184,6 +11221,7 @@ var
|
|||||||
Val, Max: Extended;
|
Val, Max: Extended;
|
||||||
LoopNode: PVirtualNode;
|
LoopNode: PVirtualNode;
|
||||||
begin
|
begin
|
||||||
|
PaintAlternatingRowBackground(TargetCanvas, Node, CellRect);
|
||||||
// Display color bars
|
// Display color bars
|
||||||
if Column in [1,2,4..9] then begin
|
if Column in [1,2,4..9] then begin
|
||||||
vt := Sender as TVirtualStringTree;
|
vt := Sender as TVirtualStringTree;
|
||||||
@ -11541,6 +11579,7 @@ procedure TMainForm.HostListBeforeCellPaint(Sender: TBaseVirtualTree; TargetCanv
|
|||||||
var
|
var
|
||||||
vt: TVirtualStringTree;
|
vt: TVirtualStringTree;
|
||||||
begin
|
begin
|
||||||
|
PaintAlternatingRowBackground(TargetCanvas, Node, CellRect);
|
||||||
vt := Sender as TVirtualStringTree;
|
vt := Sender as TVirtualStringTree;
|
||||||
if (Column = 5) and (vt = ListProcesses) then
|
if (Column = 5) and (vt = ListProcesses) then
|
||||||
PaintColorBar(MakeFloat(vt.Text[Node, Column]), FProcessListMaxTime, TargetCanvas, CellRect);
|
PaintColorBar(MakeFloat(vt.Text[Node, Column]), FProcessListMaxTime, TargetCanvas, CellRect);
|
||||||
|
@ -1093,19 +1093,9 @@ procedure TfrmTableEditor.listColumnsBeforeCellPaint(Sender: TBaseVirtualTree;
|
|||||||
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
|
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
|
||||||
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
|
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
|
||||||
var
|
var
|
||||||
clEven, clOdd, BgColor: TColor;
|
BgColor: TColor;
|
||||||
isEven: Boolean;
|
|
||||||
begin
|
begin
|
||||||
BgColor := clNone;
|
BgColor := MainForm.GetAlternatingRowBackground(Node);
|
||||||
|
|
||||||
// Alternating row background. See issue #139
|
|
||||||
clEven := AppSettings.ReadInt(asRowBackgroundEven);
|
|
||||||
clOdd := AppSettings.ReadInt(asRowBackgroundOdd);
|
|
||||||
isEven := Node.Index mod 2 = 0;
|
|
||||||
if IsEven and (clEven <> clNone) then
|
|
||||||
BgColor := clEven
|
|
||||||
else if (not IsEven) and (clOdd <> clNone) then
|
|
||||||
BgColor := clOdd;
|
|
||||||
|
|
||||||
// Darken cell background to signalize it doesn't allow length/set
|
// Darken cell background to signalize it doesn't allow length/set
|
||||||
// Exclude non editable checkbox columns - grey looks ugly there.
|
// Exclude non editable checkbox columns - grey looks ugly there.
|
||||||
|
Reference in New Issue
Block a user