From ab585d53ed58b84fa8b300bddf8e1658b77a70e6 Mon Sep 17 00:00:00 2001 From: zeljko Date: Mon, 27 Feb 2017 17:32:56 +0000 Subject: [PATCH] Qt: implemented TQtWidgetSet.InitStockFont, but disabled because of problems with THintWindow.Font git-svn-id: trunk@54296 - --- lcl/interfaces/qt/qtwinapi.inc | 63 +++++++++++++++++++++++++++++++++ lcl/interfaces/qt/qtwinapih.inc | 1 + 2 files changed, 64 insertions(+) diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 0be170b6c5..d71162fdf8 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -4842,6 +4842,69 @@ begin CritSection:=TCriticalSection(ACritSec); end; +function TQtWidgetSet.InitStockFont(AFont: TObject; AStockFont: TStockFont + ): Boolean; +var + Font: TFont absolute AFont; + AMenu: QMenuH; + QtFont: QFontH; + AName: WideString; +begin + Result := False; + exit; // exit for now since there''s bug with THintWindow.Font + if AStockFont = sfMenu then + begin + AName := 'MenuTitle'; + AMenu := QMenu_create(@AName, nil); + try + QtFont := QWidget_font(AMenu); + QFont_family(QtFont, @AName); + Font.Name := UTF16ToUTF8(AName); + if QFont_pointSize(QtFont) > 0 then + Font.Size := QFont_pointSize(QtFont) + else + Font.Height := QFont_pixelSize(QtFont); + if QFont_bold(QtFont) then + Font.Style := Font.Style + [fsBold]; + if QFont_italic(QtFont) then + Font.Style := Font.Style + [fsItalic]; + if QFont_underline(QtFont) then + Font.Style := Font.Style + [fsUnderline]; + if QFont_strikeOut(QtFont) then + Font.Style := Font.Style + [fsStrikeOut]; + Result := True; + finally + QWidget_destroy(AMenu); + end; + end else + begin + QtFont := QFont_create; + try + if AStockFont = sfHint then + QToolTip_font(QtFont) + else + QApplication_font(QtFont); + QFont_family(QtFont, @AName); + Font.Name := UTF16ToUTF8(AName); + if QFont_pointSize(QtFont) > 0 then + Font.Size := QFont_pointSize(QtFont) + else + Font.Height := QFont_pixelSize(QtFont); + if QFont_bold(QtFont) then + Font.Style := Font.Style + [fsBold]; + if QFont_italic(QtFont) then + Font.Style := Font.Style + [fsItalic]; + if QFont_underline(QtFont) then + Font.Style := Font.Style + [fsUnderline]; + if QFont_strikeOut(QtFont) then + Font.Style := Font.Style + [fsStrikeOut]; + Result := True; + finally + QFont_destroy(QtFont); + end; + end; +end; + function TQtWidgetSet.IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer; var QtDC: TQtDeviceContext absolute dc; diff --git a/lcl/interfaces/qt/qtwinapih.inc b/lcl/interfaces/qt/qtwinapih.inc index 533940d426..e7ba320b43 100644 --- a/lcl/interfaces/qt/qtwinapih.inc +++ b/lcl/interfaces/qt/qtwinapih.inc @@ -142,6 +142,7 @@ function HideCaret(hWnd: HWND): Boolean; override; function InvalidateRect(aHandle : HWND; Rect : pRect; bErase : Boolean) : Boolean; override; function InvalidateRgn(aHandle: HWND; Rgn: HRGN; Erase: Boolean): Boolean; override; procedure InitializeCriticalSection(var CritSection: TCriticalSection); override; +function InitStockFont(AFont: TObject; AStockFont: TStockFont): Boolean; override; function IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer; override; function IsIconic(Handle: HWND): boolean; override; function IsWindow(handle: HWND): boolean; override;