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