fixed dead update splitters

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14347 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-02-22 15:08:27 +00:00
parent f1c8426195
commit 153b7996e5
2 changed files with 38 additions and 38 deletions

View File

@@ -246,6 +246,9 @@ protected:
// set the real sash position, sashPos here must be positive // set the real sash position, sashPos here must be positive
void DoSetSashPosition(int sashPos); void DoSetSashPosition(int sashPos);
// set the cursor appropriate for the current split mode
void SetResizeCursor();
wxSplitMode m_splitMode; wxSplitMode m_splitMode;
bool m_permitUnsplitAlways; bool m_permitUnsplitAlways;
bool m_needUpdating; // when in live mode, set this to TRUE to resize children in idle bool m_needUpdating; // when in live mode, set this to TRUE to resize children in idle
@@ -258,11 +261,12 @@ protected:
int m_sashSize; // Sash width or height int m_sashSize; // Sash width or height
int m_sashPosition; // Number of pixels from left or top int m_sashPosition; // Number of pixels from left or top
int m_requestedSashPosition; int m_requestedSashPosition;
int m_sashPositionCurrent; // while dragging
int m_firstX; int m_firstX;
int m_firstY; int m_firstY;
int m_minimumPaneSize; int m_minimumPaneSize;
wxCursor* m_sashCursorWE; wxCursor m_sashCursorWE;
wxCursor* m_sashCursorNS; wxCursor m_sashCursorNS;
wxPen* m_sashTrackerPen; wxPen* m_sashTrackerPen;
wxPen* m_lightShadowPen; wxPen* m_lightShadowPen;
wxPen* m_mediumShadowPen; wxPen* m_mediumShadowPen;

View File

@@ -111,8 +111,8 @@ void wxSplitterWindow::Init()
m_borderSize = 2; m_borderSize = 2;
m_sashPosition = m_requestedSashPosition = 0; m_sashPosition = m_requestedSashPosition = 0;
m_minimumPaneSize = 0; m_minimumPaneSize = 0;
m_sashCursorWE = new wxCursor(wxCURSOR_SIZEWE); m_sashCursorWE = wxCursor(wxCURSOR_SIZEWE);
m_sashCursorNS = new wxCursor(wxCURSOR_SIZENS); m_sashCursorNS = wxCursor(wxCURSOR_SIZENS);
m_sashTrackerPen = new wxPen(*wxBLACK, 2, wxSOLID); m_sashTrackerPen = new wxPen(*wxBLACK, 2, wxSOLID);
m_lightShadowPen = (wxPen *) NULL; m_lightShadowPen = (wxPen *) NULL;
m_mediumShadowPen = (wxPen *) NULL; m_mediumShadowPen = (wxPen *) NULL;
@@ -131,8 +131,6 @@ void wxSplitterWindow::Init()
wxSplitterWindow::~wxSplitterWindow() wxSplitterWindow::~wxSplitterWindow()
{ {
delete m_sashCursorWE;
delete m_sashCursorNS;
delete m_sashTrackerPen; delete m_sashTrackerPen;
delete m_lightShadowPen; delete m_lightShadowPen;
delete m_darkShadowPen; delete m_darkShadowPen;
@@ -142,6 +140,12 @@ wxSplitterWindow::~wxSplitterWindow()
delete m_faceBrush; delete m_faceBrush;
} }
void wxSplitterWindow::SetResizeCursor()
{
SetCursor(m_splitMode == wxSPLIT_VERTICAL ? m_sashCursorWE
: m_sashCursorNS);
}
void wxSplitterWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) void wxSplitterWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
{ {
wxPaintDC dc(this); wxPaintDC dc(this);
@@ -167,14 +171,19 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
// reset the cursor // reset the cursor
#ifdef __WXMOTIF__ #ifdef __WXMOTIF__
SetCursor(* wxSTANDARD_CURSOR); SetCursor(* wxSTANDARD_CURSOR);
#endif #elif defined(__WXMSW__)
#ifdef __WXMSW__
SetCursor(wxCursor()); SetCursor(wxCursor());
#endif #endif
if (GetWindowStyle() & wxSP_NOSASH) if (GetWindowStyle() & wxSP_NOSASH)
return; return;
// with wxSP_LIVE_UPDATE style the splitter windows are always resized
// following the mouse movement while it drags the sash, without it we only
// draw the sash at the new position but only resize the windows when the
// dragging is finished
bool isLive = (GetWindowStyleFlag() & wxSP_LIVE_UPDATE) != 0;
if (event.LeftDown()) if (event.LeftDown())
{ {
if ( SashHitTest(x, y) ) if ( SashHitTest(x, y) )
@@ -183,22 +192,19 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
m_dragMode = wxSPLIT_DRAG_DRAGGING; m_dragMode = wxSPLIT_DRAG_DRAGGING;
if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0) if ( !isLive )
{ {
// remember the initial sash position and draw the initial
// shadow sash
m_sashPositionCurrent = m_sashPosition;
DrawSashTracker(x, y); DrawSashTracker(x, y);
} }
m_oldX = x; m_oldX = x;
m_oldY = y; m_oldY = y;
if ( m_splitMode == wxSPLIT_VERTICAL ) SetResizeCursor();
{
SetCursor(*m_sashCursorWE);
}
else
{
SetCursor(*m_sashCursorNS);
}
return; return;
} }
} }
@@ -209,7 +215,7 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
ReleaseMouse(); ReleaseMouse();
// Erase old tracker // Erase old tracker
if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0) if ( !isLive )
{ {
DrawSashTracker(m_oldX, m_oldY); DrawSashTracker(m_oldX, m_oldY);
} }
@@ -219,7 +225,8 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
// mouse has moved // mouse has moved
int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_oldX : y - m_oldY; int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_oldX : y - m_oldY;
int posSashNew = OnSashPositionChanging(m_sashPosition + diff); int posSashOld = isLive ? m_sashPosition : m_sashPositionCurrent;
int posSashNew = OnSashPositionChanging(posSashOld + diff);
if ( posSashNew == -1 ) if ( posSashNew == -1 )
{ {
// change not allowed // change not allowed
@@ -263,14 +270,7 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
// Just change the cursor if required // Just change the cursor if required
if ( SashHitTest(x, y) ) if ( SashHitTest(x, y) )
{ {
if ( m_splitMode == wxSPLIT_VERTICAL ) SetResizeCursor();
{
SetCursor(*m_sashCursorWE);
}
else
{
SetCursor(*m_sashCursorNS);
}
} }
#if defined(__WXGTK__) || defined(__WXMSW__) #if defined(__WXGTK__) || defined(__WXMSW__)
else else
@@ -290,19 +290,13 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
#ifdef __WXMSW__ #ifdef __WXMSW__
// Otherwise, the cursor sometimes reverts to the normal cursor // Otherwise, the cursor sometimes reverts to the normal cursor
// during dragging. // during dragging.
if ( m_splitMode == wxSPLIT_VERTICAL ) SetResizeCursor();
{
SetCursor(*m_sashCursorWE);
}
else
{
SetCursor(*m_sashCursorNS);
}
#endif // __WXMSW__ #endif // __WXMSW__
int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_oldX : y - m_oldY; int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_oldX : y - m_oldY;
int posSashNew = OnSashPositionChanging(m_sashPosition + diff); int posSashOld = isLive ? m_sashPosition : m_sashPositionCurrent;
int posSashNew = OnSashPositionChanging(posSashOld + diff);
if ( posSashNew == -1 ) if ( posSashNew == -1 )
{ {
// change not allowed // change not allowed
@@ -313,7 +307,7 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
return; return;
// Erase old tracker // Erase old tracker
if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0) if ( !isLive )
{ {
DrawSashTracker(m_oldX, m_oldY); DrawSashTracker(m_oldX, m_oldY);
} }
@@ -341,8 +335,10 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
#endif // __WXMSW__ #endif // __WXMSW__
// Draw new one // Draw new one
if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0) if ( !isLive )
{ {
m_sashPositionCurrent = posSashNew;
DrawSashTracker(m_oldX, m_oldY); DrawSashTracker(m_oldX, m_oldY);
} }
else else