From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / OSX / SaverRunner.h
1 /* xscreensaver, Copyright (c) 2006-2016 Jamie Zawinski <jwz@jwz.org>
2  *
3  * Permission to use, copy, modify, distribute, and sell this software and its
4  * documentation for any purpose is hereby granted without fee, provided that
5  * the above copyright notice appear in all copies and that both that
6  * copyright notice and this permission notice appear in supporting
7  * documentation.  No representations are made about the suitability of this
8  * software for any purpose.  It is provided "as is" without express or 
9  * implied warranty.
10  */
11
12 #ifdef USE_IPHONE
13 # import <Foundation/Foundation.h>
14 # import <UIKit/UIKit.h>
15 # import <OpenGLES/EAGL.h>
16 # import <OpenGLES/ES1/gl.h>
17 # import <OpenGLES/ES1/glext.h>
18 # import <QuartzCore/QuartzCore.h>
19 # define NSView  UIView
20 # define NSRect  CGRect
21 # define NSSize  CGSize
22 # define NSColor UIColor
23 # define NSImage UIImage
24 # define NSEvent UIEvent
25 # define NSWindow UIWindow
26 # define NSButton UIButton
27 # define NSApplication UIApplication
28 # define NSScreen UIScreen
29 #else
30 # import <Cocoa/Cocoa.h>
31 # import <ScreenSaver/ScreenSaver.h>
32 #endif
33
34 #import <XScreenSaverView.h>
35
36 #ifdef USE_IPHONE
37
38 @class SaverRunner;
39
40 @interface SaverViewController : UIViewController
41 {
42   SaverRunner *_parent;
43   NSString *_saverName;
44   XScreenSaverView *_saverView;
45
46   /* When a the SaverViewController is presented, iOS automatically changes
47      the status bar orientation. (And, by extension, the notification center
48      orientation.) But there's no willPresentAsModal: event for a
49      UIViewController so that it knows when this is going to happen, and the
50      other event handlers occur after the status bar is changed. So save the
51      orientation just before the view controller is modal-presented, and
52      restore the proper status bar orientation just before the saverView is
53      created so it can pick it up in didRotate:. */
54   // UIInterfaceOrientation _storedOrientation;
55
56   BOOL _showAboutBox;
57   UIView *aboutBox;
58   NSTimer *splashTimer;
59 }
60
61 @property(nonatomic, retain) NSString *saverName;
62
63 @end
64
65 #endif
66
67 @interface SaverRunner : NSObject
68 # ifdef USE_IPHONE
69   <XScreenSaverViewDelegate>
70 # else
71   <NSWindowDelegate>
72 # endif
73 {
74   NSString *saverName;          // the one currently loaded
75   NSArray  *saverNames;         // Names of available savers
76   NSString *saverDir;           // Where we find saver bundles
77
78 # ifndef USE_IPHONE
79
80   NSBundle *saverBundle;
81   NSArray  *windows;
82   IBOutlet NSMenu *menubar;
83   NSTimer *anim_timer;
84
85 # else  // USE_IPHONE
86
87   UINavigationController *rotating_nav;         // Hierarchy 1 (UI)
88   IBOutlet UIWindow *window;
89   IBOutlet UIView *view;
90
91   SaverViewController *nonrotating_controller;  // Hierarchy 2 (savers)
92
93   UIImage *saved_screenshot;
94
95 # endif // USE_IPHONE
96 }
97
98 - (XScreenSaverView *) newSaverView: (NSString *) module
99                            withSize: (NSSize) size;
100 - (void) loadSaver: (NSString *)name;
101 - (void) selectedSaverDidChange:(NSDictionary *)change;
102
103 #ifndef USE_IPHONE
104 - (void) openPreferences: (id)sender;
105 #else  // USE_IPHONE
106 - (UIImage *) screenshot;
107 - (NSString *) makeDesc:(NSString *)saver
108                yearOnly:(BOOL) yearp;
109 #endif // USE_IPHONE
110
111 @end