[Effective WX] 理解wxWindow与wxSizer的关系
2012-08-15 10:07
155 查看
wxWindow与wxSizer
每个wxWindow都有一个m_contaningSizer(包含这个wxWindow窗口),还有一个m_windowSizer(这个窗口所包含的顶层wxSizer)。
设置包含这个window的sizer
设置这个窗口包含的顶层sizer
窗口的Layout函数
layout这个窗口时,如果存在顶层sizer,就会调用这个sizer的Layout(in SetDimension函数中)。
window的virtual size是client sizer和virtual Size变量的较大值。一般的window都是client size和virtual size变量一样大,除了scroll window类似的窗口。
每个wxWindow都有一个m_contaningSizer(包含这个wxWindow窗口),还有一个m_windowSizer(这个窗口所包含的顶层wxSizer)。
设置包含这个window的sizer
void wxWindowBase::SetContainingSizer(wxSizer* sizer) { // adding a window to a sizer twice is going to result in fatal and // hard to debug problems later because when deleting the second // associated wxSizerItem we're going to dereference a dangling // pointer; so try to detect this as early as possible wxASSERT_MSG( !sizer || m_containingSizer != sizer, _T("Adding a window to the same sizer twice?") ); m_containingSizer = sizer; }
设置这个窗口包含的顶层sizer
void wxWindowBase::SetSizer(wxSizer *sizer, bool deleteOld) { if ( sizer == m_windowSizer) return;</em> if ( m_windowSizer ) { m_windowSizer->SetContainingWindow(NULL); if ( deleteOld ) delete m_windowSizer; } m_windowSizer = sizer; if ( m_windowSizer ) { m_windowSizer->SetContainingWindow((wxWindow *)this); } SetAutoLayout(m_windowSizer != NULL); }
窗口的Layout函数
layout这个窗口时,如果存在顶层sizer,就会调用这个sizer的Layout(in SetDimension函数中)。
bool wxWindowBase::Layout() { // If there is a sizer, use it instead of the constraints if ( GetSizer() ) { int w = 0, h = 0; GetVirtualSize(&w, &h); GetSizer()->SetDimension( 0, 0, w, h ); } #if wxUSE_CONSTRAINTS else { SatisfyConstraints(); // Find the right constraints values SetConstraintSizes(); // Recursively set the real window sizes } #endif return true; }
window的virtual size是client sizer和virtual Size变量的较大值。一般的window都是client size和virtual size变量一样大,除了scroll window类似的窗口。
wxSize wxWindowBase::DoGetVirtualSize() const { // we should use the entire client area so if it is greater than our // virtual size, expand it to fit (otherwise if the window is big enough we // wouldn't be using parts of it) wxSize size = GetClientSize(); if ( m_virtualSize.x > size.x ) size.x = m_virtualSize.x; if ( m_virtualSize.y >= size.y ) size.y = m_virtualSize.y; return size; }
相关文章推荐
- [Effective WX] 理解wxWindow中增加和去除/销毁子窗口的过程
- [Effective WX] 理解wxWidget中wxGrid相关类的关系
- [Effective WX] 理解wxWindow中的各种size
- 向党中央看齐--深入理解安全策略关系
- 从关系角度理解SQL
- 新手理解HTML、CSS、javascript之间的关系
- 我所理解开发和测试人员的关系
- React Native与原生关系理解与对比
- 关系代数中除法运算的理解
- hibernate中一对多多对一关系设计的理解
- node学习(2) -- 自定义模块(理解exports 和 module.exports的关系)
- 对java类和对象关系的理解
- 如何理解Nginx, WSGI, Flask之间的关系
- putchar和printf的区别,以及数组和指针的关系理解
- 深入理解javascript原型和闭包(2)——函数和对象的关系
- 线程进程Java多线程(一)、理解进程与多线程的概念及关系
- cocos2d-x学习笔记-CCAction动作类继承关系图及理解
- 理解js中的原型链,prototype与__proto__的关系
- 深入理解Java Servlet与Web容器之间的关系
- mysql中字符宽度与字节的关系理解