Tk_GetVisual(3)

✨ Tk_GetVisual(3) ✨

okay bestie, welcome to the Tk Library Procedures page for Tk_GetVisual β€” the string-to-visual translator. it's giving β€œfind me a suitable X Visual for this window,” and I'm obsessed. πŸ’…


🌸 NAME 🌸

Tk_GetVisual β€” translate from string to visual. literally the glow-up from text to visual. ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <tk.h>

Visual *
Tk_GetVisual(interp, tkwin, string, depthPtr, colormapPtr)

πŸ¦‹ ARGUMENTS πŸ¦‹

  • Tcl_Interp *interp (in) β€” interpreter to use for error reporting. she's the messenger for any oops.
  • Tk_Window tkwin (in) β€” token for window in which the visual will be used. main character window energy.
  • const char *string (in) β€” string that identifies the desired visual. valid formats are down in DESCRIPTION, iykyk.
  • int *depthPtr (out) β€” depth of the returned visual gets stored here.
  • Colormap *colormapPtr (out) β€” if non-NULL, then a suitable colormap for the visual is found and its identifier is stored here. πŸŽ€

πŸ’– DESCRIPTION πŸ’–

Tk_GetVisual takes a string description of a visual and finds a suitable X Visual for use in tkwin, 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 *depthPtr. if string is unrecognizable or if no suitable visual could be found, then NULL is returned and Tk_GetVisual leaves an error message in interpreter interp's result. 😭 no visual? it said error message.

If colormap is non-NULL then Tk_GetVisual also locates an appropriate colormap for use with the result visual and stores its X identifier at *colormapPtr.

The string argument specifies the desired visual in one of the following ways:

  • class depth β€” the string consists of a class name followed by an integer depth, with any amount of white space (including none) in between. class selects what sort of visual is desired and must be one of directcolor, grayscale, greyscale, pseudocolor, staticcolor, staticgray, staticgrey, or truecolor, or a unique abbreviation. depth specifies how many bits per pixel are needed for the visual. if possible, Tk_GetVisual will return a visual with this depth; if there is no visual of the desired depth then Tk_GetVisual looks first for a visual with greater depth, then one with less depth. ✨
  • default β€” use the default visual for tkwin's screen. the safe vibe.
  • pathName β€” use the visual for the window given by pathName. pathName must be the name of a window on the same screen as tkwin. no cross-screen drama, bestie.
  • number β€” use the visual whose X identifier is number. numbers era.
  • best ?depth? β€” choose the β€œbest possible” visual, using the following rules, in decreasing order of priority:
    • (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);
    • (b) if no depth is specified, then the deepest available visual is chosen;
    • (c) pseudocolor is better than truecolor or directcolor, which are better than staticcolor, which is better than staticgray or grayscale;
    • (d) the default visual for the screen is better than any other visual. πŸ‘‘

🌈 CREDITS 🌈

the idea for Tk_GetVisual, and the first implementation, came from Paul Mackerras. shoutout legend 🫢


⭐ KEYWORDS ⭐

colormap, screen, visual β€” the keyword trio. πŸ”₯


okay that's the whole page! πŸ’– footer energy: Tk, version 4.0, Tk_GetVisual(3) β€” byeee, go find your visual bestie ✨🫢

πŸ“¦ where this page comes from