Tk_GetReliefFromObj(3tk)
β¨ Tk_GetReliefFromObj β it's giving relief translation β¨
okay bestie so this one lives in the Tk Library Procedures manual, and it's literally the little trio of functions that translate back and forth between relief strings (you know, flat, raised, sunkenβ¦) and the actual relief values Tk wants. no cap, it's the glow-up translator for your widgets. π
πΈ NAME πΈ
Tk_GetReliefFromObj, Tk_GetRelief, Tk_NameOfRelief β translate between strings and relief values π¦
π SYNOPSIS π
#include <tk.h>
int
Tk_GetReliefFromObj(interp, objPtr, reliefPtr)
int
Tk_GetRelief(interp, name, reliefPtr)
const char *
Tk_NameOfRelief(relief)
π ARGUMENTS π
Tcl_Interp *interp(in) β the interpreter you want to use for error reporting. that's its whole job.Tcl_Obj *objPtr(in/out) β its string value holds the name of a relief, one of"flat","groove","raised","ridge","solid", or"sunken"(or literally any unique abbreviation of those on input, iykyk); the internal rep gets modified so it can cache the matching relief value. main character behavior tbh.const char *name(in) β same energy asobjPtrexcept the relief description shows up as a plain string instead.int *reliefPtr(out) β pointer to the spot where the relief value matchingobjPtrornamegets stored. π«Άint relief(in) β a relief value, one ofTK_RELIEF_FLAT,TK_RELIEF_RAISED,TK_RELIEF_SUNKEN,TK_RELIEF_GROOVE,TK_RELIEF_SOLID, orTK_RELIEF_RIDGE.
π DESCRIPTION π
Tk_GetReliefFromObj places into *reliefPtr the relief value that corresponds to the value of objPtr. that value is gonna be one of TK_RELIEF_FLAT, TK_RELIEF_RAISED, TK_RELIEF_SUNKEN, TK_RELIEF_GROOVE, TK_RELIEF_SOLID, or TK_RELIEF_RIDGE. under normal circumstances the return value is TCL_OK and interp just sits there unused, minding its business. π
but if objPtr does not contain one of the valid relief names β or an abbreviation of one of them β then TCL_ERROR comes back, *reliefPtr stays unmodified (not a single thing about it changes, periodt), and an error message gets stored in interp's result, but only if interp is not NULL.
and here's the slay part: Tk_GetReliefFromObj caches info about the return value inside objPtr, which speeds up future calls to Tk_GetReliefFromObj with that same objPtr. it remembers so you don't have to. π
Tk_GetRelief is identical to Tk_GetReliefFromObj except the relief description is specified with a string instead of an object. but the way that this prevents Tk_GetRelief from caching the return valueβ¦ yeah, that makes Tk_GetRelief less efficient than Tk_GetReliefFromObj. no caching, no speed-up, it's giving hard mode. π
Tk_NameOfRelief is the logical inverse of Tk_GetRelief. hand it a relief value and it returns the corresponding string (flat, raised, sunken, groove, solid, or ridge). and if relief is not a legal relief value? then "unknown relief" gets returned. iconic fail state, honestly.
lowkey reminder bestie: those six relief names and their unique abbreviations are the whole vibe check β anything else is aTCL_ERRORand*reliefPtrdoesn't budge. π₯
π KEYWORDS π
name, relief, string
and that's the whole page, bestie π this one came from the Tk docs, version 8.1, dated 8.1 β go forth and translate your reliefs, you absolute legend π§π
π¦ where this page comes from
- debian trixie: tk8.6-doc 8.6.16-1
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk8.6-doc 8.6.17-1
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk8.6-doc 8.6.17-1build1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk8.6-doc 8.6.18-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1990 The Regents of the University of California
- Copyright (c) 1994-1998 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms