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
2:创建windows结束后,开始寻找windows的属性,delegate,子对象等.
我们的重点在子对象上面.
到了下面的代码

newComponent = createNewComponent(NULL,VFFInputStream::ufCreateComponent);
进行了子对象的创建.
3:进行Component and Container的关联
addNewComponent函数进行上述关联.
展开后:
这里面Container里面controls_对象保存了所有的控件.
注意child->setParent( controlContainer_ );这一句.里面设置了关于component的关联
parent->addComponent( this );具体实现了这个功能.
刷新:
我们看看windows的paint,如果一直跟,就会到
AbstractContainer::paintChildren( GraphicsContext* context),这里面就做了将所有的control刷新的机制…所以windows只要paint,其子控件会自动刷新.
内存释放:
我们刚才通过父component add 了子component.
看了堆栈.很清楚.释放是通过component来代理释放的.
相关代码: