From 8563adf4b93064c25a673c0d3f55315c45c363b9 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Mon, 16 Feb 2015 10:59:19 +0000 Subject: [PATCH] cocoa: Initial code for rewriting treeview theme git-svn-id: trunk@47822 - --- lcl/interfaces/cocoa/cocoathemes.pas | 31 ++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoathemes.pas b/lcl/interfaces/cocoa/cocoathemes.pas index 135e3105d1..ef2a75d8c5 100644 --- a/lcl/interfaces/cocoa/cocoathemes.pas +++ b/lcl/interfaces/cocoa/cocoathemes.pas @@ -338,6 +338,7 @@ var LabelRect: HIRect; b: TCocoaBrush; lColor: NSColor; + lPoints: array of TPoint; begin case Details.Part of TVP_TREEITEM: @@ -356,6 +357,10 @@ begin end; TVP_GLYPH, TVP_HOTGLYPH: begin + // HIThemeDrawButton exists only in 32-bits and there is no Cocoa alternative =( + {$define CocoaUseHITheme} + {$ifdef CocoaUseHITheme} + {$ifdef CPU386} ButtonDrawInfo.version := 0; ButtonDrawInfo.State := GetDrawState(Details); ButtonDrawInfo.kind := kThemeDisclosureTriangle; @@ -370,12 +375,34 @@ begin LabelRect.origin.x := LabelRect.origin.x - 2; LabelRect.origin.y := LabelRect.origin.y - 1; - {$ifdef i386} HIThemeDrawButton(LabelRect, ButtonDrawInfo, DC.CGContext(), kHIThemeOrientationNormal, @LabelRect); - {$endif} Result := CGRectToRect(LabelRect); + {$endif} + {$else} + SetLength(lPoints, 3); + + // face right + if Details.State = GLPS_CLOSED then + begin + lPoints[0] := Types.Point(R.Left, R.Top); + lPoints[1] := Types.Point(R.Left, R.Bottom); + lPoints[2] := Types.Point(R.Right, (R.Top + R.Bottom) div 2); + end + // face down + else + begin + lPoints[0] := Types.Point(R.Left, R.Top); + lPoints[1] := Types.Point(R.Right, R.Top); + lPoints[2] := Types.Point((R.Left + R.Right) div 2, R.Bottom); + end; + + DC.Brush.SetColor(Graphics.RGBToColor(0, 0, 0), True); + DC.Polygon(lPoints, 3, False); + + Result := R; + {$endif} end; end; end;