]> git.saurik.com Git - wxWidgets.git/commitdiff
Corrected cursors for during capture mouse.
authorRobert Roebling <robert@roebling.de>
Mon, 7 Jun 1999 09:00:15 +0000 (09:00 +0000)
committerRobert Roebling <robert@roebling.de>
Mon, 7 Jun 1999 09:00:15 +0000 (09:00 +0000)
  Added wxSP_LIVE_UPADTE to splitter.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2683 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/defs.h
include/wx/generic/splitter.h
samples/splitter/test.cpp
src/generic/splitter.cpp
src/gtk/window.cpp
src/gtk1/window.cpp

index ae0ff7dc641180ebe67f00f86bd82848c98c7115..58e4c51cc43528ed09742cdc4a684d96be6a7cdc 100644 (file)
@@ -745,6 +745,7 @@ typedef  wxUint16        wxWord;
 #define wxSP_3D             0x0004
 #define wxSP_BORDER         0x0008
 #define wxSP_PERMIT_UNSPLIT 0x0010
+#define wxSP_LIVE_UPDATE    0x0020
 
 /*
  * wxFrame extra flags
index aa70baae1d38aace1d7fc5998a1d4a3aeb429229..17e349a05106efdf789f6cfdeed427e37dd37c01 100644 (file)
@@ -160,6 +160,9 @@ public:
     // Adjusts the panes
     void OnSize(wxSizeEvent& event);
 
+    // In live mode, resize child windows in idle time
+    void OnIdle(wxIdleEvent& event);
+
     // Draws borders
     void DrawBorders(wxDC& dc);
 
@@ -189,6 +192,7 @@ protected:
 
     int         m_splitMode;
     bool        m_permitUnsplitAlways;
+    bool        m_needUpdating; // when in live mode, set the to TRUE to resize children in idle
     wxWindow*   m_windowOne;
     wxWindow*   m_windowTwo;
     int         m_dragMode;
index c44103a332804754c7db10c472d94475da0e3978..64a0228da38804efcd2638de579cbae1d772226f 100644 (file)
@@ -35,7 +35,8 @@ public:
 class MySplitterWindow : public wxSplitterWindow
 {
 public:
-  MySplitterWindow(wxFrame *parent, wxWindowID id) : wxSplitterWindow(parent, id)
+  MySplitterWindow(wxFrame *parent, wxWindowID id) 
+    : wxSplitterWindow(parent, id, wxDefaultPosition, wxDefaultSize, wxSP_3D | wxSP_LIVE_UPDATE)
   {
     m_frame = parent;
   }
index 779e8234eb58837831e7491c05f19034e06da3b1..b458a92561a0e5dc1b1f1ada9d7e002358b14e38 100644 (file)
@@ -37,6 +37,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxSplitterEvent, wxCommandEvent)
 BEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow)
     EVT_PAINT(wxSplitterWindow::OnPaint)
     EVT_SIZE(wxSplitterWindow::OnSize)
+    EVT_IDLE(wxSplitterWindow::OnIdle)
     EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent)
 
     EVT_SPLITTER_SASH_POS_CHANGED(-1, wxSplitterWindow::OnSashPosChanged)
@@ -72,6 +73,7 @@ wxSplitterWindow::wxSplitterWindow()
     m_facePen = (wxPen *) NULL;
     m_hilightPen = (wxPen *) NULL;
     m_minimumPaneSize = 0;
+    m_needUpdating = FALSE;
 }
 
 wxSplitterWindow::wxSplitterWindow(wxWindow *parent, wxWindowID id,
@@ -125,6 +127,8 @@ wxSplitterWindow::wxSplitterWindow(wxWindow *parent, wxWindowID id,
 
     // For debugging purposes, to see the background.
 //    SetBackground(wxBLUE_BRUSH);
+
+    m_needUpdating = FALSE;
 }
 
 wxSplitterWindow::~wxSplitterWindow()
@@ -149,6 +153,11 @@ void wxSplitterWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
     DrawSash(dc);
 }
 
+void wxSplitterWindow::OnIdle(wxIdleEvent& WXUNUSED(event))
+{
+    if (m_needUpdating)
+        SizeWindows();
+}
 
 void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
 {
@@ -163,15 +172,6 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
     SetCursor(wxCursor());
 #endif
 
-    // under wxGTK the method above causes the mouse
-    // to flicker so we set the standard cursor only
-    // when leaving the window and when moving over
-    // non-sash parts of the window. this should work
-    // on the other platforms as well, but who knows.
-#ifdef __WXGTK__
-    if (event.Leaving())
-        SetCursor(* wxSTANDARD_CURSOR);
-#endif
 
     if (event.LeftDown())
     {
@@ -181,7 +181,11 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
 
             m_dragMode = wxSPLIT_DRAG_DRAGGING;
 
-            DrawSashTracker(x, y);
+            if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
+           {
+               DrawSashTracker(x, y);
+           }
+           
             m_oldX = x;
             m_oldY = y;
             return;
@@ -194,7 +198,10 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
         ReleaseMouse();
 
         // Erase old tracker
-        DrawSashTracker(m_oldX, m_oldY);
+        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
@@ -293,7 +300,10 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
         }
 
         // Erase old tracker
-        DrawSashTracker(m_oldX, m_oldY);
+        if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
+       {
+            DrawSashTracker(m_oldX, m_oldY);
+       }
 
         if (m_splitMode == wxSPLIT_VERTICAL)
             x = new_sash_position;
@@ -321,7 +331,15 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
 #endif // __WXMSW__
 
         // Draw new one
-        DrawSashTracker(m_oldX, m_oldY);
+        if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
+       {
+            DrawSashTracker(m_oldX, m_oldY);
+       }
+       else
+       {
+            m_sashPosition = new_sash_position;
+           m_needUpdating = TRUE;
+       }
     }
     else if ( event.LeftDClick() )
     {
index 97cc6cd44a2c4ca60f56284a1b4b60a0e6bb597b..4d2bc6c47495512d095731fe1ab0809664e6e8e6 100644 (file)
@@ -131,7 +131,7 @@ extern wxList     wxPendingDelete;
 extern bool       g_blockEventsOnDrag;
 extern bool       g_blockEventsOnScroll;
 extern wxCursor   g_globalCursor;
-static bool       g_capturing = FALSE;
+static wxWindow  *g_captureWindow = (wxWindow*) NULL;
 static wxWindow  *g_focusWindow = (wxWindow*) NULL;
 
 /* hack: we need something to pass to gtk_menu_popup, so we store the time of
@@ -899,7 +899,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
     // Some control don't have their own X window and thus cannot get
     // any events.
 
-    if (!g_capturing)
+    if (!g_captureWindow)
     {
         wxNode *node = win->GetChildren().First();
         while (node)
@@ -1009,7 +1009,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
     // Some control don't have their own X window and thus cannot get
     // any events.
 
-    if (!g_capturing)
+    if (!g_captureWindow)
     {
         wxNode *node = win->GetChildren().First();
         while (node)
@@ -1120,7 +1120,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
     // Some control don't have their own X window and thus cannot get
     // any events.
 
-    if (!g_capturing)
+    if (!g_captureWindow)
     {
         wxNode *node = win->GetChildren().First();
         while (node)
@@ -2063,18 +2063,18 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
 
 void wxWindow::OnInternalIdle()
 {
-    GdkWindow *window = GetConnectWidget()->window;
-    if (window)
-    {
-        wxCursor cursor = m_cursor;
-        if (g_globalCursor.Ok()) cursor = g_globalCursor;
+        GdkWindow *window = GetConnectWidget()->window;
+        if (window)
+        {
+            wxCursor cursor = m_cursor;
+            if (g_globalCursor.Ok()) cursor = g_globalCursor;
        
-       if (m_currentGdkCursor != cursor)
-       {
-           gdk_window_set_cursor( window, cursor.GetCursor() );
-           m_currentGdkCursor = cursor;
+           if (m_currentGdkCursor != cursor)
+           {
+               gdk_window_set_cursor( window, cursor.GetCursor() );
+               m_currentGdkCursor = cursor;
+           }
        }
-    }
 
     UpdateWindowUI();
 }
@@ -2803,35 +2803,33 @@ void wxWindow::CaptureMouse()
 {
     wxCHECK_RET( m_widget != NULL, _T("invalid window") );
 
-    wxCHECK_RET( g_capturing == FALSE, _T("CaptureMouse called twice") );
+    wxCHECK_RET( g_captureWindow == NULL, _T("CaptureMouse called twice") );
 
     GtkWidget *connect_widget = GetConnectWidget();
     if (!connect_widget->window) return;
     
-    gtk_grab_add( connect_widget );
     gdk_pointer_grab( connect_widget->window, FALSE,
                       (GdkEventMask)
                          (GDK_BUTTON_PRESS_MASK |
                           GDK_BUTTON_RELEASE_MASK |
                           GDK_POINTER_MOTION_MASK),
                       (GdkWindow *) NULL,
-                      (GdkCursor *) NULL,
+                      m_cursor.GetCursor(),
                       GDK_CURRENT_TIME );
-    g_capturing = TRUE;
+    g_captureWindow = this;
 }
 
 void wxWindow::ReleaseMouse()
 {
     wxCHECK_RET( m_widget != NULL, _T("invalid window") );
 
-    wxCHECK_RET( g_capturing == TRUE, _T("ReleaseMouse called twice") );
+    wxCHECK_RET( g_captureWindow, _T("ReleaseMouse called twice") );
 
     GtkWidget *connect_widget = GetConnectWidget();
     if (!connect_widget->window) return;
     
-    gtk_grab_remove( connect_widget );
     gdk_pointer_ungrab ( GDK_CURRENT_TIME );
-    g_capturing = FALSE;
+    g_captureWindow = (wxWindow*) NULL;
 }
 
 bool wxWindow::IsRetained() const
index 97cc6cd44a2c4ca60f56284a1b4b60a0e6bb597b..4d2bc6c47495512d095731fe1ab0809664e6e8e6 100644 (file)
@@ -131,7 +131,7 @@ extern wxList     wxPendingDelete;
 extern bool       g_blockEventsOnDrag;
 extern bool       g_blockEventsOnScroll;
 extern wxCursor   g_globalCursor;
-static bool       g_capturing = FALSE;
+static wxWindow  *g_captureWindow = (wxWindow*) NULL;
 static wxWindow  *g_focusWindow = (wxWindow*) NULL;
 
 /* hack: we need something to pass to gtk_menu_popup, so we store the time of
@@ -899,7 +899,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
     // Some control don't have their own X window and thus cannot get
     // any events.
 
-    if (!g_capturing)
+    if (!g_captureWindow)
     {
         wxNode *node = win->GetChildren().First();
         while (node)
@@ -1009,7 +1009,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
     // Some control don't have their own X window and thus cannot get
     // any events.
 
-    if (!g_capturing)
+    if (!g_captureWindow)
     {
         wxNode *node = win->GetChildren().First();
         while (node)
@@ -1120,7 +1120,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
     // Some control don't have their own X window and thus cannot get
     // any events.
 
-    if (!g_capturing)
+    if (!g_captureWindow)
     {
         wxNode *node = win->GetChildren().First();
         while (node)
@@ -2063,18 +2063,18 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
 
 void wxWindow::OnInternalIdle()
 {
-    GdkWindow *window = GetConnectWidget()->window;
-    if (window)
-    {
-        wxCursor cursor = m_cursor;
-        if (g_globalCursor.Ok()) cursor = g_globalCursor;
+        GdkWindow *window = GetConnectWidget()->window;
+        if (window)
+        {
+            wxCursor cursor = m_cursor;
+            if (g_globalCursor.Ok()) cursor = g_globalCursor;
        
-       if (m_currentGdkCursor != cursor)
-       {
-           gdk_window_set_cursor( window, cursor.GetCursor() );
-           m_currentGdkCursor = cursor;
+           if (m_currentGdkCursor != cursor)
+           {
+               gdk_window_set_cursor( window, cursor.GetCursor() );
+               m_currentGdkCursor = cursor;
+           }
        }
-    }
 
     UpdateWindowUI();
 }
@@ -2803,35 +2803,33 @@ void wxWindow::CaptureMouse()
 {
     wxCHECK_RET( m_widget != NULL, _T("invalid window") );
 
-    wxCHECK_RET( g_capturing == FALSE, _T("CaptureMouse called twice") );
+    wxCHECK_RET( g_captureWindow == NULL, _T("CaptureMouse called twice") );
 
     GtkWidget *connect_widget = GetConnectWidget();
     if (!connect_widget->window) return;
     
-    gtk_grab_add( connect_widget );
     gdk_pointer_grab( connect_widget->window, FALSE,
                       (GdkEventMask)
                          (GDK_BUTTON_PRESS_MASK |
                           GDK_BUTTON_RELEASE_MASK |
                           GDK_POINTER_MOTION_MASK),
                       (GdkWindow *) NULL,
-                      (GdkCursor *) NULL,
+                      m_cursor.GetCursor(),
                       GDK_CURRENT_TIME );
-    g_capturing = TRUE;
+    g_captureWindow = this;
 }
 
 void wxWindow::ReleaseMouse()
 {
     wxCHECK_RET( m_widget != NULL, _T("invalid window") );
 
-    wxCHECK_RET( g_capturing == TRUE, _T("ReleaseMouse called twice") );
+    wxCHECK_RET( g_captureWindow, _T("ReleaseMouse called twice") );
 
     GtkWidget *connect_widget = GetConnectWidget();
     if (!connect_widget->window) return;
     
-    gtk_grab_remove( connect_widget );
     gdk_pointer_ungrab ( GDK_CURRENT_TIME );
-    g_capturing = FALSE;
+    g_captureWindow = (wxWindow*) NULL;
 }
 
 bool wxWindow::IsRetained() const