Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0c9458084a
Fetching contributors…

Cannot retrieve contributors at this time

101 lines (100 sloc) 3.545 kb
'\" Copyright (c) 1994 The Regents of the University of California.
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
.so man.macros
.TH Tk_GetVisual 3 4.0 Tk "Tk Library Procedures"
Tk_GetVisual \- translate from string to visual
\fB#include <tk.h>\fR
Visual *
\fBTk_GetVisual(\fIinterp, tkwin, string, depthPtr, colormapPtr\fB)\fR
.AS "Tcl_Interp" *colormapPtr
.AP Tcl_Interp *interp in
Interpreter to use for error reporting.
.AP Tk_Window tkwin in
Token for window in which the visual will be used.
.AP "const char" *string in
String that identifies the desired visual. See below for
valid formats.
.AP int *depthPtr out
Depth of returned visual gets stored here.
.AP Colormap *colormapPtr out
If non-NULL then a suitable colormap for visual is found and its
identifier is stored here.
\fBTk_GetVisual\fR takes a string description of a visual and
finds a suitable X Visual for use in \fItkwin\fR, if there is one.
It returns a pointer to the X Visual structure for the visual
and stores the number of bits per pixel for it at \fI*depthPtr\fR.
If \fIstring\fR is unrecognizable or if no suitable visual could
be found, then NULL is returned and \fBTk_GetVisual\fR leaves
an error message in interpreter \fIinterp\fR's result.
If \fIcolormap\fR is non-NULL then \fBTk_GetVisual\fR
also locates an appropriate colormap for use with the result visual
and stores its X identifier at \fI*colormapPtr\fR.
The \fIstring\fR argument specifies the desired visual in one
of the following ways:
.TP 15
\fIclass depth\fR
The string consists of a class name followed by an integer depth,
with any amount of white space (including none) in between.
\fIclass\fR selects what sort of visual is desired and must be one of
\fBdirectcolor\fR, \fBgrayscale\fR, \fBgreyscale\fR, \fBpseudocolor\fR,
\fBstaticcolor\fR, \fBstaticgray\fR, \fBstaticgrey\fR, or
\fBtruecolor\fR, or a unique abbreviation.
\fIdepth\fR specifies how many bits per pixel are needed for the
If possible, \fBTk_GetVisual\fR will return a visual with this depth;
if there is no visual of the desired depth then \fBTk_GetVisual\fR
looks first for a visual with greater depth, then one with less
.TP 15
Use the default visual for \fItkwin\fR's screen.
.TP 15
Use the visual for the window given by \fIpathName\fR.
\fIpathName\fR must be the name of a window on the same screen
as \fItkwin\fR.
.TP 15
Use the visual whose X identifier is \fInumber\fR.
.TP 15
\fBbest\fR ?\fIdepth\fR?
Choose the
.QW "best possible"
visual, using the following rules, in decreasing order of priority:
.IP (a)
a visual that has exactly the desired depth is best, followed
by a visual with greater depth than requested (but as little extra
as possible), followed by a visual with less depth than requested
(but as great a depth as possible);
.IP (b)
if no \fIdepth\fR is specified, then the deepest available visual
is chosen;
.IP (c)
\fBpseudocolor\fR is better than \fBtruecolor\fR or \fBdirectcolor\fR,
which are better than \fBstaticcolor\fR, which is better than
\fBstaticgray\fR or \fBgrayscale\fR;
.IP (d)
the default visual for the screen is better than any other visual.
The idea for \fBTk_GetVisual\fR, and the first implementation, came
from Paul Mackerras.
colormap, screen, visual
Jump to Line
Something went wrong with that request. Please try again.