Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtappbuilder / src / ab / x_util.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23  
24 /*
25  *      $XConsortium: x_util.h /main/3 1995/11/06 17:57:58 rswiston $
26  *
27  * @(#)x_util.h 1.16 21 Apr 1994      cde_app_builder/src/ab
28  *
29  *      RESTRICTED CONFIDENTIAL INFORMATION:
30  *
31  *      The information in this document is subject to special
32  *      restrictions in a confidential disclosure agreement between
33  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
34  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
35  *      Sun's specific written approval.  This document and all copies
36  *      and derivative works thereof must be returned or destroyed at
37  *      Sun's request.
38  *
39  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
40  *
41  */
42
43 /*
44  * ab_x_util.h 
45  */
46 #ifndef _X_UTIL_H_
47 #define _X_UTIL_H_
48
49 #include <X11/Intrinsic.h>
50 #include <X11/StringDefs.h>
51
52 #ifndef min
53 #define min(a,b) ((a) < (b)? (a):(b))
54 #endif
55
56 #ifndef max
57 #define max(a,b) ((a) > (b)? (a):(b))
58 #endif
59
60 extern int      x_load_cursor_bitmaps(
61                     Widget          w
62                 );
63 extern void     x_get_widget_rect(
64                     Widget      w, 
65                     XRectangle *r
66                 );
67 extern void     x_get_rect_bounding(
68                     XRectangle *r1, 
69                     XRectangle *r2
70                 );
71 extern void     x_graphics_op(
72                     Display     *dpy,
73                     Drawable    dest,
74                     GC          gc,
75                     int         x,
76                     int         y,
77                     int         width,
78                     int      height,
79                     Pixmap   src
80                 );
81 extern void     x_get_widget_rect(
82                     Widget     widget, 
83                     XRectangle *rect
84                 );
85 extern void     x_adjust_rect_margin(
86                     XRectangle *r, 
87                     int            m
88                 );                     
89 extern void     x_box(
90                     Widget     widget, 
91                     Drawable   win, 
92                     int            x0, 
93                     int            y0, 
94                     int            x1, 
95                     int            y1
96                 );
97 extern void     x_box_r(
98                     Widget       widget, 
99                     XRectangle  *r
100                 );
101 extern void     x_dashed_box_r(
102                     Widget      widget, 
103                     Drawable    drawable, 
104                     XRectangle  *r
105                 );
106 extern void     x_fullscreen_box(
107                     Widget          widget,
108                     Drawable        rootwin,
109                     int             x0,
110                     int             y0,
111                     int             x1,
112                     int             y1
113                 );
114 extern void     x_fullscreen_preview_box(
115                     Widget          widget,
116                     Drawable        rootwin,
117                     int             x0,
118                     int             y0,
119                     int             x1,
120                     int             y1
121                 );
122 extern void     x_conn_fullscreen_init(
123                     Widget          w,
124                     Drawable    root_win
125                 );
126 extern void     x_conn_fullscreen_chord(
127                     Widget    w,
128                     Drawable rootwin,
129                     int    x0,
130                     int    y0,
131                     int    x1,
132                     int    y1
133                 );
134 extern void     x_fullscreen_chord(
135                     Widget          widget,
136                     Drawable    rootwin,
137                     int             x0,
138                     int             y0,
139                     int             x1,
140                     int             y1
141                 );
142 extern void     x_conn_fullscreen_cleanup(
143                     Widget          w
144                 );
145 extern unsigned int    
146                 x_contrast_color(
147                     Widget          w
148                 );
149 extern Boolean  x_widget_translate_xy(
150                     Widget          src, 
151                     XtPointer   dst, 
152                     int             src_x, 
153                     int             src_y,
154                     int             *p_dst_x, 
155                     int             *p_dst_y
156                 );
157 extern Boolean  x_rootxy_inside_widget(
158                     Widget          w, 
159                     int             rootx, 
160                     int             rooty
161                 );
162 extern Window   x_xwin_at_rootxy(
163                     Widget      widget,
164                     int         x,
165                     int         y,
166                     int         *p_wx,
167                     int         *p_wy
168                 );
169 extern Cursor   x_create_cursor(
170                     Widget              widget,
171                     Window              root_win,                
172                     unsigned char       bits[],
173                     unsigned short      width,
174                     unsigned short      height,
175                     unsigned int        xhot,
176                     unsigned int        yhot
177                 );
178
179 extern Cursor   x_create_stencil_cursor(
180                     Widget widget, 
181                     Pixmap pixmap, 
182                     unsigned short width, 
183                     unsigned short height,
184                     unsigned int xhot, 
185                     unsigned int yhot
186                 );
187
188 extern int      x_get_num_pending_expose_events(Display *display);
189
190
191 /*************************************************************************
192 **                                                                      **
193 **       Macros                                                         **
194 **                                                                      **
195 **************************************************************************/
196 #define rect_right(r)   (short)((r)->x + (short)(r)->width)
197 #define rect_bottom(r)  (short)((r)->y + (short)(r)->height)
198
199 #define rect_includespoint(r,p_x,p_y) \
200         ((p_x) >= (r)->x && (p_y) >= (r)->y && \
201          (p_x)< (short)((r)->x+(short)(r)->width) && \
202          (p_y)< (short)((r)->y+(short)(r)->height))
203
204 #define rect_includesrect(r1, r2) \
205         ((r2)->x >= (r1)->x && (r2)->y >= (r1)->y && \
206          ((r2)->x + (short)(r2)->width)  <= ((r1)->x + (short)(r1)->width) && \
207          ((r2)->y + (short)(r2)->height) <= ((r1)->y + (short)(r1)->height))
208
209 #define rect_equal(r1,r2) \
210         ((r1)->x==(r2)->x && (r1)->width==(r2)->width && \
211          (r1)->y==(r2)->y && (r1)->height==(r2)->height)
212
213 #define rect_zero_out(r) \
214     { (r)->x=0;(r)->y=0;(r)->width=0;(r)->height=0; }
215
216 #define rect_isnull(r) \
217     ((r)->width==0 && (r)->height==0)
218
219 /*************************************************************************
220 **                                                                      **
221 **       Extern Data                                                    **
222 **                                                                      **
223 **************************************************************************/
224 extern Pixmap           AB_cp_cursor_pixmap, AB_mv_cursor_pixmap;
225 extern unsigned short   AB_cp_cursor_height, AB_cp_cursor_width;
226 extern unsigned short   AB_mv_cursor_height, AB_mv_cursor_width;
227
228 #endif /* _X_UTIL_H_ */
229