]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/src/gizmos/dynamicsash.cpp
make pen/brush parameters const
[wxWidgets.git] / contrib / src / gizmos / dynamicsash.cpp
index 0ca0c59e3c77fca997f965c58727c467debc0c12..137d00cc4e2fdc5970f418c8175f2247c490ffae 100644 (file)
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-    #pragma implementation "splittree.h"
-#endif
-
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
@@ -85,17 +81,30 @@ const wxChar* wxDynamicSashWindowNameStr = wxT("dynamicSashWindow");
 
 */
 
-#include <wx/dcmemory.h>
-#include <wx/dcscreen.h>
-#include <wx/layout.h>
-#include <wx/scrolbar.h>
-#include <wx/settings.h>
+#include "wx/dcmemory.h"
+#include "wx/dcscreen.h"
+#include "wx/layout.h"
+#include "wx/scrolbar.h"
+#include "wx/settings.h"
 
 
 const wxEventType wxEVT_DYNAMIC_SASH_SPLIT = wxNewEventType();
 const wxEventType wxEVT_DYNAMIC_SASH_UNIFY = wxNewEventType();
 const wxEventType wxEVT_DYNAMIC_SASH_REPARENT = wxNewEventType();
 
+enum DynamicSashRegion
+{
+    DSR_NONE,
+    DSR_VERTICAL_TAB,
+    DSR_HORIZONTAL_TAB,
+    DSR_CORNER,
+    DSR_LEFT_EDGE,
+    DSR_TOP_EDGE,
+    DSR_RIGHT_EDGE,
+    DSR_BOTTOM_EDGE
+};
+
+
 /*
     wxDynamicSashReparentEvent is generated by the AddChild() method of
     wxDynamicSashWindow when it wants a Leaf to reparent a user view window
@@ -104,7 +113,8 @@ const wxEventType wxEVT_DYNAMIC_SASH_REPARENT = wxNewEventType();
     class.  Instead, we queue up this event, and the window is actually
     reparented the next time we process events in the idle loop.
 */
-class wxDynamicSashReparentEvent : public wxEvent {
+class wxDynamicSashReparentEvent : public wxEvent
+{
 public:
     wxDynamicSashReparentEvent();
     wxDynamicSashReparentEvent(wxObject *object);
@@ -116,19 +126,8 @@ public:
 };
 
 
-enum DynamicSashRegion {
-    DSR_NONE,
-    DSR_VERTICAL_TAB,
-    DSR_HORIZONTAL_TAB,
-    DSR_CORNER,
-    DSR_LEFT_EDGE,
-    DSR_TOP_EDGE,
-    DSR_RIGHT_EDGE,
-    DSR_BOTTOM_EDGE
-};
-
-
-class wxDynamicSashWindowImpl : public wxEvtHandler {
+class wxDynamicSashWindowImpl : public wxEvtHandler
+{
 public:
     wxDynamicSashWindowImpl(wxDynamicSashWindow *window);
     ~wxDynamicSashWindowImpl();
@@ -180,7 +179,8 @@ public:
     int m_drag_x, m_drag_y;
 };
 
-class wxDynamicSashWindowLeaf : public wxEvtHandler {
+class wxDynamicSashWindowLeaf : public wxEvtHandler
+{
 public:
     wxDynamicSashWindowLeaf(wxDynamicSashWindowImpl *impl);
     ~wxDynamicSashWindowLeaf();
@@ -188,10 +188,11 @@ public:
     bool Create();
     void AddChild(wxWindow *window);
     DynamicSashRegion GetRegion(int x, int y);
-    void ResizeChild(wxSize size);
+    void ResizeChild(const wxSize& size);
     wxScrollBar *FindScrollBar(const wxWindow *child, int vert) const;
 
     void OnSize(wxSizeEvent &event);
+    void OnViewSize(wxSizeEvent &event);
     void OnPaint(wxPaintEvent &event);
     void OnScroll(wxScrollEvent &event);
     void OnFocus(wxFocusEvent &event);
@@ -203,36 +204,51 @@ public:
 
     wxDynamicSashWindowImpl *m_impl;
 
-    wxScrollBar *m_vscroll, *m_hscroll;
+    wxScrollBar *m_vscroll,
+                *m_hscroll;
 
     /*  m_child is the window provided to us by the application developer.
         m_viewport is a window we've created, and it is the immediately
         parent of m_child.  We scroll m_child by moving it around within
         m_viewport.  */
-    wxWindow *m_viewport, *m_child;
+    wxWindow *m_viewport,
+             *m_child;
 };
 
-// wxDynamicSashWindow //////////////////////////////////////////////////////
 
-wxDynamicSashWindow::wxDynamicSashWindow() {
+// ============================================================================
+// wxDynamicSashWindow
+// ============================================================================
+
+wxDynamicSashWindow::wxDynamicSashWindow()
+{
     m_impl = NULL;
 }
 
-wxDynamicSashWindow::wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
-                                         const wxPoint& pos, const wxSize& size,
-                                         long style, const wxString& name) {
+wxDynamicSashWindow::wxDynamicSashWindow(wxWindow *parent,
+                                         wxWindowID id,
+                                         const wxPoint& pos,
+                                         const wxSize& size,
+                                         long style,
+                                         const wxString& name)
+{
     m_impl = NULL;
     Create(parent, id, pos, size, style, name);
 }
 
-wxDynamicSashWindow::~wxDynamicSashWindow() {
+wxDynamicSashWindow::~wxDynamicSashWindow()
+{
     SetEventHandler(this);
     delete m_impl;
 }
 
-bool wxDynamicSashWindow::Create(wxWindow *parent, wxWindowID id,
-                                 const wxPoint& pos, const wxSize& size,
-                                 long style, const wxString& name) {
+bool wxDynamicSashWindow::Create(wxWindow *parent,
+                                 wxWindowID id,
+                                 const wxPoint& pos,
+                                 const wxSize& size,
+                                 long style,
+                                 const wxString& name)
+{
     if (m_impl)
         return false;
 
@@ -243,7 +259,8 @@ bool wxDynamicSashWindow::Create(wxWindow *parent, wxWindowID id,
     if (!m_impl)
         return false;
 
-    if (!m_impl->Create()) {
+    if (!m_impl->Create())
+    {
         delete m_impl;
         m_impl = NULL;
         return false;
@@ -252,38 +269,47 @@ bool wxDynamicSashWindow::Create(wxWindow *parent, wxWindowID id,
     return true;
 }
 
-void wxDynamicSashWindow::AddChild(wxWindowBase *child) {
+void wxDynamicSashWindow::AddChild(wxWindowBase *child)
+{
     wxWindow::AddChild(child);
 
     m_impl->AddChild(wxDynamicCast(child, wxWindow));
 }
 
-wxScrollBar *wxDynamicSashWindow::GetHScrollBar(const wxWindow *child) const {
+wxScrollBar *wxDynamicSashWindow::GetHScrollBar(const wxWindow *child) const
+{
     return m_impl->FindScrollBar(child, 0);
 }
 
-wxScrollBar *wxDynamicSashWindow::GetVScrollBar(const wxWindow *child) const {
+wxScrollBar *wxDynamicSashWindow::GetVScrollBar(const wxWindow *child) const
+{
     return m_impl->FindScrollBar(child, 1);
 }
 
 IMPLEMENT_DYNAMIC_CLASS(wxDynamicSashWindow, wxWindow)
 
-// wxDynamicSashWindowImpl //////////////////////////////////////////////////
 
-wxDynamicSashWindowImpl::wxDynamicSashWindowImpl(wxDynamicSashWindow *window) {
+// ============================================================================
+// wxDynamicSashWindowImpl
+// ============================================================================
+
+wxDynamicSashWindowImpl::wxDynamicSashWindowImpl(wxDynamicSashWindow *window)
+{
     m_window = window;
     m_add_child_target = this;
 
     m_container = NULL;
     m_parent = NULL;
     m_top = this;
-    m_child[0] = m_child[1] = NULL;
+    m_child[0] =
+    m_child[1] = NULL;
     m_leaf = NULL;
     m_dragging = DSR_NONE;
     m_split = DSR_NONE;
 }
 
-wxDynamicSashWindowImpl::~wxDynamicSashWindowImpl() {
+wxDynamicSashWindowImpl::~wxDynamicSashWindowImpl()
+{
     delete m_leaf;
     delete m_child[0];
     m_child[0] = NULL;
@@ -291,16 +317,17 @@ wxDynamicSashWindowImpl::~wxDynamicSashWindowImpl() {
     m_child[1] = NULL;
     m_leaf = NULL;
 
-    if (m_container != m_window && m_container) {
+    if (m_container != m_window && m_container)
+    {
         m_container->SetEventHandler(m_container);
         m_container->Destroy();
     }
 }
 
-bool wxDynamicSashWindowImpl::Create() {
-    if (!m_container) {
+bool wxDynamicSashWindowImpl::Create()
+{
+    if (!m_container)
         m_container = m_window;
-    }
 
     wxCursor cursor(wxCURSOR_ARROW);
     m_container->SetCursor(cursor);
@@ -309,7 +336,8 @@ bool wxDynamicSashWindowImpl::Create() {
     if (!m_leaf)
         return false;
 
-    if (!m_leaf->Create()) {
+    if (!m_leaf->Create())
+    {
         delete m_leaf;
         m_leaf = NULL;
         return false;
@@ -317,38 +345,30 @@ bool wxDynamicSashWindowImpl::Create() {
 
     m_container->SetEventHandler(this);
 
-    Connect(wxID_ANY, wxEVT_SIZE, (wxObjectEventFunction)
-                            (wxEventFunction)
-                            (wxSizeEventFunction)&wxDynamicSashWindowImpl::OnSize);
-    Connect(wxID_ANY, wxEVT_PAINT, (wxObjectEventFunction)
-                             (wxEventFunction)
-                             (wxPaintEventFunction)&wxDynamicSashWindowImpl::OnPaint);
-    Connect(wxID_ANY, wxEVT_MOTION, (wxObjectEventFunction)
-                              (wxEventFunction)
-                              (wxMouseEventFunction)&wxDynamicSashWindowImpl::OnMouseMove);
-    Connect(wxID_ANY, wxEVT_ENTER_WINDOW, (wxObjectEventFunction)
-                                    (wxEventFunction)
-                                    (wxMouseEventFunction)&wxDynamicSashWindowImpl::OnMouseMove);
-    Connect(wxID_ANY, wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)
-                                    (wxEventFunction)
-                                    (wxMouseEventFunction)&wxDynamicSashWindowImpl::OnLeave);
-    Connect(wxID_ANY, wxEVT_LEFT_DOWN, (wxObjectEventFunction)
-                                 (wxEventFunction)
-                                 (wxMouseEventFunction)&wxDynamicSashWindowImpl::OnPress);
-    Connect(wxID_ANY, wxEVT_LEFT_UP, (wxObjectEventFunction)
-                               (wxEventFunction)
-                               (wxMouseEventFunction)&wxDynamicSashWindowImpl::OnRelease);
+    Connect(wxEVT_SIZE, wxSizeEventHandler(wxDynamicSashWindowImpl::OnSize));
+    Connect(wxEVT_PAINT, wxPaintEventHandler(wxDynamicSashWindowImpl::OnPaint));
+    Connect(wxEVT_MOTION,
+            wxMouseEventHandler(wxDynamicSashWindowImpl::OnMouseMove));
+    Connect(wxEVT_ENTER_WINDOW,
+            wxMouseEventHandler(wxDynamicSashWindowImpl::OnMouseMove));
+    Connect(wxEVT_LEAVE_WINDOW,
+            wxMouseEventHandler(wxDynamicSashWindowImpl::OnLeave));
+    Connect(wxEVT_LEFT_DOWN,
+            wxMouseEventHandler(wxDynamicSashWindowImpl::OnPress));
+    Connect(wxEVT_LEFT_UP,
+            wxMouseEventHandler(wxDynamicSashWindowImpl::OnRelease));
 
     return true;
 }
 
-void wxDynamicSashWindowImpl::AddChild(wxWindow *window) {
-    if (m_add_child_target && m_add_child_target->m_leaf) {
+void wxDynamicSashWindowImpl::AddChild(wxWindow *window)
+{
+    if (m_add_child_target && m_add_child_target->m_leaf)
         m_add_child_target->m_leaf->AddChild(window);
-    }
 }
 
-void wxDynamicSashWindowImpl::DrawSash(int x, int y) const {
+void wxDynamicSashWindowImpl::DrawSash(int x, int y) const
+{
     int i, j;
 
     wxScreenDC dc;
@@ -358,11 +378,12 @@ void wxDynamicSashWindowImpl::DrawSash(int x, int y) const {
     wxMemoryDC bdc;
     bdc.SelectObject(bmp);
     bdc.DrawRectangle(-1, -1, 10, 10);
-    for (i = 0; i < 8; i++) {
-        for (j = 0; j < 8; j++) {
-            if ((i + j) & 1) {
+    for (i = 0; i < 8; i++)
+    {
+        for (j = 0; j < 8; j++)
+        {
+            if ((i + j) & 1)
                 bdc.DrawPoint(i, j);
-            }
         }
     }
 
@@ -371,20 +392,24 @@ void wxDynamicSashWindowImpl::DrawSash(int x, int y) const {
     dc.SetLogicalFunction(wxXOR);
 
     if ((m_dragging == DSR_CORNER) &&
-        (m_window->GetWindowStyle() & wxDS_DRAG_CORNER) != 0) {
+        (m_window->GetWindowStyle() & wxDS_DRAG_CORNER) != 0)
+    {
         int cx = 0;
         int cy = 0;
 
         m_container->ClientToScreen(&cx, &cy);
         m_container->ClientToScreen(&x, &y);
 
-        if (cx < x && cy < y) {
+        if (cx < x && cy < y)
+        {
             dc.DrawRectangle(cx - 2, cy - 2, x - cx + 4, 4);
             dc.DrawRectangle(x - 2, cy + 2, 4, y - cy);
             dc.DrawRectangle(cx - 2, cy + 2, 4, y - cy);
             dc.DrawRectangle(cx + 2, y - 2, x - cx - 4, 4);
         }
-    } else {
+    }
+    else
+    {
         int body_w, body_h;
         m_container->GetClientSize(&body_w, &body_h);
 
@@ -416,17 +441,21 @@ void wxDynamicSashWindowImpl::DrawSash(int x, int y) const {
     dc.EndDrawingOnTop();
 }
 
-wxDynamicSashWindowImpl *wxDynamicSashWindowImpl::FindParent(DynamicSashRegion side) const {
-    if (m_parent == NULL) {
+wxDynamicSashWindowImpl *
+wxDynamicSashWindowImpl::FindParent(DynamicSashRegion side) const
+{
+    if (m_parent == NULL)
         return NULL;
-    }
 
-    if (m_parent->m_split == DSR_HORIZONTAL_TAB) {
+    if (m_parent->m_split == DSR_HORIZONTAL_TAB)
+    {
         if (side == DSR_TOP_EDGE && m_parent->m_child[1] == this)
             return m_parent;
         if (side == DSR_BOTTOM_EDGE && m_parent->m_child[0] == this)
             return m_parent;
-    } else if (m_parent->m_split == DSR_VERTICAL_TAB) {
+    }
+    else if (m_parent->m_split == DSR_VERTICAL_TAB)
+    {
         if (side == DSR_LEFT_EDGE && m_parent->m_child[1] == this)
             return m_parent;
         if (side == DSR_RIGHT_EDGE && m_parent->m_child[0] == this)
@@ -436,14 +465,16 @@ wxDynamicSashWindowImpl *wxDynamicSashWindowImpl::FindParent(DynamicSashRegion s
     return m_parent->FindParent(side);
 }
 
-wxDynamicSashWindowImpl *wxDynamicSashWindowImpl::FindUpperParent(wxDynamicSashWindowImpl *sash_a,
-                                                                  wxDynamicSashWindowImpl *sash_b) const {
+wxDynamicSashWindowImpl *
+wxDynamicSashWindowImpl::FindUpperParent(wxDynamicSashWindowImpl *sash_a,
+                                         wxDynamicSashWindowImpl *sash_b) const
+{
     wxWindow *win;
     win = sash_a->m_container->GetParent();
-    while (win && !win->IsTopLevel()) {
-        if (win == sash_b->m_container) {
+    while (win && !win->IsTopLevel())
+    {
+        if (win == sash_b->m_container)
             return sash_b;
-        }
 
         win = win->GetParent();
     }
@@ -452,7 +483,8 @@ wxDynamicSashWindowImpl *wxDynamicSashWindowImpl::FindUpperParent(wxDynamicSashW
 }
 
 
-wxWindow *wxDynamicSashWindowImpl::FindFrame() const {
+wxWindow *wxDynamicSashWindowImpl::FindFrame() const
+{
     wxWindow *win;
 
     win = m_window->GetParent();
@@ -460,38 +492,44 @@ wxWindow *wxDynamicSashWindowImpl::FindFrame() const {
 #ifdef __WXMSW__
            && ! wxIsKindOf(win, wxMDIChildFrame)  // not top-level but still a frame
 #endif
-        ) {
+        )
+    {
         win = win->GetParent();
     }
 
     return win;
 }
 
-wxScrollBar *wxDynamicSashWindowImpl::FindScrollBar(const wxWindow *child, int vert) const {
-    if (m_child[0] == NULL && m_leaf == NULL) {
+wxScrollBar *
+wxDynamicSashWindowImpl::FindScrollBar(const wxWindow *child, int vert) const
+{
+    if (m_child[0] == NULL && m_leaf == NULL)
         return NULL;
-    }
 
-    if (!m_child[0]) {
+    if (!m_child[0])
+    {
         return m_leaf->FindScrollBar(child, vert);
-    } else {
-        wxScrollBar *ret = m_child[0]->FindScrollBar(child, vert);
-        if (!ret) {
-            ret = m_child[1]->FindScrollBar(child, vert);
-        }
-
-        return ret;
     }
+
+    wxScrollBar *ret = m_child[0]->FindScrollBar(child, vert);
+    if (!ret)
+        ret = m_child[1]->FindScrollBar(child, vert);
+
+    return ret;
 }
 
-void wxDynamicSashWindowImpl::ConstrainChildren(int px, int py) {
+void wxDynamicSashWindowImpl::ConstrainChildren(int px, int py)
+{
     wxLayoutConstraints *layout = new wxLayoutConstraints();
     layout->left.SameAs(m_container, wxLeft);
     layout->top.SameAs(m_container, wxTop);
-    if (m_split == DSR_HORIZONTAL_TAB) {
+    if (m_split == DSR_HORIZONTAL_TAB)
+    {
         layout->right.SameAs(m_container, wxRight);
         layout->height.PercentOf(m_container, wxHeight, py);
-    } else {
+    }
+    else
+    {
         layout->bottom.SameAs(m_container, wxBottom);
         layout->width.PercentOf(m_container, wxWidth, px);
     }
@@ -500,23 +538,25 @@ void wxDynamicSashWindowImpl::ConstrainChildren(int px, int py) {
     layout = new wxLayoutConstraints();
     layout->right.SameAs(m_container, wxRight);
     layout->bottom.SameAs(m_container, wxBottom);
-    if (m_split == DSR_HORIZONTAL_TAB) {
+    if (m_split == DSR_HORIZONTAL_TAB)
+    {
         layout->top.Below(m_child[0]->m_container, 1);
         layout->left.SameAs(m_container, wxLeft);
-    } else {
+    }
+    else
+    {
         layout->left.RightOf(m_child[0]->m_container, 1);
         layout->top.SameAs(m_container, wxTop);
     }
     m_child[1]->m_container->SetConstraints(layout);
 }
 
-void wxDynamicSashWindowImpl::Unify(int panel) {
-    int other = 0;
-    if (panel == 0) {
-        other = 1;
-    }
+void wxDynamicSashWindowImpl::Unify(int panel)
+{
+    int other = panel == 0 ? 1 : 0;
 
-    if (m_child[panel]->m_leaf) {
+    if (m_child[panel]->m_leaf)
+    {
         wxDynamicSashWindowImpl *child[2];
 
         child[0] = m_child[0];
@@ -547,7 +587,9 @@ void wxDynamicSashWindowImpl::Unify(int panel) {
 
         wxDynamicSashUnifyEvent unify(m_leaf->m_child);
         m_leaf->m_child->ProcessEvent(unify);
-    } else {
+    }
+    else
+    {
         m_split = m_child[panel]->m_split;
 
         delete m_child[other];
@@ -576,7 +618,8 @@ void wxDynamicSashWindowImpl::Unify(int panel) {
     }
 }
 
-void wxDynamicSashWindowImpl::Split(int px, int py) {
+void wxDynamicSashWindowImpl::Split(int px, int py)
+{
 
     m_add_child_target = NULL;
 
@@ -585,7 +628,8 @@ void wxDynamicSashWindowImpl::Split(int px, int py) {
     m_child[0]->m_parent = this;
     m_child[0]->m_top = m_top;
     m_child[0]->Create();
-    if (m_leaf->m_child) {
+    if (m_leaf->m_child)
+    {
         m_leaf->m_child->Reparent(m_container);
         m_child[0]->AddChild(m_leaf->m_child);
     }
@@ -635,33 +679,38 @@ void wxDynamicSashWindowImpl::Split(int px, int py) {
     by destroying the neighbors.
 
     But this will do for now.  */
-void wxDynamicSashWindowImpl::Resize(int x, int y) {
+void wxDynamicSashWindowImpl::Resize(int x, int y)
+{
     wxDynamicSashWindowImpl *h_parent = FindParent(DSR_BOTTOM_EDGE);
     wxDynamicSashWindowImpl *v_parent = FindParent(DSR_RIGHT_EDGE);
     int h_unify = -1;
     int v_unify = -1;
     wxWindow *frame = FindFrame();
 
-    if (x < 0) {
+    if (x < 0)
         x = 0;
-    }
-    if (y < 0) {
+    if (y < 0)
         y = 0;
-    }
 
-    if (h_parent) {
+    if (h_parent)
+    {
         m_container->ClientToScreen(NULL, &y);
         h_parent->m_container->ScreenToClient(NULL, &y);
 
         int py = (int)((y * 100) / h_parent->m_container->GetSize().GetHeight() + 0.5);
 
-        if (py < 10) {
+        if (py < 10)
+        {
             wxDynamicSashWindowImpl *ho_parent = FindParent(DSR_TOP_EDGE);
 
-            if (ho_parent) {
-                if (FindUpperParent(h_parent, ho_parent) == ho_parent) {
+            if (ho_parent)
+            {
+                if (FindUpperParent(h_parent, ho_parent) == ho_parent)
+                {
                     h_unify = 1;
-                } else {
+                }
+                else
+                {
                     py = (int)((ho_parent->m_child[0]->m_container->GetSize().GetHeight() * 100)
                                 / h_parent->m_container->GetSize().GetHeight() + 0.5);
                     h_parent->m_child[0]->m_container->GetConstraints()->height.PercentOf(
@@ -670,51 +719,68 @@ void wxDynamicSashWindowImpl::Resize(int x, int y) {
                     h_parent = ho_parent;
                     h_unify = 0;
                 }
-            } else {
+            }
+            else
+            {
                 h_unify = 1;
             }
-        } else if (py > 90) {
+        }
+        else if (py > 90)
+        {
             h_unify = 0;
-        } else {
+        }
+        else
+        {
             h_parent->m_child[0]->m_container->GetConstraints()->height.PercentOf(
                     h_parent->m_container, wxHeight, py);
             h_parent->m_container->Layout();
         }
-    } else {
+    }
+    else
+    {
         int do_resize = 1;
         h_parent = FindParent(DSR_TOP_EDGE);
 
-        if (h_parent) {
+        if (h_parent)
+        {
             int py = (int)((y * 100) /
                         (h_parent->m_container->GetSize().GetHeight() +
                                 y - m_container->GetSize().GetHeight()) + 0.5);
 
-            if (py < 10) {
+            if (py < 10)
                 h_unify = 0;
-            }
-        } else if (y < 64) {
+        }
+        else if (y < 64)
+        {
             do_resize = 0;
         }
 
-        if (do_resize) {
+        if (do_resize)
+        {
             wxSize size = frame->GetSize();
             frame->SetSize(size.GetWidth(), size.GetHeight() + y - m_container->GetSize().GetHeight());
         }
     }
 
-    if (v_parent) {
+    if (v_parent)
+    {
         m_container->ClientToScreen(&x, NULL);
         v_parent->m_container->ScreenToClient(&x, NULL);
 
         int px = (int)((x * 100) / v_parent->m_container->GetSize().GetWidth() + 0.5);
 
-        if (px < 10) {
+        if (px < 10)
+        {
             wxDynamicSashWindowImpl *vo_parent = FindParent(DSR_LEFT_EDGE);
 
-            if (vo_parent) {
-                if (FindUpperParent(v_parent, vo_parent) == vo_parent) {
+            if (vo_parent)
+            {
+                if (FindUpperParent(v_parent, vo_parent) == vo_parent)
+                {
                     v_unify = 1;
-                } else {
+                }
+                else
+                {
                     px = (int)((vo_parent->m_child[0]->m_container->GetSize().GetWidth() * 100)
                                 / v_parent->m_container->GetSize().GetWidth() + 0.5);
                     v_parent->m_child[0]->m_container->GetConstraints()->width.PercentOf(
@@ -723,91 +789,121 @@ void wxDynamicSashWindowImpl::Resize(int x, int y) {
                     v_parent = vo_parent;
                     v_unify = 0;
                 }
-            } else {
+            }
+            else
+            {
                 v_unify = 1;
             }
-        } else if (px > 90) {
+        }
+        else if (px > 90)
+        {
             v_unify = 0;
-        } else {
+        }
+        else
+        {
             v_parent->m_child[0]->m_container->GetConstraints()->width.PercentOf(
                     v_parent->m_container, wxWidth, px);
             v_parent->m_container->Layout();
         }
-    } else {
+    }
+    else
+    {
         int do_resize = 1;
         v_parent = FindParent(DSR_LEFT_EDGE);
 
-        if (v_parent) {
+        if (v_parent)
+        {
             int px = (int)((x * 100) /
                         (v_parent->m_container->GetSize().GetWidth() +
                                 x - m_container->GetSize().GetWidth()) + 0.5);
 
-            if (px < 10) {
+            if (px < 10)
                 v_unify = 0;
-            }
-        } else if (x < 64) {
+        }
+        else if (x < 64)
+        {
             do_resize = 0;
         }
 
-        if (do_resize) {
+        if (do_resize)
+        {
             wxSize size = frame->GetSize();
             frame->SetSize(size.GetWidth() + x - m_container->GetSize().GetWidth(), size.GetHeight());
         }
     }
 
-    if (h_unify != -1 && v_unify != -1) {
+    if (h_unify != -1 && v_unify != -1)
+    {
         wxDynamicSashWindowImpl *parent = FindUpperParent(h_parent, v_parent);
 
-        if (parent == h_parent) {
+        if (parent == h_parent)
+        {
             h_parent->Unify(h_unify);
-        } else {
+        }
+        else
+        {
             v_parent->Unify(v_unify);
         }
-    } else if (h_unify != -1) {
+    }
+    else if (h_unify != -1)
+    {
         h_parent->Unify(h_unify);
-    } else if (v_unify != -1) {
+    }
+    else if (v_unify != -1)
+    {
         v_parent->Unify(v_unify);
     }
 }
 
 
-void wxDynamicSashWindowImpl::OnSize(wxSizeEvent &event) {
+void wxDynamicSashWindowImpl::OnSize(wxSizeEvent &event)
+{
     m_container->Layout();
 
     if (m_leaf)
         m_leaf->OnSize(event);
 }
 
-void wxDynamicSashWindowImpl::OnPaint(wxPaintEvent &event) {
+void wxDynamicSashWindowImpl::OnPaint(wxPaintEvent &event)
+{
     if (m_leaf)
         m_leaf->OnPaint(event);
-    else {
+    else
+    {
         wxPaintDC dc(m_container);
         dc.SetBackground(wxBrush(m_container->GetBackgroundColour(), wxSOLID));
         dc.Clear();
     }
 }
 
-void wxDynamicSashWindowImpl::OnMouseMove(wxMouseEvent &event) {
-    if (m_dragging) {
+void wxDynamicSashWindowImpl::OnMouseMove(wxMouseEvent &event)
+{
+    if (m_dragging)
+    {
         DrawSash(m_drag_x, m_drag_y);
         m_drag_x = event.m_x;  m_drag_y = event.m_y;
         DrawSash(m_drag_x, m_drag_y);
-    } else if (m_leaf) {
+    }
+    else if (m_leaf)
+    {
         m_leaf->OnMouseMove(event);
     }
 }
 
-void wxDynamicSashWindowImpl::OnLeave(wxMouseEvent &event) {
-    if (m_leaf) {
+void wxDynamicSashWindowImpl::OnLeave(wxMouseEvent &event)
+{
+    if (m_leaf)
         m_leaf->OnLeave(event);
-    }
 }
 
-void wxDynamicSashWindowImpl::OnPress(wxMouseEvent &event) {
-    if (m_leaf) {
+void wxDynamicSashWindowImpl::OnPress(wxMouseEvent &event)
+{
+    if (m_leaf)
+    {
         m_leaf->OnPress(event);
-    } else {
+    }
+    else
+    {
         m_dragging = m_split;
         m_drag_x = event.m_x;
         m_drag_y = event.m_y;
@@ -816,16 +912,20 @@ void wxDynamicSashWindowImpl::OnPress(wxMouseEvent &event) {
     }
 }
 
-void wxDynamicSashWindowImpl::OnRelease(wxMouseEvent &event) {
+void wxDynamicSashWindowImpl::OnRelease(wxMouseEvent &event)
+{
     if ((m_dragging == DSR_CORNER) &&
-        (m_window->GetWindowStyle() & wxDS_DRAG_CORNER) != 0) {
+        (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) {
+    }
+    else if (m_dragging)
+    {
         DrawSash(m_drag_x, m_drag_y);
         m_container->ReleaseMouse();
 
@@ -834,82 +934,107 @@ void wxDynamicSashWindowImpl::OnRelease(wxMouseEvent &event) {
         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) {
+                    || (m_dragging == DSR_VERTICAL_TAB && px >= 10 && px <= 90))
+        {
+            if (m_child[0] == NULL)
+            {
                 Split(px, py);
-            } else {
+            }
+            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) {
+                if (m_split == DSR_HORIZONTAL_TAB)
+                {
                     layout->height.PercentOf(m_container, wxHeight, py);
-                } else {
+                }
+                else
+                {
                     layout->width.PercentOf(m_container, wxWidth, px);
                 }
                 m_container->Layout();
             }
-        } else {
-            if (m_child[0] != NULL) {
+        }
+        else
+        {
+            if (m_child[0] != NULL)
+            {
                 if ((m_dragging == DSR_HORIZONTAL_TAB && py <= 10)
-                        || (m_dragging == DSR_VERTICAL_TAB && px <= 10)) {
+                        || (m_dragging == DSR_VERTICAL_TAB && px <= 10))
+                {
                     Unify(1);
-                } else {
+                }
+                else
+                {
                     Unify(0);
                 }
             }
         }
 
-        wxCursor cursor(wxCURSOR_ARROW);
-        if (m_split == DSR_HORIZONTAL_TAB) {
+        wxCursor cursor;
+        if (m_split == DSR_HORIZONTAL_TAB)
             cursor = wxCursor(wxCURSOR_SIZENS);
-        } else if (m_split == DSR_VERTICAL_TAB) {
+        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) {
+    }
+    else if (m_leaf)
+    {
         m_leaf->OnRelease(event);
     }
 }
 
-// wxDynamicSashWindowLeaf //////////////////////////////////////////////////
+// ============================================================================
+// wxDynamicSashWindowLeaf
+// ============================================================================
 
-wxDynamicSashWindowLeaf::wxDynamicSashWindowLeaf(wxDynamicSashWindowImpl *impl) {
+wxDynamicSashWindowLeaf::wxDynamicSashWindowLeaf(wxDynamicSashWindowImpl *impl)
+{
     m_impl = impl;
 
-    m_hscroll = m_vscroll = NULL;
+    m_hscroll =
+    m_vscroll = NULL;
+
     m_child = NULL;
 }
 
-wxDynamicSashWindowLeaf::~wxDynamicSashWindowLeaf() {
+wxDynamicSashWindowLeaf::~wxDynamicSashWindowLeaf()
+{
     m_hscroll->SetEventHandler(m_hscroll);
     m_vscroll->SetEventHandler(m_vscroll);
-    m_viewport->SetEventHandler(m_viewport);
 
     m_hscroll->Destroy();
     m_vscroll->Destroy();
     m_viewport->Destroy();
 }
 
-bool wxDynamicSashWindowLeaf::Create() {
-    bool success;
-
+bool wxDynamicSashWindowLeaf::Create()
+{
     m_hscroll = new wxScrollBar();
     m_vscroll = new wxScrollBar();
     m_viewport = new wxWindow();
 
-    if (!m_hscroll || !m_vscroll || !m_viewport) {
-        return false;
-    }
-
     wxDynamicSashWindowImpl *add_child_target = m_impl->m_add_child_target;
     m_impl->m_add_child_target = NULL;
-    success = m_hscroll->Create(m_impl->m_container, wxID_ANY, wxDefaultPosition, wxDefaultSize,
-                                wxSB_HORIZONTAL);
-    success = success && m_vscroll->Create(m_impl->m_container, wxID_ANY, wxDefaultPosition, wxDefaultSize,
-                                            wxSB_VERTICAL);
-    success = success && m_viewport->Create(m_impl->m_container, wxID_ANY);
+
+    bool success = m_hscroll->Create(m_impl->m_container, wxID_ANY,
+                                     wxDefaultPosition, wxDefaultSize,
+                                     wxSB_HORIZONTAL);
+    if ( success )
+        success = m_vscroll->Create(m_impl->m_container, wxID_ANY,
+                                    wxDefaultPosition, wxDefaultSize,
+                                    wxSB_VERTICAL);
+    if ( success )
+        success = m_viewport->Create(m_impl->m_container, wxID_ANY);
+    if ( !success )
+        return false;
+
     m_impl->m_add_child_target = add_child_target;
 
     wxCursor cursor(wxCURSOR_ARROW);
@@ -917,49 +1042,46 @@ bool wxDynamicSashWindowLeaf::Create() {
     m_vscroll->SetCursor(cursor);
     m_viewport->SetCursor(cursor);
 
-    m_viewport->SetEventHandler(this);
-    Connect(wxID_ANY, wxEVT_DYNAMIC_SASH_REPARENT, (wxObjectEventFunction)&wxDynamicSashWindowLeaf::OnReparent);
+    // the viewport must resize its child when it is itself resized, but it's
+    // more convenient to do it in our own method instead of deriving a new
+    // class just for this: this is why we pass this as last Connect() argument
+    m_viewport->Connect(wxEVT_SIZE,
+                        wxSizeEventHandler(wxDynamicSashWindowLeaf::OnViewSize),
+                        NULL, this);
+
+    Connect(wxEVT_DYNAMIC_SASH_REPARENT,
+            wxEventHandler(wxDynamicSashWindowLeaf::OnReparent));
 
-    if (m_impl->m_window->GetWindowStyle() & wxDS_MANAGE_SCROLLBARS) {
+    if (m_impl->m_window->GetWindowStyle() & wxDS_MANAGE_SCROLLBARS)
+    {
         m_hscroll->SetEventHandler(this);
         m_vscroll->SetEventHandler(this);
 
-        Connect(wxID_ANY, wxEVT_SET_FOCUS, (wxObjectEventFunction)
-                                     (wxEventFunction)
-                                     (wxFocusEventFunction)&wxDynamicSashWindowLeaf::OnFocus);
-        Connect(wxID_ANY, wxEVT_SCROLL_TOP, (wxObjectEventFunction)
-                                      (wxEventFunction)
-                                      (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(wxID_ANY, wxEVT_SCROLL_BOTTOM, (wxObjectEventFunction)
-                                         (wxEventFunction)
-                                         (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(wxID_ANY, wxEVT_SCROLL_LINEUP, (wxObjectEventFunction)
-                                         (wxEventFunction)
-                                         (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(wxID_ANY, wxEVT_SCROLL_LINEDOWN, (wxObjectEventFunction)
-                                           (wxEventFunction)
-                                           (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(wxID_ANY, wxEVT_SCROLL_PAGEUP, (wxObjectEventFunction)
-                                         (wxEventFunction)
-                                         (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(wxID_ANY, wxEVT_SCROLL_PAGEDOWN, (wxObjectEventFunction)
-                                           (wxEventFunction)
-                                           (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(wxID_ANY, wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)
-                                             (wxEventFunction)
-                                             (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(wxID_ANY, wxEVT_SCROLL_THUMBRELEASE, (wxObjectEventFunction)
-                                               (wxEventFunction)
-                                               (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
+        Connect(wxEVT_SET_FOCUS,
+                wxFocusEventHandler(wxDynamicSashWindowLeaf::OnFocus));
+        Connect(wxEVT_SCROLL_TOP,
+                wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll));
+        Connect(wxEVT_SCROLL_BOTTOM,
+                wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll));
+        Connect(wxEVT_SCROLL_LINEUP,
+                wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll));
+        Connect(wxEVT_SCROLL_LINEDOWN,
+                wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll));
+        Connect(wxEVT_SCROLL_PAGEUP,
+                wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll));
+        Connect(wxEVT_SCROLL_PAGEDOWN,
+                wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll));
+        Connect(wxEVT_SCROLL_THUMBTRACK,
+                wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll));
+        Connect(wxEVT_SCROLL_THUMBRELEASE,
+                wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll));
     }
 
     wxLayoutConstraints *layout = new wxLayoutConstraints();
     if (!layout)
         return false;
+
     wxSize size = m_hscroll->GetBestSize();
-#ifdef __WXMSW__
-    size = m_hscroll->GetSize();
-#endif
 
     layout->left.SameAs(m_impl->m_container, wxLeft, 10);
     layout->right.LeftOf(m_vscroll);
@@ -970,10 +1092,8 @@ bool wxDynamicSashWindowLeaf::Create() {
     layout = new wxLayoutConstraints();
     if (!layout)
         return false;
-    size = size = m_vscroll->GetBestSize();
-#ifdef __WXMSW__
-    size = m_vscroll->GetSize();
-#endif
+
+    size = m_vscroll->GetBestSize();
 
     layout->top.SameAs(m_impl->m_container, wxTop, 10);
     layout->bottom.Above(m_hscroll);
@@ -992,13 +1112,13 @@ bool wxDynamicSashWindowLeaf::Create() {
 
     m_impl->m_container->Layout();
 
-    return success;
+    return true;
 }
 
-void wxDynamicSashWindowLeaf::AddChild(wxWindow *window) {
-    if (m_child) {
+void wxDynamicSashWindowLeaf::AddChild(wxWindow *window)
+{
+    if (m_child)
         m_child->Destroy();
-    }
 
     m_child = window;
 
@@ -1006,7 +1126,8 @@ void wxDynamicSashWindowLeaf::AddChild(wxWindow *window) {
     AddPendingEvent(event);
 }
 
-DynamicSashRegion wxDynamicSashWindowLeaf::GetRegion(int x, int y) {
+DynamicSashRegion wxDynamicSashWindowLeaf::GetRegion(int x, int y)
+{
     wxSize size = m_impl->m_container->GetSize();
     int w = size.GetWidth();
     int h = size.GetHeight();
@@ -1033,34 +1154,30 @@ DynamicSashRegion wxDynamicSashWindowLeaf::GetRegion(int x, int y) {
     return DSR_NONE;
 }
 
-void wxDynamicSashWindowLeaf::ResizeChild(wxSize size) {
-    if (m_child) {
-        if (m_impl->m_window->GetWindowStyle() & wxDS_MANAGE_SCROLLBARS) {
-            m_child->SetSize(size);
+void wxDynamicSashWindowLeaf::ResizeChild(const wxSize& size)
+{
+    if (m_child)
+    {
+        if (m_impl->m_window->HasFlag(wxDS_MANAGE_SCROLLBARS))
+        {
             wxSize best_size = m_child->GetBestSize();
-            if (best_size.GetWidth() < size.GetWidth()) {
+            if (best_size.GetWidth() < size.GetWidth())
                 best_size.SetWidth(size.GetWidth());
-            }
-            if (best_size.GetHeight() < size.GetHeight()) {
+            if (best_size.GetHeight() < size.GetHeight())
                 best_size.SetHeight(size.GetHeight());
-            }
             m_child->SetSize(best_size);
 
             int hpos = m_hscroll->GetThumbPosition();
             int vpos = m_vscroll->GetThumbPosition();
 
-            if (hpos < 0) {
+            if (hpos < 0)
                 hpos = 0;
-            }
-            if (vpos < 0) {
+            if (vpos < 0)
                 vpos = 0;
-            }
-            if (hpos > best_size.GetWidth() - size.GetWidth()) {
+            if (hpos > best_size.GetWidth() - size.GetWidth())
                 hpos = best_size.GetWidth() - size.GetWidth();
-            }
-            if (vpos > best_size.GetHeight() - size.GetHeight()) {
+            if (vpos > best_size.GetHeight() - size.GetHeight())
                 vpos = best_size.GetHeight() - size.GetHeight();
-            }
 
             m_hscroll->SetScrollbar(hpos, size.GetWidth(),
                                     best_size.GetWidth(), size.GetWidth());
@@ -1074,30 +1191,38 @@ void wxDynamicSashWindowLeaf::ResizeChild(wxSize size) {
 
             wxPoint pos = m_child->GetPosition();
             m_viewport->ScrollWindow(-hpos - pos.x, -vpos - pos.y);
-        } else {
+        }
+        else // !wxDS_MANAGE_SCROLLBARS
+        {
             m_child->SetSize(size);
         }
     }
 }
 
-wxScrollBar *wxDynamicSashWindowLeaf::FindScrollBar(const wxWindow *child, int vert) const {
-    if (m_child == child) {
-        if (vert) {
-            return m_vscroll;
-        } else {
-            return m_hscroll;
-        }
+wxScrollBar *
+wxDynamicSashWindowLeaf::FindScrollBar(const wxWindow *child, int vert) const
+{
+    if (m_child == child)
+    {
+        return vert ? m_vscroll : m_hscroll;
     }
 
     return NULL;
 }
 
-void wxDynamicSashWindowLeaf::OnSize(wxSizeEvent &WXUNUSED(event)) {
+void wxDynamicSashWindowLeaf::OnSize(wxSizeEvent &WXUNUSED(event))
+{
     m_impl->m_container->Refresh();
-    ResizeChild(m_viewport->GetSize());
 }
 
-void wxDynamicSashWindowLeaf::OnPaint(wxPaintEvent &WXUNUSED(event)) {
+void wxDynamicSashWindowLeaf::OnViewSize(wxSizeEvent &WXUNUSED(event))
+{
+    if ( m_viewport )
+        ResizeChild(m_viewport->GetSize());
+}
+
+void wxDynamicSashWindowLeaf::OnPaint(wxPaintEvent &WXUNUSED(event))
+{
     wxPaintDC dc(m_impl->m_container);
     dc.SetBackground(wxBrush(m_impl->m_container->GetBackgroundColour(), wxSOLID));
     dc.Clear();
@@ -1156,9 +1281,12 @@ void wxDynamicSashWindowLeaf::OnPaint(wxPaintEvent &WXUNUSED(event)) {
         sx -= 4;
 
     int x, y;
-    for (y = sy; y < h - 2; y += 4) {
-        for (x = sx; x < w - 2; x += 4) {
-            if (x - cx >= -(y - cy)) {
+    for (y = sy; y < h - 2; y += 4)
+    {
+        for (x = sx; x < w - 2; x += 4)
+        {
+            if (x - cx >= -(y - cy))
+            {
                 dc.SetPen(highlight);
                 dc.DrawPoint(x, y);
                 dc.SetPen(shadow);
@@ -1168,45 +1296,61 @@ void wxDynamicSashWindowLeaf::OnPaint(wxPaintEvent &WXUNUSED(event)) {
     }
 }
 
-void wxDynamicSashWindowLeaf::OnScroll(wxScrollEvent &WXUNUSED(event)) {
+void wxDynamicSashWindowLeaf::OnScroll(wxScrollEvent &WXUNUSED(event))
+{
     int nx = -m_hscroll->GetThumbPosition();
     int ny = -m_vscroll->GetThumbPosition();
 
-    if (m_child) {
+    if (m_child)
+    {
         wxPoint pos = m_child->GetPosition();
 
         m_viewport->ScrollWindow(nx - pos.x, ny - pos.y);
     }
 }
 
-void wxDynamicSashWindowLeaf::OnFocus(wxFocusEvent &event) {
-    if (event.GetEventObject() == m_hscroll || event.GetEventObject() == m_vscroll) {
+void wxDynamicSashWindowLeaf::OnFocus(wxFocusEvent &event)
+{
+    if ( event.GetEventObject() == m_hscroll ||
+            event.GetEventObject() == m_vscroll )
+    {
         m_child->SetFocus();
     }
 }
 
 
-void wxDynamicSashWindowLeaf::OnMouseMove(wxMouseEvent &event) {
-    if (m_impl->m_dragging) {
+void wxDynamicSashWindowLeaf::OnMouseMove(wxMouseEvent &event)
+{
+    if (m_impl->m_dragging)
         return;
-    }
 
     DynamicSashRegion region = GetRegion(event.m_x, event.m_y);
 
     wxCursor cursor(wxCURSOR_ARROW);
-    if (region == DSR_HORIZONTAL_TAB) {
+    if (region == DSR_HORIZONTAL_TAB)
+    {
         cursor = wxCursor(wxCURSOR_SIZENS);
-    } else if (region == DSR_VERTICAL_TAB) {
+    }
+    else if (region == DSR_VERTICAL_TAB)
+    {
         cursor = wxCursor(wxCURSOR_SIZEWE);
-    } else if ((region == DSR_CORNER) &&
-               (m_impl->m_window->GetWindowStyle() & wxDS_DRAG_CORNER) != 0) {
+    }
+    else if ((region == DSR_CORNER) &&
+               (m_impl->m_window->GetWindowStyle() & wxDS_DRAG_CORNER) != 0)
+    {
         cursor = wxCursor(wxCURSOR_SIZENWSE);
-    } else if (region == DSR_LEFT_EDGE || region == DSR_TOP_EDGE
-                || region == DSR_RIGHT_EDGE || region == DSR_BOTTOM_EDGE) {
-        if (m_impl->FindParent(region)) {
-            if (region == DSR_LEFT_EDGE || region == DSR_RIGHT_EDGE) {
+    }
+    else if (region == DSR_LEFT_EDGE || region == DSR_TOP_EDGE
+                || region == DSR_RIGHT_EDGE || region == DSR_BOTTOM_EDGE)
+    {
+        if (m_impl->FindParent(region))
+        {
+            if (region == DSR_LEFT_EDGE || region == DSR_RIGHT_EDGE)
+            {
                 cursor = wxCursor(wxCURSOR_SIZEWE);
-            } else {
+            }
+            else
+            {
                 cursor = wxCursor(wxCURSOR_SIZENS);
             }
         }
@@ -1215,29 +1359,35 @@ void wxDynamicSashWindowLeaf::OnMouseMove(wxMouseEvent &event) {
     m_impl->m_container->SetCursor(cursor);
 }
 
-void wxDynamicSashWindowLeaf::OnLeave(wxMouseEvent &WXUNUSED(event)) {
+void wxDynamicSashWindowLeaf::OnLeave(wxMouseEvent &WXUNUSED(event))
+{
     wxCursor cursor(wxCURSOR_ARROW);
     m_impl->m_container->SetCursor(cursor);
 }
 
 
-void wxDynamicSashWindowLeaf::OnPress(wxMouseEvent &event) {
+void wxDynamicSashWindowLeaf::OnPress(wxMouseEvent &event)
+{
     DynamicSashRegion region = GetRegion(event.m_x, event.m_y);
 
     if ((region == DSR_CORNER) && (m_impl->m_window->GetWindowStyle() & wxDS_DRAG_CORNER) == 0)
         return;
 
-    if (region == DSR_HORIZONTAL_TAB || region == DSR_VERTICAL_TAB || region == DSR_CORNER) {
+    if (region == DSR_HORIZONTAL_TAB || region == DSR_VERTICAL_TAB || region == DSR_CORNER)
+    {
         m_impl->m_dragging = region;
         m_impl->m_drag_x = event.m_x;
         m_impl->m_drag_y = event.m_y;
         m_impl->DrawSash(event.m_x, event.m_y);
         m_impl->m_container->CaptureMouse();
-    } else if (region == DSR_LEFT_EDGE || region == DSR_TOP_EDGE
-                || region == DSR_RIGHT_EDGE || region == DSR_BOTTOM_EDGE) {
+    }
+    else if (region == DSR_LEFT_EDGE || region == DSR_TOP_EDGE
+                || region == DSR_RIGHT_EDGE || region == DSR_BOTTOM_EDGE)
+    {
         wxDynamicSashWindowImpl *parent = m_impl->FindParent(region);
 
-        if (parent) {
+        if (parent)
+        {
             int x = event.m_x;
             int y = event.m_y;
 
@@ -1253,53 +1403,61 @@ void wxDynamicSashWindowLeaf::OnPress(wxMouseEvent &event) {
     }
 }
 
-void wxDynamicSashWindowLeaf::OnRelease(wxMouseEvent &WXUNUSED(event)) {
+void wxDynamicSashWindowLeaf::OnRelease(wxMouseEvent &WXUNUSED(event))
+{
 }
 
-void wxDynamicSashWindowLeaf::OnReparent(wxEvent &WXUNUSED(event)) {
-    if (m_child) {
+void wxDynamicSashWindowLeaf::OnReparent(wxEvent &WXUNUSED(event))
+{
+    if (m_child)
+    {
         m_child->Reparent(m_viewport);
     }
 
     ResizeChild(m_viewport->GetSize());
 }
 
-// wxDynamicSashSplitEvent //////////////////////////////////////////////////
+// ============================================================================
+// events
+// ============================================================================
 
-wxDynamicSashSplitEvent::wxDynamicSashSplitEvent() {
+wxDynamicSashSplitEvent::wxDynamicSashSplitEvent()
+{
     m_eventObject = NULL;
     m_eventType = wxEVT_DYNAMIC_SASH_SPLIT;
 }
 
-wxDynamicSashSplitEvent::wxDynamicSashSplitEvent(wxObject *object) {
+wxDynamicSashSplitEvent::wxDynamicSashSplitEvent(wxObject *object)
+{
     m_eventObject = object;
     m_eventType = wxEVT_DYNAMIC_SASH_SPLIT;
 }
 
 IMPLEMENT_DYNAMIC_CLASS(wxDynamicSashSplitEvent, wxCommandEvent)
 
-// wxDynamicSashUnifyEvent //////////////////////////////////////////////////
-
-wxDynamicSashUnifyEvent::wxDynamicSashUnifyEvent() {
+wxDynamicSashUnifyEvent::wxDynamicSashUnifyEvent()
+{
     m_eventObject = NULL;
     m_eventType = wxEVT_DYNAMIC_SASH_UNIFY;
 }
 
-wxDynamicSashUnifyEvent::wxDynamicSashUnifyEvent(wxObject *object) {
+wxDynamicSashUnifyEvent::wxDynamicSashUnifyEvent(wxObject *object)
+{
     m_eventObject = object;
     m_eventType = wxEVT_DYNAMIC_SASH_UNIFY;
 }
 
 IMPLEMENT_DYNAMIC_CLASS(wxDynamicSashUnifyEvent, wxCommandEvent)
 
-// wxDynamicSsahReparentEvent ///////////////////////////////////////////////
 
-wxDynamicSashReparentEvent::wxDynamicSashReparentEvent() {
+wxDynamicSashReparentEvent::wxDynamicSashReparentEvent()
+{
     m_eventObject = NULL;
     m_eventType = wxEVT_DYNAMIC_SASH_REPARENT;
 }
 
-wxDynamicSashReparentEvent::wxDynamicSashReparentEvent(wxObject *object) {
+wxDynamicSashReparentEvent::wxDynamicSashReparentEvent(wxObject *object)
+{
     m_eventObject = object;
     m_eventType = wxEVT_DYNAMIC_SASH_REPARENT;
 }
@@ -1311,4 +1469,3 @@ wxDynamicSashReparentEvent::wxDynamicSashReparentEvent(const wxDynamicSashRepare
 
 IMPLEMENT_DYNAMIC_CLASS(wxDynamicSashReparentEvent, wxEvent)
 
-/////////////////////////////////////////////////////////////////////////////