1Tk_GetVisual(3) Tk Library Procedures Tk_GetVisual(3)
2
3
4
5______________________________________________________________________________
6
8 Tk_GetVisual - translate from string to visual
9
11 #include <tk.h>
12
13 Visual *
14 Tk_GetVisual(interp, tkwin, string, depthPtr, colormapPtr)
15
17 Tcl_Interp *interp (in) Interpreter to use for error
18 reporting.
19
20 Tk_Window tkwin (in) Token for window in which the
21 visual will be used.
22
23 CONST char *string (in) String that identifies the
24 desired visual. See below for
25 valid formats.
26
27 int *depthPtr (out) Depth of returned visual gets
28 stored here.
29
30 Colormap *colormapPtr (out) If non-NULL then a suitable col‐
31 ormap for visual is found and its
32 identifier is stored here.
33_________________________________________________________________
34
35
37 Tk_GetVisual takes a string description of a visual and finds a suit‐
38 able X Visual for use in tkwin, if there is one. It returns a pointer
39 to the X Visual structure for the visual and stores the number of bits
40 per pixel for it at *depthPtr. If string is unrecognizable or if no
41 suitable visual could be found, then NULL is returned and Tk_GetVisual
42 leaves an error message in interp->result. If colormap is non-NULL
43 then Tk_GetVisual also locates an appropriate colormap for use with the
44 result visual and stores its X identifier at *colormapPtr.
45
46 The string argument specifies the desired visual in one of the follow‐
47 ing ways:
48
49 class depth The string consists of a class name followed by an inte‐
50 ger depth, with any amount of white space (including
51 none) in between. class selects what sort of visual is
52 desired and must be one of directcolor, grayscale,
53 greyscale, pseudocolor, staticcolor, staticgray, static‐
54 grey, or truecolor, or a unique abbreviation. depth
55 specifies how many bits per pixel are needed for the
56 visual. If possible, Tk_GetVisual will return a visual
57 with this depth; if there is no visual of the desired
58 depth then Tk_GetVisual looks first for a visual with
59 greater depth, then one with less depth.
60
61 default Use the default visual for tkwin's screen.
62
63 pathName Use the visual for the window given by pathName. path‐
64 Name must be the name of a window on the same screen as
65 tkwin.
66
67 number Use the visual whose X identifier is number.
68
69 best ?depth? Choose the ``best possible'' visual, using the following
70 rules, in decreasing order of priority: (a) a visual
71 that has exactly the desired depth is best, followed by
72 a visual with greater depth than requested (but as lit‐
73 tle extra as possible), followed by a visual with less
74 depth than requested (but as great a depth as possible);
75 (b) if no depth is specified, then the deepest available
76 visual is chosen; (c) pseudocolor is better than true‐
77 color or directcolor, which are better than staticcolor,
78 which is better than staticgray or grayscale; (d) the
79 default visual for the screen is better than any other
80 visual.
81
82
84 The idea for Tk_GetVisual, and the first implementation, came from Paul
85 Mackerras.
86
87
89 colormap, screen, visual
90
91
92
93Tk 4.0 Tk_GetVisual(3)