src/video/cocoa/SDL_cocoawindow.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 21 Feb 2011 15:25:49 -0800
changeset 5374 dacb4f5e0dd3
parent 5371 fc3d3d580777
child 5375 16877f74123c
permissions -rw-r--r--
We still want the delegate functionality for windowShouldClose()
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2011 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #ifndef _SDL_cocoawindow_h
    25 #define _SDL_cocoawindow_h
    26 
    27 #import <Cocoa/Cocoa.h>
    28 
    29 typedef struct SDL_WindowData SDL_WindowData;
    30 
    31 /* *INDENT-OFF* */
    32 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
    33 @interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
    34 #else
    35 @interface Cocoa_WindowListener : NSResponder {
    36 #endif
    37     SDL_WindowData *_data;
    38 }
    39 
    40 -(void) listen:(SDL_WindowData *) data;
    41 -(void) close;
    42 
    43 /* Window delegate functionality */
    44 -(BOOL) windowShouldClose:(id) sender;
    45 -(void) windowDidExpose:(NSNotification *) aNotification;
    46 -(void) windowDidMove:(NSNotification *) aNotification;
    47 -(void) windowDidResize:(NSNotification *) aNotification;
    48 -(void) windowDidMiniaturize:(NSNotification *) aNotification;
    49 -(void) windowDidDeminiaturize:(NSNotification *) aNotification;
    50 -(void) windowDidBecomeKey:(NSNotification *) aNotification;
    51 -(void) windowDidResignKey:(NSNotification *) aNotification;
    52 -(void) windowDidHide:(NSNotification *) aNotification;
    53 -(void) windowDidUnhide:(NSNotification *) aNotification;
    54 
    55 /* Window event handling */
    56 -(void) mouseDown:(NSEvent *) theEvent;
    57 -(void) rightMouseDown:(NSEvent *) theEvent;
    58 -(void) otherMouseDown:(NSEvent *) theEvent;
    59 -(void) mouseUp:(NSEvent *) theEvent;
    60 -(void) rightMouseUp:(NSEvent *) theEvent;
    61 -(void) otherMouseUp:(NSEvent *) theEvent;
    62 -(void) mouseEntered:(NSEvent *)theEvent;
    63 -(void) mouseExited:(NSEvent *)theEvent;
    64 -(void) mouseMoved:(NSEvent *) theEvent;
    65 -(void) mouseDragged:(NSEvent *) theEvent;
    66 -(void) rightMouseDragged:(NSEvent *) theEvent;
    67 -(void) otherMouseDragged:(NSEvent *) theEvent;
    68 -(void) scrollWheel:(NSEvent *) theEvent;
    69 -(void) touchesBeganWithEvent:(NSEvent *) theEvent;
    70 -(void) touchesMovedWithEvent:(NSEvent *) theEvent;
    71 -(void) touchesEndedWithEvent:(NSEvent *) theEvent;
    72 -(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
    73 
    74 /* Touch event handling */
    75 typedef enum {
    76     COCOA_TOUCH_DOWN,
    77     COCOA_TOUCH_UP,
    78     COCOA_TOUCH_MOVE,
    79     COCOA_TOUCH_CANCELLED
    80 } cocoaTouchType;
    81 -(void) handleTouches:(cocoaTouchType)type withEvent:(NSEvent*) event;
    82 
    83 @end
    84 /* *INDENT-ON* */
    85 
    86 struct SDL_WindowData
    87 {
    88     SDL_Window *window;
    89     NSWindow *nswindow;
    90     SDL_bool created;
    91     Cocoa_WindowListener *listener;
    92     struct SDL_VideoData *videodata;
    93 };
    94 
    95 extern int Cocoa_CreateWindow(_THIS, SDL_Window * window);
    96 extern int Cocoa_CreateWindowFrom(_THIS, SDL_Window * window,
    97                                   const void *data);
    98 extern void Cocoa_SetWindowTitle(_THIS, SDL_Window * window);
    99 extern void Cocoa_SetWindowPosition(_THIS, SDL_Window * window);
   100 extern void Cocoa_SetWindowSize(_THIS, SDL_Window * window);
   101 extern void Cocoa_ShowWindow(_THIS, SDL_Window * window);
   102 extern void Cocoa_HideWindow(_THIS, SDL_Window * window);
   103 extern void Cocoa_RaiseWindow(_THIS, SDL_Window * window);
   104 extern void Cocoa_MaximizeWindow(_THIS, SDL_Window * window);
   105 extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window);
   106 extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window);
   107 extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
   108 extern void Cocoa_SetWindowGrab(_THIS, SDL_Window * window);
   109 extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window);
   110 extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window,
   111                                       struct SDL_SysWMinfo *info);
   112 
   113 #endif /* _SDL_cocoawindow_h */
   114 
   115 /* vi: set ts=4 sw=4 expandtab: */