void wxDynamicSashWindowImpl::OnSize(wxSizeEvent &event) { m_container->Layout(); if (m_leaf) m_leaf->OnSize(event); }
void wxDynamicSashWindowImpl::Split(int px, int py) { m_add_child_target = NULL; m_child[0] = new wxDynamicSashWindowImpl(m_window); m_child[0]->m_container = new wxWindow(m_container, wxID_ANY); m_child[0]->m_parent = this; m_child[0]->m_top = m_top; m_child[0]->Create(); if (m_leaf->m_child) { m_leaf->m_child->Reparent(m_container); m_child[0]->AddChild(m_leaf->m_child); } m_child[1] = new wxDynamicSashWindowImpl(m_window); m_child[1]->m_container = new wxWindow(m_container, wxID_ANY); m_child[1]->m_parent = this; m_child[1]->m_top = m_top; m_child[1]->Create(); m_split = m_dragging; ConstrainChildren(px, py); m_top->m_add_child_target = m_child[1]; wxDynamicSashSplitEvent split(m_child[0]->m_leaf->m_child); m_child[0]->m_leaf->m_child->ProcessEvent(split); m_child[0]->m_leaf->m_vscroll->SetScrollbar(m_leaf->m_vscroll->GetThumbPosition(), m_leaf->m_vscroll->GetThumbSize(), m_leaf->m_vscroll->GetRange(), m_leaf->m_vscroll->GetPageSize()); m_child[0]->m_leaf->m_hscroll->SetScrollbar(m_leaf->m_hscroll->GetThumbPosition(), m_leaf->m_hscroll->GetThumbSize(), m_leaf->m_hscroll->GetRange(), m_leaf->m_hscroll->GetPageSize()); m_child[1]->m_leaf->m_vscroll->SetScrollbar(m_leaf->m_vscroll->GetThumbPosition(), m_leaf->m_vscroll->GetThumbSize(), m_leaf->m_vscroll->GetRange(), m_leaf->m_vscroll->GetPageSize()); m_child[1]->m_leaf->m_hscroll->SetScrollbar(m_leaf->m_hscroll->GetThumbPosition(), m_leaf->m_hscroll->GetThumbSize(), m_leaf->m_hscroll->GetRange(), m_leaf->m_hscroll->GetPageSize()); delete m_leaf; m_leaf = NULL; m_container->Layout(); }
void wxDynamicSashWindowImpl::OnRelease(wxMouseEvent &event) { if ((m_dragging == DSR_CORNER) && (m_window->GetWindowStyle() & wxDS_DRAG_CORNER) != 0) { DrawSash(m_drag_x, m_drag_y); m_container->ReleaseMouse(); Resize(event.m_x, event.m_y); m_dragging = DSR_NONE; } else if (m_dragging) { DrawSash(m_drag_x, m_drag_y); m_container->ReleaseMouse(); wxSize size = m_container->GetSize(); int px = (int)((event.m_x * 100) / size.GetWidth() + 0.5); int py = (int)((event.m_y * 100) / size.GetHeight() + 0.5); if ((m_dragging == DSR_HORIZONTAL_TAB && py >= 10 && py <= 90) || (m_dragging == DSR_VERTICAL_TAB && px >= 10 && px <= 90)) { if (m_child[0] == NULL) { Split(px, py); } else { /* It would be nice if moving *this* sash didn't implicitly move the sashes of our children (if any). But this will do. */ wxLayoutConstraints *layout = m_child[0]->m_container->GetConstraints(); if (m_split == DSR_HORIZONTAL_TAB) { layout->height.PercentOf(m_container, wxHeight, py); } else { layout->width.PercentOf(m_container, wxWidth, px); } m_container->Layout(); } } else { if (m_child[0] != NULL) { if ((m_dragging == DSR_HORIZONTAL_TAB && py <= 10) || (m_dragging == DSR_VERTICAL_TAB && px <= 10)) { Unify(1); } else { Unify(0); } } } wxCursor cursor; if (m_split == DSR_HORIZONTAL_TAB) cursor = wxCursor(wxCURSOR_SIZENS); else if (m_split == DSR_VERTICAL_TAB) cursor = wxCursor(wxCURSOR_SIZEWE); else cursor = wxCursor(wxCURSOR_ARROW); m_container->SetCursor(cursor); m_dragging = DSR_NONE; } else if (m_leaf) { m_leaf->OnRelease(event); } }
void wxDynamicSashWindowImpl::Unify(int panel) { int other = panel == 0 ? 1 : 0; if (m_child[panel]->m_leaf) { wxDynamicSashWindowImpl *child[2]; child[0] = m_child[0]; child[1] = m_child[1]; m_child[0] = m_child[1] = NULL; m_leaf = new wxDynamicSashWindowLeaf(this); m_leaf->Create(); m_leaf->m_child = child[panel]->m_leaf->m_child; m_leaf->m_vscroll->SetScrollbar(child[panel]->m_leaf->m_vscroll->GetThumbPosition(), child[panel]->m_leaf->m_vscroll->GetThumbSize(), child[panel]->m_leaf->m_vscroll->GetRange(), child[panel]->m_leaf->m_vscroll->GetPageSize()); m_leaf->m_hscroll->SetScrollbar(child[panel]->m_leaf->m_hscroll->GetThumbPosition(), child[panel]->m_leaf->m_hscroll->GetThumbSize(), child[panel]->m_leaf->m_hscroll->GetRange(), child[panel]->m_leaf->m_hscroll->GetPageSize()); m_add_child_target = NULL; wxDynamicSashReparentEvent event(m_leaf); m_leaf->ProcessEvent(event); delete child[0]; delete child[1]; m_split = DSR_NONE; wxDynamicSashUnifyEvent unify(m_leaf->m_child); m_leaf->m_child->ProcessEvent(unify); } else { m_split = m_child[panel]->m_split; delete m_child[other]; wxDynamicSashWindowImpl *child_panel = m_child[panel]; m_child[0] = child_panel->m_child[0]; m_child[1] = child_panel->m_child[1]; m_child[0]->m_parent = this; m_child[1]->m_parent = this; m_add_child_target = NULL; m_child[0]->m_container->Reparent(m_container); m_child[1]->m_container->Reparent(m_container); child_panel->m_child[0] = child_panel->m_child[1] = NULL; delete child_panel; wxSize size = m_container->GetSize(); wxSize child_size = m_child[0]->m_container->GetSize(); ConstrainChildren(child_size.GetWidth() * 100 / size.GetWidth(), child_size.GetHeight() * 100 / size.GetHeight()); m_container->Layout(); } }