| 1 | /* Definitions and headers for communication on the NeXT/Open/GNUstep API. |
| 2 | Copyright (C) 1995, 2005, 2008-2011 Free Software Foundation, Inc. |
| 3 | |
| 4 | This file is part of GNU Emacs. |
| 5 | |
| 6 | GNU Emacs is free software: you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation, either version 3 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | GNU Emacs is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | #ifndef __NSGUI_H__ |
| 20 | #define __NSGUI_H__ |
| 21 | |
| 22 | /* this gets included from a couple of the plain (non-NS) .c files */ |
| 23 | #ifdef __OBJC__ |
| 24 | |
| 25 | #ifdef NS_IMPL_COCOA |
| 26 | #ifdef Z |
| 27 | #warning "Z is defined. If you get a later parse error in a header, check that buffer.h or other files #define-ing Z are not included." |
| 28 | #endif /* Z */ |
| 29 | #define Cursor FooFoo |
| 30 | #undef init_process |
| 31 | #endif /* NS_IMPL_COCOA */ |
| 32 | |
| 33 | #undef verify |
| 34 | |
| 35 | #import <AppKit/AppKit.h> |
| 36 | |
| 37 | #ifdef NS_IMPL_COCOA |
| 38 | #undef Cursor |
| 39 | #define init_process emacs_init_process |
| 40 | #endif /* NS_IMPL_COCOA */ |
| 41 | #import <Foundation/NSDistantObject.h> |
| 42 | |
| 43 | #ifdef NS_IMPL_COCOA |
| 44 | #include <AvailabilityMacros.h> |
| 45 | #endif /* NS_IMPL_COCOA */ |
| 46 | |
| 47 | #endif /* __OBJC__ */ |
| 48 | |
| 49 | #undef verify |
| 50 | #undef _GL_VERIFY_H |
| 51 | #include <verify.h> |
| 52 | |
| 53 | /* menu-related */ |
| 54 | #define free_widget_value(wv) xfree (wv) |
| 55 | #define malloc_widget_value() ((widget_value *) memset (xmalloc \ |
| 56 | (sizeof (widget_value)), 0, sizeof (widget_value))) |
| 57 | |
| 58 | /* Emulate XCharStruct. */ |
| 59 | typedef struct _XCharStruct |
| 60 | { |
| 61 | int rbearing; |
| 62 | int lbearing; |
| 63 | int width; |
| 64 | int ascent; |
| 65 | int descent; |
| 66 | } XCharStruct; |
| 67 | |
| 68 | /* Fake tructure from Xlib.h to represent two-byte characters. */ |
| 69 | #ifndef __OBJC__ |
| 70 | typedef unsigned short unichar; |
| 71 | #endif |
| 72 | typedef unichar XChar2b; |
| 73 | |
| 74 | #define STORE_XCHAR2B(chp, b1, b2) \ |
| 75 | (*(chp) = ((XChar2b)((((b1) & 0x00ff) << 8) | ((b2) & 0x00ff)))) |
| 76 | |
| 77 | #define XCHAR2B_BYTE1(chp) \ |
| 78 | (((*chp) & 0xff00) >> 8) |
| 79 | |
| 80 | #define XCHAR2B_BYTE2(chp) \ |
| 81 | ((*chp) & 0x00ff) |
| 82 | |
| 83 | |
| 84 | /* XXX: xfaces requires these structures, but the question is are we |
| 85 | forced to use them? */ |
| 86 | typedef struct _XGCValues |
| 87 | { |
| 88 | unsigned long foreground; |
| 89 | unsigned long background; |
| 90 | #ifdef __OBJC__ |
| 91 | struct ns_font *font; |
| 92 | #else |
| 93 | void *font; |
| 94 | #endif |
| 95 | } XGCValues; |
| 96 | |
| 97 | typedef XGCValues * GC; |
| 98 | |
| 99 | #define GCForeground 0x01 |
| 100 | #define GCBackground 0x02 |
| 101 | #define GCFont 0x03 |
| 102 | |
| 103 | #ifdef __OBJC__ |
| 104 | typedef id Pixmap; |
| 105 | #else |
| 106 | typedef void *Pixmap; |
| 107 | #endif |
| 108 | |
| 109 | #ifdef __OBJC__ |
| 110 | typedef NSCursor * Cursor; |
| 111 | #else |
| 112 | typedef void *Cursor; |
| 113 | #endif |
| 114 | |
| 115 | #define No_Cursor (0) |
| 116 | |
| 117 | #ifdef __OBJC__ |
| 118 | typedef NSColor * Color; |
| 119 | #else |
| 120 | typedef void * Color; |
| 121 | #endif |
| 122 | typedef int Window; |
| 123 | typedef int Display; |
| 124 | |
| 125 | /* Xism */ |
| 126 | typedef Lisp_Object XrmDatabase; |
| 127 | |
| 128 | |
| 129 | /* some sort of attempt to normalize rectangle handling.. seems a bit much |
| 130 | for what is accomplished */ |
| 131 | typedef struct { |
| 132 | int x, y; |
| 133 | unsigned width, height; |
| 134 | } XRectangle; |
| 135 | |
| 136 | #ifndef __OBJC__ |
| 137 | #if defined (__LP64__) && __LP64__ |
| 138 | typedef double CGFloat; |
| 139 | #else |
| 140 | typedef float CGFloat; |
| 141 | #endif |
| 142 | typedef struct _NSPoint { CGFloat x, y; } NSPoint; |
| 143 | typedef struct _NSSize { CGFloat width, height; } NSSize; |
| 144 | typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect; |
| 145 | #endif /* NOT OBJC */ |
| 146 | |
| 147 | #define NativeRectangle NSRect |
| 148 | |
| 149 | #define CONVERT_TO_XRECT(xr, nr) \ |
| 150 | ((xr).x = (nr).origin.x, \ |
| 151 | (xr).y = (nr).origin.y, \ |
| 152 | (xr).width = (nr).size.width, \ |
| 153 | (xr).height = (nr).size.height) |
| 154 | |
| 155 | #define CONVERT_FROM_XRECT(xr, nr) \ |
| 156 | ((nr).origin.x = (xr).x, \ |
| 157 | (nr).origin.y = (xr).y, \ |
| 158 | (nr).size.width = (xr).width, \ |
| 159 | (nr).size.height = (xr).height) |
| 160 | |
| 161 | #define STORE_NATIVE_RECT(nr, px, py, pwidth, pheight) \ |
| 162 | ((nr).origin.x = (px), \ |
| 163 | (nr).origin.y = (py), \ |
| 164 | (nr).size.width = (pwidth), \ |
| 165 | (nr).size.height = (pheight)) |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | /* This stuff needed by frame.c. */ |
| 171 | #define ForgetGravity 0 |
| 172 | #define NorthWestGravity 1 |
| 173 | #define NorthGravity 2 |
| 174 | #define NorthEastGravity 3 |
| 175 | #define WestGravity 4 |
| 176 | #define CenterGravity 5 |
| 177 | #define EastGravity 6 |
| 178 | #define SouthWestGravity 7 |
| 179 | #define SouthGravity 8 |
| 180 | #define SouthEastGravity 9 |
| 181 | #define StaticGravity 10 |
| 182 | |
| 183 | #define NoValue 0x0000 |
| 184 | #define XValue 0x0001 |
| 185 | #define YValue 0x0002 |
| 186 | #define WidthValue 0x0004 |
| 187 | #define HeightValue 0x0008 |
| 188 | #define AllValues 0x000F |
| 189 | #define XNegative 0x0010 |
| 190 | #define YNegative 0x0020 |
| 191 | |
| 192 | #define USPosition (1L << 0) /* user specified x, y */ |
| 193 | #define USSize (1L << 1) /* user specified width, height */ |
| 194 | |
| 195 | #define PPosition (1L << 2) /* program specified position */ |
| 196 | #define PSize (1L << 3) /* program specified size */ |
| 197 | #define PMinSize (1L << 4) /* program specified minimum size */ |
| 198 | #define PMaxSize (1L << 5) /* program specified maximum size */ |
| 199 | #define PResizeInc (1L << 6) /* program specified resize increments */ |
| 200 | #define PAspect (1L << 7) /* program specified min, max aspect ratios */ |
| 201 | #define PBaseSize (1L << 8) /* program specified base for incrementing */ |
| 202 | #define PWinGravity (1L << 9) /* program specified window gravity */ |
| 203 | |
| 204 | #endif /* __NSGUI_H__ */ |
| 205 | |