Blame client/iOS/Views/RDPSessionView.m

Packit 1fb8d4
/*
Packit 1fb8d4
 RDP Session View
Packit Service 5a9772
Packit 1fb8d4
 Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
Packit Service 5a9772
Packit Service 5a9772
 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
Packit Service 5a9772
 If a copy of the MPL was not distributed with this file, You can obtain one at
Packit Service 5a9772
 http://mozilla.org/MPL/2.0/.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#import "RDPSessionView.h"
Packit 1fb8d4
Packit 1fb8d4
@implementation RDPSessionView
Packit 1fb8d4
Packit Service 5a9772
- (void)setSession:(RDPSession *)session
Packit 1fb8d4
{
Packit Service 5a9772
	_session = session;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
- (void)awakeFromNib
Packit 1fb8d4
{
Packit Service 5a9772
	[super awakeFromNib];
Packit Service 5a9772
	_session = nil;
Packit 1fb8d4
}
Packit 1fb8d4
Packit Service 5a9772
- (void)drawRect:(CGRect)rect
Packit 1fb8d4
{
Packit Service 5a9772
	if (_session != nil && [_session bitmapContext])
Packit 1fb8d4
	{
Packit 1fb8d4
		CGContextRef context = UIGraphicsGetCurrentContext();
Packit 1fb8d4
		CGImageRef cgImage = CGBitmapContextCreateImage([_session bitmapContext]);
Packit 1fb8d4
Packit Service 5a9772
		CGContextTranslateCTM(context, 0, [self bounds].size.height);
Packit Service 5a9772
		CGContextScaleCTM(context, 1.0, -1.0);
Packit Service 5a9772
		CGContextClipToRect(context,
Packit Service 5a9772
		                    CGRectMake(rect.origin.x,
Packit Service 5a9772
		                               [self bounds].size.height - rect.origin.y - rect.size.height,
Packit Service 5a9772
		                               rect.size.width, rect.size.height));
Packit Service 5a9772
		CGContextDrawImage(context,
Packit Service 5a9772
		                   CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height),
Packit Service 5a9772
		                   cgImage);
Packit Service 5a9772
Packit Service 5a9772
		CGImageRelease(cgImage);
Packit Service 5a9772
	}
Packit Service 5a9772
	else
Packit Service 5a9772
	{
Packit Service 5a9772
		// just clear the screen with black
Packit Service 5a9772
		[[UIColor blackColor] set];
Packit Service 5a9772
		UIRectFill([self bounds]);
Packit 1fb8d4
	}
Packit 1fb8d4
}
Packit 1fb8d4
Packit Service 5a9772
- (void)dealloc
Packit Service 5a9772
{
Packit Service 5a9772
	[super dealloc];
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
@end