# cocoa_v.h

Go to the documentation of this file.

    00001 /* $Id$ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef VIDEO_COCOA_H
    00013 #define VIDEO_COCOA_H
    00014
    00015 #include <AvailabilityMacros.h>
    00016
    00017 #include "../video_driver.hpp"
    00018
    00019 class VideoDriver_Cocoa: public VideoDriver {
    00020 public:
    00021   /* virtual */ const char *Start(const char * const *param);
    00022
    00023   /* virtual */ void Stop();
    00024
    00025   /* virtual */ void MakeDirty(int left, int top, int width, int height);
    00026
    00027   /* virtual */ void MainLoop();
    00028
    00029   /* virtual */ bool ChangeResolution(int w, int h);
    00030
    00031   /* virtual */ bool ToggleFullscreen(bool fullscreen);
    00032
    00033   /* virtual */ const char *GetName() const { return "cocoa"; }
    00034 };
    00035
    00036 class FVideoDriver_Cocoa: public VideoDriverFactory<FVideoDriver_Cocoa> {
    00037 public:
    00038   static const int priority = 10;
    00039   /* virtual */ const char *GetName() { return "cocoa"; }
    00040   /* virtual */ const char *GetDescription() { return "Cocoa Video Driver"; }
    00041   /* virtual */ Driver *CreateInstance() { return new VideoDriver_Cocoa(); }
    00042 };
    00043
    00044
    00045
    00046 class CocoaSubdriver {
    00047 public:
    00048   virtual ~CocoaSubdriver() {}
    00049
    00050   virtual void Draw(bool force_update = false) = 0;
    00051   virtual void MakeDirty(int left, int top, int width, int height) = 0;
    00052   virtual void UpdatePalette(uint first_color, uint num_colors) = 0;
    00053
    00054   virtual uint ListModes(OTTD_Point *modes, uint max_modes) = 0;
    00055
    00056   virtual bool ChangeResolution(int w, int h) = 0;
    00057
    00058   virtual bool IsFullscreen() = 0;
    00059   virtual int GetWidth() = 0;
    00060   virtual int GetHeight() = 0;
    00061   virtual void *GetPixelBuffer() = 0;
    00062
    00063   /* Convert local coordinate to window server (CoreGraphics) coordinate */
    00064   virtual CGPoint PrivateLocalToCG(NSPoint *p) = 0;
    00065
    00066   virtual NSPoint GetMouseLocation(NSEvent *event) = 0;
    00067   virtual bool MouseIsInsideView(NSPoint *pt) = 0;
    00068
    00069   virtual bool IsActive() = 0;
    00070 };
    00071
    00072 extern CocoaSubdriver *_cocoa_subdriver;
    00073
    00074 CocoaSubdriver *QZ_CreateFullscreenSubdriver(int width, int height, int bpp);
    00075
    00076 #ifdef ENABLE_COCOA_QUICKDRAW
    00077 CocoaSubdriver *QZ_CreateWindowQuickdrawSubdriver(int width, int height, int bpp);
    00078 #endif
    00079
    00080 #ifdef ENABLE_COCOA_QUARTZ
    00081 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
    00082 CocoaSubdriver *QZ_CreateWindowQuartzSubdriver(int width, int height, int bpp);
    00083 #endif
    00084 #endif
    00085
    00086 void QZ_GameSizeChanged();
    00087
    00088 void QZ_GameLoop();
    00089
    00090 void QZ_ShowMouse();
    00091 void QZ_HideMouse();
    00092
    00093 uint QZ_ListModes(OTTD_Point *modes, uint max_modes, CGDirectDisplayID display_id, int display_depth);
    00094
    00095 #endif /* VIDEO_COCOA_H */