#endif
#ifndef WX_PRECOMP
- #include "wx/wx.h"
+ #include "wx/window.h"
+ #include "wx/dialog.h"
+ #include "wx/frame.h"
#endif
#include <stdlib.h>
#include "wx/string.h"
#include "wx/splitter.h"
#include "wx/dcscreen.h"
+#include "wx/settings.h"
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindow, wxWindow)
IMPLEMENT_DYNAMIC_CLASS(wxSplitterEvent, wxCommandEvent)
EVT_SPLITTER_DCLICK(-1, wxSplitterWindow::OnDoubleClick)
EVT_SPLITTER_UNSPLIT(-1, wxSplitterWindow::OnUnsplitEvent)
END_EVENT_TABLE()
-#endif
wxSplitterWindow::wxSplitterWindow()
{
void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
{
- long x = event.GetX();
- long y = event.GetY();
+ wxCoord x = (wxCoord)event.GetX(),
+ y = (wxCoord)event.GetY();
// reset the cursor
#ifdef __WXMOTIF__
m_dragMode = wxSPLIT_DRAG_DRAGGING;
if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
- {
- DrawSashTracker(x, y);
- }
-
+ {
+ DrawSashTracker(x, y);
+ }
+
m_oldX = x;
m_oldY = y;
+
+ if ( m_splitMode == wxSPLIT_VERTICAL )
+ {
+ SetCursor(*m_sashCursorWE);
+ }
+ else
+ {
+ SetCursor(*m_sashCursorNS);
+ }
return;
}
}
// Erase old tracker
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
}
#endif // __WXGTK__
}
- else if (event.Dragging() && (m_dragMode == wxSPLIT_DRAG_DRAGGING))
+ else if (event.Dragging() && (m_dragMode == wxSPLIT_DRAG_DRAGGING))
{
+#ifdef __WXMSW__
+ // Otherwise, the cursor sometimes reverts to the normal cursor
+ // during dragging.
+ if ( m_splitMode == wxSPLIT_VERTICAL )
+ {
+ SetCursor(*m_sashCursorWE);
+ }
+ else
+ {
+ SetCursor(*m_sashCursorNS);
+ }
+#endif
+
// Obtain window size. We are only interested in the dimension the sash
// splits up
int new_sash_position =
// Erase old tracker
if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
- {
+ {
DrawSashTracker(m_oldX, m_oldY);
- }
+ }
if (m_splitMode == wxSPLIT_VERTICAL)
x = new_sash_position;
// Draw new one
if ((GetWindowStyleFlag() & wxSP_LIVE_UPDATE) == 0)
- {
+ {
DrawSashTracker(m_oldX, m_oldY);
- }
- else
- {
+ }
+ else
+ {
m_sashPosition = new_sash_position;
- m_needUpdating = TRUE;
- }
+ m_needUpdating = TRUE;
+ }
}
else if ( event.LeftDClick() )
{
if ( dialog )
iconized = dialog->IsIconized();
else
- wxFAIL_MSG(_T("should have a top level frame or dialog parent!"));
+ wxFAIL_MSG(wxT("should have a top level frame or dialog parent!"));
}
if ( iconized )
else
return FALSE;
}
-
- return FALSE;
}
// Draw 3D effect borders
if ( GetWindowStyleFlag() & wxSP_3D )
{
+
+ dc.SetPen(*m_facePen);
+ dc.SetBrush(*m_faceBrush);
+ dc.DrawRectangle(1, 1 , w-1, m_borderSize-2 ); //high
+ dc.DrawRectangle(1, m_borderSize-2 , m_borderSize-2, h-1 ); // left
+ dc.DrawRectangle(w-m_borderSize+2, m_borderSize-2 , w-1, h-1 ); // right
+ dc.DrawRectangle(m_borderSize-2, h-m_borderSize+2 , w-m_borderSize+2, h-1 ); //bottom
+
dc.SetPen(*m_mediumShadowPen);
- dc.DrawLine(0, 0, w-1, 0);
- dc.DrawLine(0, 0, 0, h - 1);
+ dc.DrawLine(m_borderSize-2, m_borderSize-2, w-m_borderSize+1, m_borderSize-2);
+ dc.DrawLine(m_borderSize-2, m_borderSize-2, m_borderSize-2, h-m_borderSize+1);
dc.SetPen(*m_darkShadowPen);
- dc.DrawLine(1, 1, w-2, 1);
- dc.DrawLine(1, 1, 1, h-2);
+ dc.DrawLine(m_borderSize-1, m_borderSize-1, w-m_borderSize, m_borderSize-1);
+ dc.DrawLine(m_borderSize-1, m_borderSize-1, m_borderSize-1, h-m_borderSize);
dc.SetPen(*m_hilightPen);
- dc.DrawLine(0, h-1, w-1, h-1);
- dc.DrawLine(w-1, 0, w-1, h); // Surely the maximum y pos. should be h - 1.
+ dc.DrawLine(m_borderSize - 2, h-m_borderSize+1, w-m_borderSize+1, h-m_borderSize+1);
+ dc.DrawLine(w-m_borderSize+1, m_borderSize - 2, w-m_borderSize+1, h-m_borderSize+2); // Surely the maximum y pos. should be h - 1.
/// Anyway, h is required for MSW.
dc.SetPen(*m_lightShadowPen);
- dc.DrawLine(w-2, 1, w-2, h-2); // Right hand side
- dc.DrawLine(1, h-2, w-1, h-2); // Bottom
+ dc.DrawLine(w-m_borderSize, m_borderSize-1, w-m_borderSize, h-m_borderSize); // Right hand side
+ dc.DrawLine(m_borderSize-1, h-m_borderSize, w-m_borderSize+1, h-m_borderSize); // Bottom
}
else if ( GetWindowStyleFlag() & wxSP_BORDER )
{
{
dc.SetPen(*m_facePen);
dc.SetBrush(*m_faceBrush);
- dc.DrawRectangle(m_sashPosition + 2, 0, m_sashSize - 4, h);
+ dc.DrawRectangle(m_sashPosition + 2, 0 , m_sashSize - 4, h );
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.SetPen(*m_lightShadowPen);
- dc.DrawLine(m_sashPosition, 1, m_sashPosition, h-2);
+ int xShadow = m_borderSize ? m_borderSize - 1 : 0 ;
+ dc.DrawLine(m_sashPosition, xShadow , m_sashPosition, h-m_borderSize);
dc.SetPen(*m_hilightPen);
- dc.DrawLine(m_sashPosition+1, 0, m_sashPosition+1, h);
+ dc.DrawLine(m_sashPosition+1, m_borderSize - 2, m_sashPosition+1, h - m_borderSize+2);
dc.SetPen(*m_mediumShadowPen);
- dc.DrawLine(m_sashPosition+m_sashSize-2, 1, m_sashPosition+m_sashSize-2, h-1);
+ int yMedium = m_borderSize ? h-m_borderSize+1 : h ;
+ dc.DrawLine(m_sashPosition+m_sashSize-2, xShadow, m_sashPosition+m_sashSize-2, yMedium);
dc.SetPen(*m_darkShadowPen);
- dc.DrawLine(m_sashPosition+m_sashSize-1, 2, m_sashPosition+m_sashSize-1, h-2);
+ dc.DrawLine(m_sashPosition+m_sashSize-1, m_borderSize, m_sashPosition+m_sashSize-1, h-m_borderSize );
}
else
{
dc.SetPen(*m_facePen);
dc.SetBrush(*m_faceBrush);
- dc.DrawRectangle(0, m_sashPosition + 2, w, m_sashSize - 4);
+ dc.DrawRectangle( m_borderSize-2, m_sashPosition + 2, w-m_borderSize+2, m_sashSize - 4);
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.SetPen(*m_lightShadowPen);
- dc.DrawLine(1, m_sashPosition, w-2, m_sashPosition);
+ dc.DrawLine(m_borderSize-1, m_sashPosition, w-m_borderSize, m_sashPosition);
dc.SetPen(*m_hilightPen);
- dc.DrawLine(0, m_sashPosition+1, w, m_sashPosition+1);
+ dc.DrawLine(m_borderSize-2, m_sashPosition+1, w-m_borderSize+1, m_sashPosition+1);
dc.SetPen(*m_mediumShadowPen);
- dc.DrawLine(1, m_sashPosition+m_sashSize-2, w-1, m_sashPosition+m_sashSize-2);
+ dc.DrawLine(m_borderSize-1, m_sashPosition+m_sashSize-2, w-m_borderSize+1, m_sashPosition+m_sashSize-2);
dc.SetPen(*m_darkShadowPen);
- dc.DrawLine(2, m_sashPosition+m_sashSize-1, w-2, m_sashPosition+m_sashSize-1);
+ dc.DrawLine(m_borderSize, m_sashPosition+m_sashSize-1, w-m_borderSize, m_sashPosition+m_sashSize-1);
}
}
else
if ( m_windowOne && !m_windowTwo )
{
m_windowOne->SetSize(m_borderSize, m_borderSize, w - 2*m_borderSize, h - 2*m_borderSize);
-
- if (m_windowOne->GetAutoLayout())
- m_windowOne->Layout();
+
}
else if ( m_windowOne && m_windowTwo )
{
m_windowOne->SetSize(x1, y1, w1, h1);
m_windowTwo->SetSize(x2, y2, w2, h2);
-
- if (m_windowOne->GetAutoLayout())
- m_windowOne->Layout();
- if (m_windowTwo->GetAutoLayout())
- m_windowTwo->Layout();
+
}
else
{
w - 2*m_borderSize, m_sashPosition - m_borderSize);
m_windowTwo->SetSize(m_borderSize, m_sashPosition + m_sashSize,
w - 2*m_borderSize, h - 2*m_borderSize - m_sashSize - (m_sashPosition - m_borderSize));
-
- if (m_windowOne->GetAutoLayout())
- m_windowOne->Layout();
- if (m_windowTwo->GetAutoLayout())
- m_windowTwo->Layout();
+
}
}
wxClientDC dc(this);
- DrawBorders(dc);
+ if ( m_borderSize > 0 )
+ DrawBorders(dc);
DrawSash(dc);
}
}
else
{
- wxFAIL_MSG(_T("splitter: attempt to remove a non-existent window"));
+ wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
return FALSE;
}
// Replace a window with another one
bool wxSplitterWindow::ReplaceWindow(wxWindow *winOld, wxWindow *winNew)
{
- wxCHECK_MSG( winOld, FALSE, _T("use one of Split() functions instead") );
- wxCHECK_MSG( winNew, FALSE, _T("use Unsplit() functions instead") );
+ wxCHECK_MSG( winOld, FALSE, wxT("use one of Split() functions instead") );
+ wxCHECK_MSG( winNew, FALSE, wxT("use Unsplit() functions instead") );
if ( winOld == m_windowTwo )
{
}
else
{
- wxFAIL_MSG(_T("splitter: attempt to replace a non-existent window"));
+ wxFAIL_MSG(wxT("splitter: attempt to replace a non-existent window"));
return FALSE;
}
// for compatibility, call the virtual function
OnDoubleClickSash(event.GetX(), event.GetY());
- if ( GetMinimumPaneSize() == 0
- || m_permitUnsplitAlways)
+ if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways )
{
Unsplit();
}
{
wxWindow *win = event.GetWindowBeingRemoved();
+ // do it before calling OnUnsplit() which may delete the window
+ win->Show(FALSE);
+
// for compatibility, call the virtual function
OnUnsplit(win);
-
- win->Show(FALSE);
}