Subject: Re: Tk XGetGCValues equiv for Win32? - DN [1]
"George A. Howlett" <gah@cadence.com> - 21 Jan 2000 - comp.lang.tcl
Douglas du Boulay <ddb@crystal.uwa.edu.au> wrote:
> I have hacked togeather a small C code fortran interface library to
> Tcl/Tk with its own "canvas" object that I can render to directly
> with X11.
> I am now trying to port it to the Win32 platform but have discovered
> that the only X11 command that I used which is not in the X11
> emulation library supplied with the 8.2 Tcl/Tk distribution for that
> platform is XGetGCValues
> Under Unix/X11 I used this function to query the foreground colour
> of a given (non Tk GraphicsContext and return the colour to the tcl
> interpreter as a string.
> Is there some other way to get this info from the Tk equivalent of
> the X11 graphics context under Windows??? Any work around will do
> at this point!
If you are using the Xlib emulation routines from the Tk library, then
XGetGCValues should be fairly easy to implement. The GC that
XCreateGC returns is actually a pointer to an XGCValues structure.
XColor *fg;
fg = gc->foreground;
Status
XGetGCValues(display, gc, mask, valuesPtr)
Display *display;
GC gc;
unsigned long mask;
XGCValues *valuesPtr;
{
if (mask & GCFunction) {
valuesPtr->function = gc->function;
mask &= ~GCFunction;
}
if (mask & GCPlaneMask) {
valuesPtr->plane_mask = gc->plane_mask;
mask &= ~GCPlaneMask;
}
if (mask & GCForeground) {
valuesPtr->foreground = gc->foreground;
mask &= ~GCForground;
}
if (mask & GCBackground) {
valuesPtr->background = gc->background;
mask &= ~GCBackground;
}
if (mask & GCLineWidth) {
valuesPtr->line_width = gc->line_width;
mask &= ~GCLineWidth;
}
if (mask & GCLineStyle) {
valuesPtr->line_style = gc->line_style;
mask &= ~GCLineStyle;
}
if (mask & GCCapStyle) {
valuesPtr->cap_style = gc->cap_style;
mask &= ~GCCapStyle;
}
if (mask & GCJoinStyle) {
valuesPtr->join_style = gc->join_style;
mask &= ~GCJoinStyle;
}
if (mask & GCFillStyle) {
valuesPtr->fill_style = gc->fill_style;
mask &= ~GCFillStyle;
}
if (mask & GCFillRule) {
valuesPtr->fill_rule = gc->fill_rule;
mask &= ~GCFillRule;
}
if (mask & GCArcMode) {
valuesPtr->arc_mode = gc->arc_mode;
mask &= ~GCArcMode;
}
if (mask & GCTile) {
valuesPtr->tile = gc->tile;
mask &= ~GCTile;
}
if (mask & GCStipple) {
valuesPtr->stipple = gc->stipple;
mask &= ~GCStipple;
}
if (mask & GCTileStipXOrigin) {
valuesPtr->ts_x_origin = gc->ts_x_origin;
mask &= ~GCTileStipXOrigin;
}
if (mask & GCTileStipYOrigin) {
valuesPtr->ts_y_origin = gc->ts_y_origin;
mask &= ~GCTileStipYOrigin;
}
if (mask & GCFont) {
valuesPtr->font = gc->font;
mask &= ~GCFont;
}
if (mask & GCSubwindowMode) {
valuesPtr->subwindow_mode = gc->subwindow_mode;
mask &= ~GCSubwindowMode;
}
if (mask & GCGraphicsExposures) {
valuesPtr->graphics_exposures = gc->graphics_exposures;
mask &= ~GCGraphicsExposures;
}
if (mask & GCClipXOrigin) {
valuesPtr->clip_x_origin = gc->clip_x_origin;
mask &= ~GCClipXOrigin;
}
if (mask & GCClipYOrigin) {
valuesPtr->clip_y_origin = gc->clip_y_origin;
mask &= ~GCClipYOrigin;
}
if (mask & GCClipMask) {
XSetClipMask(d, valuesPtr, gc->clip_mask);
mask &= ~GCClipMask;
}
if (mask & GCDashOffset) {
valuesPtr->dash_offset = gc->dash_offset;
mask &= ~GCDashOffset;
}
if (mask & GCDashList) {
valuesPtr->dashes = gc->dashes;
mask &= ~GCDashList;
}
return (mask == 0);
}
--gah
Last modified
2000-02-10
2000-02-10
(195.108.246.50)
Note: you are looking at
the snapshot of an old wiki
- much of this information
is likely to be very outdated
