From f7b4d0c0b82f12e948d2c56df859243f1334a80c Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sat, 3 Feb 2018 22:47:29 +0100 Subject: [PATCH] Try the same workaround for invisible or black dropdown buttons on Wine as previously only for dropdown toolbuttons (becd4bdd0e3845f9ad7845fe7637460914878afa and 61202be058cc135f938a131207f47f9546efff26). Probably fixes issue #94. May also not fix it, as the toolbutton issue was not only on Wine. --- source/apphelpers.pas | 26 ++++++++++++++++++++++++-- source/connections.pas | 1 + source/copytable.pas | 1 + source/main.pas | 11 +---------- source/tabletools.pas | 1 + source/texteditor.pas | 5 +---- 6 files changed, 29 insertions(+), 16 deletions(-) diff --git a/source/apphelpers.pas b/source/apphelpers.pas index dcddb341..d74e4388 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -13,7 +13,7 @@ uses Windows, ShlObj, ActiveX, VirtualTrees, SynRegExpr, Messages, Math, Registry, DateUtils, Generics.Collections, StrUtils, AnsiStrings, TlHelp32, Types, dbconnection, mysql_structures, SynMemo, Menus, WinInet, gnugettext, Themes, - Character, ImgList, System.UITypes, ActnList, WinSock, IOUtils; + Character, ImgList, System.UITypes, ActnList, WinSock, IOUtils, StdCtrls, ComCtrls; type @@ -292,6 +292,7 @@ type function WideHexToBin(text: String): AnsiString; function BinToWideHex(bin: AnsiString): String; procedure FixVT(VT: TVirtualStringTree; MultiLineCount: Word=1); + procedure FixDropDownButtons(Form: TForm); function GetTextHeight(Font: TFont): Integer; function ColorAdjustBrightness(Col: TColor; Shift: SmallInt): TColor; function ComposeOrderClause(Cols: TOrderColArray): String; @@ -1446,13 +1447,34 @@ begin VT.ShowHint := True; VT.HintMode := hmToolTip; // Apply case insensitive incremental search event - if VT.IncrementalSearch <> isNone then + if VT.IncrementalSearch <> VirtualTrees.isNone then VT.OnIncrementalSearch := Mainform.AnyGridIncrementalSearch; VT.OnStartOperation := Mainform.AnyGridStartOperation; VT.OnEndOperation := Mainform.AnyGridEndOperation; end; +procedure FixDropDownButtons(Form: TForm); +var + i: Integer; + Comp: TComponent; +begin + // Work around broken dropdown (tool)button on Wine after translation: + // https://sourceforge.net/p/dxgettext/bugs/80/ + for i:=0 to Form.ComponentCount-1 do begin + Comp := Form.Components[i]; + if (Comp is TButton) and (TButton(Comp).Style = bsSplitButton) then begin + TButton(Comp).Style := bsPushButton; + TButton(Comp).Style := bsSplitButton; + end; + if (Comp is TToolButton) and (TToolButton(Comp).Style = tbsDropDown) then begin + TToolButton(Comp).Style := tbsButton; + TToolButton(Comp).Style := tbsDropDown; + end; + end; +end; + + function GetTextHeight(Font: TFont): Integer; var DC: HDC; diff --git a/source/connections.pas b/source/connections.pas index 8a992125..215031f6 100644 --- a/source/connections.pas +++ b/source/connections.pas @@ -224,6 +224,7 @@ begin // Fix GUI stuff TranslateComponent(Self); InheritFont(Font); + FixDropDownButtons(Self); Width := AppSettings.ReadInt(asSessionManagerWindowWidth); Height := AppSettings.ReadInt(asSessionManagerWindowHeight); diff --git a/source/copytable.pas b/source/copytable.pas index 28e70c39..c3349326 100644 --- a/source/copytable.pas +++ b/source/copytable.pas @@ -68,6 +68,7 @@ const procedure TCopyTableForm.FormCreate(Sender: TObject); begin TranslateComponent(Self); + FixDropDownButtons(Self); InheritFont(Font); Width := AppSettings.ReadInt(asCopyTableWindowWidth); Height := AppSettings.ReadInt(asCopyTableWindowHeight); diff --git a/source/main.pas b/source/main.pas index cac29407..94c0b874 100644 --- a/source/main.pas +++ b/source/main.pas @@ -1606,6 +1606,7 @@ begin // space left besides them. TP_GlobalIgnoreClass(TFont); TranslateComponent(Self); + FixDropDownButtons(Self); MainMenu1.Images := ImageListMain; // Translate menu items menuQueryHelpersGenerateSelect.Caption := f_('Generate %s ...', ['SELECT']); @@ -1613,16 +1614,6 @@ begin menuQueryHelpersGenerateUpdate.Caption := f_('Generate %s ...', ['UPDATE']); menuQueryHelpersGenerateDelete.Caption := f_('Generate %s ...', ['DELETE']); - // Fix drop down buttons on main toolbar. Same as r4304. - // Caused by missing Application.MainFormOnTaskBar - for i:=0 to ToolBarMainButtons.ButtonCount-1 do begin - ToolButton := ToolBarMainButtons.Buttons[i]; - if ToolButton.Style = tbsDropDown then begin - ToolButton.Style := tbsButton; - ToolButton.Style := tbsDropDown; - end; - end; - // Detect version dwInfoSize := GetFileVersionInfoSize(PChar(Application.ExeName), dwWnd); GetMem(ptrVerBuf, dwInfoSize); diff --git a/source/tabletools.pas b/source/tabletools.pas index 5908a4ea..2f6794d9 100644 --- a/source/tabletools.pas +++ b/source/tabletools.pas @@ -200,6 +200,7 @@ var Obj: TDBObject; begin TranslateComponent(Self); + FixDropDownButtons(Self); OUTPUT_FILE := _('Single .sql file'); OUTPUT_FILE_COMPRESSED := _('ZIP compressed .sql file'); OUTPUT_CLIPBOARD := _('Clipboard'); diff --git a/source/texteditor.pas b/source/texteditor.pas index 85453390..aff7e06a 100644 --- a/source/texteditor.pas +++ b/source/texteditor.pas @@ -160,10 +160,7 @@ begin actSearchReplace.Caption := MainForm.actQueryReplace.Caption; actSearchReplace.Hint := MainForm.actQueryReplace.Hint; TranslateComponent(Self); - // Work around broken dropdown toolbutton after translation: - // https://sourceforge.net/tracker/index.php?func=detail&aid=902470&group_id=74086&atid=539908 - btnLinebreaks.Style := tbsButton; - btnLinebreaks.Style := tbsDropDown; + FixDropDownButtons(Self); // Assign linebreak values to their menu item tags, to write less code later menuWindowsLB.Tag := Integer(lbsWindows); menuUnixLB.Tag := Integer(lbsUnix);