diff options
author | Ruben Undheim <ruben.undheim@gmail.com> | 2018-10-20 17:54:32 +0200 |
---|---|---|
committer | Ruben Undheim <ruben.undheim@gmail.com> | 2018-10-20 17:54:32 +0200 |
commit | ca2442640f4394296d9d6b0c42d41d399dbf9667 (patch) | |
tree | 879c0a6065d6982d5a82b35dc3ff67299e2ea7d9 /menucalls.c | |
parent | 04d5d0ea0f65a434e568fe031f6396caec9b3a8d (diff) |
New upstream version 3.9.73+dfsg.1
Diffstat (limited to 'menucalls.c')
-rw-r--r-- | menucalls.c | 140 |
1 files changed, 73 insertions, 67 deletions
diff --git a/menucalls.c b/menucalls.c index 389049a..a4b71f2 100644 --- a/menucalls.c +++ b/menucalls.c @@ -46,7 +46,6 @@ extern xcWidget top; extern Display *dpy; extern Globaldata xobjs; extern XCWindowData *areawin; -extern int *appcolors; extern int number_colors; extern colorindex *colorlist; extern ApplicationData appdata; @@ -590,50 +589,65 @@ void makenewfontbutton() /*---------------------------------------------------------------*/ /* Some Xcircuit routines using toggle and toggleexcl, */ /* put here because they reference the menu structures directly. */ +/* */ +/* Note that by bypassing addnewcolorentry(), the new colors in */ +/* colorlist are NOT added to the GUI list of colors. */ /*---------------------------------------------------------------*/ void setcolorscheme(Boolean boolvalue) { + int i; + if (boolvalue) { - PARAMCOLOR = appdata.parampix; - AUXCOLOR = appdata.auxpix; - OFFBUTTONCOLOR = appdata.buttonpix; - SELECTCOLOR = appdata.selectpix; - GRIDCOLOR = appdata.gridpix; - SNAPCOLOR = appdata.snappix; - AXESCOLOR = appdata.axespix; - BACKGROUND = appdata.bg; - FOREGROUND = appdata.fg; + colorlist[PARAMCOLOR].color.pixel = appdata.parampix; + colorlist[AUXCOLOR].color.pixel = appdata.auxpix; + colorlist[OFFBUTTONCOLOR].color.pixel = appdata.buttonpix; + colorlist[SELECTCOLOR].color.pixel = appdata.selectpix; + colorlist[GRIDCOLOR].color.pixel = appdata.gridpix; + colorlist[SNAPCOLOR].color.pixel = appdata.snappix; + colorlist[AXESCOLOR].color.pixel = appdata.axespix; + colorlist[BACKGROUND].color.pixel = appdata.bg; + colorlist[FOREGROUND].color.pixel = appdata.fg; } else { - PARAMCOLOR = appdata.parampix2; - AUXCOLOR = appdata.auxpix2; - OFFBUTTONCOLOR = appdata.buttonpix2; - SELECTCOLOR = appdata.selectpix2; - GRIDCOLOR = appdata.gridpix2; - SNAPCOLOR = appdata.snappix2; - AXESCOLOR = appdata.axespix2; - BACKGROUND = appdata.bg2; - FOREGROUND = appdata.fg2; + colorlist[PARAMCOLOR].color.pixel = appdata.parampix2; + colorlist[AUXCOLOR].color.pixel = appdata.auxpix2; + colorlist[OFFBUTTONCOLOR].color.pixel = appdata.buttonpix2; + colorlist[SELECTCOLOR].color.pixel = appdata.selectpix2; + colorlist[GRIDCOLOR].color.pixel = appdata.gridpix2; + colorlist[SNAPCOLOR].color.pixel = appdata.snappix2; + colorlist[AXESCOLOR].color.pixel = appdata.axespix2; + colorlist[BACKGROUND].color.pixel = appdata.bg2; + colorlist[FOREGROUND].color.pixel = appdata.fg2; } - BARCOLOR = appdata.barpix; - FILTERCOLOR = appdata.filterpix; - - LOCALPINCOLOR = appdata.localcolor; - GLOBALPINCOLOR = appdata.globalcolor; - INFOLABELCOLOR = appdata.infocolor; - RATSNESTCOLOR = appdata.ratsnestcolor; - BBOXCOLOR = appdata.bboxpix; - CLIPMASKCOLOR = appdata.clipcolor; - -#if !defined(TCL_WRAPPER) && !defined(DOUBLEBUFFER) - { - Arg wargs[1]; - XtSetArg(wargs[0], XtNbackground, BACKGROUND); - XtSetValues(areawin->area, wargs, 1); + colorlist[BARCOLOR].color.pixel = appdata.barpix; + colorlist[FILTERCOLOR].color.pixel = appdata.filterpix; + + colorlist[LOCALPINCOLOR].color.pixel = appdata.localcolor; + colorlist[GLOBALPINCOLOR].color.pixel = appdata.globalcolor; + colorlist[INFOLABELCOLOR].color.pixel = appdata.infocolor; + colorlist[RATSNESTCOLOR].color.pixel = appdata.ratsnestcolor; + colorlist[BBOXCOLOR].color.pixel = appdata.bboxpix; + colorlist[CLIPMASKCOLOR].color.pixel = appdata.clipcolor; + + /* Fill in pixel information */ + + for (i = 0; i < NUMBER_OF_COLORS; i++) { + unsigned short r, g, b; + + /* Get the color the hard way by querying the X server colormap */ + xc_get_color_rgb(colorlist[i].color.pixel, &r, &g, &b); + + /* Store this information locally so we don't have to do */ + /* the lookup the hard way in the future. */ + + colorlist[i].color.red = r; + colorlist[i].color.green = g; + colorlist[i].color.blue = b; } -#endif + areawin->redraw_needed = True; + drawarea(NULL, NULL, NULL); } /*----------------------------------------------------------------*/ @@ -854,18 +868,12 @@ void setcolormark(int colorval) /* Set GUI variables and execute any command tags associated */ /* with the "color" command */ +#ifdef TCL_WRAPPER char cstr[6]; - int i; - if (colorval != DEFAULTCOLOR) { - for (i = 0; i < number_colors; i++) - if (colorlist[i].color.pixel == colorval) { - sprintf(cstr, "%5d", i); - break; - } - } + if (colorval != DEFAULTCOLOR) + sprintf(cstr, "%5d", colorval); -#ifdef TCL_WRAPPER XcInternalTagCall(xcinterp, 3, "color", "set", (colorval == DEFAULTCOLOR) ? "inherit" : cstr); #endif @@ -1009,8 +1017,7 @@ int setelementstyle(xcWidget w, u_short value, u_short mask) continue; } - XSetFunction(dpy, areawin->gc, GXcopy); - XSetForeground(dpy, areawin->gc, BACKGROUND); + SetForeground(dpy, areawin->gc, BACKGROUND); easydraw(*sstyle, DOFORALL); *estyle = newstyle; @@ -1018,8 +1025,7 @@ int setelementstyle(xcWidget w, u_short value, u_short mask) (SELTOPOLY(sstyle))->color = (value & BBOX) ? BBOXCOLOR : DEFAULTCOLOR; - XSetFunction(dpy, areawin->gc, GXxor); - XSetForeground(dpy, areawin->gc, SELECTCOLOR ^ BACKGROUND); + SetForeground(dpy, areawin->gc, SELECTCOLOR); easydraw(*sstyle, DOFORALL); #ifdef TCL_WRAPPER @@ -1084,13 +1090,10 @@ int setelementstyle(xcWidget w, u_short value, u_short mask) void setcolor(xcWidget w, int cindex) { short *scolor; - int *ecolor, cval, oldcolor; + int *ecolor, oldcolor; Boolean selected = False; stringpart *strptr, *nextptr; - if (cindex == -1) cval = -1; - else cval = colorlist[cindex].color.pixel; - if (eventmode == TEXT_MODE || eventmode == ETEXT_MODE) { labelptr curlabel = TOLABEL(EDITPART); strptr = findstringpart(areawin->textpos - 1, NULL, curlabel->string, @@ -1118,7 +1121,7 @@ void setcolor(xcWidget w, int cindex) + areawin->selects; scolor++) { ecolor = &(SELTOCOLOR(scolor)); oldcolor = *ecolor; - *ecolor = cval; + *ecolor = cindex; selected = True; register_for_undo(XCF_Color, (scolor == areawin->selectlist @@ -1128,10 +1131,10 @@ void setcolor(xcWidget w, int cindex) } } - setcolormark(cval); + setcolormark(cindex); if (!selected) { if (eventmode != TEXT_MODE && eventmode != ETEXT_MODE) - areawin->color = cval; + areawin->color = cindex; } else pwriteback(areawin->topinstance); } @@ -1148,7 +1151,7 @@ void togglefontmark(int fontval) /*------------------------------------------------------*/ /* Set checkmarks on label style menu */ -/* fvalue is for font, jvalue is for justification */ +/* fvalue is for font, jvalue is for anchoring */ /*------------------------------------------------------*/ void togglestylemark(int styleval) @@ -1170,19 +1173,22 @@ void toggleencodingmark(int encodingval) } /*------------------------------------------------------*/ -/* Set checkmarks on label justification & flags menu */ +/* Set checkmarks on label anchoring & flags menu */ /*------------------------------------------------------*/ -void togglejustmarks(int justvalue) +void toggleanchormarks(int anchorvalue) { - XcInternalTagCall(xcinterp, 4, "label", "justify", (justvalue & RIGHT) ? "right" : - (justvalue & NOTLEFT) ? "center" : "left", - (justvalue & TOP) ? "top" : (justvalue & NOTBOTTOM) ? "middle" : "bottom"); - XcInternalTagCall(xcinterp, 3, "label", "flipinvariant", (justvalue & FLIPINV) ? + XcInternalTagCall(xcinterp, 4, "label", "anchor", (anchorvalue & RIGHT) ? "right" : + (anchorvalue & NOTLEFT) ? "center" : "left", + (anchorvalue & TOP) ? "top" : (anchorvalue & NOTBOTTOM) ? "middle" : "bottom"); + XcInternalTagCall(xcinterp, 3, "label", "justify", (anchorvalue & JUSTIFYRIGHT) ? + "right" : (anchorvalue & TEXTCENTERED) ? "center" : (anchorvalue & JUSTIFYBOTH) + ? "both" : "left"); + XcInternalTagCall(xcinterp, 3, "label", "flipinvariant", (anchorvalue & FLIPINV) ? "true" : "false"); - XcInternalTagCall(xcinterp, 3, "label", "latex", (justvalue & LATEXLABEL) ? + XcInternalTagCall(xcinterp, 3, "label", "latex", (anchorvalue & LATEXLABEL) ? "true" : "false"); - XcInternalTagCall(xcinterp, 3, "label", "visible", (justvalue & PINVISIBLE) ? + XcInternalTagCall(xcinterp, 3, "label", "visible", (anchorvalue & PINVISIBLE) ? "true" : "false"); } @@ -1197,7 +1203,7 @@ void setfontmarks(short fvalue, short jvalue) togglestylemark(fvalue); togglefontmark(fvalue); } - togglejustmarks(jvalue); + toggleanchormarks(jvalue); } #endif /* TCL_WRAPPER */ @@ -1253,7 +1259,7 @@ void startunparam(xcWidget w, pointertype value, caddr_t calldata) void setdefaultfontmarks() { - setfontmarks(areawin->psfont, areawin->justify); + setfontmarks(areawin->psfont, areawin->anchor); } /*----------------------------------------------------------------*/ @@ -1685,7 +1691,7 @@ Boolean dospecial() int cfont; curlabel = TOLABEL(EDITPART); - if (curlabel->justify & LATEXLABEL) return False; + if (curlabel->anchor & LATEXLABEL) return False; cfont = findcurfont(areawin->textpos, curlabel->string, areawin->topinstance); composefontlib(cfont); |