summaryrefslogtreecommitdiff
path: root/xtfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'xtfuncs.c')
-rw-r--r--xtfuncs.c174
1 files changed, 85 insertions, 89 deletions
diff --git a/xtfuncs.c b/xtfuncs.c
index 60f65e5..a3e8b1f 100644
--- a/xtfuncs.c
+++ b/xtfuncs.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;
@@ -89,9 +88,9 @@ void togglegridstyles(xcWidget button) {
toggleexcl(button, GridStyles, XtNumber(GridStyles));
}
-void togglejustifs(xcWidget button) {
+void toggleanchors(xcWidget button) {
if (button != NULL)
- toggleexcl(button, Justifs, XtNumber(Justifs));
+ toggleexcl(button, Anchors, XtNumber(Anchors));
}
void togglefontstyles(xcWidget button) {
@@ -105,108 +104,108 @@ void toggleencodings(xcWidget button) {
}
/*--------------------------------------------------------------*/
-/* Toggle a bit in the justification field of a label */
+/* Toggle a bit in the anchoring field of a label */
/*--------------------------------------------------------------*/
-void dojustifybit(xcWidget w, labelptr settext, short bitfield)
+void doanchorbit(xcWidget w, labelptr settext, short bitfield)
{
if (settext != NULL) {
- int oldjust = (int)settext->justify;
+ int oldanchor = (int)settext->anchor;
undrawtext(settext);
- settext->justify ^= bitfield;
+ settext->anchor ^= bitfield;
redrawtext(settext);
pwriteback(areawin->topinstance);
- register_for_undo(XCF_Justify, UNDO_MORE, areawin->topinstance,
- (genericptr)settext, oldjust);
+ register_for_undo(XCF_Anchor, UNDO_MORE, areawin->topinstance,
+ (genericptr)settext, oldanchor);
}
else
- areawin->justify ^= bitfield;
+ areawin->anchor ^= bitfield;
if (w != NULL) {
Boolean boolval;
if (settext)
- boolval = (settext->justify & bitfield) ? 0 : 1;
+ boolval = (settext->anchor & bitfield) ? 0 : 1;
else
- boolval = (areawin->justify & bitfield) ? 0 : 1;
+ boolval = (areawin->anchor & bitfield) ? 0 : 1;
toggle(w, (pointertype)(-1), &boolval);
}
}
/*--------------------------------------------------------------*/
-/* Toggle a pin-related bit in the justification field of a */
-/* label. This differs from dojustifybit() in that the label */
+/* Toggle a pin-related bit in the anchoring field of a */
+/* label. This differs from doanchorbit() in that the label */
/* must be a pin, and this function cannot change the default */
-/* behavior set by areawin->justify. */
+/* behavior set by areawin->anchor. */
/*--------------------------------------------------------------*/
-void dopinjustbit(xcWidget w, labelptr settext, short bitfield)
+void dopinanchorbit(xcWidget w, labelptr settext, short bitfield)
{
if ((settext != NULL) && settext->pin) {
- int oldjust = (int)settext->justify;
+ int oldanchor = (int)settext->anchor;
undrawtext(settext);
- settext->justify ^= bitfield;
+ settext->anchor ^= bitfield;
redrawtext(settext);
pwriteback(areawin->topinstance);
- register_for_undo(XCF_Justify, UNDO_MORE, areawin->topinstance,
- (genericptr)settext, oldjust);
+ register_for_undo(XCF_Anchor, UNDO_MORE, areawin->topinstance,
+ (genericptr)settext, oldanchor);
if (w != NULL) {
- Boolean boolval = (settext->justify & bitfield) ? 0 : 1;
+ Boolean boolval = (settext->anchor & bitfield) ? 0 : 1;
toggle(w, (pointertype)(-1), &boolval);
}
}
}
/*----------------------------------------------------------------*/
-/* Set the justification for the label passed as 3rd parameter */
+/* Set the anchoring for the label passed as 3rd parameter */
/*----------------------------------------------------------------*/
-void setjust(xcWidget w, pointertype value, labelptr settext, short mode)
+void setanchor(xcWidget w, pointertype value, labelptr settext, short mode)
{
- short newjust, oldjust;
+ short newanchor, oldanchor;
if (settext != NULL) {
if (mode == 1)
- newjust = (settext->justify & (NONJUSTFIELD | TBJUSTFIELD))
+ newanchor = (settext->anchor & (NONANCHORFIELD | TBANCHORFIELD))
| value;
else
- newjust = (settext->justify & (NONJUSTFIELD | RLJUSTFIELD))
+ newanchor = (settext->anchor & (NONANCHORFIELD | RLANCHORFIELD))
| value;
- if (settext->justify != newjust) {
- oldjust = (int)settext->justify;
+ if (settext->anchor != newanchor) {
+ oldanchor = (int)settext->anchor;
undrawtext(settext);
- settext->justify = newjust;
+ settext->anchor = newanchor;
redrawtext(settext);
pwriteback(areawin->topinstance);
- register_for_undo(XCF_Justify, UNDO_MORE, areawin->topinstance,
- (genericptr)settext, oldjust);
+ register_for_undo(XCF_Anchor, UNDO_MORE, areawin->topinstance,
+ (genericptr)settext, oldanchor);
}
}
else {
if (mode == 1)
- newjust = (areawin->justify & (NONJUSTFIELD | TBJUSTFIELD))
+ newanchor = (areawin->anchor & (NONANCHORFIELD | TBANCHORFIELD))
| value;
else
- newjust = (areawin->justify & (NONJUSTFIELD | RLJUSTFIELD))
+ newanchor = (areawin->anchor & (NONANCHORFIELD | RLANCHORFIELD))
| value;
- areawin->justify = newjust;
+ areawin->anchor = newanchor;
}
- if (w != NULL) togglejustifs(w);
+ if (w != NULL) toggleanchors(w);
}
-/*----------------------------------------------------------------*/
-/* Set vertical justification (top, middle, bottom) on all */
-/* selected labels */
-/*----------------------------------------------------------------*/
+/*--------------------------------------------------------------*/
+/* Set vertical anchoring (top, middle, bottom) on all */
+/* selected labels */
+/*--------------------------------------------------------------*/
-void setvjust(xcWidget w, pointertype value, caddr_t nulldata)
+void setvanchor(xcWidget w, pointertype value, caddr_t nulldata)
{
short *fselect;
labelptr settext;
@@ -214,7 +213,7 @@ void setvjust(xcWidget w, pointertype value, caddr_t nulldata)
if (eventmode == TEXT_MODE || eventmode == ETEXT_MODE) {
settext = *((labelptr *)EDITPART);
- setjust(w, value, settext, 2);
+ setanchor(w, value, settext, 2);
}
else {
for (fselect = areawin->selectlist; fselect < areawin->selectlist +
@@ -222,20 +221,20 @@ void setvjust(xcWidget w, pointertype value, caddr_t nulldata)
if (SELECTTYPE(fselect) == LABEL) {
labelcount++;
settext = SELTOLABEL(fselect);
- setjust(NULL, value, settext, 2);
+ setanchor(NULL, value, settext, 2);
}
}
- if (labelcount == 0) setjust(w, value, NULL, 2);
+ if (labelcount == 0) setanchor(w, value, NULL, 2);
else unselect_all();
}
}
/*----------------------------------------------------------------*/
-/* Set horizontal justification (left, center, right) on all */
+/* Set horizontal anchoring (left, center, right) on all */
/* selected labels */
/*----------------------------------------------------------------*/
-void sethjust(xcWidget w, pointertype value, caddr_t nulldata)
+void sethanchor(xcWidget w, pointertype value, caddr_t nulldata)
{
short *fselect;
labelptr settext;
@@ -243,7 +242,7 @@ void sethjust(xcWidget w, pointertype value, caddr_t nulldata)
if (eventmode == TEXT_MODE || eventmode == ETEXT_MODE) {
settext = *((labelptr *)EDITPART);
- setjust(w, value, settext, 1);
+ setanchor(w, value, settext, 1);
}
else {
for (fselect = areawin->selectlist; fselect < areawin->selectlist +
@@ -251,20 +250,20 @@ void sethjust(xcWidget w, pointertype value, caddr_t nulldata)
if (SELECTTYPE(fselect) == LABEL) {
labelcount++;
settext = SELTOLABEL(fselect);
- setjust(NULL, value, settext, 1);
+ setanchor(NULL, value, settext, 1);
}
}
- if (labelcount == 0) setjust(w, value, NULL, 1);
+ if (labelcount == 0) setanchor(w, value, NULL, 1);
else unselect_all();
}
}
/*--------------------------------------------------------------*/
-/* Set a justify field bit on all selected labels */
+/* Set an anchor field bit on all selected labels */
/* (flip invariance, latex mode, etc.) */
/*--------------------------------------------------------------*/
-void setjustbit(xcWidget w, pointertype value, caddr_t nulldata)
+void setanchorbit(xcWidget w, pointertype value, caddr_t nulldata)
{
short *fselect;
labelptr settext;
@@ -272,7 +271,7 @@ void setjustbit(xcWidget w, pointertype value, caddr_t nulldata)
if (eventmode == TEXT_MODE || eventmode == ETEXT_MODE) {
settext = *((labelptr *)EDITPART);
- dojustifybit(w, settext, (short)value);
+ doanchorbit(w, settext, (short)value);
}
else {
for (fselect = areawin->selectlist; fselect < areawin->selectlist +
@@ -280,20 +279,20 @@ void setjustbit(xcWidget w, pointertype value, caddr_t nulldata)
if (SELECTTYPE(fselect) == LABEL) {
labelcount++;
settext = SELTOLABEL(fselect);
- dojustifybit(NULL, settext, (short)value);
+ doanchorbit(NULL, settext, (short)value);
}
}
- if (labelcount == 0) dojustifybit(w, NULL, (short)value);
+ if (labelcount == 0) doanchorbit(w, NULL, (short)value);
else unselect_all();
}
}
/*--------------------------------------------------------------*/
-/* Set pin-related bit field of "justify" on all selected pins */
+/* Set pin-related bit field of "anchor" on all selected pins */
/* (e.g., pin visibility) */
/*--------------------------------------------------------------*/
-void setpinjustbit(xcWidget w, pointertype value, caddr_t nulldata)
+void setpinanchorbit(xcWidget w, pointertype value, caddr_t nulldata)
{
short *fselect;
labelptr settext;
@@ -301,7 +300,7 @@ void setpinjustbit(xcWidget w, pointertype value, caddr_t nulldata)
if (eventmode == TEXT_MODE || eventmode == ETEXT_MODE) {
settext = *((labelptr *)EDITPART);
if (settext->pin)
- dopinjustbit(w, settext, (short)value);
+ dopinanchorbit(w, settext, (short)value);
}
else {
for (fselect = areawin->selectlist; fselect < areawin->selectlist +
@@ -309,7 +308,7 @@ void setpinjustbit(xcWidget w, pointertype value, caddr_t nulldata)
if (SELECTTYPE(fselect) == LABEL) {
settext = SELTOLABEL(fselect);
if (settext->pin)
- dopinjustbit(NULL, settext, (short)value);
+ dopinanchorbit(NULL, settext, (short)value);
}
}
unselect_all();
@@ -394,7 +393,7 @@ void overdrawpixmap(xcWidget button)
#endif
#else
-#define overdrawpixmap(a)
+void overdrawpixmap(xcWidget button) {}
#endif /* XPM */
/*--------------------------------------------------------------*/
@@ -414,7 +413,7 @@ buttonsave *getgeneric(xcWidget button, void (*getfunction)(), void *dataptr)
if (button != NULL) {
XtSetArg(wargs[0], XtNforeground, &saveptr->foreground);
XtGetValues(button, wargs, 1);
- XtSetArg(wargs[0], XtNforeground, OFFBUTTONCOLOR);
+ XtSetArg(wargs[0], XtNforeground, colorlist[OFFBUTTONCOLOR].color.pixel);
XtSetValues(button, wargs, 1);
XtRemoveAllCallbacks(button, XtNselect);
}
@@ -1109,6 +1108,7 @@ void toolcursor(int mode)
void highlightexcl(xcWidget widget, int func, int value)
{
+#ifdef HAVE_XPM
Arg args[2];
xcWidget parent = xcParent(PanToolButton);
xcWidget sibling, self = (xcWidget)NULL;
@@ -1116,8 +1116,8 @@ void highlightexcl(xcWidget widget, int func, int value)
/* remove highlight from all widgets in the toolbar */
- XtSetArg(args[0], XtNbackground, BACKGROUND);
- XtSetArg(args[1], XtNborderColor, SNAPCOLOR);
+ XtSetArg(args[0], XtNbackground, colorlist[BACKGROUND].color.pixel);
+ XtSetArg(args[1], XtNborderColor, colorlist[SNAPCOLOR].color.pixel);
for (titem = ToolBar; titem < ToolBar + toolbuttons; titem++) {
sibling = XtNameToWidget(parent, titem->name);
if (sibling == widget)
@@ -1155,10 +1155,11 @@ void highlightexcl(xcWidget widget, int func, int value)
/* Now highlight the currently pushed widget */
if (self != (xcWidget)NULL) {
- XtSetArg(args[0], XtNbackground, RATSNESTCOLOR);
- XtSetArg(args[1], XtNborderColor, RATSNESTCOLOR);
+ XtSetArg(args[0], XtNbackground, colorlist[RATSNESTCOLOR].color.pixel);
+ XtSetArg(args[1], XtNborderColor, colorlist[RATSNESTCOLOR].color.pixel);
XtSetValues(self, args, 2);
}
+#endif /* HAVE_XPM */
}
/*--------------------*/
@@ -1405,18 +1406,13 @@ void setcolormark(int colorval)
if (colorval == DEFAULTCOLOR)
w = ColorInheritColorButton;
- else {
- for (i = 0; i < number_colors; i++)
- if (colorlist[i].color.pixel == colorval) {
- w = colorlist[i].cbutton;
- break;
- }
- }
+ else
+ w = colorlist[colorval].cbutton;
/* Remove mark from all menu items */
XtSetArg(args[0], XtNsetMark, False);
- for (i = 0; i < number_colors; i++)
+ for (i = NUMBER_OF_COLORS; i < number_colors; i++)
XtSetValues(colorlist[i].cbutton, args, 1);
XtSetValues(ColorInheritColorButton, args, 1);
@@ -1539,7 +1535,7 @@ void setcolor(xcWidget w, pointertype value, caddr_t calldata)
XtSetArg(wargs[0], XtNrectColor, &cval);
XtGetValues(w, wargs, 1);
- for (cindex = 0; cindex < number_colors; cindex++)
+ for (cindex = NUMBER_OF_COLORS; cindex < number_colors; cindex++)
if (colorlist[cindex].color.pixel == cval)
break;
if (cindex >= number_colors) {
@@ -1575,15 +1571,15 @@ void setcolor(xcWidget w, pointertype value, caddr_t calldata)
+ areawin->selects; scolor++) {
ecolor = &(SELTOCOLOR(scolor));
- *ecolor = cval;
+ *ecolor = cindex;
selected = True;
}
}
- setcolormark(cval);
+ setcolormark(cindex);
if (!selected) {
if (eventmode != TEXT_MODE && eventmode != ETEXT_MODE)
- areawin->color = cval;
+ areawin->color = cindex;
overdrawpixmap(w);
}
}
@@ -1616,10 +1612,10 @@ void setnewcolor(xcWidget w, caddr_t nullptr)
}
ccolor = rgb_alloccolor(red, green, blue);
}
- else
+ else {
ccolor = xc_alloccolor(_STR2);
-
- addnewcolorentry(ccolor);
+ addnewcolorentry(ccolor);
+ }
}
/*----------------------------------------------------------------*/
@@ -1661,23 +1657,23 @@ void setfontmarks(short fvalue, short jvalue)
togglefontmark(fvalue);
}
if (jvalue >= 0) {
- switch(jvalue & (RLJUSTFIELD)) {
- case NORMAL: w = JustificationLeftJustifiedButton; break;
- case NOTLEFT: w = JustificationCenterJustifiedButton; break;
- case RIGHT|NOTLEFT: w = JustificationRightJustifiedButton; break;
+ switch(jvalue & (RLANCHORFIELD)) {
+ case NORMAL: w = AnchoringLeftAnchoredButton; break;
+ case NOTLEFT: w = AnchoringCenterAnchoredButton; break;
+ case RIGHT|NOTLEFT: w = AnchoringRightAnchoredButton; break;
}
- toggleexcl(w, Justifs, XtNumber(Justifs));
+ toggleexcl(w, Anchors, XtNumber(Anchors));
- switch(jvalue & (TBJUSTFIELD)) {
- case NORMAL: w = JustificationBottomJustifiedButton; break;
- case NOTBOTTOM: w = JustificationMiddleJustifiedButton; break;
- case TOP|NOTBOTTOM: w = JustificationTopJustifiedButton; break;
+ switch(jvalue & (TBANCHORFIELD)) {
+ case NORMAL: w = AnchoringBottomAnchoredButton; break;
+ case NOTBOTTOM: w = AnchoringMiddleAnchoredButton; break;
+ case TOP|NOTBOTTOM: w = AnchoringTopAnchoredButton; break;
}
- toggleexcl(w, Justifs, XtNumber(Justifs));
+ toggleexcl(w, Anchors, XtNumber(Anchors));
/* Flip Invariance property */
- w = JustificationFlipInvariantButton;
+ w = AnchoringFlipInvariantButton;
if (jvalue & FLIPINV)
XtSetArg(wargs[0], XtNsetMark, True);
else