1 /*
2 * vhfCompatibility.h
3 *
4 * Copyright (C) 2000-2013 by vhf interservice GmbH
5 * Author: Georg Fleischmann
6 *
7 * created: 2000-04-01
8 * modified: 2013-04-10 (VHFIsDrawingToScreen(): workaround for GNUstep Cairo backend)
9 * 2013-01-24 (use sel_isEqual() instead of sel_eq())
10 * 2012-01-06 (CGFloat, NSInteger)
11 * 2010-02-13 (NSAppKitVersionNumber##_# for Apple)
12 *
13 * This file is part of the vhf Shared Library.
14 *
15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the vhf Public License as
17 * published by the vhf interservice GmbH. Among other things,
18 * the License requires that the copyright notices and this notice
19 * be preserved on all copies.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24 * See the vhf Public License for more details.
25 *
26 * You should have received a copy of the vhf Public License along
27 * with this library; see the file LICENSE. If not, write to vhf.
28 *
29 * If you want to link this library to your proprietary software,
30 * or for other uses which are not covered by the definitions
31 * laid down in the vhf Public License, vhf also offers a proprietary
32 * license scheme. See the vhf internet pages or ask for details.
33 *
34 * vhf interservice GmbH, Im Marxle 3, 72119 Altingen, Germany
35 * eMail: info@vhf.de
36 * http://www.vhf.de
37 */
38
39 #ifndef VHF_H_COMPATIBILITY
40 #define VHF_H_COMPATIBILITY
41
42 #include <AppKit/AppKit.h>
43 #include "types.h"
44
45 /* GNUstep
46 */
47 #if defined( GNUSTEP_BASE_VERSION )
48
49 //# define VHFIsDrawingToScreen() ( [[NSGraphicsContext currentContext] isDrawingToScreen] )
VHFIsDrawingToScreen()50 static __inline__ BOOL VHFIsDrawingToScreen()
51 { NSGraphicsContext *gc = [NSGraphicsContext currentContext];
52 return ( [gc isDrawingToScreen] ||
53 [[[gc attributes] valueForKey:@"NSDeviceIsScreen"] hasPrefix:@"Y"] ); // 2013-04-10, workaround: Cairo
54 }
55 # define VHFSelectorIsEqual(a, b) sel_isEqual(a, b)
56 //# define VHFSelectorIsEqual(a, b) sel_eq(a, b)
57 # define VHFAntialiasing() [[NSGraphicsContext currentContext] shouldAntialias]
58 # define VHFSetAntialiasing(f) [[NSGraphicsContext currentContext] setShouldAntialias:f]
59 # define PSWait() [[NSGraphicsContext currentContext] flushGraphics]
60
61 /* MAC OS X
62 */
63 #elif defined ( __APPLE__ )
64
65 # define VHFIsDrawingToScreen() [[NSGraphicsContext currentContext] isDrawingToScreen]
66 //# define VHFSelectorIsEqual(a, b) sel_isEqual(a, b) // same as '=='
67 # define VHFSelectorIsEqual(a, b) a == b
68 # define VHFAntialiasing() [[NSGraphicsContext currentContext] shouldAntialias]
69 # define VHFSetAntialiasing(f) [[NSGraphicsContext currentContext] setShouldAntialias:f]
70 # define PSWait() [[NSGraphicsContext currentContext] flushGraphics]
71 # define PSgsave() [NSGraphicsContext saveGraphicsState]
72 # define PSgrestore() [NSGraphicsContext restoreGraphicsState]
PScomposite(float x,float y,float w,float h,int gstateNum,float dx,float dy,int op)73 static __inline__ void PScomposite(float x, float y, float w, float h, int gstateNum, float dx, float dy, int op) { }
74 /* add definitions missing in OS X 10.4 (2012-01-06) */
75 //# ifndef CGFloat
76 # if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
77 # if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
78 typedef long NSInteger;
79 typedef unsigned long NSUInteger;
80 typedef double CGFloat;
81 # else
82 typedef int NSInteger;
83 typedef unsigned int NSUInteger;
84 typedef float CGFloat;
85 # endif
86 # endif
87
88 // for runtime version checks use if (NSAppKitVersionNumber ><= ):
89 # ifndef NSAppKitVersionNumber10_4
90 # define NSAppKitVersionNumber10_4 824
91 # endif
92 # ifndef NSAppKitVersionNumber10_5
93 # define NSAppKitVersionNumber10_5 949
94 # endif
95 # ifndef NSAppKitVersionNumber10_6
96 # define NSAppKitVersionNumber10_6 1038
97 # endif
98 # ifndef NSAppKitVersionNumber10_7
99 # define NSAppKitVersionNumber10_7 1138
100 # endif
101 # ifndef NSAppKitVersionNumber10_8
102 # define NSAppKitVersionNumber10_8 1187
103 # endif
104
105 // for compile time version checks use:
106 // #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
107 // MAC_OS_X_VERSION_MIN_REQUIRED
108
109 /* OpenStep
110 */
111 #else
112
113 # include <NSBezierPath.h>
114 //# include <AppKit/psops.h>
115 # define VHFIsDrawingToScreen() [[NSDPSContext currentContext] isDrawingToScreen]
116 # define VHFSelectorIsEqual(a, b) a == b
117 # define VHFAntialiasing() NO
118 # define VHFSetAntialiasing(f)
119 # define NSGraphicsContext NSDPSContext
120 # define NSBackspaceCharacter NSBackspaceKey
121 # define NSDeleteCharacter NSDeleteKey
122
123 #endif
124
125 #endif // VHF_H_COMPATIBILITY
126