/*
* tkTextDisp.c --
*
* This module provides facilities to display text widgets. It is the
* only place where information is kept about the screen layout of text
* widgets. (Well, strictly, each TkTextLine and B-tree node caches its
* last observed pixel height, but that information originates here).
*
* Copyright (c) 1992-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 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: tkTextDisp.c,v 1.68.2.1 2009/08/04 21:46:03 dkf Exp $
*/
#include "tkInt.h"
#include "tkText.h"
#ifdef __WIN32__
#include "tkWinInt.h"
#endif
#ifdef MAC_OSX_TK
#include "tkMacOSXInt.h"
#endif
/*
* "Calculations of line pixel heights and the size of the vertical
* scrollbar."
*
* Given that tag, font and elide changes can happen to large numbers of
* diverse chunks in a text widget containing megabytes of text, it is not
* possible to recalculate all affected height information immediately any
* such change takes place and maintain a responsive user-experience. Yet, for
* an accurate vertical scrollbar to be drawn, we must know the total number
* of vertical pixels shown on display versus the number available to be
* displayed.
*
* The way the text widget solves this problem is by maintaining cached line
* pixel heights (in the BTree for each logical line), and having asynchronous
* timer callbacks (i) to iterate through the logical lines recalculating
* their heights, and (ii) to recalculate the vertical scrollbar's position
* and size.
*
* Typically this works well but there are some situations where the overall
* functional design of this file causes some problems. These problems can
* only arise because the calculations used to display lines on screen are not
* connected to those in the iterating-line- recalculation-process.
*
* The reason for this disconnect is that the display calculations operate in
* display lines, and the iteration and cache operates in logical lines.
* Given that the display calculations both need not contain complete logical
* lines (at top or bottom of display), and that they do not actually keep
* track of logical lines (for simplicity of code and historical design), this
* means a line may be known and drawn with a different pixel height to that
* which is cached in the BTree, and this might cause some temporary
* undesirable mismatch between display and the vertical scrollbar.
*
* All such mismatches should be temporary, however, since the asynchronous
* height calculations will always catch up eventually.
*
* For further details see the comments before and within the following
* functions below: LayoutDLine, AsyncUpdateLineMetrics, GetYView,
* GetYPixelCount, TkTextUpdateOneLine, TkTextUpdateLineMetrics.
*
* For details of the way in which the BTree keeps track of pixel heights, see
* tkTextBTree.c. Basically the BTree maintains two pieces of information: the
* logical line indices and the pixel height cache.
*/
/*
* TK_LAYOUT_WITH_BASE_CHUNKS:
*
* With this macro set, collect all char chunks that have no holes
* between them, that are on the same line and use the same font and font
* size. Allocate the chars of all these chunks, the so-called "stretch",
* in a DString in the first chunk, the so-called "base chunk". Use the
* base chunk string for measuring and drawing, so that these actions are
* always performed with maximum context.
*
* This is necessary for text rendering engines that provide ligatures
* and sub-pixel layout, like ATSU on Mac. If we don't do this, the
* measuring will change all the time, leading to an ugly "tremble and
* shiver" effect. This is because of the continuous splitting and
* re-merging of chunks that goes on in a text widget, when the cursor or
* the selection move.
*
* Side effects:
*
* Memory management changes. Instead of attaching the character data to
* the clientData structures of the char chunks, an additional DString is
* used. The collection process will even lead to resizing this DString
* for large stretches (> TCL_DSTRING_STATIC_SIZE == 200). We could
* reduce the overall memory footprint by copying the result to a plain
* char array after the line breaking process, but that would complicate
* the code and make performance even worse speedwise. See also TODOs.
*
* TODOs:
*
* - Move the character collection process from the LayoutProc into
* LayoutDLine(), so that the collection can be done before actual
* layout. In this way measuring can look at the following text, too,
* right from the beginning. Memory handling can also be improved with
* this. Problem: We don't easily know which chunks are adjacent until
* all the other chunks have calculated their width. Apparently marks
* would return width==0. A separate char collection loop would have to
* know these things.
*
* - Use a new context parameter to pass the context from LayoutDLine() to
* the LayoutProc instead of using a global variable like now. Not
* pressing until the previous point gets implemented.
*/
/*
* The following structure describes how to display a range of characters.
* The information is generated by scanning all of the tags associated with
* the characters and combining that with default information for the overall
* widget. These structures form the hash keys for dInfoPtr->styleTable.
*/
typedef struct StyleValues {
Tk_3DBorder border; /* Used for drawing background under text.
* NULL means use widget background. */
int borderWidth; /* Width of 3-D border for background. */
int relief; /* 3-D relief for background. */
Pixmap bgStipple; /* Stipple bitmap for background. None means
* draw solid. */
XColor *fgColor; /* Foreground color for text. */
Tk_Font tkfont; /* Font for displaying text. */
Pixmap fgStipple; /* Stipple bitmap for text and other
* foreground stuff. None means draw solid.*/
int justify; /* Justification style for text. */
int lMargin1; /* Left margin, in pixels, for first display
* line of each text line. */
int lMargin2; /* Left margin, in pixels, for second and
* later display lines of each text line. */
int offset; /* Offset in pixels of baseline, relative to
* baseline of line. */
int overstrike; /* Non-zero means draw overstrike through
* text. */
int rMargin; /* Right margin, in pixels. */
int spacing1; /* Spacing above first dline in text line. */
int spacing2; /* Spacing between lines of dline. */
int spacing3; /* Spacing below last dline in text line. */
TkTextTabArray *tabArrayPtr;/* Locations and types of tab stops (may be
* NULL). */
int tabStyle; /* One of TABULAR or WORDPROCESSOR. */
int underline; /* Non-zero means draw underline underneath
* text. */
int elide; /* Zero means draw text, otherwise not. */
TkWrapMode wrapMode; /* How to handle wrap-around for this tag.
* One of TEXT_WRAPMODE_CHAR,
* TEXT_WRAPMODE_NONE or TEXT_WRAPMODE_WORD.*/
} StyleValues;
/*
* The following structure extends the StyleValues structure above with
* graphics contexts used to actually draw the characters. The entries in
* dInfoPtr->styleTable point to structures of this type.
*/
typedef struct TextStyle {
int refCount; /* Number of times this structure is
* referenced in Chunks. */
GC bgGC; /* Graphics context for background. None means
* use widget background. */
GC fgGC; /* Graphics context for foreground. */
StyleValues *sValuePtr; /* Raw information from which GCs were
* derived. */
Tcl_HashEntry *hPtr; /* Pointer to entry in styleTable. Used to
* delete entry. */
} TextStyle;
/*
* The following macro determines whether two styles have the same background
* so that, for example, no beveled border
没有合适的资源?快使用搜索试试~ 我知道了~
tk8.5.8-src.tar.gz
5星 · 超过95%的资源 需积分: 10 37 下载量 13 浏览量
2011-08-19
15:03:36
上传
评论
收藏 3.61MB GZ 举报
温馨提示
共878个文件
c:201个
tcl:122个
test:101个
tk8.5.8-src.tar.gz适应于unix系统安装使用!
资源推荐
资源详情
资源评论
收起资源包目录
tk8.5.8-src.tar.gz (878个子文件)
wish.1 9KB
ChangeLog.2002 270KB
ChangeLog.2004 131KB
SetOptions.3 32KB
ConfigWidg.3 28KB
CrtItemType.3 24KB
ParseArgv.3 14KB
TextLayout.3 14KB
3DBorder.3 13KB
CrtPhImgFmt.3 12KB
CrtImgType.3 11KB
FindPhoto.3 11KB
GetCursor.3 10KB
GetBitmap.3 10KB
ttk_Geometry.3 8KB
GetColor.3 7KB
BindTable.3 7KB
CanvTkwin.3 6KB
CrtWindow.3 6KB
CrtErrHdlr.3 6KB
ConfigWind.3 6KB
WindowId.3 6KB
MeasureChar.3 6KB
CrtSelHdlr.3 5KB
GetImage.3 5KB
CanvPsY.3 5KB
GetFont.3 4KB
CanvTxtInfo.3 4KB
GeomReq.3 4KB
MaintGeom.3 4KB
GetVisual.3 4KB
RestrictEv.3 3KB
FontId.3 3KB
ManageGeom.3 3KB
GetPixels.3 3KB
CrtGenHdlr.3 3KB
SetClassProcs.3 3KB
Name.3 3KB
GetJustify.3 3KB
GetClrmap.3 3KB
GetSelect.3 3KB
GetAnchor.3 3KB
Clipboard.3 3KB
EventHndlr.3 3KB
GetRelief.3 3KB
TkInitStubs.3 3KB
GetScroll.3 3KB
GetGC.3 3KB
CrtCmHdlr.3 3KB
Tk_Init.3 3KB
GetDash.3 3KB
ImgChanged.3 2KB
Grab.3 2KB
SetGrid.3 2KB
SetAppName.3 2KB
Tk_Main.3 2KB
MoveToplev.3 2KB
SetClass.3 2KB
GetJoinStl.3 2KB
GetCapStyl.3 2KB
InternAtom.3 2KB
FreeXId.3 2KB
QWinEvent.3 2KB
OwnSelect.3 2KB
GetVRoot.3 2KB
SetVisual.3 2KB
GetPixmap.3 2KB
CoordToWin.3 2KB
MapWindow.3 2KB
AddOption.3 2KB
HandleEvent.3 2KB
Restack.3 2KB
GetUid.3 2KB
CrtConsoleChan.3 2KB
GetOption.3 1KB
GetRootCrd.3 1KB
MainWin.3 1KB
ClrSelect.3 1KB
StrictMotif.3 1KB
DrawFocHlt.3 1KB
Inactive.3 1KB
SetCaret.3 1KB
ttk_Theme.3 1KB
MainLoop.3 994B
GetHWND.3 924B
DeleteImg.3 921B
IdToWindow.3 898B
NameOfImg.3 880B
HWNDToWindow.3 704B
GetHINSTANCE.3 595B
configure.ac 498B
buildall.vc.bat 4KB
rmd.bat 340B
mkd.bat 186B
makefile.bc 17KB
lamp.bmp 2KB
buttons.bmp 846B
browse 2KB
tkTextDisp.c 251KB
tkWinWm.c 231KB
共 878 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
zhanjack
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- C语言基础-C语言编程基础之Leetcode编程题解之第39题组合总和.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第38题外观数列.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第37题解数独.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第36题有效的数独.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第35题搜索插入位置.zip
- index.wxml
- C语言基础-C语言编程基础之Leetcode编程题解之第33题搜索旋转排序数组.zip
- 基于Python实现的手写数字识别系统源码.zip
- 从网页提取禁止转载的文字
- C语言基础-C语言编程基础之Leetcode编程题解之第32题最长有效括号.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页