]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/splitter.cpp
yet another help browser visual enhancement
[wxWidgets.git] / src / generic / splitter.cpp
index 2df6674596197fa925d2d713edb27e3c36288d98..31aea495e1752f47834d36b9b3d2c3ab727d269f 100644 (file)
@@ -21,7 +21,9 @@
 #endif
 
 #ifndef WX_PRECOMP
-    #include "wx/wx.h"
+    #include "wx/window.h"
+    #include "wx/dialog.h"
+    #include "wx/frame.h"
 #endif
 
 #include <stdlib.h>
@@ -29,8 +31,8 @@
 #include "wx/string.h"
 #include "wx/splitter.h"
 #include "wx/dcscreen.h"
+#include "wx/settings.h"
 
-#if !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindow, wxWindow)
 IMPLEMENT_DYNAMIC_CLASS(wxSplitterEvent, wxCommandEvent)
 
@@ -47,7 +49,6 @@ BEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow)
     EVT_SPLITTER_DCLICK(-1,           wxSplitterWindow::OnDoubleClick)
     EVT_SPLITTER_UNSPLIT(-1,          wxSplitterWindow::OnUnsplitEvent)
 END_EVENT_TABLE()
-#endif
 
 wxSplitterWindow::wxSplitterWindow()
 {
@@ -161,8 +162,8 @@ void wxSplitterWindow::OnIdle(wxIdleEvent& WXUNUSED(event))
 
 void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
 {
-    long x = event.GetX();
-    long y = event.GetY();
+    wxCoord x = (wxCoord)event.GetX(),
+            y = (wxCoord)event.GetY();
 
     // reset the cursor
 #ifdef __WXMOTIF__
@@ -182,10 +183,10 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
             m_dragMode = wxSPLIT_DRAG_DRAGGING;
 
             if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
-           {
-               DrawSashTracker(x, y);
-           }
-           
+            {
+                DrawSashTracker(x, y);
+            }
+
             m_oldX = x;
             m_oldY = y;
             return;
@@ -199,9 +200,9 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
 
         // Erase old tracker
         if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
-       {
+        {
             DrawSashTracker(m_oldX, m_oldY);
-       }
+        }
 
         // Obtain window size. We are only interested in the dimension the sash
         // splits up
@@ -279,7 +280,7 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
         }
 #endif // __WXGTK__
     }
-    else if (event.Dragging() && (m_dragMode == wxSPLIT_DRAG_DRAGGING)) 
+    else if (event.Dragging() && (m_dragMode == wxSPLIT_DRAG_DRAGGING))
     {
         // Obtain window size. We are only interested in the dimension the sash
         // splits up
@@ -301,9 +302,9 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
 
         // Erase old tracker
         if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
-       {
+        {
             DrawSashTracker(m_oldX, m_oldY);
-       }
+        }
 
         if (m_splitMode == wxSPLIT_VERTICAL)
             x = new_sash_position;
@@ -332,14 +333,14 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
 
         // Draw new one
         if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
-       {
+        {
             DrawSashTracker(m_oldX, m_oldY);
-       }
-       else
-       {
+        }
+        else
+        {
             m_sashPosition = new_sash_position;
-           m_needUpdating = TRUE;
-       }
+            m_needUpdating = TRUE;
+        }
     }
     else if ( event.LeftDClick() )
     {
@@ -421,8 +422,6 @@ bool wxSplitterWindow::SashHitTest(int x, int y, int tolerance)
         else
             return FALSE;
     }
-
-    return FALSE;
 }
 
 // Draw 3D effect borders
@@ -433,7 +432,7 @@ void wxSplitterWindow::DrawBorders(wxDC& dc)
 
     if ( GetWindowStyleFlag() & wxSP_3D )
     {
-               
+
         dc.SetPen(*m_facePen);
         dc.SetBrush(*m_faceBrush);
         dc.DrawRectangle(1, 1 , w-1, m_borderSize-2 ); //high
@@ -489,14 +488,14 @@ void wxSplitterWindow::DrawSash(wxDC& dc)
             dc.SetBrush(*wxTRANSPARENT_BRUSH);
 
             dc.SetPen(*m_lightShadowPen);
-                       int xShadow = m_borderSize ? m_borderSize - 1 : 0 ;
+                        int xShadow = m_borderSize ? m_borderSize - 1 : 0 ;
             dc.DrawLine(m_sashPosition, xShadow , m_sashPosition, h-m_borderSize);
 
             dc.SetPen(*m_hilightPen);
             dc.DrawLine(m_sashPosition+1, m_borderSize - 2, m_sashPosition+1, h - m_borderSize+2);
 
             dc.SetPen(*m_mediumShadowPen);
-                       int yMedium = m_borderSize ? h-m_borderSize+1 : h ;
+                        int yMedium = m_borderSize ? h-m_borderSize+1 : h ;
             dc.DrawLine(m_sashPosition+m_sashSize-2, xShadow, m_sashPosition+m_sashSize-2, yMedium);
 
             dc.SetPen(*m_darkShadowPen);
@@ -618,9 +617,7 @@ void wxSplitterWindow::SizeWindows()
     if ( m_windowOne && !m_windowTwo )
     {
         m_windowOne->SetSize(m_borderSize, m_borderSize, w - 2*m_borderSize, h - 2*m_borderSize);
-       
-       if (m_windowOne->GetAutoLayout())
-           m_windowOne->Layout();
+
     }
     else if ( m_windowOne && m_windowTwo )
     {
@@ -638,11 +635,7 @@ void wxSplitterWindow::SizeWindows()
 
             m_windowOne->SetSize(x1, y1, w1, h1);
             m_windowTwo->SetSize(x2, y2, w2, h2);
-       
-           if (m_windowOne->GetAutoLayout())
-               m_windowOne->Layout();
-           if (m_windowTwo->GetAutoLayout())
-               m_windowTwo->Layout();
+
         }
         else
         {
@@ -650,16 +643,12 @@ void wxSplitterWindow::SizeWindows()
                 w - 2*m_borderSize, m_sashPosition - m_borderSize);
             m_windowTwo->SetSize(m_borderSize, m_sashPosition + m_sashSize,
                 w - 2*m_borderSize, h - 2*m_borderSize - m_sashSize - (m_sashPosition - m_borderSize));
-               
-           if (m_windowOne->GetAutoLayout())
-               m_windowOne->Layout();
-           if (m_windowTwo->GetAutoLayout())
-               m_windowTwo->Layout();
+
         }
     }
     wxClientDC dc(this);
-       if ( m_borderSize > 0 )
-               DrawBorders(dc);
+    if ( m_borderSize > 0 )
+        DrawBorders(dc);
     DrawSash(dc);
 }
 
@@ -900,8 +889,7 @@ void wxSplitterWindow::OnDoubleClick(wxSplitterEvent& event)
     // for compatibility, call the virtual function
     OnDoubleClickSash(event.GetX(), event.GetY());
 
-    if ( GetMinimumPaneSize() == 0
-        || m_permitUnsplitAlways)
+    if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways )
     {
         Unsplit();
     }
@@ -911,8 +899,9 @@ void wxSplitterWindow::OnUnsplitEvent(wxSplitterEvent& event)
 {
     wxWindow *win = event.GetWindowBeingRemoved();
 
+    // do it before calling OnUnsplit() which may delete the window
+    win->Show(FALSE);
+
     // for compatibility, call the virtual function
     OnUnsplit(win);
-
-    win->Show(FALSE);
 }