⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textlayout.3

📁 linux系统下的音频通信
💻 3
字号:
'\"'\" 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.'\" '\" SCCS: @(#) TextLayout.3 1.6 96/12/16 16:48:12'\" .so man.macros.TH Tk_ComputeTextLayout 3 "" Tk "Tk Library Procedures".BS.SH NAMETk_ComputeTextLayout, Tk_FreeTextLayout, Tk_DrawTextLayout, Tk_UnderlineTextLayout, Tk_PointToChar, Tk_CharBbox, Tk_DistanceToTextLayout, Tk_IntersectTextLayout, Tk_TextLayoutToPostscript \- routines to measure and display single-font, multi-line, justified text..SH SYNOPSIS.nf\fB#include <tk.h>\fR.spTk_TextLayout\fBTk_ComputeTextLayout(\fItkfont, string, numChars, wrapLength, justify, flags, widthPtr, heightPtr\fB)\fR.spvoid\fBTk_FreeTextLayout(\fIlayout\fB)\fR.spvoid\fBTk_DrawTextLayout(\fIdisplay, drawable, gc, layout, x, y, firstChar, lastChar\fB)\fR.spvoid\fBTk_UnderlineTextLayout(\fIdisplay, drawable, gc, layout, x, y, underline\fB)\fR.spint\fBTk_PointToChar(\fIlayout, x, y\fB)\fR.spint\fBTk_CharBbox(\fIlayout, index, xPtr, yPtr, widthPtr, heightPtr\fB)\fR.spint\fBTk_DistanceToTextLayout(\fIlayout, x, y\fB)\fR.spint\fBTk_IntersectTextLayout(\fIlayout, x, y, width, height\fB)\fR.spvoid\fBTk_TextLayoutToPostscript(\fIinterp, layout\fB)\fR.SH ARGUMENTS.AS Tk_TextLayout "*xPtr, *yPtr".AP Tk_Font tkfont inFont to use when constructing and displaying a text layout.  The\fItkfont\fR must remain valid for the lifetime of the text layout.  Musthave been returned by a previous call to \fBTk_GetFont\fR..AP "const char" *string inPotentially multi-line string whose dimensions are to be computed andstored in the text layout.  The \fIstring\fR must remain valid for thelifetime of the text layout.  .AP int numChars inThe number of characters to consider from \fIstring\fR.  If\fInumChars\fR is less than 0, then assumes \fIstring\fR is nullterminated and uses \fBstrlen(\fIstring\fB)\fR..AP int wrapLength inLongest permissible line length, in pixels.  Lines in \fIstring\fR willautomatically be broken at word boundaries and wrapped when they reachthis length.  If \fIwrapLength\fR is too small for even a singlecharacter to fit on a line, it will be expanded to allow one character tofit on each line.  If \fIwrapLength\fR is <= 0, there is no automaticwrapping; lines will get as long as they need to be and only wrap if anewline/return character is encountered..AP Tk_Justify justify inHow to justify the lines in a multi-line text layout.  Possible valuesare TK_JUSTIFY_LEFT, TK_JUSTIFY_CENTER, or TK_JUSTIFY_RIGHT.  If the textlayout only occupies a single line, then \fIjustify\fR is irrelevant.  .AP int flags inVarious flag bits OR-ed together.  TK_IGNORE_TABS means that tab charactersshould not be expanded to the next tab stop.  TK_IGNORE_NEWLINES means thatnewline/return characters should not cause a line break.  If either tabs ornewlines/returns are ignored, then they will be treated as regularcharacters, being measured and displayed in a platform-dependent manner asdescribed in \fBTk_MeasureChars\fR, and will not have any special behaviors..AP int *widthPtr outIf non-NULL, filled with either the width, in pixels, of the widestline in the text layout, or the width, in pixels, of the bounding box for the character specified by \fIindex\fR..AP int *heightPtr outIf non-NULL, filled with either the total height, in pixels, of allthe lines in the text layout, or the height, in pixels, of the boundingbox for the character specified by \fIindex\fR..AP Tk_TextLayout layout inA token that represents the cached layout information about the single-font,multi-line, justified piece of text.  This token is returned by\fBTk_ComputeTextLayout\fR..AP Display *display inDisplay on which to draw..AP Drawable drawable inWindow or pixmap in which to draw..AP GC gc inGraphics context to use for drawing text layout.  The font selected inthis GC must correspond to the \fItkfont\fR used when constructing thetext layout..AP int "x, y" inPoint, in pixels, at which to place the upper-left hand corner of thetext layout when it is being drawn, or the coordinates of a point (withrespect to the upper-left hand corner of the text layout) to checkagainst the text layout..AP int firstChar inThe index of the first character to draw from the given text layout.  The number 0 means to draw from the beginning..AP int lastChar inThe index of the last character up to which to draw.  The characterspecified by \fIlastChar\fR itself will not be drawn.  A number lessthan 0 means to draw all characters in the text layout..AP int underline inIndex of the single character to underline in the text layout, or a numberless than 0 for no underline..AP int index inThe index of the character whose bounding box is desired.  The boundingbox is computed with respect to the upper-left hand corner of the text layout..AP int "*xPtr, *yPtr" outFilled with the upper-left hand corner, in pixels, of the bounding boxfor the character specified by \fIindex\fR.  Either or both \fIxPtr\fRand \fIyPtr\fR may be NULL, in which case the corresponding valueis not calculated..AP int "width, height" inSpecifies the width and height, in pixels, of the rectangular area to compare for intersection against the text layout..AP Tcl_Interp *interp outPostscript code that will print the text layout is appended to\fIinterp->result\fR..BE.SH DESCRIPTION.PPThese routines are for measuring and displaying single-font, multi-line,justified text.  To measure and display simple single-font, single-linestrings, refer to the documentation for \fBTk_MeasureChars\fR.  There isno programming interface in the core of Tk that supports multi-font,multi-line text; support for that behavior must be built on top ofsimpler layers..PPThe routines described here are built on top of the programming interfacedescribed in the \fBTk_MeasureChars\fR documentation.  Tab characters andnewline/return characters may be treated specially by these procedures,but all other characters are passed through to the lower level..PP\fBTk_ComputeTextLayout\fR computes the layout information needed todisplay a single-font, multi-line, justified \fIstring\fR of text andreturns a Tk_TextLayout token that holds this information.  This token isused in subsequent calls to procedures such as \fBTk_DrawTextLayout\fR,\fBTk_DistanceToTextLayout\fR, and \fBTk_FreeTextLayout\fR.  The\fIstring\fR and \fItkfont\fR used when computing the layout must remainvalid for the lifetime of this token.  .PP\fBTk_FreeTextLayout\fR is called to release the storage associated with\fIlayout\fR when it is no longer needed.  A \fIlayout\fR should not be usedin any other text layout procedures once it has been released. .PP\fBTk_DrawTextLayout\fR uses the information in \fIlayout\fR to display asingle-font, multi-line, justified string of text at the specified location..PP\fBTk_UnderlineTextLayout\fR uses the information in \fIlayout\fR todisplay an underline below an individual character.  This procedure doesnot draw the text, just the underline.  To produce natively underlinedtext, an underlined font should be constructed and used.  All characters,including tabs, newline/return characters, and spaces at the ends oflines, can be underlined using this method.  However, the underline willnever be drawn outside of the computed width of \fIlayout\fR; theunderline will stop at the edge for any character that would extendpartially outside of \fIlayout\fR, and the underline will not be visibleat all for any character that would be located completely outside of thelayout..PP\fBTk_PointToChar\fR uses the information in \fIlayout\fR to determine thecharacter closest to the given point.  The point is specified with respectto the upper-left hand corner of the \fIlayout\fR, which is considered to belocated at (0, 0).  Any point whose \fIy\fR-value is less that 0 will beconsidered closest to the first character in the text layout; any pointwhose \fIy\fR-value is greater than the height of the text layout will beconsidered closest to the last character in the text layout.  Any pointwhose \fIx\fR-value is less than 0 will be considered closest to the firstcharacter on that line; any point whose \fIx\fR-value is greater than thewidth of the text layout will be considered closest to the last character onthat line.  The return value is the index of the character that was closestto the point.  Given a \fIlayout\fR with no characters, the value 0 willalways be returned, referring to a hypothetical zero-width placeholdercharacter.  .PP\fBTk_CharBBox\fR uses the information in \fIlayout\fR to return thebounding box for the character specified by \fIindex\fR.  The width of thebounding box is the advance width of the character, and does not include anyleft or right bearing.  Any character that extends partially outside of \fIlayout\fR is considered to be truncated at the edge.  Any characterthat would be located completely outside of \fIlayout\fR is considered tobe zero-width and pegged against the edge.  The height of the boundingbox is the line height for this font, extending from the top of theascent to the bottom of the descent; information about the actual heightof individual letters is not available.  For measurement purposes, a\fIlayout\fR that contains no characters is considered to contain asingle zero-width placeholder character at index 0.  If \fIindex\fR wasnot a valid character index, the return value is 0 and \fI*xPtr\fR,\fI*yPtr\fR, \fI*widthPtr\fR, and \fI*heightPtr\fR are unmodified.Otherwise, if \fIindex\fR did specify a valid, the return value isnon-zero, and \fI*xPtr\fR, \fI*yPtr\fR, \fI*widthPtr\fR, and\fI*heightPtr\fR are filled with the bounding box information for thecharacter.  If any of \fIxPtr\fR, \fIyPtr\fR, \fIwidthPtr\fR, or\fIheightPtr\fR are NULL, the corresponding value is not calculated orstored..PP\fBTk_DistanceToTextLayout\fR computes the shortest distance in pixels fromthe given point (\fIx, y\fR) to the characters in \fIlayout\fR.Newline/return characters and non-displaying space characters that occur atthe end of individual lines in the text layout are ignored for hit detectionpurposes, but tab characters are not.  The return value is 0 if the pointactually hits the \fIlayout\fR.  If the point didn't hit the \fIlayout\fRthen the return value is the distance in pixels from the point to the\fIlayout\fR..PP\fBTk_IntersectTextLayout\fR determines whether a \fIlayout\fR liesentirely inside, entirely outside, or overlaps a given rectangle.Newline/return characters and non-displaying space characters that occurat the end of individual lines in the \fIlayout\fR are ignored forintersection calculations.  The return value is \-1 if the \fIlayout\fR isentirely outside of the rectangle, 0 if it overlaps, and 1 if it isentirely inside of the rectangle..PP\fBTk_TextLayoutToPostscript\fR outputs code consisting of a Postscriptarray of strings that represent the individual lines in \fIlayout\fR.  Itis the responsibility of the caller to take the Postscript array ofstrings and add some Postscript function operate on the array to rendereach of the lines.  The code that represents the Postscript array ofstrings is appended to \fIinterp->result\fR..PP.SH DISPLAY MODELWhen measuring a text layout, space characters that occur at the end of aline are ignored.  The space characters still exist and the insertion pointcan be positioned amongst them, but their additional width is ignored whenjustifying lines or returning the total width of a text layout.  Allend-of-line space characters are considered to be attached to the right edgeof the line; this behavior is logical for left-justified text and reasonablefor center-justified text, but not very useful when editing right-justifiedtext.  Spaces are considered variable width characters; the first space thatextends past the edge of the text layout is clipped to the edge, and anysubsequent spaces on the line are considered zero width and pegged againstthe edge.  Space characters that occur in the middle of a line of text arenot suppressed and occupy their normal space width..PPTab characters are not ignored for measurement calculations.  If wrappingis turned on and there are enough tabs on a line, the next tab will wrapto the beginning of the next line.  There are some possible strangeinteractions between tabs and justification; tab positions are calculatedand the line length computed in a left-justified world, and then thewhole resulting line is shifted so it is centered or right-justified,causing the tab columns not to align any more..PPWhen wrapping is turned on, lines may wrap at word breaks (space or tabcharacters) or newline/returns.  A dash or hyphen character in the middleof a word is not considered a word break.  \fBTk_ComputeTextLayout\fRalways attempts to place at least one word on each line.  If it cannotbecause the \fIwrapLength\fR is too small, the word will be broken and asmuch as fits placed on the line and the rest on subsequent line(s).  If\fIwrapLength\fR is so small that not even one character can fit on agiven line, the \fIwrapLength\fR is ignored for that line and onecharacter will be placed on the line anyhow.  When wrapping is turnedoff, only newline/return characters may cause a line break.  .PPWhen a text layout has been created using an underlined \fItkfont\fR,then any space characters that occur at the end of individual lines,newlines/returns, and tabs will not be displayed underlined when \fBTk_DrawTextLayout\fR is called, because those characters are neveractually drawn \- they are merely placeholders maintained in the\fIlayout\fR.  .SH KEYWORDSfont

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -