#include "StdAfx.h"
#include "CeWnd.h"
#include "CeSplit.h"
void CeSplitFrame::GetWindowPlacements(CeRect& rc, CeRect& rcTop, CeRect& rcBottom)
{
if (GetSystemMetrics(SM_CXSCREEN) >= GetSystemMetrics(SM_CYSCREEN))
{
// HPC
rcTop = CeRect(rc.left, rc.top, rc.left + 2 * rc.Width() / 5, rc.bottom);
rcBottom = CeRect(rcTop.right, rc.top, rc.right, rc.bottom);
m_bVertical = false;
rcTop.right -= 3;
rcBottom.left += 3;
}
else
{
// PPC
rcTop = CeRect(rc.left, rc.top, rc.right, rc.top + rc.Height() / 2);
rcBottom = CeRect(rc.left, rcTop.bottom, rc.right, rc.bottom);
m_bVertical = true;
rcTop.bottom -= 3;
rcBottom.top += 3;
}
}
void CeSplitFrame::OnLButtonDown( UINT nFlags, POINT point, bool& bHandled )
{
bHandled = true;
SetCapture();
Invalidate();
m_bMoving = true;
}
void CeSplitFrame::OnLButtonUp( UINT nFlags, POINT point, bool& bHandled )
{
bHandled = true;
ReleaseCapture();
Invalidate();
m_bMoving = false;
}
void CeSplitFrame::OnMouseMove( UINT nFlags, POINT point, bool& bHandled )
{
bHandled = true;
if (m_bMoving)
{
CeRect rc, rcTop, rcBottom;
GetClientRect(rc);
#ifdef _WIN32_WCE
rc.top += m_cmdband.Height();
#endif
if (! m_bVertical)
{
// HPC
rcTop = CeRect(rc.left, rc.top, point.x - 3, rc.bottom);
rcBottom = CeRect(rcTop.right + 3, rc.top, rc.right, rc.bottom);
rcTop.right--;
rcBottom.left++;
}
else
{
// PPC
rcTop = CeRect(rc.left, rc.top, rc.right, point.y - 3);
rcBottom = CeRect(rc.left, rcTop.bottom + 3, rc.right, rc.bottom);
rcTop.bottom--;
rcBottom.top++;
}
if (rcTop.Height() >= 0 && rcBottom.Height() >= 0)
{
::MoveWindow(m_hwndTop, rcTop.left, rcTop.top, rcTop.Width(), rcTop.Height(), TRUE);
::MoveWindow(m_hwndBottom, rcBottom.left, rcBottom.top, rcBottom.Width(), rcBottom.Height(), TRUE);
}
}
}
//
// Paint the divider between the two panes
//
void CeSplitFrame::OnPaint( bool& bHandled )
{
bHandled = true;
PAINTSTRUCT ps;
HDC hDC = ::BeginPaint(*this, &ps);
CeRect rc;
::GetWindowRect(m_hwndTop, rc);
ScreenToClient(rc);
if (m_bVertical)
{
// PPC
rc.top = rc.bottom;
rc.bottom += 6;
rc.left -= 2;
rc.right += 2;
}
else
{
// HPC
rc.left = rc.right;
rc.right += 6;
rc.top -= 2;
rc.bottom += 2;
}
if (m_bMoving)
{
::SetBkColor(hDC, RGB(0,0,0));
::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
}
else
{
::DrawFrameControl(hDC, &rc, DFC_BUTTON, DFCS_BUTTONPUSH);
}
::EndPaint(*this, &ps);
}
//
// Incase we're sized, set to defaults
//
void CeSplitFrame::OnSize( UINT nType, int cx, int cy, bool& bHandled )
{
bHandled = false; // allow default
CeRect rc;
GetClientRect(&rc);
#ifdef _WIN32_WCE
rc.top += m_cmdband.Height();
#endif
CeRect rcTop, rcBottom;
GetWindowPlacements(rc, rcTop, rcBottom);
::MoveWindow(m_hwndBottom, rcBottom.left, rcBottom.top,
rcBottom.Width(), rcBottom.Height(), TRUE);
::MoveWindow(m_hwndTop, rcTop.left, rcTop.top,
rcTop.Width(), rcTop.Height(), TRUE);
TRACE0("Size Change\n");
}