Permalink
Browse files

Issue #8: convert system colors applied by code into their theme color

  • Loading branch information...
ansgarbecker committed Oct 27, 2018
1 parent 8f85cc0 commit 3759611c34810876922344d65f72a82cdcbe9a24
@@ -5,7 +5,7 @@ interface
implementation
uses
System.SysUtils, Winapi.Windows, Vcl.Forms, Vcl.Graphics, System.UITypes
System.SysUtils, Winapi.Windows, Vcl.Forms, Vcl.Graphics, System.UITypes, apphelpers
//
, DDetours
//
@@ -105,9 +105,9 @@ procedure HookedGetMetricSettings(const Self);
Screen.MessageFont.Handle := GetStockObject(SYSTEM_FONT);
Screen.CaptionFont.Handle := GetStockObject(SYSTEM_FONT);
end;
Screen.HintFont.Color := clInfoText;
Screen.MenuFont.Color := clMenuText;
Screen.MessageFont.Color := clWindowText;
Screen.HintFont.Color := GetThemeColor(clInfoText);
Screen.MenuFont.Color := GetThemeColor(clMenuText);
Screen.MessageFont.Color := GetThemeColor(clWindowText);
finally
if Assigned(Application) then Application.ShowHint := SaveShowHint;
end;
@@ -349,6 +349,7 @@ TAppSettings = class(TObject)
function GetUwpFullName: String;
function RunningAsUwp: Boolean;
procedure ScaleImageList(const ImgList: TImageList; ScaleFactor: Real);
function GetThemeColor(Color: TColor): TColor;
var
AppSettings: TAppSettings;
@@ -2975,6 +2976,13 @@ procedure ScaleImageList(const ImgList: TImageList; ScaleFactor: Real);
end;
function GetThemeColor(Color: TColor): TColor;
begin
Result := TStyleManager.ActiveStyle.GetSystemColor(Color);
end;
{ Threading stuff }
@@ -3389,7 +3397,7 @@ constructor TAppSettings.Create;
InitSetting(asDataFontSize, 'DataFontSize', 8);
InitSetting(asDataLocalNumberFormat, 'DataLocalNumberFormat', 0, True);
InitSetting(asHintsOnResultTabs, 'HintsOnResultTabs', 0, True);
InitSetting(asHightlightSameTextBackground, 'HightlightSameTextBackground', clInfoBk);
InitSetting(asHightlightSameTextBackground, 'HightlightSameTextBackground', GetThemeColor(clInfoBk));
InitSetting(asLogsqlnum, 'logsqlnum', 300);
InitSetting(asLogsqlwidth, 'logsqlwidth', 2000);
InitSetting(asSessionLogsDirectory, 'SessionLogsDirectory', 0, False, DirnameUserAppData + 'Sessionlogs\');
@@ -1248,7 +1248,7 @@ procedure Tconnform.editSSHPlinkExeChange(Sender: TObject);
if not FileExists(editSSHPlinkExe.Text) then
editSSHPlinkExe.Font.Color := clRed
else
editSSHPlinkExe.Font.Color := clWindowText;
editSSHPlinkExe.Font.Color := GetThemeColor(clWindowText);
Modification(Sender);
end;
@@ -210,10 +210,10 @@ procedure TCopyTableForm.TreeElementsChecked(Sender: TBaseVirtualTree; Node: PVi
btnRecentFilters.Enabled := MemoFilter.Enabled;
if MemoFilter.Enabled then begin
MemoFilter.Highlighter := MainForm.SynSQLSyn1;
MemoFilter.Color := clWindow;
MemoFilter.Color := GetThemeColor(clWindow);
end else begin
MemoFilter.Highlighter := nil;
MemoFilter.Color := clBtnFace;
MemoFilter.Color := GetThemeColor(clBtnFace);
end;
end;
end;
@@ -227,9 +227,9 @@ procedure TfrmExportGrid.ValidateControls(Sender: TObject);
editNull.RightButton.Enabled := lblNull.Enabled;
btnOK.Enabled := radioOutputCopyToClipboard.Checked or (radioOutputFile.Checked and (editFilename.Text <> ''));
if radioOutputFile.Checked then
editFilename.Font.Color := clWindowText
editFilename.Font.Color := GetThemeColor(clWindowText)
else
editFilename.Font.Color := clGrayText;
editFilename.Font.Color := GetThemeColor(clGrayText);
comboEncoding.Enabled := radioOutputFile.Checked;
lblEncoding.Enabled := radioOutputFile.Checked;
if ExportFormat = efExcel then
@@ -1140,7 +1140,7 @@ function TInplaceEditorLink.PrepareEdit(Tree: TBaseVirtualTree;
Exit;
FEdit.Font.Assign(FCellFont);
FEdit.Font.Color := clWindowText;
FEdit.Font.Color := GetThemeColor(clWindowText);
FPanel.Color := FCellBackground;
FEdit.Text := FCellText;
FEdit.Modified := False;
@@ -1176,7 +1176,7 @@ constructor TColumnDefaultEditorLink.Create(Tree: TVirtualStringTree);
FPanel.OnExit := DoEndEdit;
FPanel.Width := 200;
FPanel.ParentBackground := False;
FPanel.Color := clWindow;
FPanel.Color := GetThemeColor(clWindow);
FPanel.BevelKind := bkFlat;
FPanel.BevelOuter := bvNone;
FMainControl := FPanel;
@@ -1418,9 +1418,9 @@ function TColumnDefaultEditorLink.EndEdit: Boolean; stdcall;
procedure TColumnDefaultEditorLink.RadioClick(Sender: TObject);
begin
if not FRadioText.Checked then
FCustomEdit.Color := clBtnFace
FCustomEdit.Color := GetThemeColor(clBtnFace)
else begin
FCustomEdit.Color := clWindow;
FCustomEdit.Color := GetThemeColor(clWindow);
if FCustomEdit.CanFocus then
FCustomEdit.SetFocus;
end;
@@ -1492,8 +1492,8 @@ constructor TDataTypeEditorLink.Create(Tree: TVirtualStringTree);
FMemoHelp := TMemo.Create(FParentForm);
FMemoHelp.Hide;
FMemoHelp.Parent := FParentForm;
FMemoHelp.Color := clInfoBk;
FMemoHelp.Font.Color := clInfoText;
FMemoHelp.Color := GetThemeColor(clInfoBk);
FMemoHelp.Font.Color := GetThemeColor(clInfoText);
FMemoHelp.BorderStyle := bsNone;
FMemoHelp.BevelKind := bkFlat;
FMemoHelp.BevelInner := bvNone;
@@ -40,7 +40,7 @@ procedure TfrmLogin.FormCreate(Sender: TObject);
Caption := APPNAME + ' - Login';
MainForm.ImageListMain.GetBitmap(144, imgIcon.Picture.Bitmap);
lblPrompt.Font.Size := 10;
lblPrompt.Font.Color := clHotlight;
lblPrompt.Font.Color := GetThemeColor(clHotlight);
lblPrompt.Font.Style := lblPrompt.Font.Style + [fsBold];
editUsername.Text := '';
editPassword.Text := '';
@@ -7113,7 +7113,7 @@ procedure TMainForm.AnyGridAfterPaint(Sender: TBaseVirtualTree;
begin
h := (Sender as TVirtualStringTree).Header;
for i:=0 to h.Columns.Count-1 do begin
NewColor := clWindow;
NewColor := GetThemeColor(clWindow);
if h.SortColumn = i then
NewColor := ColorAdjustBrightness(NewColor, COLORSHIFT_SORTCOLUMNS);
h.Columns[i].Color := NewColor;
@@ -7434,11 +7434,11 @@ procedure TMainForm.ListProcessesFocusChanged(Sender: TBaseVirtualTree;
if enableSQLView then begin
SynMemoProcessView.Highlighter := SynSQLSyn1;
SynMemoProcessView.Text := ListProcesses.Text[Node, 7];
SynMemoProcessView.Color := clWindow;
SynMemoProcessView.Color := GetThemeColor(clWindow);
end else begin
SynMemoProcessView.Highlighter := nil;
SynMemoProcessView.Text := _('Please select a process in the above list.');
SynMemoProcessView.Color := clBtnFace;
SynMemoProcessView.Color := GetThemeColor(clBtnFace);
end;
lblExplainProcess.Enabled := enableSQLView and ActiveConnection.Parameters.IsMySQL;
menuExplainProcess.Enabled := lblExplainProcess.Enabled;
@@ -7656,7 +7656,7 @@ procedure TMainForm.ListVariablesPaintText(Sender: TBaseVirtualTree;
end;
if (tmp=-1) or (not MySQLVariables[tmp].IsDynamic) then begin
// Gray out whole row if the variable is either unknown or not editable
TargetCanvas.Font.Color := clGrayText
TargetCanvas.Font.Color := GetThemeColor(clGrayText)
end else if Column in [1, 2] then begin
SessionVal := vt.Text[Node, 1];
GlobalVal := vt.Text[Node, 2];
@@ -8697,7 +8697,7 @@ procedure TMainForm.AnyGridPaintText(Sender: TBaseVirtualTree; const TargetCanva
// Do not apply any color on a selected, highlighted cell to keep readability
if (vsSelected in Node.States) and (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then
cl := clHighlightText
cl := GetThemeColor(clHighlightText)
else if vsSelected in Node.States then
cl := clBlack
else if r.IsNull(Column) then
@@ -9242,7 +9242,7 @@ procedure TMainForm.AnyGridBeforeCellPaint(Sender: TBaseVirtualTree;
cl := clNone;
if (vsSelected in Node.States) and (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then
cl := clHighlight
cl := GetThemeColor(clHighlight)
else if vsSelected in Node.States then
cl := $00DDDDDD
else if r.IsNull(Column) then begin
@@ -10924,9 +10924,9 @@ procedure TMainForm.UpdateFilterPanel(Sender: TObject);
editFilterVT.Enabled := pnlFilterVT.Enabled;
lblFilterVTInfo.Enabled := pnlFilterVT.Enabled;
if pnlFilterVT.Enabled then
editFilterVT.Color := clWindow
editFilterVT.Color := GetThemeColor(clWindow)
else
editFilterVT.Color := clBtnFace;
editFilterVT.Color := GetThemeColor(clBtnFace);
tab := PageControlMain.ActivePage;
if tab = tabHost then
@@ -11615,7 +11615,7 @@ procedure TMainForm.treeQueryHelpersPaintText(Sender: TBaseVirtualTree; const Ta
if Tab <> nil then begin
History := Tab.HistoryDays.Objects[Node.Parent.Index] as TQueryHistory;
if ActiveConnection.Database <> History[Node.Index].Database then
TargetCanvas.Font.Color := clGrayText;
TargetCanvas.Font.Color := GetThemeColor(clGrayText);
end;
end;
@@ -11627,7 +11627,7 @@ procedure TMainForm.treeQueryHelpersPaintText(Sender: TBaseVirtualTree; const Ta
if StrLen(PChar(Tab.ListBindParams.Items[Node.Index].Value)) = 0 then
TargetCanvas.Font.Style := [fsItalic]+[fsUnderline];
TargetCanvas.Font.Color := clGrayText;
TargetCanvas.Font.Color := GetThemeColor(clGrayText);
end;
@@ -333,7 +333,7 @@ procedure TfrmRoutineEditor.listParametersPaintText(Sender: TBaseVirtualTree;
TextType: TVSTTextType);
begin
if (Column = 3) and (comboType.ItemIndex = 1) then
TargetCanvas.Font.Color := clBtnShadow;
TargetCanvas.Font.Color := GetThemeColor(clBtnShadow);
end;
@@ -82,12 +82,12 @@ procedure TfrmSelectDBObject.ValidateControls(Sender: TObject);
begin
// Signalize if tree or edit box is used
if editDb.Modified then begin
TreeDBO.Color := clBtnFace;
editDb.Color := clWindow;
TreeDBO.Color := GetThemeColor(clBtnFace);
editDb.Color := GetThemeColor(clWindow);
btnOK.Enabled := editDb.GetTextLen > 0;
end else begin
TreeDBO.Color := clWindow;
editDb.Color := clBtnFace;
TreeDBO.Color := GetThemeColor(clWindow);
editDb.Color := GetThemeColor(clBtnFace);
btnOK.Enabled := Assigned(TreeDBO.FocusedNode);
end;
end;
@@ -909,7 +909,7 @@ procedure TfrmTableEditor.listColumnsBeforeCellPaint(Sender: TBaseVirtualTree;
// Darken cell background to signalize it doesn't allow length/set
// Exclude non editable checkbox columns - grey looks ugly there.
if (not CellEditingAllowed(Node, Column)) and (not (Column in [4, 5, 6])) then begin
TargetCanvas.Brush.Color := clBtnFace;
TargetCanvas.Brush.Color := GetThemeColor(clBtnFace);
TargetCanvas.FillRect(CellRect);
end;
end;
@@ -1090,7 +1090,7 @@ procedure TfrmTableTools.ResultGridPaintText(Sender: TBaseVirtualTree; const Tar
else if LowerCase(Msg) = 'error' then
TargetCanvas.Font.Color := clRed
else if Pos(STRSKIPPED, Msg) > 0 then
TargetCanvas.Font.Color := clGrayText;
TargetCanvas.Font.Color := GetThemeColor(clGrayText);
end;
end;
@@ -149,9 +149,9 @@ procedure TfrmUpdateCheck.ReadCheckFile;
btnRelease.Enabled := groupRelease.Enabled;
memoRelease.Enabled := groupRelease.Enabled;
if not memoRelease.Enabled then
memoRelease.Font.Color := cl3DDkShadow
memoRelease.Font.Color := GetThemeColor(cl3DDkShadow)
else
memoRelease.Font.Color := clWindowText;
memoRelease.Font.Color := GetThemeColor(clWindowText);
end;
// Read [Build] section of check file

0 comments on commit 3759611

Please sign in to comment.