NAME
TkGetColormap, TkFreeColormap - allocate and free colormaps
SYNOPSIS
##iinncclluuddee <
Colormap TTkkGGeettCCoolloorrmmaapp((interp, tkwin, string)) TTkkFFrreeeeCCoolloorrmmaapp((display, colormap)) AARRGGUUMMEENNTTSS TclInterp *interp (in) Interpreter to use for error reporting. TkWindow tkwin (in) Token for window in which colormap will be used. CONST char *string (in) Selects a colormap: either nneeww or the name of a window with the same screen and visual as tkwin.> Display *display (in) Display for which colormap was allo-
cated. Colormap colormap (in) Colormap to free; must have beenreturned by a previous call to TTkkGGeett-
CCoolloorrmmaapp or TTkkGGeettVViissuuaall.DESCRIPTION
These procedures are used to manage colormaps. TTkkGGeettCCoolloorrmmaapp returns a colormap suitable for use in tkwin. If its string argument is nneeww then a new colormap is created; otherwise string must be the name ofanother window with the same screen and visual as tkwin, and the col-
ormap from that window is returned. If string doesn't make sense, or if it refers to a window on a different screen from tkwin or with a different visual than tkwin, then TTkkGGeettCCoolloorrmmaapp returns NNoonnee andleaves an error message in interp->result.
TTkkFFrreeeeCCoolloorrmmaapp should be called when a colormap returned by TTkkGGeettCCooll-
oorrmmaapp is no longer needed. Tk maintains a reference count for each colormap returned by TTkkGGeettCCoolloorrmmaapp, so there should eventually be onecall to TTkkFFrreeeeCCoolloorrmmaapp for each call to TTkkGGeettCCoolloorrmmaapp. When a col-
ormap's reference count becomes zero, Tk releases the X colormap. TTkkGGeettVViissuuaall and TTkkGGeettCCoolloorrmmaapp work together, in that a new colormap created by TTkkGGeettVViissuuaall may later be returned by TTkkGGeettCCoolloorrmmaapp. The reference counting mechanism for colormaps includes both procedures, so callers of TTkkGGeettVViissuuaall must also call TTkkFFrreeeeCCoolloorrmmaapp to release the colormap. If TTkkGGeettCCoolloorrmmaapp is called with a string value of nneeww thenthe resulting colormap will never be returned by TTkkGGeettVViissuuaall; how-
ever, it can be used in other windows by calling TTkkGGeettCCoolloorrmmaapp with the original window's name as string. KKEEYYWWOORRDDSS colormap Tk 4.0 TkGetColormap(3)