]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/sashwin.cpp
show correctly the initially selected colour and update the sliders (patch 484415)
[wxWidgets.git] / src / generic / sashwin.cpp
index a808264d02be01f497dfa1b551d46300d28091d3..8d679953dfc5c32bee6e49c651b7f25a077b8b9e 100644 (file)
 #pragma hdrstop
 #endif
 
+#if wxUSE_SASH
+
 #ifndef WX_PRECOMP
-#include "wx/wx.h"
+    #include "wx/dialog.h"
+    #include "wx/frame.h"
+    #include "wx/settings.h"
 #endif
 
-#if wxUSE_SASH
-
 #include <math.h>
 #include <stdlib.h>
 
-#include "wx/string.h"
 #include "wx/dcscreen.h"
 #include "wx/sashwin.h"
 #include "wx/laywin.h"
 
+DEFINE_EVENT_TYPE(wxEVT_SASH_DRAGGED)
+
 IMPLEMENT_DYNAMIC_CLASS(wxSashWindow, wxWindow)
 IMPLEMENT_DYNAMIC_CLASS(wxSashEvent, wxCommandEvent)
 
@@ -73,6 +76,7 @@ void wxSashWindow::Init()
     m_maximumPaneSizeY = 10000;
     m_sashCursorWE = new wxCursor(wxCURSOR_SIZEWE);
     m_sashCursorNS = new wxCursor(wxCURSOR_SIZENS);
+    m_mouseCaptured = FALSE;
 
     // Eventually, we'll respond to colour change messages
     InitColours();
@@ -97,7 +101,8 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event)
 
     // reset the cursor
 #if defined(__WXMOTIF__) || defined(__WXGTK__)
-    SetCursor(* wxSTANDARD_CURSOR);
+    // Not necessary and in fact inhibits proper cursor setting (JACS 8/2000)
+    //SetCursor(* wxSTANDARD_CURSOR);
 #endif
 #ifdef __WXMSW__
     SetCursor(wxNullCursor);
@@ -106,6 +111,7 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event)
     if (event.LeftDown())
     {
         CaptureMouse();
+        m_mouseCaptured = TRUE;
 
         if ( sashHit != wxSASH_NONE )
         {
@@ -144,7 +150,10 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event)
     else if ( event.LeftUp() && m_dragMode == wxSASH_DRAG_LEFT_DOWN )
     {
         // Wasn't a proper drag
-        ReleaseMouse();
+        if (m_mouseCaptured)
+            ReleaseMouse();
+        m_mouseCaptured = FALSE;
+
         wxScreenDC::EndDrawingOnTop();
         m_dragMode = wxSASH_DRAG_NONE;
         m_draggingEdge = wxSASH_NONE;
@@ -153,7 +162,10 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event)
     {
         // We can stop dragging now and see what we've got.
         m_dragMode = wxSASH_DRAG_NONE;
-        ReleaseMouse();
+        if (m_mouseCaptured)
+            ReleaseMouse();
+        m_mouseCaptured = FALSE;
+
         // Erase old tracker
         DrawSashTracker(m_draggingEdge, m_oldX, m_oldY);
 
@@ -273,7 +285,9 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event)
     }
     else if ( event.LeftUp() )
     {
-        ReleaseMouse();
+        if (m_mouseCaptured)
+           ReleaseMouse();
+        m_mouseCaptured = FALSE;
     }
     else if (event.Moving() && !event.Dragging())
     {
@@ -645,7 +659,7 @@ void wxSashWindow::SizeWindows()
 void wxSashWindow::InitColours()
 {
     // Shadow colours
-#if defined(__WIN95__)
+#ifndef __WIN16__
     m_faceColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
     m_mediumShadowColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW);
     m_darkShadowColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DDKSHADOW);