ExtControlBar.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:775k
- {
- CRect rcArea = *pBtn;
- CRect rcDefOffsetWnd;
- GetWindowRect( &rcDefOffsetWnd );
- rcArea.OffsetRect( rcDefOffsetWnd.TopLeft() );
- OnAdvancedPopupMenuTipWndDisplay(
- *pATTW,
- rcArea,
- _ti.lpszText
- );
- }
- }
- if( _ti.lpszText != NULL
- && _ti.lpszText != LPSTR_TEXTCALLBACK
- )
- ::free( _ti.lpszText );
- }
- }
- break;
- case WM_PRINT:
- case WM_PRINTCLIENT:
- {
- CDC * pDC = CDC::FromHandle( (HDC) wParam );
- CRect rcRgnWnd, rcRgnClient;
- GetWindowRect( &rcRgnWnd );
- GetClientRect( &rcRgnClient );
- if( IsFloating() )
- {
- CRect rcFloatClient;
- GetParentFrame()->GetClientRect( &rcFloatClient );
- if( rcRgnClient.Width() > rcFloatClient.Width() )
- rcRgnClient.right = rcRgnClient.left + rcFloatClient.Width();
- if( rcRgnClient.Height() > rcFloatClient.Height() )
- rcRgnClient.bottom = rcRgnClient.top + rcFloatClient.Height();
- }
- if( (lParam&PRF_NONCLIENT) != 0 )
- {
- CRect rcWnd = rcRgnWnd, rcClient = rcRgnClient;
- ClientToScreen( &rcClient );
- rcClient.OffsetRect( -rcWnd.TopLeft() );
- rcWnd.OffsetRect( -rcWnd.TopLeft() );
- CRgn rgnWnd;
- if( rgnWnd.CreateRectRgnIndirect(&rcWnd) )
- pDC->SelectClipRgn( &rgnWnd );
- pDC->ExcludeClipRect( &rcClient );
- DoPaintNC( pDC );
- pDC->SelectClipRgn( NULL );
- }
- if( (lParam&(PRF_CLIENT|PRF_ERASEBKGND)) != 0 )
- {
- CPoint ptVpOffset( 0, 0 );
- if( (lParam&PRF_NONCLIENT) != 0 )
- {
- CRect rcWnd = rcRgnWnd, rcClient = rcRgnClient;
- ClientToScreen( &rcClient );
- ptVpOffset.x = rcWnd.left - rcClient.left;
- ptVpOffset.y = rcWnd.top - rcClient.top;
- }
- if( ptVpOffset.x != 0
- || ptVpOffset.y != 0
- )
- pDC->OffsetViewportOrg(
- -ptVpOffset.x,
- -ptVpOffset.y
- );
- // DoEraseBk( pDC );
- // DoPaint( pDC );
- CDC dcSurface;
- CBitmap bmpSurface;
- CWindowDC dcDesktop( NULL );
- if( dcSurface.CreateCompatibleDC( NULL )
- && bmpSurface.CreateCompatibleBitmap(
- &dcDesktop,
- rcRgnClient.Width(),
- rcRgnClient.Height()
- )
- )
- {
- CBitmap * pOldBmp = dcSurface.SelectObject( &bmpSurface );
- DoEraseBk( &dcSurface );
- DoPaint( &dcSurface );
- pDC->BitBlt(
- 0,
- 0,
- rcRgnClient.Width(),
- rcRgnClient.Height(),
- &dcSurface,
- 0,
- 0,
- SRCCOPY
- );
- dcSurface.SelectObject( pOldBmp );
- }
- if( ptVpOffset.x != 0
- || ptVpOffset.y != 0
- )
- pDC->OffsetViewportOrg(
- ptVpOffset.x,
- ptVpOffset.y
- );
- } // if( (lParam&(PRF_CLIENT|PRF_ERASEBKGND)) != 0 )
- if( (lParam&PRF_CHILDREN) != 0 )
- CExtPaintManager::stat_PrintChildren(
- m_hWnd,
- message,
- pDC->GetSafeHdc(),
- lParam,
- false
- );
- }
- return (!0);
- case WM_TIMER:
- // if( wParam == __TIMER_ID_DELAYED_UPDATE )
- // {
- // CFrameWnd * pFrame = _GetDockingFrameImpl();
- // if( pFrame != NULL )
- // OnUpdateCmdUI( pFrame, TRUE );
- // KillTimer( __TIMER_ID_DELAYED_UPDATE );
- // return 0L;
- // } // if( wParam == __TIMER_ID_DELAYED_UPDATE )
- // else
- if( wParam == __TIMER_ID_DRELAYED_REPAINT_FAKE )
- {
- RedrawWindow(
- NULL,
- NULL,
- RDW_INVALIDATE|RDW_UPDATENOW
- |RDW_ERASE|RDW_ERASENOW
- |RDW_ALLCHILDREN
- |RDW_FRAME
- );
- KillTimer( __TIMER_ID_DRELAYED_REPAINT_FAKE );
- return 0L;
- } // if( wParam == __TIMER_ID_DRELAYED_REPAINT_FAKE )
- if( AnimationSite_OnHookTimer( UINT(wParam) ) )
- return 0L;
- break;
- case WM_CLOSE:
- // emulate for disabling update in user non-frame mode
- m_bInCustomModeUpdateCmdUI = true;
- return 0;
- case WM_DESTROY:
- AnimationSite_ClientRemove();
- #if (_MFC_VER >= 0x700) && (_MFC_VER <= 0x710)
- if( m_pDockSite != NULL
- && m_pDockSite->IsKindOf( RUNTIME_CLASS(CMDIChildWnd) )
- )
- {
- CFrameWnd * pFrame = GetParentFrame();
- if( pFrame != m_pDockSite )
- m_bHelperSuppressDestruction = true;
- }
- #endif // (_MFC_VER >= 0x700) && (_MFC_VER <= 0x710)
- // emulate for disabling update in user non-frame mode
- m_bInCustomModeUpdateCmdUI = true;
-
- break;
- case WM_NCDESTROY:
- AnimationSite_ClientRemove();
- if( m_pDockContext != NULL )
- {
- m_pDockBar = NULL;
- delete m_pDockContext;
- m_pDockContext = NULL;
- }
- // emulate for disabling update in user non-frame mode
- m_bInCustomModeUpdateCmdUI = true;
- NcButtons_RemoveAll();
- break;
- case WM_SETFOCUS:
- {
- LRESULT lResult =
- CControlBar::WindowProc(message, wParam, lParam);
- if( IsMinimizedOnRow() )
- MaximizeOnRow();
- if( !IsFixedMode() )
- {
- CWnd * pWnd = GetWindow(GW_CHILD);
- if( pWnd != NULL
- && stat_QueryFocusChangingEnabled( this, pWnd->m_hWnd )
- )
- {
- pWnd->SetFocus();
- //#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- // ASSERT(
- // pWnd->GetWindow(GW_HWNDNEXT) == NULL
- // || IsKindOf(RUNTIME_CLASS(CExtDynTabControlBar))
- // );
- //#else
- // ASSERT(
- // pWnd->GetWindow(GW_HWNDNEXT) == NULL
- // );
- //#endif // else from (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- }
- } // if( !IsFixedMode() )
- return lResult;
- }
- case WM_ERASEBKGND:
- if( !m_bDoNotEraseClientBackground )
- return !0;
- CExtPaintManager::stat_ExcludeChildAreas(
- (HDC)wParam,
- *this
- );
- return CControlBar::WindowProc(message, wParam, lParam);
- case WM_CREATE:
- {
- if( (!m_bPresubclassDialogMode) && (!IsFixedMode()) )
- {
- ASSERT( GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow(GetSafeHwnd()) );
- HWND hWndParent = ::GetParent( GetSafeHwnd() );
- CFrameWnd * pFrame = NULL;
- do
- {
- ASSERT( hWndParent != NULL );
- ASSERT( ::IsWindow(hWndParent) );
- CWnd * pWnd = CWnd::FromHandle( hWndParent );
- if( pWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd)) )
- {
- pFrame = (CFrameWnd *)pWnd;
- break;
- }
- } while( pFrame == NULL );
- ASSERT( pFrame != NULL );
- ASSERT_VALID( pFrame );
- if( pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) )
- {
- pFrame = pFrame->GetParentFrame();
- ASSERT( pFrame != NULL );
- ASSERT_VALID( pFrame );
- ASSERT( !pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) );
- }
- VERIFY( _FrameEnableDockingImpl( pFrame ) );
- } // if( (!m_bPresubclassDialogMode) && (!IsFixedMode()) )
- ////AnimationSite_Init( false );
- }
- break;
- case WM_SHOWWINDOW:
- case WM_SIZE:
- m_bDelelayRepaintNcButtons = true;
- OnControlBarPositionChange(
- this,
- __ECBPC_MUTUAL_DEPENDENCY,
- true,
- true
- );
- break;
- case WM_WINDOWPOSCHANGED:
- {
- CExtPopupMenuTipWnd * pATTW =
- OnAdvancedPopupMenuTipWndGet();
- if( pATTW != NULL )
- pATTW->Hide();
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = NotifiedCustomizeSiteGet();
- if( pSite != NULL )
- pSite->OnBarStateChanged( this );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
-
- if( m_pDockBar == NULL && (!m_bPresubclassDialogMode) )
- break; // on destruction
- LPWINDOWPOS lpWindowPos =
- reinterpret_cast < LPWINDOWPOS > (lParam);
- ASSERT( lpWindowPos != NULL );
- if( ! IsFixedMode() )
- _UpdateVisibilityInChain();
- CExtControlBar * pBar = this;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDynTabControlBar * pTabBar = _GetNearestTabbedContainer();
- if( pTabBar != NULL && pTabBar != this )
- pBar = pTabBar;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- pBar->m_bDelelayRepaintNcButtons = true;
- pBar->PostMessage( WM_NCPAINT );
- if( (lpWindowPos->flags & SWP_FRAMECHANGED) == 0 )
- _RecalcNcArea();
- OnControlBarPositionChange(
- this,
- __ECBPC_MUTUAL_DEPENDENCY,
- true,
- true
- );
- break;
- }
- case WM_WINDOWPOSCHANGING:
- {
- m_bDelelayRepaintNcButtons = true;
- if( m_pDockBar == NULL && (!m_bPresubclassDialogMode) )
- break; // on destruction
- LPWINDOWPOS lpWindowPos =
- reinterpret_cast < LPWINDOWPOS > (lParam);
- ASSERT( lpWindowPos != NULL );
- lpWindowPos->flags |= SWP_FRAMECHANGED;
- break;
- }
- case WM_SETTEXT:
- {
- m_bDelelayRepaintNcButtons = true;
- LRESULT lResult = CControlBar::WindowProc(message, wParam, lParam);
- if( (! IsFixedMode() )
- && (! IsKindOf( RUNTIME_CLASS(CExtDynControlBar) ) )
- )
- {
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( AutoHideModeGet() )
- {
- CExtDynAutoHideArea * pTabs =
- CExtDynAutoHideArea::stat_FindAreaOfBar( this );
- if( pTabs != NULL )
- {
- ASSERT_VALID( pTabs );
- pTabs->UpdateTabWnd();
- CExtDynAutoHideSlider * pAutoHideSlider =
- pTabs->GetAutoHideSlider();
- if( pAutoHideSlider->GetSafeHwnd() != NULL
- && (pAutoHideSlider->GetStyle()&WS_VISIBLE) != 0
- )
- pAutoHideSlider->SendMessage( WM_NCPAINT );
- } // if( pTabs != NULL )
- } // if( AutoHideModeGet() )
- else
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( IsVisible() )
- {
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CWnd * pWnd = GetParent();
- bool bRecalcThisNcArea = true;
- if( pWnd != NULL
- && pWnd->IsKindOf( RUNTIME_CLASS(CExtDockDynTabBar) )
- )
- {
- ASSERT_VALID( pWnd );
- pWnd = pWnd->GetParent();
- ASSERT_VALID( pWnd );
- CExtDynTabControlBar * pTabBar =
- DYNAMIC_DOWNCAST(
- CExtDynTabControlBar,
- pWnd
- );
- if( pTabBar != NULL )
- {
- pTabBar->InvalidateSwitcher();
- CFrameWnd * pFrame = pTabBar->GetParentFrame();
- ASSERT_VALID( pFrame );
- pFrame->DelayRecalcLayout();
- pFrame->PostMessage( WM_NULL );
- LONG nSelIdx = pTabBar->GetSwitcherSelection();
- if( nSelIdx >= 0 )
- {
- CExtControlBar * pBarTest = pTabBar->GetBarAt( nSelIdx, true );
- if( pBarTest == this )
- {
- CString strText;
- GetWindowText( strText );
- pTabBar->SetWindowText( strText );
- } // if( pBarTest == this )
- } // if( nSelIdx >= 0 )
- ((CExtControlBar*)pTabBar)->_RecalcNcArea();
- bRecalcThisNcArea = false;
- } // if( pTabBar != NULL )
- } // if( pWnd != NULL ...
- if( bRecalcThisNcArea )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- _RecalcNcArea();
- } // else if( IsVisible() )
- } // if( ! IsFixedMode() ...
- return lResult;
- } // case WM_SETTEXT:
- } // switch( message )
- return CControlBar::WindowProc(message, wParam, lParam);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtControlBar message handlers
- void CExtControlBar::NcButtons_Paint( CDC & dc )
- {
- ASSERT( dc.GetSafeHdc() != NULL );
- INT nCountOfNcButtons = NcButtons_GetCount();
- for( INT nBtn = 0; nBtn < nCountOfNcButtons; nBtn++ )
- {
- CExtBarNcAreaButton * pBtn =
- NcButtons_GetAt( nBtn );
- if( ! pBtn->OnQueryVisibility() )
- continue;
- pBtn->OnNcAreaDraw( dc );
- } // for( INT nBtn = 0; nBtn < nCountOfNcButtons; nBtn++ )
- }
- CRect & CExtControlBar::NcButtons_CalcGripperTextLocation(
- CRect & rcPreCalcText
- )
- {
- INT nCountOfNcButtons = NcButtons_GetCount();
- if( nCountOfNcButtons == 0 )
- return rcPreCalcText;
- bool bHorz = false;
- bool bGripperAtTop = true;
- if( ! IsFloating() )
- {
- if( ! IsBarWithGripper( &bGripperAtTop ) )
- return rcPreCalcText;
- bHorz = IsDockedHorizontally();
- }
- // find last visible at right or at bottom
- CExtBarNcAreaButton * pBtn = NULL;
- for( INT nBtnIdx = nCountOfNcButtons; nBtnIdx > 0 ; nBtnIdx-- )
- {
- CExtBarNcAreaButton * pBtnExamine =
- NcButtons_GetAt( nBtnIdx - 1 );
- ASSERT_VALID( pBtnExamine );
- if( pBtnExamine->OnQueryVisibility() )
- {
- pBtn = pBtnExamine;
- break;
- }
- } // for( INT nBtnIdx = nCountOfNcButtons; nBtnIdx > 0 ; nBtnIdx-- )
- CRect rcDefalte = PmBridge_GetPM()->Bar_GetCaptionBordersForText( this );
- rcPreCalcText.DeflateRect(
- rcDefalte.left,
- rcDefalte.top,
- rcDefalte.right,
- rcDefalte.bottom
- );
- if( pBtn == NULL )
- return rcPreCalcText;
- // adjust caption text rect
- const CRect & rcBtn = *pBtn;
- if( bHorz && (! bGripperAtTop ) )
- {
- rcPreCalcText.top = rcBtn.bottom + 1;
- if( rcPreCalcText.top > rcPreCalcText.bottom )
- rcPreCalcText.top = rcPreCalcText.bottom;
- } // if( bHorz && (! bGripperAtTop ) )
- else
- {
- if( (g_ResourceManager->OnQueryLangLayout()&LAYOUT_RTL) != 0 )
- {
- rcPreCalcText.left = rcBtn.right + 1;
- if( rcPreCalcText.right < rcPreCalcText.left )
- rcPreCalcText.right = rcPreCalcText.left;
- }
- else
- {
- rcPreCalcText.right = rcBtn.left - 1;
- if( rcPreCalcText.left > rcPreCalcText.right )
- rcPreCalcText.left = rcPreCalcText.right;
- }
- } // if( bHorz && (! bGripperAtTop ) )
- return rcPreCalcText;
- }
- UINT CExtControlBar::NcButtons_HitTest(
- CPoint point,
- CExtBarNcAreaButton ** ppBtn // = NULL
- )
- {
- if( ppBtn != NULL )
- *ppBtn = NULL;
- bool bNeedRepaint = false;
- CWnd * pWndNcRepaint = this;
- CRect rcBarWnd;
- if( IsFloating() )
- {
- CExtMiniDockFrameWnd * pFrame =
- DYNAMIC_DOWNCAST(
- CExtMiniDockFrameWnd,
- GetParentFrame()
- );
- if( pFrame == NULL )
- return HTCLIENT;
- pFrame->GetWindowRect( &rcBarWnd );
- pWndNcRepaint = pFrame;
- } // if( IsFloating() )
- else
- {
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( AutoHideModeGet() )
- {
- ASSERT_VALID( m_pDockBar );
- ASSERT_KINDOF( CExtDockBar, m_pDockBar );
- CExtDynAutoHideArea * pWndAutoHideArea =
- ((CExtDockBar*)m_pDockBar)->_GetAutoHideArea();
- ASSERT_VALID( pWndAutoHideArea );
- ASSERT_VALID( pWndAutoHideArea->m_pWndSlider );
- if( pWndAutoHideArea->m_pWndSlider->_GetBar() != this
- || ((pWndAutoHideArea->m_pWndSlider->GetStyle() & WS_VISIBLE) == 0)
- )
- return HTCLIENT;
- pWndAutoHideArea->m_pWndSlider->
- GetWindowRect( &rcBarWnd );
- }
- else
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- GetWindowRect( &rcBarWnd );
- } // else from if( IsFloating() )
- CPoint ptDevOffset = -rcBarWnd.TopLeft();
- CPoint ptWnd( point + ptDevOffset );
- bool bDragging = m_bDragging;
- if( !bDragging )
- bDragging = (_DraggingGetBar() != NULL) ? true : false;
- UINT nFirstHT = HTCLIENT;
- if( _DraggingGetBar() == NULL
- && (!CExtPopupMenuWnd::IsMenuTracking())
- )
- {
- INT nCountOfNcButtons = NcButtons_GetCount();
- for( INT nBtn = 0; nBtn < nCountOfNcButtons; nBtn++ )
- {
- CExtBarNcAreaButton * pBtn =
- NcButtons_GetAt( nBtn );
- if( !pBtn->OnQueryVisibility() )
- continue;
-
- if( (pBtn->m_bHover || pBtn->m_bPushed)
- && ppBtn == NULL
- )
- {
- bNeedRepaint = true;
- if( bDragging || m_bRowRecalcing || m_bRowResizing )
- {
- pBtn->m_bHover = false;
- pBtn->m_bPushed = false;
- continue;
- }
- }
- UINT nHT =
- pBtn->OnNcAreaHitTest( ptWnd );
- if( nHT != HTCLIENT )
- {
- if( ppBtn != NULL )
- {
- *ppBtn = pBtn;
- return nHT;
- }
- // TO FIX: ASSERT( nFirstHT == HTCLIENT );
- nFirstHT = nHT;
- bNeedRepaint = true;
- }
- } // for( INT nBtn = 0; nBtn < nCountOfNcButtons; nBtn++ )
- }
- if( bNeedRepaint )
- pWndNcRepaint->SendMessage( WM_NCPAINT );
-
- return nFirstHT;
- }
- UINT CExtControlBar::OnNcHitTest(CPoint point)
- {
- if( _DraggingGetBar() != NULL )
- return HTNOWHERE;
- UINT nHT = NcButtons_HitTest( point );
- if( nHT != HTCLIENT )
- {
- m_bNcAreaBtnTracking = true;
- return nHT;
- }
- else
- {
- if( m_bNcAreaBtnTracking )
- PostMessage( WM_NCPAINT );
- m_bNcAreaBtnTracking = false;
- // if( ( ! CExtPopupMenuWnd::IsKeyPressed( VK_LBUTTON ) )
- // && GetSafeHwnd() != NULL
- // && ::GetCapture() == m_hWnd
- // )
- // ::ReleaseCapture();
- }
- if( IsFixedMode() || IsFloating() )
- return HTCLIENT;
- CRect rcBarWnd;
- GetWindowRect( &rcBarWnd );
- CPoint ptDevOffset = -rcBarWnd.TopLeft();
- CRect rcBarClient;
- GetClientRect( &rcBarClient );
- ClientToScreen( &rcBarClient );
- if( rcBarWnd == rcBarClient )
- return HTCLIENT;
- // rcBarWnd.OffsetRect( ptDevOffset );
- // rcBarClient.OffsetRect( ptDevOffset );
- point += ptDevOffset;
- CRect rcRowResize = _RectRowResizeGet();
- CRect rcRowRecalc = _RectRowRecalcGet();
- CRect rcRowRecalcUp = _RectRowRecalcUpGet();
- bool bHorz = IsDockedHorizontally();
- if( (! rcRowResize.IsRectEmpty() )
- && rcRowResize.PtInRect( point )
- )
- {
- if( ! _RowResizingIsEnabled( this ) )
- return HTNOWHERE;
- return bHorz ? HTBOTTOM : HTRIGHT;
- }
- if( (! rcRowRecalc.IsRectEmpty() )
- && rcRowRecalc.PtInRect( point )
- )
- {
- if( _IsLastBarInRow( true ) )
- return HTNOWHERE; //HTCLIENT;
- if( ! _RowRecalcingIsEnabled( this ) )
- return HTNOWHERE;
- if( !_RowRecalcing_IsBottomEnabled() )
- return HTNOWHERE; //HTCLIENT;
- return bHorz ? HTRIGHT : HTBOTTOM;
- }
- if( (! rcRowRecalcUp.IsRectEmpty() )
- && rcRowRecalcUp.PtInRect( point )
- )
- {
- if( _IsFirstBarInRow( true ) )
- return HTNOWHERE; //HTCLIENT;
- if( ! _RowRecalcingIsEnabled( this ) )
- return HTNOWHERE;
- if( ! _RowRecalcing_IsTopEnabled() )
- return HTNOWHERE; //HTCLIENT;
- return bHorz ? HTLEFT : HTTOP;
- }
- return HTCLIENT;
- }
- void CExtControlBar::_GetDeepNcModeMetrics(
- bool & bEnableResizerLeft,
- bool & bEnableResizerTop,
- bool & bEnableResizerRight,
- bool & bEnableResizerBottom
- )
- {
- bEnableResizerLeft = true;
- bEnableResizerTop = true;
- bEnableResizerRight = true;
- bEnableResizerBottom = true;
- if( IsFixedMode() )
- return;
- // if( !IsVisible() )
- // return;
- if( m_pDockSite == NULL || m_pDockBar == NULL )
- {
- bEnableResizerLeft = false;
- bEnableResizerTop = false;
- bEnableResizerRight = false;
- bEnableResizerBottom = false;
- return;
- }
- ASSERT_VALID( m_pDockSite );
- ASSERT_VALID( m_pDockBar );
- if( ! m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockBar)) )
- {
- bEnableResizerLeft = false;
- bEnableResizerTop = false;
- bEnableResizerRight = false;
- bEnableResizerBottom = false;
- return;
- }
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockDynTabBar)) )
- {
- bEnableResizerLeft = false;
- bEnableResizerTop = false;
- bEnableResizerRight = false;
- bEnableResizerBottom = false;
- return;
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDockBar * pDockBar = (CExtDockBar *) m_pDockBar;
- UINT nDockBarID = pDockBar->GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nDockBarID );
- BOOL bHorz = ( nDockBarID == AFX_IDW_DOCKBAR_TOP || nDockBarID == AFX_IDW_DOCKBAR_BOTTOM );
- INT nCount = (INT)pDockBar->m_arrBars.GetSize();
- ASSERT( nCount >= 1 );
- if( nCount == 1 )
- return;
- INT nOwnIdx = pDockBar->FindBar( this );
- if( nOwnIdx == -1 )
- return; // destruction
- ASSERT( nOwnIdx > 0 && nOwnIdx < nCount );
- bool bPrevRowExist = false;
- bool bFirstVisibleOnRow = true;
- INT nBar = nOwnIdx-1;
- for( ; nBar > 0; nBar-- )
- {
- CControlBar * pBar = (CControlBar *) pDockBar->m_arrBars[nBar];
- if( pBar == NULL )
- {
- if( nBar > 0 )
- bPrevRowExist = true;
- break;
- }
- if( __PLACEHODLER_BAR_PTR( pBar ) )
- continue;
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- if( pBar->IsVisible() )
- bFirstVisibleOnRow = false;
- }
- bool bPrevVisibleRowExist = false;
- if( bPrevRowExist )
- {
- for( nBar--; nBar > 0; nBar-- )
- {
- CControlBar * pBar = (CControlBar *) pDockBar->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR( pBar ) )
- continue;
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- if( pBar->IsVisible() )
- {
- bPrevVisibleRowExist = true;
- break;
- }
- }
- }
- bool bNextRowExist = false;
- bool bLastVisibleOnRow = true;
- for( nBar = nOwnIdx+1; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *) pDockBar->m_arrBars[nBar];
- if( pBar == NULL )
- {
- if( nBar < (nCount-1) )
- bNextRowExist = true;
- break;
- }
- if( __PLACEHODLER_BAR_PTR( pBar ) )
- continue;
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- if( pBar->IsVisible() )
- bLastVisibleOnRow = false;
- }
- bool bNextVisibleRowExist = false;
- if( bNextRowExist )
- {
- for( nBar++; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *) pDockBar->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR( pBar ) )
- continue;
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- if( pBar->IsVisible() )
- {
- bNextVisibleRowExist = true;
- break;
- }
- }
- }
- if( m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockDynBar)) )
- { // if dockbar is dynamic docker
- if( bHorz )
- {
- if( !bPrevVisibleRowExist )
- bEnableResizerTop = false;
- /**/ if( !bNextVisibleRowExist )
- /**/ bEnableResizerBottom = false;
- if( bFirstVisibleOnRow )
- bEnableResizerLeft = false;
- if( bLastVisibleOnRow )
- bEnableResizerRight = false;
- } // if( bHorz )
- else
- {
- if( !bPrevVisibleRowExist )
- bEnableResizerLeft = false;
- /**/ if( !bNextVisibleRowExist )
- /**/ bEnableResizerRight = false;
- if( bFirstVisibleOnRow )
- bEnableResizerTop = false;
- if( bLastVisibleOnRow )
- bEnableResizerBottom = false;
- } // else from if( bHorz )
- } // if dockbar is dynamic docker
- else
- { // if dockbar is static docker
-
- INT nOwnCircleNo = GetDockBarCircleNo();
- if( nOwnCircleNo > 0 )
- {
- switch( nDockBarID )
- {
- case AFX_IDW_DOCKBAR_TOP:
- if( !bPrevVisibleRowExist )
- bEnableResizerTop = false;
- // if( !bNextVisibleRowExist )
- // bEnableResizerBottom = false;
- if( bFirstVisibleOnRow )
- bEnableResizerLeft = false;
- if( bLastVisibleOnRow )
- bEnableResizerRight = false;
- break;
- case AFX_IDW_DOCKBAR_BOTTOM:
- // if( !bPrevVisibleRowExist )
- // bEnableResizerTop = false;
- if( !bNextVisibleRowExist )
- bEnableResizerBottom = false;
- if( bFirstVisibleOnRow )
- bEnableResizerLeft = false;
- if( bLastVisibleOnRow )
- bEnableResizerRight = false;
- break;
- case AFX_IDW_DOCKBAR_LEFT:
- if( !bPrevVisibleRowExist )
- bEnableResizerLeft = false;
- // if( !bNextVisibleRowExist )
- // bEnableResizerRight = false;
- if( bFirstVisibleOnRow )
- bEnableResizerTop = false;
- if( bLastVisibleOnRow )
- bEnableResizerBottom = false;
- break;
- case AFX_IDW_DOCKBAR_RIGHT:
- // if( !bPrevVisibleRowExist )
- // bEnableResizerLeft = false;
- if( !bNextVisibleRowExist )
- bEnableResizerRight = false;
- if( bFirstVisibleOnRow )
- bEnableResizerTop = false;
- if( bLastVisibleOnRow )
- bEnableResizerBottom = false;
- break;
- #ifdef _DEBUG
- default:
- {
- ASSERT( FALSE );
- }
- break;
- #endif // _DEBUG
- } // switch( nDockBarID )
- } // if( nOwnCircleNo > 0 )
- } // if dockbar is static docker
- }
- void CExtControlBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
- {
- bCalcValidRects;
- if( m_pDockBar == NULL && (!m_bPresubclassDialogMode) )
- return; // on destruction
- CRect & rcClientLoc =
- reinterpret_cast < CRect & > ( lpncsp->rgrc[0] );
- CRect rcClientLocSaved = rcClientLoc;
- if( IsFloating() ) // (+ v.2.22)
- {
- if( !IsFixedMode() ) // (+ v.2.23)
- {
- rcClientLoc.DeflateRect( 1, 1 );
- return;
- }
- rcClientLoc.OffsetRect( 0, -rcClientLoc.top );
- rcClientLoc.OffsetRect( -rcClientLoc.left, 0 );
- return;
- }
- bool bEnableResizerLeft = true;
- bool bEnableResizerTop = true;
- bool bEnableResizerRight = true;
- bool bEnableResizerBottom = true;
- _GetDeepNcModeMetrics(
- bEnableResizerLeft,
- bEnableResizerTop,
- bEnableResizerRight,
- bEnableResizerBottom
- );
- CRect rcDevOrg( rcClientLoc );
- CRect rcGrip, rcRowResize, rcRowRecalc, rcRowRecalcUp;
- rcGrip.SetRectEmpty();
- rcRowResize.SetRectEmpty();
- rcRowRecalc.SetRectEmpty();
- rcRowRecalcUp.SetRectEmpty();
- INT nSeparatorWidth = 0;
- INT nSeparatorHeight = 0;
- INT nGripWidthAtLeft = 0;
- INT nGripHeightAtTop = 0;
- CUSTOM_NC_AREA_QUERY_DATA _cnaqd( this );
- _cnaqd.Notify();
- nSeparatorWidth = _SeparatorWidthGet();
- nSeparatorHeight = _SeparatorHeightGet();
- nGripWidthAtLeft = _GripperWidthAtLeftGet();
- nGripHeightAtTop = _GripperHeightAtTopGet();
- m_nMinHW = nSeparatorWidth;
- m_nMinVH = nSeparatorHeight;
- bool bGripperAtTop = false;
- bool bGripperExists = IsBarWithGripper( &bGripperAtTop );
- #ifdef _DEBUG
- if( IsKindOf( RUNTIME_CLASS( CExtDynControlBar ) ) )
- {
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( !IsKindOf( RUNTIME_CLASS( CExtDynTabControlBar ) ) )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- {
- ASSERT( !bGripperExists );
- }
- }
- #endif // _DEBUG
-
- CPoint ptGripOffset( 0, 0 );
- UINT nDockBarDlgCtrlID = GetSafeDockBarDlgCtrlID();
- if( ! IsFixedMode() )
- {
- MfcControlBarVector_t vBars;
- _GetRowBars( vBars );
- int nCountOfnBars = (int)vBars.GetSize();
- INT nLastFixedIdx = -1;
- CExtControlBar * pLastExtBar = NULL;
- bool bAddTopRecalc = false;
- for( INT nBar = 0; nBar < nCountOfnBars ; nBar++ )
- {
- CControlBar * pBar = vBars[ nBar ];
- ASSERT_VALID( pBar );
- if( !pBar->IsVisible() )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar != NULL && pExtBar->IsFixedMode() )
- pExtBar = NULL;
- if( pExtBar != NULL )
- {
- if( pExtBar == this
- && pLastExtBar != NULL
- && nLastFixedIdx == (nBar-1)
- )
- {
- bAddTopRecalc = true;
- break;
- }
- pLastExtBar = pExtBar;
- }
- else
- nLastFixedIdx = nBar;
- } // for( INT nBar = 0; nBar < nCountOfnBars ; nBar++ )
- switch( nDockBarDlgCtrlID )
- {
- case AFX_IDW_DOCKBAR_TOP:
- if( bEnableResizerRight )
- {
- rcRowRecalc = rcClientLoc;
- rcRowRecalc.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- rcRowRecalc.left = rcRowRecalc.right - nSeparatorWidth;
- rcClientLoc.right -= nSeparatorWidth;
- }
-
- if( bEnableResizerBottom )
- {
- rcClientLoc.DeflateRect( 0, 0, 0, nSeparatorHeight );
- rcRowResize = rcClientLoc;
- rcRowResize.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- rcRowResize.top = rcRowResize.bottom;
- rcRowResize.bottom += nSeparatorHeight;
- rcRowResize.right = rcRowResize.left + rcDevOrg.Width();
- }
- if( bAddTopRecalc )
- {
- rcRowRecalcUp = rcClientLoc;
- rcRowRecalcUp.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- rcRowRecalcUp.right = rcRowRecalcUp.left + nSeparatorWidth;
- if( bGripperExists )
- ptGripOffset.x += nSeparatorWidth;
- rcClientLoc.DeflateRect( nSeparatorWidth, 0, 0, 0 );
- } // if( bAddTopRecalc )
- break;
- case AFX_IDW_DOCKBAR_BOTTOM:
- if( bEnableResizerRight )
- {
- rcRowRecalc = rcClientLoc;
- rcRowRecalc.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- rcRowRecalc.left = rcRowRecalc.right - nSeparatorWidth;
- rcClientLoc.right -= nSeparatorWidth;
- }
-
- if( bEnableResizerTop )
- {
- rcClientLoc.DeflateRect( 0, nSeparatorHeight, 0, 0 );
- rcRowResize = rcClientLoc;
- rcRowResize.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- rcRowResize.bottom = rcRowResize.top + nSeparatorHeight;
- rcRowResize.right = rcRowResize.left + rcDevOrg.Width();
- if( bGripperExists )
- ptGripOffset.y += nSeparatorHeight;
- }
- if( bAddTopRecalc )
- {
- rcRowRecalcUp = rcClientLoc;
- rcRowRecalcUp.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- rcRowRecalcUp.right = rcRowRecalcUp.left + nSeparatorWidth;
- if( bGripperExists )
- ptGripOffset.x += nSeparatorWidth;
- rcClientLoc.DeflateRect( nSeparatorWidth, 0, 0, 0 );
- } // if( bAddTopRecalc )
- break;
- case AFX_IDW_DOCKBAR_LEFT:
- if( bEnableResizerBottom )
- {
- rcRowRecalc = rcClientLoc;
- rcRowRecalc.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- rcRowRecalc.top = rcRowRecalc.bottom - nSeparatorHeight;
- rcClientLoc.DeflateRect( 0, 0, 0, nSeparatorHeight );
- }
-
- if( bEnableResizerRight )
- {
- rcClientLoc.DeflateRect( 0, 0, nSeparatorHeight, 0 );
- rcRowResize = rcClientLoc;
- rcRowResize.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- rcRowResize.left = rcRowResize.right;
- rcRowResize.right += nSeparatorWidth;
- rcRowResize.bottom = rcRowResize.top + rcDevOrg.Height();
- }
- if( bAddTopRecalc )
- {
- rcRowRecalcUp = rcClientLoc;
- rcRowRecalcUp.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- rcRowRecalcUp.bottom = rcRowRecalcUp.top + nSeparatorWidth;
- if( bGripperExists )
- ptGripOffset.y += nSeparatorHeight;
- rcClientLoc.DeflateRect( 0, nSeparatorHeight, 0, 0 );
- } // if( bAddTopRecalc )
- break;
- case AFX_IDW_DOCKBAR_RIGHT:
- if( bEnableResizerBottom )
- {
- rcRowRecalc = rcClientLoc;
- rcRowRecalc.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- rcRowRecalc.top = rcRowRecalc.bottom - nSeparatorHeight;
- rcClientLoc.DeflateRect( 0, 0, 0, nSeparatorHeight );
- }
-
- if( bEnableResizerLeft )
- {
- rcClientLoc.DeflateRect( nSeparatorHeight, 0, 0, 0 );
- rcRowResize = rcClientLoc;
- rcRowResize.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- rcRowResize.right = rcRowResize.left + nSeparatorWidth;
- rcRowResize.bottom = rcRowResize.top + rcDevOrg.Height();
- if( bGripperExists )
- ptGripOffset.x += nSeparatorWidth;
- }
- if( bAddTopRecalc )
- {
- rcRowRecalcUp = rcClientLoc;
- rcRowRecalcUp.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- rcRowRecalcUp.bottom = rcRowRecalcUp.top + nSeparatorWidth;
- if( bGripperExists )
- ptGripOffset.y += nSeparatorHeight;
- rcClientLoc.DeflateRect( 0, nSeparatorHeight, 0, 0 );
- } // if( bAddTopRecalc )
- break;
- } // switch( nDockBarDlgCtrlID )
- } // if( ! IsFixedMode() )
- else
- {
- PmBridge_GetPM()->FixedBar_AdjustClientRect(
- this,
- rcClientLoc
- );
- } // else from if( !IsFixedMode() )
- if( bGripperExists )
- {
- rcGrip = rcClientLoc;
- rcGrip.OffsetRect( -rcClientLoc.left, -rcClientLoc.top );
- if( bGripperAtTop )
- {
- rcGrip.bottom = rcGrip.top + nGripHeightAtTop;
- m_nMinVH += rcGrip.Height();
- if( IsFixedMode() )
- rcGrip.DeflateRect( __BAR_NC_GAP_X, 0 );
- } // if( bGripperAtTop )
- else
- {
- rcGrip.right = rcGrip.left + nGripHeightAtTop;
- m_nMinHW += rcGrip.Width();
- if( IsFixedMode() )
- rcGrip.DeflateRect( 0, __BAR_NC_GAP_Y );
- } // else from if( bGripperAtTop )
- rcGrip.OffsetRect( ptGripOffset );
- if( IsFixedMode() )
- rcGrip.DeflateRect(
- (nDockBarDlgCtrlID == AFX_IDW_DOCKBAR_LEFT) ? __BAR_NC_GAP_X : 0,
- (nDockBarDlgCtrlID == AFX_IDW_DOCKBAR_TOP) ? __BAR_NC_GAP_X : 0,
- (nDockBarDlgCtrlID == AFX_IDW_DOCKBAR_RIGHT) ? __BAR_NC_GAP_X : 0,
- (nDockBarDlgCtrlID == AFX_IDW_DOCKBAR_BOTTOM) ? __BAR_NC_GAP_X : 0
- );
- } // if( bGripperExists )
- OnNcAreaButtonsReinitialize();
- OnNcAreaButtonsReposition();
- if( bGripperExists )
- {
- rcClientLoc.DeflateRect(
- bGripperAtTop
- ? 0
- : nGripWidthAtLeft + __BAR_NC_GAP_X
- ,
- bGripperAtTop
- ? nGripHeightAtTop + __BAR_NC_GAP_Y
- : 0
- ,
- 0,
- 0
- );
- } // if( bGripperExists )
- // if( !IsKindOf(RUNTIME_CLASS(CExtDynControlBar)) )
- // rcClientLoc.DeflateRect( __BAR_NC_GAP_X, __BAR_NC_GAP_Y );
- if( rcClientLoc.bottom < rcClientLoc.top )
- rcClientLoc.bottom = rcClientLoc.top;
- if( rcClientLoc.right < rcClientLoc.left )
- rcClientLoc.right = rcClientLoc.left;
- _RectGripSet( rcGrip );
- _RectRowResizeSet( rcRowResize );
- _RectRowRecalcSet( rcRowRecalc );
- _RectRowRecalcUpSet( rcRowRecalcUp );
- }
- void CExtControlBar::OnNcPaint()
- {
- // if( m_pDockBar == NULL
- // && (!m_bPresubclassDialogMode)
- // )
- // return; // on destruction
- if( m_bDelelayRepaintNcButtons )
- {
- m_bDelelayRepaintNcButtons = false;
- OnNcAreaButtonsReposition();
- }
- #if (defined __DEBUG_PAINTING_AREAS_EXTRESIZABLEBAR__)
- CRect rcBarWnd, rcBarClient;
- GetWindowRect( &rcBarWnd );
- GetClientRect( &rcBarClient );
- ClientToScreen( &rcBarClient );
- if( rcBarWnd == rcBarClient )
- return;
- CPoint ptDevOffset = -rcBarWnd.TopLeft();
- rcBarWnd.OffsetRect( ptDevOffset );
- rcBarClient.OffsetRect( ptDevOffset );
- CWindowDC dcBarWnd( this );
- ASSERT( dcBarWnd.GetSafeHdc() != NULL );
- dcBarWnd.ExcludeClipRect( &rcBarClient );
- CDC & dc = dcBarWnd;
- dc.FillSolidRect( &rcBarWnd, PmBridge_GetPM()->GetColor( COLOR_3DFACE, this ) );
- bool bGripperAtTop = false;
- bool bGripperExists = IsBarWithGripper( &bGripperAtTop );
- if( bGripperExists )
- {
- CRect rcGrip = _RectGripGet();
- // ASSERT( ! rcGrip.IsRectEmpty() );
- CExtSafeString sWndText;
- OnGetBarCaptionText( __EBCT_SINGLE_CAPTION_DOCKED, sWndText );
- dc.FillSolidRect( &rcGrip, PmBridge_GetPM()->GetColor( COLOR_HIGHLIGHT, this ) );
- if( !sWndText.IsEmpty() )
- {
- CRect rcGripText( rcGrip );
- rcGripText.DeflateRect( 2, 2 );
- HFONT hOldFont = (HFONT)
- ::SelectObject(
- dc.GetSafeHdc(),
- ::GetStockObject(DEFAULT_GUI_FONT)
- );
- COLORREF clrTextOld =
- dc.SetTextColor( PmBridge_GetPM()->GetColor( COLOR_HIGHLIGHTTEXT, this ) );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- dc.DrawText(
- sWndText,
- &rcGripText,
- DT_LEFT|DT_VCENTER|DT_END_ELLIPSIS
- );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrTextOld );
- ::SelectObject(
- dc.GetSafeHdc(),
- hOldFont
- );
- }
- } // if( bGripperExists )
- CRect rcRowResize = _RectRowResizeGet();
- CRect rcRowRecalc = _RectRowRecalcGet();
- CRect rcRowRecalcUp = _RectRowRecalcUpGet();
- if( ! rcRowResize.IsRectEmpty() )
- dc.FillSolidRect( &rcRowResize, RGB(255,0,0) );
- if( ! rcRowRecalc.IsRectEmpty() )
- dc.FillSolidRect( &rcRowRecalc, RGB(0,255,0) );
- if( ! rcRowRecalcUp.IsRectEmpty() )
- dc.FillSolidRect( &rcRowRecalcUp, RGB(0,0,255) );
- if( IsBarWithGripper() && !IsFloating() )
- NcButtons_Paint( dc );
- #else // __DEBUG_PAINTING_AREAS_EXTRESIZABLEBAR__
- CWindowDC dc( this );
- CRect rcClient, rcBar;
- GetClientRect( rcClient );
- ClientToScreen( rcClient );
- GetWindowRect( rcBar );
- rcClient.OffsetRect( -rcBar.TopLeft() );
- rcBar.OffsetRect( -rcBar.TopLeft() );
- dc.ExcludeClipRect( rcClient );
- CExtMemoryDC mdc( &dc, &rcBar );
- CUSTOM_NC_AREA_QUERY_DATA _cnaqd( this, mdc.GetSafeHdc() );
- if( ! _cnaqd.Notify() )
- DoPaintNC( &mdc );
- mdc.__Flush();
- ReleaseDC( &dc );
- PmBridge_GetPM()->OnPaintSessionComplete( this );
- #endif // ! __DEBUG_PAINTING_AREAS_EXTRESIZABLEBAR__
- }
- void CExtControlBar::DoPaintNC( CDC * pDC )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pDC );
- ASSERT( pDC->GetSafeHdc() != NULL );
- CRect rcClient, rcBar;
- GetClientRect( rcClient );
- ClientToScreen( rcClient );
- GetWindowRect( rcBar );
- rcClient.OffsetRect( -rcBar.TopLeft() );
- rcBar.OffsetRect( -rcBar.TopLeft() );
- pDC->ExcludeClipRect( rcClient );
- if( (! PmBridge_GetPM()->GetCb2DbTransparentMode(this) )
- || (! PmBridge_GetPM()->PaintDockerBkgnd( false, *pDC, this ) )
- )
- pDC->FillSolidRect(
- &rcBar,
- PmBridge_GetPM()->GetColor(
- CExtPaintManager::CLR_3DFACE_OUT, this
- )
- );
- bool bFloating = IsFloating() ? true : false;
- bool bFixedMode = IsFixedMode();
- bool bPaintFrame = true;
- if( bFloating
- && bFixedMode
- && CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON != NULL
- && CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_pHelperTearOffBar == this
- )
- bPaintFrame = false;
- if( bPaintFrame )
- {
- CExtPaintManager::PAINTDOCKINGFRAMEDATA _pdfd(
- this,
- rcBar,
- rcClient,
- IsBarWindowActive(),
- bFloating,
- ! bFixedMode,
- ! bFixedMode
- );
- PmBridge_GetPM()->PaintDockingFrame( *pDC, _pdfd );
- } // if( bPaintFrame )
- if( ! bFloating )
- {
- bool bHorz = IsDockedHorizontally();
- CRect rc;
- rc = _RectRowResizeGet();
- if( ! rc.IsRectEmpty() )
- PmBridge_GetPM()->PaintResizableBarSeparator(
- *pDC,
- rc,
- bHorz,
- this
- );
- rc = _RectRowRecalcGet();
- if( ! rc.IsRectEmpty() )
- PmBridge_GetPM()->PaintResizableBarSeparator(
- *pDC,
- rc,
- !bHorz,
- this
- );
- rc = _RectRowRecalcUpGet();
- if( ! rc.IsRectEmpty() )
- PmBridge_GetPM()->PaintResizableBarSeparator(
- *pDC,
- rc,
- !bHorz,
- this
- );
- } // if( ! bFloating )
- bool bGripperAtTop = false;
- if( IsBarWithGripper(&bGripperAtTop) && (! bFloating ) )
- {
- CRect rcGrip = _RectGripGet();
- bool bHorz = IsDockedHorizontally();
- CRect rcText( rcGrip );
- if( bHorz && (! bGripperAtTop ) )
- {
- rcText.DeflateRect( 0, 2 );
- rcText.OffsetRect( -2, 0 );
- } // if( bHorz && (! bGripperAtTop ) )
- else
- {
- rcText.DeflateRect( 2, 0 );
- } // else from if( bHorz && (! bGripperAtTop ) )
- NcButtons_CalcGripperTextLocation( rcText );
- CExtSafeString sCaption;
- OnGetBarCaptionText( __EBCT_SINGLE_CAPTION_DOCKED, sCaption );
- CRgn rgnExclude;
- if( rgnExclude.CreateRectRgnIndirect( &rcGrip ) )
- pDC->SelectClipRgn( &rgnExclude );
- CExtControlBar * pFlashingBar = this;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDynTabControlBar * pTabbedBar = DYNAMIC_DOWNCAST( CExtDynTabControlBar, this );
- if( pTabbedBar != NULL )
- {
- LONG nSel = pTabbedBar->GetSwitcherSelection();
- if( nSel >= 0 )
- {
- CExtControlBar * pBar = pTabbedBar->GetBarAt( nSel, true );
- if( pBar != NULL )
- {
- ASSERT_VALID( pBar );
- ASSERT( pBar->GetSafeHwnd() != NULL );
- pFlashingBar = pBar;
- } // if( pBar != NULL )
- } // if( nSel >= 0 )
- } // if( pTabbedBar != NULL )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtPaintManager::PAINTGRIPPERDATA _pgd(
- pFlashingBar, // this
- rcGrip,
- rcText,
- IsBarWindowActive(),
- false,
- bHorz && !bGripperAtTop,
- !bFixedMode,
- sCaption.IsEmpty() ? LPCTSTR( NULL ) : sCaption,
- ( (g_ResourceManager->OnQueryLangLayout()&LAYOUT_RTL) != 0 ) ? true : false
- );
- bool bDrawDefaultCaption = true, bFlashCaptionHighlightedState = false;
- if( pFlashingBar->FlashCaptionIsInProgress( &bFlashCaptionHighlightedState ) )
- {
- _pgd.m_bFlashCaptionHighlightedState = bFlashCaptionHighlightedState;
- _pgd.m_clrFlashCaptionText = pFlashingBar->m_clrFlashCaptionText;
- _pgd.m_clrFlashCaptionBackground = pFlashingBar->m_clrFlashCaptionBackground;
- if( pFlashingBar->FlashCaption_DoPaintNC(
- *pDC,
- (LPVOID)(&_pgd)
- )
- )
- bDrawDefaultCaption = false;
- } // if( pFlashingBar->FlashCaptionIsInProgress( &bFlashCaptionHighlightedState ) )
- if( bDrawDefaultCaption )
- {
- PmBridge_GetPM()->PaintGripper( *pDC, _pgd );
- NcButtons_Paint( *pDC );
- } // if( bDrawDefaultCaption )
- pDC->SelectClipRgn( NULL );
- } // if( IsBarWithGripper(&bGripperAtTop) && (! bFloating ) )
- }
- void CExtControlBar::OnSysColorChange()
- {
- CControlBar::OnSysColorChange();
- //CExtPaintManager * pPM = PmBridge_GetPM();
- // g_PaintManager.OnSysColorChange( this );
- // g_CmdManager.OnSysColorChange( pPM, this );
- _RecalcLayoutImpl();
- }
- void CExtControlBar::OnSettingChange(UINT uFlags, __EXT_MFC_SAFE_LPCTSTR lpszSection)
- {
- CControlBar::OnSettingChange(uFlags, lpszSection);
- // m_nGripHeightAtTop = ::GetSystemMetrics(SM_CYSMCAPTION)+1;
- // m_nGripWidthAtLeft = ::GetSystemMetrics(SM_CYSMCAPTION)+1;
- // m_nSeparatorHeight = min( 4, ::GetSystemMetrics(SM_CYSIZEFRAME) );
- // m_nSeparatorWidth = min( 4, ::GetSystemMetrics(SM_CXSIZEFRAME) );
- // m_nMinHW = ::GetSystemMetrics(SM_CYSMCAPTION)+1 + m_nSeparatorHeight;
- // m_nMinVH = ::GetSystemMetrics(SM_CYSMCAPTION)+1 + m_nSeparatorHeight;
- CExtPaintManager * pPM = PmBridge_GetPM();
- g_PaintManager.OnSettingChange( this, uFlags, lpszSection );
- g_CmdManager.OnSettingChange( pPM, this, uFlags, lpszSection );
- _RecalcLayoutImpl();
- }
- LRESULT CExtControlBar::OnDisplayChange( WPARAM wParam, LPARAM lParam )
- {
- LRESULT lResult = CControlBar::OnDisplayChange( wParam, lParam );
- //CExtPaintManager * pPM = PmBridge_GetPM();
- // g_PaintManager.OnDisplayChange( this, (INT)wParam, CPoint(lParam) );
- // g_CmdManager.OnDisplayChange( pPM, this, (INT)wParam, CPoint(lParam) );
- return lResult;
- }
- LRESULT CExtControlBar::OnThemeChanged( WPARAM wParam, LPARAM lParam )
- {
- wParam;
- lParam;
- LRESULT lResult = Default();
- //CExtPaintManager * pPM = PmBridge_GetPM();
- // g_PaintManager.OnThemeChanged( this, wParam, lParam );
- // g_CmdManager.OnThemeChanged( pPM, this, wParam, lParam );
- return lResult;
- }
- void CExtControlBar::OnCancelMode()
- {
- if( m_bRowResizing )
- _RowResizingStop( true );
- if( m_bRowRecalcing )
- _RowRecalcingStop( true );
- if( m_bDragging )
- _DraggingStop( true );
- // CExtPopupMenuWnd::CancelMenuTracking();
- CWnd::CancelToolTips();
- // ASSERT( !CExtPopupMenuWnd::IsMenuTracking() );
- if( m_bNcAreaBtnTracking )
- {
- m_bNcAreaBtnTracking = false;
- PostMessage( WM_NCPAINT );
- if( GetSafeHwnd() != NULL
- && ::GetCapture() == m_hWnd
- )
- ::ReleaseCapture();
- }
- CControlBar::OnCancelMode();
- }
- void CExtControlBar::OnCaptureChanged(CWnd *pWnd)
- {
- if( m_bRowResizing )
- _RowResizingStop( true );
- if( m_bRowRecalcing )
- _RowRecalcingStop( true );
- // if( m_bDragging )
- // _DraggingStop( true );
- CControlBar::OnCaptureChanged(pWnd);
- }
- bool CExtControlBar::_OnMouseMoveMsg(UINT nFlags, CPoint point)
- {
- nFlags;
- _SetCursor( point );
- if( m_bNcAreaBtnTracking )
- return true;
- if( m_bRowResizing )
- {
- _RowResizingUpdateState();
- return true;
- }
- if( m_bRowRecalcing )
- {
- _RowRecalcingUpdateState();
- return true;
- }
- if( m_bDragging )
- {
- CPoint ptScreen( point );
- ClientToScreen( &ptScreen );
- _DraggingUpdateState(
- ptScreen,
- CExtPopupMenuWnd::IsKeyPressed(VK_CONTROL) ? true : false
- );
- return true;
- }
- if( IsFloating()
- && CExtMiniDockFrameWnd::g_bAutoMakeTopmostOnMouseEvent
- && (!CExtPopupMenuWnd::IsMenuTracking())
- )
- {
- CFrameWnd * pParentFrame = GetParentFrame();
- if( pParentFrame != NULL )
- pParentFrame->BringWindowToTop();
- }
- return false;
- }
- void CExtControlBar::OnMouseMove(UINT nFlags, CPoint point)
- {
- __PROF_UIS_MANAGE_STATE;
- if( ! CExtPopupMenuWnd::IsMenuTracking() )
- {
- if( ! OnQueryBarHoverProcessingEnabled() )
- return;
- } // if( ! CExtPopupMenuWnd::IsMenuTracking() )
- if( _OnMouseMoveMsg(nFlags,point) )
- return;
- CControlBar::OnMouseMove(nFlags,point);
- }
- bool CExtControlBar::OnQueryBarHoverProcessingEnabled() const
- {
- ASSERT_VALID( this );
- HWND hWndOwn = GetSafeHwnd();
- if( hWndOwn == NULL )
- return false;
- if( ! CExtPopupMenuWnd::TestHoverEnabledFromActiveHWND( hWndOwn ) )
- return false;
- return true;
- }
- bool CExtControlBar::_RowRecalcing_IsBottomEnabled()
- {
- // previous or next CExtControlBar should not be minimized
- ExtControlBarVector_t vBars;
- _GetRowExtBars( vBars );
- INT nCountOfBars = (INT)vBars.GetSize();
- bool bThisPassed = false;
- CExtControlBar * pBarPrev = NULL, * pBarNext = NULL;
- for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CExtControlBar * pBar = vBars[ nBar ];
- ASSERT_VALID( pBar );
- if( !pBar->IsVisible() )
- continue;
- if( !bThisPassed )
- pBarPrev = pBar;
- else
- {
- pBarNext = pBar;
- break;
- }
- if( pBar == this )
- {
- bThisPassed = true;
- continue;
- }
- } // for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- bool bMinimizedPrev = true, bMinimizedNext = true;
- if( pBarPrev != NULL )
- bMinimizedPrev = pBarPrev->IsMinimizedOnRow();
- if( pBarNext != NULL )
- bMinimizedNext = pBarNext->IsMinimizedOnRow();
- if( bMinimizedPrev && bMinimizedNext )
- return false;
- return true;
- }
- bool CExtControlBar::_RowRecalcing_IsTopEnabled()
- {
- // this or next extbar should not be minimized
- ExtControlBarVector_t vBars;
- _GetRowExtBars( vBars );
- INT nCountOfBars = (INT)vBars.GetSize();
- CExtControlBar * pBarNext = NULL;
- for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CExtControlBar * pBar = vBars[ nCountOfBars - nBar - 1 ];
- ASSERT_VALID( pBar );
- if( !pBar->IsVisible() )
- continue;
- if( pBar == this )
- break;
- pBarNext = pBar;
- } // for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- bool bMinimizedNext = true;
- if( pBarNext != NULL )
- bMinimizedNext = pBarNext->IsMinimizedOnRow();
- if( bMinimizedNext && IsMinimizedOnRow() )
- return false;
- return true;
- }
- void CExtControlBar::OnNcLButtonDown(UINT nHitTest, CPoint point)
- {
- ASSERT_VALID( this );
- _ActivateOnClick();
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = NotifiedCustomizeSiteGet();
- if( pSite != NULL
- && pSite->IsCustomizeMode()
- )
- pSite->DropTargetPopupCancel();
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( IsFixedMode() || IsFloating() )
- return;
- switch( nHitTest )
- {
- case HTLEFT:
- case HTBOTTOM:
- break; // case HTLEFT & HTBOTTOM
- default:
- if( ( !IsFixedMode() )
- && ( !IsMinimizedOnRow() )
- )
- {
- CPoint ptScreen( point );
- //ClientToScreen( &ptScreen );
- CExtBarNcAreaButton * pBtn = NULL;
- ( const_cast < CExtControlBar * > ( this ) ) ->
- NcButtons_HitTest( ptScreen, &pBtn );
- if( pBtn == NULL ) // (+ v.2.24)
- {
- if( stat_QueryFocusChangingEnabled( this, m_hWnd ) )
- SetFocus();
- }
- }
- //return;
- break;
- } // switch( nHitTest )
- ASSERT( !m_bRowRecalcing );
- ASSERT( !m_bRowResizing );
- CRect rcBarWnd, rcBarClient;
- GetWindowRect( &rcBarWnd );
- GetClientRect( &rcBarClient );
- ClientToScreen( &rcBarClient );
- if( rcBarWnd == rcBarClient )
- return;
- CPoint ptDevOffset = -rcBarWnd.TopLeft();
- // rcBarWnd.OffsetRect( ptDevOffset );
- // rcBarClient.OffsetRect( ptDevOffset );
- point += ptDevOffset;
- CRect rcRowResize = _RectRowResizeGet();
- CRect rcRowRecalc = _RectRowRecalcGet();
- CRect rcRowRecalcUp = _RectRowRecalcUpGet();
- bool bHorz = IsDockedHorizontally();
- if( (! rcRowResize.IsRectEmpty() )
- && rcRowResize.PtInRect( point )
- )
- {
- ASSERT( (INT)nHitTest == (bHorz ? HTBOTTOM : HTRIGHT) );
- _RowResizingStart();
- return;
- }
- if( (! rcRowRecalc.IsRectEmpty() )
- && rcRowRecalc.PtInRect( point )
- )
- {
- ASSERT( !_IsLastBarInRow( true ) );
- ASSERT( (INT)nHitTest == (bHorz ? HTRIGHT : HTBOTTOM) );
- m_bTopRecalcing = false;
-
- if( !_RowRecalcing_IsBottomEnabled() )
- return;
-
- _RowRecalcingStart();
- return;
- }
- if( (! rcRowRecalcUp.IsRectEmpty() )
- && rcRowRecalcUp.PtInRect( point )
- )
- {
- ASSERT( !_IsFirstBarInRow( true ) );
- ASSERT( (INT)nHitTest == (bHorz ? HTLEFT : HTTOP) );
- if( !_RowRecalcing_IsTopEnabled() )
- return;
-
- m_bTopRecalcing = true;
- _RowRecalcingStart();
- return;
- }
- CPoint ptScreen = point + rcBarWnd.TopLeft();
- bool bNeedRepaint = false;
- UINT nHT = NcButtons_HitTest( ptScreen );
- if( nHT == HTCLIENT )
- {
- if( m_bNcAreaBtnTracking )
- bNeedRepaint = true;
- m_bNcAreaBtnTracking = false;
- if( GetSafeHwnd() != NULL
- && ::GetCapture() == m_hWnd
- )
- ::ReleaseCapture();
- } // if( nHT == HTCLIENT )
- else
- {
- if( !m_bNcAreaBtnTracking )
- bNeedRepaint = true;
- m_bNcAreaBtnTracking = true;
- if( GetSafeHwnd() != NULL
- && ::GetCapture() != m_hWnd
- )
- ::SetCapture( m_hWnd );
- } // else from if( nHT == HTCLIENT )
- if( bNeedRepaint )
- {
- SendMessage( WM_NCPAINT );
- GetParent()->SendMessage( WM_NCPAINT );
- }
- }
- void CExtControlBar::OnNcLButtonUp(UINT nHitTest, CPoint point)
- {
- // if( m_bNcAreaBtnTracking )
- // {
- // if( GetSafeHwnd() == NULL
- // || ::GetCapture() != m_hWnd
- // )
- // return;
- // ::ReleaseCapture();
- // CRect rcBarWnd;
- // GetWindowRect( &rcBarWnd );
- // CPoint ptDevOffset = -rcBarWnd.TopLeft();
- // CPoint ptWnd( point + ptDevOffset );
- // INT nCountOfNcButtons = NcButtons_GetCount();
- // for( INT nBtn = 0; nBtn < nCountOfNcButtons; nBtn++ )
- // {
- // CExtBarNcAreaButton * pBtn =
- // NcButtons_GetAt( nBtn );
- // if( ! pBtn->OnQueryVisibility() )
- // continue;
- // if( pBtn->OnNcAreaClicked( ptWnd ) )
- // return;
- // } // for( INT nBtn = 0; nBtn < nCountOfNcButtons; nBtn++ )
- // return;
- // }
- if( m_bRowResizing )
- {
- _RowResizingStop( false );
- return;
- }
-
- if( m_bRowRecalcing )
- {
- _RowRecalcingStop( false );
- return;
- }
-
- if( m_bDragging )
- {
- //_DraggingStop( false );
- return;
- }
- CControlBar::OnNcLButtonUp(nHitTest, point);
- }
- void CExtControlBar::OnRButtonDown(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- _ActivateOnClick();
- CControlBar::OnRButtonDown( nFlags, point );
- }
- void CExtControlBar::OnMButtonDown(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- _ActivateOnClick();
- CControlBar::OnMButtonDown( nFlags, point );
- }
- void CExtControlBar::OnLButtonDown(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- if( m_pDockBar == NULL || CExtPopupMenuWnd::IsMenuTracking() )
- {
- CWnd::OnLButtonDown(nFlags, point);
- return;
- }
- _ActivateOnClick();
- // start dragging
- ASSERT_VALID( m_pDockBar );
- ASSERT( m_pDockContext != NULL );
- ClientToScreen( &point );
-
- bool bExtendedDragging = _IsShowContentWhenDragging();
- if( !bExtendedDragging && IsFixedMode() )
- {
- m_pDockContext->StartDrag( point );
- return;
- }
- if( m_pDockBar != NULL && (!IsFloating()) )
- {
- if( !m_pDockBar->IsKindOf(
- RUNTIME_CLASS(CExtDockBar)
- )
- )
- bExtendedDragging = false;
- }
- if( IsFloating() )
- {
- CMiniDockFrameWnd * pMiniFrame =
- DYNAMIC_DOWNCAST(
- CMiniDockFrameWnd,
- GetDockingFrame()
- );
- ASSERT_VALID( pMiniFrame );
- CExtMiniDockFrameWnd * pExtMiniFrame =
- DYNAMIC_DOWNCAST(
- CExtMiniDockFrameWnd,
- GetDockingFrame()
- );
- if( pExtMiniFrame != NULL )
- {
- pExtMiniFrame->OnNcLButtonDown(
- HTCAPTION,
- point
- );
- return;
- }
- } // if( IsFloating() )
- if( ! IsFixedMode() )
- {
- if( stat_QueryFocusChangingEnabled( this, m_hWnd ) )
- SetFocus();
- }
- CPoint ptOffset( point );
- CRect rcWnd;
- GetWindowRect( &rcWnd );
- ptOffset -= rcWnd.TopLeft();
- _DraggingStart( point, ptOffset );
- }
- void CExtControlBar::OnLButtonUp(UINT nFlags, CPoint point)
- {
- if( m_bRowResizing )
- {
- _RowResizingStop( false );
- return;
- }
- if( m_bRowRecalcing )
- {
- _RowRecalcingStop( false );
- return;
- }
- if( m_bDragging )
- {
- _DraggingStop( false );
- return;
- }
- if( m_bNcAreaBtnTracking )
- {
- if( GetSafeHwnd() == NULL
- || ::GetCapture() != m_hWnd
- )
- return;
- ::ReleaseCapture();
- CRect rcBarWnd;
- GetWindowRect( &rcBarWnd );
- CPoint ptDevOffset = -rcBarWnd.TopLeft();
- CPoint ptWnd = point;
- ClientToScreen( &ptWnd );
- ptWnd += ptDevOffset;
- INT nCountOfNcButtons = NcButtons_GetCount();
- for( INT nBtn = 0; nBtn < nCountOfNcButtons; nBtn++ )
- {
- CExtBarNcAreaButton * pBtn =
- NcButtons_GetAt( nBtn );
- if( ! pBtn->OnQueryVisibility() )
- continue;
- if( pBtn->OnNcAreaClicked( ptWnd ) )
- return;
- } // for( INT nBtn = 0; nBtn < nCountOfNcButtons; nBtn++ )
- return;
- }
- CControlBar::OnLButtonUp(nFlags, point);
- }
- void CExtControlBar::OnRButtonUp(UINT nFlags, CPoint point)
- {
- nFlags;
- // if( m_bRowResizing )
- // _RowResizingStop();
- // if( m_bRowRecalcing )
- // _RowRecalcingStop();
- // if( m_bDragging )
- // _DraggingStop( false );
- // CControlBar::OnRButtonUp(nFlags, point);
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = NotifiedCustomizeSiteGet();
- if( pSite != NULL
- && pSite->IsCustomizeMode()
- )
- return;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( m_bPresubclassDialogMode
- || _GetDockingFrameImpl() == NULL
- || CExtControlBar::FindHelpMode( this )
- )
- {
- CControlBar::OnRButtonUp( nFlags, point );
- return;
- }
- CFrameWnd * pFrame = _GetDockingFrameImpl();
- ASSERT_VALID( pFrame );
- if( ! ::GetCursorPos(&point) )
- return;
- if( (! IsFixedMode() )
- && (! IsKindOf(RUNTIME_CLASS(CExtPanelControlBar)) )
- )
- {
- CPoint ptClient = point;
- ScreenToClient( &ptClient );
- CRect rcClient;
- GetClientRect( &rcClient );
- if( rcClient.PtInRect(ptClient) )
- return;
- }
- HWND hWndTrack = GetOwner()->GetSafeHwnd();
- ASSERT( hWndTrack != NULL && ::IsWindow(hWndTrack) );
- CExtPopupMenuWnd * pPopup =
- CExtPopupMenuWnd::InstantiatePopupMenu(
- GetSafeHwnd(),
- RUNTIME_CLASS(CExtPopupMenuWnd),
- this
- );
- VERIFY( pPopup->CreatePopupMenu(hWndTrack) );
- if( ! CExtDockBar::_ConstructDockSiteControlBarPopupMenu(
- pFrame,
- pPopup,
- CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_CTX,
- this,
- WM_RBUTTONUP,
- NULL
- )
- )
- {
- delete pPopup;
- return;
- }
- if( pPopup->ItemGetCount() == 0 )
- {
- delete pPopup;
- return;
- }
- CWnd * pWndChild = GetWindow( GW_CHILD );
- if( pWndChild != NULL )
- {
- HWND hWndOwn = m_hWnd;
- if( stat_QueryFocusChangingEnabled( this, pWndChild->m_hWnd ) )
- {
- pWndChild->SetFocus();
- CExtPopupMenuWnd::PassMsgLoop( true );
- if( ! ::IsWindow( hWndOwn ) )
- {
- delete pPopup;
- return;
- }
- m_bWindowActive = true;
- SendMessage( WM_NCPAINT );
- }
- }
- if( ! pPopup->TrackPopupMenu(
- TPMX_OWNERDRAW_FIXED,
- point.x,
- point.y,
- NULL,
- this,
- NULL,
- NULL,
- true
- )
- )
- {
- //delete pPopup;
- }
- }
- void CExtControlBar::OnNcRButtonUp(UINT nHitTest, CPoint point)
- {
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = NotifiedCustomizeSiteGet();
- if( pSite != NULL
- && pSite->IsCustomizeMode()
- )
- return;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( m_bPresubclassDialogMode
- || _GetDockingFrameImpl() == NULL
- || CExtControlBar::FindHelpMode( this )
- )
- {
- CControlBar::OnNcRButtonUp( nHitTest, point );
- return;
- }
- CFrameWnd * pFrame = _GetDockingFrameImpl();
- ASSERT_VALID( pFrame );
- if( ! ::GetCursorPos(&point) )
- return;
- HWND hWndTrack = GetOwner()->GetSafeHwnd();
- ASSERT( hWndTrack != NULL && ::IsWindow(hWndTrack) );
- CExtPopupMenuWnd * pPopup =
- CExtPopupMenuWnd::InstantiatePopupMenu(
- GetSafeHwnd(),
- RUNTIME_CLASS(CExtPopupMenuWnd),
- this
- );
- VERIFY( pPopup->CreatePopupMenu(hWndTrack) );
- if( ! CExtDockBar::_ConstructDockSiteControlBarPopupMenu(
- pFrame,
- pPopup,
- CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_NC_CTX,
- this,
- WM_RBUTTONUP,
- NULL
- )
- )
- {
- delete pPopup;
- return;
- }
- if( pPopup->ItemGetCount() == 0 )
- {
- delete pPopup;
- return;
- }
- if( stat_QueryFocusChangingEnabled( this, hWndTrack ) )
- ::SetFocus( hWndTrack );
- if( ! pPopup->TrackPopupMenu(
- TPMX_OWNERDRAW_FIXED,
- point.x,
- point.y,
- NULL,
- this,
- NULL,
- NULL,
- true
- )
- )
- {
- //delete pPopup;
- }
- }
- void CExtControlBar::OnLButtonDblClk(UINT nFlags, CPoint point)
- {
- if( m_pDockBar == NULL )
- {
- CWnd::OnLButtonDblClk(nFlags, point);
- return;
- }
- if( ! _FloatStateChangingIsEnabled( this ) )
- return;
- ToggleDocking();
- }
- void CExtControlBar::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
- {
- if( m_pDockBar == NULL || nHitTest != HTCAPTION )
- {
- CWnd::OnNcLButtonDblClk(nHitTest, point);
- return;
- }
- if( ! _FloatStateChangingIsEnabled( this ) )
- return;
- ToggleDocking();
- }
- void CExtControlBar::OnNcMButtonDown(UINT nHitTest, CPoint point)
- {
- ASSERT_VALID( this );
- _ActivateOnClick();
- CControlBar::OnNcMButtonDown( nHitTest, point );
- }
- void CExtControlBar::OnNcRButtonDown(UINT nHitTest, CPoint point)
- {
- ASSERT_VALID( this );
- _ActivateOnClick();
- CControlBar::OnNcRButtonDown( nHitTest, point );
- }
- bool CExtControlBar::_IsShowContentWhenDragging() const
- {
- //BOOL bDragShowContent = FALSE;
- // ::SystemParametersInfo(
- // SPI_GETDRAGFULLWINDOWS,
- // 0,
- // &bDragShowContent,
- // 0
- // );
- // return bDragShowContent ? true : false;
- #if (!defined __EXT_MFC_NO_DOCK_MARKERS)
- eResizablePanelDockingType_t eResizablePanelDockingType =
- OnQueryDockingType();
- if( INT(eResizablePanelDockingType) >= INT(__RESIZABLE_DOCKING_TYPE_STUDIO_2005) )
- return true;
- #endif // (!defined __EXT_MFC_NO_DOCK_MARKERS)
- return false;
- }
- bool CExtControlBar::_IsShowContentWhenRowResizing() const
- {
- #if (!defined __EXT_MFC_NO_DOCK_MARKERS)
- eResizablePanelDockingType_t eResizablePanelDockingType =
- OnQueryDockingType();
- if( INT(eResizablePanelDockingType) >= INT(__RESIZABLE_DOCKING_TYPE_STUDIO_2005) )
- return false;
- #endif // (!defined __EXT_MFC_NO_DOCK_MARKERS)
- return _IsShowContentWhenDragging();
- }
- bool CExtControlBar::_IsShowContentWhenRowRecalcing() const
- {
- #if (!defined __EXT_MFC_NO_DOCK_MARKERS)
- eResizablePanelDockingType_t eResizablePanelDockingType =
- OnQueryDockingType();
- if( INT(eResizablePanelDockingType) >= INT(__RESIZABLE_DOCKING_TYPE_STUDIO_2005) )
- return false;
- #endif // (!defined __EXT_MFC_NO_DOCK_MARKERS)
- return _IsShowContentWhenDragging();
- }
- CExtControlBar::e_control_bar_position_changing_t CExtControlBar::GetCurrentControlBarPositionChangingType() const
- {
- ASSERT_VALID( this );
- return m_eCBPC;
- }
- void CExtControlBar::OnControlBarPositionChange(
- CExtControlBar * pBarEventSrc,
- e_control_bar_position_changing_t eCBPC,
- bool bInitial,
- bool bFinal
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBarEventSrc );
- pBarEventSrc;
- if( ! ( bInitial && bFinal ) )
- {
- if( bInitial && m_eCBPC == __ECBPC_EMPTY )
- m_eCBPC = eCBPC;
- else if( bFinal && m_eCBPC == eCBPC )
- m_eCBPC = __ECBPC_EMPTY;
- }
- }
- void CExtControlBar::_OnControlBarPositionChange_RedockingImpl(
- CExtControlBar * pBarEventSrc,
- e_control_bar_position_changing_t eCBPC,
- bool bInitial,
- bool bFinal
- )
- {
- ASSERT_VALID( this );
- m_bDelayShowInvoked = true;
- m_bDelayShowFlag = IsVisible() ? true : false;
- CExtDynControlBar * pDynContainer = _GetNearestDynamicContainer();
- if( pDynContainer != NULL )
- {
- pDynContainer->m_bDelayShowInvoked = true;
- pDynContainer->m_bDelayShowFlag = m_bDelayShowFlag;
- }
- ExtControlBarVector_t vBars;
- _GetFrameControlBars(
- NULL,
- pBarEventSrc->m_pDockSite,
- vBars
- );
- INT nCountOfBars = (INT)vBars.GetSize();
- ASSERT( nCountOfBars > 0 );
- for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CExtControlBar * pBar = vBars[ nBar ];
- ASSERT_VALID( pBar );
- pBar->OnControlBarPositionChange(
- pBarEventSrc,
- eCBPC,
- bInitial,
- bFinal
- );
- }
- }
- void CExtControlBar::_OnControlBarPositionChange_InRowImpl(
- CExtControlBar * pBarEventSrc,
- e_control_bar_position_changing_t eCBPC,
- bool bInitial,
- bool bFinal
- )
- {
- ASSERT_VALID( this );
- _OnControlBarPositionChange_RedockingImpl(
- pBarEventSrc,
- eCBPC,
- bInitial,
- bFinal
- );
- //ExtControlBarVector_t vBars;
- // _GetRowExtBars( vBars );
- //INT nCountOfBars = (INT)vBars.GetSize();
- // ASSERT( nCountOfBars > 0 );
- // for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- // {
- // CExtControlBar * pBar = vBars[ nBar ];
- // ASSERT_VALID( pBar );
- // pBar->OnControlBarPositionChange(
- // pBarEventSrc,
- // eCBPC,
- // bInitial,
- // bFinal
- // );
- // }
- }
- CRect CExtControlBar::g_rcHelperRowResizingLimits( -32767, -32767, 32767, 32767 );
- void CExtControlBar::_RowResizingStart()
- {
- ASSERT( !m_bRowRecalcing );
- ASSERT( !m_bRowResizing );
- g_rcHelperRowResizingLimits.SetRect( -32767, -32767, 32767, 32767 );
- CWnd::CancelToolTips();
- CExtToolControlBar::_CloseTrackingMenus();
- CExtPopupMenuWnd::CancelMenuTracking();
- if( m_pDockSite->GetSafeHwnd() != NULL )
- {
- if( GetParentFrame() == m_pDockSite )
- {
- ASSERT_VALID( m_pDockBar );
- ASSERT( m_pDockBar->GetSafeHwnd() != NULL );
- CWnd * pWnd = m_pDockBar;
- for( ; true; )
- {
- CWnd * pWnd2 = pWnd->GetParent();
- if( pWnd2 == NULL )
- {
- pWnd = NULL;
- break;
- }
- if( pWnd2 == m_pDockSite )
- break;
- pWnd = pWnd2;
- } // for( ; true; )
- if( pWnd != NULL )
- {
- CExtDockBar * pDockBar = DYNAMIC_DOWNCAST( CExtDockBar, pWnd );
- if( pDockBar != NULL )
- {
- UINT nDockBarID = UINT( pDockBar->GetDlgCtrlID() );
- if( nDockBarID == AFX_IDW_DOCKBAR_TOP
- || nDockBarID == AFX_IDW_DOCKBAR_BOTTOM
- || nDockBarID == AFX_IDW_DOCKBAR_LEFT
- || nDockBarID == AFX_IDW_DOCKBAR_RIGHT
- )
- {
- CRect rcFrameInner, rcOwnClient;
- GetClientRect( &rcOwnClient );
- m_pDockSite->GetClientRect( &rcFrameInner );
- m_pDockSite->RepositionBars(
- 0,
- 0x0FFFF,
- AFX_IDW_PANE_FIRST,
- CWnd::reposQuery,
- rcFrameInner,
- rcFrameInner
- );
- ClientToScreen( &rcOwnClient );
- m_pDockSite->ClientToScreen( &rcFrameInner );
- g_rcHelperRowResizingLimits = rcOwnClient;
- switch( nDockBarID )
- {
- case AFX_IDW_DOCKBAR_TOP:
- g_rcHelperRowResizingLimits.bottom = rcFrameInner.bottom;
- break;
- case AFX_IDW_DOCKBAR_BOTTOM:
- g_rcHelperRowResizingLimits.top = rcFrameInner.top;
- break;
- case AFX_IDW_DOCKBAR_LEFT:
- g_rcHelperRowResizingLimits.right = rcFrameInner.right;
- break;
- case AFX_IDW_DOCKBAR_RIGHT:
- g_rcHelperRowResizingLimits.left = rcFrameInner.left;
- break;
- } // switch( nDockBarID )
- }
- } // if( pDockBar != NULL )
- } // if( pWnd != NULL )
- } // if( GetParentFrame() == m_pDockSite )
- POSITION pos = m_pDockSite->m_listControlBars.GetHeadPosition();
- for( ; pos != NULL; )
- {
- CControlBar * pBar = (CControlBar *)
- m_pDockSite->m_listControlBars.GetNext( pos );
- if( pBar->GetSafeHwnd() == NULL
- || pBar->IsDockBar()
- )
- continue;
- CExtMenuControlBar * pMenuBar =
- DYNAMIC_DOWNCAST( CExtMenuControlBar, pBar );
- if( pMenuBar == NULL )
- continue;
- pMenuBar->_CancelFlatTracking();
- } // for( ; pos != NULL; )
- } // if( m_pDockSite->GetSafeHwnd() != NULL )
- if( ! _RowResizingIsEnabled(this) )
- return;
- _OnControlBarPositionChange_InRowImpl(
- this,
- __ECBPC_ROW_RESIZING,
- true,
- false
- );
- m_bRowResizing = true;
- CExtMouseCaptureSink::SetCapture( GetSafeHwnd() );
- ASSERT_VALID( m_pDockSite );
- ASSERT( !IsFloating() );
- m_nMetricOffset = IsDockedHorizontally() ?
- m_sizeDockedH.cy : m_sizeDockedV.cx;
- if( !_IsShowContentWhenRowResizing() )
- {
- CPoint ptCursorScreen( 0, 0 );
- ::GetCursorPos( &ptCursorScreen );
- m_nTrackerOffset =
- IsDockedHorizontally()
- ? ptCursorScreen.y : ptCursorScreen.x;
- _DrawResizingTracker( false );
- } // if( !_IsShowContentWhenRowResizing() )
- while( m_bRowResizing )
- {
- ::WaitMessage();
- MSG msg;
- // Process all the messages in the message queue
- while( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
- {
- bool bStop = false;
- switch( msg.message )
- {
- case WM_ACTIVATEAPP:
- case WM_CANCELMODE:
- // case WM_LBUTTONUP:
- case WM_RBUTTONDOWN:
- case WM_NCLBUTTONUP:
- // case WM_NCLBUTTONDOWN:
- case WM_NCRBUTTONUP:
- case WM_NCRBUTTONDOWN:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_NCMBUTTONDOWN:
- case WM_NCMBUTTONUP:
- case WM_CONTEXTMENU:
- bStop = true;
- break;
- default:
- if( WM_KEYFIRST <= msg.message
- && msg.message <= WM_KEYLAST
- )
- bStop = true;
- // else
- // {
- // if( CExtMouseCaptureSink::GetCapture() != GetSafeHwnd() )
- // bStop = true;
- // else
- // {
- // if( (!CExtPopupMenuWnd::
- // IsKeyPressed(VK_LBUTTON))
- // || CExtPopupMenuWnd::
- // IsKeyPressed(VK_RBUTTON)
- // || CExtPopupMenuWnd::
- // IsKeyPressed(VK_MBUTTON)
- // )
- // bStop = true;
- // }
- // }
- break;
- } // switch( msg.message )
- if( bStop )
- {
- _RowResizingStop( true );
- break;
- }
- if( !AfxGetThread()->PumpMessage() )
- {
- PostQuitMessage(0);
- break; // Signal WM_QUIT received
- } // if( !AfxGetThread()->PumpMessage() )
- } // while( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
- if( m_bRowResizing && CExtControlBar::g_bEnableOnIdleCalls )
- {
- for( LONG nIdleCounter = 0L;
- ::AfxGetThread()->OnIdle(nIdleCounter);
- nIdleCounter ++
- );
- }
- } // while( m_bRowResizing )
- _OnControlBarPositionChange_InRowImpl(
- this,
- __ECBPC_ROW_RESIZING,
- false,
- true
- );
- }
- void CExtControlBar::_RowResizingStop( bool bCancel )
- {
- m_bRowResizing = false;
- if( CExtMouseCaptureSink::GetCapture() == GetSafeHwnd() )
- CExtMouseCaptureSink::ReleaseCapture();
- ASSERT_VALID( m_pDockSite );
- ASSERT_VALID( m_pDockBar );
- ASSERT( !IsFloating() );
- if( !_IsShowContentWhenRowResizing() )
- {
- _DrawResizingTracker( true );
- if( !bCancel )
- {
- bool bHorz = IsDockedHorizontally();
- if( m_nMetricOffset !=
- (bHorz ? m_sizeDockedH.cy : m_sizeDockedV.cx)
- )
- {
- ExtControlBarVector_t vBars;
- _GetRowExtBars( vBars );
- INT nCountOfBars = (INT)vBars.GetSize();
- ASSERT( nCountOfBars > 0 );
- LONG nDiff = 0;
- for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CExtControlBar * pBar = vBars[ nBar ];
- ASSERT_VALID( pBar );
- // if( !pBar->IsVisible() )
- // continue;
- if( pBar->IsFixedMode() )
- continue;
- if( bHorz )
- {
- if( nDiff == 0 )
- nDiff = pBar->m_sizeDockedH.cy - m_nMetricOffset;
- pBar->m_sizeDockedH.cy = m_nMetricOffset;
- }
- else
- {
- if( nDiff == 0 )
- nDiff = pBar->m_sizeDockedV.cx - m_nMetricOffset;
- pBar->m_sizeDockedV.cx = m_nMetricOffset;
- }
- } // for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- if( nDiff != 0 )
- {
- UINT nDockBarID = GetSafeDockBarDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nDockBarID );
- MfcControlBarVector_t vNextRow;
- if( nDockBarID == AFX_IDW_DOCKBAR_TOP
- || nDockBarID == AFX_IDW_DOCKBAR_LEFT
- )
- _GetNextRowBars( true, vNextRow );
- else
- _GetNextRowBars( false, vNextRow );
- INT nCountOfBars = (INT)vNextRow.GetSize();
- for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CExtControlBar * pBar = (CExtControlBar *)vNextRow[ nBar ];
- ASSERT_VALID( pBar );
- if( !pBar->IsKindOf( RUNTIME_CLASS(CExtControlBar) ) )
- continue;
- if( pBar->IsFixedMode() )
- continue;
- if( bHorz )
- pBar->m_sizeDockedH.cy += nDiff;
- else
- pBar->m_sizeDockedV.cx += nDiff;
- } // for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- } // if( nDiff != 0 )
- }
- //xx//
- //m_pDockSite->RecalcLayout();
- GetParentFrame()->RecalcLayout();
- } // if( !bCancel )
- ASSERT_VALID( m_pDockBar );
- m_pDockBar->RedrawWindow(
- NULL, NULL,
- RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASENOW
- |RDW_ALLCHILDREN
- |RDW_NOFRAME
- );
- } // if( !_IsShowContentWhenRowResizing() )
- }
- void CExtControlBar::_RowResizingUpdateState()
- {
- ASSERT( m_bRowResizing );
- ASSERT_VALID( m_pDockSite );
- CRect rcDockSite;
- m_pDockSite->GetWindowRect( &rcDockSite );
- CSize sizeDockMax =
- rcDockSite.Size()
- - CSize(
- _CalcDesiredMinHW(),
- _CalcDesiredMinVH()
- );
- if( sizeDockMax.cx <= 0 || sizeDockMax.cy <= 0 )
- return;
- CPoint ptCursorScreen( 0, 0 );
- ::GetCursorPos( &ptCursorScreen );
- if( ptCursorScreen.x < g_rcHelperRowResizingLimits.left )
- ptCursorScreen.x = g_rcHelperRowResizingLimits.left;
- if( ptCursorScreen.x > g_rcHelperRowResizingLimits.right )
- ptCursorScreen.x = g_rcHelperRowResizingLimits.right;
- if( ptCursorScreen.y < g_rcHelperRowResizingLimits.top )
- ptCursorScreen.y = g_rcHelperRowResizingLimits.top;
- if( ptCursorScreen.y > g_rcHelperRowResizingLimits.bottom )
- ptCursorScreen.y = g_rcHelperRowResizingLimits.bottom;
- CPoint ptCursor( ptCursorScreen );
- CRect rcBarWnd;
- GetWindowRect( &rcBarWnd );
- CPoint ptDevOffset = -rcBarWnd.TopLeft();
- ptCursor += ptDevOffset;
- CRect rcRowResize = _RectRowResizeGet();
- CRect rcRowRecalc = _RectRowRecalcGet();
- CRect rcRowRecalcUp = _RectRowRecalcUpGet();
- bool bHorz = IsDockedHorizontally();
- if( bHorz )
- {
- INT nMin1 = _CalcDesiredMinVH();
- bool bTop = IsDockedAtTop();
- INT nMin2 = bTop
- ? (ptCursor.y + rcRowResize.Height()/2)
- : (m_sizeDockedH.cy - ptCursor.y + rcRowResize.Height()/2)
- ;
- m_nMetricOffset = max( nMin1, nMin2 );
- if( m_nMetricOffset > sizeDockMax.cy )
- m_nMetricOffset = sizeDockMax.cy;
- if( m_nMetricOffset == m_sizeDockedH.cy )
- return;
- } // if( bHorz )
- else
- {
- INT nMin1 = _CalcDesiredMinHW();
- bool bLeft = IsDockedAtLeft();
- INT nMin2 = bLeft
- ? (ptCursor.x + rcRowResize.Width()/2)
- : (m_sizeDockedV.cx - ptCursor.x + rcRowResize.Width()/2 )
- ;
- m_nMetricOffset = max( nMin1, nMin2 );
- if( m_nMetricOffset > sizeDockMax.cx )
- m_nMetricOffset = sizeDockMax.cx;
- if( m_nMetricOffset == m_sizeDockedV.cx )
- return;
- } // else from if( bHorz )
- bool bShowContent = _IsShowContentWhenRowResizing();
- if( bShowContent )
- {
- ExtControlBarVector_t vBars;
- _GetRowExtBars( vBars );
- INT nCountOfBars = (INT)vBars.GetSize();
- ASSERT( nCountOfBars > 0 );
- LONG nDiff = 0;
- for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CExtControlBar * pBar = vBars[ nBar ];
- ASSERT_VALID( pBar );
- // if( !pBar->IsVisible() )
- // continue;
- if( pBar->IsFixedMode() )
- continue;
- if( bHorz )
- {
- if( nDiff == 0 )
- nDiff = pBar->m_sizeDockedH.cy - m_nMetricOffset;
- pBar->m_sizeDockedH.cy = m_nMetricOffset;
- }
- else
- {
- if( nDiff == 0 )
- nDiff = pBar->m_sizeDockedV.cx - m_nMetricOffset;
- pBar->m_sizeDockedV.cx = m_nMetricOffset;
- }
- } // for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- /*
- if( nDiff != 0 )
- {
- UINT nDockBarID = GetSafeDockBarDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nDockBarID );
- MfcControlBarVector_t vNextRow;
- if( nDockBarID == AFX_IDW_DOCKBAR_TOP
- || nDockBarID == AFX_IDW_DOCKBAR_LEFT
- )
- _GetNextRowBars( true, vNextRow );
- else
- _GetNextRowBars( false, vNextRow );
- INT nCountOfBars = vNextRow.GetSize();
- for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CExtControlBar * pBar = (CExtControlBar *)vNextRow[ nBar ];
- ASSERT_VALID( pBar );
- if( !pBar->IsKindOf( RUNTIME_CLASS(CExtControlBar) ) )
- continue;
- if( pBar->IsFixedMode() )
- continue;
- if( bHorz )
- pBar->m_sizeDockedH.cy += nDiff;
- else
- pBar->m_sizeDockedV.cx += nDiff;
- } // for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- } // if( nDiff != 0 )
- */
- m_pDockSite->RecalcLayout();
- ASSERT_VALID( m_pDockBar );
- if( m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockBar)) )
- ((CExtDockBar *)m_pDockBar)->OnDynamicLayoutUpdate();
- CExtPaintManager::stat_PassPaintMessages();
- _OnControlBarPositionChange_InRowImpl(
- this,
- __ECBPC_ROW_RESIZING,
- false,
- false
- );
- return;
- } // if( bShowContent )
- _DrawResizingTracker( true );
- m_nTrackerOffset =
- bHorz ? ptCursorScreen.y : ptCursorScreen.x;
- _OnControlBarPositionChange_InRowImpl(
- this,
- __ECBPC_ROW_RESIZING,
- false,
- false
- );
- _DrawResizingTracker( false );
- }
- bool CExtControlBar::g_bLockAllBars = false;
- bool CExtControlBar::_DraggingIsEnabled(
- const CExtControlBar * pBarQuerySrc
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBarQuerySrc );
- pBarQuerySrc;
- return (! g_bLockAllBars );
- }
- bool CExtControlBar::_RowResizingIsEnabled(
- const CExtControlBar * pBarQuerySrc
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBarQuerySrc );
- pBarQuerySrc;
- return (! g_bLockAllBars );
- }
- bool CExtControlBar::_RowResizingGet() const
- {
- ASSERT_VALID( this );
- return m_bRowResizing;
- }
- void CExtControlBar::_RowRecalcingStart()
- {
- ASSERT( !m_bRowRecalcing );
- ASSERT( !m_bRowResizing );
- CWnd::CancelToolTips();
- CExtToolControlBar::_CloseTrackingMenus();
- CExtPopupMenuWnd::CancelMenuTracking();
- if( m_pDockSite->GetSafeHwnd() != NULL )
- {
- POSITION pos = m_pDockSite->m_listControlBars.GetHeadPosition();
- for( ; pos != NULL; )
- {
- CControlBar * pBar = (CControlBar *)
- m_pDockSite->m_listControlBars.GetNext( pos );
- if( pBar->GetSafeHwnd() == NULL
- || pBar->IsDockBar()
- )
- continue;
- CExtMenuControlBar * pMenuBar =
- DYNAMIC_DOWNCAST( CExtMenuControlBar, pBar );
- if( pMenuBar == NULL )
- continue;
- pMenuBar->_CancelFlatTracking();
- } // for( ; pos != NULL; )
- } // if( m_pDockSite->GetSafeHwnd() != NULL )
- if( ! _RowRecalcingIsEnabled(this) )
- return;
- _OnControlBarPositionChange_InRowImpl(
- this,
- __ECBPC_IN_ROW_RESIZING,
- true,
- false
- );
- m_bRowRecalcing = true;
- CExtMouseCaptureSink::SetCapture( GetSafeHwnd() );
- ASSERT_VALID( m_pDockSite );
- if( !_IsShowContentWhenRowRecalcing() )
- {
- CPoint ptCursorScreen( 0, 0 );
- ::GetCursorPos( &ptCursorScreen );
- m_nTrackerOffset =
- IsDockedHorizontally()
- ? ptCursorScreen.x
- : ptCursorScreen.y;
- m_nMetricOffset = 0;
- _DrawRecalcingTracker( false );
- } // if( !_IsShowContentWhenRowRecalcing() )
- while( m_bRowRecalcing )
- {
- ::WaitMessage();
- MSG msg;
- // Process all the messages in the message queue
- while( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
- {
- bool bStop = false;
- switch( msg.message )
- {
- case WM_ACTIVATEAPP:
- case WM_CANCELMODE:
- // case WM_LBUTTONUP:
- case WM_RBUTTONDOWN:
- // case WM_NCLBUTTONUP:
- case WM_NCLBUTTONDOWN:
- case WM_NCRBUTTONUP:
- case WM_NCRBUTTONDOWN:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_NCMBUTTONDOWN:
- case WM_NCMBUTTONUP:
- case WM_CONTEXTMENU:
- bStop = true;
- break;
- default:
- if( WM_KEYFIRST <= msg.message
- && msg.message <= WM_KEYLAST
- )
- bStop = true;
- // else
- // {
- // if( CExtMouseCaptureSink::GetCapture() != GetSafeHwnd() )
- // bStop = true;
- // else
- // {
- // if( (!CExtPopupMenuWnd::
- // IsKeyPressed(VK_LBUTTON))
- // || CExtPopupMenuWnd::
- // IsKeyPressed(VK_RBUTTON)
- // || CExtPopupMenuWnd::
- // IsKeyPressed(VK_MBUTTON)
- // )
- // bStop = true;
- // }
- // }
- break;
- } // switch( msg.message )
- if( bStop )
- {
- _RowRecalcingStop( true );
- break;
- }
- if( !AfxGetThread()->PumpMessage() )
- {
- PostQuitMessage(0);
- break; // Signal WM_QUIT received
- } // if( !AfxGetThread()->PumpMessage() )
- } // while( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
- if( m_bRowRecalcing && CExtControlBar::g_bEnableOnIdleCalls )
- {
- for( LONG nIdleCounter = 0L;
- ::AfxGetThread()->OnIdle(nIdleCounter);
- nIdleCounter ++
- );
- }
- } // while( m_bRowRecalcing )
- _OnControlBarPositionChange_InRowImpl(
- this,
- __ECBPC_IN_ROW_RESIZING,
- false,
- true
- );
- }
- void CExtControlBar::_RowRecalcingStop( bool bCancel )
- {
- m_bRowRecalcing = false;
- if( CExtMouseCaptureSink::GetCapture() == GetSafeHwnd() )
- CExtMouseCaptureSink::ReleaseCapture();
- ASSERT_VALID( m_pDockSite );
- ASSERT_VALID( m_pDockBar );
- ASSERT( !IsFloating() );
- if( !_IsShowContentWhenRowRecalcing() )
- {
- _DrawRecalcingTracker( true );
- if( !bCancel )
- {
- if( m_nMetricOffset != 0 )
- {
- bool bHorz = IsDockedHorizontally();
- ExtControlBarVector_t vBars;
- _GetRowExtBars( vBars );
- INT nCountOfBars = (INT)vBars.GetSize();
- ASSERT( nCountOfBars > 1 );
- bool bThisPassed = false;
- for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CExtControlBar * pBar =
- vBars[
- m_bTopRecalcing
- ? (nCountOfBars - nBar - 1)
- : nBar
- ];
- ASSERT_VALID( pBar );
- if( pBar == this )
- {
- bThisPassed = true;
- continue;
- }
- if( !bThisPassed )
- continue;
- if( bHorz )
- {
- pBar->m_sizeDockedH.cx += m_nMetricOffset;
- if( pBar->m_sizeDockedH.cx < pBar->_CalcDesiredMinHW() )
- {
- m_sizeDockedH.cx -=
- pBar->_CalcDesiredMinHW() - pBar->m_sizeDockedH.cx;
- pBar->m_sizeDockedH.cx = pBar->_CalcDesiredMinHW();
- }
- } // if( bHorz )
- else
- {
- pBar->m_sizeDockedV.cy += m_nMetricOffset;
- if( pBar->m_sizeDockedV.cy < pBar->_CalcDesiredMinVH() )
- {
- m_sizeDockedV.cy -=
- pBar->_CalcDesiredMinVH() - pBar->m_sizeDockedV.cy;
- pBar->m_sizeDockedV.cy = pBar->_CalcDesiredMinVH();
- }
- } // else from if( bHorz )
- break;
- } // for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- if( bHorz )
- {
- m_sizeDockedH.cx -= m_nMetricOffset;
- if( m_sizeDockedH.cx < _CalcDesiredMinHW() )
- {
- m_sizeDockedH.cx +=
- _CalcDesiredMinHW() - m_sizeDockedH.cx;
- m_sizeDockedH.cx = _CalcDesiredMinHW();
- }
- } // if( bHorz )
- else
- {
- m_sizeDockedV.cy -= m_nMetricOffset;
- if( m_sizeDockedV.cy < _CalcDesiredMinVH() )
- {
- m_sizeDockedV.cy +=
- _CalcDesiredMinVH() - m_sizeDockedV.cy;
- m_sizeDockedV.cy = _CalcDesiredMinVH();
- }
- } // else from if( bHorz )
- //xx//
- //m_pDockSite->RecalcLayout();
- GetParentFrame()->RecalcLayout();
- } // if( m_nMetricOffset != 0 )
- } // if( !bCancel )
- /*ASSERT_VALID( m_pDockBar );
- m_pDockBar->RedrawWindow(
- NULL, NULL,
- RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASENOW
- |RDW_ALLCHILDREN
- |RDW_NOFRAME
- );*/
-
- } // if( !_IsShowContentWhenRowRecalcing() )
- }
- void CExtControlBar::_RowRecalcingUpdateState()
- {
- ASSERT( m_bRowRecalcing );
- ASSERT_VALID( m_pDockBar );
- ASSERT_VALID( m_pDockSite );
- CPoint ptCursorScreen( 0, 0 );
- ::GetCursorPos( &ptCursorScreen );
- CPoint ptCursor( ptCursorScreen );
- CRect rcBarWnd;
- GetWindowRect( &rcBarWnd );
- CPoint ptDevOffset = -rcBarWnd.TopLeft();
- ptCursor += ptDevOffset;
- CRect rcRowRecalc = _RectRowRecalcGet();
- CRect rcRowRecalcUp = _RectRowRecalcUpGet();
- bool bSysDragShowContent = _IsShowContentWhenRowRecalcing();
- bool bHorz = IsDockedHorizontally();
- if( bHorz )
- {
- if( m_bTopRecalcing )
- {
- INT nMetric =
- max(
- _CalcDesiredMinHW(),
- (m_sizeDockedH.cx - ptCursor.x + rcRowRecalcUp.Width()/2)
- );
- m_nMetricOffset = m_sizeDockedH.cx - nMetric;
- if( m_nMetricOffset == 0 )
- return;
- if( bSysDragShowContent )
- m_sizeDockedH.cx = nMetric;
- } // if( m_bTopRecalcing )
- else
- {
- INT nMetric =
- max(
- _CalcDesiredMinHW(),
- (ptCursor.x + rcRowRecalc.Width()/2)
- );
- m_nMetricOffset = m_sizeDockedH.cx - nMetric;
- if( m_nMetricOffset == 0 )
- return;
- if( bSysDragShowContent )
- m_sizeDockedH.cx = nMetric;
- } // else from if( bTopRecalcing )
- } // if( bHorz )
- else
- {
- if( m_bTopRecalcing )
- {
- INT nMetric =
- max(
- _CalcDesiredMinVH(),
- (m_sizeDockedV.cy - ptCursor.y + rcRowRecalcUp.Height()/2)
- );
- m_nMetricOffset = m_sizeDockedV.cy - nMetric;
- if( m_nMetricOffset == 0 )
- return;
- if( bSysDragShowContent )
- m_sizeDockedV.cy = nMetric;
- } // if( m_bTopRecalcing )
- else
- {
- INT nMetric =
- max(
- _CalcDesiredMinVH(),
- (ptCursor.y + rcRowRecalc.Height()/2)
- );
- m_nMetricOffset = m_sizeDockedV.cy - nMetric;
- if( m_nMetricOffset == 0 )
- return;
- if( bSysDragShowContent )
- m_sizeDockedV.cy = nMetric;
- } // else from if( m_bTopRecalcing )
- } // else from if( bHorz )
- ASSERT( m_nMetricOffset != 0 );
- if( bSysDragShowContent )
- {
- ExtControlBarVector_t vBars;
- _GetRowExtBars( vBars );
- INT nCountOfBars = (INT)vBars.GetSize();
- ASSERT( nCountOfBars > 1 );
- bool bThisPassed = false;
- for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CExtControlBar * pBar =
- vBars[
- m_bTopRecalcing
- ? (nCountOfBars - nBar - 1)
- : nBar
- ];
- ASSERT_VALID( pBar );
- if( pBar == this )
- {
- bThisPassed = true;
- continue;
- }
- if( !bThisPassed )
- continue;
- if( bHorz )
- {
- pBar->m_sizeDockedH.cx += m_nMetricOffset;
- if( pBar->m_sizeDockedH.cx < pBar->_CalcDesiredMinHW() )
- {
- m_sizeDockedH.cx -=
- pBar->_CalcDesiredMinHW() - pBar->m_sizeDockedH.cx;
- pBar->m_sizeDockedH.cx = pBar->_CalcDesiredMinHW();
- }
- } // if( bHorz )
- else
- {
- pBar->m_sizeDockedV.cy += m_nMetricOffset;
- if( pBar->m_sizeDockedV.cy < pBar->_CalcDesiredMinVH() )
- {
- m_sizeDockedV.cy -=
- pBar->_CalcDesiredMinVH() - pBar->m_sizeDockedV.cy;
- pBar->m_sizeDockedV.cy = pBar->_CalcDesiredMinVH();
- }
- } // else from if( bHorz )
- break;
- } // for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- m_pDockSite->RecalcLayout();
- _OnControlBarPositionChange_InRowImpl(
- this,
- __ECBPC_IN_ROW_RESIZING,
- false,
- false
- );
- ASSERT_VALID( m_pDockBar );
- if( m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockBar)) )
- ((CExtDockBar *)m_pDockBar)->OnDynamicLayoutUpdate();
-
- return;
- } // if( bSysDragShowContent )
- ASSERT_VALID( m_pDockBar );
- CRect rcDockBarWnd;
- m_pDockBar->GetWindowRect( &rcDockBarWnd );
- INT nMinTrackerOffset = bHorz ?
- rcDockBarWnd.left : rcDockBarWnd.top;
- if( m_bTopRecalcing )
- {
- MfcControlBarVector_t vBars;
- _GetRowBars( vBars );
- INT nCountOfBars = (INT)vBars.GetSize();
- for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CControlBar * pBar = vBars[ nBar ];
- ASSERT_VALID( pBar );
- if( !pBar->IsVisible() )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar != NULL && pExtBar->IsFixedMode() )
- pExtBar = NULL;
- if( pExtBar == NULL )
- {
- CRect rcBarWnd;
- pBar->GetWindowRect( &rcBarWnd );
- nMinTrackerOffset += bHorz ?
- rcBarWnd.Width() : rcBarWnd.Height();
- } // if( pExtBar == NULL )
- else
- {
- nMinTrackerOffset += bHorz
- ? pExtBar->_CalcDesiredMinHW()
- : pExtBar->_CalcDesiredMinVH();
- } // else from if( pExtBar == NULL )
- if( pBar == this )
- break;
- } // for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- } // if( m_bTopRecalcing )
- else
- {
- nMinTrackerOffset = bHorz
- ? rcBarWnd.left + _CalcDesiredMinHW()
- : rcBarWnd.top + _CalcDesiredMinVH()
- ;
- } // else from if( m_bTopRecalcing )
- INT nMaxTrackerOffset = 0;
- if( m_bTopRecalcing )
- {
- nMaxTrackerOffset = bHorz
- ? rcBarWnd.right - _CalcDesiredMinHW()
- : rcBarWnd.bottom - _CalcDesiredMinVH()
- ;
- } // if( m_bTopRecalcing )
- else
- {
- nMaxTrackerOffset = bHorz ?
- rcDockBarWnd.right : rcDockBarWnd.bottom;
- MfcControlBarVector_t vBars;
- _GetRowBars( vBars );
- INT nCountOfBars = (INT)vBars.GetSize();
- for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CControlBar * pBar = vBars[ nCountOfBars - nBar - 1 ];
- ASSERT_VALID( pBar );
- if( !pBar->IsVisible() )
- continue;
- if( pBar == this )
- break;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar != NULL && pExtBar->IsFixedMode() )
- pExtBar = NULL;
- if( pExtBar == NULL )
- {
- CRect rcBarWnd;
- pBar->GetWindowRect( &rcBarWnd );
- nMaxTrackerOffset -= bHorz ?
- rcBarWnd.Width() : rcBarWnd.Height();
- } // if( pExtBar == NULL )
- else
- {
- nMaxTrackerOffset -= bHorz
- ? pExtBar->_CalcDesiredMinHW()
- : pExtBar->_CalcDesiredMinVH();
- } // else from if( pExtBar == NULL )
- } // for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- } // else from if( m_bTopRecalcing )
- _DrawRecalcingTracker( true );
- m_nTrackerOffset = bHorz
- ? ptCursorScreen.x
- : ptCursorScreen.y;
- ASSERT( nMinTrackerOffset <= nMaxTrackerOffset );
- if( m_nTrackerOffset < nMinTrackerOffset )
- m_nTrackerOffset = nMinTrackerOffset;
- if( m_nTrackerOffset > nMaxTrackerOffset )
- m_nTrackerOffset = nMaxTrackerOffset;
- _OnControlBarPositionChange_InRowImpl(
- this,
- __ECBPC_IN_ROW_RESIZING,
- false,
- false
- );
- _DrawRecalcingTracker( false );
- }
- bool CExtControlBar::_RowRecalcingIsEnabled(
- const CExtControlBar * pBarQuerySrc
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBarQuerySrc );
- pBarQuerySrc;
- return (! g_bLockAllBars );
- }
- bool CExtControlBar::_RowRecalcingGet() const
- {
- ASSERT_VALID( this );
- return m_bRowRecalcing;
- }
- void CExtControlBar::_DrawResizingTracker( bool bErasingPrevious )
- {
- ASSERT_VALID( this );
- ASSERT( !IsFloating() );
- ASSERT_VALID( m_pDockSite );
- ASSERT_VALID( m_pDockBar );
- CRect rcDockBar;
- m_pDockBar->GetWindowRect( &rcDockBar );
- if( rcDockBar.IsRectEmpty() )
- return;
- CRect rcRowResize = _RectRowResizeGet();
- CRect rcTracker( rcDockBar );
- if( IsDockedHorizontally() )
- {
- rcTracker.top =
- m_nTrackerOffset - rcRowResize.Height()/2;
- rcTracker.bottom =
- m_nTrackerOffset + rcRowResize.Height()/2;
- } // if( IsDockedHorizontally() )
- else
- {
- rcTracker.left =
- m_nTrackerOffset - rcRowResize.Width()/2;
- rcTracker.right =
- m_nTrackerOffset + rcRowResize.Width()/2;
- } // else from if( IsDockedHorizontally() )
- CFrameWnd * pFrame = GetDockingFrame(); // m_pDockSite;
- ASSERT_VALID( pFrame );
- CRect rcDockingFrame;
- pFrame->GetWindowRect( &rcDockingFrame );
- rcTracker.OffsetRect( -rcDockingFrame.TopLeft() );
- CDC * pDC = pFrame->GetDCEx( NULL, __DOCKSITE_DCX_FLAGS );
- DWORD dwOldLayout = pDC->SetLayout( LAYOUT_LTR );
- MsgDrawTrackedAreaData_t _MsgDrawTrackedAreaData(
- *this,
- *pDC,
- __EDTAT_RESIZING_ENTIRE_ROW,
- rcTracker,
- bErasingPrevious
- );
- _MsgDrawTrackedAreaData.NotifyOrDrawDefault();
- pDC->SetLayout( dwOldLayout );
- pFrame->ReleaseDC(pDC);
- }
- void CExtControlBar::_DrawRecalcingTracker( bool bErasingPrevious )
- {
- ASSERT_VALID( this );
- ASSERT( !IsFloating() );
- ASSERT_VALID( m_pDockSite );
- ASSERT_VALID( m_pDockBar );
- CRect rcRowRecalc = _RectRowRecalcGet();
- CRect rcRowRecalcUp = _RectRowRecalcUpGet();
- CRect rcTracker;
- GetWindowRect( &rcTracker );
- if( IsDockedHorizontally() )
- {
- INT nMetric =
- m_bTopRecalcing
- ? rcRowRecalcUp.Width()/2
- : rcRowRecalc.Width()/2;
- rcTracker.left =
- m_nTrackerOffset - nMetric;
- rcTracker.right =
- m_nTrackerOffset + nMetric;
- } // if( IsDockedHorizontally() )
- else
- {
- INT nMetric =
- m_bTopRecalcing
- ? rcRowRecalcUp.Height()/2
- : rcRowRecalc.Height()/2;
- rcTracker.top =
- m_nTrackerOffset - nMetric;
- rcTracker.bottom =
- m_nTrackerOffset + nMetric;
- } // else from if( IsDockedHorizontally() )
- CFrameWnd * pFrame = GetDockingFrame(); // m_pDockSite;
- ASSERT_VALID( pFrame );
- CRect rcDockingFrame;
- pFrame->GetWindowRect( &rcDockingFrame );
- rcTracker.OffsetRect( -rcDockingFrame.TopLeft() );
- CDC * pDC = pFrame->GetDCEx( NULL, __DOCKSITE_DCX_FLAGS );
- DWORD dwOldLayout = pDC->SetLayout( LAYOUT_LTR );
- MsgDrawTrackedAreaData_t _MsgDrawTrackedAreaData(
- *this,
- *pDC,
- __EDTAT_RESIZING_ENTIRE_ROW,
- rcTracker,
- bErasingPrevious
- );
- _MsgDrawTrackedAreaData.NotifyOrDrawDefault();
- pDC->SetLayout( dwOldLayout );
- pFrame->ReleaseDC(pDC);
- }
- bool CExtControlBar::IsOleIpObjActive(
- CFrameWnd * pFrameSearch
- )
- {
- if( FindPrintPreviewMode( pFrameSearch ) )
- return false;
- if( pFrameSearch == NULL )
- {
- pFrameSearch =
- DYNAMIC_DOWNCAST( CFrameWnd, AfxGetMainWnd() );
- if( pFrameSearch == NULL )
- return false;
- }
- //ASSERT_VALID( pFrameSearch );
- if( pFrameSearch->IsKindOf(RUNTIME_CLASS(CMiniDockFrameWnd)) )
- {
- pFrameSearch = pFrameSearch->GetParentFrame();
- ASSERT_VALID( pFrameSearch );
- ASSERT( !pFrameSearch->IsKindOf(RUNTIME_CLASS(CMiniDockFrameWnd)) );
- }
- CMDIFrameWnd * pFrameSearchMDI =
- DYNAMIC_DOWNCAST(
- CMDIFrameWnd,
- pFrameSearch
- );
- if( pFrameSearchMDI != NULL
- && pFrameSearchMDI->m_hWndMDIClient != NULL
- && ::IsWindow( pFrameSearchMDI->m_hWndMDIClient )
- )
- {
- // pFrameSearch = NULL;
- // BOOL bMaximized = FALSE;
- // HWND hWndActiveFrame = (HWND)
- // ::SendMessage(
- // pFrameSearchMDI->m_hWndMDIClient,
- // WM_MDIGETACTIVE,
- // 0,
- // (LPARAM)&bMaximized
- // );
- // if( hWndActiveFrame != NULL )
- // {
- // CWnd * pWndPermanent =
- // CWnd::FromHandlePermanent( hWndActiveFrame );
- // if( pWndPermanent != NULL )
- // {
- // CMDIChildWnd * pWndMDIChild =
- // DYNAMIC_DOWNCAST(
- // CMDIChildWnd,
- // pWndPermanent
- // );
- // if( pWndMDIChild != NULL
- // && (! pWndMDIChild->m_bPseudoInactive )
- // && (pWndMDIChild->GetStyle()&WS_VISIBLE) != 0
- // )
- // pFrameSearch = pWndMDIChild;
- // }
- // }
- pFrameSearch = ((CMDIFrameWnd*)pFrameSearch)->GetActiveFrame();
- if( pFrameSearch == NULL )
- return false;
- }
- bool bOleInplaceItemActivated = false;
- CView * pActiveView = pFrameSearch->GetActiveView();
- if( pActiveView != NULL
- && (! pActiveView->IsKindOf(RUNTIME_CLASS(CPreviewView)) )
- )
- {
- ASSERT_VALID( pActiveView );
- CDocument * pActiveDoc = pActiveView->GetDocument();
- if( pActiveDoc != NULL )
- {
- ASSERT_VALID( pActiveDoc );
- COleDocument * pActiveOleDoc =
- DYNAMIC_DOWNCAST(COleDocument,pActiveDoc);
- if( pActiveOleDoc != NULL )
- {
- ASSERT_VALID( pActiveOleDoc );
- COleClientItem * pItem =
- pActiveOleDoc->GetInPlaceActiveItem(pActiveView);
- if( pItem != NULL )
- bOleInplaceItemActivated = true;
- } // if( pActiveOleDoc != NULL )
- } // if( pActiveDoc != NULL )
- } // if( pActiveView != NULL ...
- return bOleInplaceItemActivated;
- }
- bool CExtControlBar::IsOleIpObjActive() const
- {
- ASSERT_VALID( this );
- return IsOleIpObjActive( _GetDockingFrameImpl() );
- }
- bool CExtControlBar::SafeDisplayBar()
- {
- if( m_bPresubclassDialogMode )
- {
- if( GetStyle() & WS_VISIBLE )
- return true;
- return false;
- }
- if( IsVisible() )
- {
- if( (m_nStateFlags & delayShow) == 0 )
- return true;
- } // if( IsVisible() )
- if( m_nStateFlags &
- //(CControlBar::delayHide | CControlBar::tempHide)
- CControlBar::tempHide
- )
- return false;
- CFrameWnd * pFrame =
- _GetDockingFrameImpl();
- ASSERT_VALID( pFrame );
- bool bOleInplaceItemActivated =
- //CExtControlBar::IsOleIpObjActive( pFrame );
- IsOleIpObjActive();
- if( bOleInplaceItemActivated &&
- (m_dwStyle & CBRS_HIDE_INPLACE)
- )
- return false;
- // pFrame->ShowControlBar( this, TRUE, TRUE );
- // pFrame = GetParentFrame();
- // ASSERT_VALID( pFrame );
- // pFrame->RecalcLayout();
- CExtControlBar::DoFrameBarCheckCmd(
- pFrame,
- UINT(GetDlgCtrlID())
- );
- HWND hWndThis = GetSafeHwnd();
- CExtPopupMenuWnd::PassMsgLoop(false);
- if( ! ::IsWindow(hWndThis) )
- return false;
- if( !IsVisible() )
- {
- ASSERT( FALSE );
- return false;
- }
- return true;
- }
- bool CExtControlBar::IsSingleOnRow(
- bool bOnlyFixed, // = false
- bool bOnlyNonFixed // = false
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( !IsFloating() );
- ASSERT_VALID( m_pDockBar );
- INT nTotalDockCount = (INT)m_pDockBar->m_arrBars.GetSize();
- bool bThisFound = false;
- INT nCountInRow = 0;
- for( INT nBar = 0; nBar < nTotalDockCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pDockBar->m_arrBars[ nBar ];
- if( pBar == NULL )
- {
- if( bThisFound )
- break;
- nCountInRow = 0;
- continue;
- }
- if( __PLACEHODLER_BAR_PTR( pBar ) )
- continue;
- ASSERT_KINDOF( CControlBar, pBar );
- if( pBar == (CControlBar *)this )
- bThisFound = true;
- if( !pBar->IsVisible() )
- continue;
- if( bOnlyFixed || bOnlyNonFixed )
- {
- bool bFixed = true;
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- && !((CExtControlBar *)pBar)->IsFixedMode()
- )
- bFixed = false;
- if( bOnlyFixed && !bFixed )
- continue;
- if( !bOnlyFixed && bFixed )
- continue;
- } // if( bOnlyFixed || bOnlyNonFixed )
- nCountInRow++;
- if( bThisFound && nCountInRow > 1 )
- return false;
- } // for( INT nBar = 0; nBar < nTotalDockCount; nBar++ )
- // ASSERT( nCountInRow >= 1 );
- return (nCountInRow == 1) ? true : false;
- }
- void CExtControlBar::MakeSingleOnRow()
- {
- CFrameWnd * pFrame = GetDockingFrame();
- ASSERT_VALID( pFrame );
- pFrame->RecalcLayout();
- ASSERT_VALID( m_pDockBar );
- int nPos = m_pDockBar->FindBar( this );
- ASSERT( 1 <= nPos && nPos < m_pDockBar->m_arrBars.GetSize() );
- if( nPos < m_pDockBar->m_arrBars.GetSize()
- && m_pDockBar->m_arrBars[nPos+1] != NULL
- )
- m_pDockBar->m_arrBars.InsertAt(
- nPos+1, ((CControlBar*)NULL) );
- if( m_pDockBar->m_arrBars[nPos-1] != NULL )
- m_pDockBar->m_arrBars.InsertAt(
- nPos, ((CControlBar*)NULL) );
- if( IsDockedHorizontally() )
- m_sizeDockedH = CSize( MAXSHORT, m_sizeDockedH.cy );
- else
- m_sizeDockedV = CSize( m_sizeDockedV.cx, MAXSHORT );
- pFrame->RecalcLayout();
- }
- bool CExtControlBar::IsMinimizedOnRow() const
- {
- if( IsDockedVertically()
- && m_sizeDockedV.cy == _CalcDesiredMinVH()
- )
- return true;
- if( IsDockedHorizontally()
- && m_sizeDockedH.cx == _CalcDesiredMinHW()
- )
- return true;
- return false;
- }
- bool CExtControlBar::IsMaximizedOnRow() const
- {
- if( IsFloating() )
- return false;
- if(IsMinimizedOnRow())
- return false;
- ExtControlBarVector_t vBars;
- ( const_cast < CExtControlBar * > ( this ) ) ->
- _GetRowExtBars(
- vBars
- );
- INT nCountOfBars = (INT)vBars.GetSize();
- for( int nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CExtControlBar * pBar = vBars[ nBar ];
- ASSERT( pBar != NULL );
- if( pBar == this )
- continue;
- if( !(pBar->IsMinimizedOnRow()) )
- return false;
- }
- return true;
- }
- void CExtControlBar::MinimizeOnRow()
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pDockSite );
- ASSERT_VALID( m_pDockBar );
- ASSERT( GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( GetSafeHwnd() ) != NULL );
- if( IsFloating () || IsSingleOnRow() )
- return;
- ExtControlBarVector_t vBars;
- _GetRowExtBars(vBars);
- INT nCountOfBars = (INT)vBars.GetSize();
- if( nCountOfBars <= 1 )
- return;
- CExtDockBar * pDockBar =
- (CExtDockBar*) m_pDockBar;
- ASSERT( pDockBar != NULL );
- BOOL bHorz = IsDockedHorizontally();
- INT nCalcExtentMax = 0;
- if( bHorz )
- {
- INT nMin = _CalcDesiredMinHW();
- nCalcExtentMax = m_sizeDockedH.cx - nMin;
- m_sizeDockedH.cx = nMin;
- ASSERT( nCalcExtentMax >= 0 );
- }
- else
- {
- INT nMin = _CalcDesiredMinVH();
- nCalcExtentMax = m_sizeDockedV.cy - nMin;
- m_sizeDockedV.cy = nMin;
- ASSERT( nCalcExtentMax >= 0 );
- }
- for( INT nBar = 0; nCalcExtentMax > 0; nBar++ )
- {
- if( nBar == nCountOfBars )
- nBar = 0;
- CExtControlBar * pBar = vBars[ nBar ];
- ASSERT_VALID( pBar );
- if( pBar != this )
- {
- if( bHorz )
- pBar->m_sizeDockedH.cx++;
- else
- pBar->m_sizeDockedV.cy++;
- nCalcExtentMax--;
- } // if( pBar != this )
- } // for( nBar = 0; nCalcExtentMax > 0; nBar++ )
- GetParentFrame()->RecalcLayout();
- //_GetDockingFrameImpl()->SetFocus();
- }
- void CExtControlBar::MaximizeOnRow()
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pDockSite );
- ASSERT_VALID( m_pDockBar );
- ASSERT( GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( GetSafeHwnd() ) != NULL );
- if( IsFloating () || IsSingleOnRow() )
- return;
- ExtControlBarVector_t vBars;
- _GetRowExtBars(vBars);
- INT nCountOfBars = (INT)vBars.GetSize();
- if( nCountOfBars <= 1 )
- return;
- CExtDockBar * pDockBar =
- (CExtDockBar*) m_pDockBar;
- ASSERT( pDockBar != NULL );
- BOOL bHorz = IsDockedHorizontally();
- INT nMetric = 0;
- for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CExtControlBar * pBar = vBars[ nBar ];
- ASSERT_VALID( pBar );
- if( pBar == this )
- continue;
- if( bHorz )
- {
- INT nMin = pBar->_CalcDesiredMinHW();
- nMetric += pBar->m_sizeDockedH.cx - nMin;
- pBar->m_sizeDockedH.cx = nMin;
- }
- else
- {
- INT nMin = pBar->_CalcDesiredMinVH();
- nMetric += pBar->m_sizeDockedV.cy - nMin;
- pBar->m_sizeDockedV.cy = nMin;
- }
- } // for( INT nBar = 0; nBar < nCountOfBars; nBar++ )
- if( bHorz )
- m_sizeDockedH.cx += nMetric;
- else
- m_sizeDockedV.cy += nMetric;
- GetParentFrame()->RecalcLayout();
- }
- void CExtControlBar::OnRepositionSingleChild(
- int cx, // = -1, // if negative - get from client area
- int cy, // = -1
- bool bRedraw // = TRUE
- )
- {
- if( ! m_bReposSingleChildMode )
- return;
- // automatic child resizing - only one child is allowed
- HWND hWndChild = ::GetWindow( m_hWnd, GW_CHILD );
- if( hWndChild == NULL )
- return;
- ASSERT( ::IsWindow( hWndChild ) );
- ASSERT( ::GetWindow( hWndChild, GW_HWNDNEXT ) == NULL );
- CRect rcClient;
- if( cx < 0 || cy < 0 )
- GetClientRect( &rcClient );
- else
- rcClient.SetRect( 0, 0, cx, cy );
- if( IsFloating() )
- {
- // CSize sizeFrame(
- // ::GetSystemMetrics(SM_CXSIZEFRAME),
- // ::GetSystemMetrics(SM_CYSIZEFRAME)
- // );
- // rcClient.DeflateRect( sizeFrame );
- rcClient.DeflateRect( 1, 1 );
- } // if( IsFloating() )
- CRect rcChild;
- ::GetWindowRect( hWndChild, &rcChild );
- ScreenToClient( &rcChild );
- if( rcChild == rcClient )
- return;
- ::MoveWindow(
- hWndChild,
- rcClient.left,
- rcClient.top,
- rcClient.Width(),
- rcClient.Height(),
- bRedraw ? TRUE : FALSE
- );
- }
- void CExtControlBar::OnSize(UINT nType, int cx, int cy)
- {
- nType;
- if( m_bUpdatingChain )
- return;
- OnRepositionSingleChild( cx, cy, true );
- CFrameWnd * pFrame = GetParentFrame();
- if( pFrame != NULL
- && pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd))
- )
- {
- OnNcAreaButtonsReposition();
- pFrame->SendMessage( WM_NCPAINT );
- }
- }
- void CExtControlBar::_Dragging_OnStart()
- {
- CWnd::CancelToolTips();
- CExtPopupMenuWnd::CancelMenuTracking();
- ASSERT_VALID( m_pDockBar );
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDockDynTabBar * pTabbedDockBar =
- DYNAMIC_DOWNCAST(
- CExtDockDynTabBar,
- m_pDockBar
- );
- if( pTabbedDockBar != NULL )
- {
- CExtDynTabControlBar * pTabbedBar =
- STATIC_DOWNCAST(
- CExtDynTabControlBar,
- pTabbedDockBar->GetParent()
- );
- ASSERT_VALID( pTabbedBar );
- pTabbedBar->SaveIndex( this );
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- GetOwner()->
- SendMessage(
- WM_SETMESSAGESTRING,
- IDS_EXTSTATUS_PREVENT_DOCKING
- );
- }
- void CExtControlBar::_Dragging_OnStop(
- InternalDraggingState_t & _dsOld,
- InternalDraggingState_t & _dsNew,
- bool bCancel
- )
- {
- _dsOld, _dsNew, bCancel;
- GetOwner()->
- SendMessage(
- WM_SETMESSAGESTRING,
- AFX_IDS_IDLEMESSAGE
- );
- ASSERT_VALID( this );
- if( IsFixedMode() )
- return;
- ASSERT_VALID( (&_dsOld) );
- ASSERT_VALID( (&_dsNew) );
- ASSERT( _dsNew.ExtBarSrcGet() == this );
- ASSERT_VALID( m_pDockBar );
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDockDynTabBar * pTabbedDockBar =
- DYNAMIC_DOWNCAST(
- CExtDockDynTabBar,
- m_pDockBar
- );
- if( pTabbedDockBar != NULL )
- {
- CExtDynTabControlBar * pTabbedBar =
- STATIC_DOWNCAST(
- CExtDynTabControlBar,
- pTabbedDockBar->GetParent()
- );
- ASSERT_VALID( pTabbedBar );
- pTabbedBar->RemoveTemporaryItems( false );
- if( bCancel )
- {
- pTabbedBar->RestoreIndex( this );
- pTabbedBar->SelectControlBar( this );
- } // if( bCancel )
- } // if( pTabbedDockBar != NULL )
- if( bCancel && _dsNew.ExtBarDstGet() != NULL )
- {
- CExtDynTabControlBar * pTabbedBar =
- DYNAMIC_DOWNCAST(
- CExtDynTabControlBar,
- _dsNew.ExtBarDstGet()
- );
- if( pTabbedBar != NULL )
- {
- pTabbedBar->RemoveTemporaryItems( false );
- }
- } // if( bCancel && _dsNew.ExtBarDstGet() != NULL )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- }
- void CExtControlBar::_SetCursor(
- const CPoint & point
- )
- {
- bool bCustomizeMode = false;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = NotifiedCustomizeSiteGet();
- if( pSite != NULL )
- {
- if( pSite->DraggedNodeGet() != NULL )
- return;
- bCustomizeMode = pSite->IsCustomizeMode();
- } // if( pSite != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( ! bCustomizeMode )
- {
- if( CExtControlBar::FindHelpMode(this) )
- return;
- } // if( ! bCustomizeMode )
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- else
- {
- ASSERT( ! CExtControlBar::FindHelpMode(this) );
- } // else from if( !bCustomizeMode )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- HCURSOR hCursor = NULL;
- if( ! m_bPresubclassDialogMode )
- {
- if( m_bDragging || m_bDragDetecting || m_bRowResizing || m_bRowRecalcing )
- { // if can analyze resize cursors
- if( m_bDragging || m_bDragDetecting && ( ! ( m_bRowResizing || m_bRowRecalcing ) ) )
- {
- //ASSERT( ! ( m_bRowResizing || m_bRowRecalcing ) );
- hCursor = g_hCursorArrow;
- if( ( m_bDragDetecting || m_bDragging ) && IsFixedDockStyle() )
- {
- if( m_bDragging )
- hCursor = g_hCursorDrag;
- else
- {
- CRect rcBarWnd;
- GetWindowRect( &rcBarWnd );
- CPoint ptDevOffset = -rcBarWnd.TopLeft();
- CPoint ptWnd; //( point );
- //ClientToScreen( &ptWnd );
- ::GetCursorPos( &ptWnd );
- ptWnd += ptDevOffset;
- CRect rcGrip = _RectGripGet();
- if( rcGrip.PtInRect( ptWnd ) )
- hCursor = g_hCursorDrag;
- }
- }
- else if( IsFixedDockStyle() )
- {
- e_calc_fixed_resizing_t eCFR =
- g_DragStateOld.GetCFR();
- if( eCFR == __ECFR_HORZ )
- hCursor = g_hCursorResizeH;
- else if( eCFR == __ECFR_VERT )
- hCursor = g_hCursorResizeV;
- else
- hCursor = g_hCursorDrag;
- ASSERT( hCursor != NULL );
- }
- } // if( m_bDragging || m_bDragDetecting && ( ! ( m_bRowResizing || m_bRowRecalcing ) ) )
- else
- {
- ASSERT( ! m_bDragging );
- ASSERT( ! IsFloating() );
- if( IsDockedVertically() )
- {
- if( m_bRowRecalcing )
- {
- ASSERT( ! m_bRowResizing );
- hCursor = g_hCursorResizeV;
- ASSERT( hCursor != NULL );
- } // if( m_bRowRecalcing )
- else
- {
- ASSERT( ! m_bRowRecalcing );
- hCursor = g_hCursorResizeH;
- ASSERT( hCursor != NULL );
- } // else from if( m_bRowRecalcing )
- } // if( IsDockedVertically() )
- else
- {
- if( m_bRowRecalcing )
- {
- ASSERT( ! m_bRowResizing );
- hCursor = g_hCursorResizeH;
- ASSERT( hCursor != NULL );
- } // if( m_bRowRecalcing )
- else
- {
- ASSERT( ! m_bRowRecalcing );
- hCursor = g_hCursorResizeV;
- ASSERT( hCursor != NULL );
- } // else if( m_bRowRecalcing )
- } // else from if( IsDockedVertically() )
- } // else from if( m_bDragging || m_bDragDetecting && ( ! ( m_bRowResizing || m_bRowRecalcing ) ) )
- } // if can analyze resize cursors
- else
- { // if can not analyze resize cursors
- if( ! IsFloating() )
- {
- CRect rcBarWnd;
- GetWindowRect( &rcBarWnd );
- CPoint ptDevOffset = -rcBarWnd.TopLeft();
- CPoint ptWnd( point );
- ClientToScreen( &ptWnd );
- ptWnd += ptDevOffset;
- CRect rcGrip = _RectGripGet();
- if( rcGrip.PtInRect(ptWnd) )
- {
- INT nCountOfNcButtons = NcButtons_GetCount();
- for( INT nBtn = 0; nBtn < nCountOfNcButtons; nBtn++ )
- {
- CExtBarNcAreaButton * pBtn =
- NcButtons_GetAt( nBtn );
- hCursor =
- pBtn->OnNcAreaQueryCursor( ptWnd );
- if( hCursor != NULL )
- break;
- } // for( INT nBtn = 0; nBtn < nCountOfNcButtons; nBtn++ )
- if( hCursor == NULL )
- {
- if( _DraggingIsEnabled( this ) )
- {
- if( IsFixedDockStyle() )
- hCursor = g_hCursorDrag;
- else
- hCursor = g_hCursorArrow;
- }
- else
- hCursor = g_hCursorArrow;
- ASSERT( hCursor != NULL );
- } // if( hCursor == NULL )
- } // if( rcGrip.PtInRect(ptWnd) )
- } // if( !IsFloating() )
-
- } // if can not analyze resize cursors
- } // if( ! m_bPresubclassDialogMode )
- if( hCursor == NULL )
- {
- hCursor = (HCURSOR)(__EXT_MFC_DWORD_PTR)
- ::__EXT_MFC_GetClassLong(
- m_hWnd,
- __EXT_MFC_GCL_HCURSOR
- );
- ASSERT( hCursor != NULL );
- } // if( hCursor == NULL )
-
- if( ::GetCursor() != hCursor )
- ::SetCursor( hCursor );
- }
- CExtControlBar * CExtControlBar::_DraggingGetBar() // return currently dagging controlbar
- {
- if( g_DragStateOld.IsEmpty() )
- return NULL;
- return g_DragStateOld.ExtBarSrcGet();
- }
- bool CExtControlBar::_DraggingCancel() // returns true if dragging was really canceled
- {
- CExtControlBar * pBar = _DraggingGetBar();
- if( pBar == NULL )
- return false;
- pBar->_DraggingStop( true );
- return true;
- }
- void CExtControlBar::_DraggingStart(
- const CPoint & point,
- const CPoint & pointOffset, // = CPoint( 0, 0 );
- CSize sizeWaitMouseMove // = CSize( 1, 1 )
- )
- {
- ASSERT( !m_bRowRecalcing );
- ASSERT( !m_bRowResizing );
- ASSERT( !m_bDragging );
- ASSERT_VALID( m_pDockSite );
- if( CExtControlBar::ProfileBarStateIsSerializing( m_pDockSite ) )
- return;
- if( ! _DraggingIsEnabled( this ) )
- return;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = NotifiedCustomizeSiteGet();
- if( pSite != NULL
- && pSite->IsCustomizeMode()
- )
- pSite->DropTargetPopupCancelEx( -2 );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- // (+ v.2.24)
- // detect valid dragging start event
- MSG msg;
- for( ; PeekMessage( &msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE ); );
- HWND hWndOwn = GetSafeHwnd();
- ASSERT( hWndOwn != NULL && ::IsWindow(hWndOwn) );
- CExtMouseCaptureSink::SetCapture( hWndOwn );
- m_bDragDetecting = true;
- _SetCursor( point );
- //sizeWaitMouseMove.cx = sizeWaitMouseMove.cy = 5; // debug
- if( sizeWaitMouseMove.cx > 0 && sizeWaitMouseMove.cy > 0 )
- {
- ::WaitMessage();
- CPoint ptMouseStart( 0, 0 ), ptMouseCurrent( 0, 0 );
- ::GetCursorPos( &ptMouseStart );
- bool bEnableStartDragging = true, bMouseShiftDetected = false;
- for( ; bEnableStartDragging && (!bMouseShiftDetected); )
- {
- for( ; ::IsWindow(hWndOwn)
- && PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE );
- )
- { // wait any mouse movement look
- MSG _msgOwnLBtnUp;
- ::PeekMessage(
- &_msgOwnLBtnUp,
- hWndOwn,
- WM_LBUTTONUP,
- WM_LBUTTONUP,
- PM_NOREMOVE
- );
- if( _msgOwnLBtnUp.message == WM_LBUTTONUP )
- {
- bEnableStartDragging = false;
- CWnd * pWndChild = GetWindow( GW_CHILD );
- if( pWndChild != NULL )
- {
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDynTabControlBar * pTabbedBar =
- DYNAMIC_DOWNCAST( CExtDynTabControlBar, this );
- if( pTabbedBar != NULL )
- {
- LONG nSel = pTabbedBar->GetSwitcherSelection();
- if( nSel >= 0 )
- {
- CExtControlBar * pBar =
- pTabbedBar->GetBarAt( nSel, true );
- if( pBar != NULL )
- {
- CWnd * pWndChild = pBar->GetWindow( GW_CHILD );
- if( pWndChild != NULL )
- {
- if( stat_QueryFocusChangingEnabled( this, pWndChild->m_hWnd ) )
- pWndChild->SetFocus();
- }
- else
- {
- if( stat_QueryFocusChangingEnabled( this, m_hWnd ) )
- pBar->SetFocus();
- }
- break;
- } // if( pBar != NULL )
- } // if( nSel >= 0 )
- } // if( pTabbedBar != NULL )
- else
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- {
- if( stat_QueryFocusChangingEnabled( this, pWndChild->m_hWnd ) )
- pWndChild->SetFocus();
- break;
- }
- } // if( pWndChild != NULL )
- if( stat_QueryFocusChangingEnabled( this, m_hWnd ) )
- SetFocus();
- break;
- } // if( _msgOwnLBtnUp.message == WM_LBUTTONUP )
- if( ::IsWindow(hWndOwn) )
- {
- if( msg.hwnd == hWndOwn )
- {
- if( msg.message == WM_MOUSEMOVE )
- {
- ::GetCursorPos( &ptMouseCurrent );
- CSize sizeMouseShift(
- abs( (ptMouseCurrent.x - ptMouseStart.x) ),