From 72195a0fd23def9b31434ca8de4805b4a6db730f Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 7 Jun 1999 09:00:15 +0000 Subject: [PATCH] Corrected cursors for during capture mouse. 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 | 1 + include/wx/generic/splitter.h | 4 ++++ samples/splitter/test.cpp | 3 ++- src/generic/splitter.cpp | 44 ++++++++++++++++++++++++----------- src/gtk/window.cpp | 40 +++++++++++++++---------------- src/gtk1/window.cpp | 40 +++++++++++++++---------------- 6 files changed, 76 insertions(+), 56 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index ae0ff7dc64..58e4c51cc4 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -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 diff --git a/include/wx/generic/splitter.h b/include/wx/generic/splitter.h index aa70baae1d..17e349a051 100644 --- a/include/wx/generic/splitter.h +++ b/include/wx/generic/splitter.h @@ -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; diff --git a/samples/splitter/test.cpp b/samples/splitter/test.cpp index c44103a332..64a0228da3 100644 --- a/samples/splitter/test.cpp +++ b/samples/splitter/test.cpp @@ -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; } diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index 779e8234eb..b458a92561 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -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() ) { diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 97cc6cd44a..4d2bc6c474 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -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 diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 97cc6cd44a..4d2bc6c474 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -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 -- 2.45.2