/////////////////////////////////////////////////////////////////////////
//
// CDockPageBar Version 1.2
//
// Created: Mar 16, 2004
//
/////////////////////////////////////////////////////////////////////////
// Copyright (C) 2004 by Cuick. All rights reserved.
//
// This code is free for personal and commercial use, providing this
// notice remains intact in the source files and all eventual changes are
// clearly marked with comments.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc. to
// Cuick@163.net
//
// Hint: These classes are intended to be used as base classes. Do not
// simply add your code to these file - instead create a new class
// derived from CDockPageBar classes and put there what you need. See
// CTestBar classes in the demo projects for examples.
// Modify this file only to fix bugs, and don't forget to send me a copy.
/////////////////////////////////////////////////////////////////////////
// Acknowledgements:
// o 感谢Cristi Posea的CSizingControlBar
// o 借鉴了王骏的《轻松实现类VC界面》中的部分代码,在这里表示感谢。
// o 感谢hengai帮助修改了部分内存泄漏问题
// o 开发过程中遇到的问题得到了VC知识库论坛中很多人的帮助,这里一并感谢。
//
//////////////////////////////////////////////////////////////////////////
//Updates
//////////////////////////////////////////////////////////////////////////
// Author | Date | Description
//========================================================================
// Tony |2006-09-04 | Bugfixs:
//=======================| 1.add Timer TID_AUTO_HIDE_DELAY to prevent two
//tony__cb@hotmail.com | AHFloatWnds being displayed at the same time.
// | 2.focus switch problems(especially between AHFloatwnd and
// | DockPageBar).
// | 3.frequence screen flash on sizing the DockPageBar.
// | 4.resize the AHFloatWnds with the wider than the mainframe.
// | 5.link problems related with static MFC lib
// | by setting a new compile flag STATIC_MFC_LINK
// | 6.Verify the pWnd's style in CDockPageBar::AddPage function,
// | to make sure pWnd to have the WS_CHILD style, and to avoid
// | the window management disorder in clean up.
// | ------------------------------------------------
// | Improvements and new features:
// | 1.add the slide in/out animation display for AHFloatWnds
// | (the API ::AnimateWindow doesnt work for the self-draw window)
// | 2.make a lot of detail display changes(border,caption bar,...)
// | to have nicer windows
// | 3.add the new docking detection algorithm(accurate docking)
// | just as MS VC2003, but with the limitation that
// | the horizontal docking always has the higher priority.
// | 4.add the support for MDI style Frame
// | 5.rewrite the NcPaint,NcCalClient,OnNcLButtonXXXX,OnNcHitTest part
// | for CDockPageBar to draw the caption(griper),and item tab button
// | in the NcPaint.
// | 6.disable the DragShowContent mode in CSizingControlBar and
// | the OnNcPaint in CDockPageBar when sizing the bar to avoid
// | the dirty & flashy display
//=====================================================================================================
// Tony |2006-10-19 | Modification:
//=======================| 1. Improve the accurate docking feature,and now you can let the dock page bar
// tony__cb@hotmail.com | fill the entire space in the vertical direction.
// | 2. Fix the problem that the close button wrong behavior in the dock page bar.
//======================================================================================================
// DockPageBar.cpp : implementation file
//
#include "stdafx.h"
#include "DockPageBar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////
// delete the line between menu bar and tool bar
// From <afximpl.h>
struct AUX_DATA
{
int _unused1, _unused2;
int _unused3, _unused4;
int cxBorder2, cyBorder2;
};
extern __declspec(dllimport) AUX_DATA afxData;
class INIT_afxData
{
public:
INIT_afxData ()
{
afxData.cxBorder2 = afxData.cyBorder2 = 0;
}
} g_afxData2;
/////////////////////////////////////////////////////////////////////////
// CMyButton
CMyButton::CMyButton()
{
bRaised = FALSE;
bPushed = FALSE;
}
void CMyButton::Paint(CDC* pDC, BOOL isActive)
{
CRect rc = GetRect();
if (bPushed)
pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNSHADOW),
::GetSysColor(COLOR_BTNHIGHLIGHT));
else
if (bRaised)
pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNHIGHLIGHT),
::GetSysColor(COLOR_BTNSHADOW));
}
// draw close button
void CCloseButton::Paint(CDC* pDC, BOOL isActive)
{
CMyButton::Paint(pDC, isActive);
COLORREF clrOldTextColor = pDC->GetTextColor();
if(TRUE == isActive)
pDC->SetTextColor(RGB(255,255,255));
else
pDC->SetTextColor(RGB(0,0,0));
int nPrevBkMode = pDC->SetBkMode(TRANSPARENT);
CFont font;
int ppi = pDC->GetDeviceCaps(LOGPIXELSX);
int pointsize = MulDiv(75, 96, ppi); // 6 points at 96 ppi
font.CreatePointFont(pointsize, _T("Marlett"));
CFont* oldfont = pDC->SelectObject(&font);
pDC->TextOut(ptOrg.x + 2, ptOrg.y + 2, CString(_T("r"))); // x-like
pDC->SelectObject(oldfont);
pDC->SetBkMode(nPrevBkMode);
pDC->SetTextColor(clrOldTextColor);
}
CStudButton::CStudButton()
{
}
// draw stud
void CStudButton::Paint(CDC* pDC, BOOL isActive)
{
CMyButton::Paint(pDC, isActive);
HPEN oldPen;
CPen pen;
if(TRUE == isActive)
pen.CreatePen (PS_SOLID, 1, RGB(255,255,255));
else
pen.CreatePen (PS_SOLID, 1, RGB(0,0,0));
oldPen = (HPEN)pDC->SelectObject (pen);
if(FALSE == bFloat)
{
pDC->MoveTo (ptOrg.x + 4, ptOrg.y + 8);
pDC->LineTo (ptOrg.x + 4, ptOrg.y + 3);
pDC->LineTo (ptOrg.x + 8, ptOrg.y + 3);
pDC->LineTo (ptOrg.x + 8, ptOrg.y + 8);
pDC->MoveTo (ptOrg.x + 7, ptOrg.y + 3);
pDC->LineTo (ptOrg.x + 7, ptOrg.y + 8);
pDC->MoveTo (ptOrg.x + 2, ptOrg.y + 8);
pDC->LineTo (ptOrg.x + 11, ptOrg.y + 8);
pDC->MoveTo (ptOrg.x + 6, ptOrg.y + 8);
pDC->LineTo (ptOrg.x + 6, ptOrg.y + 12);
}
else
{
pDC->MoveTo (ptOrg.x + 5, ptOrg.y + 4);
pDC->LineTo (ptOrg.x + 10, ptOrg.y + 4);
pDC->LineTo (ptOrg.x + 10, ptOrg.y + 8);
pDC->LineTo (ptOrg.x + 5, ptOrg.y + 8);
pDC->MoveTo (ptOrg.x + 5, ptOrg.y + 7);
pDC->LineTo (ptOrg.x + 10, ptOrg.y + 7);
pDC->MoveTo (ptOrg.x + 5, ptOrg.y + 2);
pDC->LineTo (ptOrg.x + 5, ptOrg.y + 11);
pDC->MoveTo (ptOrg.x + 1, ptOrg.y + 6);
pDC->LineTo (ptOrg.x + 5, ptOrg.y + 6);
}
pDC->SelectObject(oldPen);
}
/////////////////////////////////////////////////////////////////////////////
// CPageItem
void CPageItem::Draw(CDC *pDC, BOOL bActive)
{
CRect rect = m_rect;
COLORREF crOldText;
rect.top +=2;
if(bActive)
{
rect.bottom -= 2;
CRect rcButton=rect;
rcButton.DeflateRect(-1,0,0,-2);
CBrush brush(GetSysColor(COLOR_3DFACE));
pDC->FillRect(rcButton,&brush);
CPen pen(PS_SOLID,1,GetSysColor(COLOR_3DDKSHADOW));
HPEN oldPen = (HPEN)pDC->SelectObject (&pen);
pDC->MoveTo (rect.left-1 , rect.bottom+2 );
pDC->LineTo (rect.right ,rect.bottom+2);
pDC->MoveTo (rect.right-1, rect.top);
pDC->LineTo (rect.right-1,rect.bottom+3 );
pDC->SelectObject (oldPen);
crOldText = pDC->SetTextCol