SDL_cocoawindow.h (5853B)
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20*/ 21#include "../../SDL_internal.h" 22 23#ifndef _SDL_cocoawindow_h 24#define _SDL_cocoawindow_h 25 26#import <Cocoa/Cocoa.h> 27 28typedef struct SDL_WindowData SDL_WindowData; 29 30typedef enum 31{ 32 PENDING_OPERATION_NONE, 33 PENDING_OPERATION_ENTER_FULLSCREEN, 34 PENDING_OPERATION_LEAVE_FULLSCREEN, 35 PENDING_OPERATION_MINIMIZE 36} PendingWindowOperation; 37 38@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> { 39 SDL_WindowData *_data; 40 BOOL observingVisible; 41 BOOL wasCtrlLeft; 42 BOOL wasVisible; 43 BOOL isFullscreenSpace; 44 BOOL inFullscreenTransition; 45 PendingWindowOperation pendingWindowOperation; 46 BOOL isMoving; 47 int pendingWindowWarpX, pendingWindowWarpY; 48 BOOL isDragAreaRunning; 49} 50 51-(void) listen:(SDL_WindowData *) data; 52-(void) pauseVisibleObservation; 53-(void) resumeVisibleObservation; 54-(BOOL) setFullscreenSpace:(BOOL) state; 55-(BOOL) isInFullscreenSpace; 56-(BOOL) isInFullscreenSpaceTransition; 57-(void) addPendingWindowOperation:(PendingWindowOperation) operation; 58-(void) close; 59 60-(BOOL) isMoving; 61-(void) setPendingMoveX:(int)x Y:(int)y; 62-(void) windowDidFinishMoving; 63 64/* Window delegate functionality */ 65-(BOOL) windowShouldClose:(id) sender; 66-(void) windowDidExpose:(NSNotification *) aNotification; 67-(void) windowDidMove:(NSNotification *) aNotification; 68-(void) windowDidResize:(NSNotification *) aNotification; 69-(void) windowDidMiniaturize:(NSNotification *) aNotification; 70-(void) windowDidDeminiaturize:(NSNotification *) aNotification; 71-(void) windowDidBecomeKey:(NSNotification *) aNotification; 72-(void) windowDidResignKey:(NSNotification *) aNotification; 73-(void) windowWillEnterFullScreen:(NSNotification *) aNotification; 74-(void) windowDidEnterFullScreen:(NSNotification *) aNotification; 75-(void) windowWillExitFullScreen:(NSNotification *) aNotification; 76-(void) windowDidExitFullScreen:(NSNotification *) aNotification; 77-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions; 78 79/* See if event is in a drag area, toggle on window dragging. */ 80-(BOOL) processHitTest:(NSEvent *)theEvent; 81 82/* Window event handling */ 83-(void) mouseDown:(NSEvent *) theEvent; 84-(void) rightMouseDown:(NSEvent *) theEvent; 85-(void) otherMouseDown:(NSEvent *) theEvent; 86-(void) mouseUp:(NSEvent *) theEvent; 87-(void) rightMouseUp:(NSEvent *) theEvent; 88-(void) otherMouseUp:(NSEvent *) theEvent; 89-(void) mouseMoved:(NSEvent *) theEvent; 90-(void) mouseDragged:(NSEvent *) theEvent; 91-(void) rightMouseDragged:(NSEvent *) theEvent; 92-(void) otherMouseDragged:(NSEvent *) theEvent; 93-(void) scrollWheel:(NSEvent *) theEvent; 94-(void) touchesBeganWithEvent:(NSEvent *) theEvent; 95-(void) touchesMovedWithEvent:(NSEvent *) theEvent; 96-(void) touchesEndedWithEvent:(NSEvent *) theEvent; 97-(void) touchesCancelledWithEvent:(NSEvent *) theEvent; 98 99/* Touch event handling */ 100-(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent; 101 102@end 103/* *INDENT-ON* */ 104 105@class SDLOpenGLContext; 106 107struct SDL_WindowData 108{ 109 SDL_Window *window; 110 NSWindow *nswindow; 111 NSMutableArray *nscontexts; 112 SDL_bool created; 113 SDL_bool inWindowMove; 114 Cocoa_WindowListener *listener; 115 struct SDL_VideoData *videodata; 116}; 117 118extern int Cocoa_CreateWindow(_THIS, SDL_Window * window); 119extern int Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, 120 const void *data); 121extern void Cocoa_SetWindowTitle(_THIS, SDL_Window * window); 122extern void Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); 123extern void Cocoa_SetWindowPosition(_THIS, SDL_Window * window); 124extern void Cocoa_SetWindowSize(_THIS, SDL_Window * window); 125extern void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window); 126extern void Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window); 127extern void Cocoa_ShowWindow(_THIS, SDL_Window * window); 128extern void Cocoa_HideWindow(_THIS, SDL_Window * window); 129extern void Cocoa_RaiseWindow(_THIS, SDL_Window * window); 130extern void Cocoa_MaximizeWindow(_THIS, SDL_Window * window); 131extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window); 132extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window); 133extern void Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered); 134extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); 135extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp); 136extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp); 137extern void Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); 138extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window); 139extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); 140extern int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); 141 142#endif /* _SDL_cocoawindow_h */ 143 144/* vi: set ts=4 sw=4 expandtab: */