Debian Codegraph @

pod/pTk/MeasureChar.pod

raw
1 # Copyright (c) 1996 Sun Microsystems, Inc.
2 # See the file "license.terms" for information on usage and redistribution
3 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
4 #
5 #
6
7 =head1 NAME
8
9 Tk_MeasureChars, Tk_TextWidth, Tk_DrawChars, Tk_UnderlineChars - routines to measure and display simple single-line strings.
10
11 =for category C Programming
12
13 =head1 SYNOPSIS
14
15 B<#include E<lt>tk.hE<gt>>
16
17 int
18 B<Tk_MeasureChars(>I<tkfont, string, maxChars, maxPixels, flags, lengthPtr>B<)>
19
20 int
21 B<Tk_TextWidth(>I<tkfont, string, numChars>B<)>
22
23 void
24 B<Tk_DrawChars(>I<display, drawable, gc, tkfont, string, numChars, x, y>B<)>
25
26 void
27 B<Tk_UnderlineChars(>I<display, drawable, gc, tkfont, string, x, y, firstChar, lastChar>B<)>
28
29 =head1 ARGUMENTS
30
31 =over 4
32
33 =item Tk_Font tkfont (in)
34
35 Token for font in which text is to be drawn or measured. Must have been
36 returned by a previous call to B<Tk_GetFont>.
37
38 =item "const char" *string (in)
39
40 Text to be measured or displayed. Need not be null terminated. Any
41 non-printing meta-characters in the string (such as tabs, newlines, and
42 other control characters) will be measured or displayed in a
43 platform-dependent manner.
44
45 =item int maxChars (in)
46
47 The maximum number of characters to consider when measuring I<string>.
48 Must be greater than or equal to 0.
49
50 =item int maxPixels (in)
51
52 If I<maxPixels> is greater than 0, it specifies the longest permissible
53 line length in pixels. Characters from I<string> are processed only
54 until this many pixels have been covered. If I<maxPixels> is E<lt>= 0, then
55 the line length is unbounded and the I<flags> argument is ignored.
56
57 =item int flags (in)
58
59 Various flag bits OR-ed together: TK_PARTIAL_OK means include a character
60 as long as any part of it fits in the length given by I<maxPixels>;
61 otherwise, a character must fit completely to be considered.
62 TK_WHOLE_WORDS means stop on a word boundary, if possible. If
63 TK_AT_LEAST_ONE is set, it means return at least one character even if no
64 characters could fit in the length given by I<maxPixels>. If
65 TK_AT_LEAST_ONE is set and TK_WHOLE_WORDS is also set, it means that if
66 not even one word fits on the line, return the first few letters of the
67 word that did fit; if not even one letter of the word fit, then the first
68 letter will still be returned.
69
70 =item int *lengthPtr (out)
71
72 Filled with the number of pixels occupied by the number of characters
73 returned as the result of B<Tk_MeasureChars>.
74
75 =item int numChars (in)
76
77 The total number of characters to measure or draw from I<string>. Must
78 be greater than or equal to 0.
79
80 =item Display *display (in)
81
82 Display on which to draw.
83
84 =item Drawable drawable (in)
85
86 Window or pixmap in which to draw.
87
88 =item GC gc (in)
89
90 Graphics context for drawing characters. The font selected into this GC
91 must be the same as the I<tkfont>.
92
93 =item int "x, y" (in)
94
95 Coordinates at which to place the left edge of the baseline when displaying
96 I<string>.
97
98 =item int firstChar (in)
99
100 The index of the first character to underline in the I<string>.
101 Underlining begins at the left edge of this character.
102
103 =item int lastChar (in)
104
105 The index of the last character up to which the underline will
106 be drawn. The character specified by I<lastChar> will not itself be
107 underlined.
108
109 =back
110
111 =head1 DESCRIPTION
112
113 These routines are for measuring and displaying simple single-font,
114 single-line, strings. To measure and display single-font, multi-line,
115 justified text, refer to the documentation for B<Tk_ComputeTextLayout>.
116 There is no programming interface in the core of Tk that supports
117 multi-font, multi-line text; support for that behavior must be built on
118 top of simpler layers.
119
120 A glyph is the displayable picture of a letter, number, or some other
121 symbol. Not all character codes in a given font have a glyph.
122 Characters such as tabs, newlines/returns, and control characters that
123 have no glyph are measured and displayed by these procedures in a
124 platform-dependent manner; under X, they are replaced with backslashed
125 escape sequences, while under Windows and Macintosh hollow or solid boxes
126 may be substituted. Refer to the documentation for
127 B<Tk_ComputeTextLayout> for a programming interface that supports the
128 platform-independent expansion of tab characters into columns and
129 newlines/returns into multi-line text.
130
131 B<Tk_MeasureChars> is used both to compute the length of a given
132 string and to compute how many characters from a string fit in a given
133 amount of space. The return value is the number of characters from
134 I<string> that fit in the space specified by I<maxPixels> subject to
135 the conditions described by I<flags>. If all characters fit, the return
136 value will be I<maxChars>. I<*lengthPtr> is filled with the computed
137 width, in pixels, of the portion of the string that was measured. For
138 example, if the return value is 5, then I<*lengthPtr> is filled with the
139 distance between the left edge of I<string>[0] and the right edge of
140 I<string>[4].
141
142 B<Tk_TextWidth> is a wrapper function that provides a simpler interface
143 to the B<Tk_MeasureChars> function. The return value is how much
144 space in pixels the given I<string> needs.
145
146 B<Tk_DrawChars> draws the I<string> at the given location in the
147 given I<drawable>.
148
149 B<Tk_UnderlineChars> underlines the given range of characters in the
150 given I<string>. It doesn't draw the characters (which are assumed to
151 have been displayed previously by B<Tk_DrawChars>); it just draws the
152 underline. This procedure is used to underline a few characters without
153 having to construct an underlined font. To produce natively underlined
154 text, the appropriate underlined font should be constructed and used.
155
156 =head1 KEYWORDS
157
158 font