VCF Component and Container

VCF Component and Container

 

以一个配置档为例子

object AcfWindow : AcfWindow, 'ED88CRA1-26AB-11d4-B539-00C04F0196DA'

    top    = 0

    left   = 0

    height = 320

    width  = 240

    object exitButton : VCF::BitmapButton

        left   = 10

        top    = 10

        width  = 50

        height  = 30

                   caption  = 'exit'

        delegates

            ButtonClicked = [AcfWindow@AcfWindow::exit]

        end

    end

end

 

AcfWindow窗口里面创建了一个exitButton,与函数exit进行了ButtonClicked delegate绑定.

 

那么关于配置内存方面和刷新方面是怎么管理的呢?

exitButton内存谁来释放. exitButton谁负责刷新( BitmapButton是自己实现的一个lightweight的控件,所以和窗体共享一个句柄)

 

看代码.

1:首先创建windows窗口.由于是第一个创建标志为VFFInputStream::ufCreateComponent

1

2:创建windows结束后,开始寻找windows的属性,delegate,子对象等.

我们的重点在子对象上面.

到了下面的代码

 

 

2

 

 

 

newComponent = createNewComponent(NULL,VFFInputStream::ufCreateComponent);

进行了子对象的创建.

 

3:进行Component and Container的关联

 

3

 

 

 

addNewComponent函数进行上述关联.

展开后:

4

 

 

 

这里面Container里面controls_对象保存了所有的控件.

注意child->setParent( controlContainer_ );这一句.里面设置了关于component的关联

5

 

 

parent->addComponent( this );具体实现了这个功能.

 

 

刷新:

我们看看windowspaint,如果一直跟,就会到

AbstractContainer::paintChildren( GraphicsContext* context),这里面就做了将所有的control刷新的机制所以windows只要paint,其子控件会自动刷新.

 

内存释放:

我们刚才通过父component add 了子component.

6

 

 

看了堆栈.很清楚.释放是通过component来代理释放的.

相关代码:

 

 

7

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值