Virtual Treeview - Paint cycles and stages

The most complex process in Virtual Treeview is without doubts its painting.

Read here what stages Virtual Treeview enters during paint and how you can customize this process.

Description

Similar to the system tree view Virtual Treeview defines so called paint cycles.

A paint cycle is one run of the paint code which draws a part or the entire window.

In Virtual Treeview this task is accomplished by the method PaintTree

which centralizes the paint management into one place and is called

for various tasks like window painting, drag image painting, WM_PRINTCLIENT handling and so on.

This paint method is able to draw the entire tree regardless of its window to the target canvas

and optimizes painting by considering the update/clipping rectangle,

which is passed in via the Window parameter (see also PaintTree).

Usually the following paint stages are executed during a paint cycle:

--> (OnBeforePaint)
    --> (OnBeforeItemPaint)
      --> (OnBeforeItemErase)
      --> (OnAfterItemErase)
      --> (OnBeforeCellPaint)
        --> (OnPaintText)
      --> (OnAfterCellPaint)
    --> (OnAfterItemPaint)
--> (OnAfterPaint) 

The cell and node events are of course not executed if there is no node to be drawn.

A special flag (tsPainting) in TreeStates indicates when a paint cycle is in progress.

Using this flag an application can for instance determine whether a node is initialized

because it is about to be drawn or for other reasons.

Every of the stages above is accompanied by a specific event

which allows the application to customize a particular aspect in the painting.

The following list discusses tasks which can be done during the various stages.

before paint

This stage is entered only once per paint cycle.
After setting the vsPainting state it is the very first instruction in a cycle.

This stage is typically used to do any further setup of the target canvas of the paint operation
(e.g. the window or a printer canvas), like changing the mapping mode or setting another clipping region.
Since the passed canvas is not directly used to do the actual painting setting its font or colors has no effect.
Basically only properties which affect blitting a bitmap to the target canvas have an effect at all.

before item paint

This stage is entered once per node to be drawn and allows directly
to control the path which is the taken to paint the node.

In the event for this stage you can tell the tree whether you want
to paint the node entirely on your own or let the tree paint it.
As this happens on a per node basis it is the perfect place
to maintain a special layout without doing everything in the paint cycle.
Note:
setting the CustomDraw parameter in the event to True will skip the node entirely,
without painting anything of the standard things like tree lines, button,
images or erasing the background.
Hence to display any useful information for the node do it in the OnBeforeItemPaint event.

This is the first stage which gets the double buffer canvas which is used to draw a node
so if you want to set special properties this is a good opportunity.
Keep in mind though that in particular the colors are
set by the tree according to specific rules (focus, selection etc.).

before item erase

This stage is also entered only once per node and allows to customize the node‘s background.

This stage and its associated event is usually used to give the node a different background color
or erase the background with a special pattern which is different to what the tree would draw.

after item erase

This stage is also entered only once per node.

This stage and its associated event is used
to do additional drawings after the background has been erased.

before cell paint

This paint stage is the first of the cell specific stages used to customize a single cell of a node and
is called several times per node, depending on the number of columns.

If no columns are used then it is called once.

While internally a full setup for this node happened
before the stage is entered (if it is the first run) the only noticeable effect
for the application which has changed compared to after item erase is that
the painting is limited to the current column.
There are still no lines or images painted yet.

on paint text

After default stuff like lines and images has been painted the paint node/paint text stage is entered.

Because Virtual Treeview does not know how to draw the content of a node
it delegates this drawing to a virtual method called DoPaintNode.
Descendants override this method and do whatever is appropriate.
For instance TVirtualDrawTree simply triggers its OnDrawNode event
while the TVirtualStringTree prepares the target canvas and
allows the application to override some or all canvas settings (font etc.)
by triggering OnPaintText.

After this event returned the text/caption of the node is drawn.
Changed font properties are taken into account when aligning and painting the text.

Note: The string tree triggers the OnGetText event two times
if toShowStaticText is enabled in the TVirtualStringTree.TreeOptions.StringOptions property.
Once for the normal text and once for the static text.
Use the event‘s parameter to find out what is required.

after cell paint

This stage is entered immediately after the cell is drawn.

This stage can be used to add whatever you like to a single cell
after everything has been painted there and is triggered once per column.

after item paint

This stage is entered after all cells of an item are drawn.

The after item paint stage is used to add node specific stuff like frames
and the like which concern all columns of that node and is called once per node.

after paint

The after paint stage is the last stage in the long chain of paint stages
and is entered after when paint cycle is complete.

In this stage everything of the tree (related to the current update area) has been drawn,
including the selection rectangle.

时间: 2024-10-11 05:18:08

Virtual Treeview - Paint cycles and stages的相关文章

Virtual Treeview使用要点

Virtual Treeview是一套Delphi下优秀的VCL控件,代码质量高,使用灵活.功能强大.性能非常好,可以用于表达Treeview和表格类数据.它的代码现在托管在google code上. 这套控件使用了很久了,非常满意其表现,之前一直使用V4版,现在V5正式发布了,新版花了几年时间进行重构, 代码结构更加合理,去除了老版大量的小缺陷,很多功能进行了重新设计,参与维护的人也更多了. Virtual Treeview的设计思路与官方的Treeview完全不一样,VT是基于高性能和更丰富

Hypervisor, computer system, and virtual processor scheduling method

A?hypervisor?calculates the total number of processor cycles (the number of processor cycles of one or more physical processors) in a first length of time based on the sum of the operating frequencies of the respective physical processors and the fir

broswer

Web browsers are probably the most widely used software. In this book I will explain how they work behind the scenes. We will see what happens when you type 'google.com' in the address bar until you see the Google page on the browser screen. The brow

现代浏览器的工作原理

浏览器的主要组件包括: 用户界面- 包括地址栏.后退/前进按钮.书签目录等,也就是你所看到的除了用来显示你所请求页面的主窗口之外的其他部分 浏览器引擎- 用来查询及操作渲染引擎的接口 渲染引擎- 用来显示请求的内容,例如,如果请求内容为html,它负责解析html及css,并将解析后的结果显示出来 网络- 用来完成网络调用,例如http请求,它具有平台无关的接口,可以在不同平台上工作 UI 后端- 用来绘制类似组合选择框及对话框等基本组件,具有不特定于某个平台的通用接口,底层使用操作系统的用户接

[转载]浏览器的工作原理:新式网络浏览器幕后揭秘

原文地址 序言 这是一篇全面介绍 WebKit 和 Gecko 内部操作的入门文章,是以色列开发人员塔利·加希尔大量研究的成果.在过去的几年中,她查阅了所有公开发布的关于浏览器内部机制的数据(请参见资源),并花了很多时间来研读网络浏览器的源代码.她写道: 在 IE 占据 90% 市场份额的年代,我们除了把浏览器当成一个"黑箱",什么也做不了.但是现在,开放源代码的浏览器拥有了过半的市场份额,因此,是时候来揭开神秘的面纱,一探网络浏览器的内幕了.呃,里面只有数以百万行计的 C++ 代码.

render tree与css解析

浏览器在构造DOM树的同时也在构造着另一棵树-Render Tree,与DOM树相对应暂且叫它Render树吧,我们知道DOM树为javascript提供了一些列的访问接口(DOM API),但这棵树是不对外的.它的主要作用就是把HTML按照一定的布局与样式显示出来,用到了CSS的相关知识.从MVC的角度来说,可以将render树看成是V,dom树看成是M,C则是具体的调度者,比HTMLDocumentParser等. 新概念Render树 每一个Render树的节点称之为renderer或者r

(转载)How browsers work--Behind the scenes of modern web browsers (前端必读)

浏览器可以被认为是使用最广泛的软件,本文将介绍浏览器的工 作原理,我们将看到,从你在地址栏输入google.com到你看到google主页过程中都发生了什么. 将讨论的浏览器 今天,有五种主流浏览器——IE.Firefox.Safari.Chrome及Opera. 本文将基于一些开源浏览器的例子——Firefox. Chrome及Safari,Safari是部分开源的. 根据W3C(World Wide Web Consortium 万维网联盟)的浏览器统计数据,当前(2011年5月),Fire

前端必读:浏览器内部工作原理

前端必读:浏览器内部工作原理 作者: Tali Garsiel  发布时间: 2012-02-09 14:32  阅读: 56974 次  推荐: 88   原文链接   [收藏] 目录 一.介绍 二.渲染引擎 三.解析与DOM树构建 四.渲染树构建 五.布局 六.绘制 七.动态变化 八.渲染引擎的线程 九.CSS2可视模型 英文原文:How Browsers Work: Behind the Scenes of Modern Web Browsers 一.介绍 浏览器可以被认为是使用最广泛的软

C/C++技术常用网站

软件下载网站[visual studio 2005编译器] http://www.xdowns.com/ debug调试大牛 http://blogs.msdn.com/oldnewthing/ http://blogs.msdn.com/lixiong/ 绝版图书淘宝站: http://shop59563940.taobao.com/ www.vckbase.com www.codeproject.com http://www.acejoy.com --- ace 网站 http://www.