📄 controlbar.cpp
字号:
void cbDockPane::PaintPaneDecorations( wxDC& dc ){ cbDrawPaneDecorEvent evt( dc, this ); mpLayout->FirePluginEvent( evt );}void cbDockPane::PaintPane( wxDC& dc ){ size_t i; PaintPaneBackground( dc ); // first decorations for ( i = 0; i != mRows.Count(); ++i ) { PaintRowBackground( mRows[i], dc ); PaintRowDecorations( mRows[i], dc ); } // than handles for ( i = 0; i != mRows.Count(); ++i ) PaintRowHandles( mRows[i], dc ); // and finally PaintPaneDecorations( dc );}void cbDockPane::SizeBar( cbBarInfo* pBar ){ cbSizeBarWndEvent evt( pBar, this ); mpLayout->FirePluginEvent( evt ); return;}void cbDockPane::SizeRowObjects( cbRowInfo* pRow ){ size_t i; for ( i = 0; i != pRow->mBars.Count(); ++i ) SizeBar( pRow->mBars[i] );}void cbDockPane::SizePaneObjects(){ size_t i; for ( i = 0; i != mRows.Count(); ++i ) SizeRowObjects( mRows[i] );}wxDC* cbDockPane::StartDrawInArea( const wxRect& area ){ wxDC* pDc = 0; cbStartDrawInAreaEvent evt( area, &pDc, this ); mpLayout->FirePluginEvent( evt ); return pDc;}void cbDockPane::FinishDrawInArea( const wxRect& area ){ cbFinishDrawInAreaEvent evt( area, this ); mpLayout->FirePluginEvent( evt );}bool cbDockPane::IsFixedSize( cbBarInfo* pInfo ){ return ( pInfo->mDimInfo.mIsFixed );}int cbDockPane::GetNotFixedBarsCount( cbRowInfo* pRow ){ int cnt = 0; size_t i; for ( i = 0; i != pRow->mBars.Count(); ++i ) { if ( !pRow->mBars[i]->IsFixed() ) ++cnt; } return cnt;}void cbDockPane::RemoveBar( cbBarInfo* pBar ){ bool needsRestoring = mProps.mNonDestructFrictionOn && mpStoredRow == pBar->mpRow; cbRemoveBarEvent evt( pBar, this ); mpLayout->FirePluginEvent( evt ); if ( needsRestoring ) { SetRowShapeData( mpStoredRow, &mRowShapeData ); mpStoredRow = NULL; }}void cbDockPane::SyncRowFlags( cbRowInfo* pRow ){ // setup mHasOnlyFixedBars flag for the row information pRow->mHasOnlyFixedBars = true; pRow->mNotFixedBarsCnt = 0; size_t i; for ( i = 0; i != pRow->mBars.Count(); ++i ) { cbBarInfo& bar = *pRow->mBars[i]; bar.mpRow = pRow; if ( !bar.IsFixed() ) { pRow->mHasOnlyFixedBars = false; ++pRow->mNotFixedBarsCnt; } }}void cbDockPane::FrameToPane( int* x, int* y ){ *x -= mLeftMargin; *y -= mTopMargin; if ( mAlignment == FL_ALIGN_TOP || mAlignment == FL_ALIGN_BOTTOM ) { *x -= mBoundsInParent.x; *y -= mBoundsInParent.y; } else { int rx = *x, ry = *y; *x = ry - mBoundsInParent.y; *y = rx - mBoundsInParent.x; }}void cbDockPane::PaneToFrame( int* x, int* y ){ if ( mAlignment == FL_ALIGN_TOP || mAlignment == FL_ALIGN_BOTTOM ) { *x += mBoundsInParent.x; *y += mBoundsInParent.y; } else { int rx = *x, ry = *y; *x = ry + mBoundsInParent.x; *y = mBoundsInParent.y + rx; } *x += mLeftMargin; *y += mTopMargin;}void cbDockPane::FrameToPane( wxRect* pRect ){ wxPoint upperLeft ( pRect->x, pRect->y ); wxPoint lowerRight( pRect->x + pRect->width, pRect->y + pRect->height ); FrameToPane( &upperLeft.x, &upperLeft.y ); FrameToPane( &lowerRight.x, &lowerRight.y ); pRect->x = wxMin(upperLeft.x,lowerRight.x); pRect->y = wxMin(upperLeft.y,lowerRight.y); pRect->width = abs( lowerRight.x - upperLeft.x ); pRect->height = abs( lowerRight.y - upperLeft.y );}void cbDockPane::PaneToFrame( wxRect* pRect ){ wxPoint upperLeft ( pRect->x, pRect->y ); wxPoint lowerRight( pRect->x + pRect->width, pRect->y + pRect->height ); PaneToFrame( &upperLeft.x, &upperLeft.y ); PaneToFrame( &lowerRight.x, &lowerRight.y ); //wxRect newRect = wxRect( upperLeft, lowerRight ); pRect->x = wxMin(upperLeft.x,lowerRight.x); pRect->y = wxMin(upperLeft.y,lowerRight.y); pRect->width = abs( lowerRight.x - upperLeft.x ); pRect->height = abs( lowerRight.y - upperLeft.y );}int cbDockPane::GetRowAt( int paneY ){ if ( paneY < 0 ) return -1; int curY = 0; size_t i = 0; for ( ; i != mRows.Count(); ++i ) { int rowHeight = mRows[i]->mRowHeight; int third = rowHeight/3; if ( paneY >= curY && paneY < curY + third ) return i-1; if ( paneY >= curY + third && paneY < curY + rowHeight - third ) return i; curY += rowHeight; } return i;}int cbDockPane::GetRowAt( int upperY, int lowerY ){ /* // OLD STUFF:: int range = lowerY - upperY; int oneThird = range / 3; wxNode* pRow = mRows.GetFirst(); int row = 0; int curY = 0; if ( lowerY <= 0 ) return -1; while( pRow ) { int rowHeight = GetRowHeight( (wxList*)pRow->GetData() ); if ( upperY >= curY && lowerY < curY ) return row; if ( upperY <= curY && lowerY >= curY && curY - upperY >= oneThird ) return row-1; if ( ( upperY < curY + rowHeight && lowerY >= curY + rowHeight && curY + rowHeight - lowerY >= oneThird ) ) return row+1; if ( lowerY <= curY + rowHeight ) return row; ++row; curY += rowHeight; pRow = pRow->GetNext(); } */ int mid = upperY + (lowerY - upperY)/2; if ( mid < 0 ) return -1; int curY = 0; size_t i = 0; for ( ; i != mRows.Count(); ++i ) { int rowHeight = mRows[i]->mRowHeight; if ( mid >= curY && mid < curY + rowHeight ) return i; curY += rowHeight; } return i;}int cbDockPane::GetRowY( cbRowInfo* pRow ){ int curY = 0; size_t i; for ( i = 0; i != mRows.Count(); ++i ) { if ( mRows[i] == pRow ) break; curY += mRows[i]->mRowHeight; } return curY;}bool cbDockPane::HasNotFixedRowsAbove( cbRowInfo* pRow ){ while ( pRow->mpPrev ) { pRow = pRow->mpPrev; if ( pRow->mHasOnlyFixedBars ) return true; } return false;}bool cbDockPane::HasNotFixedRowsBelow( cbRowInfo* pRow ){ while( pRow->mpNext ) { pRow = pRow->mpNext; if ( pRow->mHasOnlyFixedBars ) return true; } return false;}bool cbDockPane::HasNotFixedBarsLeft( cbBarInfo* pBar ){ while( pBar->mpPrev ) { pBar = pBar->mpPrev; if ( pBar->IsFixed() ) return true; } return false;}bool cbDockPane::HasNotFixedBarsRight( cbBarInfo* pBar ){ while( pBar->mpNext ) { pBar = pBar->mpNext; if ( pBar->IsFixed() ) return true; } return false;}void cbDockPane::CalcLengthRatios( cbRowInfo* pInRow ){ size_t i; int totalWidth = 0; // calc current-maximal-total-length of all maximized bars for ( i = 0; i != pInRow->mBars.GetCount(); ++i ) { cbBarInfo& bar = *pInRow->mBars[i]; if ( !bar.IsFixed() ) totalWidth += bar.mBounds.width; } // set up percentages of occupied space for each maximized bar for ( i = 0; i != pInRow->mBars.Count(); ++i ) { cbBarInfo& bar = *pInRow->mBars[i]; if ( !bar.IsFixed() ) bar.mLenRatio = double(bar.mBounds.width)/double(totalWidth); }}void cbDockPane::RecalcRowLayout( cbRowInfo* pRow ){ cbLayoutRowEvent evt( pRow, this ); mpLayout->FirePluginEvent( evt );}void cbDockPane::ExpandBar( cbBarInfo* pBar ){ mpLayout->GetUpdatesManager().OnStartChanges(); if ( !pBar->mpRow->mpExpandedBar ) { // save ratios only when there arent any bars expanded yet cbArrayFloat& ratios = pBar->mpRow->mSavedRatios; ratios.Clear(); ratios.Alloc( pBar->mpRow->mNotFixedBarsCnt ); cbBarInfo* pCur = pBar->mpRow->mBars[0]; while( pCur ) { if ( !pCur->IsFixed() ) { ratios.Add( 0.0 ); ratios[ ratios.GetCount() - 1 ] = pCur->mLenRatio; } pCur = pCur->mpNext; } } cbBarInfo* pCur = pBar->mpRow->mBars[0]; while( pCur ) { pCur->mLenRatio = 0.0; // minimize the rest pCur = pCur->mpNext; } pBar->mLenRatio = 1.0; // 100% pBar->mBounds.width = 0; pBar->mpRow->mpExpandedBar = pBar; mpLayout->RecalcLayout( false ); mpLayout->GetUpdatesManager().OnFinishChanges(); mpLayout->GetUpdatesManager().UpdateNow();}void cbDockPane::ContractBar( cbBarInfo* pBar ){ mpLayout->GetUpdatesManager().OnStartChanges(); // FIXME: What's the purpose of this??? // double ratio = 1.0/ double( pBar->mpRow->mNotFixedBarsCnt ); // restore ratios which were present before expansion cbBarInfo* pCur = pBar->mpRow->mBars[0]; cbArrayFloat& ratios = pBar->mpRow->mSavedRatios; size_t i = 0; while( pCur ) { if ( !pCur->IsFixed() ) { pCur->mLenRatio = ratios[i]; ++i; } pCur = pCur->mpNext; } ratios.Clear(); ratios.Shrink(); pBar->mpRow->mpExpandedBar = NULL; mpLayout->RecalcLayout( false ); mpLayout->GetUpdatesManager().OnFinishChanges(); mpLayout->GetUpdatesManager().UpdateNow();}void cbDockPane::InitLinksForRow( cbRowInfo* pRow ){ size_t i; for ( i = 0; i != pRow->mBars.Count(); ++i ) { cbBarInfo& bar = *pRow->mBars[i]; if ( i == 0 ) bar.mpPrev = NULL; else bar.mpPrev = pRow->mBars[i-1]; if ( i == pRow->mBars.Count() - 1 ) bar.mpNext = NULL; else bar.mpNext = pRow->mBars[i+1]; }}void cbDockPane::InitLinksForRows(){ size_t i; for ( i = 0; i != mRows.Count(); ++i ) { cbRowInfo& row = *mRows[i]; if ( i == 0 ) row.mpPrev = NULL; else row.mpPrev = mRows[i-1]; if ( i == mRows.Count() - 1 ) row.mpNext = NULL; else row.mpNext = mRows[i+1]; }}void cbDockPane::DoInsertBar( cbBarInfo* pBar, int rowNo ){ cbRowInfo* pRow; if ( rowNo == -1 || rowNo >= (int)mRows.Count() ) { pRow = new cbRowInfo(); if ( rowNo == -1 && mRows.Count() ) mRows.Insert( pRow, 0 ); else mRows.Add( pRow ); InitLinksForRows(); } else { pRow = mRows[rowNo]; if ( mProps.mNonDestructFrictionOn == true ) { // store original shape of the row (before the bar is inserted) mpStoredRow = pRow; GetRowShapeData( mpStoredRow, &mRowShapeData ); } } if ( pRow->mBars.Count() ) pRow->mpExpandedBar = NU
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -