Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / examples / motif / draganddrop / DNDDemo.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  * (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC. 
25  * ALL RIGHTS RESERVED 
26 */ 
27 /* 
28  * Motif Release 1.2.2
29 */ 
30 /*   $XConsortium: DNDDemo.h /main/4 1995/10/27 10:43:48 rswiston $ */
31 /*
32 *  (c) Copyright 1987, 1988, 1989 HEWLETT-PACKARD COMPANY */
33 /*
34  *    file: DNDDemo.h
35  *
36  *      Header file for the program DNDDemo.
37  */
38
39 #include <stdio.h>
40 #include <X11/Xatom.h>
41 #include <X11/Intrinsic.h>
42 #include <Xm/Xm.h>
43 #include <Xm/AtomMgr.h>
44 #include <Xm/MainW.h>
45 #include <Xm/DrawingA.h>
46 #include <Xm/SeparatoG.h>
47 #include <Xm/Form.h>
48 #include <Xm/RowColumn.h>
49 #include <Xm/PushB.h>
50 #include <Xm/MessageB.h>
51 #include <Xm/DragDrop.h>
52 #include <Xm/Screen.h>
53
54
55 /* The following is used to layout the color labels */
56 #define BOX_WIDTH       85
57 #define BOX_HEIGHT      25
58 #define BOX_X_OFFSET    95
59 #define BOX_Y_OFFSET    35
60 #define BOX_X_MARGIN    10
61 #define BOX_Y_MARGIN    10
62
63 /* The following are used in setting up the drag icons */
64 #define ICON_WIDTH          32
65 #define ICON_HEIGHT         32
66 #define SMALL_ICON_WIDTH    16
67 #define SMALL_ICON_HEIGHT   16
68 #define ICON_X_HOT          0
69 #define ICON_Y_HOT          0
70
71 /* Some scales or text entry field could be added to change this value */
72 #define RECT_WIDTH  20
73 #define RECT_HEIGHT 50
74
75 /* The following defines could be setup as application resources */
76 #define RECT_START_COLOR    "black"
77 #define HIGHLIGHT_THICKNESS 3
78 #define HIGHLIGHT_COLOR     "Black"   /* this is equivalent to gray60
79                                          in the R5 rgb.txt */
80 #define DRAW_AREA_BG_COLOR "white"
81 #define DRAW_AREA_FG_COLOR "black"     /* 5127 fix */
82 #define LABEL1_COLOR       "#ff5026"     /* a slight softer shade of red,
83                                             red was too dark */
84 #define LABEL2_COLOR    "orange"
85 #define LABEL3_COLOR    "yellow"
86 #define LABEL4_COLOR    "violet"
87 #define LABEL5_COLOR    "#00C3ff"           /* a blue green color,
88                                                blue was too dark */
89 #define LABEL6_COLOR    "green"
90
91 #define VALID_CURSOR_FG_COLOR   "black"
92 #define INVALID_CURSOR_FG_COLOR "maroon"
93 #define NONE_CURSOR_FG_COLOR    "maroon"
94
95
96 /*
97  * This struct is used to contain information about each rectangle 
98  * to use in the dislay routines
99  */
100 typedef struct _RectStruct {
101     Position x;
102     Position y;
103     Dimension width;
104     Dimension height;
105     Pixel color;
106     Pixmap pixmap;   /* currently not in use */
107 } RectStruct, *RectPtr;
108
109 /* This struct is used to hold global application information */
110 typedef struct _AppInfoRec {
111     GC rectGC;              /* graphic context used to draw the rectangles */
112     Pixel currentColor;     /* color that is currently in the GC */
113     RectPtr *rectDpyTable;  /* the rectangle display table */
114     int rectsAllocd;        /* keeps track of how much the above
115                                table has been alloc'd */
116     int numRects;           /* the number of rects that are visible */
117     RectPtr highlightRect;  /* the current highlighted rectangle */
118     RectPtr clearRect;      /* the rectangle that is being moved */
119     Boolean doMove;         /* indicates that a move is being performed */
120     Boolean creatingRect;   /* indicates that a rect create is being 
121                                performed */
122     unsigned char operation;/* indicates the drop help operation */
123     unsigned int maxCursorWidth;  /* the maximum allowable cursor width */
124     unsigned int maxCursorHeight; /* the maximum allowable cursor height */
125     Position rectX;
126     Position rectY;
127     Position rectX2;
128     Position rectY2;
129 } AppInfoRec, *AppInfo;
130
131 /*
132  * This struct is used to pass information
133  * from the dropProc to the transferProc
134  */
135 typedef struct _DropTransferRec {
136     Widget widget;
137     Position x;
138     Position y;
139 } DropTransferRec, *DropTransfer;
140
141 /*
142  * This struct is used to pass information
143  * from the rectangle dragStart proc to it's associated
144  * callback procs.
145  */
146 typedef struct _DragConvertRec {
147     Widget widget;
148     RectPtr rect;
149 } DragConvertRec, *DragConvertPtr;
150
151
152
153 extern void     InitializeAppInfo(void );
154 extern void     StartRect(Widget , XEvent *, String *, Cardinal *);
155 extern void     ExtendRect(Widget , XEvent *, String *, Cardinal *);
156 extern void     EndRect(Widget , XEvent *, String *, Cardinal *);
157 extern RectPtr  RectCreate(Position , Position , Dimension ,
158                           Dimension , Pixel , Pixmap );
159 extern RectPtr  RectFind(Position , Position );
160 extern void     RectSetColor(RectPtr , Display *, Window , Pixel );
161 extern Pixel    RectGetColor(RectPtr );
162 extern Pixmap   GetBitmapFromRect(Widget , RectPtr , Pixel , Pixel ,
163                                   Dimension *, Dimension *);
164 extern void     RectHide(Display *, Window , RectPtr );
165 extern void     RectFree(RectPtr );
166 extern void     RedrawRectangles(Widget );
167 extern void     RectDrawStippled(Display *, Window , RectPtr );
168 extern void     RectHighlight(Widget , RectPtr );
169 extern void     RectUnhighlight(Widget );
170 extern void     RectSetPixmap(RectPtr , Display *, Window , Pixmap );
171 extern void     RectRegister(RectPtr , Position , Position );
172 extern void     InitializeRectDpyTable(void );
173 extern void     CreateLayout(void );
174 extern void     CreateRectGC(void );
175 extern Pixel    GetColor(char *);
176 extern void     ColorRect(Widget , XEvent *, String *, Cardinal *);
177
178
179
180 /* The following character arrays hold the bits for
181  * the source and state icons for both 32x32 and 16x16 drag icons.
182  * The source is a color palatte icon and the state is a paint brush icon.
183  */
184 extern unsigned char SOURCE_ICON_BITS[];
185 extern unsigned char SOURCE_ICON_MASK[];
186 extern unsigned char STATE_ICON_BITS[];
187 extern unsigned char STATE_ICON_MASK[];
188 extern unsigned char INVALID_ICON_BITS[];
189 extern unsigned char SMALL_SOURCE_ICON_BITS[];
190 extern unsigned char SMALL_SOURCE_ICON_MASK[];
191 extern unsigned char SMALL_STATE_ICON_BITS[];
192 extern unsigned char SMALL_STATE_ICON_MASK[];
193 extern unsigned char SMALL_INVALID_ICON_BITS[];
194
195 /* The folowing character arrays are for use with the drop help
196  * dialogs.  For internationalization, message catalogs should
197  * replace these static declarations.
198  */
199 extern char HELP_MSG1[];
200 extern char HELP_MSG2[];
201 extern char HELP_MSG3[];
202 extern char HELP_MSG4[];
203 extern char HELP_MSG5[];
204
205
206 /* Globals variables */
207 extern AppInfo      appInfo;
208 extern Widget       topLevel;
209 extern Widget       drawingArea;
210 extern Widget       helpDialog;
211 extern Widget       helpLabel, helpMenu;
212 extern XtAppContext appContext;
213