Fixed bug [ 597643 ] SashWindow-borders cause sticky arrow

Needed an OnSetCursor as per splitter window, for MSW only.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17319 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2002-09-21 14:16:24 +00:00
parent 69c18e92a0
commit b2162f4c83
3 changed files with 63 additions and 17 deletions

View File

@@ -144,6 +144,11 @@ public:
// Adjusts the panes // Adjusts the panes
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);
#ifdef __WXMSW__
// Handle cursor correctly
void OnSetCursor(wxSetCursorEvent& event);
#endif // wxMSW
// Draws borders // Draws borders
void DrawBorders(wxDC& dc); void DrawBorders(wxDC& dc);
@@ -189,6 +194,7 @@ private:
wxColour m_hilightColour; wxColour m_hilightColour;
wxColour m_faceColour; wxColour m_faceColour;
bool m_mouseCaptured; bool m_mouseCaptured;
wxCursor* m_currentCursor;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@@ -46,6 +46,10 @@ BEGIN_EVENT_TABLE(wxSashWindow, wxWindow)
EVT_PAINT(wxSashWindow::OnPaint) EVT_PAINT(wxSashWindow::OnPaint)
EVT_SIZE(wxSashWindow::OnSize) EVT_SIZE(wxSashWindow::OnSize)
EVT_MOUSE_EVENTS(wxSashWindow::OnMouseEvent) EVT_MOUSE_EVENTS(wxSashWindow::OnMouseEvent)
#ifdef __WXMSW__
EVT_SET_CURSOR(wxSashWindow::OnSetCursor)
#endif // wxMSW
END_EVENT_TABLE() END_EVENT_TABLE()
bool wxSashWindow::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, bool wxSashWindow::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos,
@@ -77,6 +81,7 @@ void wxSashWindow::Init()
m_sashCursorWE = new wxCursor(wxCURSOR_SIZEWE); m_sashCursorWE = new wxCursor(wxCURSOR_SIZEWE);
m_sashCursorNS = new wxCursor(wxCURSOR_SIZENS); m_sashCursorNS = new wxCursor(wxCURSOR_SIZENS);
m_mouseCaptured = FALSE; m_mouseCaptured = FALSE;
m_currentCursor = NULL;
// Eventually, we'll respond to colour change messages // Eventually, we'll respond to colour change messages
InitColours(); InitColours();
@@ -86,9 +91,7 @@ void wxSashWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
{ {
wxPaintDC dc(this); wxPaintDC dc(this);
// if ( m_borderSize > 0 )
DrawBorders(dc); DrawBorders(dc);
DrawSashes(dc); DrawSashes(dc);
} }
@@ -99,15 +102,6 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event)
wxSashEdgePosition sashHit = SashHitTest(x, y); wxSashEdgePosition sashHit = SashHitTest(x, y);
// reset the cursor
#if defined(__WXMOTIF__) || defined(__WXGTK__)
// Not necessary and in fact inhibits proper cursor setting (JACS 8/2000)
//SetCursor(* wxSTANDARD_CURSOR);
#endif
#ifdef __WXMSW__
SetCursor(wxNullCursor);
#endif
if (event.LeftDown()) if (event.LeftDown())
{ {
CaptureMouse(); CaptureMouse();
@@ -138,13 +132,21 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event)
m_firstY = y; m_firstY = y;
if ( (sashHit == wxSASH_LEFT) || (sashHit == wxSASH_RIGHT) ) if ( (sashHit == wxSASH_LEFT) || (sashHit == wxSASH_RIGHT) )
{
if (m_currentCursor != m_sashCursorWE)
{ {
SetCursor(*m_sashCursorWE); SetCursor(*m_sashCursorWE);
} }
m_currentCursor = m_sashCursorWE;
}
else else
{
if (m_currentCursor != m_sashCursorNS)
{ {
SetCursor(*m_sashCursorNS); SetCursor(*m_sashCursorNS);
} }
m_currentCursor = m_sashCursorNS;
}
} }
} }
else if ( event.LeftUp() && m_dragMode == wxSASH_DRAG_LEFT_DOWN ) else if ( event.LeftUp() && m_dragMode == wxSASH_DRAG_LEFT_DOWN )
@@ -295,17 +297,26 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event)
if ( sashHit != wxSASH_NONE ) if ( sashHit != wxSASH_NONE )
{ {
if ( (sashHit == wxSASH_LEFT) || (sashHit == wxSASH_RIGHT) ) if ( (sashHit == wxSASH_LEFT) || (sashHit == wxSASH_RIGHT) )
{
if (m_currentCursor != m_sashCursorWE)
{ {
SetCursor(*m_sashCursorWE); SetCursor(*m_sashCursorWE);
} }
m_currentCursor = m_sashCursorWE;
}
else else
{
if (m_currentCursor != m_sashCursorNS)
{ {
SetCursor(*m_sashCursorNS); SetCursor(*m_sashCursorNS);
} }
m_currentCursor = m_sashCursorNS;
}
} }
else else
{ {
SetCursor(wxNullCursor); SetCursor(wxNullCursor);
m_currentCursor = NULL;
} }
} }
else if ( event.Dragging() && else if ( event.Dragging() &&
@@ -313,13 +324,21 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event)
(m_dragMode == wxSASH_DRAG_LEFT_DOWN)) ) (m_dragMode == wxSASH_DRAG_LEFT_DOWN)) )
{ {
if ( (m_draggingEdge == wxSASH_LEFT) || (m_draggingEdge == wxSASH_RIGHT) ) if ( (m_draggingEdge == wxSASH_LEFT) || (m_draggingEdge == wxSASH_RIGHT) )
{
if (m_currentCursor != m_sashCursorWE)
{ {
SetCursor(*m_sashCursorWE); SetCursor(*m_sashCursorWE);
} }
m_currentCursor = m_sashCursorWE;
}
else else
{
if (m_currentCursor != m_sashCursorNS)
{ {
SetCursor(*m_sashCursorNS); SetCursor(*m_sashCursorNS);
} }
m_currentCursor = m_sashCursorNS;
}
if (m_dragMode == wxSASH_DRAG_LEFT_DOWN) if (m_dragMode == wxSASH_DRAG_LEFT_DOWN)
{ {
@@ -683,4 +702,23 @@ void wxSashWindow::SetSashVisible(wxSashEdgePosition edge, bool sash)
m_sashes[edge].m_margin = 0; m_sashes[edge].m_margin = 0;
} }
#ifdef __WXMSW__
// this is currently called (and needed) under MSW only...
void wxSashWindow::OnSetCursor(wxSetCursorEvent& event)
{
// if we don't do it, the resizing cursor might be set for child window:
// and like this we explicitly say that our cursor should not be used for
// children windows which overlap us
if ( SashHitTest(event.GetX(), event.GetY()) != wxSASH_NONE)
{
// default processing is ok
event.Skip();
}
//else: do nothing, in particular, don't call Skip()
}
#endif // wxMSW
#endif // wxUSE_SASH #endif // wxUSE_SASH

View File

@@ -3499,6 +3499,8 @@ bool wxWindowMSW::HandleSetCursor(WXHWND WXUNUSED(hWnd),
if ( hcursor ) if ( hcursor )
{ {
// wxLogDebug("HandleSetCursor: Setting cursor %ld", (long) hcursor);
::SetCursor(hcursor); ::SetCursor(hcursor);
// cursor set, stop here // cursor set, stop here