summaryrefslogtreecommitdiff
path: root/src/video/cocoa/cocoa_wnd.h
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2020-12-26 16:07:47 +0100
committerMichael Lutz <michi@icosahedron.de>2021-01-03 13:25:32 +0100
commit9ccef816f90e9a7e3042cd89141ba3c0956d7bb9 (patch)
tree906ca656f585147070658dc14211b31c0689a83e /src/video/cocoa/cocoa_wnd.h
parentab7da117e066983d076f540b9722e1b79cf01d98 (diff)
downloadopenttd-9ccef816f90e9a7e3042cd89141ba3c0956d7bb9.tar.xz
Codechange: [OSX] Re-arrange the OSX video driver code by combining all drawing code and moving the window/event handling to a different file.
This is just a code move/rename, not a functionality change.
Diffstat (limited to 'src/video/cocoa/cocoa_wnd.h')
-rw-r--r--src/video/cocoa/cocoa_wnd.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/video/cocoa/cocoa_wnd.h b/src/video/cocoa/cocoa_wnd.h
new file mode 100644
index 000000000..f395114db
--- /dev/null
+++ b/src/video/cocoa/cocoa_wnd.h
@@ -0,0 +1,77 @@
+/*
+ * This file is part of OpenTTD.
+ * 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.
+ * 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.
+ * 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/>.
+ */
+
+/** @file cocoa_wnd.h OS interface for the cocoa video driver. */
+
+#ifndef COCOA_WND_H
+#define COCOA_WND_H
+
+#import <Cocoa/Cocoa.h>
+
+class CocoaSubdriver;
+
+extern NSString *OTTDMainLaunchGameEngine;
+
+/** Category of NSCursor to allow cursor showing/hiding */
+@interface NSCursor (OTTD_QuickdrawCursor)
++ (NSCursor *) clearCocoaCursor;
+@end
+
+/** Subclass of NSWindow to cater our special needs */
+@interface OTTD_CocoaWindow : NSWindow {
+ CocoaSubdriver *driver;
+}
+
+- (void)setDriver:(CocoaSubdriver*)drv;
+
+- (void)miniaturize:(id)sender;
+- (void)display;
+- (void)setFrame:(NSRect)frameRect display:(BOOL)flag;
+- (void)appDidHide:(NSNotification*)note;
+- (void)appWillUnhide:(NSNotification*)note;
+- (void)appDidUnhide:(NSNotification*)note;
+- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag;
+@end
+
+/** Subclass of NSView to fix Quartz rendering and mouse awareness */
+@interface OTTD_CocoaView : NSView <NSTextInputClient>
+{
+ CocoaSubdriver *driver;
+ NSTrackingRectTag trackingtag;
+}
+- (void)setDriver:(CocoaSubdriver*)drv;
+- (void)drawRect:(NSRect)rect;
+- (BOOL)isOpaque;
+- (BOOL)acceptsFirstResponder;
+- (BOOL)becomeFirstResponder;
+- (void)setTrackingRect;
+- (void)clearTrackingRect;
+- (void)resetCursorRects;
+- (void)viewWillMoveToWindow:(NSWindow *)win;
+- (void)viewDidMoveToWindow;
+- (void)mouseEntered:(NSEvent *)theEvent;
+- (void)mouseExited:(NSEvent *)theEvent;
+@end
+
+/** Delegate for our NSWindow to send ask for quit on close */
+@interface OTTD_CocoaWindowDelegate : NSObject <NSWindowDelegate>
+{
+ CocoaSubdriver *driver;
+}
+
+- (void)setDriver:(CocoaSubdriver*)drv;
+
+- (BOOL)windowShouldClose:(id)sender;
+- (void)windowDidEnterFullScreen:(NSNotification *)aNotification;
+- (void)windowDidChangeScreenProfile:(NSNotification *)aNotification;
+@end
+
+
+bool CocoaSetupApplication();
+void CocoaExitApplication();
+
+#endif /* COCOA_WND_H */