From ebcf48e414c01ad5b735c26d9ec6d1b8c5dd25e4 Mon Sep 17 00:00:00 2001 From: jorendc Date: Tue, 4 Feb 2014 18:50:27 +0100 Subject: [PATCH] Proof of concept: native Mac OSX Toolbar, based on CoreUI Change-Id: I7774368a9b59e8087573348f6061b6a220fea130 --- vcl/Library_vcl.mk | 2 ++ vcl/osx/salnativewidgets.cxx | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 204a0d6..04fc6cc 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -81,6 +81,8 @@ $(eval $(call gb_Library_use_libraries,vcl,\ ifeq ($(OS),MACOSX) $(eval $(call gb_Library_add_libs,vcl,\ -framework IOKit \ + -F/System/Library/PrivateFrameworks \ + -framework CoreUI \ -lobjc \ )) endif diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx index 299e1f9..f0224fb 100644 --- a/vcl/osx/salnativewidgets.cxx +++ b/vcl/osx/salnativewidgets.cxx @@ -35,6 +35,16 @@ #define NSAppKitVersionNumber10_7 1138 #endif +extern "C" +{ + typedef CFTypeRef CUIRendererRef; + void CUIDraw(CUIRendererRef r, CGRect rect, CGContextRef ctx, CFDictionaryRef options, CFDictionaryRef* result); +} + +@interface NSWindow(CoreUIRendererPrivate) ++ (CUIRendererRef)coreUIRenderer; +@end + class AquaBlinker : public Timer { AquaSalFrame* mpFrame; @@ -524,11 +534,30 @@ sal_Bool AquaSalGraphics::drawNativeControl(ControlType nType, case CTRL_TOOLBAR: { - HIThemeMenuItemDrawInfo aMenuItemDrawInfo; - aMenuItemDrawInfo.version = 0; - aMenuItemDrawInfo.state = kThemeMenuActive; - aMenuItemDrawInfo.itemType = kThemeMenuItemHierBackground; - HIThemeDrawMenuItem(&rc,&rc,&aMenuItemDrawInfo,mrContext,kHIThemeOrientationNormal,NULL); + if (nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_DRAW_BACKGROUND_VERT) + { + BOOL isMain = [mpFrame->getNSWindow() isMainWindow]; + CGFloat unifiedHeight = rControlRegion.GetHeight(); + CGRect drawRect = CGRectMake(rControlRegion.Left(), rControlRegion.Top(), rControlRegion.GetWidth(), rControlRegion.GetHeight()); + CUIDraw([NSWindow coreUIRenderer], drawRect, mrContext, + (CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys: + @"kCUIWidgetWindowFrame", @"widget", + @"regularwin", @"windowtype", + (isMain ? @"normal" : @"inactive"), @"state", + [NSNumber numberWithDouble:unifiedHeight], @"kCUIWindowFrameUnifiedTitleBarHeightKey", + [NSNumber numberWithBool:YES], @"kCUIWindowFrameDrawTitleSeparatorKey", + [NSNumber numberWithBool:YES], @"is.flipped", + nil], + nil);; + } + else + { + HIThemeMenuItemDrawInfo aMenuItemDrawInfo; + aMenuItemDrawInfo.version = 0; + aMenuItemDrawInfo.state = kThemeMenuActive; + aMenuItemDrawInfo.itemType = kThemeMenuItemHierBackground; + HIThemeDrawMenuItem(&rc, &rc, &aMenuItemDrawInfo, mrContext, kHIThemeOrientationNormal, NULL); + } bOK = true; } break; -- 1.8.3.4 (Apple Git-47)