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.

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

  1. Virtual Treeview 安装以及入门

    Virtual Treeview是一套Delphi下优秀的VCL控件,代码质量高,使用灵活.功能强大.性能非常好,可以用于表达Treeview和表格类数据.它的代码现在托管在google code上. ...

  2. Hypervisor, computer system, and virtual processor scheduling method

    A hypervisor calculates the total number of processor cycles (the number of processor cycles of one ...

  3. Winform组合ComboBox和TreeView实现ComboTree

    最近做Winform项目需要用到类似ComboBox的TreeView控件. 虽然各种第三方控件很多,但是存在各种版本不兼容问题.所以自己写了个简单的ComboTreeView控件. 下图是实现效果: ...

  4. 什么是virtual string tree?

    Virtual stringtree(以后简称VST)是一个提供源码的免费的第三方插件,支持DELPHI和C++builder,可在http://www.soft-gems.net/下载到最新的版本. ...

  5. 浏览器内部工作原理--作者:Tali Garsiel

    本篇内容为转载,主要用于个人学习使用,作者:Tali Garsiel 一.介绍 浏览器可以被认为是使用最广泛的软件,本文将介绍浏览器的工作原理,我们将看到,从你在地址栏输入google.com到你看到 ...

  6. C/C++技术常用网站

    软件下载网站[visual studio 2005编译器] http://www.xdowns.com/ debug调试大牛 http://blogs.msdn.com/oldnewthing/ ht ...

  7. How browsers work

    这几天翻译一篇旧文 How browsers work ( 以现代浏览器chrome.火狐.safari 为对象来分析),这篇文章网上有其他的翻译版本,自己再翻译一遍主要是练习阅读英文文章,而且自己翻 ...

  8. C#接口知识大全收藏

    第一节 接口慨述 接口(interface)用来定义一种程序的协定.实现接口的类或者结构要与接口的定义严格一致.有了这个协定,就可以抛开编程语言的限制(理论上).接口可以从多个基接口继承,而类或结构可 ...

  9. QTableView使用自定义委托(QItemDelegate)

    需要在表格中绘制流程图,主要有箭头,方向,颜色,字符串,由于QTableView没有可用的绘制函数,所以需要自己去定义. 委托(delegate)继承QItemDelegate,模型(model)继承 ...

随机推荐

  1. openjudge-NOI 2.6基本算法之动态规划 专题题解目录

    1.1759 最长上升子序列 2.1768 最大子矩阵 3.1775 采药 4.1808 公共子序列 5.1944 吃糖果 6.1996 登山 7.2000 最长公共子上升序列 8.2718 移动路线 ...

  2. c++环境配置 Eclipse+mingw-get-setup

    1,到官网下载eclipse  和  mingw-get-setup 2,先安装eclipse,然后等着... 3,再安装mingw-get-setup, 等待...安装完成后打开,选择basic s ...

  3. 升级vs17中的cordova-simulate

    visual studio 17自带的cordova-simulate有一个bug,动态添加的html代码里面如果带有header,会出现js异常导致后面js程序终止执行,这个问题已经给他们提了iss ...

  4. python3.6升级及setuptools、pip安装

    升级python3.6 1.打开官网www.python.org,找到最新3.6.3版本,复制下载链接 2.创建/app目录,wget下载到该目录下,编译安装 mkdir /app cd /app w ...

  5. PlantUML——2.中文乱码及解决

    关于中文 参见: http://plantuml.sourceforge.net/unicode.html   问题描述 第一步:创建demo03.txt描述文档: @startuml Alice - ...

  6. 深度学习方法(十二):卷积神经网络结构变化——Spatial Transformer Networks

    欢迎转载,转载请注明:本文出自Bin的专栏blog.csdn.net/xbinworld. 技术交流QQ群:433250724,欢迎对算法.机器学习技术感兴趣的同学加入. 今天具体介绍一个Google ...

  7. 远程连接 mysql 数据库连接不上的解决方案

    今天用Navicat访问虚拟机上的mysql,无法访问报cannot connect(10038). 首先看是否可以telnet,本机cmd,telnet 10.10.10.10 3306,结果是连接 ...

  8. Yii2使用驼峰命名的形式访问控制器

    yii2在使用的时候,访问控制器的时候,如果控制器的名称是驼峰命名法,那访问的url中要改成横线的形式.例如: public function actionRoomUpdate() { // }//访 ...

  9. day1作业一:编写登陆接口

    作业一:编写登陆接口 1.输入用户名和密码 2.认证成功后显示欢迎信息 3.输错三次后锁定 Readme: (1)提示用户输入用户名: (2)用户名验证,验证是否已经锁定: (3)是否锁定:已锁定告诉 ...

  10. phantomjs2.1 初体验

    上次看了一下scrapy1.1的新手指南 决定写个小爬虫实验一下 目标网站是http://www.dm5.com/manhua-huofengliaoyuan准备爬取漫画火凤燎原的已有章节,将图片保存 ...