// Copyright (c) 2002
// Sergey Klimov (kidd@ukr.net)
// WTL Docking windows
//
// This code is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is
// not sold for profit without the authors written consent, and
// providing that this notice and the authors name is included. If
// the source code in this file is used in any commercial application
// then a simple email woulod be nice.
#if !defined(AFX_DOCKMISC_H__2A1A3052_6F61_4F89_A2C4_AAAC46D67AF1__INCLUDED_)
#define AFX_DOCKMISC_H__2A1A3052_6F61_4F89_A2C4_AAAC46D67AF1__INCLUDED_
#ifndef __ATLMISC_H__
#error dockmisk.h requires atlmisc.h to be included first
#endif
#include <cassert>
#include <SimpleSplitterBar.h>
namespace dockwins{
template <class TSplitterBar,/* DWORD TDockFrameStyle=0,*/
DWORD t_dwStyle = 0, DWORD t_dwExStyle = 0>
struct CDockingFrameTraitsT : CWinTraits <t_dwStyle,t_dwExStyle>
{
typedef TSplitterBar CSplitterBar;
};
typedef CDockingFrameTraitsT< CSimpleSplitterBar<5>,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE> CDockingFrameTraits;
//////////////////messages///////////////////////////
#define WMDF_FIRST (WM_USER)
#define WMDF_LAST (WMDF_FIRST+2)
#define WMDF_STYLE (WMDF_FIRST)
//wParam MAKEWPARAM(bUpdate,SET=TRUE\GET=FALSE)
//lParam style
//result = previouse style
#define WMDF_NDOCKSTATECHANGED (WMDF_FIRST+1)
//wParam MAKEWPARAM(DOCK=TRUE\UNDOCK=FALSE,bHorizontal)
//lParam hBar
#define DOCKED2HORIZONTAL(wParam) (HIWORD(wParam))
#define WMDF_DOCK (WMDF_FIRST+2)
//WMDF_DOCK'z codes:
#define DC_ACCEPT (1)
#define DC_DOCK (2)
#define DC_UNDOCK (3)
#define DC_GETDOCKPOSITION (4)
#define DC_SETDOCKPOSITION (5)
#define DC_ADJUSTDRAGRECT (7)
#define DC_REPLACE (8)
#define DC_ISBOX (9)
#define DC_ACTIVATE (10)
#define HDOCKBAR HWND
#define HNONDOCKBAR (0)
//WMDF_DOCK'z structures
typedef struct tagDFMHDR
{
HWND hWnd;
HDOCKBAR hBar;
UINT code;
}DFMHDR;
typedef struct tagDFDOCKREPLACE
{
DFMHDR hdr;
HWND hWnd;
}DFDOCKREPLACE;
typedef struct tagDFDOCKRECT
{
DFMHDR hdr;
RECT rect;
}DFDOCKRECT;
typedef struct tagDFDOCKPOS
{
DFMHDR hdr;
DWORD dwDockSide;
union
{
struct
{
unsigned long nBar;
float fPctPos;
unsigned long nWidth;
unsigned long nHeight;
};
RECT rcFloat;
};
unsigned long nIndex;
}DFDOCKPOS;
typedef struct tagDFDOCKPOSEX
{
DFDOCKPOS dockPos;
RECT rect;
BOOL bDocking;
BOOL bVisible;
} DFDOCKPOSEX;
class CDockingBarStyle
{
typedef CDockingBarStyle thisClass;
public:
enum
{
mskOrientation=0x00000001, //horizontal or vertical
mskGhostDrag=0x00000002, //Show window contents while dragging
mskIgnoreSysSettings=0x00000004 //depend on system setings (Show window contents while dragging)
};
enum
{
sHorizontal=0,
sVertical=mskOrientation,
sFullDrag=0,
sGhostDrag=mskGhostDrag,
sUseSysSettings=0,
sIgnoreSysSettings=mskIgnoreSysSettings
};
CDockingBarStyle(DWORD style=0)
:m_style(style)
{
}
bool IsHorizontal() const
{
return ((m_style&mskOrientation)==0);
}
bool IgnoreSystemSettings() const
{
return ((m_style&mskIgnoreSysSettings)!=0);
}
bool GhostDrag() const
{
return ((m_style&mskGhostDrag)!=0);
}
CDockingBarStyle Set(CDockingBarStyle style)
{
m_style=style;
return *this;
}
CDockingBarStyle Set(DWORD mask,CDockingBarStyle style)
{
m_style&=(~mask);
m_style|=style;
return *this;
}
CDockingBarStyle Toggle(DWORD mask)
{
DWORD imask=~mask;
DWORD tmask=(~m_style)&mask;
m_style=(m_style&imask)|tmask;
return *this;
}
operator DWORD() const
{
return m_style;
}
static CDockingBarStyle GetStyle(HDOCKBAR hBar)
{
assert(::IsWindow(hBar));
return CDockingBarStyle(::SendMessage(hBar,WMDF_STYLE,NULL,NULL));
}
static CDockingBarStyle SetStyle(HDOCKBAR hBar,CDockingBarStyle style,bool bUpdate=true)
{
assert(::IsWindow(hBar));
return CDockingBarStyle(::SendMessage(hBar,WMDF_STYLE,MAKEWPARAM(TRUE,bUpdate),style));
}
protected:
DWORD m_style;
};
class CDockingSide
{
enum
{
mskVertical=1, //horizontal or vertical
mskTop=2, //top or bottom
mskSide=3
};
public:
enum
{
sTop=2,sBottom=0,
sLeft=3,sRight=1,
sSingle=4, // only one window in row (or col)
sInvalid=8
};
CDockingSide(DWORD side):m_side(side)
{
}
bool IsHorizontal() const
{
assert(IsValid());
return ((m_side&mskVertical)==0);
}
bool IsTop() const
{
assert(IsValid());
return ((m_side&mskTop)!=0);
}
DWORD Side() const
{
assert(IsValid());
return m_side&mskSide;
}
bool IsSingle() const
{
assert(IsValid());
return ((m_side&sSingle)!=0);
}
bool IsValid() const
{
return ((m_side&sInvalid)==0);
}
static void Invalidate(DWORD& side)
{
side=sInvalid;
}
operator DWORD() const
{
return m_side;
}
protected:
DWORD m_side;
};
class COrientedRect : public CRect
{
public:
COrientedRect(bool bHorizontal,unsigned long thickness)
:m_thickness(thickness),m_bHorizontal(bHorizontal)
{
}
void SetOrientation(bool bHorizontal)
{
m_bHorizontal=bHorizontal;
}
bool GetOrientation() const
{
return m_bHorizontal;
}
bool IsHorizontal() const
{
return m_bHorizontal;
}
long GetThickness() const
{
return m_thickness;
}
bool CalculateRect(CRect& rc,bool bTop)
{
CopyRect(rc);
if(IsHorizontal())
{
if(bTop)
rc.top=bottom=top+GetThickness();
else
rc.bottom=top=bottom-GetThickness();
}
else
{
if(bTop)
rc.left=right=left+GetThickness();
else
rc.right=left=right-GetThickness();
}
return true;
}
protected:
bool m_bHorizontal;
unsigned long m_thickness;
};
}//namespace dockwins
#endif // !defined(AFX_DOCKMISC_H__2A1A3052_6F61_4F89_A2C4_AAAC46D67AF1__INCLUDED_)};