13 #include "../video_driver.hpp" 17 const char *
Start(
const char *
const *param)
override;
28 void MakeDirty(
int left,
int top,
int width,
int height)
override;
59 const char *
GetName()
const override {
return "cocoa"; }
89 # define MAX_DIRTY_RECTS 100 90 Rect dirty_rects[MAX_DIRTY_RECTS];
110 virtual void Draw(
bool force_update =
false) = 0;
118 virtual void MakeDirty(
int left,
int top,
int width,
int height) = 0;
121 virtual void UpdatePalette(uint first_color, uint num_colors) = 0;
123 virtual uint ListModes(OTTD_Point *modes, uint max_modes) = 0;
135 virtual bool IsFullscreen() = 0;
145 virtual int GetWidth() = 0;
150 virtual int GetHeight() = 0;
155 virtual void *GetPixelBuffer() = 0;
161 virtual CGPoint PrivateLocalToCG(NSPoint *p) = 0;
167 virtual NSPoint GetMouseLocation(NSEvent *event) = 0;
173 virtual bool MouseIsInsideView(NSPoint *pt) = 0;
178 virtual bool IsActive() = 0;
191 CocoaSubdriver *QZ_CreateFullscreenSubdriver(
int width,
int height,
int bpp);
193 #ifdef ENABLE_COCOA_QUICKDRAW 194 CocoaSubdriver *QZ_CreateWindowQuickdrawSubdriver(
int width,
int height,
int bpp);
197 #ifdef ENABLE_COCOA_QUARTZ 198 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 199 CocoaSubdriver *QZ_CreateWindowQuartzSubdriver(
int width,
int height,
int bpp);
203 void QZ_GameSizeChanged();
207 uint QZ_ListModes(OTTD_Point *modes, uint max_modes, CGDirectDisplayID display_id,
int display_depth);
211 + (NSCursor *) clearCocoaCursor;
221 - (void)miniaturize:(
id)sender;
223 - (void)setFrame:(NSRect)frameRect display:(BOOL)flag;
224 - (void)appDidHide:(NSNotification*)note;
225 - (void)appWillUnhide:(NSNotification*)note;
226 - (void)appDidUnhide:(NSNotification*)note;
227 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag;
232 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 233 # if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 234 <NSTextInputClient, NSTextInput>
243 NSTrackingRectTag trackingtag;
246 - (void)drawRect:(NSRect)rect;
248 - (BOOL)acceptsFirstResponder;
249 - (BOOL)becomeFirstResponder;
250 - (void)setTrackingRect;
251 - (void)clearTrackingRect;
252 - (void)resetCursorRects;
253 - (void)viewWillMoveToWindow:(NSWindow *)win;
254 - (void)viewDidMoveToWindow;
255 - (void)mouseEntered:(NSEvent *)theEvent;
256 - (void)mouseExited:(NSEvent *)theEvent;
261 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 270 - (BOOL)windowShouldClose:(
id)sender;
271 - (void)windowDidEnterFullScreen:(NSNotification *)aNotification;
272 - (void)windowDidChangeScreenProfile:(NSNotification *)aNotification;
bool ToggleFullscreen(bool fullscreen) override
Set a new window mode.
void EditBoxLostFocus() override
An edit box lost the input focus.
const char * GetName() const override
Return driver name.
bool ChangeResolution(int w, int h) override
Change window resolution.
int window_height
Current window height in pixel.
Category of NSCursor to allow cursor showing/hiding.
Delegate for our NSWindow to send ask for quit on close.
id cocoaview
Pointer to view object.
virtual bool WindowResized()
Whether the window was successfully resized.
void * window_buffer
Colour translation from palette to screen.
void MakeDirty(int left, int top, int width, int height) override
Mark dirty a screen region.
virtual bool ToggleFullscreen()
Toggle between fullscreen and windowed mode.
Base for all driver factories.
void * pixel_buffer
used for direct pixel access
int device_width
Width of device in pixel.
int device_depth
Colour depth of device in bit.
void Stop() override
Stop the video driver.
Generic display driver for cocoa On grounds to not duplicate some code, it contains a few variables w...
const char * Start(const char *const *param) override
Start this driver.
A driver for communicating with the user.
bool active
Whether the window is visible.
virtual void SetPortAlphaOpaque()
Makes the game region of the window 100% opaque.
Subclass of NSWindow to cater our special needs.
bool AfterBlitterChange() override
Callback invoked after the blitter was changed.
int buffer_depth
Colour depth of used frame buffer.
Driver * CreateInstance() const override
Create an instance of this driver-class.
int num_dirty_rects
Number of dirty rectangles.
void MainLoop() override
Programme main loop.
The base of all video drivers.
CGContextRef cgcontext
Context reference for Quartz subdriver.
int device_height
Height of device in pixel.
Specification of a rectangle with absolute coordinates of all edges.
virtual ~CocoaSubdriver()
Initialize driver.
id window
Pointer to window object.
int window_width
Current window width in pixel.
Subclass of NSView to fix Quartz rendering and mouse awareness.