% colortranslate darkmagenta
139 0 139
The good news is that there is a function Tk_GetColor that already
performs this task, so all I have to do to is wrap it with a command:
int colortranslate(ClientData, Tcl_Interp* interp, int, Tcl_Obj*) {
/* ... */
XColor* co = Tk_GetColor(interp, tkwin, name);
/* ... */
return TCL_OK;
}
The bad news is that I don't know how to find a tkwin argument necessary
for invoking Tk_GetColor. Any suggestions?
I am willing to pass the string name of an existing window to my
function (so that my function call would now be: "colortranslate .c
darkmagenta"), but I don't know how to convert the name of a window to a
Tk_Window object. There is another function, Tk_NameToWindow for the
latter purpose, but this function also needs a tkwin argument! Kind of
a chicken-and-egg problem. (Note: I am quite familiar with the C/Tcl API
but not with the C/Tk API.)
Thanks,
Steve Vavasis
Is there something wrong with [winfo rgb . darkmagenta]?
Chris
--
Rens-se-LEER is a county. RENS-se-ler is a city. R-P-I is a school!
He seems to want a tcl (ie: non-tk) solution.
--
Bryan Oakley mailto:oak...@channelpoint.com
ChannelPoint, Inc. http://purl.oclc.org/net/oakley
If all you really want to do is translate the colorname to an rgb value, as
specified. You can do this all in Tcl/Tk. Here is the code:
proc colortranslate {color} {
return [winfo rgb . $color]
}
If it really was how to get a tkwin item, please repost with that request.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
... assuming you have tk loaded. This won't work in tclsh. It was my
impression that the original poster wanted a pure tcl (ie: non-tk)
solution. I could be wrong.
Well, the original poster was muttering about a tkwin argument to
Tk_GetColor, so I would presume that he's already got Tk loaded. The
routine he's after is, of course, Tk_MainWindow(Tcl_Interp *interp)
Thus:
XColor color = Tk_GetColor(interp, Tk_MainWindow(interp), "skybluepink");
if (color == NULL) { /* Oops! */
return TCL_ERROR;
}
/* Use the color here */
Tk_FreeColor(color); /* Done with it now! */
Note that if you have a multi-display interpreter, this only ever uses
the main display (a problem since colours are not constant across
displays by any means...)
Donal.
--
Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fell...@cs.man.ac.uk
Department of Computer Science, University of Manchester, U.K. +44-161-275-6137
--
"And remember, evidence is nothing." - Stacy Strock <sp...@adisfwb.com>
: .... assuming you have tk loaded. This won't work in tclsh. It was my
: impression that the original poster wanted a pure tcl (ie: non-tk)
: solution. I could be wrong.
Really I have done some research on that subject developing GIS
extension to Tcl, but found that there is no portable solution.
You can try to find rgb.txt file in some predefined places, but
note that your program might run on server where no X installed.
: --
: Bryan Oakley mailto:oak...@channelpoint.com
: ChannelPoint, Inc. http://purl.oclc.org/net/oakley
--
--------------------------------------------------------
I have tin news and pine mail...
Victor Wagner @ home = vi...@wagner.rinet.ru