1 /* $TOG: main.h /main/5 1997/03/31 13:46:32 dbl $ */
2 /*
3  * Motif
4  *
5  * Copyright (c) 1987-2012, The Open Group. All rights reserved.
6  *
7  * These libraries and programs are free software; you can
8  * redistribute them and/or modify them under the terms of the GNU
9  * Lesser General Public License as published by the Free Software
10  * Foundation; either version 2 of the License, or (at your option)
11  * any later version.
12  *
13  * These libraries and programs are distributed in the hope that
14  * they will be useful, but WITHOUT ANY WARRANTY; without even the
15  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16  * PURPOSE. See the GNU Lesser General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with these librararies and programs; if not, write
21  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
22  * Floor, Boston, MA 02110-1301 USA
23  */
24 /*
25  * HISTORY
26  */
27 
28 /*
29  * The Airport Drag And Drop Demo
30  *
31  *    Airport Main Header File
32  *
33  *
34  * The airport demo is a totally useless program to illustrate
35  * Drag and Drop in Motif 1.2.
36  * It consists of an airport containing
37  *	- plane icons that can be dragged
38  *	- tracks where planes can be dropped (land)
39  *	- a radio box that shows current state of outcoming flights
40  *	- a raido box that shows current state of incoming flights
41  *	- a message area that lists successive interesting messages.
42  *
43  * The demo is more interesting when two instances of this program
44  * are run simultaneously.
45  *
46  * Each time a plane is dragged, a flight number is randomly created
47  * and the plane is announced to leave in the message area.
48  *
49  * Each time a plane is dropped onto an airport, if a gate is available,
50  * the plane is taxi-ed to this gate. The data transferred between the
51  * source airport and the destination airport is the flight number.
52  * The arriving flight is announced in the message area.
53  * If the destination airport is saturated (no gate available) the drop
54  * is rejected.
55  * If the data transfer fails because the network is down or the source
56  * client died, or whatever reason, the plane is announced to have crashed.
57  *
58  *
59  *    Created: Vania JOLOBOFF / May 1992
60  * ======================================================================
61  *
62  */
63 
64 #define DECLAREGLOBAL
65 
66 #include "airport.h"
67 #include "dragsource.h"
68 #include "dropsite.h"
69 
70 #include <Xm/XmAll.h>
71 
72 /* ======================================================================
73  *  Constants
74  */
75 
76 #define MIN_TRACK_SIZE	16
77 
78 /*
79  * The flying plane icon
80  */
81 
82 #define flying_icon_width 30
83 #define flying_icon_height 31
84 static unsigned char flying_bits[] = {
85    0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00,
86    0x00, 0x70, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
87    0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0xe0, 0x01, 0x00,
88    0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00,
89    0x00, 0xc0, 0x0f, 0x00, 0xf8, 0xff, 0xff, 0x0f, 0xfc, 0xff, 0xff, 0x1f,
90    0xfe, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x0f,
91    0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00,
92    0x00, 0xc0, 0x03, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0xe0, 0x01, 0x00,
93    0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00,
94    0x00, 0x70, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00,
95    0x00, 0x00, 0x00, 0x00};
96 
97 #define flying_mask_width 30
98 #define flying_mask_height 31
99 static unsigned char flying_mask_bits[] = {
100    0x00, 0x38, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00,
101    0x00, 0xf8, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00,
102    0x00, 0xf0, 0x01, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x03, 0x00,
103    0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00,
104    0xf8, 0xff, 0xff, 0x0f, 0xfc, 0xff, 0xff, 0x1f, 0xfe, 0xff, 0xff, 0x3f,
105    0xff, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x1f,
106    0xf8, 0xff, 0xff, 0x0f, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xe0, 0x07, 0x00,
107    0x00, 0xe0, 0x07, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x03, 0x00,
108    0x00, 0xf0, 0x01, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0xf8, 0x00, 0x00,
109    0x00, 0xf8, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00,
110    0x00, 0x38, 0x00, 0x00};
111 
112 /*
113  * The parked plane icon
114  */
115 
116 static unsigned char plane_bits[] = {
117    0x07, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
118    0x7e, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x01,
119    0xf8, 0xff, 0xff, 0x01, 0xf0, 0xff, 0xff, 0x01, 0xe0, 0xff, 0xff, 0x00,
120    0xe0, 0xff, 0x7f, 0x00, 0xe0, 0xff, 0x0f, 0x00, 0xe0, 0xff, 0x00, 0x00,
121    0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x01, 0x00, 0xe0, 0xff, 0x03, 0x00,
122    0xe0, 0xff, 0x07, 0x00, 0xe0, 0xe7, 0x0f, 0x00, 0xe0, 0xc7, 0x1f, 0x00,
123    0xe0, 0x87, 0x3f, 0x00, 0xe0, 0x07, 0x7f, 0x00, 0xe0, 0x03, 0xfe, 0x00,
124    0xe0, 0x03, 0xfc, 0x01, 0xe0, 0x03, 0xf8, 0x01, 0xe0, 0x01, 0xf0, 0x01,
125    0xe0, 0x00, 0xe0, 0x01};
126 
127 static XtResource AirportResourcesSpecs[] =
128 {
129    { "tooSmall", XtCString, XtRString, sizeof(String),
130        XtOffsetOf( struct _AirportResources, too_small), XtRImmediate,
131        (XtPointer) "Window too small, enlarge please" },
132    {
133       "trackBackground", XmCBackground, XmRPixel, sizeof (Pixel),
134       XtOffsetOf( struct _AirportResources, track_background),
135       XtRString, (XtPointer)"XtDefaultBackground"
136      },
137    {
138       "spotBackground", XmCBackground, XmRPixel, sizeof (Pixel),
139       XtOffsetOf( struct _AirportResources, spot_background),
140       XtRString, (XtPointer)"XtDefaultBackground"
141      },
142    {
143       "flyingBackground", XmCBackground, XmRPixel, sizeof (Pixel),
144       XtOffsetOf( struct _AirportResources, flight_background),
145       XtRString, (XtPointer)"XtDefaultBackground"
146   },
147    {
148       "dragUnderBackground", XmCBackground, XmRPixel, sizeof(Pixel),
149       XtOffsetOf( struct _AirportResources, drag_under_background),
150       XtRString, (XtPointer)"XtDefaultForeground"
151     },
152    {
153       "trackForeground", XmCForeground, XmRPixel, sizeof(Pixel),
154       XtOffsetOf( struct _AirportResources, track_foreground),
155       XtRString,(XtPointer)"XtDefaultForeground"
156     },
157    {
158       "dragUnderForeground", XmCForeground, XmRPixel, sizeof(Pixel),
159       XtOffsetOf( struct _AirportResources, drag_under_foreground),
160       XtRString,(XtPointer)"XtDefaultForeground"
161     },
162    {
163       "spotForeground", XmCForeground, XmRPixel, sizeof (Pixel),
164       XtOffsetOf( struct _AirportResources, spot_foreground),
165       XtRString,(XtPointer)"XtDefaultForeground"
166     },
167    {
168       "flyingForeground", XmCForeground, XmRPixel, sizeof (Pixel),
169       XtOffsetOf( struct _AirportResources, flight_foreground),
170       XtRString,(XtPointer)"XtDefaultForeground"
171     },
172    {
173       "invalidForeground", XmCForeground, XmRPixel, sizeof (Pixel),
174       XtOffsetOf( struct _AirportResources, invalid_foreground),
175       XtRString,(XtPointer)"XtDefaultForeground"
176     },
177    {
178       "validForeground", XmCHighlightColor, XmRPixel, sizeof (Pixel),
179       XtOffsetOf( struct _AirportResources, valid_foreground),
180       XtRString,(XtPointer)"XtDefaultForeground"
181     },
182    {
183       "noneForeground", XmCHighlightColor, XmRPixel, sizeof (Pixel),
184       XtOffsetOf( struct _AirportResources, none_foreground),
185       XtRString,(XtPointer)"XtDefaultForeground"
186     },
187    {
188      "trackBorderWidth", XmCBorderWidth, XmRDimension, sizeof(Dimension),
189      XtOffsetOf( struct _AirportResources, track_border_width),
190      XmRImmediate, (XtPointer) 5
191     },
192    {
193       "trackMargin", XmCDimension, XmRDimension, sizeof(Dimension),
194       XtOffsetOf( struct _AirportResources, track_margin),
195       XmRImmediate, (XtPointer)  16
196    },
197    {
198       "bellDuration", XmCMaxValue, XmRInt, sizeof(int),
199       XtOffsetOf( struct _AirportResources, bell_duration),
200       XmRImmediate, (XtPointer)  100
201    },
202    {
203       "bellPercent", XmCMaxValue, XmRInt, sizeof(int),
204       XtOffsetOf( struct _AirportResources, bell_percent),
205       XmRImmediate, (XtPointer) 100
206    }
207 };
208