Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!purdue!bu-cs!bucsb!boreas From: boreas@bucsb.UUCP (Michael A. Justice) Newsgroups: comp.windows.x Subject: X Toolkit color problem Message-ID: <3112@bucsb.UUCP> Date: 17 Aug 89 05:33:04 GMT Reply-To: boreas@bucsb.UUCP (Michael A. Justice) Distribution: usa Organization: Boston Univ Comp. Sci. Lines: 73 Having finally written a working widget, I tried making sure it worked properly in color. After a few hours of fiddling, I tried other widgets, notably the Label widget in the Xaw library. Color doesn't seem to work properly for it, either, unless set with the command-line -bg and -fg switches. The system is a Sun 3/60 with a CG4, X11R3, the MIT sample server. I don't know for certain how well-patched everything is; however, one staff member here (who refused to commit himself :-) said he believes our X stuff is up-to-date as far as official patches goes, and has the Purdue speedups installed. The following program is what I was "testing" with, compiled with the Xaw, Xmu, Xt, and X11 libraries. If run as "a.out -fg red -bg green" (or other named colors) it works fine. If run as "a.out red green" the colors are wrong, and if "a.out blue red" is run while the "red/green" window is still up, the new widget usually comes up with the same off-colors as the earlier one. (Sometimes they're different weird colors, again not the ones specified.) The same happens if the color is named within the program as a constant (as in XtSetArg (args[n], XtNbackground, "red") ; etc.) instead of placed on the command line. The same also happens if I declare the string as static char fore[] = "red"; etc. Using the resource manager (-xrm options on the command-line) works fine, BTW. I took a look in Young's Xt book; chapter six, on color, doesn't deal with toolkit color allocation much. Looked good for Xlib, though, and for using Xlib calls within toolkit programs. Sigh. What am I doing wrong? Or am I? Thanks in advance, -- Michael. #include#include #include #include #include void main (argc, argv) int argc ; char *argv[] ; { Widget toplevel, test ; Arg args[5] ; int n ; toplevel = XtInitialize ("main", "Label", NULL, 0, &argc, argv) ; n = 0 ; XtSetArg (args[n], XtNlabel, "this is a test") ; n++ ; if (argc != 1) /* assume user used two color args, since this *is* supposed to set both the fore- and background */ { XtSetArg (args[n], XtNforeground, argv[1]) ; n++ ; XtSetArg (args[n], XtNbackground, argv[2]) ; n++ ; } test = XtCreateManagedWidget("test", labelWidgetClass, toplevel, args, n) ; XtRealizeWidget (toplevel) ; XtMainLoop () ; } -- BITNet: cscj0an@buacca \ Michael Andrew Justice @ BU Graduate School (CS) ARPA: boreas@bucsb.bu.edu \ "My sophistication surprises you, Zorba?" CSNET: boreas%bucsb@bu-cs \ "Your existence surprises me, Bald Ape." UUCP: ...!husc6!bu-cs!bucsb!boreas \ S.R. Boyett, _The_Architect_of_Sleep_