OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tk/] [doc/] [MeasureChar.3] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.