Converted to dos line-endings.

git-svn-id: http://svn.code.sf.net/p/irrlicht/code/trunk@862 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
hybrid 2007-08-24 11:42:41 +00:00
parent 516e837e00
commit a776f1a1b2
7 changed files with 976 additions and 134 deletions

View File

@ -1,16 +1,16 @@
// Copyright (C) 2005 Etienne Petitjean
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#import <Cocoa/Cocoa.h>
#import "CIrrDeviceMacOSX.h"
@interface AppDelegate : NSObject
{
BOOL _quit;
irr::CIrrDeviceMacOSX *_device;
}
- (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device;
@end
// Copyright (C) 2005 Etienne Petitjean
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#import <Cocoa/Cocoa.h>
#import "CIrrDeviceMacOSX.h"
@interface AppDelegate : NSObject
{
BOOL _quit;
irr::CIrrDeviceMacOSX *_device;
}
- (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device;
@end

View File

@ -1,61 +1,61 @@
// Copyright (C) 2005 Etienne Petitjean
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#import "AppDelegate.h"
@implementation AppDelegate
- (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device
{
self = [super init];
if (self) _device = device;
return (self);
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
_quit = FALSE;
}
- (void)orderFrontStandardAboutPanel:(id)sender
{
[NSApp orderFrontStandardAboutPanel:sender];
}
- (void)unhideAllApplications:(id)sender
{
[NSApp unhideAllApplications:sender];
}
- (void)hide:(id)sender
{
[NSApp hide:sender];
}
- (void)hideOtherApplications:(id)sender
{
[NSApp hideOtherApplications:sender];
}
- (void)terminate:(id)sender
{
_quit = TRUE;
}
- (void)windowDidResize:(NSNotification *)aNotification
{
NSWindow *window;
NSRect frame;
window = [aNotification object];
frame = [window frame];
_device->setResize((int)frame.size.width,(int)frame.size.height);
}
- (BOOL)isQuit
{
return (_quit);
}
@end
// Copyright (C) 2005 Etienne Petitjean
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#import "AppDelegate.h"
@implementation AppDelegate
- (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device
{
self = [super init];
if (self) _device = device;
return (self);
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
_quit = FALSE;
}
- (void)orderFrontStandardAboutPanel:(id)sender
{
[NSApp orderFrontStandardAboutPanel:sender];
}
- (void)unhideAllApplications:(id)sender
{
[NSApp unhideAllApplications:sender];
}
- (void)hide:(id)sender
{
[NSApp hide:sender];
}
- (void)hideOtherApplications:(id)sender
{
[NSApp hideOtherApplications:sender];
}
- (void)terminate:(id)sender
{
_quit = TRUE;
}
- (void)windowDidResize:(NSNotification *)aNotification
{
NSWindow *window;
NSRect frame;
window = [aNotification object];
frame = [window frame];
_device->setResize((int)frame.size.width,(int)frame.size.height);
}
- (BOOL)isQuit
{
return (_quit);
}
@end

View File

@ -1,2 +1,214 @@
// Copyright (C) 2005 Etienne Petitjean // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in Irrlicht.h #ifndef __C_IRR_DEVICE_MACOSX_H_INCLUDED__ #define __C_IRR_DEVICE_MACOSX_H_INCLUDED__ #include "IrrCompileConfig.h" #ifdef MACOSX #include "CIrrDeviceStub.h" #include "IrrlichtDevice.h" #include "IImagePresenter.h" #include "IGUIEnvironment.h" #include "ICursorControl.h" #include <OpenGL/OpenGL.h> #include <map> namespace irr { class CIrrDeviceMacOSX : public CIrrDeviceStub, video::IImagePresenter { public: //! constructor CIrrDeviceMacOSX(video::E_DRIVER_TYPE driverType, const core::dimension2d<s32>& windowSize, u32 bits, bool fullscreen, bool sbuffer, bool vsync, bool antiAlias, IEventReceiver* receiver, const char* version); //! destructor virtual ~CIrrDeviceMacOSX(); //! runs the device. Returns false if device wants to be deleted virtual bool run(); //! Cause the device to temporarily pause execution and let other processes to run // This should bring down processor usage without major performance loss for Irrlicht virtual void yield(); //! Pause execution and let other processes to run for a specified amount of time. virtual void sleep(u32 timeMs, bool pauseTimer); //! sets the caption of the window virtual void setWindowCaption(const wchar_t* text); //! returns if window is active. if not, nothing need to be drawn virtual bool isWindowActive(); //! presents a surface in the client area virtual void present(video::IImage* surface, s32 windowId = 0, core::rect<s32>* src=0 ); //! notifies the device that it should close itself virtual void closeDevice(); //! Sets if the window should be resizeable in windowed mode.
virtual void setResizeAble(bool resize); void flush(); void setMouseLocation(int x,int y); void setResize(int width,int height); void setCursorVisible(bool visible); private: //! create the driver void createDriver(video::E_DRIVER_TYPE driverType, const core::dimension2d<s32>& windowSize, u32 bits, bool fullscreen, bool stencilbuffer, bool vsync, bool antiAlias); //! Implementation of the macos x cursor control class CCursorControl : public gui::ICursorControl { public: CCursorControl(const core::dimension2d<s32>& wsize, CIrrDeviceMacOSX *device) : WindowSize(wsize), IsVisible(true), InvWindowSize(0.0f, 0.0f), _device(device), UseReferenceRect(false) { CursorPos.X = CursorPos.Y = 0; if (WindowSize.Width!=0) InvWindowSize.Width = 1.0f / WindowSize.Width; if (WindowSize.Height!=0) InvWindowSize.Height = 1.0f / WindowSize.Height; } //! Changes the visible state of the mouse cursor. virtual void setVisible(bool visible) { IsVisible = visible; _device->setCursorVisible(visible); } //! Returns if the cursor is currently visible. virtual bool isVisible() { return IsVisible; } //! Sets the new position of the cursor. virtual void setPosition(const core::position2d<f32> &pos) { setPosition(pos.X, pos.Y); } //! Sets the new position of the cursor. virtual void setPosition(f32 x, f32 y) { setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height)); } //! Sets the new position of the cursor. virtual void setPosition(const core::position2d<s32> &pos) { if (CursorPos.X != pos.X || CursorPos.Y != pos.Y) setPosition(pos.X, pos.Y); } //! Sets the new position of the cursor. virtual void setPosition(s32 x, s32 y) { if (UseReferenceRect) { _device->setMouseLocation(ReferenceRect.UpperLeftCorner.X + x, ReferenceRect.UpperLeftCorner.Y + y); } else { _device->setMouseLocation(x,y); } } //! Returns the current position of the mouse cursor. virtual core::position2d<s32> getPosition() { return CursorPos; } //! Returns the current position of the mouse cursor. virtual core::position2d<f32> getRelativePosition() { if (!UseReferenceRect) { return core::position2d<f32>(CursorPos.X * InvWindowSize.Width, CursorPos.Y * InvWindowSize.Height); } return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(), CursorPos.Y / (f32)ReferenceRect.getHeight()); } //! Sets an absolute reference rect for calculating the cursor position. virtual void setReferenceRect(core::rect<s32>* rect=0) { if (rect) { ReferenceRect = *rect; UseReferenceRect = true; // prevent division through zero and uneven sizes if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2) ReferenceRect.LowerRightCorner.Y += 1; if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2) ReferenceRect.LowerRightCorner.X += 1; } else UseReferenceRect = false; } //! Updates the internal cursor position void updateInternalCursorPosition(int x,int y) { CursorPos.X = x; CursorPos.Y = y; } private: core::position2d<s32> CursorPos; core::dimension2d<s32> WindowSize; core::dimension2d<float> InvWindowSize; CIrrDeviceMacOSX *_device; bool IsVisible; bool UseReferenceRect; core::rect<s32> ReferenceRect; }; bool createWindow(const irr::core::dimension2d<irr::s32>& windowSize, irr::u32 bits, bool fullscreen, bool vsync, bool stencilBuffer); void initKeycodes(); void storeMouseLocation(); void postMouseEvent(void *event,irr::SEvent &ievent); void postKeyEvent(void *event,irr::SEvent &ievent,bool pressed); video::E_DRIVER_TYPE DriverType; bool stencilbuffer; void *_window; CGLContextObj _cglcontext; void *_oglcontext; int _width; int _height; std::map<int,int> _keycodes; int _screenWidth; int _screenHeight; bool _active; }; } // end namespace irr #endif // MACOSX #endif // __C_IRR_DEVICE_MACOSX_H_INCLUDED__
// Copyright (C) 2005 Etienne Petitjean
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#ifndef __C_IRR_DEVICE_MACOSX_H_INCLUDED__
#define __C_IRR_DEVICE_MACOSX_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef MACOSX
#include "CIrrDeviceStub.h"
#include "IrrlichtDevice.h"
#include "IImagePresenter.h"
#include "IGUIEnvironment.h"
#include "ICursorControl.h"
#include <OpenGL/OpenGL.h>
#include <map>
namespace irr
{
class CIrrDeviceMacOSX : public CIrrDeviceStub, video::IImagePresenter
{
public:
//! constructor
CIrrDeviceMacOSX(video::E_DRIVER_TYPE driverType,
const core::dimension2d<s32>& windowSize,
u32 bits, bool fullscreen,
bool sbuffer, bool vsync,
bool antiAlias, IEventReceiver* receiver,
const char* version);
//! destructor
virtual ~CIrrDeviceMacOSX();
//! runs the device. Returns false if device wants to be deleted
virtual bool run();
//! Cause the device to temporarily pause execution and let other processes to run
// This should bring down processor usage without major performance loss for Irrlicht
virtual void yield();
//! Pause execution and let other processes to run for a specified amount of time.
virtual void sleep(u32 timeMs, bool pauseTimer);
//! sets the caption of the window
virtual void setWindowCaption(const wchar_t* text);
//! returns if window is active. if not, nothing need to be drawn
virtual bool isWindowActive();
//! presents a surface in the client area
virtual void present(video::IImage* surface, s32 windowId = 0, core::rect<s32>* src=0 );
//! notifies the device that it should close itself
virtual void closeDevice();
//! Sets if the window should be resizeable in windowed mode.
virtual void setResizeAble(bool resize);
void flush();
void setMouseLocation(int x,int y);
void setResize(int width,int height);
void setCursorVisible(bool visible);
private:
//! create the driver
void createDriver(video::E_DRIVER_TYPE driverType,
const core::dimension2d<s32>& windowSize, u32 bits, bool fullscreen,
bool stencilbuffer, bool vsync, bool antiAlias);
//! Implementation of the macos x cursor control
class CCursorControl : public gui::ICursorControl
{
public:
CCursorControl(const core::dimension2d<s32>& wsize, CIrrDeviceMacOSX *device) : WindowSize(wsize), IsVisible(true), InvWindowSize(0.0f, 0.0f), _device(device), UseReferenceRect(false)
{
CursorPos.X = CursorPos.Y = 0;
if (WindowSize.Width!=0) InvWindowSize.Width = 1.0f / WindowSize.Width;
if (WindowSize.Height!=0) InvWindowSize.Height = 1.0f / WindowSize.Height;
}
//! Changes the visible state of the mouse cursor.
virtual void setVisible(bool visible)
{
IsVisible = visible;
_device->setCursorVisible(visible);
}
//! Returns if the cursor is currently visible.
virtual bool isVisible()
{
return IsVisible;
}
//! Sets the new position of the cursor.
virtual void setPosition(const core::position2d<f32> &pos)
{
setPosition(pos.X, pos.Y);
}
//! Sets the new position of the cursor.
virtual void setPosition(f32 x, f32 y)
{
setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height));
}
//! Sets the new position of the cursor.
virtual void setPosition(const core::position2d<s32> &pos)
{
if (CursorPos.X != pos.X || CursorPos.Y != pos.Y)
setPosition(pos.X, pos.Y);
}
//! Sets the new position of the cursor.
virtual void setPosition(s32 x, s32 y)
{
if (UseReferenceRect)
{
_device->setMouseLocation(ReferenceRect.UpperLeftCorner.X + x, ReferenceRect.UpperLeftCorner.Y + y);
}
else
{
_device->setMouseLocation(x,y);
}
}
//! Returns the current position of the mouse cursor.
virtual core::position2d<s32> getPosition()
{
return CursorPos;
}
//! Returns the current position of the mouse cursor.
virtual core::position2d<f32> getRelativePosition()
{
if (!UseReferenceRect)
{
return core::position2d<f32>(CursorPos.X * InvWindowSize.Width,
CursorPos.Y * InvWindowSize.Height);
}
return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(),
CursorPos.Y / (f32)ReferenceRect.getHeight());
}
//! Sets an absolute reference rect for calculating the cursor position.
virtual void setReferenceRect(core::rect<s32>* rect=0)
{
if (rect)
{
ReferenceRect = *rect;
UseReferenceRect = true;
// prevent division through zero and uneven sizes
if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2)
ReferenceRect.LowerRightCorner.Y += 1;
if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2)
ReferenceRect.LowerRightCorner.X += 1;
}
else
UseReferenceRect = false;
}
//! Updates the internal cursor position
void updateInternalCursorPosition(int x,int y)
{
CursorPos.X = x;
CursorPos.Y = y;
}
private:
core::position2d<s32> CursorPos;
core::dimension2d<s32> WindowSize;
core::dimension2d<float> InvWindowSize;
CIrrDeviceMacOSX *_device;
bool IsVisible;
bool UseReferenceRect;
core::rect<s32> ReferenceRect;
};
bool createWindow(const irr::core::dimension2d<irr::s32>& windowSize, irr::u32 bits, bool fullscreen, bool vsync, bool stencilBuffer);
void initKeycodes();
void storeMouseLocation();
void postMouseEvent(void *event,irr::SEvent &ievent);
void postKeyEvent(void *event,irr::SEvent &ievent,bool pressed);
video::E_DRIVER_TYPE DriverType;
bool stencilbuffer;
void *_window;
CGLContextObj _cglcontext;
void *_oglcontext;
int _width;
int _height;
std::map<int,int> _keycodes;
int _screenWidth;
int _screenHeight;
bool _active;
};
} // end namespace irr
#endif // MACOSX
#endif // __C_IRR_DEVICE_MACOSX_H_INCLUDED__

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
//
// Prefix header for all source files of the 'MacOSX' target in the 'MacOSX' project.
//
#include <architecture/byte_order.h>
//
// Prefix header for all source files of the 'MacOSX' target in the 'MacOSX' project.
//
#include <architecture/byte_order.h>

View File

@ -1,14 +1,14 @@
// Copyright (C) 2005 Etienne Petitjean
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#ifdef __cplusplus
extern "C" {
#endif
void OSXCopyToClipboard(const char *text);
char* OSXCopyFromClipboard();
#ifdef __cplusplus
}
#endif
// Copyright (C) 2005 Etienne Petitjean
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#ifdef __cplusplus
extern "C" {
#endif
void OSXCopyToClipboard(const char *text);
char* OSXCopyFromClipboard();
#ifdef __cplusplus
}
#endif

View File

@ -1,33 +1,33 @@
// Copyright (C) 2005 Etienne Petitjean
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#include "OSXClipboard.h"
#import <Cocoa/Cocoa.h>
void OSXCopyToClipboard(const char *text)
{
NSString *str;
NSPasteboard *board;
if (text != NULL && strlen(text) > 0)
{
str = [NSString stringWithCString:text encoding:NSWindowsCP1252StringEncoding];
board = [NSPasteboard generalPasteboard];
[board declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp];
[board setString:str forType:NSStringPboardType];
}
}
char* OSXCopyFromClipboard()
{
NSString *str;
NSPasteboard *board;
char *result;
result = NULL;
board = [NSPasteboard generalPasteboard];
str = [board stringForType:NSStringPboardType];
if (str != nil) result = (char*)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding];
return (result);
}
// Copyright (C) 2005 Etienne Petitjean
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#include "OSXClipboard.h"
#import <Cocoa/Cocoa.h>
void OSXCopyToClipboard(const char *text)
{
NSString *str;
NSPasteboard *board;
if (text != NULL && strlen(text) > 0)
{
str = [NSString stringWithCString:text encoding:NSWindowsCP1252StringEncoding];
board = [NSPasteboard generalPasteboard];
[board declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp];
[board setString:str forType:NSStringPboardType];
}
}
char* OSXCopyFromClipboard()
{
NSString *str;
NSPasteboard *board;
char *result;
result = NULL;
board = [NSPasteboard generalPasteboard];
str = [board stringForType:NSStringPboardType];
if (str != nil) result = (char*)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding];
return (result);
}