From 7d97f14c33bae354407a24e2116a09f5e26edff8 Mon Sep 17 00:00:00 2001 From: paul Date: Sat, 25 Apr 2009 14:40:54 +0000 Subject: [PATCH] lcl: THintWindow drawing: - remove TThemeServices.DrawTooltip, move content to DrawElement for teTooltip - call standard ThemeServices.DrawElement in THintWindow.Paint (now tooltips looks native on windows xp, vista, gtk, gtk2) git-svn-id: trunk@19619 - --- lcl/include/hintwindow.inc | 6 ++++- lcl/interfaces/win32/win32themes.pas | 38 ++++++++++------------------ lcl/themes.pas | 19 ++++++-------- 3 files changed, 27 insertions(+), 36 deletions(-) diff --git a/lcl/include/hintwindow.inc b/lcl/include/hintwindow.inc index bdd331dd63..c57a7c83f5 100644 --- a/lcl/include/hintwindow.inc +++ b/lcl/include/hintwindow.inc @@ -97,10 +97,14 @@ end; procedure THintWindow.Paint; var ARect: TRect; + Details: TThemedElementDetails; begin ARect := ClientRect; if Color = clInfoBk then // draw using themes - ThemeServices.DrawTooltip(Canvas.Handle, ARect) + begin + Details := ThemeServices.GetElementDetails(tttStandardLink); + ThemeServices.DrawElement(Canvas.Handle, Details, ARect); + end else begin Canvas.Brush.Color := Color; diff --git a/lcl/interfaces/win32/win32themes.pas b/lcl/interfaces/win32/win32themes.pas index 939e8e4cd1..25105ee80e 100644 --- a/lcl/interfaces/win32/win32themes.pas +++ b/lcl/interfaces/win32/win32themes.pas @@ -49,7 +49,6 @@ type const S: String; R: TRect; Flags, Flags2: Cardinal); override; procedure DrawText(ACanvas: TPersistent; Details: TThemedElementDetails; const S: String; R: TRect; Flags, Flags2: Cardinal); override; - procedure DrawTooltip(DC: HDC; ARect: TRect); override; function ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; override; function HasTransparentParts(Details: TThemedElementDetails): Boolean; override; @@ -182,10 +181,23 @@ begin end; procedure TWin32ThemeServices.DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect = nil); +var + ARect: TRect; + Brush: HBrush; begin if ThemesEnabled then + begin with Details do - DrawThemeBackground(Theme[Element], DC, Part, State, R, ClipRect) + DrawThemeBackground(Theme[Element], DC, Part, State, R, ClipRect); + if (Details.Element = teToolTip) and (Details.Part = TTP_STANDARD) and (WindowsVersion < wvVista) then + begin + // use native background on windows vista + ARect := ContentRect(DC, Details, R); + Brush := CreateSolidBrush(ColorToRGB(clInfoBk)); + FillRect(DC, ARect, Brush); + DeleteObject(Brush); + end; + end else inherited; end; @@ -318,26 +330,4 @@ begin inherited; end; -procedure TWin32ThemeServices.DrawTooltip(DC: HDC; ARect: TRect); -var - Details: TThemedElementDetails; - Brush: HBrush; -begin - if ThemesEnabled then - begin - Details := GetElementDetails(tttStandardNormal); - DrawElement(DC, Details, ARect); - if WindowsVersion < wvVista then - begin - // use native background on windows vista - ARect := ContentRect(DC, Details, ARect); - Brush := CreateSolidBrush(ColorToRGB(clInfoBk)); - FillRect(DC, ARect, Brush); - DeleteObject(Brush); - end; - end - else - inherited DrawTooltip(DC, ARect); -end; - end. diff --git a/lcl/themes.pas b/lcl/themes.pas index 396eee826d..6198134220 100644 --- a/lcl/themes.pas +++ b/lcl/themes.pas @@ -467,7 +467,6 @@ type Bounds: PRect = nil); procedure DrawText(DC: HDC; Details: TThemedElementDetails; const S: String; R: TRect; Flags, Flags2: Cardinal); virtual; overload; procedure DrawText(ACanvas: TPersistent; Details: TThemedElementDetails; const S: String; R: TRect; Flags, Flags2: Cardinal); virtual; overload; - procedure DrawTooltip(DC: HDC; ARect: TRect); virtual; function HasTransparentParts(Details: TThemedElementDetails): Boolean; virtual; procedure PaintBorder(Control: TObject; EraseLRCorner: Boolean); virtual; @@ -2021,6 +2020,14 @@ begin end; end; end; + teToolTip: + begin + if Details.Part = TTP_STANDARD then + begin + FillWithColor(ARect, clInfoBk); + LCLIntf.DrawEdge(DC, ARect, BDR_RAISEDOUTER, BF_RECT); + end; + end; end; end; @@ -2211,16 +2218,6 @@ begin Canvas.Font.Color := OldColor; end; -procedure TThemeServices.DrawTooltip(DC: HDC; ARect: TRect); -var - Brush: HBrush; -begin - Brush := CreateSolidBrush(ColorToRGB(clInfoBk)); - FillRect(DC, ARect, Brush); - DeleteObject(Brush); - LCLIntf.DrawEdge(DC, ARect, BDR_RAISEDOUTER, BF_RECT or BF_ADJUST); -end; - //---------------------------------------------------------------------------------------------------------------------- function TThemeServices.HasTransparentParts(Details: TThemedElementDetails): Boolean;