Update Mac OS X cocoa frontend to build using SDK 10.10
This commit is contained in:
parent
df2d62a872
commit
405965d871
243
cocoa/ArrowBox.m
243
cocoa/ArrowBox.m
|
@ -1,15 +1,28 @@
|
|||
/* Copyright (c) 1011 Sven Weidauer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
|
||||
/* Copyright 2011 Sven Weidauer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#import "ArrowBox.h"
|
||||
|
||||
|
||||
@implementation ArrowBox
|
||||
|
||||
@synthesize arrowPosition;
|
||||
|
@ -17,128 +30,134 @@
|
|||
@synthesize arrowEdge;
|
||||
@synthesize cornerRadius;
|
||||
|
||||
- (void) setArrowEdge: (ArrowEdge)newEdge;
|
||||
- (void) setArrowEdge: (ArrowEdge)newEdge
|
||||
{
|
||||
if (arrowEdge == newEdge) return;
|
||||
|
||||
arrowEdge = newEdge;
|
||||
|
||||
[self setNeedsDisplay: YES];
|
||||
updateShadow = YES;
|
||||
if (arrowEdge == newEdge) {
|
||||
return;
|
||||
}
|
||||
|
||||
arrowEdge = newEdge;
|
||||
|
||||
[self setNeedsDisplay: YES];
|
||||
updateShadow = YES;
|
||||
}
|
||||
|
||||
- (void) setArrowSize: (CGFloat)newSize;
|
||||
|
||||
- (void) setArrowSize: (CGFloat)newSize
|
||||
{
|
||||
arrowSize = newSize;
|
||||
[self setNeedsDisplay: YES];
|
||||
updateShadow = YES;
|
||||
arrowSize = newSize;
|
||||
[self setNeedsDisplay: YES];
|
||||
updateShadow = YES;
|
||||
}
|
||||
|
||||
- (void) setCornerRadius: (CGFloat)newRadius;
|
||||
|
||||
- (void) setCornerRadius: (CGFloat)newRadius
|
||||
{
|
||||
cornerRadius = newRadius;
|
||||
[self setNeedsDisplay: YES];
|
||||
updateShadow = YES;
|
||||
cornerRadius = newRadius;
|
||||
[self setNeedsDisplay: YES];
|
||||
updateShadow = YES;
|
||||
}
|
||||
|
||||
- (void) setArrowPosition: (CGFloat)newPosition;
|
||||
- (void) setArrowPosition: (CGFloat)newPosition
|
||||
{
|
||||
arrowPosition = newPosition;
|
||||
|
||||
[self setNeedsDisplay: YES];
|
||||
updateShadow = YES;
|
||||
arrowPosition = newPosition;
|
||||
|
||||
[self setNeedsDisplay: YES];
|
||||
updateShadow = YES;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
arrowPosition = 50;
|
||||
cornerRadius = 10;
|
||||
arrowSize = 15;
|
||||
}
|
||||
return self;
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
arrowPosition = 50;
|
||||
cornerRadius = 10;
|
||||
arrowSize = 15;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)dirtyRect
|
||||
- (void)drawRect:(NSRect)dirtyRect
|
||||
{
|
||||
[[NSColor clearColor] set];
|
||||
[NSBezierPath fillRect: dirtyRect];
|
||||
|
||||
NSBezierPath *path = [NSBezierPath bezierPath];
|
||||
|
||||
NSRect bounds = [self convertRectToBase: NSInsetRect( [self bounds], 2, 2 )];
|
||||
bounds.origin.x = floor( bounds.origin.x );
|
||||
bounds.origin.y = floor( bounds.origin.y );
|
||||
bounds.size.width = floor( bounds.size.width );
|
||||
bounds.size.height = floor( bounds.size.height );
|
||||
bounds = [self convertRectFromBase: bounds];
|
||||
|
||||
const CGFloat right = bounds.size.width - arrowSize;
|
||||
const CGFloat top = bounds.size.height - arrowSize;
|
||||
const CGFloat left = arrowSize;
|
||||
const CGFloat bottom = arrowSize;
|
||||
|
||||
[path setLineJoinStyle:NSRoundLineJoinStyle];
|
||||
[[NSColor clearColor] set];
|
||||
[NSBezierPath fillRect: dirtyRect];
|
||||
|
||||
[path moveToPoint: NSMakePoint( right - cornerRadius, top )];
|
||||
NSBezierPath *path = [NSBezierPath bezierPath];
|
||||
|
||||
if (arrowEdge == ArrowTopEdge) {
|
||||
[path lineToPoint: NSMakePoint( arrowPosition + arrowSize, top )];
|
||||
[path lineToPoint: NSMakePoint( arrowPosition, top + arrowSize )];
|
||||
[path lineToPoint: NSMakePoint( arrowPosition - arrowSize, top )];
|
||||
}
|
||||
|
||||
[path appendBezierPathWithArcFromPoint: NSMakePoint( left, top )
|
||||
toPoint: NSMakePoint( left, top - cornerRadius )
|
||||
radius: cornerRadius];
|
||||
|
||||
if (arrowEdge == ArrowLeftEdge) {
|
||||
[path lineToPoint: NSMakePoint( left, bottom + arrowPosition + arrowSize )];
|
||||
[path lineToPoint: NSMakePoint( left - arrowSize, bottom + arrowPosition )];
|
||||
[path lineToPoint: NSMakePoint( left, bottom + arrowPosition - arrowSize )];
|
||||
}
|
||||
|
||||
[path appendBezierPathWithArcFromPoint: NSMakePoint( left, bottom )
|
||||
toPoint: NSMakePoint( left + cornerRadius, bottom )
|
||||
radius: cornerRadius];
|
||||
|
||||
if (arrowEdge == ArrowBottomEdge) {
|
||||
[path lineToPoint: NSMakePoint( arrowPosition - arrowSize, bottom )];
|
||||
[path lineToPoint: NSMakePoint( arrowPosition, bottom - arrowSize )];
|
||||
[path lineToPoint: NSMakePoint( arrowPosition + arrowSize, bottom )];
|
||||
}
|
||||
|
||||
[path appendBezierPathWithArcFromPoint: NSMakePoint( right, bottom )
|
||||
toPoint: NSMakePoint( right, bottom + cornerRadius )
|
||||
radius: cornerRadius];
|
||||
NSRect bounds = [self convertRectToBase: NSInsetRect( [self bounds], 2, 2 )];
|
||||
bounds.origin.x = floor( bounds.origin.x );
|
||||
bounds.origin.y = floor( bounds.origin.y );
|
||||
bounds.size.width = floor( bounds.size.width );
|
||||
bounds.size.height = floor( bounds.size.height );
|
||||
bounds = [self convertRectFromBase: bounds];
|
||||
|
||||
if (arrowEdge == ArrowRightEdge) {
|
||||
[path lineToPoint: NSMakePoint( right, bottom + arrowPosition - arrowSize )];
|
||||
[path lineToPoint: NSMakePoint( right + arrowSize, bottom + arrowPosition )];
|
||||
[path lineToPoint: NSMakePoint( right, bottom + arrowPosition + arrowSize )];
|
||||
}
|
||||
|
||||
[path appendBezierPathWithArcFromPoint: NSMakePoint( right, top )
|
||||
toPoint: NSMakePoint( right - cornerRadius, top )
|
||||
radius: cornerRadius];
|
||||
[path closePath];
|
||||
|
||||
[[NSColor colorWithDeviceWhite: 1.0 alpha: 0.4] set];
|
||||
[[NSColor colorWithDeviceWhite: 0.0 alpha: 0.75] setFill];
|
||||
const CGFloat right = bounds.size.width - arrowSize;
|
||||
const CGFloat top = bounds.size.height - arrowSize;
|
||||
const CGFloat left = arrowSize;
|
||||
const CGFloat bottom = arrowSize;
|
||||
|
||||
NSAffineTransform *transform = [NSAffineTransform transform];
|
||||
[transform translateXBy: bounds.origin.x yBy: bounds.origin.y];
|
||||
[transform concat];
|
||||
|
||||
[path setLineWidth: 2.0];
|
||||
[path fill];
|
||||
[path stroke];
|
||||
|
||||
if (updateShadow) {
|
||||
[[self window] invalidateShadow];
|
||||
[[self window] update];
|
||||
updateShadow = NO;
|
||||
}
|
||||
[path setLineJoinStyle:NSRoundLineJoinStyle];
|
||||
|
||||
[path moveToPoint: NSMakePoint( right - cornerRadius, top )];
|
||||
|
||||
if (arrowEdge == ArrowTopEdge) {
|
||||
[path lineToPoint: NSMakePoint( arrowPosition + arrowSize, top )];
|
||||
[path lineToPoint: NSMakePoint( arrowPosition, top + arrowSize )];
|
||||
[path lineToPoint: NSMakePoint( arrowPosition - arrowSize, top )];
|
||||
}
|
||||
|
||||
[path appendBezierPathWithArcFromPoint: NSMakePoint( left, top )
|
||||
toPoint: NSMakePoint( left, top - cornerRadius )
|
||||
radius: cornerRadius];
|
||||
|
||||
if (arrowEdge == ArrowLeftEdge) {
|
||||
[path lineToPoint: NSMakePoint( left, bottom + arrowPosition + arrowSize )];
|
||||
[path lineToPoint: NSMakePoint( left - arrowSize, bottom + arrowPosition )];
|
||||
[path lineToPoint: NSMakePoint( left, bottom + arrowPosition - arrowSize )];
|
||||
}
|
||||
|
||||
[path appendBezierPathWithArcFromPoint: NSMakePoint( left, bottom )
|
||||
toPoint: NSMakePoint( left + cornerRadius, bottom )
|
||||
radius: cornerRadius];
|
||||
|
||||
if (arrowEdge == ArrowBottomEdge) {
|
||||
[path lineToPoint: NSMakePoint( arrowPosition - arrowSize, bottom )];
|
||||
[path lineToPoint: NSMakePoint( arrowPosition, bottom - arrowSize )];
|
||||
[path lineToPoint: NSMakePoint( arrowPosition + arrowSize, bottom )];
|
||||
}
|
||||
|
||||
[path appendBezierPathWithArcFromPoint: NSMakePoint( right, bottom )
|
||||
toPoint: NSMakePoint( right, bottom + cornerRadius )
|
||||
radius: cornerRadius];
|
||||
|
||||
if (arrowEdge == ArrowRightEdge) {
|
||||
[path lineToPoint: NSMakePoint( right, bottom + arrowPosition - arrowSize )];
|
||||
[path lineToPoint: NSMakePoint( right + arrowSize, bottom + arrowPosition )];
|
||||
[path lineToPoint: NSMakePoint( right, bottom + arrowPosition + arrowSize )];
|
||||
}
|
||||
|
||||
[path appendBezierPathWithArcFromPoint: NSMakePoint( right, top )
|
||||
toPoint: NSMakePoint( right - cornerRadius, top )
|
||||
radius: cornerRadius];
|
||||
[path closePath];
|
||||
|
||||
[[NSColor colorWithDeviceWhite: 1.0 alpha: 0.4] set];
|
||||
[[NSColor colorWithDeviceWhite: 0.0 alpha: 0.75] setFill];
|
||||
|
||||
NSAffineTransform *transform = [NSAffineTransform transform];
|
||||
[transform translateXBy: bounds.origin.x yBy: bounds.origin.y];
|
||||
[transform concat];
|
||||
|
||||
[path setLineWidth: 2.0];
|
||||
[path fill];
|
||||
[path stroke];
|
||||
|
||||
if (updateShadow) {
|
||||
[[self window] invalidateShadow];
|
||||
[[self window] update];
|
||||
updateShadow = NO;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,10 +1,25 @@
|
|||
/* Copyright (c) 1011 Sven Weidauer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/* Copyright 2011 Sven Weidauer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#import "ArrowWindow.h"
|
||||
#import "ArrowBox.h"
|
||||
|
@ -15,201 +30,208 @@
|
|||
|
||||
- (id) initWithContentRect: (NSRect)contentRect styleMask: (NSUInteger)aStyle backing: (NSBackingStoreType)bufferingType defer: (BOOL)flag
|
||||
{
|
||||
if ((self = [super initWithContentRect: contentRect styleMask: NSBorderlessWindowMask backing: bufferingType defer: flag]) == nil) return nil;
|
||||
|
||||
[self setBackgroundColor: [NSColor clearColor]];
|
||||
[self setOpaque: NO];
|
||||
[self setHasShadow: YES];
|
||||
|
||||
return self;
|
||||
if ((self = [super initWithContentRect: contentRect styleMask: NSBorderlessWindowMask backing: bufferingType defer: flag]) == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
[self setBackgroundColor: [NSColor clearColor]];
|
||||
[self setOpaque: NO];
|
||||
[self setHasShadow: YES];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) setContentView: (NSView *)aView;
|
||||
- (void) setContentView: (NSView *)aView
|
||||
{
|
||||
if (aView == content) return;
|
||||
if (aView == content) return;
|
||||
|
||||
[content removeFromSuperview];
|
||||
content = aView;
|
||||
|
||||
if (content == nil) return;
|
||||
|
||||
if (box == nil) {
|
||||
box = [[ArrowBox alloc] initWithFrame: NSZeroRect];
|
||||
[box setArrowEdge: ArrowTopEdge];
|
||||
[super setContentView: box];
|
||||
[box release];
|
||||
}
|
||||
|
||||
[box addSubview: content];
|
||||
[content removeFromSuperview];
|
||||
content = aView;
|
||||
|
||||
NSRect frame = [self contentRectForFrameRect: [self frame]];
|
||||
frame.origin = [self convertScreenToBase: frame.origin];
|
||||
frame = [box convertRect: frame fromView: nil];
|
||||
|
||||
[content setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
|
||||
[content setFrame: frame];
|
||||
if (content == nil) return;
|
||||
|
||||
if (box == nil) {
|
||||
box = [[ArrowBox alloc] initWithFrame: NSZeroRect];
|
||||
[box setArrowEdge: ArrowTopEdge];
|
||||
[super setContentView: box];
|
||||
[box release];
|
||||
}
|
||||
|
||||
[box addSubview: content];
|
||||
|
||||
NSRect frame = [self contentRectForFrameRect: [self frame]];
|
||||
frame.origin = [self convertScreenToBase: frame.origin];
|
||||
frame = [box convertRect: frame fromView: nil];
|
||||
|
||||
[content setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
|
||||
[content setFrame: frame];
|
||||
}
|
||||
|
||||
- (void) setContentSize: (NSSize)aSize;
|
||||
- (void) setContentSize: (NSSize)aSize
|
||||
{
|
||||
NSRect frame = [content frame];
|
||||
frame.size = aSize;
|
||||
|
||||
frame = [box convertRect: frame toView: nil];
|
||||
frame.origin = [self convertBaseToScreen: frame.origin];
|
||||
frame = [self frameRectForContentRect: frame];
|
||||
|
||||
[self setFrame: frame display: YES];
|
||||
NSRect frame = [content frame];
|
||||
frame.size = aSize;
|
||||
|
||||
frame = [box convertRect: frame toView: nil];
|
||||
frame.origin = [self convertBaseToScreen: frame.origin];
|
||||
frame = [self frameRectForContentRect: frame];
|
||||
|
||||
[self setFrame: frame display: YES];
|
||||
}
|
||||
|
||||
static const CGFloat padding = 0;
|
||||
|
||||
- (NSRect) contentRectForFrameRect: (NSRect)frameRect;
|
||||
- (NSRect) contentRectForFrameRect: (NSRect)frameRect
|
||||
{
|
||||
const CGFloat arrowSize = [box arrowSize];
|
||||
const CGFloat offset = 2 * (padding + arrowSize );
|
||||
const CGFloat arrowSize = [box arrowSize];
|
||||
const CGFloat offset = 2 * (padding + arrowSize );
|
||||
|
||||
return NSInsetRect( frameRect, offset, offset );
|
||||
return NSInsetRect( frameRect, offset, offset );
|
||||
}
|
||||
|
||||
- (NSRect) frameRectForContentRect: (NSRect)contentRect;
|
||||
- (NSRect) frameRectForContentRect: (NSRect)contentRect
|
||||
{
|
||||
const CGFloat arrowSize = [box arrowSize];
|
||||
const CGFloat offset = -2 * (padding + arrowSize );
|
||||
|
||||
return NSInsetRect( contentRect, offset, offset );
|
||||
const CGFloat arrowSize = [box arrowSize];
|
||||
const CGFloat offset = -2 * (padding + arrowSize );
|
||||
|
||||
return NSInsetRect( contentRect, offset, offset );
|
||||
}
|
||||
|
||||
+ (NSRect) frameRectForContentRect: (NSRect)cRect styleMask: (NSUInteger)aStyle;
|
||||
+ (NSRect) frameRectForContentRect: (NSRect)cRect styleMask: (NSUInteger)aStyle
|
||||
{
|
||||
const CGFloat DefaultArrowSize = 15;
|
||||
const CGFloat offset = -2 * (padding + DefaultArrowSize);
|
||||
|
||||
return NSInsetRect( cRect, offset, offset );
|
||||
const CGFloat DefaultArrowSize = 15;
|
||||
const CGFloat offset = -2 * (padding + DefaultArrowSize);
|
||||
|
||||
return NSInsetRect( cRect, offset, offset );
|
||||
}
|
||||
|
||||
- (BOOL) canBecomeKeyWindow;
|
||||
- (BOOL) canBecomeKeyWindow
|
||||
{
|
||||
return acceptsKey;
|
||||
return acceptsKey;
|
||||
}
|
||||
|
||||
- (void) moveToPoint: (NSPoint) screenPoint;
|
||||
- (void) moveToPoint: (NSPoint) screenPoint
|
||||
{
|
||||
switch ([box arrowEdge]) {
|
||||
case ArrowNone:
|
||||
screenPoint.x -= [box arrowSize];
|
||||
screenPoint.y += [box arrowSize];
|
||||
break;
|
||||
|
||||
case ArrowTopEdge:
|
||||
screenPoint.x -= [box arrowPosition];
|
||||
break;
|
||||
|
||||
case ArrowBottomEdge:
|
||||
screenPoint.x -= [box arrowPosition];
|
||||
screenPoint.y += NSHeight( [self frame] );
|
||||
break;
|
||||
|
||||
case ArrowLeftEdge:
|
||||
screenPoint.y += NSHeight( [self frame] ) - [box arrowPosition] - [box arrowSize];
|
||||
break;
|
||||
|
||||
case ArrowRightEdge:
|
||||
screenPoint.x -= NSWidth( [self frame] );
|
||||
screenPoint.y += NSHeight( [self frame] ) - [box arrowPosition] - [box arrowSize];
|
||||
break;
|
||||
}
|
||||
|
||||
[self setFrameTopLeftPoint: screenPoint];
|
||||
switch ([box arrowEdge]) {
|
||||
case ArrowNone:
|
||||
screenPoint.x -= [box arrowSize];
|
||||
screenPoint.y += [box arrowSize];
|
||||
break;
|
||||
|
||||
case ArrowTopEdge:
|
||||
screenPoint.x -= [box arrowPosition];
|
||||
break;
|
||||
|
||||
case ArrowBottomEdge:
|
||||
screenPoint.x -= [box arrowPosition];
|
||||
screenPoint.y += NSHeight( [self frame] );
|
||||
break;
|
||||
|
||||
case ArrowLeftEdge:
|
||||
screenPoint.y += NSHeight( [self frame] ) - [box arrowPosition] - [box arrowSize];
|
||||
break;
|
||||
|
||||
case ArrowRightEdge:
|
||||
screenPoint.x -= NSWidth( [self frame] );
|
||||
screenPoint.y += NSHeight( [self frame] ) - [box arrowPosition] - [box arrowSize];
|
||||
break;
|
||||
}
|
||||
|
||||
[self setFrameTopLeftPoint: screenPoint];
|
||||
}
|
||||
|
||||
static NSRect ScreenRectForView( NSView *view )
|
||||
{
|
||||
NSRect viewRect = [view bounds]; // in View coordinate system
|
||||
viewRect = [view convertRect: viewRect toView: nil]; // translate to window coordinates
|
||||
viewRect.origin = [[view window] convertBaseToScreen: viewRect.origin]; // translate to screen coordinates
|
||||
return viewRect;
|
||||
NSRect viewRect = [view bounds]; // in View coordinate system
|
||||
viewRect = [view convertRect: viewRect toView: nil]; // translate to window coordinates
|
||||
viewRect.origin = [[view window] convertBaseToScreen: viewRect.origin]; // translate to screen coordinates
|
||||
return viewRect;
|
||||
}
|
||||
|
||||
- (void) attachToView: (NSView *) view;
|
||||
- (void) attachToView: (NSView *) view
|
||||
{
|
||||
if (nil != attachedWindow) [self detach];
|
||||
|
||||
NSRect viewRect = ScreenRectForView( view );
|
||||
NSPoint arrowPoint;
|
||||
switch ([box arrowEdge]) {
|
||||
case ArrowNone:
|
||||
case ArrowTopEdge:
|
||||
arrowPoint = NSMakePoint( NSMidX( viewRect ), NSMinY( viewRect ) );
|
||||
break;
|
||||
|
||||
case ArrowLeftEdge:
|
||||
arrowPoint = NSMakePoint( NSMaxX( viewRect ), NSMidY( viewRect ) );
|
||||
break;
|
||||
if (nil != attachedWindow) [self detach];
|
||||
|
||||
case ArrowBottomEdge:
|
||||
arrowPoint = NSMakePoint( NSMidX( viewRect ), NSMaxY( viewRect ) );
|
||||
break;
|
||||
NSRect viewRect = ScreenRectForView( view );
|
||||
NSPoint arrowPoint;
|
||||
|
||||
case ArrowRightEdge:
|
||||
arrowPoint = NSMakePoint( NSMinX( viewRect ), NSMidY( viewRect ) );
|
||||
break;
|
||||
}
|
||||
attachedWindow = [view window];
|
||||
[self moveToPoint: arrowPoint];
|
||||
[attachedWindow addChildWindow: self ordered: NSWindowAbove];
|
||||
switch ([box arrowEdge]) {
|
||||
case ArrowNone:
|
||||
case ArrowTopEdge:
|
||||
arrowPoint = NSMakePoint( NSMidX( viewRect ),
|
||||
NSMinY( viewRect ) );
|
||||
break;
|
||||
|
||||
case ArrowLeftEdge:
|
||||
arrowPoint = NSMakePoint( NSMaxX( viewRect ),
|
||||
NSMidY( viewRect ) );
|
||||
break;
|
||||
|
||||
case ArrowBottomEdge:
|
||||
arrowPoint = NSMakePoint( NSMidX( viewRect ),
|
||||
NSMaxY( viewRect ) );
|
||||
break;
|
||||
|
||||
case ArrowRightEdge:
|
||||
arrowPoint = NSMakePoint( NSMinX( viewRect ),
|
||||
NSMidY( viewRect ) );
|
||||
break;
|
||||
}
|
||||
attachedWindow = [view window];
|
||||
[self moveToPoint: arrowPoint];
|
||||
[attachedWindow addChildWindow: self ordered: NSWindowAbove];
|
||||
}
|
||||
|
||||
- (void) detach;
|
||||
- (void) detach
|
||||
{
|
||||
[attachedWindow removeChildWindow: self];
|
||||
[self close];
|
||||
attachedWindow = nil;
|
||||
[attachedWindow removeChildWindow: self];
|
||||
[self close];
|
||||
attachedWindow = nil;
|
||||
}
|
||||
|
||||
//MARK: -
|
||||
//MARK: Properties
|
||||
|
||||
- (void) setArrowPosition: (CGFloat) newPosition;
|
||||
- (void) setArrowPosition: (CGFloat) newPosition
|
||||
{
|
||||
[box setArrowPosition: newPosition];
|
||||
[box setArrowPosition: newPosition];
|
||||
}
|
||||
|
||||
- (CGFloat) arrowPosition;
|
||||
- (CGFloat) arrowPosition
|
||||
{
|
||||
return [box arrowPosition];
|
||||
return [box arrowPosition];
|
||||
}
|
||||
|
||||
- (void) setArrowSize: (CGFloat)newSize;
|
||||
- (void) setArrowSize: (CGFloat)newSize
|
||||
{
|
||||
NSRect contentRect = [self contentRectForFrameRect: [self frame]];
|
||||
[box setArrowSize: newSize];
|
||||
[self setFrame: [self frameRectForContentRect: contentRect] display: [self isVisible]];
|
||||
NSRect contentRect = [self contentRectForFrameRect: [self frame]];
|
||||
[box setArrowSize: newSize];
|
||||
[self setFrame: [self frameRectForContentRect: contentRect] display: [self isVisible]];
|
||||
}
|
||||
|
||||
- (CGFloat) arrowSize;
|
||||
- (CGFloat) arrowSize
|
||||
{
|
||||
return [box arrowSize];
|
||||
return [box arrowSize];
|
||||
}
|
||||
|
||||
- (void) setArrowEdge: (ArrowEdge) newEdge;
|
||||
- (void) setArrowEdge: (ArrowEdge) newEdge
|
||||
{
|
||||
[box setArrowEdge: newEdge];
|
||||
[box setArrowEdge: newEdge];
|
||||
}
|
||||
|
||||
- (ArrowEdge) arrowEdge;
|
||||
- (ArrowEdge) arrowEdge
|
||||
{
|
||||
return [box arrowEdge];
|
||||
return [box arrowEdge];
|
||||
}
|
||||
|
||||
- (void) setCornerRadius: (CGFloat)newRadius;
|
||||
- (void) setCornerRadius: (CGFloat)newRadius
|
||||
{
|
||||
[box setCornerRadius: newRadius];
|
||||
[box setCornerRadius: newRadius];
|
||||
}
|
||||
|
||||
- (CGFloat) cornerRadius;
|
||||
- (CGFloat) cornerRadius
|
||||
{
|
||||
return [box cornerRadius];
|
||||
return [box cornerRadius];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -24,7 +24,6 @@ struct browser_window;
|
|||
@class BrowserWindowController;
|
||||
|
||||
@interface BrowserViewController : NSViewController {
|
||||
struct browser_window *browser;
|
||||
NSString *url;
|
||||
BrowserView *browserView;
|
||||
BrowserWindowController *windowController;
|
||||
|
|
|
@ -163,7 +163,8 @@ enum {
|
|||
- (PSMTabBarTearOffStyle)tearOffStyle;
|
||||
- (void)setTearOffStyle:(PSMTabBarTearOffStyle)tearOffStyle;
|
||||
|
||||
+ (Class) defaultStyleClass;
|
||||
// Factory for default style
|
||||
+ (Class)defaultStyleClass;
|
||||
|
||||
// accessors
|
||||
- (NSTabView *)tabView;
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
// Copyright 2005 Positive Spin Media. All rights reserved.
|
||||
//
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import "PSMTabBarControl.h"
|
||||
#import "PSMTabBarCell.h"
|
||||
#import "PSMOverflowPopUpButton.h"
|
||||
|
@ -67,7 +69,8 @@
|
|||
|
||||
#pragma mark -
|
||||
#pragma mark Characteristics
|
||||
+ (NSBundle *)bundle;
|
||||
|
||||
+ (NSBundle *)bundle
|
||||
{
|
||||
static NSBundle *bundle = nil;
|
||||
if(!bundle) {
|
||||
|
@ -174,7 +177,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
+ (Class) defaultStyleClass;
|
||||
+ (Class) defaultStyleClass
|
||||
{
|
||||
return [PSMUnifiedTabStyle class];
|
||||
}
|
||||
|
@ -350,7 +353,9 @@
|
|||
- (void)setStyleNamed:(NSString *)name {
|
||||
|
||||
Class styleClass = NSClassFromString( [NSString stringWithFormat: @"PSM%@TabStyle", [name capitalizedString]] );
|
||||
if (styleClass == Nil) styleClass = [isa defaultStyleClass];
|
||||
if (styleClass == Nil) {
|
||||
styleClass = object_getClass([PSMTabBarControl defaultStyleClass]);
|
||||
}
|
||||
|
||||
id <PSMTabStyle> newStyle = [[styleClass alloc] init];
|
||||
[self setStyle:newStyle];
|
||||
|
@ -369,7 +374,7 @@
|
|||
_tabBarWidth = 120;
|
||||
}
|
||||
|
||||
if(lastOrientation != _orientation) {
|
||||
if (lastOrientation != _orientation) {
|
||||
[[self style] setOrientation:_orientation];
|
||||
|
||||
[self _positionOverflowMenu]; //move the overflow popup button to the right place
|
||||
|
|
|
@ -49,6 +49,6 @@ typedef enum {
|
|||
|
||||
- (void) search: (SearchDirection)direction;
|
||||
|
||||
struct gui_search_table *cocoa_search_table;
|
||||
|
||||
@end
|
||||
|
||||
struct gui_search_table *cocoa_search_table;
|
||||
|
|
|
@ -249,7 +249,7 @@ static void gui_create_form_select_menu(struct gui_window *g,
|
|||
struct form_control *control)
|
||||
{
|
||||
BrowserViewController * const window = (BrowserViewController *)g;
|
||||
FormSelectMenu *menu = [[FormSelectMenu alloc] initWithControl: control forWindow: window->browser];
|
||||
FormSelectMenu *menu = [[FormSelectMenu alloc] initWithControl: control forWindow: [window browser]];
|
||||
[menu runInView: [window browserView]];
|
||||
[menu release];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue