This repository has been archived by the owner on May 19, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from numist/merge-okocsis
Merge changes from okocsis:develop to master.
- Loading branch information
Showing
16 changed files
with
362 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// HAXButton.h | ||
// Created by Kocsis Olivér on 2014-05-21 | ||
// Copyright 2014 Joinect Technologies | ||
|
||
#import <HAXcessibility/HAXView.h> | ||
|
||
@interface HAXButton : HAXView | ||
|
||
-(void)press; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// HAXButton.m | ||
// Created by Kocsis Olivér on 2014-05-21 | ||
// Copyright 2014 Joinect Technologies | ||
|
||
#import "HAXButton.h" | ||
#import "HAXElement+Protected.h" | ||
|
||
@implementation HAXButton | ||
|
||
-(void)press { | ||
[self performAction:(__bridge NSString *)kAXPressAction error:NULL]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// HAXView.h | ||
// Created by Kocsis Olivér on 2014-05-12 | ||
// Copyright 2014 Joinect Technologies | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import <Haxcessibility/HAXElement.h> | ||
|
||
@interface HAXView : HAXElement | ||
|
||
@property (nonatomic, assign) CGPoint carbonOrigin; | ||
@property (nonatomic, assign, readonly) NSPoint origin; | ||
@property (nonatomic, assign) NSSize size; | ||
@property (nonatomic, assign) CGRect carbonFrame; | ||
@property (nonatomic, assign, readonly) NSRect frame; | ||
@property (nonatomic, readonly) NSString *title; | ||
@property (nonatomic, readonly) NSScreen *screen; | ||
@property (nonatomic, readonly, getter=isFullscreen) BOOL fullscreen; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// HAXView.m | ||
// Created by Kocsis Olivér on 2014-05-12 | ||
// Copyright 2014 Joinect Technologies | ||
|
||
#import "HAXView.h" | ||
#import "HAXElement+Protected.h" | ||
#import "NSScreen+HAXPointConvert.h" | ||
|
||
@implementation HAXView | ||
|
||
-(CGPoint)carbonOrigin { | ||
CGPoint origin = {0}; | ||
AXValueRef originRef = (AXValueRef)[self copyAttributeValueForKey:(__bridge NSString *)kAXPositionAttribute error:NULL]; | ||
if(originRef) { | ||
AXValueGetValue(originRef, kAXValueCGPointType, &origin); | ||
CFRelease(originRef); | ||
originRef = NULL; | ||
} | ||
return origin; | ||
} | ||
|
||
-(void)setCarbonOrigin:(CGPoint)carbonOrigin { | ||
AXValueRef originRef = AXValueCreate(kAXValueCGPointType, &carbonOrigin); | ||
[self setAttributeValue:originRef forKey:(__bridge NSString *)kAXPositionAttribute error:NULL]; | ||
CFRelease(originRef); | ||
} | ||
|
||
-(NSPoint)origin { | ||
return [NSScreen hax_cocoaScreenFrameFromCarbonScreenFrame:self.carbonFrame].origin; | ||
} | ||
|
||
-(NSSize)size { | ||
CGSize size = {0}; | ||
AXValueRef sizeRef = (AXValueRef)[self copyAttributeValueForKey:(__bridge NSString *)kAXSizeAttribute error:NULL]; | ||
if(sizeRef) { | ||
AXValueGetValue(sizeRef, kAXValueCGSizeType, &size); | ||
CFRelease(sizeRef); | ||
sizeRef = NULL; | ||
} | ||
return size; | ||
} | ||
|
||
-(void)setSize:(NSSize)size { | ||
AXValueRef sizeRef = AXValueCreate(kAXValueCGSizeType, &size); | ||
[self setAttributeValue:sizeRef forKey:(__bridge NSString *)kAXSizeAttribute error:NULL]; | ||
CFRelease(sizeRef); | ||
} | ||
|
||
-(CGRect)carbonFrame { | ||
return (CGRect){ .origin = self.carbonOrigin, .size = self.size }; | ||
} | ||
|
||
-(void)setCarbonFrame:(CGRect)carbonFrame { | ||
self.carbonOrigin = carbonFrame.origin; | ||
self.size = carbonFrame.size; | ||
} | ||
|
||
-(NSRect)frame { | ||
return [NSScreen hax_cocoaScreenFrameFromCarbonScreenFrame:self.carbonFrame]; | ||
} | ||
|
||
-(NSString *)title { | ||
return [self getAttributeValueForKey:(__bridge NSString *)kAXTitleAttribute error:NULL]; | ||
} | ||
|
||
-(NSScreen *)screen { | ||
NSScreen *matchingScreen = nil; | ||
NSRect viewFrame = self.frame; | ||
NSUInteger bestOverlap = 0; | ||
for (NSScreen * screenI in [NSScreen screens]) { | ||
NSRect intersection = NSIntersectionRect(screenI.frame, viewFrame); | ||
NSUInteger intersectionOverlap = intersection.size.width * intersection.size.height; | ||
if(intersectionOverlap > bestOverlap) { | ||
matchingScreen = screenI; | ||
bestOverlap = intersectionOverlap; | ||
} | ||
} | ||
return matchingScreen; | ||
} | ||
|
||
-(BOOL)isFullscreen { | ||
BOOL isFullScreen = NO; | ||
NSArray * sceenArray = [NSScreen screens]; | ||
NSRect windowFrame = self.frame; | ||
|
||
for (NSScreen * screenI in sceenArray) { | ||
NSRect screenFrame; | ||
screenFrame = [screenI frame]; | ||
if(NSEqualRects(screenFrame, windowFrame)) { | ||
isFullScreen = YES; | ||
break; | ||
} | ||
} | ||
|
||
return isFullScreen; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.