summaryrefslogtreecommitdiff
path: root/vcl/osx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-05-06 13:47:10 +0900
committerTomaž Vajngerl <quikee@gmail.com>2019-05-17 10:38:11 +0200
commit06b46104cc8b35e668e4b1a6d26a6a8e828fe373 (patch)
tree0b49498e4ceabdc2c56e994ec654e1717781831c /vcl/osx
parent27ac7f9bcfafde845dcd1979272b66301a75f53c (diff)
Wrap CGContext into a ContextHolder class
Change-Id: I3088e0b2f6c54f272fd29d7a6069e8231b207666 Reviewed-on: https://gerrit.libreoffice.org/72435 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/osx')
-rw-r--r--vcl/osx/salnativewidgets.cxx84
1 files changed, 42 insertions, 42 deletions
diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx
index 91c694bfcb45..575abc976f8c 100644
--- a/vcl/osx/salnativewidgets.cxx
+++ b/vcl/osx/salnativewidgets.cxx
@@ -303,7 +303,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
if( ! CheckContext() )
return false;
- CGContextSaveGState( mrContext );
+ CGContextSaveGState( maContextHolder.get() );
tools::Rectangle buttonRect = rControlRegion;
HIRect rc = ImplGetHIRectFromRectangle(buttonRect);
@@ -325,7 +325,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
if( nState & ControlState::FOCUSED )
aComboInfo.adornment |= kThemeAdornmentFocus;
- HIThemeDrawButton(&rc, &aComboInfo, mrContext, kHIThemeOrientationNormal,&rc);
+ HIThemeDrawButton(&rc, &aComboInfo, maContextHolder.get(), kHIThemeOrientationNormal,&rc);
bOK = true;
}
break;
@@ -337,14 +337,14 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
aMenuItemDrawInfo.version = 0;
aMenuItemDrawInfo.state = kThemeMenuActive;
aMenuItemDrawInfo.itemType = kThemeMenuItemHierBackground;
- HIThemeDrawMenuItem(&rc,&rc,&aMenuItemDrawInfo,mrContext,kHIThemeOrientationNormal,NULL);
+ HIThemeDrawMenuItem(&rc,&rc,&aMenuItemDrawInfo,maContextHolder.get(),kHIThemeOrientationNormal,NULL);
#else
if (rControlRegion.Top() == 0 && nPart == ControlPart::DrawBackgroundHorz)
{
const bool bDrawActive = mpFrame == nullptr || [mpFrame->getNSWindow() isKeyWindow];
CGFloat unifiedHeight = rControlRegion.GetHeight();
CGRect drawRect = CGRectMake(rControlRegion.Left(), rControlRegion.Top(), rControlRegion.GetWidth(), rControlRegion.GetHeight());
- CUIDraw([NSWindow coreUIRenderer], drawRect, mrContext,
+ CUIDraw([NSWindow coreUIRenderer], drawRect, maContextHolder.get(),
reinterpret_cast<CFDictionaryRef>([NSDictionary dictionaryWithObjectsAndKeys:
@"kCUIWidgetWindowFrame", @"widget",
@"regularwin", @"windowtype",
@@ -361,7 +361,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
aMenuItemDrawInfo.version = 0;
aMenuItemDrawInfo.state = kThemeMenuActive;
aMenuItemDrawInfo.itemType = kThemeMenuItemHierBackground;
- HIThemeDrawMenuItem(&rc, &rc, &aMenuItemDrawInfo, mrContext, kHIThemeOrientationNormal, nullptr);
+ HIThemeDrawMenuItem(&rc, &rc, &aMenuItemDrawInfo, maContextHolder.get(), kHIThemeOrientationNormal, nullptr);
}
#endif
bOK = true;
@@ -378,8 +378,8 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
rc.size.width += 2;
rc.size.height += 2;
- HIThemeApplyBackground( &rc, &aThemeBackgroundInfo, mrContext, kHIThemeOrientationNormal);
- CGContextFillRect( mrContext, rc );
+ HIThemeApplyBackground( &rc, &aThemeBackgroundInfo, maContextHolder.get(), kHIThemeOrientationNormal);
+ CGContextFillRect( maContextHolder.get(), rc );
bOK = true;
}
break;
@@ -393,8 +393,8 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
rc.size.width += 2;
rc.size.height += 2;
- HIThemeApplyBackground( &rc, &aThemeBackgroundInfo, mrContext, kHIThemeOrientationNormal);
- CGContextFillRect( mrContext, rc );
+ HIThemeApplyBackground( &rc, &aThemeBackgroundInfo, maContextHolder.get(), kHIThemeOrientationNormal);
+ CGContextFillRect( maContextHolder.get(), rc );
bOK = true;
}
break;
@@ -427,10 +427,10 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
}
// repaints the background of the pull down menu
- HIThemeDrawMenuBackground(&rc,&aMenuInfo,mrContext,kHIThemeOrientationNormal);
+ HIThemeDrawMenuBackground(&rc,&aMenuInfo,maContextHolder.get(),kHIThemeOrientationNormal);
// repaints the item either blue (selected) and/or Aqua grey (active only)
- HIThemeDrawMenuItem(&rc,&rc,&aMenuItemDrawInfo,mrContext,kHIThemeOrientationNormal,&rc);
+ HIThemeDrawMenuItem(&rc,&rc,&aMenuItemDrawInfo,maContextHolder.get(),kHIThemeOrientationNormal,&rc);
bOK = true;
}
@@ -450,7 +450,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
UniChar mark=( nPart == ControlPart::MenuItemCheckMark ) ? kCheckUnicode: kBulletUnicode;//0x2713;
CFStringRef cfString = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, &mark, 1, kCFAllocatorNull);
- HIThemeDrawTextBox(cfString, &rc, &aTextInfo, mrContext, kHIThemeOrientationNormal);
+ HIThemeDrawTextBox(cfString, &rc, &aTextInfo, maContextHolder.get(), kHIThemeOrientationNormal);
if (cfString)
CFRelease(cfString);
@@ -510,7 +510,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
if( nState & ControlState::FOCUSED )
aPushInfo.adornment |= kThemeAdornmentFocus;
- HIThemeDrawButton( &rc, &aPushInfo, mrContext, kHIThemeOrientationNormal, nullptr );
+ HIThemeDrawButton( &rc, &aPushInfo, maContextHolder.get(), kHIThemeOrientationNormal, nullptr );
bOK = true;
}
break;
@@ -541,7 +541,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
kThemeAdornmentNone;
if( nState & ControlState::FOCUSED )
aInfo.adornment |= kThemeAdornmentFocus;
- HIThemeDrawButton( &rc, &aInfo, mrContext, kHIThemeOrientationNormal, nullptr );
+ HIThemeDrawButton( &rc, &aInfo, maContextHolder.get(), kHIThemeOrientationNormal, nullptr );
bOK = true;
}
break;
@@ -558,19 +558,19 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
// grey equilateral triangle here ourselves.
// Perhaps some other HIThemeButtonDrawInfo setting would do the trick ?
- CGContextSetShouldAntialias( mrContext, true );
+ CGContextSetShouldAntialias( maContextHolder.get(), true );
CGFloat const aGrey[] = { 0.45, 0.45, 0.45, 1.0 };
- CGContextSetFillColor( mrContext, aGrey );
- CGContextBeginPath( mrContext );
+ CGContextSetFillColor( maContextHolder.get(), aGrey );
+ CGContextBeginPath( maContextHolder.get() );
float x = rc.origin.x + rc.size.width;
float y = rc.origin.y;
- CGContextMoveToPoint( mrContext, x, y );
+ CGContextMoveToPoint( maContextHolder.get(), x, y );
y += rc.size.height;
- CGContextAddLineToPoint( mrContext, x, y );
+ CGContextAddLineToPoint( maContextHolder.get(), x, y );
x -= rc.size.height * 0.866; // cos( 30 degree ) is approx. 0.866
y -= rc.size.height/2;
- CGContextAddLineToPoint( mrContext, x, y );
- CGContextDrawPath( mrContext, kCGPathEOFill );
+ CGContextAddLineToPoint( maContextHolder.get(), x, y );
+ CGContextDrawPath( maContextHolder.get(), kCGPathEOFill );
}
else
{
@@ -598,7 +598,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
break;
}
- HIThemeDrawButton( &rc, &aInfo, mrContext, kHIThemeOrientationNormal, nullptr );
+ HIThemeDrawButton( &rc, &aInfo, maContextHolder.get(), kHIThemeOrientationNormal, nullptr );
}
bOK = true;
}
@@ -628,7 +628,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
aTrackInfo.filler1 = 0;
aTrackInfo.trackInfo.progress.phase = static_cast<long long>(CFAbsoluteTimeGetCurrent()*10.0);
- HIThemeDrawTrack( &aTrackInfo, nullptr, mrContext, kHIThemeOrientationNormal );
+ HIThemeDrawTrack( &aTrackInfo, nullptr, maContextHolder.get(), kHIThemeOrientationNormal );
bOK = true;
}
break;
@@ -657,7 +657,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
aSlideInfo.pressState = 0;
aTrackDraw.trackInfo.slider = aSlideInfo;
- HIThemeDrawTrack( &aTrackDraw, nullptr, mrContext, kHIThemeOrientationNormal );
+ HIThemeDrawTrack( &aTrackDraw, nullptr, maContextHolder.get(), kHIThemeOrientationNormal );
bOK = true;
}
}
@@ -712,7 +712,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
aTrackDraw.trackInfo.scrollbar = aScrollInfo;
- HIThemeDrawTrack( &aTrackDraw, nullptr, mrContext, kHIThemeOrientationNormal );
+ HIThemeDrawTrack( &aTrackDraw, nullptr, maContextHolder.get(), kHIThemeOrientationNormal );
bOK = true;
}
}
@@ -734,7 +734,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
rc.size.height+=TAB_HEIGHT_NORMAL/2;
rc.size.width-=2;
- HIThemeDrawTabPane(&rc, &aTabPaneDrawInfo, mrContext, kHIThemeOrientationNormal);
+ HIThemeDrawTabPane(&rc, &aTabPaneDrawInfo, maContextHolder.get(), kHIThemeOrientationNormal);
bOK = true;
}
@@ -786,7 +786,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
rc.size.width+=2;//because VCL has 2 empty pixels between 2 tabs
rc.origin.x-=1;
- HIThemeDrawTab(&rc, &aTabItemDrawInfo, mrContext, kHIThemeOrientationNormal, &rc );
+ HIThemeDrawTab(&rc, &aTabItemDrawInfo, maContextHolder.get(), kHIThemeOrientationNormal, &rc );
bOK=true;
}
@@ -808,7 +808,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
if( nState & ControlState::FOCUSED )
aListInfo.adornment |= kThemeAdornmentFocus;
- HIThemeDrawButton(&rc, &aListInfo, mrContext, kHIThemeOrientationNormal,&rc);
+ HIThemeDrawButton(&rc, &aListInfo, maContextHolder.get(), kHIThemeOrientationNormal,&rc);
bOK = true;
break;
}
@@ -822,9 +822,9 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
rc.size.width+=1; // else there's a white space because a macOS theme has no 3D border
rc.size.height+=1;
- HIThemeDrawFrame(&rc, &aTextDrawInfo, mrContext, kHIThemeOrientationNormal);
+ HIThemeDrawFrame(&rc, &aTextDrawInfo, maContextHolder.get(), kHIThemeOrientationNormal);
- if(nState & ControlState::FOCUSED) HIThemeDrawFocusRect(&rc, true, mrContext, kHIThemeOrientationNormal);
+ if(nState & ControlState::FOCUSED) HIThemeDrawFocusRect(&rc, true, maContextHolder.get(), kHIThemeOrientationNormal);
bOK=true;
break;
@@ -849,12 +849,12 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
rc.size.height += 2;
//CGContextSetFillColorWithColor
- CGContextFillRect (mrContext, CGRectMake(rc.origin.x, rc.origin.y, rc.size.width, rc.size.height));
+ CGContextFillRect (maContextHolder.get(), CGRectMake(rc.origin.x, rc.origin.y, rc.size.width, rc.size.height));
//fill a white background, because drawFrame only draws the border
- HIThemeDrawFrame(&rc, &aTextDrawInfo, mrContext, kHIThemeOrientationNormal);
+ HIThemeDrawFrame(&rc, &aTextDrawInfo, maContextHolder.get(), kHIThemeOrientationNormal);
- if(nState & ControlState::FOCUSED) HIThemeDrawFocusRect(&rc, true, mrContext, kHIThemeOrientationNormal);
+ if(nState & ControlState::FOCUSED) HIThemeDrawFocusRect(&rc, true, maContextHolder.get(), kHIThemeOrientationNormal);
bOK=true;
}
@@ -878,12 +878,12 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
rc.origin.y += FOCUS_RING_WIDTH;
//CGContextSetFillColorWithColor
- CGContextFillRect (mrContext, CGRectMake(rc.origin.x, rc.origin.y, rc.size.width, rc.size.height));
+ CGContextFillRect (maContextHolder.get(), CGRectMake(rc.origin.x, rc.origin.y, rc.size.width, rc.size.height));
//fill a white background, because drawFrame only draws the border
- HIThemeDrawFrame(&rc, &aTextDrawInfo, mrContext, kHIThemeOrientationNormal);
+ HIThemeDrawFrame(&rc, &aTextDrawInfo, maContextHolder.get(), kHIThemeOrientationNormal);
- if(nState & ControlState::FOCUSED) HIThemeDrawFocusRect(&rc, true, mrContext, kHIThemeOrientationNormal);
+ if(nState & ControlState::FOCUSED) HIThemeDrawFocusRect(&rc, true, maContextHolder.get(), kHIThemeOrientationNormal);
//buttons:
const SpinbuttonValue* pSpinButtonVal = (aValue.getType() == ControlType::SpinButtons) ? static_cast<const SpinbuttonValue*>(&aValue) : nullptr;
@@ -934,7 +934,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
if( (nUpperState & ControlState::FOCUSED) || (nLowerState & ControlState::FOCUSED))
aSpinInfo.adornment |= kThemeAdornmentFocus;
- HIThemeDrawButton( &buttonRc, &aSpinInfo, mrContext, kHIThemeOrientationNormal, nullptr );
+ HIThemeDrawButton( &buttonRc, &aSpinInfo, maContextHolder.get(), kHIThemeOrientationNormal, nullptr );
}
bOK=true;
@@ -957,9 +957,9 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
CGMutablePathRef rPath = CGPathCreateMutable();
CGPathAddRect( rPath, nullptr, CGRectMake( 0, 0, mpFrame->maGeometry.nWidth-1, mpFrame->maGeometry.nHeight-1 ) );
- CGContextBeginPath( mrContext );
- CGContextAddPath( mrContext, rPath );
- CGContextClip( mrContext );
+ CGContextBeginPath( maContextHolder.get() );
+ CGContextAddPath( maContextHolder.get(), rPath );
+ CGContextClip( maContextHolder.get() );
CGPathRelease( rPath );
}
@@ -969,7 +969,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
aTextDrawInfo.state=kThemeStateActive;
aTextDrawInfo.isFocused=false;
- HIThemeDrawFrame(&rc, &aTextDrawInfo, mrContext, kHIThemeOrientationNormal);
+ HIThemeDrawFrame(&rc, &aTextDrawInfo, maContextHolder.get(), kHIThemeOrientationNormal);
bOK=true;
}
@@ -986,7 +986,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
default: break;
}
- CGContextRestoreGState( mrContext );
+ CGContextRestoreGState( maContextHolder.get() );
/* #i90291# in most cases invalidating the whole control region instead
of just the unclipped part of it is sufficient (and probably faster).