332
344
/* In edit mode, add font scale change. */
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)
378
391
/*--------------------------------------------------------------*/
380
void autostop(Widget w, caddr_t clientdata, caddr_t nulldata)
393
void autostop(xcWidget w, caddr_t clientdata, caddr_t nulldata)
382
395
xobjs.pagelist[areastruct.page]->pmode &= 1;
385
399
/*--------------------------------------------------------------*/
387
401
/* (for now, with fixed 1" margins) */
388
402
/*--------------------------------------------------------------*/
404
void autoscale(int page)
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;
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");
403
newxscale = (xobjs.pagelist[areastruct.page]->pagesize.x - margin)
405
newyscale = (xobjs.pagelist[areastruct.page]->pagesize.y - margin)
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)
420
newyscale = (xobjs.pagelist[page]->pagesize.y - margin)
424
width = toplevelwidth(areastruct.topinstance);
425
height = toplevelheight(areastruct.topinstance);
427
width = topobject->bbox.width;
428
height = topobject->bbox.height;
431
if (xobjs.pagelist[page]->orient == 0) { /* Portrait */
413
newxscale /= objectdata->height;
414
newyscale /= objectdata->width;
417
xobjs.pagelist[areastruct.page]->outscale = min(newxscale, newyscale);
440
xobjs.pagelist[page]->outscale = min(newxscale, newyscale);
420
443
/*--------------------------------------------------------------*/
421
444
/* Set the denomenator value of the drawing scale */
422
445
/*--------------------------------------------------------------*/
424
void setscaley(Widget w, float *dataptr)
447
void setscaley(xcWidget w, float *dataptr)
426
449
float oldvalue = *dataptr;
427
450
int res = sscanf(_STR2, "%f", dataptr);
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");
434
*dataptr = (*dataptr * 72) / objectdata->height;
457
*dataptr = (*dataptr * 72) / topobject->bbox.height;
435
458
*dataptr /= getpsscale(1.0, areastruct.page);
440
463
/* Set the numerator value of the drawing scale */
441
464
/*----------------------------------------------------------------*/
443
void setscalex(Widget w, float *dataptr)
466
void setscalex(xcWidget w, float *dataptr)
445
468
float oldvalue = *dataptr;
446
469
int res = sscanf(_STR2, "%f", dataptr);
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");
453
*dataptr = (*dataptr * 72) / objectdata->width;
476
*dataptr = (*dataptr * 72) / topobject->bbox.width;
454
477
*dataptr /= getpsscale(1.0, areastruct.page);
504
530
XtUnmanageChild(autowidg);
506
532
XtSetValues(w, wargs, 1);
509
/*----------------------------------------------------------------*/
510
/* Set the output page size, in the current unit of measure */
511
/*----------------------------------------------------------------*/
513
void setpagesize(Widget w, XPoint *dataptr)
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
/*--------------------------------------------------------------*/
544
float parseunits(char *strptr)
547
Boolean inchunits = True;
551
curtype = xobjs.pagelist[areastruct.page]->coordstyle;
553
if (sscanf(strptr, "%f %11s", &pv, units) < 2)
556
if (!strncmp(units, "cm", 2) || !strncmp(units, "centimeters", 11))
560
return ((inchunits) ? (pv * 2.54) : pv);
562
return ((inchunits) ? pv : (pv / 2.54));
569
/*--------------------------------------------------------------*/
570
/* Set the output page size, in the current unit of measure */
571
/*--------------------------------------------------------------*/
573
void setpagesize(xcWidget w, XPoint *dataptr)
516
576
char units[10], *expos, fpedit[75];
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];
666
729
/*--------------------------------------------------------------*/
667
/* Generate the popup dialog for getting text scale. */
730
/* Get the text size (global or selected, depending on mode */
668
731
/*--------------------------------------------------------------*/
670
void gettsize(Widget button, caddr_t nulldata, caddr_t calldata)
733
labelptr gettextsize(float **floatptr)
673
buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
674
735
labelptr settext = NULL;
675
float *floatptr = &areastruct.textscale;
677
737
stringpart *strptr, *nextptr;
738
const float f_one = 1.00;
740
if (floatptr) *floatptr = &areastruct.textscale;
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;
688
753
else if (nextptr && nextptr->type == FONT_SCALE) {
689
floatptr = &nextptr->data.scale;
690
sprintf(buffer, "%5.3f", nextptr->data.scale);
693
floatptr = (float *)NULL;
694
strcpy(buffer, "1.00");
754
if (floatptr) *floatptr = &nextptr->data.scale;
756
else if (floatptr) *floatptr = (float *)(&f_one);
698
759
settext = *((labelptr *)EDITPART);
699
floatptr = &(settext->scale);
700
sprintf(buffer, "%4.2f", *floatptr);
760
if (floatptr) *floatptr = &(settext->scale);
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);
711
sprintf(buffer, "%4.2f", *floatptr);
713
if (settext != NULL) {
776
/*--------------------------------------------------------------*/
777
/* Generate the popup dialog for getting text scale. */
778
/*--------------------------------------------------------------*/
780
void gettsize(xcWidget button, caddr_t nulldata, caddr_t calldata)
783
buttonsave *savebutton = (buttonsave *)malloc(sizeof(buttonsave));
788
settext = gettextsize(&floatptr);
789
sprintf(buffer, "%5.2f", *floatptr);
714
792
getgeneric(savebutton, button, gettsize, settext);
715
793
popupprompt(button, "Enter text scale:", buffer, settsize, savebutton, NULL);
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);
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);
952
sprintf(objectdata->name, "%.79s", _STR2);
1028
sprintf(topobject->name, "%.79s", _STR2);
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);
960
printname(objectdata);
1036
printname(topobject);
961
1037
renamepage(areastruct.page);
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
/*--------------------------------------------------------------*/
968
1046
void makenewfontbutton()
972
Widget newbutton, cascade;
1052
xcWidget newbutton, cascade;
974
1054
if (fontcount == 0) return;
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);
1164
1276
/*----------------------------------------------------------------*/
1165
1277
/* Change menu selection for reported measurement units */
1166
1278
/*----------------------------------------------------------------*/
1168
void togglegrid(u_short type)
1170
Widget button, bparent = XtParent(GridtypedisplayDecimalInchesButton);
1282
void togglegrid(u_short type)
1284
static char *stylenames[] = {
1286
"fractional inches",
1290
/* Note that Tcl_SetVar() doesn't require double-quotes around the */
1291
/* string; doing so prevents the menu from recognizing the variable */
1294
Tcl_SetVar(xcinterp, "gridstyle", stylenames[type], TCL_NAMESPACE_ONLY);
1299
void togglegrid(u_short type)
1301
xcWidget button, bparent = XtParent(GridtypedisplayDecimalInchesButton);
1172
1303
if (type == CM) button = XtNameToWidget(bparent, "Centimeters");
1173
1304
else if (type == FRAC_INCH) button = XtNameToWidget(bparent, "Fractional Inches");
1198
1341
/*----------------------------------------------------------------*/
1199
1342
/* Called by setgridtype() to complete setting the reported */
1200
1343
/* measurement units */
1201
1344
/*----------------------------------------------------------------*/
1203
void getgridtype(Widget button, u_int value, caddr_t calldata)
1346
void getgridtype(xcWidget button, pointertype value, caddr_t calldata)
1205
1348
short oldtype = xobjs.pagelist[areastruct.page]->coordstyle;
1206
1349
float scalefac = getpsscale(1.0, areastruct.page) / INCHSCALE;
1208
1352
toggleexcl(button, GridStyles, XtNumber(GridStyles));
1209
1354
xobjs.pagelist[areastruct.page]->coordstyle = (short)value;
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;
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! */
1215
1365
xobjs.pagelist[areastruct.page]->pagesize.x = 612;
1216
1366
xobjs.pagelist[areastruct.page]->pagesize.y = 792; /* letter */
1220
1371
if (oldtype != CM) {
1221
1372
xobjs.pagelist[areastruct.page]->outscale *= scalefac;
1222
1374
xobjs.pagelist[areastruct.page]->pagesize.x = 595;
1223
1375
xobjs.pagelist[areastruct.page]->pagesize.y = 842; /* A4 */
1268
1421
int createlibrary()
1270
Widget libmenu, newbutton, oldbutton;
1423
xcWidget libmenu, newbutton, oldbutton;
1272
1425
char libstring[20];
1427
objectptr newlibobj;
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];
1282
xobjs.libtop[libnum] = (objectptr) malloc(sizeof(object));
1283
initmem(xobjs.libtop[libnum]);
1284
sprintf(xobjs.libtop[libnum]->name, "Library %d", libnum - LIBRARY + 1);
1437
newlibobj = (objectptr) malloc(sizeof(object));
1439
xobjs.libtop[libnum] = newpageinst(newlibobj);
1441
sprintf(newlibobj->name, "Library %d", libnum - LIBRARY + 1);
1286
1443
/* Create the library */
1291
1448
xobjs.userlibs[libnum - LIBRARY].library = (objectptr *) malloc(sizeof(objectptr));
1292
1449
xobjs.userlibs[libnum - LIBRARY].number = 0;
1453
sprintf(_STR2, "xcircuit::newlibrarybutton \"%s\"", newlibobj->name);
1454
Tcl_Eval(xcinterp, _STR2);
1294
1458
/* Previously last button becomes new library pointer */
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);
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" */
1307
1471
sprintf(libstring, "Library %d", libnum - LIBRARY + 2);
1368
1538
void renamepage(short pagenumber)
1541
char *pname, *plabel;
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);
1371
Widget parent = XtParent(GotoPageAddNewPageButton);
1553
xcWidget parent = XtParent(GotoPageAddNewPageButton);
1373
1555
char bname[10];
1375
1557
sprintf(bname, "Page %d", pagenumber + 1);
1376
1558
button = XtNameToWidget(parent, bname);
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);
1382
1565
XtSetArg(wargs[0], XtNlabel, bname);
1383
1566
XtSetValues(button, wargs, 1);
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);
1389
1573
/*--------------------------------------------------------------*/
1393
1577
void renamelib(short libnumber)
1580
sprintf(_STR2, "xcircuit::renamelib %d \"%s\"", libnumber - LIBRARY + 1,
1581
xobjs.libtop[libnumber]->thisobject->name);
1582
Tcl_Eval(xcinterp, _STR2);
1396
Widget parent = XtParent(GotoLibraryAddNewLibraryButton);
1585
xcWidget parent = XtParent(GotoLibraryAddNewLibraryButton);
1398
1587
char bname[13];
1400
1589
sprintf(bname, "Library %d", libnumber - LIBRARY + 1);
1401
1590
button = XtNameToWidget(parent, bname);
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);
1407
1596
XtSetArg(wargs[0], XtNlabel, bname);
1408
1597
XtSetValues(button, wargs, 1);
1411
printf("Error: No Button Widget named \"%12s\"\n", bname);
1600
Fprintf(stderr, "Error: No Button Widget named \"%12s\"\n", bname);
1414
1604
/*----------------------------------------------*/
1418
1608
#define BORDERS (NOBORDER | DOTTED | DASHED)
1419
1609
#define ALLFILLS (FILLSOLID | FILLED)
1421
/*----------------------------------------------*/
1422
/* Set the menu marks according to style value */
1423
/*----------------------------------------------*/
1425
void setstylemarks(Widget w, u_int value, Boolean boolval)
1429
/* if widget is unknown, find button for each part */
1431
if (value & UNCLOSED) {
1432
XtSetArg(wargs[0], XtNsetMark, boolval);
1433
XtSetValues(w, wargs, 1);
1435
if (value & OPAQUE) {
1436
XtSetArg(wargs[0], XtNsetMark, boolval);
1437
XtSetValues(w, wargs, 1);
1440
XtSetArg(wargs[0], XtNsetMark, boolval);
1441
XtSetValues(w, wargs, 1);
1443
if (value & BORDERS || value & ALLFILLS || value == 0) {
1444
toggleexcl(w, BorderStyles, XtNumber(BorderStyles));
1445
toggleexcl(w, Stipples, XtNumber(Stipples));
1449
1611
/*--------------------------------------------------------------*/
1450
1612
/* Set the menu checkmarks on the color menu */
1451
1613
/*--------------------------------------------------------------*/
1453
1615
void setcolormark(int colorval)
1459
1622
if (colorval == DEFAULTCOLOR)
1476
1639
/* Add mark to the menu button for the chosen color */
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);
1647
/* Set GUI variables and execute any command tags associated */
1648
/* with the "color" command */
1653
objv[0] = Tcl_NewStringObj("color", 5);
1654
if (colorval == DEFAULTCOLOR)
1655
objv[1] = Tcl_NewStringObj("inherit", 7);
1657
for (i = 0; i < number_colors; i++)
1658
if (colorlist[i].color.pixel == colorval)
1660
objv[1] = Tcl_NewIntObj((int)i);
1662
Tcl_SetVar2Ex(xcinterp, "colorval", NULL, objv[1], TCL_NAMESPACE_ONLY);
1664
XcTagCallback(xcinterp, 2, objv);
1485
1668
/*----------------------------------------------------------------*/
1486
1669
/* Set the checkmarks on the element styles menu */
1487
1670
/*----------------------------------------------------------------*/
1489
void setallstylemarks(short styleval)
1672
void setallstylemarks(u_short styleval)
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);
1678
XtSetArg(wargs[0], XtNsetMark, (styleval & UNCLOSED) ? 0 : 1);
1679
XtSetValues(BorderClosedButton, wargs, 1);
1681
XtSetArg(wargs[0], XtNsetMark, (styleval & BBOX) ? 1 : 0);
1682
XtSetValues(BorderBoundingBoxButton, wargs, 1);
1500
1684
if (styleval & NOBORDER)
1501
1685
w = BorderUnborderedButton;
1523
1713
case 7: w = FillBlackButton; break;
1526
setstylemarks(w, ALLFILLS, 0);
1716
toggleexcl(w, Stipples, XtNumber(Stipples));
1719
/* Set GUI variables and execute any command tags associated */
1720
/* with the "fill" and "border" commands. */
1726
const char *borders[] = {"solid", "unbordered", "dashed", "dotted"};
1727
enum BorderIdx { SolidIdx, UnborderedIdx, DashedIdx, DottedIdx };
1729
objv[0] = Tcl_NewStringObj("fill", 4);
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);
1736
objv[1] = Tcl_NewIntObj(fillfactor);
1739
objv[1] = Tcl_NewStringObj("unfilled", 8);
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);
1749
switch (styleval & BORDERS) {
1751
bptr = borders[DashedIdx];
1754
bptr = borders[DottedIdx];
1757
bptr = borders[UnborderedIdx];
1760
bptr = borders[SolidIdx];
1763
Tcl_SetVar(xcinterp, "linestyle", (char *)bptr, TCL_NAMESPACE_ONLY);
1765
XcTagCallback(xcinterp, 2, objv);
1529
1770
/*--------------------------------------------------------------*/
1588
1832
estyle = &((SELTOPATH(sstyle))->style);
1836
newstyle &= ~(mask);
1839
if ((newstyle & NOBORDER) && !(newstyle & FILLED)) {
1840
Wprintf("Must have either a border or filler");
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);
1600
else if (value & OPAQUE) {
1601
boolval = (*estyle & OPAQUE) ? False : True;
1603
*estyle |= (boolval ? OPAQUE : NORMAL);
1605
else if (value & BBOX) {
1606
boolval = (*estyle & BBOX) ? False : True;
1608
*estyle |= (boolval ? BBOX : NORMAL);
1609
(SELTOPOLY(sstyle))->color = boolval ? BBOXCOLOR : DEFAULTCOLOR;
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;
1850
(SELTOPOLY(sstyle))->color = (value & BBOX) ? BBOXCOLOR : DEFAULTCOLOR;
1621
1852
XSetFunction(dpy, areastruct.gc, GXxor);
1622
1853
XSetForeground(dpy, areastruct.gc, SELECTCOLOR ^ BACKGROUND);
1623
1854
easydraw(*sstyle, DOFORALL);
1629
pwriteback(NORMINST);
1860
pwriteback(areastruct.topinstance);
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);
1636
else if (value & UNCLOSED) {
1637
boolval = (areastruct.style & UNCLOSED) ? True : False;
1638
areastruct.style &= ~UNCLOSED;
1639
areastruct.style |= (boolval ? NORMAL : UNCLOSED);
1641
else if (value & OPAQUE) {
1642
boolval = (areastruct.style & OPAQUE) ? False : True;
1643
areastruct.style &= ~OPAQUE;
1644
areastruct.style |= (boolval ? OPAQUE : NORMAL);
1647
short savestyle = areastruct.style;
1649
if (value & BORDERS || value == NORMAL)
1650
areastruct.style &= ~BORDERS;
1651
else areastruct.style &= ~ALLFILLS;
1652
if (value != FILLSOLID) areastruct.style |= value;
1654
if ((areastruct.style & NOBORDER) && !(areastruct.style & FILLED)) {
1655
Wprintf("Must have either a border or filler");
1656
areastruct.style = savestyle;
1873
if ((newstyle & NOBORDER) && !(newstyle & FILLED)) {
1874
Wprintf("Must have either a border or filler");
1877
areastruct.style = newstyle;
1660
1878
overdrawpixmap(w);
1663
setstylemarks(w, value, boolval);
1665
setallstylemarks(areastruct.style);
1880
setallstylemarks(newstyle);
1667
1881
objectdeselect();
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
/*----------------------------------------------------------------*/
1676
void makebbox(Widget w, u_int value, caddr_t calldata)
1678
getfill(w, value, NULL);
1681
/*----------------------------------------------------------------*/
1683
void getset(Widget w, u_int value, caddr_t calldata)
1685
getfill(w, value, NULL);
1688
/*----------------------------------------------------------------*/
1690
void getline(Widget w, u_int value, caddr_t calldata)
1692
getfill(w, value, NULL);
1695
/*----------------------------------------------------------------*/
1697
void getopaque(Widget w, u_int value, caddr_t calldata)
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
/*--------------------------------------------------------------*/
1891
void setfill(xcWidget w, pointertype value, caddr_t calldata)
1893
setelementstyle(w, (u_short)value, OPAQUE | FILLED | FILLSOLID);
1896
/*--------------------------------------------------------------*/
1898
void makebbox(xcWidget w, pointertype value, caddr_t calldata)
1900
setelementstyle(w, (u_short)value, BBOX);
1903
/*--------------------------------------------------------------*/
1905
void setclosure(xcWidget w, pointertype value, caddr_t calldata)
1907
setelementstyle(w, (u_short)value, UNCLOSED);
1910
/*----------------------------------------------------------------*/
1912
void setline(xcWidget w, pointertype value, caddr_t calldata)
1914
setelementstyle(w, (u_short)value, BORDERS);
1917
/*----------------------------------------------------------------*/
1919
void setopaque(xcWidget w, pointertype value, caddr_t calldata)
1921
setelementstyle(w, (u_short)value, OPAQUE);
1702
1924
/*-----------------------------------------------*/
1703
1925
/* Set the color value for all selected elements */
1704
1926
/*-----------------------------------------------*/
1706
void setcolor(Widget w, u_int value, caddr_t calldata)
1929
void setcolor(xcWidget w, int cindex)
1933
Boolean selected = False;
1934
stringpart *strptr, *nextptr;
1936
if (cindex == -1) cval = -1;
1937
else cval = colorlist[cindex].color.pixel;
1941
void setcolor(xcWidget w, pointertype value, caddr_t calldata)
1709
1944
int *ecolor, cindex, cval;
1719
1954
XtSetArg(wargs[0], XtNrectColor, &cval);
1720
1955
XtGetValues(w, wargs, 1);
1721
1957
for (cindex = 0; cindex < number_colors; cindex++)
1722
1958
if (colorlist[cindex].color.pixel == cval)
1724
if (cindex == number_colors) {
1960
if (cindex >= number_colors) {
1725
1961
Wprintf("Error: No such color!");
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;
1819
2057
/* fvalue is for font, jvalue is for justification */
1820
2058
/*------------------------------------------------------*/
1822
void setfontmarks(short fvalue, short jvalue)
2062
void togglestylemark(int styleval)
2065
case 0: Tcl_SetVar(xcinterp, "fontstyle", "normal", TCL_NAMESPACE_ONLY);
2067
case 1: Tcl_SetVar(xcinterp, "fontstyle", "bold", TCL_NAMESPACE_ONLY);
2069
case 2: Tcl_SetVar(xcinterp, "fontstyle", "italic", TCL_NAMESPACE_ONLY);
2071
case 3: Tcl_SetVar(xcinterp, "fontstyle", "bolditalic", TCL_NAMESPACE_ONLY);
2076
/*------------------------------------------------------*/
2078
void toggleencodingmark(int encodingval)
2080
switch(encodingval) {
2081
case 0: Tcl_SetVar(xcinterp, "fontencoding", "Standard", TCL_NAMESPACE_ONLY);
2083
case 1: Tcl_SetVar(xcinterp, "fontencoding", "special", TCL_NAMESPACE_ONLY);
2085
case 2: Tcl_SetVar(xcinterp, "fontencoding", "ISOLatin1", TCL_NAMESPACE_ONLY);
2087
case 3: Tcl_SetVar(xcinterp, "fontencoding", "ISOLatin2", TCL_NAMESPACE_ONLY);
2089
case 4: Tcl_SetVar(xcinterp, "fontencoding", "ISOLatin3", TCL_NAMESPACE_ONLY);
2091
case 5: Tcl_SetVar(xcinterp, "fontencoding", "ISOLatin4", TCL_NAMESPACE_ONLY);
2093
case 6: Tcl_SetVar(xcinterp, "fontencoding", "ISOLatin5", TCL_NAMESPACE_ONLY);
2095
case 7: Tcl_SetVar(xcinterp, "fontencoding", "ISOLatin6", TCL_NAMESPACE_ONLY);
2100
/*------------------------------------------------------*/
2102
void togglejustmarks(int justvalue)
2104
switch(justvalue & (NOTLEFT | RIGHT)) {
2105
case NORMAL: Tcl_SetVar(xcinterp, "jhoriz", "left", TCL_NAMESPACE_ONLY);
2107
case NOTLEFT: Tcl_SetVar(xcinterp, "jhoriz", "center", TCL_NAMESPACE_ONLY);
2109
case RIGHT|NOTLEFT: Tcl_SetVar(xcinterp, "jhoriz", "right", TCL_NAMESPACE_ONLY);
2112
switch(justvalue & (NOTBOTTOM | TOP)) {
2113
case NORMAL: Tcl_SetVar(xcinterp, "jvert", "bottom", TCL_NAMESPACE_ONLY);
2115
case NOTBOTTOM: Tcl_SetVar(xcinterp, "jvert", "middle", TCL_NAMESPACE_ONLY);
2117
case TOP|NOTBOTTOM: Tcl_SetVar(xcinterp, "jvert", "top", TCL_NAMESPACE_ONLY);
2121
/* Flip Invariance property */
2122
Tcl_SetVar(xcinterp, "flipinvariant", (justvalue & FLIPINV) ? "true" : "false",
2123
TCL_NAMESPACE_ONLY);
2126
/* Pin visibility property */
2127
Tcl_SetVar(xcinterp, "pinvisible", (justvalue & PINVISIBLE) ? "true" : "false",
2128
TCL_NAMESPACE_ONLY);
2132
/*------------------------------------------------------*/
2134
void setfontmarks(short fvalue, short jvalue)
2136
if ((fvalue >= 0) && (fontcount > 0)) {
2137
togglestylemark(fonts[fvalue].flags & 0x03);
2138
toggleencodingmark((fonts[fvalue].flags & 0xf80) >> 7);
2139
togglefontmark(fvalue);
2142
togglejustmarks(jvalue);
2146
/*------------------------------------------------------*/
2148
#else /* !TCL_WRAPPER */
2150
void setfontmarks(short fvalue, short jvalue)
1827
2155
if ((fvalue >= 0) && (fontcount > 0)) {
2137
2471
/* Set polygon editing style */
2138
2472
/*---------------------------*/
2140
void boxedit(Widget w, u_int value, caddr_t nulldata)
2476
void boxedit(xcWidget w, pointertype value, caddr_t nulldata)
2480
Tcl_SetVar(xcinterp, "polyedittype", "manhattan", TCL_NAMESPACE_ONLY);
2483
Tcl_SetVar(xcinterp, "polyedittype", "rhomboidx", TCL_NAMESPACE_ONLY);
2486
Tcl_SetVar(xcinterp, "polyedittype", "rhomboidy", TCL_NAMESPACE_ONLY);
2489
Tcl_SetVar(xcinterp, "polyedittype", "rhomboida", TCL_NAMESPACE_ONLY);
2492
Tcl_SetVar(xcinterp, "polyedittype", "normal", TCL_NAMESPACE_ONLY);
2496
if (areastruct.boxedit == value) return;
2497
areastruct.boxedit = value;
2502
void boxedit(xcWidget w, pointertype value, caddr_t nulldata)
2142
2504
if (w == NULL) {
2143
2505
switch (value) {
2602
2978
dy = (pz - ph) >> 1;
2604
2980
XwPostPopup(pshell, cascade, toolbutton, dx, dy);
2607
2984
/*------------------------------------------------------*/
2608
2985
/* Functions which pop up a menu cascade in sticky mode */
2609
2986
/*------------------------------------------------------*/
2611
void border_popup(Widget w, caddr_t clientdata, caddr_t calldata)
2988
void border_popup(xcWidget w, caddr_t clientdata, caddr_t calldata)
2613
2991
position_popup(w, BorderLinewidthButton);
2616
2995
/*-------------------------------------------------------------------------*/
2618
void color_popup(Widget w, caddr_t clientdata, caddr_t calldata)
2997
void color_popup(xcWidget w, caddr_t clientdata, caddr_t calldata)
2620
3000
position_popup(w, ColorAddNewColorButton);
2623
3004
/*-------------------------------------------------------------------------*/
2625
void fill_popup(Widget w, caddr_t clientdata, caddr_t calldata)
3006
void fill_popup(xcWidget w, caddr_t clientdata, caddr_t calldata)
2627
3009
position_popup(w, FillOpaqueButton);
2630
3013
/*-------------------------------------------------------------------------*/
2632
void param_popup(Widget w, caddr_t clientdata, caddr_t calldata)
3015
void param_popup(xcWidget w, caddr_t clientdata, caddr_t calldata)
2634
3018
position_popup(w, ParametersSubstringButton);
2637
3022
/*-------------------------------------------------------------------------*/