head	1.10;
access;
symbols
	core-8-5-9:1.10
	core-8-5-8:1.10
	macosx-cocoa-merge:1.10
	macosx-cocoa-premerge:1.10
	macosx-carbon-freeze:1.10
	core-8-5-7:1.10
	core-8-5-6:1.10
	core-8-6-b1:1.10
	core-8-6-a3:1.10
	core-8-5-5:1.10
	core-8-6-a2:1.10
	core-8-5-4:1.10
	core-8-5-3:1.10
	core-8-6-a1:1.10
	core-8-4-19:1.4
	core-8-5-branch:1.10.0.2
	core-8-5-2:1.10
	core-8-4-18:1.4
	core-8-5-1:1.10
	core-8-4-17:1.4
	core-8-5-0:1.9
	core-8-5-b3:1.8
	core-8-5-b2:1.7
	core-8-4-16:1.4
	core-8-5-b1:1.7
	core-stablilizer-merge:1.7
	core-stabilizer-branch:1.7.0.2
	core-stabilizer-merge:1.10
	core-8-4-15:1.4
	core-8-5-a6:1.7
	core-8-5-a5:1.7
	core-8-4-14:1.4
	core-8-5-a4:1.7
	core-8-4-13:1.4
	core-8-4-12:1.4
	core-8-4-11:1.4
	core-8-5-a3:1.7
	core-8-4-10:1.4
	core-8-4-9-branch:1.4.0.14
	core-8-5-a2:1.6
	core-8-4-9:1.4
	core-8-4-8:1.4
	core-8-4-7:1.4
	core-8-5-a1:1.4
	core-8-4-6:1.4
	core-8-4-5:1.4
	mistachkin-dev-branch:1.4.0.12
	core-8-4-4:1.4
	core-8-4-3:1.4
	core-8-4-branch:1.4.0.10
	core-8-4-2:1.4
	core-8-4-1:1.4
	core-8-3-5:1.4
	core-8-4-0:1.4
	macosx-8-4-merge-2002-08-31-trunk:1.4
	macosx-8-4-premerge-2002-08-31-branch:1.4
	macosx-8-4-premerge-2002-08-31-trunk:1.4
	macosx-8-4-merge-2002-08-30-branch:1.4
	macosx-8-4-merge-2002-08-30-trunk:1.4
	macosx-8-4-merge-2002-08-20-branch:1.4
	macosx-8-4-merge-2002-08-20-trunk:1.4
	core-8-4-b2:1.4
	core-8-4-b1:1.4
	macosx-premerge-6-9-02:1.4
	core-8-4-a4:1.4
	core-8-3-4:1.4
	macosx-8-4-branch:1.4.0.8
	macosx-8-4-branchpoint:1.4
	core-8-4-a3:1.4
	core-8-3-3:1.4
	dgp-privates-into-namespace:1.4.0.6
	tclpro-1-5-0:1.4
	core-8-4-win-speedup:1.4.0.4
	core-8-4-a2:1.4
	tclpro-1-4-1:1.4
	tclpro-1-4-0:1.4
	core-8-3-2:1.4
	ajuba-ajuba2-2-1-base:1.4
	ajuba-ajuba2-2-0:1.4
	core-8-4-a1:1.4
	core-8-3-1-branch:1.4.0.2
	core-8-3-1:1.4
	scriptics-sc-2-0-b5:1.4
	scriptics-sc-2-0-fixed:1.4
	scriptics-sc-2-0-b2:1.4
	scriptics-sc-2-0-b1:1.4
	core-8-3-0:1.4
	core-8-3-b2:1.4
	core-8-3-b1:1.4
	scriptics-sc-1-1:1.3
	scriptics-sc-1-1-b1:1.3
	core-8-2-3:1.3
	scriptics-sc-1-1-branch:1.3.0.10
	scriptics-sc-1-1-base:1.3
	scriptics-sc-1-0:1.3
	scriptics-sc-1-0-branch:1.3.0.8
	scriptics-sc-1-0-base:1.3
	core-8-2-2:1.3
	core-8-2-1:1.3
	scriptics-bc-1-0-b1:1.3
	core-8-2-1-branch:1.3.0.6
	scriptics-tclpro-1-3-0:1.3
	core-8-2-0:1.3
	core-8-2-b3-branch:1.3.0.4
	core-8-2-b3-base:1.3
	scriptics-tclpro-1-3-b4:1.3
	core-8-2-b2:1.3
	scriptics-tclpro-1-3-b3:1.3
	core-8-2-b1:1.3
	scriptics-tclpro-1-3-b2:1.3
	merge-to-mainline-5/21/99:1.3
	scriptics-tclpro-1-3-b2-branch:1.3.0.2
	core-8-1-1:1.3
	scriptics-tclpro-1-3-b1:1.3
	core-8-1-1-base:1.3
	core-8-1-0:1.3
	merge-to-mainline-4-29-99:1.3
	merge-to-mainline-4-23-99:1.3
	core-8-1-branch-old:1.1.0.4
	core-8-0-6-branch:1.2.0.6
	core-8-0-6-base:1.2
	core-8-0-5:1.2
	core-8-1-b3:1.1.4.3
	core-8-1-b2:1.1.4.2
	dev-8-1-stubs-branch:1.1.4.2.0.2
	dev-stubs-branch:1.2.0.4
	scriptics-tclpro-1-2:1.2
	scriptics-tclpro-1-2-b2:1.2
	core-8-1-merge-2/10/99:1.2
	core-8-0-5-branch:1.2.0.2
	core-8-0-5-base:1.2
	scriptics-tclpro-1-2-b1:1.2
	scriptics-tclpro-1-2-a1:1.2
	core-8-1-b1:1.1.4.2
	core-8-0-4:1.2
	core-8-1-a2:1.1
	core-8-0-2:1.1
	core-8-0-3:1.2;
locks; strict;
comment	@# @;


1.10
date	2008.02.04.09.53.24;	author dkf;	state Exp;
branches;
next	1.9;

1.9
date	2007.12.13.15.23.43;	author dgp;	state Exp;
branches;
next	1.8;

1.8
date	2007.10.29.16.04.13;	author dkf;	state Exp;
branches;
next	1.7;

1.7
date	2005.04.06.21.11.54;	author dkf;	state Exp;
branches
	1.7.2.1;
next	1.6;

1.6
date	2004.09.19.16.05.36;	author dkf;	state Exp;
branches;
next	1.5;

1.5
date	2004.08.22.15.43.20;	author dkf;	state Exp;
branches;
next	1.4;

1.4
date	99.12.21.23.54.17;	author hobbs;	state Exp;
branches;
next	1.3;

1.3
date	99.04.16.01.51.08;	author stanton;	state Exp;
branches;
next	1.2;

1.2
date	98.09.14.18.22.52;	author stanton;	state Exp;
branches;
next	1.1;

1.1
date	98.04.01.09.40.09;	author rjohnson;	state Exp;
branches
	1.1.4.1;
next	;

1.1.4.1
date	98.09.30.02.16.03;	author stanton;	state Exp;
branches;
next	1.1.4.2;

1.1.4.2
date	98.11.25.04.10.25;	author stanton;	state Exp;
branches;
next	1.1.4.3;

1.1.4.3
date	99.03.30.04.12.54;	author stanton;	state Exp;
branches;
next	;

1.7.2.1
date	2007.11.01.16.37.13;	author dgp;	state Exp;
branches;
next	1.7.2.2;

1.7.2.2
date	2008.02.04.16.07.36;	author dgp;	state Exp;
branches;
next	;


desc
@@


1.10
log
@Minor documentation improvements
@
text
@'\"
'\" Copyright (c) 1996 Sun Microsystems, Inc.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\" 
'\" RCS: @@(#) $Id: MeasureChar.3,v 1.9 2007/12/13 15:23:43 dgp Exp $
'\" 
.so man.macros
.TH Tk_MeasureChars 3 8.1 Tk "Tk Library Procedures"
.BS
.SH NAME
Tk_MeasureChars, Tk_TextWidth, Tk_DrawChars, Tk_UnderlineChars \- routines to measure and display simple single-line strings.
.SH SYNOPSIS
.nf
\fB#include <tk.h>\fR
.sp
int
\fBTk_MeasureChars(\fItkfont, string, numBytes, maxPixels, flags, lengthPtr\fB)\fR
.sp
int
\fBTk_TextWidth(\fItkfont, string, numBytes\fB)\fR
.sp
\fBTk_DrawChars(\fIdisplay, drawable, gc, tkfont, string, numBytes, x, y\fB)\fR
.sp
\fBTk_UnderlineChars(\fIdisplay, drawable, gc, tkfont, string, x, y, firstByte, lastByte\fB)\fR
.sp
.SH ARGUMENTS
.AS "const char" firstChar
.AP Tk_Font tkfont in
Token for font in which text is to be drawn or measured.  Must have been
returned by a previous call to \fBTk_GetFont\fR.
.AP "const char" *string in
Text to be measured or displayed.  Need not be null terminated.  Any
non-printing meta-characters in the string (such as tabs, newlines, and
other control characters) will be measured or displayed in a
platform-dependent manner.  
.AP int numBytes in
The maximum number of bytes to consider when measuring or drawing
\fIstring\fR.  Must be greater than or equal to 0.
.AP int maxPixels in
If \fImaxPixels\fR is >= 0, it specifies the longest permissible
line length in pixels.  Characters from \fIstring\fR are processed only
until this many pixels have been covered.  If \fImaxPixels\fR is < 0, then
the line length is unbounded and the \fIflags\fR argument is ignored.
.AP int flags in
Various flag bits OR-ed together: \fBTK_PARTIAL_OK\fR means include a character
as long as any part of it fits in the length given by \fImaxPixels\fR;
otherwise, a character must fit completely to be considered.
\fBTK_WHOLE_WORDS\fR means stop on a word boundary, if possible.  If
\fBTK_AT_LEAST_ONE\fR is set, it means return at least one character even if no
characters could fit in the length given by \fImaxPixels\fR.  If
\fBTK_AT_LEAST_ONE\fR is set and \fBTK_WHOLE_WORDS\fR is also set, it means that if
not even one word fits on the line, return the first few letters of the
word that did fit; if not even one letter of the word fit, then the first
letter will still be returned.
.AP int *lengthPtr out
Filled with the number of pixels occupied by the number of characters
returned as the result of \fBTk_MeasureChars\fR.
.AP Display *display in
Display on which to draw.
.AP Drawable drawable in
Window or pixmap in which to draw.
.AP GC gc in
Graphics context for drawing characters.  The font selected into this GC 
must be the same as the \fItkfont\fR.
.AP int "x, y" in
Coordinates at which to place the left edge of the baseline when displaying
\fIstring\fR.  
.AP int firstByte in
The index of the first byte of the first character to underline in the
\fIstring\fR.  Underlining begins at the left edge of this character.
.AP int lastByte in
The index of the first byte of the last character up to which the
underline will be drawn.  The character specified by \fIlastByte\fR
will not itself be underlined.
.BE
.SH DESCRIPTION
.PP
These routines are for measuring and displaying simple single-font,
single-line strings.  To measure and display single-font, multi-line,
justified text, refer to the documentation for \fBTk_ComputeTextLayout\fR.
There is no programming interface in the core of Tk that supports
multi-font, multi-line text; support for that behavior must be built on
top of simpler layers.  
Note that the interfaces described here are
byte-oriented not character-oriented, so index values coming from Tcl
scripts need to be converted to byte offsets using the
\fBTcl_UtfAtIndex\fR and related routines.
.PP
A glyph is the displayable picture of a letter, number, or some other
symbol.  Not all character codes in a given font have a glyph.
Characters such as tabs, newlines/returns, and control characters that
have no glyph are measured and displayed by these procedures in a
platform-dependent manner; under X, they are replaced with backslashed
escape sequences, while under Windows and Macintosh hollow or solid boxes
may be substituted.  Refer to the documentation for
\fBTk_ComputeTextLayout\fR for a programming interface that supports the
platform-independent expansion of tab characters into columns and
newlines/returns into multi-line text.  
.PP
\fBTk_MeasureChars\fR is used both to compute the length of a given
string and to compute how many characters from a string fit in a given
amount of space.  The return value is the number of bytes from
\fIstring\fR that fit in the space specified by \fImaxPixels\fR subject to
the conditions described by \fIflags\fR.  If all characters fit, the return
value will be \fInumBytes\fR.  \fI*lengthPtr\fR is filled with the computed
width, in pixels, of the portion of the string that was measured.  For
example, if the return value is 5, then \fI*lengthPtr\fR is filled with the
distance between the left edge of \fIstring\fR[0] and the right edge of
\fIstring\fR[4]. 
.PP
\fBTk_TextWidth\fR is a wrapper function that provides a simpler interface
to the \fBTk_MeasureChars\fR function.  The return value is how much
space in pixels the given \fIstring\fR needs.
.PP 
\fBTk_DrawChars\fR draws the \fIstring\fR at the given location in the
given \fIdrawable\fR.
.PP
\fBTk_UnderlineChars\fR underlines the given range of characters in the
given \fIstring\fR.  It does not draw the characters (which are assumed to
have been displayed previously by \fBTk_DrawChars\fR); it just draws the
underline.  This procedure is used to underline a few characters without
having to construct an underlined font.  To produce natively underlined
text, the appropriate underlined font should be constructed and used. 
.SH "SEE ALSO"
font(n), FontId(3)
.SH KEYWORDS
font, measurement
@


1.9
log
@merge stable branch onto HEAD
@
text
@d7 1
a7 1
'\" RCS: @@(#) $Id: MeasureChar.3,v 1.7.2.1 2007/11/01 16:37:13 dgp Exp $
a23 1
void
a25 1
void
a77 1

d126 2
a127 1

d129 1
a129 1
font
@


1.8
log
@Lots more GOOBE stuff. Now works with 'make html'!
@
text
@d7 1
a7 1
'\" RCS: @@(#) $Id: MeasureChar.3,v 1.7 2005/04/06 21:11:54 dkf Exp $
@


1.7
log
@Purge old and inaccurate .VS/.VE macros.
@
text
@d7 1
a7 1
'\" RCS: @@(#) $Id: MeasureChar.3,v 1.6 2004/09/19 16:05:36 dkf Exp $
d124 1
a124 1
given \fIstring\fR.  It doesn't draw the characters (which are assumed to
@


1.7.2.1
log
@merge updates from HEAD
@
text
@d7 1
a7 1
'\" RCS: @@(#) $Id: MeasureChar.3,v 1.7 2005/04/06 21:11:54 dkf Exp $
d124 1
a124 1
given \fIstring\fR.  It does not draw the characters (which are assumed to
@


1.7.2.2
log
@merge udpates from HEAD
@
text
@d7 1
a7 1
'\" RCS: @@(#) $Id: MeasureChar.3,v 1.9 2007/12/13 15:23:43 dgp Exp $
d24 1
d27 1
d80 1
d129 1
a129 2
.SH "SEE ALSO"
font(n), FontId(3)
d131 1
a131 1
font, measurement
@


1.6
log
@Standardize style of section refs & public symbols. Remove displayed tabs
@
text
@d7 1
a7 1
'\" RCS: @@(#) $Id: MeasureChar.3,v 1.5 2004/08/22 15:43:20 dkf Exp $
a39 1
.VS 8.1
a42 1
.VE 8.1
a71 1
.VS 8.1
a78 1
.VE 8.1
a88 1
.VS 8.1
a92 1
.VE 8.1
@


1.5
log
@More doc fixes from Mikhail Kolesnitchenko. [Patch 1013520]
@
text
@d7 1
a7 1
'\" RCS: @@(#) $Id: MeasureChar.3,v 1.4 1999/12/21 23:54:17 hobbs Exp $
d51 1
a51 1
Various flag bits OR-ed together: TK_PARTIAL_OK means include a character
d54 2
a55 2
TK_WHOLE_WORDS means stop on a word boundary, if possible.  If
TK_AT_LEAST_ONE is set, it means return at least one character even if no
d57 1
a57 1
TK_AT_LEAST_ONE is set and TK_WHOLE_WORDS is also set, it means that if
@


1.4
log
@	* doc/MeasureChar.3: fixed docs for Tk_MeasureChars to reflect code
	* doc/listbox.n: fixed formatting problem
@
text
@d7 1
a7 1
'\" RCS: @@(#) $Id: MeasureChar.3,v 1.3 1999/04/16 01:51:08 stanton Exp $
d88 1
a88 1
single-line, strings.  To measure and display single-font, multi-line,
@


1.3
log
@* Merged 8.1 branch into the main trunk
@
text
@d7 1
a7 1
'\" RCS: @@(#) $Id$
d46 1
a46 1
If \fImaxPixels\fR is greater than 0, it specifies the longest permissible
d48 1
a48 1
until this many pixels have been covered.  If \fImaxPixels\fR is <= 0, then
@


1.2
log
@Replaced SCCS strings, fixed binary files
@
text
@d10 1
a10 1
.TH Tk_MeasureChars 3 "" Tk "Tk Library Procedures"
d19 1
a19 1
\fBTk_MeasureChars(\fItkfont, string, maxChars, maxPixels, flags, lengthPtr\fB)\fR
d22 1
a22 1
\fBTk_TextWidth(\fItkfont, string, numChars\fB)\fR
d25 1
a25 1
\fBTk_DrawChars(\fIdisplay, drawable, gc, tkfont, string, numChars, x, y\fB)\fR
d28 1
a28 1
\fBTk_UnderlineChars(\fIdisplay, drawable, gc, tkfont, string, x, y, firstChar, lastChar\fB)\fR
d40 5
a44 3
.AP int maxChars in
The maximum number of characters to consider when measuring \fIstring\fR.
Must be greater than or equal to 0.
a63 3
.AP int numChars in
The total number of characters to measure or draw from \fIstring\fR.  Must
be greater than or equal to 0.
d74 9
a82 7
.AP int firstChar in
The index of the first character to underline in the \fIstring\fR.  
Underlining begins at the left edge of this character.
.AP int lastChar in
The index of the last character up to which the underline will 
be drawn.  The character specified by \fIlastChar\fR will not itself be
underlined.
d92 7
a98 1
top of simpler layers.
d113 1
a113 1
amount of space.  The return value is the number of characters from
d116 1
a116 1
value will be \fImaxChars\fR.  \fI*lengthPtr\fR is filled with the computed
@


1.1
log
@Initial revision
@
text
@d7 1
a7 1
'\" SCCS: @@(#) MeasureChar.3 1.5 97/06/10 17:33:36
@


1.1.4.1
log
@Merged 8.0.3 changes into 8.1
@
text
@d7 1
a7 1
'\" RCS: @@(#) $Id: MeasureChar.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
@


1.1.4.2
log
@fixed bugs introduced in last menu changes
@
text
@d7 1
a7 1
'\" RCS: @@(#) $Id: MeasureChar.3,v 1.1.4.1 1998/09/30 02:16:03 stanton Exp $
d19 1
a19 1
\fBTk_MeasureChars(\fItkfont, string, numBytes, maxPixels, flags, lengthPtr\fB)\fR
d40 2
a41 2
.AP int numBytes in
The maximum number of bytes to consider when measuring \fIstring\fR.
@


1.1.4.3
log
@* doc/MeasureChar.3:
* doc/TextLayout.3:
* generic/tk.decls:
* generic/tkCanvText.c:
* generic/tkEntry.c:
* generic/tkFont.c:
* generic/tkListbox.c:
* generic/tkMessage.c:
* mac/tkMacFont.c:
* unix/tkUnixButton.c:
* unix/tkUnixFont.c:
* unix/tkUnixMenu.c:
* win/tkWinFont.c:
* win/tkWinMenu.c: Standardized text layout and font interfaces
so they are consistent with respect to byte versus character
oriented indices.  The layout functions all manipulate character
oriented values while the lower level measurement functions all
operate on byte oriented values.  This distinction was not clear
and so the functions were being used improperly in a number of
places.  [Bug: 1053, 747, 749, 1646]

* generic/tk.decls: Eliminated uses of C++ STL types string and
list from declarations.

* generic/tkFont.c: Changes to named fonts were not being
propagated in some cases. [Bug: 1144]
@
text
@d7 1
a7 1
'\" RCS: @@(#) $Id$
d10 1
a10 1
.TH Tk_MeasureChars 3 8.1 Tk "Tk Library Procedures"
d22 1
a22 1
\fBTk_TextWidth(\fItkfont, string, numBytes\fB)\fR
d25 1
a25 1
\fBTk_DrawChars(\fIdisplay, drawable, gc, tkfont, string, numBytes, x, y\fB)\fR
d28 1
a28 1
\fBTk_UnderlineChars(\fIdisplay, drawable, gc, tkfont, string, x, y, firstByte, lastByte\fB)\fR
a39 1
.VS 8.1
d41 2
a42 3
The maximum number of bytes to consider when measuring or drawing
\fIstring\fR.  Must be greater than or equal to 0.
.VE 8.1
d62 3
d75 7
a81 9
.VS 8.1
.AP int firstByte in
The index of the first byte of the first character to underline in the
\fIstring\fR.  Underlining begins at the left edge of this character.
.AP int lastByte in
The index of the first byte of the last character up to which the
underline will be drawn.  The character specified by \fIlastByte\fR
will not itself be underlined.
.VE 8.1
d91 1
a91 7
top of simpler layers.  
.VS 8.1
Note that the interfaces described here are
byte-oriented not character-oriented, so index values coming from Tcl
scripts need to be converted to byte offsets using the
\fBTcl_UtfAtIndex\fR and related routines.
.VE 8.1
d106 1
a106 1
amount of space.  The return value is the number of bytes from
d109 1
a109 1
value will be \fInumBytes\fR.  \fI*lengthPtr\fR is filled with the computed
@


