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