csplugincommon/macosx/OSXDriver2D.h
00001 // 00002 // OSXDriver2D.h 00003 // 00004 // Created by mreda on Wed Oct 31 2001. 00005 // Copyright (c) 2001 Matt Reda. All rights reserved. 00006 // 00007 00008 // This code must be callable from the ObjC delegate. Since that uses the 00009 // standard C compiler, it doesn't like C++ classes, so we create a C API to 00010 // some functions of this object 00011 00012 #ifndef __CS_OSXDRIVER2D_H__ 00013 #define __CS_OSXDRIVER2D_H__ 00014 00015 #if defined(__cplusplus) 00016 00017 #include "csextern_osx.h" 00018 #include "OSXDelegate2D.h" 00019 00020 #include "csgeom/csrect.h" 00021 #include "csutil/macosx/OSXAssistant.h" 00022 #include "iutil/eventh.h" 00023 #include "ivideo/graph2d.h" 00024 #include "csplugincommon/canvas/graph2d.h" 00025 00026 #include <CoreFoundation/CoreFoundation.h> 00027 #include <ApplicationServices/ApplicationServices.h> 00028 00029 00031 struct GammaTable 00032 { 00033 float r[256]; 00034 float g[256]; 00035 float b[256]; 00036 }; 00037 00038 00039 CS_CSPLUGINCOMMON_OSX_EXPORT 00040 class OSXDriver2D 00041 { 00042 public: 00044 OSXDriver2D(csGraphics2D *inCanvas); 00045 00047 virtual ~OSXDriver2D(); 00048 00050 virtual bool Initialize(iObjectRegistry *reg); 00051 00053 virtual bool Open(); 00054 00056 virtual void Close(); 00057 00059 virtual void Print(csRect const* area = 0) = 0; 00060 00062 virtual bool Resize(int w, int h) = 0; 00063 00065 virtual bool HandleEvent(iEvent &ev); 00066 00068 void DispatchEvent(OSXEvent ev, OSXView view); 00069 00071 virtual void HideMouse(); 00072 virtual void ShowMouse(); 00073 00075 struct EventHandler : public scfImplementation1<EventHandler, iEventHandler> 00076 { 00077 private: 00078 OSXDriver2D *parent; 00079 public: 00080 EventHandler(OSXDriver2D *p) 00081 : scfImplementationType (this) 00082 { 00083 parent = p; 00084 }; 00085 virtual bool HandleEvent (iEvent& e) { return parent->HandleEvent(e); } 00086 CS_EVENTHANDLER_NAMES ("crystalspace.macosx.driver2d") 00087 CS_EVENTHANDLER_NIL_CONSTRAINTS 00088 } *scfiEventHandler; 00089 00090 protected: 00092 void Initialize16(); 00093 00095 void Initialize32(); 00096 00098 bool EnterFullscreenMode(); 00099 00101 void ExitFullscreenMode(); 00102 00104 virtual bool ToggleFullscreen(); 00105 00107 void FadeToRGB(CGDirectDisplayID disp, float r, float g, float b); 00108 00110 void FadeToGammaTable(CGDirectDisplayID disp, GammaTable table); 00111 00113 void SaveGamma(CGDirectDisplayID disp, GammaTable &table); 00114 00116 void ChooseDisplay(); 00117 00119 CFDictionaryRef originalMode; 00121 GammaTable originalGamma; 00123 bool inFullscreenMode; 00125 CGDirectDisplayID display; 00127 unsigned int screen; 00128 00130 int origWidth, origHeight; 00131 00133 OSXDelegate2D delegate; 00135 csGraphics2D *canvas; 00136 00138 csRef<iOSXAssistant> assistant; 00140 csEventID focusChangedEvt; 00141 csEventID commandLineHelpEvt; 00142 csEventID keyboardDownEvt; 00144 iObjectRegistry *objectReg; 00145 }; 00146 00147 #else // __cplusplus 00148 00149 #define DRV2D_FUNC(ret, func) __private_extern__ ret OSXDriver2D_##func 00150 00151 typedef void *OSXDriver2D; 00152 typedef void *OSXEventHandle; 00153 typedef void *OSXViewHandle; 00154 00155 // C API to driver class 00156 DRV2D_FUNC(void, DispatchEvent)(OSXDriver2D driver, OSXEventHandle ev, 00157 OSXViewHandle view); 00158 DRV2D_FUNC(bool, Resize)(OSXDriver2D driver, int w, int h); 00159 DRV2D_FUNC(void, HideMouse)(OSXDriver2D driver); 00160 DRV2D_FUNC(void, ShowMouse)(OSXDriver2D driver); 00161 00162 #undef DRV2D_FUNC 00163 00164 #endif // __cplusplus 00165 00166 #endif // __CS_OSXDRIVER2D_H__
Generated for Crystal Space 2.0 by doxygen 1.6.1