| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# 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 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     CS_EVENTHANDLER_NAMES ("crystalspace.macosx.driver2d")
    00092     CS_EVENTHANDLER_NIL_CONSTRAINTS
    00093   } *scfiEventHandler;
    00094
    00095 protected:
    00097   void Initialize16();
    00098
    00100   void Initialize32();
    00101
    00103   bool EnterFullscreenMode();
    00104
    00106   void ExitFullscreenMode();
    00107
    00109   virtual bool ToggleFullscreen();
    00110
    00112   void FadeToRGB(CGDirectDisplayID disp, float r, float g, float b);
    00113
    00115   void FadeToGammaTable(CGDirectDisplayID disp, GammaTable table);
    00116
    00118   void SaveGamma(CGDirectDisplayID disp, GammaTable &table);
    00119
    00121   void ChooseDisplay();
    00122
    00124   CFDictionaryRef originalMode;
    00126   GammaTable originalGamma;
    00128   bool inFullscreenMode;
    00130   CGDirectDisplayID display;
    00132   unsigned int screen;
    00133
    00135   int origWidth, origHeight;
    00136
    00138   OSXDelegate2D delegate;
    00140   csGraphics2D *canvas;
    00141
    00143   csRef<iOSXAssistant> assistant;
    00145   csEventID focusChangedEvt;
    00146   csEventID commandLineHelpEvt;
    00147   csEventID keyboardDownEvt;
    00149   iObjectRegistry *objectReg;
    00150 };
    00151
    00152 #else // __cplusplus
    00153
    00154 #define DRV2D_FUNC(ret, func) __private_extern__ ret OSXDriver2D_##func
    00155
    00156 typedef void *OSXDriver2D;
    00157 typedef void *OSXEventHandle;
    00158 typedef void *OSXViewHandle;
    00159
    00160 // C API to driver class
    00161 DRV2D_FUNC(void, DispatchEvent)(OSXDriver2D driver, OSXEventHandle ev,
    00162   OSXViewHandle view);
    00163 DRV2D_FUNC(bool, Resize)(OSXDriver2D driver, int w, int h);
    00164 DRV2D_FUNC(void, HideMouse)(OSXDriver2D driver);
    00165 DRV2D_FUNC(void, ShowMouse)(OSXDriver2D driver);
    00166
    00167 #undef DRV2D_FUNC
    00168
    00169 #endif // __cplusplus
    00170
    00171 #endif // __CS_OSXDRIVER2D_H__