~ubuntu-branches/ubuntu/precise/xcircuit/precise

« back to all changes in this revision

Viewing changes to menucalls.c

  • Committer: Bazaar Package Importer
  • Author(s): David Z Maze
  • Date: 2003-08-24 09:08:10 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20030824090810-5d6ptk9msqsbsnqv
Tags: 3.1.19-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
#include <stdlib.h>
9
9
#include <string.h>
10
10
#include <ctype.h>
11
 
#if defined(DARWIN)
12
 
#include <sys/malloc.h>
13
 
#else
14
 
#include <malloc.h>
15
 
#endif
16
11
#include <sys/types.h>
17
12
#include <errno.h>
18
13
#include <limits.h>
21
16
#include <X11/StringDefs.h>
22
17
#include <X11/Xutil.h>
23
18
 
 
19
#ifdef TCL_WRAPPER 
 
20
#include <tk.h>
 
21
#else
24
22
#include "Xw/Xw.h"
25
23
#include "Xw/MenuBtn.h"
26
24
#include "Xw/PopupMgr.h"
 
25
#endif
27
26
 
28
27
/*----------------------------------------------------------------------*/
29
28
/* Local includes                                                       */
43
42
 
44
43
extern char      _STR2[250];
45
44
extern char      _STR[150];          /* Generic multipurpose string */
46
 
extern Widget    top;
 
45
extern xcWidget  top;
47
46
extern Display   *dpy;
48
 
extern Window    win;
49
47
extern short     popups;             /* total number of popup windows */
50
 
extern Widget    menuwidgets[];
51
 
extern Widget    toolbar;
 
48
extern xcWidget    menuwidgets[];
 
49
extern xcWidget  toolbar;
52
50
extern Globaldata xobjs;
53
51
extern Clientdata areastruct;
54
52
extern int        *appcolors;
59
57
extern fontinfo *fonts;
60
58
extern short fontcount;
61
59
extern short eventmode, textpos, textend;
62
 
extern objectpair *pushlist;
 
60
 
 
61
#ifdef TCL_WRAPPER
 
62
extern Tcl_Interp *xcinterp;
 
63
#endif
63
64
 
64
65
/*----------------------------------------------------------------------*/
65
66
/* The rest of the local includes depend on the prototype declarations  */
66
67
/* and some of the external global variable declarations.               */
67
68
/*----------------------------------------------------------------------*/
 
69
#ifndef TCL_WRAPPER
68
70
#include "menus.h"
69
71
#include "menudep.h"
 
72
#endif
70
73
 
71
74
/*----------------------------------------------------------------------*/
72
75
/* Local Variable definitions                                           */
80
83
/*--------------------------------------------------------------*/
81
84
 
82
85
#ifdef HAVE_XPM
83
 
void dotoolbar(Widget w, caddr_t clientdata, caddr_t calldata)   
 
86
void dotoolbar(xcWidget w, caddr_t clientdata, caddr_t calldata)   
84
87
{
85
88
   Arg wargs[1];
86
89
 
 
90
#ifndef TCL_WRAPPER
87
91
   if (areastruct.toolbar_on) {
88
92
      areastruct.toolbar_on = False;
89
93
      XtUnmanageChild(toolbar);
98
102
      XtSetValues(OptionsDisableToolbarButton, wargs, 1);
99
103
      XtAddCallback(areastruct.area, XtNresize, (XtCallbackProc)resizetoolbar, NULL);
100
104
   }
 
105
#endif
101
106
}  
102
107
 
 
108
#ifndef TCL_WRAPPER
 
109
 
103
110
/*--------------------------------------------------------------*/
104
111
/* Overwrite the toolbar pixmap for color or stipple entries    */
105
112
/*--------------------------------------------------------------*/
106
113
 
107
 
void overdrawpixmap(Widget button)
 
114
void overdrawpixmap(xcWidget button)
108
115
{
109
 
   Widget pbutton;
 
116
   xcWidget pbutton;
110
117
   Arg args[3];
111
118
   int ltype, color;
112
119
   Pixmap stippix;
149
156
}
150
157
#else
151
158
#define overdrawpixmap(a)
152
 
#endif
 
159
#endif  /* TCL */
 
160
#else
 
161
#define overdrawpixmap(a)
 
162
#endif  /* XPM */
153
163
 
154
164
/*--------------------------------------------------------------*/
155
165
/* Generic routine for use by all other data handling routines  */
156
166
/*--------------------------------------------------------------*/
157
167
 
158
 
void getgeneric(buttonsave *saveptr, Widget button, void (*getfunction)(),
 
168
void getgeneric(buttonsave *saveptr, xcWidget button, void (*getfunction)(),
159
169
        void *dataptr)
160
170
{
161
171
   Arg  wargs[1];
164
174
   saveptr->buttoncall = getfunction;
165
175
   saveptr->dataptr = dataptr;
166
176
 
 
177
#ifndef TCL_WRAPPER
167
178
   if (button != NULL) {
168
179
      XtSetArg(wargs[0], XtNforeground, &saveptr->foreground);
169
180
      XtGetValues(button, wargs, 1);
171
182
      XtSetValues(button, wargs, 1);
172
183
      XtRemoveAllCallbacks(button, XtNselect);
173
184
   }
 
185
#endif
174
186
}
175
187
 
176
188
 
179
191
/* include routines to parse fractions                            */
180
192
/*----------------------------------------------------------------*/
181
193
 
182
 
void setgrid(Widget w, float *dataptr)
 
194
void setgrid(xcWidget w, float *dataptr)
183
195
{
184
196
   float oldvalue = *dataptr;
185
197
   float oscale, iscale = (float)xobjs.pagelist[areastruct.page]->drawingscale.y /
252
264
/* Generate popup dialog for snap space value input             */
253
265
/*--------------------------------------------------------------*/
254
266
 
255
 
void getsnapspace(Widget button, caddr_t clientdata, caddr_t calldata)
 
267
void getsnapspace(xcWidget button, caddr_t clientdata, caddr_t calldata)
256
268
{
257
269
   char buffer[50];
258
270
   buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
267
279
/* Generate popup dialog for grid space value input             */
268
280
/*--------------------------------------------------------------*/
269
281
 
270
 
void getgridspace(Widget button, caddr_t clientdata, caddr_t calldata)
 
282
void getgridspace(xcWidget button, caddr_t clientdata, caddr_t calldata)
271
283
{
272
284
   char buffer[50];
273
285
   buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
283
295
/* (float *) pointer passed as the second parameter)              */
284
296
/*----------------------------------------------------------------*/
285
297
 
286
 
void setfloat(Widget w, float *dataptr)
 
298
void setfloat(xcWidget w, float *dataptr)
287
299
{
288
300
   float oldvalue = *dataptr;
289
301
   int res = sscanf(_STR2, "%f", dataptr);
300
312
/* is twice the value passed through pointer "dataptr".           */
301
313
/*----------------------------------------------------------------*/
302
314
 
303
 
void setwidth(Widget w, float *dataptr)
 
315
void setwidth(xcWidget w, float *dataptr)
304
316
{
305
317
   float oldvalue = *dataptr;
306
318
   if (sscanf(_STR2, "%f", dataptr) == 0) {
316
328
/* Set text scale.                                                */
317
329
/*----------------------------------------------------------------*/
318
330
 
319
 
void settsize(Widget w, labelptr settext)
 
331
void settsize(xcWidget w, labelptr settext)
320
332
{
321
333
   float tmpres;
322
334
   short *osel;
332
344
   /* In edit mode, add font scale change. */
333
345
 
334
346
   if (eventmode == TEXT2_MODE || eventmode == TEXT3_MODE) {
335
 
      if (textpos > 0 || textpos < stringlength(settext->string, True, NORMINST)) {
 
347
      if (textpos > 0 || textpos < stringlength(settext->string, True, areastruct.topinstance)) {
336
348
         undrawtext(settext);
337
 
         strptr = findstringpart(textpos - 1, NULL, settext->string, NORMINST);
338
 
         nextptr = findstringpart(textpos, NULL, settext->string, NORMINST);
 
349
         strptr = findstringpart(textpos - 1, NULL, settext->string, areastruct.topinstance);
 
350
         nextptr = findstringpart(textpos, NULL, settext->string, areastruct.topinstance);
339
351
         if (strptr->type == FONT_SCALE)
340
352
            strptr->data.scale = tmpres;
341
353
         else if (nextptr && nextptr->type == FONT_SCALE)
344
356
            labeltext(FONT_SCALE, (char *)&tmpres);
345
357
         redrawtext(settext);
346
358
      }
347
 
      else if (stringlength(settext->string, True, NORMINST) > 0)
 
359
      else if (stringlength(settext->string, True, areastruct.topinstance) > 0)
348
360
         labeltext(FONT_SCALE, (char *)&tmpres);
349
361
      else (settext->scale = tmpres);
350
362
   }
365
377
   }
366
378
}
367
379
 
 
380
#ifndef TCL_WRAPPER
368
381
/*--------------------------------------------------------------*/
369
382
/* Auto-set:  Enable automatic scaling                          */
370
383
/*--------------------------------------------------------------*/
371
384
 
372
 
void autoset(Widget w, WidgetList entertext, caddr_t nulldata)
 
385
void autoset(xcWidget w, xcWidgetList entertext, caddr_t nulldata)
373
386
{
374
387
   xobjs.pagelist[areastruct.page]->pmode |= 2;
375
388
   updatetext(w, entertext, nulldata);
377
390
 
378
391
/*--------------------------------------------------------------*/
379
392
 
380
 
void autostop(Widget w, caddr_t clientdata, caddr_t nulldata)
 
393
void autostop(xcWidget w, caddr_t clientdata, caddr_t nulldata)
381
394
{
382
395
   xobjs.pagelist[areastruct.page]->pmode &= 1;
383
396
}
 
397
#endif
384
398
 
385
399
/*--------------------------------------------------------------*/
386
400
/* Auto-scale                                                   */
387
401
/* (for now, with fixed 1" margins)                             */
388
402
/*--------------------------------------------------------------*/
389
403
 
390
 
void autoscale()
 
404
void autoscale(int page)
391
405
{
392
406
   float newxscale, newyscale;
393
 
   float scalefudge = (xobjs.pagelist[areastruct.page]->coordstyle
 
407
   float scalefudge = (xobjs.pagelist[page]->coordstyle
394
408
        == CM) ? CMSCALE : INCHSCALE;
395
409
   float margin = 144.0;
 
410
   int width, height;
396
411
 
397
 
   if (!(xobjs.pagelist[areastruct.page]->pmode & 2)) return;
398
 
   else if (objectdata->width == 0 || objectdata->height == 0) {
 
412
   if (!(xobjs.pagelist[page]->pmode & 2)) return;
 
413
   else if (topobject->bbox.width == 0 || topobject->bbox.height == 0) {
399
414
      Wprintf("Cannot auto-fit empty page");
400
415
      return;
401
416
   }
402
417
 
403
 
   newxscale = (xobjs.pagelist[areastruct.page]->pagesize.x - margin)
404
 
        / scalefudge;
405
 
   newyscale = (xobjs.pagelist[areastruct.page]->pagesize.y - margin)
406
 
        / scalefudge;
407
 
 
408
 
   if (xobjs.pagelist[areastruct.page]->orient == 0) {  /* Portrait */
409
 
      newxscale /= objectdata->width;
410
 
      newyscale /= objectdata->height;
 
418
   newxscale = (xobjs.pagelist[page]->pagesize.x - margin)
 
419
        / scalefudge;
 
420
   newyscale = (xobjs.pagelist[page]->pagesize.y - margin)
 
421
        / scalefudge;
 
422
 
 
423
#ifdef SCHEMA
 
424
   width = toplevelwidth(areastruct.topinstance);
 
425
   height = toplevelheight(areastruct.topinstance);
 
426
#else
 
427
   width = topobject->bbox.width;
 
428
   height = topobject->bbox.height;
 
429
#endif
 
430
 
 
431
   if (xobjs.pagelist[page]->orient == 0) {     /* Portrait */
 
432
      newxscale /= width;
 
433
      newyscale /= height;
411
434
   }
412
435
   else {
413
 
      newxscale /= objectdata->height;
414
 
      newyscale /= objectdata->width;
 
436
      newxscale /= height;
 
437
      newyscale /= width;
415
438
   }
416
439
 
417
 
   xobjs.pagelist[areastruct.page]->outscale = min(newxscale, newyscale);
 
440
   xobjs.pagelist[page]->outscale = min(newxscale, newyscale);
418
441
}
419
442
 
420
443
/*--------------------------------------------------------------*/
421
444
/* Set the denomenator value of the drawing scale               */ 
422
445
/*--------------------------------------------------------------*/
423
446
 
424
 
void setscaley(Widget w, float *dataptr)
 
447
void setscaley(xcWidget w, float *dataptr)
425
448
{
426
449
   float oldvalue = *dataptr;
427
450
   int res = sscanf(_STR2, "%f", dataptr);
428
451
 
429
 
   if (res == 0 || *dataptr <= 0 || objectdata->height == 0) {
 
452
   if (res == 0 || *dataptr <= 0 || topobject->bbox.height == 0) {
430
453
      *dataptr = oldvalue;
431
454
      Wprintf("Illegal value");
432
455
   }
433
456
   else {
434
 
      *dataptr = (*dataptr * 72) / objectdata->height;
 
457
      *dataptr = (*dataptr * 72) / topobject->bbox.height;
435
458
      *dataptr /= getpsscale(1.0, areastruct.page);
436
459
   }
437
460
}
440
463
/* Set the numerator value of the drawing scale                   */
441
464
/*----------------------------------------------------------------*/
442
465
 
443
 
void setscalex(Widget w, float *dataptr)
 
466
void setscalex(xcWidget w, float *dataptr)
444
467
{
445
468
   float oldvalue = *dataptr;
446
469
   int res = sscanf(_STR2, "%f", dataptr);
447
470
 
448
 
   if (res == 0 || *dataptr <= 0 || objectdata->width == 0) {
 
471
   if (res == 0 || *dataptr <= 0 || topobject->bbox.width == 0) {
449
472
      *dataptr = oldvalue;
450
473
      Wprintf("Illegal value");
451
474
   }
452
475
   else {
453
 
      *dataptr = (*dataptr * 72) / objectdata->width;
 
476
      *dataptr = (*dataptr * 72) / topobject->bbox.width;
454
477
      *dataptr /= getpsscale(1.0, areastruct.page);
455
478
   }
456
479
}
459
482
/* Set the page orientation (either Landscape or Portrait)        */
460
483
/*----------------------------------------------------------------*/
461
484
 
462
 
void setorient(Widget w, short *dataptr)
 
485
void setorient(xcWidget w, short *dataptr)
463
486
{
464
487
   Arg wargs[1];
465
488
 
 
489
#ifndef TCL_WRAPPER
466
490
   if (*dataptr == 0) {
467
491
      *dataptr = 90;
468
492
      XtSetArg(wargs[0], XtNlabel, "Landscape");
472
496
      XtSetArg(wargs[0], XtNlabel, "Portrait");
473
497
   }
474
498
   XtSetValues(w, wargs, 1);
 
499
#endif
475
500
}
476
501
 
477
502
/*----------------------------------------------------------------*/
479
504
/* or "Embedded" (encapsulated PostScript)                        */
480
505
/*----------------------------------------------------------------*/
481
506
 
482
 
void setpmode(Widget w, short *dataptr)
 
507
void setpmode(xcWidget w, short *dataptr)
483
508
{
484
509
   Arg wargs[1];
485
 
   Widget pwidg = XtParent(w);
486
 
   Widget autowidg = XtNameToWidget(pwidg, "Auto-fit");
 
510
#ifndef TCL_WRAPPER
 
511
   xcWidget pwidg = XtParent(w);
 
512
   xcWidget autowidg = XtNameToWidget(pwidg, "Auto-fit");
487
513
 
488
514
   if (!(*dataptr & 1)) {
489
515
      *dataptr = 1;
504
530
      XtUnmanageChild(autowidg);
505
531
   }
506
532
   XtSetValues(w, wargs, 1);
507
 
}
508
 
 
509
 
/*----------------------------------------------------------------*/
510
 
/* Set the output page size, in the current unit of measure       */
511
 
/*----------------------------------------------------------------*/
512
 
 
513
 
void setpagesize(Widget w, XPoint *dataptr)
 
533
#endif
 
534
}
 
535
 
 
536
#ifdef TCL_WRAPPER
 
537
 
 
538
/*--------------------------------------------------------------*/
 
539
/* Parse a string for possible units of measure.  Convert to    */ 
 
540
/* current units of measure, if necessary.  Return the value    */
 
541
/* in current units, as a type float.                           */
 
542
/*--------------------------------------------------------------*/
 
543
 
 
544
float parseunits(char *strptr)
 
545
{
 
546
   short curtype;
 
547
   Boolean inchunits = True;
 
548
   float pv;
 
549
   char units[12];
 
550
 
 
551
   curtype = xobjs.pagelist[areastruct.page]->coordstyle;
 
552
 
 
553
   if (sscanf(strptr, "%f %11s", &pv, units) < 2)
 
554
      return pv;
 
555
   else {
 
556
      if (!strncmp(units, "cm", 2) || !strncmp(units, "centimeters", 11))
 
557
         inchunits = False;
 
558
      switch(curtype) {
 
559
         case CM:
 
560
            return ((inchunits) ? (pv * 2.54) : pv);
 
561
         default:
 
562
            return ((inchunits) ? pv : (pv / 2.54));
 
563
      }
 
564
   }
 
565
}
 
566
 
 
567
#endif
 
568
 
 
569
/*--------------------------------------------------------------*/
 
570
/* Set the output page size, in the current unit of measure     */
 
571
/*--------------------------------------------------------------*/
 
572
 
 
573
void setpagesize(xcWidget w, XPoint *dataptr)
514
574
{
515
575
   float px, py;
516
576
   char units[10], *expos, fpedit[75];
558
618
          (float)xobjs.pagelist[areastruct.page]->pagesize.x
559
619
          / 72.0, (float)xobjs.pagelist[areastruct.page]->pagesize.y / 72.0);
560
620
   }
 
621
 
 
622
#ifndef TCL_WRAPPER
561
623
   XtSetArg(wargs[0], XtNstring, fpedit);
562
624
   XtSetValues(XtNameToWidget(XtParent(w), "fpedit"), wargs, 1);
 
625
#endif
563
626
}
564
627
 
565
628
/*--------------------------------------------------------------*/
567
630
/* is two integer numbers in the range -128 to +127 (size char) */
568
631
/*--------------------------------------------------------------*/
569
632
 
570
 
void getkern(Widget button, caddr_t nulldata, caddr_t calldata)
 
633
void getkern(xcWidget button, caddr_t nulldata, caddr_t calldata)
571
634
{
572
635
   char buffer[50];
573
636
   buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
578
641
 
579
642
   if (eventmode == TEXT2_MODE || eventmode == TEXT3_MODE) {
580
643
      labelptr curlabel = TOLABEL(EDITPART);
581
 
      strptr = findstringpart(textpos - 1, NULL, curlabel->string, NORMINST);
582
 
      nextptr = findstringpart(textpos, NULL, curlabel->string, NORMINST);
 
644
      strptr = findstringpart(textpos - 1, NULL, curlabel->string, areastruct.topinstance);
 
645
      nextptr = findstringpart(textpos, NULL, curlabel->string, areastruct.topinstance);
583
646
      if (strptr->type == KERN) {
584
647
         kx = strptr->data.kern[0];
585
648
         ky = strptr->data.kern[1];
602
665
/* Set a character kern value                                   */ 
603
666
/*--------------------------------------------------------------*/
604
667
 
605
 
void setkern(Widget w, stringpart *kpart)
 
668
void setkern(xcWidget w, stringpart *kpart)
606
669
{
607
670
   char *sptr;
608
671
   short kd[2];
632
695
/* whole-number ratio X:Y                                         */
633
696
/*----------------------------------------------------------------*/
634
697
 
635
 
void getdscale(Widget button, caddr_t nulldata, caddr_t calldata)
 
698
void getdscale(xcWidget button, caddr_t nulldata, caddr_t calldata)
636
699
{
637
700
   char buffer[50];
638
701
   buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
647
710
/* Set the drawing scale (specified as ratio X:Y)                 */
648
711
/*----------------------------------------------------------------*/
649
712
 
650
 
void setdscale(Widget w, XPoint *dataptr)
 
713
void setdscale(xcWidget w, XPoint *dataptr)
651
714
{
652
715
   char *sptr;
653
716
 
664
727
}
665
728
 
666
729
/*--------------------------------------------------------------*/
667
 
/* Generate the popup dialog for getting text scale.            */ 
 
730
/* Get the text size (global or selected, depending on mode     */
668
731
/*--------------------------------------------------------------*/
669
732
 
670
 
void gettsize(Widget button, caddr_t nulldata, caddr_t calldata)
 
733
labelptr gettextsize(float **floatptr)
671
734
{
672
 
   char buffer[50];
673
 
   buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
674
735
   labelptr settext = NULL;
675
 
   float      *floatptr = &areastruct.textscale;
676
 
   short *osel;
 
736
   short    *osel;
677
737
   stringpart *strptr, *nextptr;
 
738
   const float f_one = 1.00;
 
739
 
 
740
   if (floatptr) *floatptr = &areastruct.textscale;
678
741
 
679
742
   if (eventmode == TEXT2_MODE || eventmode == TEXT3_MODE) {
680
 
      if (textpos > 0 || textpos < stringlength(settext->string, True, NORMINST)) {
 
743
      if (textpos > 0 || textpos < stringlength(settext->string, True,
 
744
                areastruct.topinstance)) {
681
745
         settext = *((labelptr *)EDITPART);
682
 
         strptr = findstringpart(textpos - 1, NULL, settext->string, NORMINST);
683
 
         nextptr = findstringpart(textpos, NULL, settext->string, NORMINST);
 
746
         strptr = findstringpart(textpos - 1, NULL, settext->string,
 
747
                        areastruct.topinstance);
 
748
         nextptr = findstringpart(textpos, NULL, settext->string,
 
749
                        areastruct.topinstance);
684
750
         if (strptr->type == FONT_SCALE) {
685
 
            floatptr = &strptr->data.scale;
686
 
            sprintf(buffer, "%5.3f", strptr->data.scale);
 
751
            if (floatptr) *floatptr = &strptr->data.scale;
687
752
         }
688
753
         else if (nextptr && nextptr->type == FONT_SCALE) {
689
 
            floatptr = &nextptr->data.scale;
690
 
            sprintf(buffer, "%5.3f", nextptr->data.scale);
691
 
         }
692
 
         else {
693
 
            floatptr = (float *)NULL;
694
 
            strcpy(buffer, "1.00");
695
 
         }
 
754
            if (floatptr) *floatptr = &nextptr->data.scale;
 
755
         }
 
756
         else if (floatptr) *floatptr = (float *)(&f_one);
696
757
      }
697
758
      else {
698
759
         settext = *((labelptr *)EDITPART);
699
 
         floatptr = &(settext->scale);
700
 
         sprintf(buffer, "%4.2f", *floatptr);
 
760
         if (floatptr) *floatptr = &(settext->scale);
701
761
      }
702
762
   }
703
763
   else if (areastruct.selects > 0) {
704
764
      for (osel = areastruct.selectlist; osel < areastruct.selectlist +
705
 
                areastruct.selects; osel++)
 
765
                areastruct.selects; osel++) {
706
766
         if (SELECTTYPE(osel) == LABEL) {
707
767
            settext = SELTOLABEL(osel);
708
 
            floatptr = &(settext->scale);
 
768
            if (floatptr) *floatptr = &(settext->scale);
709
769
            break;
710
770
         }
711
 
      sprintf(buffer, "%4.2f", *floatptr);
 
771
      }
712
772
   }
713
 
   if (settext != NULL) {
 
773
   return settext;
 
774
}
 
775
 
 
776
/*--------------------------------------------------------------*/
 
777
/* Generate the popup dialog for getting text scale.            */ 
 
778
/*--------------------------------------------------------------*/
 
779
 
 
780
void gettsize(xcWidget button, caddr_t nulldata, caddr_t calldata)
 
781
{
 
782
   char buffer[50];
 
783
   buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
 
784
   float *floatptr;
 
785
   Boolean local;
 
786
   labelptr settext;
 
787
 
 
788
   settext = gettextsize(&floatptr);
 
789
   sprintf(buffer, "%5.2f", *floatptr);
 
790
 
 
791
   if (settext) {
714
792
      getgeneric(savebutton, button, gettsize, settext);
715
793
      popupprompt(button, "Enter text scale:", buffer, settsize, savebutton, NULL);
716
794
   }
717
795
   else {
718
 
      sprintf(buffer, "%4.2f", *floatptr);
719
796
      getgeneric(savebutton, button, gettsize, floatptr);
720
797
      popupprompt(button,
721
798
            "Enter default text scale:", buffer, setfloat, savebutton, NULL);
726
803
/* Set the scale of an object or group of selected objects        */
727
804
/*----------------------------------------------------------------*/
728
805
 
729
 
void setosize(Widget w, objinstptr dataptr)
 
806
void setosize(xcWidget w, objinstptr dataptr)
730
807
{
731
808
   float tmpres;
732
809
   short *osel;
745
822
      }
746
823
   }
747
824
   objectdeselect();
748
 
   pwriteback(NORMINST);
 
825
   pwriteback(areastruct.topinstance);
749
826
   drawarea(NULL, NULL, NULL);
750
827
}
751
828
 
753
830
/* Generate popup dialog for getting object scale                 */
754
831
/*----------------------------------------------------------------*/
755
832
 
756
 
void getosize(Widget button, caddr_t clientdata, caddr_t calldata)
 
833
void getosize(xcWidget button, caddr_t clientdata, caddr_t calldata)
757
834
{
758
835
   char buffer[50];
759
836
   float flval;
782
859
/* Generate popup prompt for getting global linewidth             */
783
860
/*----------------------------------------------------------------*/
784
861
 
785
 
void getwirewidth(Widget button, caddr_t clientdata, caddr_t calldata)
 
862
void getwirewidth(xcWidget button, caddr_t clientdata, caddr_t calldata)
786
863
{
787
864
   char buffer[50];
788
865
   buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
800
877
/* paths.                                                         */
801
878
/*----------------------------------------------------------------*/
802
879
 
803
 
void setwwidth(Widget w, void *dataptr)
 
880
void setwwidth(xcWidget w, void *dataptr)
804
881
{
805
882
   float     tmpres;
806
883
   short     *osel;
837
914
         }
838
915
      }
839
916
      objectdeselect();
840
 
      pwriteback(NORMINST);
 
917
      pwriteback(areastruct.topinstance);
841
918
      drawarea(NULL, NULL, NULL);
842
919
   }
843
920
}
846
923
/* Generate popup dialong for getting linewidths of elements      */ 
847
924
/*----------------------------------------------------------------*/
848
925
 
849
 
void getwwidth(Widget button, caddr_t clientdata, caddr_t calldata)
 
926
void getwwidth(xcWidget button, caddr_t clientdata, caddr_t calldata)
850
927
{
851
928
   char buffer[50];
852
929
   buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
855
932
   float flval;
856
933
 
857
934
   for (; osel < areastruct.selectlist + areastruct.selects; osel++) {
858
 
      setel = *(objectdata->plist + (*osel));
 
935
      setel = *(topobject->plist + (*osel));
859
936
      if (setel->type == ARC) {
860
937
         flval = ((arcptr)setel)->width;
861
938
         break;
890
967
/* Generic popup prompt for getting a floating-point value        */
891
968
/*----------------------------------------------------------------*/
892
969
 
893
 
void getfloat(Widget button, float *floatptr, caddr_t calldata)
 
970
void getfloat(xcWidget button, float *floatptr, caddr_t calldata)
894
971
{
895
972
   char buffer[50];
896
973
   buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
904
981
/* Set the filename for the current page                          */
905
982
/*----------------------------------------------------------------*/
906
983
 
907
 
void setfilename(Widget w, char **dataptr)
 
984
void setfilename(xcWidget w, char **dataptr)
908
985
{
909
986
   short cpage, depend = 0;
910
987
   objectptr checkpage;
917
994
 
918
995
   /* All existing filenames which match the old string should also be changed */
919
996
   for (cpage = 0; cpage < xobjs.pages; cpage++) {
920
 
      checkpage = xobjs.pagelist[cpage]->pageobj;
921
 
      if ((checkpage != NULL) && (cpage != areastruct.page)) {
 
997
      if ((xobjs.pagelist[cpage]->pageinst != NULL) && (cpage != areastruct.page)) {
922
998
         if (!strcmp(xobjs.pagelist[cpage]->filename, oldstr)) {
923
999
            free(xobjs.pagelist[cpage]->filename);
924
1000
            xobjs.pagelist[cpage]->filename = strdup(_STR2);
932
1008
/* Set the page label for the current page                        */
933
1009
/*----------------------------------------------------------------*/
934
1010
 
935
 
void setpagelabel(Widget w, char *dataptr)
 
1011
void setpagelabel(xcWidget w, char *dataptr)
936
1012
{
937
1013
   short i;
938
1014
 
947
1023
 
948
1024
   if (!strcmp(dataptr, _STR2)) return; /* no change in string */
949
1025
   if (strlen(_STR2) == 0)
950
 
      sprintf(objectdata->name, "Page %d", areastruct.page + 1);
 
1026
      sprintf(topobject->name, "Page %d", areastruct.page + 1);
951
1027
   else
952
 
      sprintf(objectdata->name, "%.79s", _STR2);
 
1028
      sprintf(topobject->name, "%.79s", _STR2);
953
1029
 
954
1030
#ifdef SCHEMA
955
1031
   /* For schematics, all pages with associations to symbols must have  */
956
1032
   /* unique names.                                                     */
957
 
   if (objectdata->symschem != NULL) checkpagename(objectdata);
 
1033
   if (topobject->symschem != NULL) checkpagename(topobject);
958
1034
#endif
959
1035
 
960
 
   printname(objectdata);
 
1036
   printname(topobject);
961
1037
   renamepage(areastruct.page);
962
1038
}
963
1039
 
964
1040
/*--------------------------------------------------------------*/
965
1041
/* Add a new font name to the list of known fonts               */
 
1042
/* Register the font number for the Alt-F cycling mechanism     */
 
1043
/* Tcl: depends on command tag mechanism for GUI menu update.   */
966
1044
/*--------------------------------------------------------------*/
967
1045
 
968
1046
void makenewfontbutton()
969
1047
{
 
1048
 
 
1049
#ifndef TCL_WRAPPER
970
1050
   Arg  wargs[1];
971
1051
   int  n = 0;
972
 
   Widget newbutton, cascade;
 
1052
   xcWidget newbutton, cascade;
973
1053
 
974
1054
   if (fontcount == 0) return;
975
1055
 
981
1061
   XtAddCallback (newbutton, XtNselect, (XtCallbackProc)setfont,
982
1062
                Number(fontcount - 1));
983
1063
   XtManageChild(newbutton);
 
1064
#endif
984
1065
 
985
1066
   nfontnumbers++;
986
1067
   if (nfontnumbers == 1)
991
1072
   fontnumbers[nfontnumbers - 1] = fontcount - 1;
992
1073
}
993
1074
 
 
1075
#ifndef TCL_WRAPPER
 
1076
 
994
1077
/*--------------------------------------------------------------*/
995
1078
/* Make new encoding menu button                                */
996
1079
/*--------------------------------------------------------------*/
999
1082
{
1000
1083
   Arg  wargs[1];
1001
1084
   int  n = 0;
1002
 
   Widget newbutton, cascade;
 
1085
   xcWidget newbutton, cascade;
1003
1086
 
1004
1087
   cascade = XtParent(EncodingStandardButton);
1005
1088
 
1016
1099
   XtManageChild(newbutton);
1017
1100
}
1018
1101
 
 
1102
#endif
 
1103
 
1019
1104
/*--------------------------------------------------------------*/
1020
1105
/* Set the menu checkmarks on the font menu                     */
1021
1106
/*--------------------------------------------------------------*/
1022
1107
 
 
1108
#ifdef TCL_WRAPPER
 
1109
 
 
1110
void togglefontmark(int fontval)
 
1111
{
 
1112
   Tcl_SetVar(xcinterp, "fontfamily", fonts[fontval].family, TCL_NAMESPACE_ONLY);
 
1113
}
 
1114
 
 
1115
#else
 
1116
 
1023
1117
void togglefontmark(int fontval)
1024
1118
{
1025
1119
   Arg args[1];
1026
 
   Widget widget, cascade, sibling;
 
1120
   xcWidget widget, cascade, sibling;
1027
1121
   short i;
1028
1122
 
1029
1123
   cascade = XtParent(FontAddNewFontButton);
1045
1139
   XtSetValues(widget, args, 1);
1046
1140
}
1047
1141
 
 
1142
#endif
 
1143
 
 
1144
#ifndef TCL_WRAPPER
 
1145
 
1048
1146
/*--------------------------------------------------------------------*/
1049
1147
/* Toggle one of a set of menu items, only one of which can be active */
1050
1148
/*--------------------------------------------------------------------*/
1051
1149
 
1052
 
void toggleexcl(Widget widget, menuptr menu, int menulength)
 
1150
void toggleexcl(xcWidget widget, menuptr menu, int menulength)
1053
1151
{
1054
1152
   Arg          args[1];
1055
 
   Widget       parent = XtParent(widget);
1056
 
   Widget       sibling;
 
1153
   xcWidget     parent = xcParent(widget);
 
1154
   xcWidget     sibling;
1057
1155
   menuptr      mitem, mtest;
1058
1156
   short        i;
1059
1157
 
1089
1187
   XtSetValues(widget, args, 1);
1090
1188
}
1091
1189
 
 
1190
#endif
 
1191
 
1092
1192
/*--------------------*/
1093
1193
/* Toggle a menu item */
1094
1194
/*--------------------*/
1095
1195
 
1096
 
void toggle(Widget w, Boolean *boolvalue, caddr_t calldata)
 
1196
#ifdef TCL_WRAPPER
 
1197
 
 
1198
void toggle(xcWidget w, Boolean *boolvalue, caddr_t calldata)
 
1199
{
 
1200
}
 
1201
 
 
1202
#else
 
1203
 
 
1204
void toggle(xcWidget w, Boolean *boolvalue, caddr_t calldata)
1097
1205
{
1098
1206
   Arg  wargs[1];
1099
1207
 
1103
1211
   drawarea(w, NULL, NULL);
1104
1212
}
1105
1213
 
 
1214
#endif
 
1215
 
1106
1216
/*---------------------------------------------------------------*/
1107
1217
/* Some Xcircuit routines using toggle and toggleexcl,           */
1108
1218
/* put here because they reference the menu structures directly. */
1111
1221
void setcolorscheme(Boolean boolvalue)
1112
1222
{
1113
1223
   if (boolvalue) {
1114
 
      BBOXCOLOR = appdata.bboxpix;
1115
1224
      PARAMCOLOR = appdata.parampix;
1116
1225
      AUXCOLOR = appdata.auxpix;
1117
1226
      BARCOLOR = appdata.barpix;
1126
1235
      FOREGROUND = appdata.fg;
1127
1236
   }
1128
1237
   else {
1129
 
      BBOXCOLOR = appdata.bboxpix2;
1130
1238
      PARAMCOLOR = appdata.parampix2;
1131
1239
      AUXCOLOR = appdata.auxpix2;
1132
1240
      BARCOLOR = appdata.barpix2;
1148
1256
/* Invert the color scheme used for the background/foreground     */
1149
1257
/*----------------------------------------------------------------*/
1150
1258
 
1151
 
void inversecolor(Widget w, Boolean *boolvalue, caddr_t calldata)
 
1259
#ifndef TCL_WRAPPER
 
1260
 
 
1261
void inversecolor(xcWidget w, Boolean *boolvalue, caddr_t calldata)
1152
1262
{
1153
1263
   /* change color scheme */
1154
1264
 
1158
1268
 
1159
1269
   if (w == NULL) w = OptionsAltColorsButton;
1160
1270
   if (w != NULL) toggle(w, boolvalue, calldata);
1161
 
   if (eventmode == NORMAL_MODE) XDefineCursor (dpy, win, CROSS);
 
1271
   if (eventmode == NORMAL_MODE) XDefineCursor (dpy, areastruct.areawin, CROSS);
1162
1272
}
1163
1273
 
 
1274
#endif
 
1275
 
1164
1276
/*----------------------------------------------------------------*/
1165
1277
/* Change menu selection for reported measurement units           */
1166
1278
/*----------------------------------------------------------------*/
1167
1279
 
1168
 
void togglegrid(u_short type)
1169
 
{
1170
 
   Widget button, bparent = XtParent(GridtypedisplayDecimalInchesButton);
 
1280
#ifdef TCL_WRAPPER
 
1281
 
 
1282
void togglegrid(u_short type)
 
1283
{
 
1284
   static char *stylenames[] = {
 
1285
      "decimal inches",
 
1286
      "fractional inches",
 
1287
      "centimeters",
 
1288
   };
 
1289
 
 
1290
   /* Note that Tcl_SetVar() doesn't require double-quotes around the   */
 
1291
   /* string; doing so prevents the menu from recognizing the variable  */
 
1292
   /* value.                                                            */
 
1293
 
 
1294
   Tcl_SetVar(xcinterp, "gridstyle", stylenames[type], TCL_NAMESPACE_ONLY);
 
1295
}
 
1296
 
 
1297
#else
 
1298
 
 
1299
void togglegrid(u_short type)
 
1300
{
 
1301
   xcWidget button, bparent = XtParent(GridtypedisplayDecimalInchesButton);
1171
1302
 
1172
1303
   if (type == CM) button = XtNameToWidget(bparent, "Centimeters");
1173
1304
   else if (type == FRAC_INCH) button = XtNameToWidget(bparent, "Fractional Inches");
1177
1308
   W1printf(" ");
1178
1309
}
1179
1310
 
 
1311
#endif
 
1312
 
1180
1313
/*----------------------------------------------------------------*/
1181
1314
/* Set the default reported grid units to inches or centimeters   */
1182
1315
/*----------------------------------------------------------------*/
1183
1316
 
1184
 
void setgridtype(char *string)
1185
 
{
1186
 
   Widget button, bparent = XtParent(GridtypedisplayDecimalInchesButton);
 
1317
#ifdef TCL_WRAPPER
 
1318
 
 
1319
void setgridtype(char *string)
 
1320
{
 
1321
}
 
1322
 
 
1323
#else
 
1324
 
 
1325
void setgridtype(char *string)
 
1326
{
 
1327
   xcWidget button, bparent = XtParent(GridtypedisplayDecimalInchesButton);
1187
1328
 
1188
1329
   if (!strcmp(string, "inchscale")) {
1189
1330
      button = XtNameToWidget(bparent, "Fractional Inches");
1195
1336
   }
1196
1337
}
1197
1338
 
 
1339
#endif
 
1340
 
1198
1341
/*----------------------------------------------------------------*/
1199
1342
/* Called by setgridtype() to complete setting the reported       */
1200
1343
/* measurement units                                              */
1201
1344
/*----------------------------------------------------------------*/
1202
1345
 
1203
 
void getgridtype(Widget button, u_int value, caddr_t calldata)
 
1346
void getgridtype(xcWidget button, pointertype value, caddr_t calldata)
1204
1347
{
1205
1348
   short oldtype = xobjs.pagelist[areastruct.page]->coordstyle;
1206
1349
   float scalefac = getpsscale(1.0, areastruct.page) / INCHSCALE;
1207
1350
 
 
1351
#ifndef TCL_WRAPPER
1208
1352
   toggleexcl(button, GridStyles, XtNumber(GridStyles));
 
1353
#endif
1209
1354
   xobjs.pagelist[areastruct.page]->coordstyle = (short)value;
1210
1355
 
1211
1356
   switch(value) {
1212
1357
      case FRAC_INCH: case DEC_INCH:
1213
1358
         if (oldtype == CM) {
1214
1359
            xobjs.pagelist[areastruct.page]->outscale *= scalefac;
 
1360
#ifndef TCL_WRAPPER
 
1361
            /* Note:  Tcl defines a method for selecting standard  */
 
1362
            /* page sizes.  We really DON'T want to reset the size */
 
1363
            /* just because we switched measurement formats!       */
 
1364
 
1215
1365
            xobjs.pagelist[areastruct.page]->pagesize.x = 612;
1216
1366
            xobjs.pagelist[areastruct.page]->pagesize.y = 792; /* letter */
 
1367
#endif
1217
1368
         }
1218
1369
         break;
1219
1370
      case CM:
1220
1371
         if (oldtype != CM) {
1221
1372
            xobjs.pagelist[areastruct.page]->outscale *= scalefac;
 
1373
#ifndef TCL_WRAPPER
1222
1374
            xobjs.pagelist[areastruct.page]->pagesize.x = 595;
1223
1375
            xobjs.pagelist[areastruct.page]->pagesize.y = 842; /* A4 */
 
1376
#endif
1224
1377
         }
1225
1378
         break;
1226
1379
   }
1236
1389
/* library directory, and go to that library page.      */
1237
1390
/*------------------------------------------------------*/
1238
1391
 
1239
 
void newlibrary(Widget w, caddr_t clientdata, caddr_t calldata)
 
1392
void newlibrary(xcWidget w, caddr_t clientdata, caddr_t calldata)
1240
1393
{
1241
1394
   int libnum = createlibrary();
1242
1395
   startcatalog(w, libnum, NULL);
1267
1420
 
1268
1421
int createlibrary()
1269
1422
{
1270
 
   Widget libmenu, newbutton, oldbutton;
 
1423
   xcWidget libmenu, newbutton, oldbutton;
1271
1424
   Arg wargs[2];
1272
1425
   char libstring[20];
1273
1426
   int libnum;
 
1427
   objectptr newlibobj;
1274
1428
 
1275
1429
   /* If there's an empty library, return its number */
1276
1430
   if ((libnum = findemptylib()) >= 0) return (libnum + LIBRARY);
1277
1431
   libnum = (xobjs.numlibs++) + LIBRARY;
1278
 
   xobjs.libtop = (objectptr *)realloc(xobjs.libtop, (libnum + 1)
1279
 
                * sizeof(objectptr));
 
1432
   xobjs.libtop = (objinstptr *)realloc(xobjs.libtop,
 
1433
                (libnum + 1) * sizeof(objinstptr));
1280
1434
   xobjs.libtop[libnum] = xobjs.libtop[libnum - 1];
1281
1435
   libnum--;
1282
 
   xobjs.libtop[libnum] = (objectptr) malloc(sizeof(object));
1283
 
   initmem(xobjs.libtop[libnum]);
1284
 
   sprintf(xobjs.libtop[libnum]->name, "Library %d", libnum - LIBRARY + 1);
 
1436
 
 
1437
   newlibobj = (objectptr) malloc(sizeof(object));
 
1438
   initmem(newlibobj);
 
1439
   xobjs.libtop[libnum] = newpageinst(newlibobj);
 
1440
 
 
1441
   sprintf(newlibobj->name, "Library %d", libnum - LIBRARY + 1);
1285
1442
 
1286
1443
   /* Create the library */
1287
1444
 
1291
1448
   xobjs.userlibs[libnum - LIBRARY].library = (objectptr *) malloc(sizeof(objectptr));
1292
1449
   xobjs.userlibs[libnum - LIBRARY].number = 0;
1293
1450
 
 
1451
#ifdef TCL_WRAPPER
 
1452
 
 
1453
   sprintf(_STR2, "xcircuit::newlibrarybutton \"%s\"", newlibobj->name);
 
1454
   Tcl_Eval(xcinterp, _STR2);
 
1455
 
 
1456
#else
 
1457
 
1294
1458
   /* Previously last button becomes new library pointer */
1295
1459
 
1296
1460
   oldbutton = GotoLibraryLibrary2Button;
1297
1461
   XtRemoveAllCallbacks (oldbutton, XtNselect);
1298
1462
   XtAddCallback (oldbutton, XtNselect, (XtCallbackProc)startcatalog,
1299
1463
        Number(libnum));
1300
 
   XtSetArg(wargs[0], XtNlabel, xobjs.libtop[libnum]->name);
 
1464
   XtSetArg(wargs[0], XtNlabel, xobjs.libtop[libnum]->thisobject->name);
1301
1465
   XtSetValues(oldbutton, wargs, 1);
1302
1466
 
1303
1467
   /* Make new entry in the menu to replace the User Library button */
1304
 
   /* Widget name is unique so button can be found later.  Label is */
 
1468
   /* xcWidget name is unique so button can be found later.  Label is */
1305
1469
   /* always set to "User Library"                                  */
1306
1470
 
1307
1471
   sprintf(libstring, "Library %d", libnum - LIBRARY + 2);
1314
1478
        Number(libnum + 1));
1315
1479
   XtManageChild(newbutton);
1316
1480
   GotoLibraryLibrary2Button = newbutton;
 
1481
#endif
1317
1482
 
1318
1483
   /* Update the library directory to include the new page */
1319
1484
 
1327
1492
/* (wrapper for routine events.c:newpage())     */
1328
1493
/*----------------------------------------------*/
1329
1494
 
1330
 
void newpagemenu(Widget w, u_int value, caddr_t nulldata)
 
1495
void newpagemenu(xcWidget w, pointertype value, caddr_t nulldata)
1331
1496
{
1332
1497
   newpage((short)value);
1333
1498
}
1339
1504
 
1340
1505
void makepagebutton()
1341
1506
{
1342
 
   Widget pagemenu, newbutton;
 
1507
   xcWidget pagemenu, newbutton;
1343
1508
   Arg wargs[1];
1344
1509
   char pagestring[10];
1345
1510
 
1346
1511
   /* make new entry in the menu */
1347
1512
 
 
1513
#ifdef TCL_WRAPPER
 
1514
   sprintf(_STR2, "newpagebutton \"Page %d\"", xobjs.pages);
 
1515
   Tcl_Eval(xcinterp, _STR2);
 
1516
#else
1348
1517
   pagemenu = XtParent(GotoPageAddNewPageButton);
1349
1518
   XtSetArg(wargs[0], XtNfont, appdata.xcfont);
1350
1519
   sprintf(pagestring, "Page %d", xobjs.pages);
1353
1522
   XtAddCallback (newbutton, XtNselect, (XtCallbackProc)newpagemenu,
1354
1523
        Number(xobjs.pages - 1));
1355
1524
   XtManageChild(newbutton);
 
1525
#endif
1356
1526
 
1357
1527
   /* Update the page directory */
1358
1528
 
1367
1537
 
1368
1538
void renamepage(short pagenumber)
1369
1539
{
 
1540
#ifdef TCL_WRAPPER
 
1541
   char *pname, *plabel;
 
1542
 
 
1543
   if ((pagenumber >= 0) && (pagenumber < xobjs.pages - 1) &&
 
1544
            (xobjs.pagelist[pagenumber]->pageinst != NULL)) {
 
1545
      plabel = xobjs.pagelist[pagenumber]->pageinst->thisobject->name;
 
1546
      pname = (char *)malloc(28 + strlen(plabel));
 
1547
      sprintf(pname, "xcircuit::renamepage %d {%s}", pagenumber + 1, plabel);
 
1548
      Tcl_Eval(xcinterp, pname);
 
1549
      free(pname);
 
1550
   }
 
1551
#else
1370
1552
   Arg wargs[1];
1371
 
   Widget parent = XtParent(GotoPageAddNewPageButton);
1372
 
   Widget button;
 
1553
   xcWidget parent = XtParent(GotoPageAddNewPageButton);
 
1554
   xcWidget button;
1373
1555
   char bname[10];
1374
1556
 
1375
1557
   sprintf(bname, "Page %d", pagenumber + 1);
1376
1558
   button = XtNameToWidget(parent, bname);
1377
1559
 
1378
 
   if (button != NULL) {
1379
 
      if (xobjs.pagelist[pagenumber]->pageobj->name != NULL)
1380
 
         XtSetArg(wargs[0], XtNlabel, xobjs.pagelist[pagenumber]->pageobj->name);
 
1560
   if ((button != NULL) && (xobjs.pagelist[pagenumber]->pageinst != NULL)) {
 
1561
      if (xobjs.pagelist[pagenumber]->pageinst->thisobject->name != NULL)
 
1562
         XtSetArg(wargs[0], XtNlabel,
 
1563
                xobjs.pagelist[pagenumber]->pageinst->thisobject->name);
1381
1564
      else
1382
1565
         XtSetArg(wargs[0], XtNlabel, bname);
1383
1566
      XtSetValues(button, wargs, 1);
1384
1567
   }
1385
 
   else
1386
 
      printf("Error:  No Button Widget named \"%9s\"\n", bname);
 
1568
   else if (button == NULL)
 
1569
      Fprintf(stderr, "Error:  No Button Widget named \"%9s\"\n", bname);
 
1570
#endif
1387
1571
}
1388
1572
 
1389
1573
/*--------------------------------------------------------------*/
1392
1576
 
1393
1577
void renamelib(short libnumber)
1394
1578
{
 
1579
#ifdef TCL_WRAPPER
 
1580
   sprintf(_STR2, "xcircuit::renamelib %d \"%s\"", libnumber - LIBRARY + 1,
 
1581
        xobjs.libtop[libnumber]->thisobject->name);
 
1582
   Tcl_Eval(xcinterp, _STR2);
 
1583
#else
1395
1584
   Arg wargs[1];
1396
 
   Widget parent = XtParent(GotoLibraryAddNewLibraryButton);
1397
 
   Widget button;
 
1585
   xcWidget parent = XtParent(GotoLibraryAddNewLibraryButton);
 
1586
   xcWidget button;
1398
1587
   char bname[13];
1399
1588
 
1400
1589
   sprintf(bname, "Library %d", libnumber - LIBRARY + 1);
1401
1590
   button = XtNameToWidget(parent, bname);
1402
1591
 
1403
1592
   if (button != NULL) {
1404
 
      if (xobjs.libtop[libnumber]->name != NULL)
1405
 
         XtSetArg(wargs[0], XtNlabel, xobjs.libtop[libnumber]->name);
 
1593
      if (xobjs.libtop[libnumber]->thisobject->name != NULL)
 
1594
         XtSetArg(wargs[0], XtNlabel, xobjs.libtop[libnumber]->thisobject->name);
1406
1595
      else
1407
1596
         XtSetArg(wargs[0], XtNlabel, bname);
1408
1597
      XtSetValues(button, wargs, 1);
1409
1598
   }
1410
1599
   else
1411
 
      printf("Error:  No Button Widget named \"%12s\"\n", bname);
 
1600
      Fprintf(stderr, "Error:  No Button Widget named \"%12s\"\n", bname);
 
1601
#endif
1412
1602
}
1413
1603
 
1414
1604
/*----------------------------------------------*/
1418
1608
#define BORDERS  (NOBORDER | DOTTED | DASHED)
1419
1609
#define ALLFILLS (FILLSOLID | FILLED)
1420
1610
 
1421
 
/*----------------------------------------------*/
1422
 
/* Set the menu marks according to style value  */
1423
 
/*----------------------------------------------*/
1424
 
 
1425
 
void setstylemarks(Widget w, u_int value, Boolean boolval)
1426
 
{
1427
 
   Arg  wargs[1];
1428
 
 
1429
 
   /* if widget is unknown, find button for each part */
1430
 
 
1431
 
   if (value & UNCLOSED) {
1432
 
      XtSetArg(wargs[0], XtNsetMark, boolval);
1433
 
      XtSetValues(w, wargs, 1);
1434
 
   }
1435
 
   if (value & OPAQUE) {
1436
 
      XtSetArg(wargs[0], XtNsetMark, boolval);
1437
 
      XtSetValues(w, wargs, 1);
1438
 
   }
1439
 
   if (value & BBOX) {
1440
 
      XtSetArg(wargs[0], XtNsetMark, boolval);
1441
 
      XtSetValues(w, wargs, 1);
1442
 
   }
1443
 
   if (value & BORDERS || value & ALLFILLS || value == 0) {
1444
 
      toggleexcl(w, BorderStyles, XtNumber(BorderStyles));
1445
 
      toggleexcl(w, Stipples, XtNumber(Stipples));
1446
 
   }
1447
 
}
1448
 
 
1449
1611
/*--------------------------------------------------------------*/
1450
1612
/* Set the menu checkmarks on the color menu                    */
1451
1613
/*--------------------------------------------------------------*/
1452
1614
 
1453
1615
void setcolormark(int colorval)
1454
1616
{
 
1617
#ifndef TCL_WRAPPER
1455
1618
   Arg args[1];
1456
 
   Widget w = NULL;
 
1619
   xcWidget w = NULL;
1457
1620
   short i;
1458
1621
 
1459
1622
   if (colorval == DEFAULTCOLOR)
1475
1638
 
1476
1639
   /* Add mark to the menu button for the chosen color */
1477
1640
 
1478
 
   if (w != (Widget)NULL) {
 
1641
   if (w != (xcWidget)NULL) {
1479
1642
      overdrawpixmap(w);
1480
1643
      XtSetArg(args[0], XtNsetMark, True);
1481
1644
      XtSetValues(w, args, 1);
1482
1645
   }
 
1646
#else
 
1647
   /* Set GUI variables and execute any command tags associated */
 
1648
   /* with the "color" command */
 
1649
 
 
1650
   Tcl_Obj *objv[2];
 
1651
   int i;
 
1652
 
 
1653
   objv[0] = Tcl_NewStringObj("color", 5);
 
1654
   if (colorval == DEFAULTCOLOR)
 
1655
      objv[1] = Tcl_NewStringObj("inherit", 7);
 
1656
   else {
 
1657
      for (i = 0; i < number_colors; i++)
 
1658
         if (colorlist[i].color.pixel == colorval)
 
1659
            break;
 
1660
      objv[1] = Tcl_NewIntObj((int)i);
 
1661
   }
 
1662
   Tcl_SetVar2Ex(xcinterp, "colorval", NULL, objv[1], TCL_NAMESPACE_ONLY);
 
1663
 
 
1664
   XcTagCallback(xcinterp, 2, objv);
 
1665
#endif
1483
1666
}
1484
1667
 
1485
1668
/*----------------------------------------------------------------*/
1486
1669
/* Set the checkmarks on the element styles menu                  */
1487
1670
/*----------------------------------------------------------------*/
1488
1671
 
1489
 
void setallstylemarks(short styleval)
 
1672
void setallstylemarks(u_short styleval)
1490
1673
{
1491
 
   Widget w;
1492
 
 
1493
 
   w = BorderClosedButton;
1494
 
   setstylemarks(w, UNCLOSED, !(styleval & UNCLOSED));
1495
 
   w = FillOpaqueButton;
1496
 
   setstylemarks(w, OPAQUE, (styleval & OPAQUE) > 0);
1497
 
   w = BorderBoundingBoxButton;
1498
 
   setstylemarks(w, BBOX, (styleval & BBOX) > 0);
 
1674
#ifndef TCL_WRAPPER
 
1675
   xcWidget w;
 
1676
   Arg  wargs[1];
 
1677
 
 
1678
   XtSetArg(wargs[0], XtNsetMark, (styleval & UNCLOSED) ? 0 : 1);
 
1679
   XtSetValues(BorderClosedButton, wargs, 1);
 
1680
 
 
1681
   XtSetArg(wargs[0], XtNsetMark, (styleval & BBOX) ? 1 : 0);
 
1682
   XtSetValues(BorderBoundingBoxButton, wargs, 1);
1499
1683
 
1500
1684
   if (styleval & NOBORDER)
1501
1685
      w = BorderUnborderedButton;
1505
1689
      w = BorderDottedButton;
1506
1690
   else
1507
1691
      w = BorderSolidButton;
1508
 
   setstylemarks(w, BORDERS, 0);
 
1692
   toggleexcl(w, BorderStyles, XtNumber(BorderStyles));
 
1693
 
 
1694
   if (styleval & OPAQUE)
 
1695
      w = FillOpaqueButton;
 
1696
   else
 
1697
      w = FillTransparentButton;
 
1698
   toggleexcl(w, Stipples, XtNumber(Stipples));
1509
1699
 
1510
1700
   if (!(styleval & FILLED))
1511
1701
      w = FillWhiteButton;
1523
1713
         case 7: w = FillBlackButton;  break;
1524
1714
      }
1525
1715
   }
1526
 
   setstylemarks(w, ALLFILLS, 0);
 
1716
   toggleexcl(w, Stipples, XtNumber(Stipples));
 
1717
#else
 
1718
 
 
1719
   /* Set GUI variables and execute any command tags associated */
 
1720
   /* with the "fill" and "border" commands.                    */
 
1721
 
 
1722
   Tcl_Obj *objv[2];
 
1723
   int fillfactor;
 
1724
   const char *bptr;
 
1725
 
 
1726
   const char *borders[] = {"solid", "unbordered", "dashed", "dotted"};
 
1727
   enum BorderIdx { SolidIdx, UnborderedIdx, DashedIdx, DottedIdx };
 
1728
 
 
1729
   objv[0] = Tcl_NewStringObj("fill", 4);
 
1730
 
 
1731
   if (styleval & FILLED) {
 
1732
      fillfactor = (int)(12.5 * (float)(1 + ((styleval & FILLSOLID) >> 5)));
 
1733
      if (fillfactor == 100)
 
1734
         objv[1] = Tcl_NewStringObj("solid", 5);
 
1735
      else
 
1736
         objv[1] = Tcl_NewIntObj(fillfactor);
 
1737
   }
 
1738
   else
 
1739
      objv[1] = Tcl_NewStringObj("unfilled", 8);
 
1740
 
 
1741
   Tcl_SetVar2Ex(xcinterp, "fillamount", NULL, objv[1], TCL_NAMESPACE_ONLY);
 
1742
   Tcl_SetVar(xcinterp, "opaque", (styleval & OPAQUE) ? "true" : "false",
 
1743
                TCL_NAMESPACE_ONLY);
 
1744
   Tcl_SetVar(xcinterp, "bboxtype", (styleval & BBOX) ? "true" : "false",
 
1745
                TCL_NAMESPACE_ONLY);
 
1746
   Tcl_SetVar(xcinterp, "polyclosed", (styleval & UNCLOSED) ? "false" : "true",
 
1747
                TCL_NAMESPACE_ONLY);
 
1748
 
 
1749
   switch (styleval & BORDERS) {
 
1750
      case DASHED:
 
1751
         bptr = borders[DashedIdx];
 
1752
         break;
 
1753
      case DOTTED:
 
1754
         bptr = borders[DottedIdx];
 
1755
         break;
 
1756
      case NOBORDER:
 
1757
         bptr = borders[UnborderedIdx];
 
1758
         break;
 
1759
      default:
 
1760
         bptr = borders[SolidIdx];
 
1761
         break;
 
1762
   }
 
1763
   Tcl_SetVar(xcinterp, "linestyle", (char *)bptr, TCL_NAMESPACE_ONLY);
 
1764
 
 
1765
   XcTagCallback(xcinterp, 2, objv);
 
1766
 
 
1767
#endif
1527
1768
}
1528
1769
 
1529
1770
/*--------------------------------------------------------------*/
1543
1784
}
1544
1785
 
1545
1786
/*--------------------------------------------------------------*/
1546
 
/* Get a value for element fill style                           */
 
1787
/* Set a value for element style.  "Mask" determines the bits   */
 
1788
/* to be affected, so that "value" may turn bits either on or   */
 
1789
/* off.                                                         */
1547
1790
/*--------------------------------------------------------------*/
1548
1791
 
1549
 
void getfill(Widget w, u_int value, caddr_t nulldata)
 
1792
void setelementstyle(xcWidget w, u_short value, u_short mask)
1550
1793
{
1551
 
   Boolean boolval, selected = False;
 
1794
   Boolean selected = False;
1552
1795
   short *sstyle;
 
1796
   u_short newstyle;
1553
1797
 
1554
1798
   if (areastruct.selects > 0) {
1555
1799
      if (value & BBOX) {
1562
1806
            Wprintf("Bounding box can only be a polygon");
1563
1807
            return;
1564
1808
         }
1565
 
         else if (((ckp = checkforbbox(objectdata)) != NULL) &&
 
1809
         else if (((ckp = checkforbbox(topobject)) != NULL) &&
1566
1810
                (ckp != SELTOPOLY(areastruct.selectlist))) {
1567
1811
            Wprintf("Only one bounding box allowed per page");
1568
1812
            return;
1588
1832
                  estyle = &((SELTOPATH(sstyle))->style);
1589
1833
                  break;
1590
1834
            }
 
1835
            newstyle = *estyle;
 
1836
            newstyle &= ~(mask);
 
1837
            newstyle |= value;
 
1838
 
 
1839
            if ((newstyle & NOBORDER) && !(newstyle & FILLED)) {
 
1840
               Wprintf("Must have either a border or filler");
 
1841
               continue;
 
1842
            }
1591
1843
 
1592
1844
            XSetFunction(dpy, areastruct.gc, GXcopy);
1593
1845
            XSetForeground(dpy, areastruct.gc, BACKGROUND);
1594
1846
            easydraw(*sstyle, DOFORALL);
1595
 
            if (value & UNCLOSED) {
1596
 
               boolval = (*estyle & UNCLOSED) ? True : False;
1597
 
               *estyle &= ~UNCLOSED;
1598
 
               *estyle |= (boolval ? NORMAL : UNCLOSED);
1599
 
            }
1600
 
            else if (value & OPAQUE) {
1601
 
               boolval = (*estyle & OPAQUE) ? False : True;
1602
 
               *estyle &= ~OPAQUE;
1603
 
               *estyle |= (boolval ? OPAQUE : NORMAL);
1604
 
            }
1605
 
            else if (value & BBOX) {
1606
 
               boolval = (*estyle & BBOX) ? False : True;
1607
 
               *estyle &= ~BBOX;
1608
 
               *estyle |= (boolval ? BBOX : NORMAL);
1609
 
               (SELTOPOLY(sstyle))->color = boolval ? BBOXCOLOR : DEFAULTCOLOR;
1610
 
            }
1611
 
            else {
1612
 
               if (value & BORDERS || value == NORMAL) *estyle &= ~BORDERS;
1613
 
               else *estyle &= ~ALLFILLS;
1614
 
               if (value != FILLSOLID) *estyle |= value;
1615
 
               if ((*estyle & NOBORDER) && !(*estyle & FILLED)) {
1616
 
                  Wprintf("Must have either a border or filler");
1617
 
                  *estyle &= ~NOBORDER;
1618
 
                  value &= ~NOBORDER;
1619
 
               }
1620
 
            }
 
1847
 
 
1848
            *estyle = newstyle;
 
1849
            if (mask & BBOX)
 
1850
               (SELTOPOLY(sstyle))->color = (value & BBOX) ? BBOXCOLOR : DEFAULTCOLOR;
 
1851
 
1621
1852
            XSetFunction(dpy, areastruct.gc, GXxor);
1622
1853
            XSetForeground(dpy, areastruct.gc, SELECTCOLOR ^ BACKGROUND);
1623
1854
            easydraw(*sstyle, DOFORALL);
1626
1857
      }
1627
1858
   }
1628
1859
   if (selected)
1629
 
      pwriteback(NORMINST);
 
1860
      pwriteback(areastruct.topinstance);
1630
1861
   else {
 
1862
      newstyle = areastruct.style;
1631
1863
      if (value & BBOX) {
1632
1864
         Wprintf("Cannot set default style to Bounding Box");
1633
 
         areastruct.style &= ~BBOX;
 
1865
         newstyle &= ~(BBOX);
1634
1866
         return;
1635
1867
      }
1636
 
      else if (value & UNCLOSED) {
1637
 
         boolval = (areastruct.style & UNCLOSED) ? True : False;
1638
 
         areastruct.style &= ~UNCLOSED;
1639
 
         areastruct.style |= (boolval ? NORMAL : UNCLOSED);
1640
 
      }
1641
 
      else if (value & OPAQUE) {
1642
 
         boolval = (areastruct.style & OPAQUE) ? False : True;
1643
 
         areastruct.style &= ~OPAQUE;
1644
 
         areastruct.style |= (boolval ? OPAQUE : NORMAL);
1645
 
      }
1646
1868
      else {
1647
 
         short savestyle = areastruct.style;
1648
 
 
1649
 
         if (value & BORDERS || value == NORMAL)
1650
 
            areastruct.style &= ~BORDERS;
1651
 
         else areastruct.style &= ~ALLFILLS;
1652
 
         if (value != FILLSOLID) areastruct.style |= value;
1653
 
 
1654
 
         if ((areastruct.style & NOBORDER) && !(areastruct.style & FILLED)) {
1655
 
            Wprintf("Must have either a border or filler");
1656
 
            areastruct.style = savestyle;
1657
 
            return;
1658
 
         }
1659
 
      }
 
1869
         newstyle &= ~mask;
 
1870
         newstyle |= value;
 
1871
      }
 
1872
 
 
1873
      if ((newstyle & NOBORDER) && !(newstyle & FILLED)) {
 
1874
         Wprintf("Must have either a border or filler");
 
1875
         return;
 
1876
      }
 
1877
      areastruct.style = newstyle;
1660
1878
      overdrawpixmap(w);
1661
1879
   }
1662
 
   if (w)
1663
 
      setstylemarks(w, value, boolval);
1664
 
   else
1665
 
      setallstylemarks(areastruct.style);
1666
 
 
 
1880
   setallstylemarks(newstyle);
1667
1881
   objectdeselect();
1668
1882
}
1669
1883
 
1670
 
/*----------------------------------------------------------------*/
1671
 
/* The following four routines are all wrappers for getfill(),    */
1672
 
/* used in menudefs to differentiate between sections, each of    */
1673
 
/* which has settings independent of the others.                  */
1674
 
/*----------------------------------------------------------------*/
1675
 
 
1676
 
void makebbox(Widget w, u_int value, caddr_t calldata)
1677
 
{
1678
 
   getfill(w, value, NULL);
1679
 
}
1680
 
 
1681
 
/*----------------------------------------------------------------*/
1682
 
 
1683
 
void getset(Widget w, u_int value, caddr_t calldata)
1684
 
{
1685
 
   getfill(w, value, NULL);
1686
 
}
1687
 
 
1688
 
/*----------------------------------------------------------------*/
1689
 
 
1690
 
void getline(Widget w, u_int value, caddr_t calldata)
1691
 
{
1692
 
   getfill(w, value, NULL);
1693
 
}
1694
 
 
1695
 
/*----------------------------------------------------------------*/
1696
 
 
1697
 
void getopaque(Widget w, u_int value, caddr_t calldata)
1698
 
{
1699
 
   getfill(w, value, NULL);
 
1884
/*--------------------------------------------------------------*/
 
1885
/* The following four routines are all wrappers for             */
 
1886
/* setelementstyle(),                                           */
 
1887
/* used in menudefs to differentiate between sections, each of  */
 
1888
/* which has settings independent of the others.                */
 
1889
/*--------------------------------------------------------------*/
 
1890
 
 
1891
void setfill(xcWidget w, pointertype value, caddr_t calldata)
 
1892
{
 
1893
   setelementstyle(w, (u_short)value, OPAQUE | FILLED | FILLSOLID);
 
1894
}
 
1895
 
 
1896
/*--------------------------------------------------------------*/
 
1897
 
 
1898
void makebbox(xcWidget w, pointertype value, caddr_t calldata)
 
1899
{
 
1900
   setelementstyle(w, (u_short)value, BBOX);
 
1901
}
 
1902
 
 
1903
/*--------------------------------------------------------------*/
 
1904
 
 
1905
void setclosure(xcWidget w, pointertype value, caddr_t calldata)
 
1906
{
 
1907
   setelementstyle(w, (u_short)value, UNCLOSED);
 
1908
}
 
1909
 
 
1910
/*----------------------------------------------------------------*/
 
1911
 
 
1912
void setline(xcWidget w, pointertype value, caddr_t calldata)
 
1913
{
 
1914
   setelementstyle(w, (u_short)value, BORDERS);
 
1915
}
 
1916
 
 
1917
/*----------------------------------------------------------------*/
 
1918
 
 
1919
void setopaque(xcWidget w, pointertype value, caddr_t calldata)
 
1920
{
 
1921
   setelementstyle(w, (u_short)value, OPAQUE);
1700
1922
}
1701
1923
   
1702
1924
/*-----------------------------------------------*/
1703
1925
/* Set the color value for all selected elements */
1704
1926
/*-----------------------------------------------*/
1705
1927
 
1706
 
void setcolor(Widget w, u_int value, caddr_t calldata)
 
1928
#ifdef TCL_WRAPPER
 
1929
void setcolor(xcWidget w, int cindex)
 
1930
{
 
1931
   short *scolor;
 
1932
   int *ecolor, cval;
 
1933
   Boolean selected = False;
 
1934
   stringpart *strptr, *nextptr;
 
1935
 
 
1936
   if (cindex == -1) cval = -1;
 
1937
   else cval = colorlist[cindex].color.pixel;
 
1938
 
 
1939
#else
 
1940
 
 
1941
void setcolor(xcWidget w, pointertype value, caddr_t calldata)
1707
1942
{
1708
1943
   short *scolor;
1709
1944
   int *ecolor, cindex, cval;
1718
1953
   else {
1719
1954
      XtSetArg(wargs[0], XtNrectColor, &cval);
1720
1955
      XtGetValues(w, wargs, 1);
 
1956
 
1721
1957
      for (cindex = 0; cindex < number_colors; cindex++)
1722
1958
         if (colorlist[cindex].color.pixel == cval)
1723
1959
            break;
1724
 
      if (cindex == number_colors) {
 
1960
      if (cindex >= number_colors) {
1725
1961
         Wprintf("Error: No such color!");
1726
1962
         return;
1727
1963
      }
1728
1964
   }
 
1965
 
 
1966
#endif
1729
1967
   
1730
1968
   if (eventmode == TEXT2_MODE || eventmode == TEXT3_MODE) {
1731
1969
      labelptr curlabel = TOLABEL(EDITPART);
1732
 
      strptr = findstringpart(textpos - 1, NULL, curlabel->string, NORMINST);
1733
 
      nextptr = findstringpart(textpos, NULL, curlabel->string, NORMINST);
 
1970
      strptr = findstringpart(textpos - 1, NULL, curlabel->string, areastruct.topinstance);
 
1971
      nextptr = findstringpart(textpos, NULL, curlabel->string, areastruct.topinstance);
1734
1972
      if (strptr->type == FONT_COLOR) {
1735
1973
         undrawtext(curlabel);
1736
1974
         strptr->data.color = cindex;
1757
1995
      }
1758
1996
   }
1759
1997
 
1760
 
   setcolormark(cindex);
 
1998
   setcolormark(cval);
1761
1999
   if (!selected) {
1762
2000
      if (eventmode != TEXT2_MODE && eventmode != TEXT3_MODE)
1763
2001
         areastruct.color = cval;      
1771
2009
/* Parse a new color entry and add it to the color list.          */
1772
2010
/*----------------------------------------------------------------*/
1773
2011
 
1774
 
void setnewcolor(Widget w, caddr_t nullptr)
 
2012
void setnewcolor(xcWidget w, caddr_t nullptr)
1775
2013
{
1776
2014
   int ccolor, red, green, blue;
1777
2015
   char *ppos, *cpos;
1805
2043
/* Generate popup dialog for adding a new color name or RGB value */
1806
2044
/*----------------------------------------------------------------*/
1807
2045
 
1808
 
void addnewcolor(Widget w, caddr_t clientdata, caddr_t calldata)
 
2046
void addnewcolor(xcWidget w, caddr_t clientdata, caddr_t calldata)
1809
2047
{
1810
2048
   buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
1811
2049
 
1819
2057
/* fvalue is for font, jvalue is for justification      */
1820
2058
/*------------------------------------------------------*/
1821
2059
 
1822
 
void setfontmarks(short fvalue, short jvalue)
1823
 
{
1824
 
   Widget w;
 
2060
#ifdef TCL_WRAPPER
 
2061
 
 
2062
void togglestylemark(int styleval)
 
2063
{
 
2064
   switch(styleval) {
 
2065
      case 0: Tcl_SetVar(xcinterp, "fontstyle", "normal", TCL_NAMESPACE_ONLY);
 
2066
         break;
 
2067
      case 1: Tcl_SetVar(xcinterp, "fontstyle", "bold", TCL_NAMESPACE_ONLY);
 
2068
         break;
 
2069
      case 2: Tcl_SetVar(xcinterp, "fontstyle", "italic", TCL_NAMESPACE_ONLY);
 
2070
         break;
 
2071
      case 3: Tcl_SetVar(xcinterp, "fontstyle", "bolditalic", TCL_NAMESPACE_ONLY);
 
2072
         break;
 
2073
   }
 
2074
}
 
2075
 
 
2076
/*------------------------------------------------------*/
 
2077
 
 
2078
void toggleencodingmark(int encodingval)
 
2079
{
 
2080
   switch(encodingval) {
 
2081
      case 0: Tcl_SetVar(xcinterp, "fontencoding", "Standard", TCL_NAMESPACE_ONLY);
 
2082
         break;
 
2083
      case 1: Tcl_SetVar(xcinterp, "fontencoding", "special", TCL_NAMESPACE_ONLY);
 
2084
         break;
 
2085
      case 2: Tcl_SetVar(xcinterp, "fontencoding", "ISOLatin1", TCL_NAMESPACE_ONLY);
 
2086
         break;
 
2087
      case 3: Tcl_SetVar(xcinterp, "fontencoding", "ISOLatin2", TCL_NAMESPACE_ONLY);
 
2088
         break;
 
2089
      case 4: Tcl_SetVar(xcinterp, "fontencoding", "ISOLatin3", TCL_NAMESPACE_ONLY);
 
2090
         break;
 
2091
      case 5: Tcl_SetVar(xcinterp, "fontencoding", "ISOLatin4", TCL_NAMESPACE_ONLY);
 
2092
         break;
 
2093
      case 6: Tcl_SetVar(xcinterp, "fontencoding", "ISOLatin5", TCL_NAMESPACE_ONLY);
 
2094
         break;
 
2095
      case 7: Tcl_SetVar(xcinterp, "fontencoding", "ISOLatin6", TCL_NAMESPACE_ONLY);
 
2096
         break;
 
2097
   }
 
2098
}
 
2099
 
 
2100
/*------------------------------------------------------*/
 
2101
 
 
2102
void togglejustmarks(int justvalue)
 
2103
{
 
2104
   switch(justvalue & (NOTLEFT | RIGHT)) {
 
2105
      case NORMAL: Tcl_SetVar(xcinterp, "jhoriz", "left", TCL_NAMESPACE_ONLY);
 
2106
         break;
 
2107
      case NOTLEFT: Tcl_SetVar(xcinterp, "jhoriz", "center", TCL_NAMESPACE_ONLY);
 
2108
         break;
 
2109
      case RIGHT|NOTLEFT: Tcl_SetVar(xcinterp, "jhoriz", "right", TCL_NAMESPACE_ONLY);
 
2110
         break;
 
2111
   }
 
2112
   switch(justvalue & (NOTBOTTOM | TOP)) {
 
2113
      case NORMAL: Tcl_SetVar(xcinterp, "jvert", "bottom", TCL_NAMESPACE_ONLY);
 
2114
         break;
 
2115
      case NOTBOTTOM: Tcl_SetVar(xcinterp, "jvert", "middle", TCL_NAMESPACE_ONLY);
 
2116
         break;
 
2117
      case TOP|NOTBOTTOM: Tcl_SetVar(xcinterp, "jvert", "top", TCL_NAMESPACE_ONLY);
 
2118
         break;
 
2119
   }
 
2120
 
 
2121
   /* Flip Invariance property */
 
2122
   Tcl_SetVar(xcinterp, "flipinvariant", (justvalue & FLIPINV) ? "true" : "false",
 
2123
        TCL_NAMESPACE_ONLY);
 
2124
     
 
2125
#ifdef SCHEMA
 
2126
   /* Pin visibility property */
 
2127
   Tcl_SetVar(xcinterp, "pinvisible", (justvalue & PINVISIBLE) ? "true" : "false",
 
2128
        TCL_NAMESPACE_ONLY);
 
2129
#endif
 
2130
}
 
2131
 
 
2132
/*------------------------------------------------------*/
 
2133
 
 
2134
void setfontmarks(short fvalue, short jvalue)
 
2135
{
 
2136
   if ((fvalue >= 0) && (fontcount > 0)) {
 
2137
      togglestylemark(fonts[fvalue].flags & 0x03);
 
2138
      toggleencodingmark((fonts[fvalue].flags & 0xf80) >> 7);
 
2139
      togglefontmark(fvalue);
 
2140
   }
 
2141
   if (jvalue >= 0) {
 
2142
      togglejustmarks(jvalue);
 
2143
   }
 
2144
}
 
2145
 
 
2146
/*------------------------------------------------------*/
 
2147
 
 
2148
#else /* !TCL_WRAPPER */
 
2149
 
 
2150
void setfontmarks(short fvalue, short jvalue)
 
2151
{
 
2152
   xcWidget w;
1825
2153
   Arg wargs[1];
1826
2154
 
1827
2155
   if ((fvalue >= 0) && (fontcount > 0)) {
1878
2206
   }
1879
2207
}
1880
2208
 
 
2209
#endif /* !TCL_WRAPPER */
 
2210
 
1881
2211
/*--------------------------------------------------------------*/
1882
2212
/* Parameterize a label string (wrapper for parameterize()).    */
1883
2213
/*--------------------------------------------------------------*/
1884
2214
 
1885
 
void startparam(Widget w, u_int value, caddr_t calldata)
 
2215
void startparam(xcWidget w, pointertype value, caddr_t calldata)
1886
2216
{
1887
2217
   genericptr *settext;
1888
2218
 
1891
2221
         settext = (genericptr *)EDITPART;
1892
2222
         makeparam(TOLABEL(settext));
1893
2223
         objectdeselect();
 
2224
         setparammarks(NULL);
1894
2225
      }
1895
 
      else if (checkselect(LABEL)) parameterize(value);
 
2226
      else if (checkselect(LABEL)) parameterize((int)value);
1896
2227
      else
1897
2228
         eventmode = LPARAM_MODE;
1898
2229
   }
1901
2232
         eventmode = IPARAM_MODE;
1902
2233
         Wprintf("Click on object to parameterize.");
1903
2234
      }      
1904
 
      else parameterize(value);
 
2235
      else parameterize((int)value);
1905
2236
   }
1906
2237
}
1907
2238
 
1909
2240
/* Unparameterize a label string (wrapper for parameterize()).  */
1910
2241
/*--------------------------------------------------------------*/
1911
2242
 
1912
 
void startunparam(Widget w, u_int value, caddr_t calldata)
 
2243
void startunparam(xcWidget w, pointertype value, caddr_t calldata)
1913
2244
{
1914
2245
   if (areastruct.selects == 0) {
1915
2246
      if (value == LABEL)
1919
2250
      Wprintf("Select element or substring to remove parameters.");
1920
2251
   }
1921
2252
   else
1922
 
      unparameterize(value);
 
2253
      unparameterize((int)value);
1923
2254
   objectdeselect();
 
2255
   setparammarks(NULL);
1924
2256
}
1925
2257
 
1926
2258
/*----------------------------------------------------------------*/
1936
2268
/* Change flip invariance on the label passed as 2nd parameter    */
1937
2269
/*----------------------------------------------------------------*/
1938
2270
 
1939
 
void doflipflip(Widget w, labelptr settext)
 
2271
void doflipflip(xcWidget w, labelptr settext)
1940
2272
{
1941
2273
   short newjust;
1942
2274
   Boolean boolval;
1950
2282
      undrawtext(settext);
1951
2283
      settext->justify = newjust;
1952
2284
      redrawtext(settext);
1953
 
      pwriteback(NORMINST);
 
2285
      pwriteback(areastruct.topinstance);
1954
2286
   }
1955
2287
   else {
1956
2288
      boolval = (areastruct.justify & FLIPINV) ? True : False;
1965
2297
/* Change pin visibility on the label passed as 2nd parameter     */
1966
2298
/*----------------------------------------------------------------*/
1967
2299
 
1968
 
void dopinvisible(Widget w, labelptr settext)
 
2300
void dopinvisible(xcWidget w, labelptr settext)
1969
2301
{
1970
2302
   short newjust;
1971
2303
   Boolean boolval;
1979
2311
      undrawtext(settext);
1980
2312
      settext->justify = newjust;
1981
2313
      redrawtext(settext);
1982
 
      pwriteback(NORMINST);
 
2314
      pwriteback(areastruct.topinstance);
1983
2315
      if (w != NULL) toggle(w, &boolval, NULL);
1984
2316
   }
1985
2317
}
1988
2320
/* Set the justification for the label passed as 3rd parameter    */
1989
2321
/*----------------------------------------------------------------*/
1990
2322
 
1991
 
void setjust(Widget w, u_int value, labelptr settext, short mode)
 
2323
void setjust(xcWidget w, pointertype value, labelptr settext, short mode)
1992
2324
{
1993
2325
   short newjust;
1994
2326
 
2004
2336
      undrawtext(settext);
2005
2337
      settext->justify = newjust;
2006
2338
      redrawtext(settext);
2007
 
      pwriteback(NORMINST);
 
2339
      pwriteback(areastruct.topinstance);
2008
2340
   }
2009
2341
   else {
2010
2342
      if (mode == 1)
2015
2347
                        | value;
2016
2348
      areastruct.justify = newjust;
2017
2349
   }
 
2350
#ifndef TCL_WRAPPER
2018
2351
   if (w != NULL) toggleexcl(w, Justifs, XtNumber(Justifs));
 
2352
#endif
2019
2353
}
2020
2354
 
2021
2355
/*----------------------------------------------------------------*/
2023
2357
/* selected labels                                                */
2024
2358
/*----------------------------------------------------------------*/
2025
2359
 
2026
 
void setvjust(Widget w, u_int value, caddr_t nulldata)
 
2360
void setvjust(xcWidget w, pointertype value, caddr_t nulldata)
2027
2361
{
2028
2362
   short *fselect;
2029
2363
   labelptr settext;
2052
2386
/* selected labels                                                */
2053
2387
/*----------------------------------------------------------------*/
2054
2388
 
2055
 
void sethjust(Widget w, u_int value, caddr_t nulldata)
 
2389
void sethjust(xcWidget w, pointertype value, caddr_t nulldata)
2056
2390
{
2057
2391
   short *fselect;
2058
2392
   labelptr settext;
2080
2414
/* Set flip invariance on all selected labels                     */ 
2081
2415
/*----------------------------------------------------------------*/
2082
2416
 
2083
 
void setflipinv(Widget w, u_int value, caddr_t nulldata)
 
2417
void setflipinv(xcWidget w, pointertype value, caddr_t nulldata)
2084
2418
{
2085
2419
   short *fselect;
2086
2420
   labelptr settext;
2108
2442
/* Set pin visibility on all selected pins                        */ 
2109
2443
/*----------------------------------------------------------------*/
2110
2444
 
2111
 
void setpinvisible(Widget w, u_int value, caddr_t nulldata)
 
2445
void setpinvisible(xcWidget w, pointertype value, caddr_t nulldata)
2112
2446
{
2113
2447
   short *fselect;
2114
2448
   labelptr settext;
2137
2471
/* Set polygon editing style */
2138
2472
/*---------------------------*/
2139
2473
 
2140
 
void boxedit(Widget w, u_int value, caddr_t nulldata)
 
2474
#ifdef TCL_WRAPPER
 
2475
 
 
2476
void boxedit(xcWidget w, pointertype value, caddr_t nulldata)
 
2477
{
 
2478
   switch (value) {
 
2479
      case MANHATTAN:
 
2480
         Tcl_SetVar(xcinterp, "polyedittype", "manhattan", TCL_NAMESPACE_ONLY);
 
2481
         break;
 
2482
      case RHOMBOIDX:
 
2483
         Tcl_SetVar(xcinterp, "polyedittype", "rhomboidx", TCL_NAMESPACE_ONLY);
 
2484
         break;
 
2485
      case RHOMBOIDY:
 
2486
         Tcl_SetVar(xcinterp, "polyedittype", "rhomboidy", TCL_NAMESPACE_ONLY);
 
2487
         break;
 
2488
      case RHOMBOIDA:
 
2489
         Tcl_SetVar(xcinterp, "polyedittype", "rhomboida", TCL_NAMESPACE_ONLY);
 
2490
         break;
 
2491
      case NORMAL:
 
2492
         Tcl_SetVar(xcinterp, "polyedittype", "normal", TCL_NAMESPACE_ONLY);
 
2493
         break;
 
2494
   }
 
2495
 
 
2496
   if (areastruct.boxedit == value) return;
 
2497
   areastruct.boxedit = value;
 
2498
}
 
2499
 
 
2500
#else
 
2501
 
 
2502
void boxedit(xcWidget w, pointertype value, caddr_t nulldata)
2141
2503
{
2142
2504
   if (w == NULL) {
2143
2505
      switch (value) {
2155
2517
   areastruct.boxedit = value;
2156
2518
}
2157
2519
 
 
2520
#endif
 
2521
 
2158
2522
/*----------------------------------------------------------------*/
2159
2523
/* Pick up font name from _STR2 and pass it to loadfontfile()     */
2160
2524
/*----------------------------------------------------------------*/
2161
2525
 
2162
 
void locloadfont(Widget w, char *value)
 
2526
void locloadfont(xcWidget w, char *value)
2163
2527
{
2164
2528
   loadfontfile(_STR2);
2165
2529
   free(value);
2169
2533
/* Generate popup dialog for entering a new font name */
2170
2534
/*----------------------------------------------------*/
2171
2535
 
2172
 
void addnewfont(Widget w, caddr_t clientdata, caddr_t calldata)
 
2536
void addnewfont(xcWidget w, caddr_t clientdata, caddr_t calldata)
2173
2537
{
2174
2538
   buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
2175
2539
   char *tempstr = malloc(2 * sizeof(char));
2284
2648
/* or as the default font to begin new labels.                    */
2285
2649
/*----------------------------------------------------------------*/
2286
2650
 
2287
 
void setfontval(Widget w, u_int value, labelptr settext)
 
2651
void setfontval(xcWidget w, pointertype value, labelptr settext)
2288
2652
{
2289
2653
   int newfont;
2290
2654
   short i, tc;
2294
2658
 
2295
2659
      /* if last byte was a font designator, use it */
2296
2660
 
2297
 
      if (textpos > 0 || textpos < stringlength(settext->string, True, NORMINST)) {
2298
 
         strptr = findstringpart(textpos - 1, NULL, settext->string, NORMINST);
 
2661
      if (textpos > 0 || textpos < stringlength(settext->string, True, areastruct.topinstance)) {
 
2662
         strptr = findstringpart(textpos - 1, NULL, settext->string, areastruct.topinstance);
2299
2663
         if (strptr->type == FONT_NAME) {
2300
2664
            tc = strptr->data.font;
2301
2665
            i = findbestfont(tc, (short)value, -1, -1);
2313
2677
      }
2314
2678
 
2315
2679
      /* otherwise, look for the last style used in the string */
2316
 
      tc = findcurfont(textpos, settext->string, NORMINST);
 
2680
      tc = findcurfont(textpos, settext->string, areastruct.topinstance);
2317
2681
   }
2318
2682
   else tc = areastruct.psfont;
2319
2683
 
2331
2695
      sprintf(_STR, "Default font is now %s", fonts[newfont].psname);
2332
2696
      areastruct.psfont = newfont;
2333
2697
   }
 
2698
   Wprintf(_STR);
2334
2699
 
2335
2700
   if (w != NULL) togglefontmark(newfont);
2336
 
 
2337
 
   Wprintf(_STR);
2338
2701
}
2339
2702
 
2340
2703
/*----------------------------------------------------------------*/
2341
2704
/* Wrapper for routine setfontval()                               */
2342
2705
/*----------------------------------------------------------------*/
2343
2706
 
2344
 
void setfont(Widget w, u_int value, caddr_t calldata)
 
2707
void setfont(xcWidget w, pointertype value, caddr_t calldata)
2345
2708
{
2346
2709
   short *fselect;
2347
2710
   labelptr settext;
2375
2738
/* to the above routine setfontval().                             */
2376
2739
/*----------------------------------------------------------------*/
2377
2740
 
2378
 
void setfontstyle(Widget w, u_int value, labelptr settext)
 
2741
void setfontstyle(xcWidget w, pointertype value, labelptr settext)
2379
2742
{
2380
2743
   int newfont;
2381
2744
   short i, tc;
2385
2748
 
2386
2749
      /* if last byte was a font designator, use it */
2387
2750
 
2388
 
      if (textpos > 0 || textpos < stringlength(settext->string, True, NORMINST)) {
2389
 
         strptr = findstringpart(textpos - 1, NULL, settext->string, NORMINST);
 
2751
      if (textpos > 0 || textpos < stringlength(settext->string, True, areastruct.topinstance)) {
 
2752
         strptr = findstringpart(textpos - 1, NULL, settext->string, areastruct.topinstance);
2390
2753
         if (strptr->type == FONT_NAME) {
2391
2754
            tc = strptr->data.font;
2392
2755
 
2399
2762
               redrawtext(settext);
2400
2763
               if (w != NULL) {
2401
2764
                  charreport(settext);
 
2765
#ifndef TCL_WRAPPER
2402
2766
                  toggleexcl(w, FontStyles, XtNumber(FontStyles));
 
2767
#endif
2403
2768
               }
2404
2769
            }
2405
2770
            return;
2407
2772
      }
2408
2773
 
2409
2774
      /* otherwise, look for the last font used in the string */
2410
 
      tc = findcurfont(textpos - 2, settext->string, NORMINST);
 
2775
      tc = findcurfont(textpos - 2, settext->string, areastruct.topinstance);
2411
2776
   }
2412
2777
   else tc = areastruct.psfont;
2413
2778
 
2422
2787
      sprintf(_STR, "Default font is now %s", fonts[newfont].psname);
2423
2788
      areastruct.psfont = newfont;
2424
2789
   }
 
2790
#ifdef TCL_WRAPPER
 
2791
   toggleencodingmark(value);
 
2792
#else
2425
2793
   if (w != NULL) toggleexcl(w, FontStyles, XtNumber(FontStyles));
 
2794
#endif
2426
2795
 
2427
2796
   Wprintf(_STR);
2428
2797
}
2431
2800
/* Wrapper for routine setfontstyle()                             */
2432
2801
/*----------------------------------------------------------------*/
2433
2802
 
2434
 
void fontstyle(Widget w, u_int value, caddr_t nulldata)
 
2803
void fontstyle(xcWidget w, pointertype value, caddr_t nulldata)
2435
2804
{
2436
2805
   short *fselect;
2437
2806
   labelptr settext;
2465
2834
/* similarly to the above routine setfontval().                   */
2466
2835
/*----------------------------------------------------------------*/
2467
2836
 
2468
 
void setfontencoding(Widget w, u_int value, labelptr settext)
 
2837
void setfontencoding(xcWidget w, pointertype value, labelptr settext)
2469
2838
{
2470
2839
   int newfont;
2471
2840
   short i, tc;
2475
2844
 
2476
2845
      /* if last byte was a font designator, use it */
2477
2846
 
2478
 
      if (textpos > 0 || textpos < stringlength(settext->string, True, NORMINST)) {
2479
 
         strptr = findstringpart(textpos - 1, NULL, settext->string, NORMINST);
 
2847
      if (textpos > 0 || textpos < stringlength(settext->string, True, areastruct.topinstance)) {
 
2848
         strptr = findstringpart(textpos - 1, NULL, settext->string, areastruct.topinstance);
2480
2849
         if (strptr->type == FONT_NAME) {
2481
2850
            tc = strptr->data.font;
2482
2851
 
2487
2856
               redrawtext(settext);
2488
2857
               if (w != NULL) {
2489
2858
                  charreport(settext);
 
2859
#ifdef TCL_WRAPPER
 
2860
                  toggleencodingmark(value);
 
2861
#else
2490
2862
                  toggleexcl(w, FontEncodings, XtNumber(FontEncodings));
 
2863
#endif
2491
2864
               }
2492
2865
            }
2493
2866
            return;
2495
2868
      }
2496
2869
 
2497
2870
      /* otherwise, look for the last style used in the string */
2498
 
      tc = findcurfont(textpos - 2, settext->string, NORMINST);
 
2871
      tc = findcurfont(textpos - 2, settext->string, areastruct.topinstance);
2499
2872
   }
2500
2873
   else tc = areastruct.psfont;
2501
2874
 
2511
2884
      areastruct.psfont = newfont;
2512
2885
   }
2513
2886
 
 
2887
#ifndef TCL_WRAPPER
2514
2888
   if (w != NULL) toggleexcl(w, FontEncodings, XtNumber(FontEncodings));
 
2889
#endif
2515
2890
 
2516
2891
   Wprintf(_STR);
2517
2892
}
2520
2895
/* Wrapper for routine setfontencoding()                          */
2521
2896
/*----------------------------------------------------------------*/
2522
2897
 
2523
 
void fontencoding(Widget w, u_int value, caddr_t nulldata)
 
2898
void fontencoding(xcWidget w, pointertype value, caddr_t nulldata)
2524
2899
{
2525
2900
   short *fselect;
2526
2901
   labelptr settext;
2559
2934
   int cfont;
2560
2935
 
2561
2936
   curlabel = TOLABEL(EDITPART);
2562
 
   cfont = findcurfont(textpos, curlabel->string, NORMINST);
 
2937
   cfont = findcurfont(textpos, curlabel->string, areastruct.topinstance);
2563
2938
   composefontlib(cfont);
2564
2939
   startcatalog(NULL, FONTLIB, NULL);
2565
2940
}
2568
2943
/* Wrapper for labeltext when called from the menu */
2569
2944
/*-------------------------------------------------*/
2570
2945
 
2571
 
void addtotext(Widget w, u_int value, caddr_t nulldata)
 
2946
void addtotext(xcWidget w, pointertype value, caddr_t nulldata)
2572
2947
{
2573
2948
   if (eventmode != TEXT2_MODE && eventmode != TEXT3_MODE) return;
2574
 
   if (value == (u_int)SPECIAL)
 
2949
   if (value == (pointertype)SPECIAL)
2575
2950
      dospecial();
2576
2951
   else
2577
2952
      labeltext((int)value, (char *)1);
2581
2956
/* Position a popup menu directly beside the toolbar button */
2582
2957
/*----------------------------------------------------------*/
2583
2958
 
2584
 
void position_popup(Widget toolbutton, Widget menubutton)
 
2959
void position_popup(xcWidget toolbutton, xcWidget menubutton)
2585
2960
{
2586
2961
   int n = 0;
2587
2962
   Arg wargs[2];
2588
2963
   Position pz, pw, ph;
2589
2964
   int dx, dy;
2590
2965
 
2591
 
   Widget cascade = XtParent(menubutton);
2592
 
   Widget pshell = XtParent(XtParent(cascade));
 
2966
#ifndef TCL_WRAPPER
 
2967
   xcWidget cascade = XtParent(menubutton);
 
2968
   xcWidget pshell = XtParent(XtParent(cascade));
2593
2969
 
2594
2970
   XtnSetArg(XtNheight, &pz);
2595
2971
   XtGetValues(toolbutton, wargs, n); n = 0;
2602
2978
   dy = (pz - ph) >> 1;
2603
2979
 
2604
2980
   XwPostPopup(pshell, cascade, toolbutton, dx, dy);
 
2981
#endif
2605
2982
}
2606
2983
 
2607
2984
/*------------------------------------------------------*/
2608
2985
/* Functions which pop up a menu cascade in sticky mode */
2609
2986
/*------------------------------------------------------*/
2610
2987
 
2611
 
void border_popup(Widget w, caddr_t clientdata, caddr_t calldata)
 
2988
void border_popup(xcWidget w, caddr_t clientdata, caddr_t calldata)
2612
2989
 
2990
#ifndef TCL_WRAPPER
2613
2991
   position_popup(w, BorderLinewidthButton);
 
2992
#endif
2614
2993
}
2615
2994
 
2616
2995
/*-------------------------------------------------------------------------*/
2617
2996
 
2618
 
void color_popup(Widget w, caddr_t clientdata, caddr_t calldata)
 
2997
void color_popup(xcWidget w, caddr_t clientdata, caddr_t calldata)
2619
2998
 
2999
#ifndef TCL_WRAPPER
2620
3000
   position_popup(w, ColorAddNewColorButton);
 
3001
#endif
2621
3002
}
2622
3003
 
2623
3004
/*-------------------------------------------------------------------------*/
2624
3005
 
2625
 
void fill_popup(Widget w, caddr_t clientdata, caddr_t calldata)
 
3006
void fill_popup(xcWidget w, caddr_t clientdata, caddr_t calldata)
2626
3007
 
3008
#ifndef TCL_WRAPPER
2627
3009
   position_popup(w, FillOpaqueButton);
 
3010
#endif
2628
3011
}
2629
3012
 
2630
3013
/*-------------------------------------------------------------------------*/
2631
3014
 
2632
 
void param_popup(Widget w, caddr_t clientdata, caddr_t calldata)
 
3015
void param_popup(xcWidget w, caddr_t clientdata, caddr_t calldata)
2633
3016
 
3017
#ifndef TCL_WRAPPER
2634
3018
   position_popup(w, ParametersSubstringButton);
 
3019
#endif
2635
3020
}
2636
3021
 
2637
3022
/*-------------------------------------------------------------------------*/