(svn r21576) -Codechange: [OSX] Deduplicate code by moving the handling of the view for windowed screen drivers to a common class
This commit is contained in:
		@@ -124,6 +124,15 @@ void QZ_HideMouse();
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
uint QZ_ListModes(OTTD_Point *modes, uint max_modes, CGDirectDisplayID display_id, int display_depth);
 | 
					uint QZ_ListModes(OTTD_Point *modes, uint max_modes, CGDirectDisplayID display_id, int display_depth);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Subclass of NSView to fix Quartz rendering */
 | 
				
			||||||
 | 
					@interface OTTD_CocoaView : NSView {
 | 
				
			||||||
 | 
						CocoaSubdriver *driver;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					- (void)setDriver:(CocoaSubdriver*)drv;
 | 
				
			||||||
 | 
					- (void)drawRect:(NSRect)rect;
 | 
				
			||||||
 | 
					- (BOOL)isOpaque;
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Delegate for our NSWindow to send ask for quit on close */
 | 
					/** Delegate for our NSWindow to send ask for quit on close */
 | 
				
			||||||
@interface OTTD_CocoaWindowDelegate : NSObject {
 | 
					@interface OTTD_CocoaWindowDelegate : NSObject {
 | 
				
			||||||
	CocoaSubdriver *driver;
 | 
						CocoaSubdriver *driver;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -407,6 +407,36 @@ void cocoaReleaseAutoreleasePool()
 | 
				
			|||||||
	[ _ottd_autorelease_pool release ];
 | 
						[ _ottd_autorelease_pool release ];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@implementation OTTD_CocoaView
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Initialize the driver
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					- (void)setDriver:(CocoaSubdriver*)drv
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						driver = drv;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Define the opaqueness of the window / screen
 | 
				
			||||||
 | 
					 * @return opaqueness of window / screen
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					- (BOOL)isOpaque
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return YES;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Draws a rectangle on the screen.
 | 
				
			||||||
 | 
					 * It's overwritten by the individual drivers but must be defined
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					- (void)drawRect:(NSRect)invalidRect
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@implementation OTTD_CocoaWindowDelegate
 | 
					@implementation OTTD_CocoaWindowDelegate
 | 
				
			||||||
/** Initialize the video driver */
 | 
					/** Initialize the video driver */
 | 
				
			||||||
- (void)setDriver:(CocoaSubdriver*)drv
 | 
					- (void)setDriver:(CocoaSubdriver*)drv
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -62,15 +62,10 @@ class WindowQuartzSubdriver;
 | 
				
			|||||||
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag;
 | 
					- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag;
 | 
				
			||||||
@end
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Subclass of NSView to fix Quartz rendering */
 | 
					/* Subclass of OTTD_CocoaView to fix Quartz rendering */
 | 
				
			||||||
@interface OTTD_QuartzView : NSView {
 | 
					@interface OTTD_QuartzView : OTTD_CocoaView
 | 
				
			||||||
	WindowQuartzSubdriver *driver;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- (void)setDriver:(WindowQuartzSubdriver*)drv;
 | 
					- (void)setDriver:(WindowQuartzSubdriver*)drv;
 | 
				
			||||||
 | 
					- (void)drawRect:(NSRect)invalidRect;
 | 
				
			||||||
- (void)drawRect:(NSRect)rect;
 | 
					 | 
				
			||||||
- (BOOL)isOpaque;
 | 
					 | 
				
			||||||
@end
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class WindowQuartzSubdriver: public CocoaSubdriver {
 | 
					class WindowQuartzSubdriver: public CocoaSubdriver {
 | 
				
			||||||
@@ -239,13 +234,6 @@ static CGColorSpaceRef QZ_GetCorrectColorSpace()
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	driver = drv;
 | 
						driver = drv;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- (BOOL)isOpaque
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return YES;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- (void)drawRect:(NSRect)invalidRect
 | 
					- (void)drawRect:(NSRect)invalidRect
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (driver->cgcontext == NULL) return;
 | 
						if (driver->cgcontext == NULL) return;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user