aboutsummaryrefslogtreecommitdiff
path: root/src/graph/view2D/control2d.c.pamphlet
blob: c45ba4000ad2836927473f8e27bdf83320cb958e (plain)
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
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/graph/view2D control2d.c}
\author{The Axiom Team}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{License}
<<license>>=
/*
Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

    - Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.

    - Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in
      the documentation and/or other materials provided with the
      distribution.

    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
@
<<*>>=
<<license>>

#define _CONTROL2D_C
#include "axiom-c-macros.h"

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

#include "header2.h"
#include "buttons2d.H1"
#include "all_2d.H1"
#include "Gfun.H1"
#include "XSpadFill.H1"
#include "util.H1"


#include "mouse11.bitmap"
#include "mouse11.mask"

/* Defines the pixmap for the arrow displayed in the scale window */

#define scaleArrowN 11
static XPoint scaleArrow[scaleArrowN] = {
  {55,14},{64,23},{59,23},
  {66,45},{79,45},
  {55,69},
  {31,45},{44,45},
  {51,23},{46,23},{55,14} };

/* Defines the pixmap for the arrows displayed in the translate window */

#define translateArrowN 25
static XPoint translateArrow[translateArrowN] = {
  {55,2},{60,10},{58,10},{58,37},
  {85,37},{85,35},{93,40},{85,45},{85,43},{58,43},
  {58,70},{60,70},{55,78},{50,70},{52,70},{52,43},
  {25,43}, {25,45}, {17,40},  {25,35}, {25,37}, {52,37},
  {52,10},{50,10},{55,2} };

/****************************
 * void writeControlTitle() *
 ****************************/

void 
#ifdef _NO_PROTO
writeControlTitle()
#else
writeControlTitle(void)
#endif
{

  int strlength;

  s = viewport->title;
  strlength = strlen(s);
  XClearArea(dsply,control->controlWindow,0,0,controlWidth,potA,False);
  GSetForeground(anotherGC,(float)controlTitleColor,Xoption);
  GDrawImageString(anotherGC,control->controlWindow,
		   centerX(anotherGC,s,strlength,controlWidth),
		   15,s,strlength,Xoption);

} /* writeControlTitle() */

void 
#ifdef _NO_PROTO
makeMessageFromData(whichGraph)
int whichGraph;
#else
makeMessageFromData(int whichGraph)
#endif
{
  if (viewport->haveControl) {
    if ((graphStateArray[whichGraph].scaleX) > 99.0) {
      strcpy(scaleXReport,"big");
    } else {
      sprintf(scaleXReport,"%4.1f",graphStateArray[whichGraph].scaleX);
    }
    if ((graphStateArray[whichGraph].scaleY) > 99.0) {
      strcpy(scaleYReport,"big");
    } else {
      sprintf(scaleYReport,"%4.1f",graphStateArray[whichGraph].scaleY);
    }
    if ((graphStateArray[whichGraph].centerX) > 999.0) {
      strcpy(deltaXReport,"+big");
    } else if ((graphStateArray[whichGraph].centerX) < -999.0) {
      strcpy(deltaXReport,"-big");
    } else {
      sprintf(deltaXReport,"%4.0f",
	      -graphStateArray[whichGraph].centerX /
	      graphArray[whichGraph].unitX);
    }
    if ((graphStateArray[whichGraph].centerY) > 999.0) {
      strcpy(deltaYReport,"+big");
    } else if ((graphStateArray[whichGraph].centerY) < -999.0) {
      strcpy(deltaYReport,"-big");
    } else {
      sprintf(deltaYReport,"%4.0f",
	      -graphStateArray[whichGraph].centerY /
	      graphArray[whichGraph].unitY);
    }
    sprintf(viewport->controlPanel->message,"[%s,%s] >%d< [%s,%s]",
	    scaleXReport,scaleYReport,whichGraph+1,deltaXReport,deltaYReport);
  }  /* if haveControl */

} /* makeMessageFromData() */


void 
#ifdef _NO_PROTO
writeControlMessage()
#else
writeControlMessage(void)
#endif
{
  int		     strlength;
  controlPanelStruct *cp;
  XWindowAttributes  cwInfo;

  cp = viewport->controlPanel;
  XGetWindowAttributes(dsply,cp->controlWindow,&cwInfo);
  strlength = strlen(cp->message);



  GDrawImageString(controlMessageGC,cp->controlWindow,
		   centerX(globalGC1,cp->message,strlength,controlWidth),
		   controlMessageY + globalFont->max_bounds.ascent - 2,
		   cp->message,strlength,Xoption);
}

/*********************************/
/***  void drawControlPanel()  ***/
/*********************************/

void 
#ifdef _NO_PROTO
drawControlPanel()
#else
drawControlPanel(void)
#endif
{

  controlPanelStruct *cp;
  int i,strlength;
  char *s;

  cp = viewport->controlPanel;
  /* Draw border lines to separate the potentiometer, message, graph select
     and button regions of the control panel. */
  GSetForeground(trashGC,(float)foregroundColor,Xoption);
  GSetLineAttributes(trashGC,3,LineSolid,CapButt,JoinMiter,Xoption);
  GDrawLine(trashGC, cp->controlWindow, 0, potA, controlWidth, potA, Xoption);
  GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption);
  GDrawLine(trashGC, cp->controlWindow, 0, potB, controlWidth, potB, Xoption);
  GDrawLine(trashGC, cp->controlWindow, 0, messageBot,
	    controlWidth, messageBot, Xoption);
  GDrawLine(trashGC, cp->controlWindow, 0, 286, controlWidth, 286, Xoption);

  /** put the line width as 1 last because used below as well **/
  GSetLineAttributes(trashGC,1,LineSolid,CapButt,JoinMiter,Xoption);
  GDrawRectangle(trashGC,cp->controlWindow,closeLeft,closeTop,
		 (controlWidth-closeLeft+8),(controlHeight-closeTop+8),Xoption);

  /* Write potentiometer titles on the control panel. */
  writeControlTitle();
  GSetForeground(globGC,(float)controlPotHeaderColor,Xoption);
  s = "Scale";
  strlength = strlen(s);
  GDrawString(globGC,cp->controlWindow,
	      centerX(globGC,s,strlength,
		      cp->buttonQueue[scale2D].buttonWidth) +
	      cp->buttonQueue[scale2D].buttonX, 31+headerHeight,s,strlength,Xoption);

  s = "Translate";
  strlength = strlen(s);
  GDrawString(globGC,cp->controlWindow,
	      centerX(globGC,s,strlength,
		      cp->buttonQueue[translate2D].buttonWidth) +
	      cp->buttonQueue[translate2D].buttonX,
	      31+headerHeight,s,strlen(s),Xoption);

  GSetForeground(globGC,(float)controlColorColor,Xoption);

  /* Write title of the graph selection window. */
  s = "Graphs";
  strlength = strlen(s);
  GDrawString(globGC,cp->controlWindow,
	      centerX(globGC,s,strlength,controlWidth),graphHeaderHeight,
	      s,strlength,Xoption);

  /* Write titles on regular buttons and draw pixmaps on potentiometers. */

  for (i=0; i<(maxButtons2D); i++) {
    if ((cp->buttonQueue[i]).pot) {

      GSetForeground(globalGC1,(float)buttonColor,Xoption);
      GDrawRectangle(globalGC1,cp->controlWindow,
		     (cp->buttonQueue[i]).buttonX,
		     (cp->buttonQueue[i]).buttonY,
		     (cp->buttonQueue[i]).buttonWidth,
		     (cp->buttonQueue[i]).buttonHeight,Xoption);

      GSetForeground(trashGC,
		     (float)monoColor((cp->buttonQueue[i]).textColor),Xoption);

      GDrawLine(globalGC1,cp->controlWindow, /* trashGC, */
		(cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf,
		(cp->buttonQueue[i]).buttonY,
		(cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf,
		(cp->buttonQueue[i]).buttonY + 2*(cp->buttonQueue[i]).yHalf,Xoption);
      GDrawLine(globalGC1,cp->controlWindow, /* trashGC, */
		(cp->buttonQueue[i]).buttonX,
		(cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf,
		(cp->buttonQueue[i]).buttonX + 2*(cp->buttonQueue[i]).xHalf,
		(cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf,Xoption);
      switch (i) {
      case scale2D:
	GDrawLines(trashGC,cp->controlWindow,scaleArrow,
		   scaleArrowN,CoordModeOrigin,Xoption);
	break;
      case translate2D:
	GDrawLines(trashGC,cp->controlWindow,translateArrow,
		   translateArrowN,CoordModeOrigin,Xoption);
	break;
      } /* switch i */
    } else if (cp->buttonQueue[i].graphNum) {

      if (mono) {
	if (graphStateArray[i-graphStart].showing) {
	  GSetForeground(graphGC,(float)backgroundColor,Xoption);
	  GSetBackground(graphGC,(float)foregroundColor,Xoption);
	} else {
	  GSetForeground(graphGC,(float)foregroundColor,Xoption);
	  GSetBackground(graphGC,(float)backgroundColor,Xoption);
	}
	strlength = strlen((cp->buttonQueue[i]).text);
	GDrawImageString(graphGC,cp->controlWindow,
			 (cp->buttonQueue[i]).buttonX +
			 centerX(graphGC,cp->buttonQueue[i].text,
				 strlength,(cp->buttonQueue[i]).buttonWidth),
			 (cp->buttonQueue[i]).buttonY +
			 centerY(graphGC,(cp->buttonQueue[i]).buttonHeight),
			 cp->buttonQueue[i].text,strlength,Xoption);
      } else {
	if (graphStateArray[i-graphStart].showing)
	  GSetForeground(graphGC,(float)graphBarShowingColor,Xoption);
	else
	  GSetForeground(graphGC,(float)graphBarHiddenColor,Xoption);
	strlength = strlen((cp->buttonQueue[i]).text);
	GDrawString(graphGC,cp->controlWindow,
		    (cp->buttonQueue[i]).buttonX +
		    centerX(graphGC,cp->buttonQueue[i].text,
			    strlength,(cp->buttonQueue[i]).buttonWidth),
		    (cp->buttonQueue[i]).buttonY +
		    centerY(graphGC,(cp->buttonQueue[i]).buttonHeight),
		    cp->buttonQueue[i].text,strlength,Xoption);
	}
    } else if (cp->buttonQueue[i].graphSelect) {
      /* The select characters are defined as: "^" for on and "-" for off. */
      if (graphStateArray[i-graphSelectStart].selected) {
	GSetForeground(graphGC,(float)graphBarSelectColor,Xoption);
	strcpy((cp->buttonQueue[i]).text,"^");
      } else {
	GSetForeground(graphGC,(float)graphBarNotSelectColor,Xoption);
	*(cp->buttonQueue[i]).text = '-';
	strcpy((cp->buttonQueue[i]).text,"-");
      }
       GDrawString(graphGC,cp->controlWindow,
		 (cp->buttonQueue[i]).buttonX +
		 centerX(graphGC,cp->buttonQueue[i].text,
			 strlength,(cp->buttonQueue[i]).buttonWidth),
		 (cp->buttonQueue[i]).buttonY +
		 centerY(graphGC,(cp->buttonQueue[i]).buttonHeight),
		 cp->buttonQueue[i].text,strlength,Xoption);
    }
    else {  /* a regular button */
      int isOn = 1;

      switch(i) {
	case pointsOnOff:
	  isOn = pointsON = graphStateArray[0].pointsOn;
	  if (graphStateArray[0].pointsOn)
	    strcpy((cp->buttonQueue[i]).text,"Pts On ");
	  else
	    strcpy((cp->buttonQueue[i]).text,"Pts Off");
	  break;

	case spline2D:
	  isOn = splineON = graphStateArray[0].splineOn;
	  if (graphStateArray[0].splineOn)
	    strcpy((cp->buttonQueue[i]).text, "Box On ");
	  else
	    strcpy((cp->buttonQueue[i]).text, "Box Off");
	  break;

	case connectOnOff:
	  isOn = connectON = graphStateArray[0].connectOn;
	  if (graphStateArray[0].connectOn)
	    strcpy((cp->buttonQueue[i]).text, "Lines On ");
	  else
	    strcpy((cp->buttonQueue[i]).text, "Lines Off");
	  break;

	case axesOnOff2D:
	  isOn = axesON = graphStateArray[0].axesOn;
	  if (graphStateArray[0].axesOn)
	    strcpy((cp->buttonQueue[i]).text , "Axes On ");
	  else
	    strcpy((cp->buttonQueue[i]).text , "Axes Off");
	  break;

	case unitsOnOff2D:
	  isOn = unitsON = graphStateArray[0].unitsOn;
	  if (graphStateArray[0].unitsOn)
	   strcpy( (cp->buttonQueue[i]).text , "Units On ");
	  else
	   strcpy( (cp->buttonQueue[i]).text , "Units Off");
	  break;
	case closeAll2D:
	  isOn = 0;

	default:
	  break;
      } /* switch i */

      s = (cp->buttonQueue[i]).text;
      strlength = strlen(s);

      GDrawPushButton(dsply, globalGC1, trashGC, processGC, cp->controlWindow,
	  (cp->buttonQueue[i]).buttonX, (cp->buttonQueue[i]).buttonY,
	  (cp->buttonQueue[i]).buttonWidth, (cp->buttonQueue[i]).buttonHeight,
	  isOn, s,buttonColor,
	  monoColor((cp->buttonQueue[i]).textColor), Xoption);

    } /* else a regular button */
  } /* for each button */

  /* Refresh the latest message */
  makeMessageFromData(0);
  writeControlMessage();
  XFlush(dsply);

}    /*** drawControlPanel ***/

controlXY 
#ifdef _NO_PROTO
getControlXY(whereDoYouWantPanel)
int whereDoYouWantPanel;
#else
getControlXY(int whereDoYouWantPanel)
#endif
{
  XWindowAttributes wAttr, wAttrib;
  controlXY	    cXY;
  int		    tmp=1;
  Window	    rootW, parentW, *childrenWs, tmpW;
  unsigned int	    nChildren;

  tmpW = viewport->titleWindow;
  while(tmp) {
    XQueryTree(dsply,tmpW,&rootW,&parentW,&childrenWs,&nChildren);
    XFree(childrenWs);
    if (parentW == rtWindow) tmp = 0;
    else tmpW = parentW;
  }
  XGetWindowAttributes(dsply,tmpW,&wAttrib);

  XGetWindowAttributes(dsply,viewport->titleWindow,&wAttr);
  if (whereDoYouWantPanel) {
    switch (whereDoYouWantPanel) {
    case 1: /* right */
      cXY.putX = wAttrib.x + wAttrib.width;
      cXY.putY = wAttrib.y;
      break;
    case 2: /* bottom */
      cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2;  /* center it */
      cXY.putY = wAttrib.y + wAttrib.height;
      break;
    case 3: /* left */
      cXY.putX = wAttrib.x - controlWidth - borderWidth;
      cXY.putY = wAttrib.y;
      break;
    case 4: /* top */
      cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2;
      cXY.putY = wAttrib.y - controlHeight - borderHeight;
    }
  } else {
    if ((physicalWidth - (wAttrib.x + wAttr.width)) >= controlWidth) {
      cXY.putX = wAttrib.x + wAttrib.width;
      cXY.putY = wAttrib.y;
    } else if ((physicalHeight - (wAttrib.y + wAttr.height)) >=
	       controlHeight) {
      cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2;
      cXY.putY = wAttrib.y + wAttrib.height;
    } else if (wAttrib.x >= controlWidth) {
      cXY.putX = wAttrib.x - controlWidth - borderWidth;
      cXY.putY = wAttrib.y;
    } else if (wAttrib.y >= controlHeight) {
      cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2;
      cXY.putY = wAttrib.y - controlHeight - borderHeight;
    } else {			   /* put inside of viewport */
      cXY.putX = wAttrib.x + wAttr.width - controlWidth;
      cXY.putY = wAttrib.y + wAttr.height - controlHeight;
    }
  }
  return(cXY);

}

/************************************************/
/***  controlPanelStruct *makeControlPanel()  ***/
/************************************************/

controlPanelStruct *
#ifdef _NO_PROTO
makeControlPanel()
#else
makeControlPanel(void)
#endif
{

  Window cw;
  int		       i,num;
  controlPanelStruct   *control;
  buttonStruct	       *buttons;
  controlXY	       cXY;
  XSetWindowAttributes cwAttrib, controlAttrib;
  XSizeHints	       sizehints;
  Pixmap	       mousebits,mousemask;
  XColor	       foreColor, backColor;

  if (!(control = (controlPanelStruct *)malloc(sizeof(controlPanelStruct)))) {
    fprintf(stderr,"Ran out of memory trying to create a control panel.\n");
    exitWithAck(RootWindow(dsply,scrn),Window,-1);
  }

  cXY = getControlXY(0);

  /* Define and assign a mouse cursor. */
  mousebits = XCreateBitmapFromData(dsply,rtWindow,mouseBitmap_bits,
				    mouseBitmap_width,mouseBitmap_height);
  mousemask = XCreateBitmapFromData(dsply,rtWindow,mouseMask_bits,
				    mouseMask_width,mouseMask_height);
  cwAttrib.background_pixel = backgroundColor; /* controlBackground; */
  cwAttrib.border_pixel = foregroundColor;
  cwAttrib.backing_store = WhenMapped;
  cwAttrib.event_mask = controlMASK;
  cwAttrib.colormap = colorMap;
  cwAttrib.override_redirect = overrideManager;
  foreColor.pixel = controlCursorForeground;
  XQueryColor(dsply,colorMap,&foreColor);
  backColor.pixel = controlCursorBackground;
  XQueryColor(dsply,colorMap,&backColor);
  cwAttrib.cursor = XCreatePixmapCursor(dsply,mousebits,mousemask,
					&foreColor,&backColor,
					mouseBitmap_x_hot,mouseBitmap_y_hot);

  cw = XCreateWindow(dsply,rtWindow,
		     cXY.putX,cXY.putY,controlWidth,controlHeight,3,
		     CopyFromParent,InputOutput,CopyFromParent,
		     controlCreateMASK,&cwAttrib);

  sizehints.flags  = PPosition | PSize;
  sizehints.x	   = cXY.putX;
  sizehints.y	   = cXY.putY;
  sizehints.width  = controlWidth;
  sizehints.height = controlHeight;

  /*** the None stands for icon pixmap...change.... ***/

  XSetNormalHints(dsply,cw,&sizehints);
  XSetStandardProperties(dsply,cw,"2D Control Panel","2D Control Panel",
			 None,NULL,0,&sizehints);

  control->controlWindow = cw;
  num = initButtons(control->buttonQueue);
  control->numOfButtons = num;
  buttons = control->buttonQueue;

  for (i=0; i<num; i++) {
    controlAttrib.event_mask = (control->buttonQueue[i]).mask;
    (control->buttonQueue[i]).self = XCreateWindow(dsply,cw,
				       (control->buttonQueue[i]).buttonX,
				       (control->buttonQueue[i]).buttonY,
				       (control->buttonQueue[i]).buttonWidth,
				       (control->buttonQueue[i]).buttonHeight,
				       0,0,InputOnly,CopyFromParent,
				       buttonCreateMASK,&controlAttrib);

    XMakeAssoc(dsply,table,(control->buttonQueue[i]).self,
	       &((control->buttonQueue[i]).buttonKey));
   /* Use buttonKey instead of i because buttonKey has a permanent address */
    XMapWindow(dsply,(control->buttonQueue[i]).self);
  }

	   /* Create message window */
  control->messageWindow = XCreateWindow(dsply,cw,0,controlMessageY,
					 controlWidth,controlMessageHeight,
					 0,0,InputOnly,CopyFromParent,
					 messageCreateMASK,&cwAttrib);
  XMapWindow(dsply,control->messageWindow);

  for (i=0; i<scaleArrowN; i++) {
    scaleArrow[i].x += buttons[scale2D].buttonX;
    scaleArrow[i].y += buttons[scale2D].buttonY;
  }
  for (i=0; i<translateArrowN; i++) {
    translateArrow[i].x += buttons[translate2D].buttonX;
    translateArrow[i].y += buttons[translate2D].buttonY;
  }

  viewport->justMadeControl = yes;
  return(control);

} /* makeControlPanel() */






/*****************************************/
/***  void putControlPanelSomewhere()  ***/
/*****************************************/

/* This routine puts up the control panel associated with the viewport
   passed in.  It first tries to put it to the right of the viewport. If
   there isn't enough room there, it tries the bottom and so on going
   clockwise. If the viewport is too big and there is no room to put the
   control panel outside of it, it placed the control panel in the bottom
   right hand corner of the viewport window. */

void 
#ifdef _NO_PROTO
putControlPanelSomewhere(whereDoesPanelGo)
int whereDoesPanelGo;
#else
putControlPanelSomewhere(int whereDoesPanelGo)
#endif
{
  controlPanelStruct *control;
  controlXY	     whereControl;

  control = viewport->controlPanel;
  whereControl = getControlXY(whereDoesPanelGo);

  viewport->haveControl = yes;

  XRaiseWindow(dsply,control->controlWindow);
  XMoveWindow(dsply,control->controlWindow,whereControl.putX,
	      whereControl.putY);

  drawControlPanel();
  if (viewport->justMadeControl) {
    XMapWindow(dsply,control->controlWindow);
    viewport->justMadeControl = no;
  }
  XMapWindow(dsply,control->controlWindow);
}





/************************************/
/***  void clearControlMessage()  ***/
/************************************/

void 
#ifdef _NO_PROTO
clearControlMessage()
#else
clearControlMessage(void)
#endif
{

  strcpy(viewport->controlPanel->message,"");
  
  XClearArea(dsply,viewport->controlPanel->controlWindow,
	     0,controlMessageY-2,controlWidth,controlMessageHeight,False);
}


@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}