From http://www.jwz.org/xscreensaver/xscreensaver-5.18.tar.gz
[xscreensaver] / OSX / XScreenSaverView.h
1 /* xscreensaver, Copyright (c) 2006-2012 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 /* This is a subclass of Apple's ScreenSaverView that knows how to run
13    xscreensaver programs without X11 via the dark magic of the "jwxyz"
14    library.  In xscreensaver terminology, this is the replacement for
15    the "screenhack.c" module.
16  */
17
18 #ifdef USE_IPHONE
19 # import <Foundation/Foundation.h>
20 # import <UIKit/UIKit.h>
21 # define NSView  UIView
22 # define NSRect  CGRect
23 # define NSSize  CGSize
24 # define NSColor UIColor
25 # define NSImage UIImage
26 # define NSEvent UIEvent
27 # define NSWindow UIWindow
28 #else
29 # import <Cocoa/Cocoa.h>
30 # import <ScreenSaver/ScreenSaver.h>
31 #endif
32
33
34 #import "screenhackI.h"
35 #import "PrefsReader.h"
36
37 #ifdef USE_IPHONE
38 @interface ScreenSaverView : NSView
39 - (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview;
40 - (NSTimeInterval)animationTimeInterval;
41 - (void)setAnimationTimeInterval:(NSTimeInterval)timeInterval;
42 - (void)startAnimation;
43 - (void)stopAnimation;
44 - (BOOL)isAnimating;
45 - (void)animateOneFrame;
46 - (BOOL)hasConfigureSheet;
47 //- (NSWindow*)configureSheet;
48 - (UIViewController*)configureView;
49 - (BOOL)isPreview;
50 @end
51
52 #endif // USE_IPHONE
53
54
55 @interface XScreenSaverView : ScreenSaverView
56 # ifdef USE_IPHONE
57                               <UIAlertViewDelegate>
58 # endif
59 {
60   struct xscreensaver_function_table *xsft;
61   PrefsReader *prefsReader;
62
63   BOOL setup_p;            // whether xsft->setup_cb() has been run
64   BOOL initted_p;          // whether xsft->init_cb() has been run
65   BOOL resized_p;          // whether to run the xsft->reshape_cb() soon
66   double next_frame_time;  // time_t in milliseconds of when to tick the frame
67
68   // Data used by the Xlib-flavored screensaver
69   Display *xdpy;
70   Window xwindow;
71   void *xdata;
72   fps_state *fpst;
73
74 # ifdef USE_IPHONE
75   UIDeviceOrientation orientation, new_orientation;
76   double tap_time;
77   CGPoint tap_point;
78   BOOL screenLocked;
79
80   GLfloat rotation_ratio;       // ratio thru rotation anim, or -1
81   NSSize rot_from, rot_to;      // start size rect, end size rect
82   GLfloat angle_from, angle_to; // start angle, end angle
83   double rot_start_time;
84
85   NSSize rot_current_size;
86   GLfloat rot_current_angle;
87
88   CGContextRef backbuffer;
89   NSSize backbuffer_size;
90
91   NSTimer *crash_timer;
92
93 # endif // USE_IPHONE
94
95 }
96
97 - (id)initWithFrame:(NSRect)frame saverName:(NSString*)n isPreview:(BOOL)p;
98
99 - (void) render_x11;
100 - (void) prepareContext;
101 - (void) resizeContext;
102 - (NSUserDefaultsController *) userDefaultsController;
103
104 #ifdef USE_IPHONE
105 - (void)didRotate:(NSNotification *)notification;
106 - (void)setScreenLocked:(BOOL)locked;
107 - (void)createBackbuffer;
108 #endif // USE_IPHONE
109
110 @end