]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/src/gizmos/dynamicsash.cpp
Typos fixed and further clarification of the Python situation on Panther
[wxWidgets.git] / contrib / src / gizmos / dynamicsash.cpp
index 37d37bf15ca5a9bd0723331b4ff1e7d1f7b0efc9..32d3e9382297762a27392450eae78ffff69aa248 100644 (file)
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
+#ifdef __GNUG__
+    #pragma implementation "splittree.h"
+#endif
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWindows headers)
+#ifndef WX_PRECOMP
+    #include "wx/wx.h"
+#endif
+
 #include "wx/gizmos/dynamicsash.h"
 
 #include "wx/gizmos/dynamicsash.h"
 
+
+const wxChar* wxDynamicSashWindowNameStr = wxT("dynamicSashWindow");
+
+
 /*
     wxDynamicSashWindow works by internally storing a tree of Implementation
     objects (wxDynamicSsahWindowImpl) and Leaf objects
 /*
     wxDynamicSashWindow works by internally storing a tree of Implementation
     objects (wxDynamicSsahWindowImpl) and Leaf objects
@@ -83,8 +104,9 @@ class wxDynamicSashReparentEvent : public wxEvent {
 public:
     wxDynamicSashReparentEvent();
     wxDynamicSashReparentEvent(wxObject *object);
 public:
     wxDynamicSashReparentEvent();
     wxDynamicSashReparentEvent(wxObject *object);
+    wxDynamicSashReparentEvent(const wxDynamicSashReparentEvent& evt);
 
 
-    virtual wxEvent* Clone() const { return NULL; }
+    virtual wxEvent* Clone() const { return new wxDynamicSashReparentEvent(*this); }
 
     DECLARE_DYNAMIC_CLASS(wxDynamicSashReparentEvent);
 };
 
     DECLARE_DYNAMIC_CLASS(wxDynamicSashReparentEvent);
 };
@@ -291,13 +313,27 @@ bool wxDynamicSashWindowImpl::Create() {
 
     m_container->SetEventHandler(this);
 
 
     m_container->SetEventHandler(this);
 
-    Connect(-1, wxEVT_SIZE, (wxObjectEventFunction)&wxDynamicSashWindowImpl::OnSize);
-    Connect(-1, wxEVT_PAINT, (wxObjectEventFunction)&wxDynamicSashWindowImpl::OnPaint);
-    Connect(-1, wxEVT_MOTION, (wxObjectEventFunction)&wxDynamicSashWindowImpl::OnMouseMove);
-    Connect(-1, wxEVT_ENTER_WINDOW, (wxObjectEventFunction)&wxDynamicSashWindowImpl::OnMouseMove);
-    Connect(-1, wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)&wxDynamicSashWindowImpl::OnLeave);
-    Connect(-1, wxEVT_LEFT_DOWN, (wxObjectEventFunction)&wxDynamicSashWindowImpl::OnPress);
-    Connect(-1, wxEVT_LEFT_UP, (wxObjectEventFunction)&wxDynamicSashWindowImpl::OnRelease);
+    Connect(-1, wxEVT_SIZE, (wxObjectEventFunction)
+                            (wxEventFunction)
+                            (wxSizeEventFunction)&wxDynamicSashWindowImpl::OnSize);
+    Connect(-1, wxEVT_PAINT, (wxObjectEventFunction)
+                             (wxEventFunction)
+                             (wxPaintEventFunction)&wxDynamicSashWindowImpl::OnPaint);
+    Connect(-1, wxEVT_MOTION, (wxObjectEventFunction)
+                              (wxEventFunction)
+                              (wxMouseEventFunction)&wxDynamicSashWindowImpl::OnMouseMove);
+    Connect(-1, wxEVT_ENTER_WINDOW, (wxObjectEventFunction)
+                                    (wxEventFunction)
+                                    (wxMouseEventFunction)&wxDynamicSashWindowImpl::OnMouseMove);
+    Connect(-1, wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)
+                                    (wxEventFunction)
+                                    (wxMouseEventFunction)&wxDynamicSashWindowImpl::OnLeave);
+    Connect(-1, wxEVT_LEFT_DOWN, (wxObjectEventFunction)
+                                 (wxEventFunction)
+                                 (wxMouseEventFunction)&wxDynamicSashWindowImpl::OnPress);
+    Connect(-1, wxEVT_LEFT_UP, (wxObjectEventFunction)
+                               (wxEventFunction)
+                               (wxMouseEventFunction)&wxDynamicSashWindowImpl::OnRelease);
 
     return TRUE;
 }
 
     return TRUE;
 }
@@ -330,7 +366,8 @@ void wxDynamicSashWindowImpl::DrawSash(int x, int y) const {
     dc.SetBrush(brush);
     dc.SetLogicalFunction(wxXOR);
 
     dc.SetBrush(brush);
     dc.SetLogicalFunction(wxXOR);
 
-    if (m_dragging == DSR_CORNER) {
+    if ((m_dragging == DSR_CORNER) &&
+        (m_window->GetWindowStyle() & wxDS_DRAG_CORNER) != 0) {
         int cx = 0;
         int cy = 0;
 
         int cx = 0;
         int cy = 0;
 
@@ -532,7 +569,6 @@ void wxDynamicSashWindowImpl::Unify(int panel) {
 }
 
 void wxDynamicSashWindowImpl::Split(int px, int py) {
 }
 
 void wxDynamicSashWindowImpl::Split(int px, int py) {
-    m_window->Hide();
 
     m_add_child_target = NULL;
 
 
     m_add_child_target = NULL;
 
@@ -579,10 +615,9 @@ void wxDynamicSashWindowImpl::Split(int px, int py) {
     m_leaf = NULL;
 
     m_container->Layout();
     m_leaf = NULL;
 
     m_container->Layout();
-
-    m_window->Show();
 }
 
 }
 
+
 /*  This code is called when you finish resizing a view by dragging the
     corner tab, but I think this implementation is lousy and will surprise
     the user more often than it will do what they are trying to do.  What
 /*  This code is called when you finish resizing a view by dragging the
     corner tab, but I think this implementation is lousy and will surprise
     the user more often than it will do what they are trying to do.  What
@@ -774,7 +809,8 @@ void wxDynamicSashWindowImpl::OnPress(wxMouseEvent &event) {
 }
 
 void wxDynamicSashWindowImpl::OnRelease(wxMouseEvent &event) {
 }
 
 void wxDynamicSashWindowImpl::OnRelease(wxMouseEvent &event) {
-    if (m_dragging == DSR_CORNER) {
+    if ((m_dragging == DSR_CORNER) &&
+        (m_window->GetWindowStyle() & wxDS_DRAG_CORNER) != 0) {
         DrawSash(m_drag_x, m_drag_y);
         m_container->ReleaseMouse();
 
         DrawSash(m_drag_x, m_drag_y);
         m_container->ReleaseMouse();
 
@@ -876,19 +912,37 @@ bool wxDynamicSashWindowLeaf::Create() {
     m_viewport->SetEventHandler(this);
     Connect(-1, wxEVT_DYNAMIC_SASH_REPARENT, (wxObjectEventFunction)&wxDynamicSashWindowLeaf::OnReparent);
 
     m_viewport->SetEventHandler(this);
     Connect(-1, wxEVT_DYNAMIC_SASH_REPARENT, (wxObjectEventFunction)&wxDynamicSashWindowLeaf::OnReparent);
 
-    if (m_impl->m_window->GetWindowStyle() & wxMANAGE_SCROLLBARS) {
+    if (m_impl->m_window->GetWindowStyle() & wxDS_MANAGE_SCROLLBARS) {
         m_hscroll->SetEventHandler(this);
         m_vscroll->SetEventHandler(this);
 
         m_hscroll->SetEventHandler(this);
         m_vscroll->SetEventHandler(this);
 
-        Connect(-1, wxEVT_SET_FOCUS, (wxObjectEventFunction)&wxDynamicSashWindowLeaf::OnFocus);
-        Connect(-1, wxEVT_SCROLL_TOP, (wxObjectEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(-1, wxEVT_SCROLL_BOTTOM, (wxObjectEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(-1, wxEVT_SCROLL_LINEUP, (wxObjectEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(-1, wxEVT_SCROLL_LINEDOWN, (wxObjectEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(-1, wxEVT_SCROLL_PAGEUP, (wxObjectEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(-1, wxEVT_SCROLL_PAGEDOWN, (wxObjectEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(-1, wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
-        Connect(-1, wxEVT_SCROLL_THUMBRELEASE, (wxObjectEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
+        Connect(-1, wxEVT_SET_FOCUS, (wxObjectEventFunction)
+                                     (wxEventFunction)
+                                     (wxFocusEventFunction)&wxDynamicSashWindowLeaf::OnFocus);
+        Connect(-1, wxEVT_SCROLL_TOP, (wxObjectEventFunction)
+                                      (wxEventFunction)
+                                      (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
+        Connect(-1, wxEVT_SCROLL_BOTTOM, (wxObjectEventFunction)
+                                         (wxEventFunction)
+                                         (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
+        Connect(-1, wxEVT_SCROLL_LINEUP, (wxObjectEventFunction)
+                                         (wxEventFunction)
+                                         (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
+        Connect(-1, wxEVT_SCROLL_LINEDOWN, (wxObjectEventFunction)
+                                           (wxEventFunction)
+                                           (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
+        Connect(-1, wxEVT_SCROLL_PAGEUP, (wxObjectEventFunction)
+                                         (wxEventFunction)
+                                         (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
+        Connect(-1, wxEVT_SCROLL_PAGEDOWN, (wxObjectEventFunction)
+                                           (wxEventFunction)
+                                           (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
+        Connect(-1, wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)
+                                             (wxEventFunction)
+                                             (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
+        Connect(-1, wxEVT_SCROLL_THUMBRELEASE, (wxObjectEventFunction)
+                                               (wxEventFunction)
+                                               (wxScrollEventFunction)&wxDynamicSashWindowLeaf::OnScroll);
     }
 
     wxLayoutConstraints *layout = new wxLayoutConstraints();
     }
 
     wxLayoutConstraints *layout = new wxLayoutConstraints();
@@ -973,7 +1027,7 @@ DynamicSashRegion wxDynamicSashWindowLeaf::GetRegion(int x, int y) {
 
 void wxDynamicSashWindowLeaf::ResizeChild(wxSize size) {
     if (m_child) {
 
 void wxDynamicSashWindowLeaf::ResizeChild(wxSize size) {
     if (m_child) {
-        if (m_impl->m_window->GetWindowStyle() & wxMANAGE_SCROLLBARS) {
+        if (m_impl->m_window->GetWindowStyle() & wxDS_MANAGE_SCROLLBARS) {
             m_child->SetSize(size);
             wxSize best_size = m_child->GetBestSize();
             if (best_size.GetWidth() < size.GetWidth()) {
             m_child->SetSize(size);
             wxSize best_size = m_child->GetBestSize();
             if (best_size.GetWidth() < size.GetWidth()) {
@@ -1030,18 +1084,18 @@ wxScrollBar *wxDynamicSashWindowLeaf::FindScrollBar(const wxWindow *child, int v
     return NULL;
 }
 
     return NULL;
 }
 
-void wxDynamicSashWindowLeaf::OnSize(wxSizeEvent &event) {
+void wxDynamicSashWindowLeaf::OnSize(wxSizeEvent &WXUNUSED(event)) {
     m_impl->m_container->Refresh();
     ResizeChild(m_viewport->GetSize());
 }
 
     m_impl->m_container->Refresh();
     ResizeChild(m_viewport->GetSize());
 }
 
-void wxDynamicSashWindowLeaf::OnPaint(wxPaintEvent &event) {
+void wxDynamicSashWindowLeaf::OnPaint(wxPaintEvent &WXUNUSED(event)) {
     wxPaintDC dc(m_impl->m_container);
     dc.SetBackground(wxBrush(m_impl->m_container->GetBackgroundColour(), wxSOLID));
     dc.Clear();
 
     wxPaintDC dc(m_impl->m_container);
     dc.SetBackground(wxBrush(m_impl->m_container->GetBackgroundColour(), wxSOLID));
     dc.Clear();
 
-    wxPen highlight(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNHIGHLIGHT), 1, wxSOLID);
-    wxPen shadow(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNSHADOW), 1, wxSOLID);
+    wxPen highlight(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT), 1, wxSOLID);
+    wxPen shadow(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW), 1, wxSOLID);
     wxPen black(*wxBLACK, 1, wxSOLID);
 
     wxSize size = m_impl->m_container->GetSize();
     wxPen black(*wxBLACK, 1, wxSOLID);
 
     wxSize size = m_impl->m_container->GetSize();
@@ -1084,7 +1138,6 @@ void wxDynamicSashWindowLeaf::OnPaint(wxPaintEvent &event) {
     dc.DrawLine(9, h - sh - 3, 9, h - 4);
     dc.DrawLine(9, h - 4, 3, h - 4);
 
     dc.DrawLine(9, h - sh - 3, 9, h - 4);
     dc.DrawLine(9, h - 4, 3, h - 4);
 
-
     int cy = (h - sh + h - 6) / 2 + 1;
     int cx = (w - sw + w - 6) / 2 + 1;
     int sy = cy;
     int cy = (h - sh + h - 6) / 2 + 1;
     int cx = (w - sw + w - 6) / 2 + 1;
     int sy = cy;
@@ -1107,7 +1160,7 @@ void wxDynamicSashWindowLeaf::OnPaint(wxPaintEvent &event) {
     }
 }
 
     }
 }
 
-void wxDynamicSashWindowLeaf::OnScroll(wxScrollEvent &event) {
+void wxDynamicSashWindowLeaf::OnScroll(wxScrollEvent &WXUNUSED(event)) {
     int nx = -m_hscroll->GetThumbPosition();
     int ny = -m_vscroll->GetThumbPosition();
 
     int nx = -m_hscroll->GetThumbPosition();
     int ny = -m_vscroll->GetThumbPosition();
 
@@ -1137,7 +1190,8 @@ void wxDynamicSashWindowLeaf::OnMouseMove(wxMouseEvent &event) {
         cursor = wxCursor(wxCURSOR_SIZENS);
     } else if (region == DSR_VERTICAL_TAB) {
         cursor = wxCursor(wxCURSOR_SIZEWE);
         cursor = wxCursor(wxCURSOR_SIZENS);
     } else if (region == DSR_VERTICAL_TAB) {
         cursor = wxCursor(wxCURSOR_SIZEWE);
-    } else if (region == DSR_CORNER) {
+    } 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) {
         cursor = wxCursor(wxCURSOR_SIZENWSE);
     } else if (region == DSR_LEFT_EDGE || region == DSR_TOP_EDGE
                 || region == DSR_RIGHT_EDGE || region == DSR_BOTTOM_EDGE) {
@@ -1153,7 +1207,7 @@ void wxDynamicSashWindowLeaf::OnMouseMove(wxMouseEvent &event) {
     m_impl->m_container->SetCursor(cursor);
 }
 
     m_impl->m_container->SetCursor(cursor);
 }
 
-void wxDynamicSashWindowLeaf::OnLeave(wxMouseEvent &event) {
+void wxDynamicSashWindowLeaf::OnLeave(wxMouseEvent &WXUNUSED(event)) {
     wxCursor cursor(wxCURSOR_ARROW);
     m_impl->m_container->SetCursor(cursor);
 }
     wxCursor cursor(wxCURSOR_ARROW);
     m_impl->m_container->SetCursor(cursor);
 }
@@ -1162,6 +1216,9 @@ void wxDynamicSashWindowLeaf::OnLeave(wxMouseEvent &event) {
 void wxDynamicSashWindowLeaf::OnPress(wxMouseEvent &event) {
     DynamicSashRegion region = GetRegion(event.m_x, event.m_y);
 
 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) {
         m_impl->m_dragging = region;
         m_impl->m_drag_x = event.m_x;
     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;
@@ -1188,10 +1245,10 @@ void wxDynamicSashWindowLeaf::OnPress(wxMouseEvent &event) {
     }
 }
 
     }
 }
 
-void wxDynamicSashWindowLeaf::OnRelease(wxMouseEvent &event) {
+void wxDynamicSashWindowLeaf::OnRelease(wxMouseEvent &WXUNUSED(event)) {
 }
 
 }
 
-void wxDynamicSashWindowLeaf::OnReparent(wxEvent &event) {
+void wxDynamicSashWindowLeaf::OnReparent(wxEvent &WXUNUSED(event)) {
     if (m_child) {
         m_child->Reparent(m_viewport);
     }
     if (m_child) {
         m_child->Reparent(m_viewport);
     }
@@ -1239,6 +1296,11 @@ wxDynamicSashReparentEvent::wxDynamicSashReparentEvent(wxObject *object) {
     m_eventType = wxEVT_DYNAMIC_SASH_REPARENT;
 }
 
     m_eventType = wxEVT_DYNAMIC_SASH_REPARENT;
 }
 
+wxDynamicSashReparentEvent::wxDynamicSashReparentEvent(const wxDynamicSashReparentEvent& evt)
+    : wxEvent(evt)
+{
+}
+
 IMPLEMENT_DYNAMIC_CLASS(wxDynamicSashReparentEvent, wxEvent)
 
 /////////////////////////////////////////////////////////////////////////////
 IMPLEMENT_DYNAMIC_CLASS(wxDynamicSashReparentEvent, wxEvent)
 
 /////////////////////////////////////////////////////////////////////////////