Fixed design flaw in splitter window whereby you couldn't have a sash without

a border. Fixed sash layout window bug that didn't erase old sash on resize.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7273 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2000-04-25 14:35:58 +00:00
parent 37aba5df39
commit 2ba791ada8
11 changed files with 114 additions and 58 deletions

View File

@@ -21,7 +21,10 @@ The following styles apply in addition to the normal wxWindow styles.
\twocolwidtha{5cm}%
\begin{twocollist}\itemsep=0pt
\twocolitem{\windowstyle{wxSW\_3D}}{Draws the sashes in 3D.}
\twocolitem{\windowstyle{wxSW\_3D}}{Draws a 3D effect sash and border.}
\twocolitem{\windowstyle{wxSW\_3DSASH}}{Draws a 3D effect sash.}
\twocolitem{\windowstyle{wxSW\_3DBORDER}}{Draws a 3D effect border.}
\twocolitem{\windowstyle{wxSW\_BORDER}}{Draws a thin black border.}
\end{twocollist}
See also \helpref{window styles overview}{windowstyles}.

View File

@@ -13,7 +13,10 @@ This is also recommended for GTK.
\begin{twocollist}\itemsep=0pt
\twocolitem{\windowstyle{wxSP\_3D}}{Draws a 3D effect border and sash.}
\twocolitem{\windowstyle{wxSP\_BORDER}}{Draws a thin black border around the window, and a black sash.}
\twocolitem{\windowstyle{wxSP\_3DSASH}}{Draws a 3D effect sash.}
\twocolitem{\windowstyle{wxSP\_3DBORDER}}{Draws a 3D effect border.}
\twocolitem{\windowstyle{wxSP\_FULLSASH}}{Draws the ends of the sash (so the window can be used without a border).}
\twocolitem{\windowstyle{wxSP\_BORDER}}{Draws a thin black border around the window.}
\twocolitem{\windowstyle{wxSP\_NOBORDER}}{No border, and a black sash.}
\twocolitem{\windowstyle{wxSP\_PERMIT\_UNSPLIT}}{Always allow to
unsplit, even with the minimum pane size other than zero.}

View File

@@ -1117,10 +1117,14 @@ enum wxStretch
* wxSplitterWindow flags
*/
#define wxSP_NOBORDER 0x0000
#define wxSP_3D 0x0010
#define wxSP_NOSASH 0x0010
#define wxSP_BORDER 0x0020
#define wxSP_PERMIT_UNSPLIT 0x0040
#define wxSP_LIVE_UPDATE 0x0080
#define wxSP_3DSASH 0x0100
#define wxSP_3DBORDER 0x0200
#define wxSP_FULLSASH 0x0400
#define wxSP_3D (wxSP_3DBORDER | wxSP_3DSASH)
/*
* wxFrame extra flags

View File

@@ -204,7 +204,7 @@ public:
return LayoutWindow(frame, mainWindow);
}
// mainWindow is sized to whatever's left over. This function for backward
// mainWindow is sized to whatever's left over.
bool LayoutWindow(wxWindow* frame, wxWindow* mainWindow = (wxWindow*) NULL);
};

View File

@@ -55,8 +55,11 @@ public:
*/
#define wxSW_NOBORDER 0x0000
#define wxSW_3D 0x0010
//#define wxSW_3D 0x0010
#define wxSW_BORDER 0x0020
#define wxSW_3DSASH 0x0040
#define wxSW_3DBORDER 0x0080
#define wxSW_3D (wxSW_3DSASH | wxSW_3DBORDER)
/*
* wxSashWindow allows any of its edges to have a sash which can be dragged

View File

@@ -178,23 +178,26 @@ public:
void OnIdle(wxIdleEvent& event);
// Draws borders
void DrawBorders(wxDC& dc);
virtual void DrawBorders(wxDC& dc);
// Draws the sash
void DrawSash(wxDC& dc);
virtual void DrawSash(wxDC& dc);
// Draws the sash tracker (for whilst moving the sash)
void DrawSashTracker(int x, int y);
virtual void DrawSashTracker(int x, int y);
// Tests for x, y over sash
bool SashHitTest(int x, int y, int tolerance = 2);
virtual bool SashHitTest(int x, int y, int tolerance = 2);
// Resizes subwindows
void SizeWindows();
virtual void SizeWindows();
// Initialize colours
void InitColours();
void SetNeedUpdating(bool needUpdating) { m_needUpdating = needUpdating; }
bool GetNeedUpdating() const { return m_needUpdating ; }
protected:
// our event handlers
void OnSashPosChanged(wxSplitterEvent& event);
@@ -211,7 +214,7 @@ private:
int m_splitMode;
bool m_permitUnsplitAlways;
bool m_needUpdating; // when in live mode, set the to TRUE to resize children in idle
bool m_needUpdating; // when in live mode, set this to TRUE to resize children in idle
wxWindow* m_windowOne;
wxWindow* m_windowTwo;
int m_dragMode;

View File

@@ -157,7 +157,15 @@ void wxSashLayoutWindow::OnCalculateLayout(wxCalculateLayoutEvent& event)
{
// If not in query mode, resize the window.
// TODO: add wxRect& form to wxWindow::SetSize
wxSize sz = GetSize();
wxPoint pos = GetPosition();
SetSize(thisRect.x, thisRect.y, thisRect.width, thisRect.height);
// Make sure the sash is erased when the window is resized
if ((pos.x != thisRect.x || pos.y != thisRect.y || sz.x != thisRect.width || sz.y != thisRect.height) &&
(GetSashVisible(wxSASH_TOP) || GetSashVisible(wxSASH_RIGHT) || GetSashVisible(wxSASH_BOTTOM) || GetSashVisible(wxSASH_LEFT)))
Refresh(TRUE);
}
event.SetRect(clientSize);

View File

@@ -400,7 +400,7 @@ void wxSashWindow::DrawBorders(wxDC& dc)
wxPen lightShadowPen(m_lightShadowColour, 1, wxSOLID);
wxPen hilightPen(m_hilightColour, 1, wxSOLID);
if ( GetWindowStyleFlag() & wxSW_3D )
if ( GetWindowStyleFlag() & wxSW_3DBORDER )
{
dc.SetPen(mediumShadowPen);
dc.DrawLine(0, 0, w-1, 0);
@@ -465,7 +465,7 @@ void wxSashWindow::DrawSash(wxSashEdgePosition edge, wxDC& dc)
dc.SetBrush(faceBrush);
dc.DrawRectangle(sashPosition, 0, GetEdgeMargin(edge), h);
if (GetWindowStyleFlag() & wxSW_3D)
if (GetWindowStyleFlag() & wxSW_3DSASH)
{
if (edge == wxSASH_LEFT)
{
@@ -495,7 +495,7 @@ void wxSashWindow::DrawSash(wxSashEdgePosition edge, wxDC& dc)
dc.SetBrush(faceBrush);
dc.DrawRectangle(0, sashPosition, w, GetEdgeMargin(edge));
if (GetWindowStyleFlag() & wxSW_3D)
if (GetWindowStyleFlag() & wxSW_3DSASH)
{
if (edge == wxSASH_BOTTOM)
{

View File

@@ -64,21 +64,18 @@ bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id,
m_permitUnsplitAlways = (style & wxSP_PERMIT_UNSPLIT) != 0;
if ( style & wxSP_3D )
{
m_borderSize = 2;
if ( style & wxSP_3DSASH )
m_sashSize = 7;
}
else if ( style & wxSP_BORDER )
{
m_borderSize = 1;
m_sashSize = 3;
}
else
{
m_borderSize = 0;
m_sashSize = 3;
}
if ( style & wxSP_3DBORDER )
m_borderSize = 2;
else if ( style & wxSP_BORDER )
m_borderSize = 1;
else
m_borderSize = 0;
return TRUE;
}
@@ -156,6 +153,8 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
SetCursor(wxCursor());
#endif
if (GetWindowStyle() & wxSP_NOSASH)
return;
if (event.LeftDown())
{
@@ -439,7 +438,7 @@ void wxSplitterWindow::DrawBorders(wxDC& dc)
int w, h;
GetClientSize(&w, &h);
if ( GetWindowStyleFlag() & wxSP_3D )
if ( GetWindowStyleFlag() & wxSP_3DBORDER )
{
dc.SetPen(*m_facePen);
@@ -482,11 +481,13 @@ void wxSplitterWindow::DrawSash(wxDC& dc)
{
if ( m_sashPosition == 0 || !m_windowTwo)
return;
if (GetWindowStyle() & wxSP_NOSASH)
return;
int w, h;
GetClientSize(&w, &h);
if ( GetWindowStyleFlag() & wxSP_3D )
if ( GetWindowStyleFlag() & wxSP_3DSASH )
{
if ( m_splitMode == wxSPLIT_VERTICAL )
{
@@ -509,6 +510,18 @@ void wxSplitterWindow::DrawSash(wxDC& dc)
dc.SetPen(*m_darkShadowPen);
dc.DrawLine(m_sashPosition+m_sashSize-1, m_borderSize, m_sashPosition+m_sashSize-1, h-m_borderSize );
// Draw the top and bottom edges of the sash, if requested
if (GetWindowStyle() & wxSP_FULLSASH)
{
// Top
dc.SetPen(*m_hilightPen);
dc.DrawLine(m_sashPosition+1, m_borderSize, m_sashPosition+m_sashSize-1, m_borderSize);
// Bottom
dc.SetPen(*m_darkShadowPen);
dc.DrawLine(m_sashPosition+1, h-m_borderSize-1, m_sashPosition+m_sashSize-1, h-m_borderSize-1);
}
}
else
{
@@ -529,6 +542,18 @@ void wxSplitterWindow::DrawSash(wxDC& dc)
dc.SetPen(*m_darkShadowPen);
dc.DrawLine(m_borderSize, m_sashPosition+m_sashSize-1, w-m_borderSize, m_sashPosition+m_sashSize-1);
// Draw the left and right edges of the sash, if requested
if (GetWindowStyle() & wxSP_FULLSASH)
{
// Left
dc.SetPen(*m_hilightPen);
dc.DrawLine(m_borderSize, m_sashPosition, m_borderSize, m_sashPosition+m_sashSize);
// Right
dc.SetPen(*m_darkShadowPen);
dc.DrawLine(w-m_borderSize-1, m_sashPosition+1, w-m_borderSize-1, m_sashPosition+m_sashSize-1);
}
}
}
else
@@ -538,19 +563,28 @@ void wxSplitterWindow::DrawSash(wxDC& dc)
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxBLACK_BRUSH);
int h1 = h-1;
if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER )
int y1 = 0;
if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER )
h1 += 1; // Not sure why this is necessary...
dc.DrawRectangle(m_sashPosition, 0, m_sashSize, h1);
if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER)
{
y1 = 2; h1 -= 3;
}
dc.DrawRectangle(m_sashPosition, y1, m_sashSize, h1);
}
else
{
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxBLACK_BRUSH);
int w1 = w-1;
if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER )
int x1 = 0;
if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER )
w1 ++;
dc.DrawRectangle(0, m_sashPosition, w1, m_sashSize);
if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER)
{
x1 = 2; w1 -= 3;
}
dc.DrawRectangle(x1, m_sashPosition, w1, m_sashSize);
}
}
@@ -623,44 +657,42 @@ void wxSplitterWindow::SizeWindows()
int w, h;
GetClientSize(&w, &h);
if ( m_windowOne && !m_windowTwo )
if ( GetWindow1() && !GetWindow2() )
{
m_windowOne->SetSize(m_borderSize, m_borderSize, w - 2*m_borderSize, h - 2*m_borderSize);
GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(), w - 2*GetBorderSize(), h - 2*GetBorderSize());
}
else if ( m_windowOne && m_windowTwo )
else if ( GetWindow1() && GetWindow2() )
{
if (m_splitMode == wxSPLIT_VERTICAL)
if (GetSplitMode() == wxSPLIT_VERTICAL)
{
int x1 = m_borderSize;
int y1 = m_borderSize;
int w1 = m_sashPosition - m_borderSize;
int h1 = h - 2*m_borderSize;
int x1 = GetBorderSize();
int y1 = GetBorderSize();
int w1 = GetSashPosition() - GetBorderSize();
int h1 = h - 2*GetBorderSize();
int x2 = m_sashPosition + m_sashSize;
int y2 = m_borderSize;
int w2 = w - 2*m_borderSize - m_sashSize - w1;
int h2 = h - 2*m_borderSize;
m_windowOne->SetSize(x1, y1, w1, h1);
m_windowTwo->SetSize(x2, y2, w2, h2);
int x2 = GetSashPosition() + GetSashSize();
int y2 = GetBorderSize();
int w2 = w - 2*GetBorderSize() - GetSashSize() - w1;
int h2 = h - 2*GetBorderSize();
GetWindow1()->SetSize(x1, y1, w1, h1);
GetWindow2()->SetSize(x2, y2, w2, h2);
}
else
{
m_windowOne->SetSize(m_borderSize, m_borderSize,
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));
GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
w - 2*GetBorderSize(), GetSashPosition() - GetBorderSize());
GetWindow2()->SetSize(GetBorderSize(), GetSashPosition() + GetSashSize(),
w - 2*GetBorderSize(), h - 2*GetBorderSize() - GetSashSize() - (GetSashPosition() - GetBorderSize()));
}
}
wxClientDC dc(this);
if ( m_borderSize > 0 )
if ( GetBorderSize() > 0 )
DrawBorders(dc);
DrawSash(dc);
m_needUpdating = FALSE;
SetNeedUpdating(FALSE);
}
// Set pane for unsplit window

View File

@@ -89,7 +89,7 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
exstyle = GetExStyle(style, &want3D);
}
// all controls have these childs (wxWindows creates all controls visible
// all controls have these styles (wxWindows creates all controls visible
// by default)
style |= WS_CHILD | WS_VISIBLE;