1 /* $XConsortium: airport.h /main/5 1995/07/15 20:44:29 drk $ */
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 Data Structure
32  *
33  *
34  *    Created: Vania JOLOBOFF / May 1992
35  *
36  *
37  * ======================================================================
38  *
39  */
40 
41 /*
42  * ===================== include ========================================
43  */
44 
45 #if (! defined airport_h)
46 #define airport_h
47 
48 #include <stdlib.h>
49 #include <stdio.h>
50 #include <Xm/XmAll.h>
51 
52 /* ======================================================================
53  *  General Types
54  */
55 
56 typedef struct _Source {
57    Widget departure;
58    Widget over_ocean;
59    Widget over_land;
60    Widget over_site;
61    Widget landing;
62    Widget landed;
63 } SourceRec, *Source;
64 
65 typedef struct _Destination {
66    Widget enter;
67    Widget leave;
68    Widget landing;
69    Widget parked;
70    int gate;
71 } DestinationRec, *Destination;
72 
73 typedef struct _Spot {
74    Boolean empty;
75    Position x,y;
76 } SpotRec, *Spot;
77 
78 typedef enum {empty, normal, full} ParkState ;
79 
80 typedef struct _Park {
81    ParkState state;
82    GC gc;
83    int spot_count;
84    int plane_count;
85    Spot spots; /* variable length array of spots */
86 } ParkRec, *Park;
87 
88 typedef struct _Track {
89    int borderwidth;
90    XRectangle bbox;
91    GC gc;
92 } TrackRec, *Track;
93 
94 typedef enum {closed, open} AirportState ;
95 
96 /*
97  * The airport data structure consists of
98  * 	- the widget needed in various callbacks
99  *	- the drag source data
100  *	- the drop site data
101  *	- the details of the track graphics
102  */
103 
104 typedef struct _Airport {
105    XtAppContext context;
106    Display * display;
107    Window ocean;
108    int screen_width;
109    int screen_height;
110    AirportState state;
111    Widget main; /* the main window */
112    Widget airport; /* the airport drawing area */
113    Widget help_dialog;
114    Widget error_dialog;
115    Widget warning_dialog;
116    Widget dragIcon;
117    Widget msg_area;
118    SourceRec from; /* the drag data */
119    DestinationRec to; /* drop site data */
120    ParkRec park; /* info on available gates at the airport */
121    TrackRec track; /* info on track graphics */
122 } AirportRec, *Airport;
123 
124 /*
125  * A flight has a flight number. It starts from some airport (from)
126  * When landing, it will be taxi-ed to some gate.
127  */
128 
129 typedef struct _Flight {
130    long number;
131    int gate;     /* the gate it's going to be taxi-ed */
132    Airport from; /* the airport it took off */
133 } FlightRec, *Flight;
134 
135 /* ======================================================================
136  * Global constants
137  */
138 
139 #define plane_width 25
140 #define plane_height 25
141 
142 /* ======================================================================
143  * Global variables
144  */
145 
146 #ifdef DECLAREGLOBAL
147 #define global
148 #else
149 #define global extern
150 #endif
151 
152 global Atom FlightAtom;
153 global Atom DeleteAtom;
154 
155 /*
156  * Application Resources
157  */
158 
159 global struct _AirportResources {
160    String too_small;
161    Pixel spot_background;
162    Pixel spot_foreground;
163    Pixel flight_background;
164    Pixel flight_foreground;
165    Pixel invalid_foreground;
166    Pixel valid_foreground;
167    Pixel none_foreground;
168    Pixel track_background;
169    Pixel track_foreground;
170    Pixel drag_under_background;
171    Pixel drag_under_foreground;
172    Dimension track_border_width;
173    Dimension track_margin;
174    int bell_duration;
175    int bell_percent;
176 } AirportResources;
177 
178 global void DrawAirport(Airport this, Window wd, Pixel bg, Pixel fg);
179 /* draw the tracks and parked planes */
180 
181 global void Paging(Airport this, String msg);
182 /* display a message in message area */
183 
184 
185 #endif /* airport_h */
186