cocos2d for iPhone 1.0.0
2D engine for iOS and OS X
/Users/rquesada/progs/cocos2d-iphone/cocos2d/Platforms/Mac/CCEventDispatcher.h
00001 /*
00002  * cocos2d for iPhone: http://www.cocos2d-iphone.org
00003  *
00004  * Copyright (c) 2010 Ricardo Quesada
00005  * Copyright (c) 2011 Zynga Inc.
00006  * 
00007  * Permission is hereby granted, free of charge, to any person obtaining a copy
00008  * of this software and associated documentation files (the "Software"), to deal
00009  * in the Software without restriction, including without limitation the rights
00010  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011  * copies of the Software, and to permit persons to whom the Software is
00012  * furnished to do so, subject to the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice shall be included in
00015  * all copies or substantial portions of the Software.
00016  * 
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00022  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00023  * THE SOFTWARE.
00024  */
00025 
00026 // Only compile this code on Mac. These files should not be included on your iOS project.
00027 // But in case they are included, it won't be compiled.
00028 #import <Availability.h>
00029 #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
00030 #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
00031 
00032 #import <Cocoa/Cocoa.h>
00033 
00034 #import "MacGLView.h"
00035 #import "../../Support/uthash.h"        // hack: uthash needs to be imported before utlist to prevent warning
00036 #import "../../Support/utlist.h"
00037 #import "../../ccConfig.h"
00038 
00039 #pragma mark -
00040 #pragma mark CCMouseEventDelegate
00041 
00045 @protocol CCMouseEventDelegate <NSObject>
00046 @optional
00047 
00048 //
00049 // left
00050 //
00054 -(BOOL) ccMouseDown:(NSEvent*)event;
00055 
00059 -(BOOL) ccMouseDragged:(NSEvent*)event;
00060 
00065 -(BOOL) ccMouseMoved:(NSEvent*)event;
00066 
00070 -(BOOL) ccMouseUp:(NSEvent*)event;
00071 
00072 
00073 //
00074 // right
00075 //
00076 
00080 -(BOOL) ccRightMouseDown:(NSEvent*)event;
00081 
00085 -(BOOL) ccRightMouseDragged:(NSEvent*)event;
00086 
00090 -(BOOL) ccRightMouseUp:(NSEvent*)event;
00091 
00092 //
00093 // other
00094 //
00095 
00099 -(BOOL) ccOtherMouseDown:(NSEvent*)event;
00100 
00104 -(BOOL) ccOtherMouseDragged:(NSEvent*)event;
00105 
00109 -(BOOL) ccOtherMouseUp:(NSEvent*)event;
00110 
00111 //
00112 // scroll wheel
00113 //
00114 
00118 - (BOOL)ccScrollWheel:(NSEvent *)theEvent;
00119 
00120 
00121 //
00122 // enter / exit
00123 //
00124 
00128 - (void)ccMouseEntered:(NSEvent *)theEvent;
00129 
00133 - (void)ccMouseExited:(NSEvent *)theEvent;
00134 
00135 @end
00136 
00137 #pragma mark -
00138 #pragma mark CCKeyboardEventDelegate
00139 
00143 @protocol CCKeyboardEventDelegate <NSObject>
00144 @optional
00148 -(BOOL) ccKeyUp:(NSEvent*)event;
00149 
00153 -(BOOL) ccKeyDown:(NSEvent*)event;
00157 -(BOOL) ccFlagsChanged:(NSEvent*)event;
00158 @end
00159 
00160 #pragma mark -
00161 #pragma mark CCTouchEventDelegate
00162 
00166 @protocol CCTouchEventDelegate <NSObject>
00167 @optional
00171 - (BOOL)ccTouchesBeganWithEvent:(NSEvent *)event;
00172 
00176 - (BOOL)ccTouchesMovedWithEvent:(NSEvent *)event;
00177 
00181 - (BOOL)ccTouchesEndedWithEvent:(NSEvent *)event;
00182 
00186 - (BOOL)ccTouchesCancelledWithEvent:(NSEvent *)event;
00187 
00188 @end
00189 
00190 
00191 #pragma mark -
00192 #pragma mark CCEventDispatcher
00193 
00194 struct _listEntry;
00195 
00205 @interface CCEventDispatcher : NSObject <MacEventDelegate> {
00206 
00207         BOOL                                    dispatchEvents_;
00208         
00209         struct  _listEntry              *keyboardDelegates_;
00210         struct  _listEntry              *mouseDelegates_;
00211         struct  _listEntry              *touchDelegates_;
00212 }
00213 
00214 @property (nonatomic, readwrite) BOOL dispatchEvents;
00215 
00216 
00218 +(CCEventDispatcher*) sharedDispatcher;
00219 
00220 #pragma mark CCEventDispatcher - Mouse
00221 
00228 -(void) addMouseDelegate:(id<CCMouseEventDelegate>) delegate priority:(NSInteger)priority;
00229 
00231 -(void) removeMouseDelegate:(id) delegate;
00232 
00234 -(void) removeAllMouseDelegates;
00235 
00236 #pragma mark CCEventDispatcher - Keyboard
00237 
00244 -(void) addKeyboardDelegate:(id<CCKeyboardEventDelegate>) delegate priority:(NSInteger)priority;
00245 
00247 -(void) removeKeyboardDelegate:(id) delegate;
00248 
00250 -(void) removeAllKeyboardDelegates;
00251 
00252 #pragma mark CCEventDispatcher - Touches
00253 
00260 - (void)addTouchDelegate:(id<CCTouchEventDelegate>)delegate priority:(NSInteger)priority;
00261 
00263 - (void)removeTouchDelegate:(id) delegate;
00264 
00266 - (void)removeAllTouchDelegates;
00267 
00268 #pragma mark CCEventDispatcher - Dispatch Events
00269 
00270 #if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
00271 -(void) dispatchQueuedEvents;
00272 #endif
00273 
00274 @end
00275 
00276 
00277 #endif // __MAC_OS_X_VERSION_MAX_ALLOWED
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

cocos2d for iPhone API Reference - Generated using Doxygen 1.7.4