Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
OSXDriver2D.h
00001 // 00002 // OSXDriver2D.h 00003 // 00004 // 00005 // Created by mreda on Wed Oct 31 2001. 00006 // Copyright (c) 2001 Matt Reda. All rights reserved. 00007 // 00008 00009 00010 // This code must be callable from the ObjC delegate. Since that uses the 00011 // standard C compiler, it doesn't like C++ classes, so we create a C API to 00012 // some functions of this object 00013 00014 #ifndef __CS_OSXDRIVER2D_H__ 00015 #define __CS_OSXDRIVER2D_H__ 00016 00017 #if defined(__cplusplus) 00018 00019 #include "OSXDelegate2D.h" 00020 00021 #include "csgeom/csrect.h" 00022 #include "csutil/macosx/OSXAssistant.h" 00023 #include "iutil/eventh.h" 00024 #include "ivideo/graph2d.h" 00025 #include "csplugincommon/canvas/graph2d.h" 00026 00027 #include <CoreFoundation/CoreFoundation.h> 00028 #include <ApplicationServices/ApplicationServices.h> 00029 00030 00031 // Table for storing gamma values 00032 struct GammaTable 00033 { 00034 float r[256]; 00035 float g[256]; 00036 float b[256]; 00037 }; 00038 00039 00040 class OSXDriver2D 00041 { 00042 public: 00043 // Constructor 00044 OSXDriver2D(csGraphics2D *inCanvas); 00045 00046 // Destructor 00047 virtual ~OSXDriver2D(); 00048 00049 // Initialize 2D plugin 00050 virtual bool Initialize(iObjectRegistry *reg); 00051 00052 // Open graphics system (set mode, open window, etc) 00053 virtual bool Open(); 00054 00055 // Close graphics system 00056 virtual void Close(); 00057 00058 // Flip video page (or dump to framebuffer) - pure virtual 00059 virtual void Print(csRect const* area = 0) = 0; 00060 00061 // Pure virtual function - the driver must invlude code to handle resizing 00062 virtual bool Resize(int w, int h) = 0; 00063 00064 // Handle an event 00065 virtual bool HandleEvent(iEvent &ev); 00066 00067 // Dispatch an event to the assistant 00068 inline void DispatchEvent(OSXEvent ev, OSXView view); 00069 00070 // Show/Hide the mouse 00071 virtual void HideMouse(); 00072 virtual void ShowMouse(); 00073 00074 // Event handler 00075 struct EventHandler : public iEventHandler 00076 { 00077 private: 00078 OSXDriver2D *parent; 00079 public: 00080 SCF_DECLARE_IBASE; 00081 EventHandler(OSXDriver2D *p) 00082 { 00083 SCF_CONSTRUCT_IBASE(0); 00084 parent = p; 00085 }; 00086 virtual ~EventHandler() 00087 { 00088 SCF_DESTRUCT_IBASE(); 00089 }; 00090 virtual bool HandleEvent (iEvent& e) { return parent->HandleEvent(e); } 00091 } *scfiEventHandler; 00092 00093 protected: 00094 // Initialize pixel format for 16 bit depth 00095 void Initialize16(); 00096 00097 // Initialize pixel format for 32 bit depth 00098 void Initialize32(); 00099 00100 // Switch to fullscreen mode 00101 bool EnterFullscreenMode(); 00102 00103 // Switch out of fullscreen mode, to mode stored in originalMode 00104 void ExitFullscreenMode(); 00105 00106 // Toggle current state of fullscreen 00107 virtual bool ToggleFullscreen(); 00108 00109 // Uses CoreGraphics to fade to a given color 00110 void FadeToRGB(CGDirectDisplayID disp, float r, float g, float b); 00111 00112 // Fade to a given gamma table 00113 void FadeToGammaTable(CGDirectDisplayID disp, GammaTable table); 00114 00115 // Save the current gamma values to the given table 00116 void SaveGamma(CGDirectDisplayID disp, GammaTable &table); 00117 00118 // Choose which display to use 00119 void ChooseDisplay(); 00120 00121 CFDictionaryRef originalMode; // Original display mode 00122 GammaTable originalGamma; // Original gamma values 00123 bool inFullscreenMode; // In full-screen mode 00124 CGDirectDisplayID display; // Screen to display on 00125 uint32_t screen; // Screen number to display on 00126 00127 int origWidth, origHeight; // Original dimensions kept so they can 00128 // be restored when switching modes 00129 00130 OSXDelegate2D delegate; // Delegate for ObjC stuff 00131 csGraphics2D *canvas; // Canvas (parent class) 00132 00133 csRef<iOSXAssistant> assistant; // Assistant for dispatching events 00134 iObjectRegistry *objectReg; // Object registry 00135 }; 00136 00137 #else // __cplusplus 00138 00139 #define DRV2D_FUNC(ret, func) __private_extern__ inline ret OSXDriver2D_##func 00140 00141 typedef void *OSXDriver2D; 00142 typedef void *OSXEventHandle; 00143 typedef void *OSXViewHandle; 00144 00145 // C API to driver class 00146 DRV2D_FUNC(void, DispatchEvent)(OSXDriver2D driver, OSXEventHandle ev, 00147 OSXViewHandle view); 00148 DRV2D_FUNC(bool, Resize)(OSXDriver2D driver, int w, int h); 00149 DRV2D_FUNC(void, HideMouse)(OSXDriver2D driver); 00150 DRV2D_FUNC(void, ShowMouse)(OSXDriver2D driver); 00151 00152 #undef DRV2D_FUNC 00153 00154 #endif // __cplusplus 00155 00156 #endif // __CS_OSXDRIVER2D_H__
Generated for Crystal Space by doxygen 1.3.9.1