Commit f758fb54 authored by mercury233's avatar mercury233

patch files

parent d0d04c32
This diff is collapsed.
// Copyright (C) 2005-2006 Etienne Petitjean // Copyright (C) 2005-2006 Etienne Petitjean
// Copyright (C) 2007-2012 Christian Stehno // Copyright (C) 2007-2012 Christian Stehno
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h // For conditions of distribution and use, see copyright notice in Irrlicht.h
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "CIrrDeviceMacOSX.h" #import "CIrrDeviceMacOSX.h"
@interface AppDelegate : NSObject @interface AppDelegate : NSTextView <NSApplicationDelegate>
{ {
BOOL _quit; BOOL _quit;
irr::CIrrDeviceMacOSX *_device; irr::CIrrDeviceMacOSX *_device;
} }
- (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device; - (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device;
- (BOOL)isQuit; - (BOOL)isQuit;
@end @end
#endif // _IRR_COMPILE_WITH_OSX_DEVICE_ #endif // _IRR_COMPILE_WITH_OSX_DEVICE_
// Copyright (C) 2005-2006 Etienne Petitjean // Copyright (C) 2005-2006 Etienne Petitjean
// Copyright (C) 2007-2012 Christian Stehno // Copyright (C) 2007-2012 Christian Stehno
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h // For conditions of distribution and use, see copyright notice in Irrlicht.h
#import "AppDelegate.h" #import "AppDelegate.h"
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
@implementation AppDelegate @implementation AppDelegate
- (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device - (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device
{ {
self = [super init]; self = [super init];
if (self) _device = device; if (self) _device = device;
return (self); return (self);
} }
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{ {
_quit = FALSE; _quit = FALSE;
} }
- (void)orderFrontStandardAboutPanel:(id)sender - (void)orderFrontStandardAboutPanel:(id)sender
{ {
[NSApp orderFrontStandardAboutPanel:sender]; [NSApp orderFrontStandardAboutPanel:sender];
} }
- (void)unhideAllApplications:(id)sender - (void)unhideAllApplications:(id)sender
{ {
[NSApp unhideAllApplications:sender]; [NSApp unhideAllApplications:sender];
} }
- (void)hide:(id)sender - (void)hide:(id)sender
{ {
[NSApp hide:sender]; [NSApp hide:sender];
} }
- (void)hideOtherApplications:(id)sender - (void)hideOtherApplications:(id)sender
{ {
[NSApp hideOtherApplications:sender]; [NSApp hideOtherApplications:sender];
} }
- (void)terminate:(id)sender - (void)terminate:(id)sender
{ {
_quit = TRUE; _quit = TRUE;
} }
- (void)windowWillClose:(id)sender - (void)windowWillClose:(id)sender
{ {
_quit = TRUE; _quit = TRUE;
} }
- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize - (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
{ {
if (_device->isResizable()) if (_device->isResizable())
return proposedFrameSize; return proposedFrameSize;
else else
return [window frame].size; return [window frame].size;
} }
- (void)windowDidResize:(NSNotification *)aNotification - (void)windowDidResize:(NSNotification *)aNotification
{ {
NSWindow *window; NSWindow *window;
NSRect frame; NSRect frame;
window = [aNotification object]; window = [aNotification object];
frame = [window frame]; frame = [window frame];
_device->setResize((int)frame.size.width,(int)frame.size.height); _device->setResize((int)frame.size.width,(int)frame.size.height);
} }
- (BOOL)isQuit - (BOOL)isQuit
{ {
return (_quit); return (_quit);
} }
@end
- (void)keyDown:(NSEvent *)event
#endif // _IRR_COMPILE_WITH_OSX_DEVICE_ {
[self interpretKeyEvents:@[event]];
}
- (void)insertText:(id)string
{
[self setString: @""];
if ([string isKindOfClass:[NSAttributedString class]])
{
_device->handleInputEvent([[string string] UTF8String]);
}
else
{
_device->handleInputEvent([string UTF8String]);
}
}
- (void)doCommandBySelector:(SEL)selector
{
_device->processKeyEvent();
}
@end
#endif // _IRR_COMPILE_WITH_OSX_DEVICE_
This diff is collapsed.
This diff is collapsed.
// Copyright (C) 2005-2006 Etienne Petitjean // Copyright (C) 2005-2006 Etienne Petitjean
// Copyright (C) 2007-2012 Christian Stehno // Copyright (C) 2007-2012 Christian Stehno
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h // For conditions of distribution and use, see copyright notice in Irrlicht.h
#include "OSXClipboard.h" #include "OSXClipboard.h"
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
void OSXCopyToClipboard(const char *text) void OSXCopyToClipboard(const char *text)
{ {
NSString *str; NSString *str;
NSPasteboard *board; NSPasteboard *board;
if ((text != NULL) && (strlen(text) > 0)) if ((text != NULL) && (strlen(text) > 0))
{ {
str = [NSString stringWithCString:text encoding:NSWindowsCP1252StringEncoding]; str = [NSString stringWithUTF8String:text];
board = [NSPasteboard generalPasteboard]; board = [NSPasteboard generalPasteboard];
[board declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp]; [board declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp];
[board setString:str forType:NSStringPboardType]; [board setString:str forType:NSStringPboardType];
} }
} }
char* OSXCopyFromClipboard() char* OSXCopyFromClipboard()
{ {
NSString* str; NSString* str;
NSPasteboard* board; NSPasteboard* board;
char* result; char* result;
result = NULL; result = NULL;
board = [NSPasteboard generalPasteboard]; board = [NSPasteboard generalPasteboard];
str = [board stringForType:NSStringPboardType]; str = [board stringForType:NSStringPboardType];
if (str != nil) if (str != nil)
result = (char*)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding]; result = (char*)[str UTF8String];
return (result); return (result);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment