1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
|
#define PURIFY /*GG_220596
Liberation memoire lors de la destruction d'une fenetre*/
#define S3593 /*GG130398
OPTIMISATION MFT -> Desactiver temporairement le clipping
*/
#include <Xw_Extension.h>
/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_WINDOW
#define TRACE_CLOSE_WINDOW
#endif
/*
XW_EXT_WINDOW* Xw_def_window (adisplay,window,istransparent);
XW_EXT_DISPLAY *adisplay ;
Aspect_Handle window XWindow ID
int istransparent
Create the Window Extension info
and save Window attributes
Returns ERROR if the connection failed.
Returns extended data window structure pointer
if the connection done.
XW_STATUS Xw_close_window (awindow,destroy):
XW_EXT_WINDOW *awindow
int destroy
Close the window(s) and free all structures attached to
NOTE than this Close all windows if awindow is NULL
Destroy the XWindow if destroy is TRUE;
returns ERROR NO Extended Window address has been defined
returns SUCCESS if successful
*/
#ifdef XW_PROTOTYPE
void* Xw_def_window (void *adisplay,Aspect_Handle window,int istransparent)
#else
void* Xw_def_window (adisplay,window,istransparent)
void *adisplay ;
Aspect_Handle window ;
int istransparent ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_DISPLAY *pdisplay = (XW_EXT_DISPLAY*)adisplay ;
XW_EXT_WINDOW *pwindow = NULL ;
XW_WINDOWSTATE state ;
//XWindowAttributes attributes ;
XGCValues gc_values;
int mask,maskext ;
//XEvent event ;
//int i,j,status,xc,yc,width,height ;
int i,xc,yc,width,height ;
if( !Xw_isdefine_display(pdisplay) ) {
/*ERROR*Bad EXT_DISPLAY Address*/
Xw_set_error(96,"Xw_def_window",pdisplay) ;
return (NULL) ;
}
if( !(pwindow = Xw_add_window_structure(sizeof(XW_EXT_WINDOW))) )
return (NULL) ;
_DRAWABLE = _WINDOW = window ;
_PIXMAP = 0 ;
_NWBUFFER = 0 ;
_FWBUFFER = 0 ;
_BWBUFFER = 0 ;
_COLORMAP = NULL ;
_WIDTHMAP = NULL ;
_TYPEMAP = NULL ;
_FONTMAP = NULL ;
_TILEMAP = NULL ;
_MARKMAP = NULL ;
pwindow->connexion = pdisplay ;
state = Xw_get_window_position(pwindow,&xc,&yc,&width,&height) ;
if( state == XW_WS_UNKNOWN ) {
/*ERROR*Bad Window Attributes*/
Xw_del_window_structure(pwindow) ;
Xw_set_error(54,"Xw_def_window",&window) ;
return (NULL) ;
}
pwindow->axleft = xc - width/2 ;
pwindow->axright = xc + width/2 ;
pwindow->aytop = yc - height/2 ;
pwindow->aybottom = yc + height/2 ;
pwindow->rwidth = 0 ;
pwindow->rheight = 0 ;
pwindow->lineindex = 0 ;
pwindow->polyindex = 0 ;
pwindow->textindex = 0 ;
pwindow->markindex = 0 ;
if( istransparent ) {
pwindow->backindex = -1 ;
} else {
pwindow->backindex = 0 ;
}
pwindow->clipflag = True;
for( i=0 ; i<MAXEVENT ; i++ ) {
pwindow->ecbk[i].function = NULL ;
pwindow->ecbk[i].userdata = NULL ;
pwindow->icbk[i].function = NULL ;
}
gc_values.function = GXcopy ; mask = GCFunction ;
gc_values.plane_mask = AllPlanes ; mask |= GCPlaneMask ;
gc_values.background = BlackPixelOfScreen(_SCREEN) ;
mask |= GCBackground ;
gc_values.foreground = WhitePixelOfScreen(_SCREEN) ;
mask |= GCForeground ;
pwindow->qgwind.gc = XCreateGC(_DISPLAY,_WINDOW, mask, &gc_values) ;
gc_values.foreground = BlackPixelOfScreen(_SCREEN) ;
pwindow->qgwind.gcclear = XCreateGC(_DISPLAY,_WINDOW, mask, &gc_values);
gc_values.graphics_exposures = False ; mask |= GCGraphicsExposures ;
gc_values.foreground = WhitePixelOfScreen(_SCREEN) ;
pwindow->qgwind.gccopy = XCreateGC(_DISPLAY,_WINDOW, mask, &gc_values) ;
gc_values.function = GXxor ;
gc_values.graphics_exposures = True ;
pwindow->qgwind.gchigh = XCreateGC(_DISPLAY,_WINDOW, mask, &gc_values) ;
gc_values.function = GXcopy ;
pwindow->qgwind.code = ~0 ;
pwindow->qgwind.pimage = NULL ;
pwindow->qgwind.method = Aspect_FM_NONE ;
pwindow->qgwind.pixmap = 0 ;
_BINDEX = 0 ;
for( i=0 ; i<MAXBUFFERS ; i++ ) {
_BUFFER(i).bufferid = 0 ;
_BUFFER(i).gcf = NULL ;
_BUFFER(i).gcb = NULL ;
_BUFFER(i).code = 0 ;
_BUFFER(i).isdrawn = False ;
_BUFFER(i).isempty = True ;
_BUFFER(i).isretain = False ;
_BUFFER(i).isupdated = False ;
_BUFFER(i).rxmin = _WIDTH ;
_BUFFER(i).rymin = _HEIGHT ;
_BUFFER(i).rxmax = 0 ;
_BUFFER(i).rymax = 0 ;
_BUFFER(i).xpivot = 0 ;
_BUFFER(i).ypivot = 0 ;
_BUFFER(i).dxpivot = 0 ;
_BUFFER(i).dypivot = 0 ;
_BUFFER(i).xscale = 1. ;
_BUFFER(i).yscale = 1. ;
_BUFFER(i).dxscale = 1. ;
_BUFFER(i).dyscale = 1. ;
_BUFFER(i).angle = 0. ;
_BUFFER(i).dangle = 0. ;
_BUFFER(i).ptextdesc = NULL ;
_BUFFER(i).plinedesc = NULL ;
_BUFFER(i).ppntlist = NULL ;
_BUFFER(i).pseglist = NULL ;
_BUFFER(i).plinelist = NULL ;
_BUFFER(i).ppolylist = NULL ;
_BUFFER(i).plarclist = NULL ;
_BUFFER(i).pparclist = NULL ;
_BUFFER(i).pltextlist = NULL ;
_BUFFER(i).pptextlist = NULL ;
_BUFFER(i).plmarklist = NULL ;
_BUFFER(i).ppmarklist = NULL ;
_BUFFER(i).pimaglist = NULL ;
}
for( i=0 ; i<MAXQG ; i++ ) {
gc_values.line_width = 0 ; maskext = GCLineWidth ;
gc_values.line_style = LineSolid ; maskext |= GCLineStyle ;
gc_values.dash_offset = 0 ; maskext |= GCDashOffset ;
gc_values.join_style = JoinRound ; maskext |= GCJoinStyle ;
pwindow->qgline[i].code = ~0 ;
pwindow->qgline[i].count = 0 ;
pwindow->qgline[i].gc = XCreateGC(_DISPLAY,_WINDOW,
mask | maskext, &gc_values) ;
pwindow->qgmark[i].code = ~0;
pwindow->qgmark[i].count = 0 ;
pwindow->qgmark[i].gc = XCreateGC(_DISPLAY,_WINDOW,
mask | maskext, &gc_values) ;
gc_values.fill_style = FillSolid ; maskext = GCFillStyle ;
gc_values.fill_rule = EvenOddRule ; maskext |= GCFillRule ;
pwindow->qgpoly[i].code = ~0 ;
pwindow->qgpoly[i].count = 0 ;
pwindow->qgpoly[i].gc = XCreateGC(_DISPLAY,_WINDOW,
mask | maskext, &gc_values) ;
maskext = 0 ;
pwindow->qgtext[i].code = ~0;
pwindow->qgtext[i].count = 0 ;
pwindow->qgtext[i].gc = XCreateGC(_DISPLAY,_WINDOW,
mask | maskext, &gc_values) ;
}
XFlush(_DISPLAY) ;
Xw_set_window_ratio(pwindow,0.001 METER) ;
#ifdef TRACE_DEF_WINDOW
if( Xw_get_trace() ) {
printf (" Xw_def_window(%lx,%lx,%d)\n",(long ) pdisplay,(long ) window,istransparent) ;
}
#endif
return (pwindow);
}
static XW_EXT_WINDOW *PwindowList =NULL ;
#ifdef XW_PROTOTYPE
XW_EXT_WINDOW* Xw_add_window_structure(int size)
#else
XW_EXT_WINDOW* Xw_add_window_structure(size)
int size ;
#endif /*XW_PROTOTYPE*/
/*
Create and Insert one Extended window structure in the
EXtended Window List
returns Extended window address if successful
or NULL if Bad Allocation
*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) Xw_malloc(size) ;
if( pwindow ) {
pwindow->type = WINDOW_TYPE ;
pwindow->link = PwindowList ;
pwindow->other = NULL ;
PwindowList = pwindow ;
} else {
/*ERROR*EXT_WINDOW allocation failed*/
Xw_set_error(69,"Xw_add_window_structure",0) ;
}
return (pwindow) ;
}
#ifdef XW_PROTOTYPE
XW_EXT_WINDOW* Xw_get_window_structure(Window window)
#else
XW_EXT_WINDOW* Xw_get_window_structure(window)
Window window ;
#endif /*XW_PROTOTYPE*/
/*
Return the Extended window address corresponding to the required
Window Id or NULL if not found
*/
{
XW_EXT_WINDOW *pwindow = PwindowList ;
while (pwindow) {
if( pwindow->window == window ) {
break ;
}
pwindow = (XW_EXT_WINDOW*) pwindow->link ;
}
return (pwindow) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_close_window (void* awindow,int destroy)
#else
XW_STATUS Xw_close_window (awindow,destroy)
void *awindow;
int destroy;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
int i ;
if( !pwindow ) {
while( Xw_del_window_structure(NULL) ) ;
} else {
if( destroy ) {
#ifdef PURIFY
XFreeGC(_DISPLAY,pwindow->qgwind.gc);
XFreeGC(_DISPLAY,pwindow->qgwind.gcclear);
XFreeGC(_DISPLAY,pwindow->qgwind.gccopy);
XFreeGC(_DISPLAY,pwindow->qgwind.gchigh);
for( i=0 ; i<MAXQG ; i++ ) {
XFreeGC(_DISPLAY,pwindow->qgline[i].gc);
XFreeGC(_DISPLAY,pwindow->qgmark[i].gc);
XFreeGC(_DISPLAY,pwindow->qgpoly[i].gc);
XFreeGC(_DISPLAY,pwindow->qgtext[i].gc);
}
#endif
XDestroyWindow(_DISPLAY,_WINDOW) ;
}
Xw_del_window_structure(pwindow) ;
}
#ifdef TRACE_CLOSE_WINDOW
if( Xw_get_trace() ) {
printf (" Xw_close_window(%lx,%d)\n",(long ) pwindow,destroy) ;
}
#endif
return (XW_SUCCESS);
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_del_window_structure(XW_EXT_WINDOW* pwindow)
#else
XW_STATUS Xw_del_window_structure(pwindow)
XW_EXT_WINDOW *pwindow;
#endif /*XW_PROTOTYPE*/
/*
Remove the Extended window address or the next from the Extended List
and Free the Extended Window
returns ERROR if the window address is not Found in the list
or NO more Window exist
returns SUCCESS if successful
*/
{
XW_EXT_WINDOW *qwindow = PwindowList ;
int i ;
if( !qwindow ) return (XW_ERROR) ;
if( pwindow == qwindow ) {
PwindowList = (XW_EXT_WINDOW*) pwindow->link ;
} else if( !pwindow ) {
if( !PwindowList ) return (XW_ERROR) ;
pwindow = PwindowList ;
PwindowList = (XW_EXT_WINDOW*) PwindowList->link ;
} else {
for( ; qwindow ; qwindow = (XW_EXT_WINDOW*) qwindow->link ) {
if( qwindow->link == pwindow ) {
qwindow->link = pwindow->link ;
break ;
}
}
}
if( _PIXMAP ) {
Xw_close_pixmap(pwindow) ;
}
if( _BIMAGE ) {
Xw_close_image(_BIMAGE) ;
_BIMAGE = NULL;
}
if( _BPIXMAP ) {
Xw_close_background_pixmap(pwindow) ;
_BPIXMAP = 0;
}
Xw_close_buffer(pwindow,0) ;
for( i=1 ; i<MAXBUFFERS ; i++ ) {
Xw_close_buffer(pwindow,-i) ;
}
if( pwindow->other ) Xw_free(pwindow->other) ;
if( _COLORMAP && (_COLORMAP->maxwindow > 0) ) {
_COLORMAP->maxwindow -= 1;
}
Xw_free(pwindow) ;
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_reset_attrib(XW_EXT_WINDOW* awindow)
#else
XW_STATUS Xw_reset_attrib(awindow)
XW_EXT_WINDOW *awindow ;
#endif /*XW_PROTOTYPE*/
/*
Reset ALL Window attributes of a particular Window or ALL Windows
if NULL
*/
{
XW_EXT_WINDOW *pwindow ;
unsigned long highpixel,backpixel ;
int i ;
if( !(pwindow = PwindowList) ) return (XW_ERROR) ;
while (pwindow) {
if( !awindow || (pwindow == awindow) ) {
for( i=0 ; i<MAXQG ; i++ ) {
pwindow->qgline[i].code = ~0 ;
pwindow->qgpoly[i].code = ~0 ;
pwindow->qgtext[i].code = ~0 ;
pwindow->qgmark[i].code = ~0 ;
}
if( _COLORMAP ) {
highpixel = _COLORMAP->highpixel ;
if( pwindow->backindex < 0 ) {
backpixel = _COLORMAP->backpixel ;
} else {
backpixel = _COLORMAP->pixels[pwindow->backindex] ;
}
XSetForeground(_DISPLAY, pwindow->qgwind.gccopy, highpixel) ;
highpixel ^= backpixel ;
XSetForeground(_DISPLAY, pwindow->qgwind.gchigh, highpixel) ;
}
}
pwindow = (XW_EXT_WINDOW*) pwindow->link ;
}
return (XW_SUCCESS) ;
}
#ifdef XW_PROTOTYPE
XW_STATUS Xw_get_color_attrib(XW_EXT_WINDOW* awindow,
XW_DRAWMODE mode,int color,unsigned long* hcolor,
int* function,unsigned long* planemask)
#else
XW_STATUS Xw_get_color_attrib(awindow,mode,color,hcolor,function,planemask)
XW_EXT_WINDOW *awindow ;
XW_DRAWMODE mode ;
int color ;
int *function ;
unsigned long *planemask ;
unsigned long *hcolor ;
#endif /*XW_PROTOTYPE*/
/*
Returns the best drawing attributs color,function and planemask
depending of write mode and colormap visual class attached to this
window .
returns ERROR if the Visual class is not authorized
returns SUCCESS if successfull
*/
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
switch ( _CLASS ) {
case TrueColor :
switch (mode) {
case XW_ERASE :
if( pwindow->backindex >= 0 )
*hcolor = _COLORMAP->pixels[pwindow->backindex] ;
else *hcolor = _COLORMAP->backpixel;
*function = GXcopy ;
*planemask = AllPlanes ;
break ;
case XW_REPLACE :
*hcolor = _COLORMAP->pixels[color] ;
*function = GXcopy ;
*planemask = AllPlanes ;
break ;
case XW_XORBACK :
if( pwindow->backindex >= 0 )
*hcolor = _COLORMAP->pixels[pwindow->backindex]
^ _COLORMAP->pixels[color] ;
else *hcolor = _COLORMAP->backpixel
^ _COLORMAP->pixels[color] ;
*function = GXxor ;
*planemask = AllPlanes ;
break ;
case XW_XORLIGHT :
case XW_HIGHLIGHT :
case XW_UNHIGHLIGHT :
*hcolor = _COLORMAP->highpixel ^ _COLORMAP->pixels[color] ;
*function = GXxor ;
*planemask = AllPlanes ;
break ;
}
break ;
case PseudoColor :
switch (mode) {
case XW_ERASE :
if( pwindow->backindex >= 0 )
*hcolor = _COLORMAP->pixels[pwindow->backindex] ;
else *hcolor = _COLORMAP->backpixel;
*function = GXcopy ;
*planemask = AllPlanes ;
break ;
case XW_REPLACE :
*hcolor = _COLORMAP->pixels[color] ;
*function = GXcopy ;
*planemask = AllPlanes ;
break ;
case XW_XORBACK :
if( pwindow->backindex >= 0 )
*hcolor = _COLORMAP->pixels[pwindow->backindex]
^ _COLORMAP->pixels[color] ;
else *hcolor = _COLORMAP->backpixel
^ _COLORMAP->pixels[color] ;
*function = GXxor ;
*planemask = AllPlanes ;
break ;
case XW_XORLIGHT :
case XW_HIGHLIGHT :
case XW_UNHIGHLIGHT :
*hcolor = _COLORMAP->highpixel ^ _COLORMAP->pixels[color] ;
*function = GXxor ;
*planemask = AllPlanes ;
break ;
}
break ;
case StaticColor :
switch (mode) {
case XW_ERASE :
if( pwindow->backindex >= 0 )
*hcolor = _COLORMAP->pixels[pwindow->backindex] ;
else *hcolor = _COLORMAP->backpixel;
*function = GXcopy ;
*planemask = AllPlanes ;
break ;
case XW_REPLACE :
*hcolor = _COLORMAP->pixels[color] ;
*function = GXcopy ;
*planemask = AllPlanes ;
break ;
case XW_XORBACK :
if( pwindow->backindex >= 0 )
*hcolor = _COLORMAP->pixels[pwindow->backindex]
^ _COLORMAP->pixels[color] ;
else *hcolor = _COLORMAP->backpixel
^ _COLORMAP->pixels[color] ;
*function = GXxor ;
*planemask = AllPlanes ;
break ;
case XW_XORLIGHT :
case XW_HIGHLIGHT :
case XW_UNHIGHLIGHT :
*hcolor = _COLORMAP->highpixel ^ _COLORMAP->pixels[color] ;
*function = GXxor ;
*planemask = AllPlanes ;
break ;
}
break ;
case StaticGray :
case GrayScale :
case DirectColor :
/*ERROR*Unimplemented Visual class*/
Xw_set_error(5,"Xw_get_color_attrib",&_CLASS) ;
return (XW_ERROR) ;
}
return (XW_SUCCESS) ;
}
#ifdef S3593
#ifdef XW_PROTOTYPE
void Xw_set_clipping(void* awindow, int flag)
#else
void Xw_set_clipping(awindow,flag)
void* awindow;
int flag;
#endif
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) awindow;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_set_clipping",pwindow) ;
return;
}
pwindow->clipflag = flag;
}
#ifdef XW_PROTOTYPE
int Xw_get_clipping(void* awindow)
#else
int Xw_get_clipping(awindow)
void* awindow;
#endif
{
XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) awindow;
if( !Xw_isdefine_window(pwindow) ) {
/*ERROR*Bad EXT_WINDOW Address*/
Xw_set_error(24,"Xw_get_clipping",pwindow) ;
return (True) ;
}
return pwindow->clipflag;
}
#endif /*S3593*/
|