📄 docktabsplitpane.h
字号:
}
void moveClientView( HWND sourceWnd, HWND targetWnd) {
ATLASSERT( ::IsWindow( sourceWnd));
ATLASSERT( ::IsWindow( targetWnd));
Pane* sourcePane = this->lookUpPane( sourceWnd);
Pane* targetPane = this->lookUpPane( targetWnd);
ATLASSERT( NULL != sourcePane);
ATLASSERT( NULL != targetPane);
this->setFocusTo( sourceWnd);
this->splitWithCurrentTab( sourcePane, targetPane, Pane::TabPaneHitTest_TabArea);
}
void moveClientViewsTo( SplitPane* targetPane) {
POSITION position = this->clientViewPaneMap.GetStartPosition();
if ( position) {
do {
Pane* pane;
HWND clientViewWnd;
this->clientViewPaneMap.GetNextAssoc( position, clientViewWnd, pane);
ClientProperties clientProperties;
if ( pane->get( clientViewWnd, clientProperties)) {
pane->removeClientView( clientViewWnd);
targetPane->append( clientProperties.caption, clientViewWnd, clientProperties.toolTip, clientProperties.imageIndex);
}
} while ( position);
this->removeAll();
this->currentPane = NULL;
this->rootWnd = NULL;
}
return;
}
HWND focusedClientView() const {
return this->currentPane->focusedClientView();
}
bool setFocusTo( long x, long y) {
CPoint hitPoint( x, y);
POSITION position = this->paneMap.GetStartPosition();
if ( position)
do {
Pane* pane = this->paneMap.GetNextValue( position);
CRect rect;
pane->GetWindowRect( rect);
if ( rect.PtInRect( hitPoint)) {
pane->SetFocus();
return true;
}
} while (position);
return false;
}
bool setFocusTo( HWND clientViewWnd) {
Pane* pane = this->lookUpPane( clientViewWnd);
if ( NULL != pane && pane->setFocusTo( clientViewWnd)) {
this->currentPane = pane;
return true;
}
return false;
}
bool append( const TCHAR* caption, HWND hWnd, const TCHAR* toolTip = NULL, int imageIndex = -1) {
ATLASSERT( NULL != hWnd);
this->currentPane->append( caption, hWnd, toolTip, imageIndex);
this->clientViewPaneMap[hWnd] = this->currentPane;
this->currentPane->updateLayout();
return true;
}
int getClientViewCount() {
return (int) this->clientViewPaneMap.GetCount();
}
bool detachClientView( HWND clientViewWnd) {
ATLASSERT( true);
Pane* pane = this->lookUpPane( clientViewWnd);
if ( NULL == pane)
return false;
if ( !pane->removeClientView( clientViewWnd))
return false;
this->clientViewPaneMap.RemoveKey( clientViewWnd);
::ShowWindow( clientViewWnd, FALSE);
if ( pane->isEmpty() && this->rootWnd != pane->m_hWnd) {
if ( pane->IsChild( clientViewWnd))
::SetParent( clientViewWnd, this->m_hWnd);
this->PostMessage( WM_USER_DESTROY_PANE, 0, (LPARAM) pane->m_hWnd);
}
return false;
}
void setImageList( HIMAGELIST imgList) {
this->imageList = imgList;
}
HIMAGELIST getImageList() const {
return this->imageList;
}
bool getClientViewRect( LPPOINT point, CRect& rect) {
ATLASSERT( point);
CPoint hitPoint( *point);
POSITION position = this->paneMap.GetStartPosition();
if ( position)
do {
Pane* pane = this->paneMap.GetNextValue( position);
if ( Pane::TabPaneHitTest_TabArea == pane->hitTest( &hitPoint)) {
pane->getTabPageRect( rect);
pane->ClientToScreen( rect);
return true;
}
} while (position);
return false;
}
// Overridables
static LPCTSTR GetWndCaption() {
return NULL;
}
HWND create( HWND hWndParent, ATL::_U_RECT rect = NULL) {
if ( NULL == this->GetWndClassInfo().m_lpszOrigName)
this->GetWndClassInfo().m_lpszOrigName = GetWndClassName();
ATOM atom = this->GetWndClassInfo().Register( &m_pfnSuperWindowProc);
int dwStyle = this->GetWndStyle( 0);
int dwExStyle = this->GetWndExStyle(0);
return CWindowImplBaseT< TBase, TWinTraits >::Create( hWndParent
, rect, NULL
, dwStyle
, dwExStyle
, ATL::_U_MENUorID( (UINT) 0)
, atom
, 0
);
}
// Event handlers
DECLARE_WND_CLASS( _T("SplitPane"))
BEGIN_MSG_MAP( SplitPane)
MESSAGE_HANDLER( WM_CREATE, OnCreate)
MESSAGE_HANDLER( WM_SIZE, OnSize)
MESSAGE_HANDLER( WM_ERASEBKGND, OnEraseBackground)
MESSAGE_HANDLER( WM_CLOSE, OnClose)
MESSAGE_HANDLER( WM_MOUSEACTIVATE, OnMouseActivate)
MESSAGE_HANDLER( WM_USER_DESTROY_PANE, OnDestroyPane);
END_MSG_MAP()
LRESULT OnMouseActivate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled){
LRESULT result = this->DefWindowProc( uMsg, wParam, lParam);
if ( MA_ACTIVATE == result || MA_ACTIVATEANDEAT == result)
this->SetFocus();
return result;
}
LRESULT OnClose( UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) {
POSITION position = this->clientViewPaneMap.GetStartPosition();
if ( position)
do {
HWND clientViewWnd = this->clientViewPaneMap.GetNextKey( position);
ATLASSERT( ::IsWindow( clientViewWnd)); // check if it's still window
if ( 0 != ::SendMessage( clientViewWnd, WM_CLOSE, 0, 0))
return 1;
} while ( position);
return 0;
}
LRESULT OnDestroyPane( UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) {
HWND srcPane = (HWND) lParam;
// determine a source pane
CAtlMap< HWND, Pane*>::CPair* sourcePanePair = this->paneMap.Lookup( srcPane);
if ( NULL == sourcePanePair)
return 1;
Pane* sourcePane;
sourcePane = sourcePanePair->m_value;
if ( NULL == sourcePane)
return 1;
HWND sourcePaneParentWnd = sourcePane->GetParent();
CAtlMap< HWND, HSplitter*>::CPair* horSplitPair;
CAtlMap< HWND, VSplitter*>::CPair* verSplitPair;
HWND neighbourWnd;
CRect neighbourRect;
if ( NULL != ( verSplitPair = this->verSplitterMap.Lookup( sourcePaneParentWnd))) {
// it is a vertical splitter
VSplitter* parentSplitter = verSplitPair->m_value;
neighbourWnd = parentSplitter->GetSplitterPane( SPLIT_PANE_LEFT);
if ( neighbourWnd == sourcePane->m_hWnd)
neighbourWnd = parentSplitter->GetSplitterPane( SPLIT_PANE_RIGHT);
HWND theParentWnd = ::GetParent( parentSplitter->m_hWnd);
::SetParent( neighbourWnd, theParentWnd);
if ( this->rootWnd == parentSplitter->m_hWnd)
this->rootWnd = neighbourWnd;
// find the parent of the parent splitter and replace the pane to the neighbour
if ( theParentWnd == this->m_hWnd) {
this->GetClientRect( &neighbourRect);
} else if ( NULL != ( verSplitPair = this->verSplitterMap.Lookup( theParentWnd))) {
VSplitter* theParent = verSplitPair->m_value;
if ( theParent->GetSplitterPane( SPLIT_PANE_LEFT) == parentSplitter->m_hWnd) {
theParent->SetSplitterPane( SPLIT_PANE_LEFT, neighbourWnd);
theParent->GetSplitterPaneRect( SPLIT_PANE_LEFT, &neighbourRect);
} else if ( theParent->GetSplitterPane( SPLIT_PANE_RIGHT) == parentSplitter->m_hWnd) {
theParent->SetSplitterPane( SPLIT_PANE_RIGHT, neighbourWnd);
theParent->GetSplitterPaneRect( SPLIT_PANE_RIGHT, &neighbourRect);
}
} else if ( NULL != ( horSplitPair = this->horSplitterMap.Lookup( theParentWnd))) {
HSplitter* theParent = horSplitPair->m_value;
if ( theParent->GetSplitterPane( SPLIT_PANE_LEFT) == parentSplitter->m_hWnd) {
theParent->SetSplitterPane( SPLIT_PANE_LEFT, neighbourWnd);
theParent->GetSplitterPaneRect( SPLIT_PANE_LEFT, &neighbourRect);
} else if ( theParent->GetSplitterPane( SPLIT_PANE_RIGHT) == parentSplitter->m_hWnd) {
theParent->SetSplitterPane( SPLIT_PANE_RIGHT, neighbourWnd);
theParent->GetSplitterPaneRect( SPLIT_PANE_RIGHT, &neighbourRect);
}
}
// delete the parent splitter
this->verSplitterMap.RemoveKey( parentSplitter->m_hWnd);
sourcePane->DestroyWindow();
parentSplitter->DestroyWindow();
delete parentSplitter;
} else if ( NULL != ( horSplitPair = this->horSplitterMap.Lookup( sourcePaneParentWnd))) {
// it is a horizontal splitter
HSplitter* parentSplitter = horSplitPair->m_value;
neighbourWnd = parentSplitter->GetSplitterPane( SPLIT_PANE_LEFT);
if ( neighbourWnd == sourcePane->m_hWnd)
neighbourWnd = parentSplitter->GetSplitterPane( SPLIT_PANE_RIGHT);
HWND theParentWnd = ::GetParent( parentSplitter->m_hWnd);
::SetParent( neighbourWnd, theParentWnd);
if ( this->rootWnd == parentSplitter->m_hWnd)
this->rootWnd = neighbourWnd;
// find the parent of the parent splitter and replace the pane to the neighbour
if ( theParentWnd == this->m_hWnd) {
this->GetClientRect( &neighbourRect);
} else if ( NULL != ( verSplitPair = this->verSplitterMap.Lookup( theParentWnd))) {
VSplitter* theParent = verSplitPair->m_value;
if ( theParent->GetSplitterPane( SPLIT_PANE_LEFT) == parentSplitter->m_hWnd) {
theParent->SetSplitterPane( SPLIT_PANE_LEFT, neighbourWnd, false);
theParent->GetSplitterPaneRect( SPLIT_PANE_LEFT, &neighbourRect);
} else if ( theParent->GetSplitterPane( SPLIT_PANE_RIGHT) == parentSplitter->m_hWnd) {
theParent->SetSplitterPane( SPLIT_PANE_RIGHT, neighbourWnd, false);
theParent->GetSplitterPaneRect( SPLIT_PANE_RIGHT, &neighbourRect);
}
} else if ( NULL != ( horSplitPair = this->horSplitterMap.Lookup( theParentWnd))) {
HSplitter* theParent = horSplitPair->m_value;
if ( theParent->GetSplitterPane( SPLIT_PANE_LEFT) == parentSplitter->m_hWnd) {
theParent->SetSplitterPane( SPLIT_PANE_LEFT, neighbourWnd, false);
theParent->GetSplitterPaneRect( SPLIT_PANE_LEFT, &neighbourRect);
} else if ( theParent->GetSplitterPane( SPLIT_PANE_RIGHT) == parentSplitter->m_hWnd) {
theParent->SetSplitterPane( SPLIT_PANE_RIGHT, neighbourWnd, false);
theParent->GetSplitterPaneRect( SPLIT_PANE_RIGHT, &neighbourRect);
}
}
// delete the parent splitter
this->horSplitterMap.RemoveKey( parentSplitter->m_hWnd);
sourcePane->DestroyWindow();
parentSplitter->DestroyWindow();
delete parentSplitter;
}
this->paneMap.RemoveKey( srcPane);
delete sourcePane; //
::SetWindowPos( neighbourWnd, HWND_TOP, neighbourRect.left, neighbourRect.top, neighbourRect.Width(), neighbourRect.Height(), SWP_SHOWWINDOW);
if ( this->currentPane == sourcePane)
this->currentPane = this->getNextPane( neighbourWnd);
return 1;
}
LRESULT OnEraseBackground( UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) {
return 1;
}
LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) {
if ( NULL == this->rootWnd)
return 0;
WORD width = LOWORD( lParam);
WORD height = HIWORD( lParam);
::SetWindowPos( this->rootWnd, NULL, 0, 0, width, height, SWP_NOZORDER);
return 0;
}
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
this->currentPane = new Pane( this, this->tabOnTop);
this->currentPane->Create( this->m_hWnd);
this->paneMap.SetAt( this->currentPane->m_hWnd, this->currentPane);
this->rootWnd = this->currentPane->m_hWnd;
return 0;
}
}; // class SplitPane: public WinContainer<SplitPane>{};
}; // namespace DockSplitTab
#endif // __DOCKSPLITPANE_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -