1Tk_GetPixelsFromObj(3) Tk Library Procedures Tk_GetPixelsFromObj(3)
2
3
4
5______________________________________________________________________________
6
8 Tk_GetPixelsFromObj, Tk_GetPixels, Tk_GetMMFromObj, Tk_GetScreenMM -
9 translate between strings and screen units
10
12 #include <tk.h>
13
14 int
15 Tk_GetPixelsFromObj(interp, tkwin, objPtr, intPtr)
16
17 int
18 Tk_GetPixels(interp, tkwin, string, intPtr)
19
20 int
21 Tk_GetMMFromObj(interp, tkwin, objPtr, doublePtr)
22
23 int
24 Tk_GetScreenMM(interp, tkwin, string, doublePtr)
25
27 Tcl_Interp *interp (in) Interpreter to use for error report‐
28 ing.
29
30 Tk_Window tkwin (in) Window whose screen geometry deter‐
31 mines the conversion between absolute
32 units and pixels.
33
34 Tcl_Obj *objPtr (in/out) String value specifies a distance on
35 the screen; internal rep will be mod‐
36 ified to cache converted distance.
37
38 const char *string (in) Same as objPtr except specification
39 of distance is passed as a string.
40
41 int *intPtr (out) Pointer to location in which to store
42 converted distance in pixels.
43
44 double *doublePtr (out) Pointer to location in which to store
45 converted distance in millimeters.
46_________________________________________________________________
47
48
50 These procedures take as argument a specification of distance on the
51 screen (objPtr or string) and compute the corresponding distance either
52 in integer pixels or floating-point millimeters. In either case,
53 objPtr or string specifies a screen distance as a floating-point number
54 followed by one of the following characters that indicates units:
55
56 <none> The number specifies a distance in pixels.
57
58 c The number specifies a distance in centimeters on the screen.
59
60 i The number specifies a distance in inches on the screen.
61
62 m The number specifies a distance in millimeters on the screen.
63
64 p The number specifies a distance in printer's points (1/72 inch)
65 on the screen.
66
67 Tk_GetPixelsFromObj converts the value of objPtr to the nearest even
68 number of pixels and stores that value at *intPtr. It returns TCL_OK
69 under normal circumstances. If an error occurs (e.g. objPtr contains a
70 number followed by a character that is not one of the ones above) then
71 TCL_ERROR is returned and an error message is left in interp's result
72 if interp is not NULL. Tk_GetPixelsFromObj caches information about
73 the return value in objPtr, which speeds up future calls to Tk_GetPix‐
74 elsFromObj with the same objPtr.
75
76 Tk_GetPixels is identical to Tk_GetPixelsFromObj except that the screen
77 distance is specified with a string instead of an object. This pre‐
78 vents Tk_GetPixels from caching the return value, so Tk_GetAnchor is
79 less efficient than Tk_GetPixelsFromObj.
80
81 Tk_GetMMFromObj and Tk_GetScreenMM are similar to Tk_GetPixelsFromObj
82 and Tk_GetPixels (respectively) except that they convert the screen
83 distance to millimeters and store a double-precision floating-point
84 result at *doublePtr.
85
86
88 centimeters, convert, inches, millimeters, pixels, points, screen units
89
90
91
92Tk 8.1 Tk_GetPixelsFromObj(3)