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