Merge from emacs-23; up to 2010-06-10T12:56:11Z!michael.albinus@gmx.de.
[emacs.git] / src / nsgui.h
bloba695563094153d2beced167e3d620888483ec633
1 /* Definitions and headers for communication on the NeXT/Open/GNUstep API.
2 Copyright (C) 1995, 2005, 2008-2011 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
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.
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.
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/>. */
19 #ifndef __NSGUI_H__
20 #define __NSGUI_H__
22 /* this gets included from a couple of the plain (non-NS) .c files */
23 #ifdef __OBJC__
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 */
33 #import <AppKit/AppKit.h>
35 #ifdef NS_IMPL_COCOA
36 #undef Cursor
37 #define init_process emacs_init_process
38 #endif /* NS_IMPL_COCOA */
39 #import <Foundation/NSDistantObject.h>
41 #ifdef NS_IMPL_COCOA
42 #include <AvailabilityMacros.h>
43 #endif /* NS_IMPL_COCOA */
45 #endif /* __OBJC__ */
48 /* menu-related */
49 #define free_widget_value(wv) xfree (wv)
50 #define malloc_widget_value() ((widget_value *) memset (xmalloc \
51 (sizeof (widget_value)), 0, sizeof (widget_value)))
53 /* Emulate XCharStruct. */
54 typedef struct _XCharStruct
56 int rbearing;
57 int lbearing;
58 int width;
59 int ascent;
60 int descent;
61 } XCharStruct;
63 /* Fake tructure from Xlib.h to represent two-byte characters. */
64 #ifndef __OBJC__
65 typedef unsigned short unichar;
66 #endif
67 typedef unichar XChar2b;
69 #define STORE_XCHAR2B(chp, b1, b2) \
70 (*(chp) = ((XChar2b)((((b1) & 0x00ff) << 8) | ((b2) & 0x00ff))))
72 #define XCHAR2B_BYTE1(chp) \
73 (((*chp) & 0xff00) >> 8)
75 #define XCHAR2B_BYTE2(chp) \
76 ((*chp) & 0x00ff)
79 /* XXX: xfaces requires these structures, but the question is are we
80 forced to use them? */
81 typedef struct _XGCValues
83 unsigned long foreground;
84 unsigned long background;
85 #ifdef __OBJC__
86 struct ns_font *font;
87 #else
88 void *font;
89 #endif
90 } XGCValues;
92 typedef XGCValues * GC;
94 #define GCForeground 0x01
95 #define GCBackground 0x02
96 #define GCFont 0x03
98 #ifdef __OBJC__
99 typedef id Pixmap;
100 #else
101 typedef void *Pixmap;
102 #endif
104 #ifdef __OBJC__
105 typedef NSCursor * Cursor;
106 #else
107 typedef void *Cursor;
108 #endif
110 #define No_Cursor (0)
112 #ifdef __OBJC__
113 typedef NSColor * Color;
114 #else
115 typedef void * Color;
116 #endif
117 typedef int Window;
118 typedef int Display;
120 /* Xism */
121 typedef Lisp_Object XrmDatabase;
124 /* some sort of attempt to normalize rectangle handling.. seems a bit much
125 for what is accomplished */
126 typedef struct {
127 int x, y;
128 unsigned width, height;
129 } XRectangle;
131 #ifndef __OBJC__
132 #if defined(__LP64__) && __LP64__
133 typedef double CGFloat;
134 #else
135 typedef float CGFloat;
136 #endif
137 typedef struct _NSPoint { CGFloat x, y; } NSPoint;
138 typedef struct _NSSize { CGFloat width, height; } NSSize;
139 typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect;
140 #endif /* NOT OBJC */
142 #define NativeRectangle NSRect
144 #define CONVERT_TO_XRECT(xr, nr) \
145 ((xr).x = (nr).origin.x, \
146 (xr).y = (nr).origin.y, \
147 (xr).width = (nr).size.width, \
148 (xr).height = (nr).size.height)
150 #define CONVERT_FROM_XRECT(xr, nr) \
151 ((nr).origin.x = (xr).x, \
152 (nr).origin.y = (xr).y, \
153 (nr).size.width = (xr).width, \
154 (nr).size.height = (xr).height)
156 #define STORE_NATIVE_RECT(nr, px, py, pwidth, pheight) \
157 ((nr).origin.x = (px), \
158 (nr).origin.y = (py), \
159 (nr).size.width = (pwidth), \
160 (nr).size.height = (pheight))
165 /* This stuff needed by frame.c. */
166 #define ForgetGravity 0
167 #define NorthWestGravity 1
168 #define NorthGravity 2
169 #define NorthEastGravity 3
170 #define WestGravity 4
171 #define CenterGravity 5
172 #define EastGravity 6
173 #define SouthWestGravity 7
174 #define SouthGravity 8
175 #define SouthEastGravity 9
176 #define StaticGravity 10
178 #define NoValue 0x0000
179 #define XValue 0x0001
180 #define YValue 0x0002
181 #define WidthValue 0x0004
182 #define HeightValue 0x0008
183 #define AllValues 0x000F
184 #define XNegative 0x0010
185 #define YNegative 0x0020
187 #define USPosition (1L << 0) /* user specified x, y */
188 #define USSize (1L << 1) /* user specified width, height */
190 #define PPosition (1L << 2) /* program specified position */
191 #define PSize (1L << 3) /* program specified size */
192 #define PMinSize (1L << 4) /* program specified minimum size */
193 #define PMaxSize (1L << 5) /* program specified maximum size */
194 #define PResizeInc (1L << 6) /* program specified resize increments */
195 #define PAspect (1L << 7) /* program specified min, max aspect ratios */
196 #define PBaseSize (1L << 8) /* program specified base for incrementing */
197 #define PWinGravity (1L << 9) /* program specified window gravity */
199 #endif /* __NSGUI_H__ */