Add 2012 to FSF copyright years for Emacs files (do not merge to trunk)
[bpt/emacs.git] / src / nsgui.h
CommitLineData
edfda783 1/* Definitions and headers for communication on the NeXT/Open/GNUstep API.
49f70d46 2 Copyright (C) 1995, 2005, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
edfda783
AR
3
4This file is part of GNU Emacs.
5
32d235f8 6GNU Emacs is free software: you can redistribute it and/or modify
edfda783 7it under the terms of the GNU General Public License as published by
32d235f8
GM
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
edfda783
AR
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
32d235f8 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
edfda783
AR
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
edfda783
AR
33#import <AppKit/AppKit.h>
34
edfda783
AR
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>
40
41#ifdef NS_IMPL_COCOA
42#include <AvailabilityMacros.h>
43#endif /* NS_IMPL_COCOA */
44
45#endif /* __OBJC__ */
46
47
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)))
52
53/* Emulate XCharStruct. */
54typedef struct _XCharStruct
55{
56 int rbearing;
57 int lbearing;
58 int width;
59 int ascent;
60 int descent;
61} XCharStruct;
62
3fe53a83 63/* Fake tructure from Xlib.h to represent two-byte characters. */
edfda783
AR
64#ifndef __OBJC__
65typedef unsigned short unichar;
66#endif
67typedef unichar XChar2b;
68
69#define STORE_XCHAR2B(chp, b1, b2) \
70 (*(chp) = ((XChar2b)((((b1) & 0x00ff) << 8) | ((b2) & 0x00ff))))
71
72#define XCHAR2B_BYTE1(chp) \
73 (((*chp) & 0xff00) >> 8)
74
75#define XCHAR2B_BYTE2(chp) \
76 ((*chp) & 0x00ff)
77
edfda783 78
df2142db
AR
79/* XXX: xfaces requires these structures, but the question is are we
80 forced to use them? */
edfda783
AR
81typedef struct _XGCValues
82{
15034960
AR
83 unsigned long foreground;
84 unsigned long background;
edfda783 85#ifdef __OBJC__
edfda783
AR
86 struct ns_font *font;
87#else
edfda783
AR
88 void *font;
89#endif
90} XGCValues;
91
92typedef XGCValues * GC;
93
94#define GCForeground 0x01
95#define GCBackground 0x02
96#define GCFont 0x03
97
98#ifdef __OBJC__
99typedef id Pixmap;
100#else
101typedef void *Pixmap;
102#endif
103
104#ifdef __OBJC__
105typedef NSCursor * Cursor;
106#else
107typedef void *Cursor;
108#endif
109
110#define No_Cursor (0)
111
112#ifdef __OBJC__
113typedef NSColor * Color;
114#else
115typedef void * Color;
116#endif
117typedef int Window;
118typedef int Display;
119
120/* Xism */
121typedef Lisp_Object XrmDatabase;
122
123
3fe53a83
AR
124/* some sort of attempt to normalize rectangle handling.. seems a bit much
125 for what is accomplished */
edfda783
AR
126typedef struct {
127 int x, y;
128 unsigned width, height;
129} XRectangle;
130
131#ifndef __OBJC__
9094eb48
AR
132#if defined(__LP64__) && __LP64__
133typedef double CGFloat;
134#else
135typedef float CGFloat;
edfda783 136#endif
9094eb48
AR
137typedef struct _NSPoint { CGFloat x, y; } NSPoint;
138typedef struct _NSSize { CGFloat width, height; } NSSize;
139typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect;
140#endif /* NOT OBJC */
edfda783 141
9094eb48 142#define NativeRectangle NSRect
edfda783
AR
143
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)
149
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)
155
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))
161
162
163
164
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
177
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
186
187#define USPosition (1L << 0) /* user specified x, y */
188#define USSize (1L << 1) /* user specified width, height */
189
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 */
198
199#endif /* __NSGUI_H__ */
0ae1e5e5
MB
200
201/* arch-tag: b2af3275-62c3-45b4-9335-4c9635c67e55
202 (do not change this comment) */