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
This commit is contained in:
Robert Roebling
1999-06-07 09:00:15 +00:00
parent 5df1250b30
commit 72195a0fd2
6 changed files with 76 additions and 56 deletions

View File

@@ -745,6 +745,7 @@ typedef wxUint16 wxWord;
#define wxSP_3D 0x0004 #define wxSP_3D 0x0004
#define wxSP_BORDER 0x0008 #define wxSP_BORDER 0x0008
#define wxSP_PERMIT_UNSPLIT 0x0010 #define wxSP_PERMIT_UNSPLIT 0x0010
#define wxSP_LIVE_UPDATE 0x0020
/* /*
* wxFrame extra flags * wxFrame extra flags

View File

@@ -160,6 +160,9 @@ public:
// Adjusts the panes // Adjusts the panes
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);
// In live mode, resize child windows in idle time
void OnIdle(wxIdleEvent& event);
// Draws borders // Draws borders
void DrawBorders(wxDC& dc); void DrawBorders(wxDC& dc);
@@ -189,6 +192,7 @@ protected:
int m_splitMode; int m_splitMode;
bool m_permitUnsplitAlways; bool m_permitUnsplitAlways;
bool m_needUpdating; // when in live mode, set the to TRUE to resize children in idle
wxWindow* m_windowOne; wxWindow* m_windowOne;
wxWindow* m_windowTwo; wxWindow* m_windowTwo;
int m_dragMode; int m_dragMode;

View File

@@ -35,7 +35,8 @@ public:
class MySplitterWindow : public wxSplitterWindow class MySplitterWindow : public wxSplitterWindow
{ {
public: 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; m_frame = parent;
} }

View File

@@ -37,6 +37,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxSplitterEvent, wxCommandEvent)
BEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow) BEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow)
EVT_PAINT(wxSplitterWindow::OnPaint) EVT_PAINT(wxSplitterWindow::OnPaint)
EVT_SIZE(wxSplitterWindow::OnSize) EVT_SIZE(wxSplitterWindow::OnSize)
EVT_IDLE(wxSplitterWindow::OnIdle)
EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent) EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent)
EVT_SPLITTER_SASH_POS_CHANGED(-1, wxSplitterWindow::OnSashPosChanged) EVT_SPLITTER_SASH_POS_CHANGED(-1, wxSplitterWindow::OnSashPosChanged)
@@ -72,6 +73,7 @@ wxSplitterWindow::wxSplitterWindow()
m_facePen = (wxPen *) NULL; m_facePen = (wxPen *) NULL;
m_hilightPen = (wxPen *) NULL; m_hilightPen = (wxPen *) NULL;
m_minimumPaneSize = 0; m_minimumPaneSize = 0;
m_needUpdating = FALSE;
} }
wxSplitterWindow::wxSplitterWindow(wxWindow *parent, wxWindowID id, wxSplitterWindow::wxSplitterWindow(wxWindow *parent, wxWindowID id,
@@ -125,6 +127,8 @@ wxSplitterWindow::wxSplitterWindow(wxWindow *parent, wxWindowID id,
// For debugging purposes, to see the background. // For debugging purposes, to see the background.
// SetBackground(wxBLUE_BRUSH); // SetBackground(wxBLUE_BRUSH);
m_needUpdating = FALSE;
} }
wxSplitterWindow::~wxSplitterWindow() wxSplitterWindow::~wxSplitterWindow()
@@ -149,6 +153,11 @@ void wxSplitterWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
DrawSash(dc); DrawSash(dc);
} }
void wxSplitterWindow::OnIdle(wxIdleEvent& WXUNUSED(event))
{
if (m_needUpdating)
SizeWindows();
}
void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
{ {
@@ -163,15 +172,6 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
SetCursor(wxCursor()); SetCursor(wxCursor());
#endif #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()) if (event.LeftDown())
{ {
@@ -181,7 +181,11 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
m_dragMode = wxSPLIT_DRAG_DRAGGING; m_dragMode = wxSPLIT_DRAG_DRAGGING;
if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
{
DrawSashTracker(x, y); DrawSashTracker(x, y);
}
m_oldX = x; m_oldX = x;
m_oldY = y; m_oldY = y;
return; return;
@@ -194,7 +198,10 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
ReleaseMouse(); ReleaseMouse();
// Erase old tracker // Erase old tracker
if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
{
DrawSashTracker(m_oldX, m_oldY); DrawSashTracker(m_oldX, m_oldY);
}
// Obtain window size. We are only interested in the dimension the sash // Obtain window size. We are only interested in the dimension the sash
// splits up // splits up
@@ -293,7 +300,10 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
} }
// Erase old tracker // Erase old tracker
if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
{
DrawSashTracker(m_oldX, m_oldY); DrawSashTracker(m_oldX, m_oldY);
}
if (m_splitMode == wxSPLIT_VERTICAL) if (m_splitMode == wxSPLIT_VERTICAL)
x = new_sash_position; x = new_sash_position;
@@ -321,8 +331,16 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
#endif // __WXMSW__ #endif // __WXMSW__
// Draw new one // Draw new one
if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
{
DrawSashTracker(m_oldX, m_oldY); DrawSashTracker(m_oldX, m_oldY);
} }
else
{
m_sashPosition = new_sash_position;
m_needUpdating = TRUE;
}
}
else if ( event.LeftDClick() ) else if ( event.LeftDClick() )
{ {
wxSplitterEvent eventSplitter(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED, wxSplitterEvent eventSplitter(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED,

View File

@@ -131,7 +131,7 @@ extern wxList wxPendingDelete;
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll; extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor; extern wxCursor g_globalCursor;
static bool g_capturing = FALSE; static wxWindow *g_captureWindow = (wxWindow*) NULL;
static wxWindow *g_focusWindow = (wxWindow*) NULL; static wxWindow *g_focusWindow = (wxWindow*) NULL;
/* hack: we need something to pass to gtk_menu_popup, so we store the time of /* 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 // Some control don't have their own X window and thus cannot get
// any events. // any events.
if (!g_capturing) if (!g_captureWindow)
{ {
wxNode *node = win->GetChildren().First(); wxNode *node = win->GetChildren().First();
while (node) 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 // Some control don't have their own X window and thus cannot get
// any events. // any events.
if (!g_capturing) if (!g_captureWindow)
{ {
wxNode *node = win->GetChildren().First(); wxNode *node = win->GetChildren().First();
while (node) 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 // Some control don't have their own X window and thus cannot get
// any events. // any events.
if (!g_capturing) if (!g_captureWindow)
{ {
wxNode *node = win->GetChildren().First(); wxNode *node = win->GetChildren().First();
while (node) while (node)
@@ -2803,35 +2803,33 @@ void wxWindow::CaptureMouse()
{ {
wxCHECK_RET( m_widget != NULL, _T("invalid window") ); 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(); GtkWidget *connect_widget = GetConnectWidget();
if (!connect_widget->window) return; if (!connect_widget->window) return;
gtk_grab_add( connect_widget );
gdk_pointer_grab( connect_widget->window, FALSE, gdk_pointer_grab( connect_widget->window, FALSE,
(GdkEventMask) (GdkEventMask)
(GDK_BUTTON_PRESS_MASK | (GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK), GDK_POINTER_MOTION_MASK),
(GdkWindow *) NULL, (GdkWindow *) NULL,
(GdkCursor *) NULL, m_cursor.GetCursor(),
GDK_CURRENT_TIME ); GDK_CURRENT_TIME );
g_capturing = TRUE; g_captureWindow = this;
} }
void wxWindow::ReleaseMouse() void wxWindow::ReleaseMouse()
{ {
wxCHECK_RET( m_widget != NULL, _T("invalid window") ); 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(); GtkWidget *connect_widget = GetConnectWidget();
if (!connect_widget->window) return; if (!connect_widget->window) return;
gtk_grab_remove( connect_widget );
gdk_pointer_ungrab ( GDK_CURRENT_TIME ); gdk_pointer_ungrab ( GDK_CURRENT_TIME );
g_capturing = FALSE; g_captureWindow = (wxWindow*) NULL;
} }
bool wxWindow::IsRetained() const bool wxWindow::IsRetained() const

View File

@@ -131,7 +131,7 @@ extern wxList wxPendingDelete;
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll; extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor; extern wxCursor g_globalCursor;
static bool g_capturing = FALSE; static wxWindow *g_captureWindow = (wxWindow*) NULL;
static wxWindow *g_focusWindow = (wxWindow*) NULL; static wxWindow *g_focusWindow = (wxWindow*) NULL;
/* hack: we need something to pass to gtk_menu_popup, so we store the time of /* 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 // Some control don't have their own X window and thus cannot get
// any events. // any events.
if (!g_capturing) if (!g_captureWindow)
{ {
wxNode *node = win->GetChildren().First(); wxNode *node = win->GetChildren().First();
while (node) 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 // Some control don't have their own X window and thus cannot get
// any events. // any events.
if (!g_capturing) if (!g_captureWindow)
{ {
wxNode *node = win->GetChildren().First(); wxNode *node = win->GetChildren().First();
while (node) 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 // Some control don't have their own X window and thus cannot get
// any events. // any events.
if (!g_capturing) if (!g_captureWindow)
{ {
wxNode *node = win->GetChildren().First(); wxNode *node = win->GetChildren().First();
while (node) while (node)
@@ -2803,35 +2803,33 @@ void wxWindow::CaptureMouse()
{ {
wxCHECK_RET( m_widget != NULL, _T("invalid window") ); 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(); GtkWidget *connect_widget = GetConnectWidget();
if (!connect_widget->window) return; if (!connect_widget->window) return;
gtk_grab_add( connect_widget );
gdk_pointer_grab( connect_widget->window, FALSE, gdk_pointer_grab( connect_widget->window, FALSE,
(GdkEventMask) (GdkEventMask)
(GDK_BUTTON_PRESS_MASK | (GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK), GDK_POINTER_MOTION_MASK),
(GdkWindow *) NULL, (GdkWindow *) NULL,
(GdkCursor *) NULL, m_cursor.GetCursor(),
GDK_CURRENT_TIME ); GDK_CURRENT_TIME );
g_capturing = TRUE; g_captureWindow = this;
} }
void wxWindow::ReleaseMouse() void wxWindow::ReleaseMouse()
{ {
wxCHECK_RET( m_widget != NULL, _T("invalid window") ); 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(); GtkWidget *connect_widget = GetConnectWidget();
if (!connect_widget->window) return; if (!connect_widget->window) return;
gtk_grab_remove( connect_widget );
gdk_pointer_ungrab ( GDK_CURRENT_TIME ); gdk_pointer_ungrab ( GDK_CURRENT_TIME );
g_capturing = FALSE; g_captureWindow = (wxWindow*) NULL;
} }
bool wxWindow::IsRetained() const bool wxWindow::IsRetained() const