From 11a68fa3af72d8a237e5dc509b820de0077f1a56 Mon Sep 17 00:00:00 2001 From: George Tasker Date: Thu, 22 Nov 2001 23:15:12 +0000 Subject: [PATCH] Removed non-reachable code (consulted Aleks first, and he said the code was no longer needed) Commented out unused variables to stop BCC warnings - left the code for debugging purposes Removed hardcoded tabs and replaced with spaces per the wxWindows code style specs Spelling typos fixed in comments Miscellaneous source formatting issues fixed to meet standard wxwindows coding styles git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12605 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/fl/bardragpl.cpp | 2 +- contrib/src/fl/barhintspl.cpp | 687 ++++++------- contrib/src/fl/gcupdatesmgr.cpp | 9 +- contrib/src/fl/panedrawpl.cpp | 31 +- contrib/src/fl/rowdragpl.cpp | 4 +- contrib/src/fl/rowlayoutpl.cpp | 1589 +++++++++++++++---------------- contrib/src/fl/updatesmgr.cpp | 1 + 7 files changed, 1158 insertions(+), 1165 deletions(-) diff --git a/contrib/src/fl/bardragpl.cpp b/contrib/src/fl/bardragpl.cpp index 26b927e93a..b48d254038 100644 --- a/contrib/src/fl/bardragpl.cpp +++ b/contrib/src/fl/bardragpl.cpp @@ -371,7 +371,7 @@ void cbBarDragPlugin::UnstickFromPane( cbDockPane* pPane, wxPoint& mousePos ) if ( pPane->IsHorizontal() && fromLowerEdge ) { - bool fromLowerEdge = mousePos.y > bounds.y; +// bool fromLowerEdge = mousePos.y > bounds.y; mHintRect.y = wxMax( bounds.y + bounds.height + 1, mousePos.y - newHeight ); diff --git a/contrib/src/fl/barhintspl.cpp b/contrib/src/fl/barhintspl.cpp index 2a5b99ca03..90985f7d17 100644 --- a/contrib/src/fl/barhintspl.cpp +++ b/contrib/src/fl/barhintspl.cpp @@ -6,7 +6,7 @@ // Created: 30/11/98 (my 22th birthday :-) // RCS-ID: $Id$ // Copyright: (c) Aleksandras Gluchovas -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -49,42 +49,42 @@ IMPLEMENT_DYNAMIC_CLASS( cbBarHintsPlugin, cbPluginBase ) BEGIN_EVENT_TABLE( cbBarHintsPlugin, cbPluginBase ) - EVT_PL_SIZE_BAR_WND ( cbBarHintsPlugin::OnSizeBarWindow ) - EVT_PL_DRAW_BAR_DECOR( cbBarHintsPlugin::OnDrawBarDecorations ) + EVT_PL_SIZE_BAR_WND ( cbBarHintsPlugin::OnSizeBarWindow ) + EVT_PL_DRAW_BAR_DECOR( cbBarHintsPlugin::OnDrawBarDecorations ) - EVT_PL_LEFT_DOWN( cbBarHintsPlugin::OnLeftDown ) - EVT_PL_LEFT_UP ( cbBarHintsPlugin::OnLeftUp ) - EVT_PL_MOTION ( cbBarHintsPlugin::OnMotion ) + EVT_PL_LEFT_DOWN( cbBarHintsPlugin::OnLeftDown ) + EVT_PL_LEFT_UP ( cbBarHintsPlugin::OnLeftUp ) + EVT_PL_MOTION ( cbBarHintsPlugin::OnMotion ) END_EVENT_TABLE() cbBarHintsPlugin::cbBarHintsPlugin(void) - : mpPane( 0 ), - mBtnPressed ( FALSE ), - mCloseBoxOn ( TRUE ), - mCollapseBoxOn( TRUE ), - mGrooveCount ( 2 ), - mHintGap ( 4 ), - mXWeight ( 2 ) + : mpPane( 0 ), + mBtnPressed ( FALSE ), + mCloseBoxOn ( TRUE ), + mCollapseBoxOn( TRUE ), + mGrooveCount ( 2 ), + mHintGap ( 4 ), + mXWeight ( 2 ) { - mBoxes[CLOSE_BOX_IDX] = NULL; - mBoxes[COLLAPSE_BOX_IDX] = NULL; + mBoxes[CLOSE_BOX_IDX] = NULL; + mBoxes[COLLAPSE_BOX_IDX] = NULL; } cbBarHintsPlugin::cbBarHintsPlugin( wxFrameLayout* pLayout, int paneMask ) - : cbPluginBase( pLayout, paneMask ), - mpPane( 0 ), - mBtnPressed ( FALSE ), - mCloseBoxOn ( TRUE ), - mCollapseBoxOn( TRUE ), - mGrooveCount ( 2 ), - mHintGap ( 5 ), - mXWeight ( 2 ) + : cbPluginBase( pLayout, paneMask ), + mpPane( 0 ), + mBtnPressed ( FALSE ), + mCloseBoxOn ( TRUE ), + mCollapseBoxOn( TRUE ), + mGrooveCount ( 2 ), + mHintGap ( 5 ), + mXWeight ( 2 ) { - mBoxes[CLOSE_BOX_IDX] = NULL; - mBoxes[COLLAPSE_BOX_IDX] = NULL; + mBoxes[CLOSE_BOX_IDX] = NULL; + mBoxes[COLLAPSE_BOX_IDX] = NULL; } @@ -93,31 +93,31 @@ cbBarHintsPlugin::~cbBarHintsPlugin() if (mBoxes[CLOSE_BOX_IDX]) delete mBoxes[CLOSE_BOX_IDX]; - if (mBoxes[COLLAPSE_BOX_IDX]) + if (mBoxes[COLLAPSE_BOX_IDX]) delete mBoxes[COLLAPSE_BOX_IDX]; } // cbBarHintsPlugin destructor void cbBarHintsPlugin::SetGrooveCount( int nGrooves ) { - mGrooveCount = nGrooves; + mGrooveCount = nGrooves; } void cbBarHintsPlugin::CreateBoxes() { - cbCloseBox* box1 = new cbCloseBox(); - cbCollapseBox* box2 = new cbCollapseBox(); - - mBoxes[CLOSE_BOX_IDX] = box1; - mBoxes[COLLAPSE_BOX_IDX] = box2; - - int i; - for( i = 0; i != BOXES_IN_HINT; ++i ) - { - mBoxes[i]->mpLayout = mpLayout; - mBoxes[i]->mpPlugin = this; - mBoxes[i]->mpWnd = NULL; - } + cbCloseBox* box1 = new cbCloseBox(); + cbCollapseBox* box2 = new cbCollapseBox(); + + mBoxes[CLOSE_BOX_IDX] = box1; + mBoxes[COLLAPSE_BOX_IDX] = box2; + + int i; + for ( i = 0; i != BOXES_IN_HINT; ++i ) + { + mBoxes[i]->mpLayout = mpLayout; + mBoxes[i]->mpPlugin = this; + mBoxes[i]->mpWnd = NULL; + } } @@ -130,431 +130,434 @@ void cbBarHintsPlugin::DrawCloseBox( wxDC& dc, const wxPoint& pos, bool pressed } void cbBarHintsPlugin::DrawCollapseBox( wxDC& dc, const wxPoint& pos, - bool atLeft, bool disabled, bool pressed ) + bool atLeft, bool disabled, bool pressed ) { } void cbBarHintsPlugin::DrawGrooves( wxDC& dc, const wxPoint& pos, int length ) { - int ofs = 0; - - int i; - for( i = 0; i != mGrooveCount; ++i, ofs += ( GROOVE_WIDTH + GROOVE_TO_GROOVE_GAP ) ) - - if ( mpPane->IsHorizontal() ) - { - dc.SetPen( mpLayout->mLightPen ); - dc.DrawLine( pos.x + ofs, pos.y, pos.x + ofs, pos.y + length - 1 ); - dc.DrawPoint( pos.x + ofs + 1, pos.y ); - - dc.SetPen( mpLayout->mDarkPen ); - dc.DrawLine( pos.x + ofs + 2, pos.y, pos.x + ofs + 2, pos.y + length ); - dc.DrawPoint( pos.x + ofs + 1, pos.y + length - 1 ); - dc.DrawPoint( pos.x + ofs, pos.y + length - 1 ); - } - else - { - dc.SetPen( mpLayout->mLightPen ); - dc.DrawLine( pos.x, pos.y + ofs, pos.x + length - 1, pos.y + ofs ); - dc.DrawPoint( pos.x, pos.y + ofs + 1 ); - - dc.SetPen( mpLayout->mDarkPen ); - dc.DrawLine( pos.x, pos.y + ofs + 2, pos.x + length, pos.y + ofs + 2 ); - dc.DrawPoint( pos.x + length - 1, pos.y + ofs + 1 ); - dc.DrawPoint( pos.x + length - 1, pos.y + ofs ); - } + int ofs = 0; + + int i; + for ( i = 0; i != mGrooveCount; ++i, ofs += ( GROOVE_WIDTH + GROOVE_TO_GROOVE_GAP ) ) + { + if ( mpPane->IsHorizontal() ) + { + dc.SetPen( mpLayout->mLightPen ); + dc.DrawLine( pos.x + ofs, pos.y, pos.x + ofs, pos.y + length - 1 ); + dc.DrawPoint( pos.x + ofs + 1, pos.y ); + + dc.SetPen( mpLayout->mDarkPen ); + dc.DrawLine( pos.x + ofs + 2, pos.y, pos.x + ofs + 2, pos.y + length ); + dc.DrawPoint( pos.x + ofs + 1, pos.y + length - 1 ); + dc.DrawPoint( pos.x + ofs, pos.y + length - 1 ); + } + else + { + dc.SetPen( mpLayout->mLightPen ); + dc.DrawLine( pos.x, pos.y + ofs, pos.x + length - 1, pos.y + ofs ); + dc.DrawPoint( pos.x, pos.y + ofs + 1 ); + + dc.SetPen( mpLayout->mDarkPen ); + dc.DrawLine( pos.x, pos.y + ofs + 2, pos.x + length, pos.y + ofs + 2 ); + dc.DrawPoint( pos.x + length - 1, pos.y + ofs + 1 ); + dc.DrawPoint( pos.x + length - 1, pos.y + ofs ); + } + } } void cbBarHintsPlugin::ExcludeHints( wxRect& rect, cbBarInfo& info ) { - int boxHeight = BTN_BOX_HEIGHT; + int boxHeight = BTN_BOX_HEIGHT; - // collapse and close box are not placed on fixed bars + // collapse and close box are not placed on fixed bars - if ( info.IsFixed() || ( !mCloseBoxOn && !mCollapseBoxOn ) ) + if ( info.IsFixed() || ( !mCloseBoxOn && !mCollapseBoxOn ) ) - boxHeight = 0; + boxHeight = 0; - int height = wxMax( mGrooveCount*(GROOVE_WIDTH + GROOVE_TO_GROOVE_GAP) - - GROOVE_TO_GROOVE_GAP, - boxHeight - ); + int height = wxMax( mGrooveCount*(GROOVE_WIDTH + GROOVE_TO_GROOVE_GAP) + - GROOVE_TO_GROOVE_GAP, + boxHeight + ); - if ( mpPane->IsHorizontal() ) - { - rect.x += ( mHintGap*2 + height ); - rect.width -= (height + 2*mHintGap); + if ( mpPane->IsHorizontal() ) + { + rect.x += ( mHintGap*2 + height ); + rect.width -= (height + 2*mHintGap); - rect.x -= info.mDimInfo.mHorizGap + 2; - rect.width += info.mDimInfo.mHorizGap + 2; - } - else - { - rect.y += (mHintGap*2 + height); - rect.height -= (height + 2*mHintGap); + rect.x -= info.mDimInfo.mHorizGap + 2; + rect.width += info.mDimInfo.mHorizGap + 2; + } + else + { + rect.y += (mHintGap*2 + height); + rect.height -= (height + 2*mHintGap); - rect.y -= info.mDimInfo.mVertGap + 2; - rect.height += info.mDimInfo.mVertGap + 2; - } + rect.y -= info.mDimInfo.mVertGap + 2; + rect.height += info.mDimInfo.mVertGap + 2; + } } void cbBarHintsPlugin::DoDrawHint( wxDC& dc, wxRect& rect, - int pos, int boxOfs, int grooveOfs, - bool isFixed ) + int pos, int boxOfs, int grooveOfs, + bool isFixed ) { - if ( !isFixed ) - { - if ( mpPane->IsHorizontal() ) - { - if ( mCloseBoxOn ) - - mBoxes[CLOSE_BOX_IDX]->Draw( dc ); - - if ( mCollapseBoxOn ) - - mBoxes[COLLAPSE_BOX_IDX]->Draw( dc ); - } - else - { - if ( mCloseBoxOn ) - - mBoxes[CLOSE_BOX_IDX]->Draw( dc ); - - if ( mCollapseBoxOn ) - - mBoxes[COLLAPSE_BOX_IDX]->Draw( dc ); - } - } - - if ( mpPane->IsHorizontal() ) - - DrawGrooves( dc, wxPoint( rect.x + mHintGap + grooveOfs, pos ), - rect.height - (pos - rect.y) - mHintGap ); - else - DrawGrooves( dc, wxPoint( rect.x + mHintGap, rect.y + mHintGap + grooveOfs ), - (pos - rect.x) - mHintGap ); + if ( !isFixed ) + { + if ( mpPane->IsHorizontal() ) + { + if ( mCloseBoxOn ) + + mBoxes[CLOSE_BOX_IDX]->Draw( dc ); + + if ( mCollapseBoxOn ) + + mBoxes[COLLAPSE_BOX_IDX]->Draw( dc ); + } + else + { + if ( mCloseBoxOn ) + + mBoxes[CLOSE_BOX_IDX]->Draw( dc ); + + if ( mCollapseBoxOn ) + + mBoxes[COLLAPSE_BOX_IDX]->Draw( dc ); + } + } + + if ( mpPane->IsHorizontal() ) + + DrawGrooves( dc, wxPoint( rect.x + mHintGap + grooveOfs, pos ), + rect.height - (pos - rect.y) - mHintGap ); + else + DrawGrooves( dc, wxPoint( rect.x + mHintGap, rect.y + mHintGap + grooveOfs ), + (pos - rect.x) - mHintGap ); } void cbBarHintsPlugin::GetHintsLayout( wxRect& rect, cbBarInfo& info, - int& boxOfs, int& grooveOfs, int& pos ) + int& boxOfs, int& grooveOfs, int& pos ) { - int boxHeight = BTN_BOX_HEIGHT; - int boxWidth = BTN_BOX_WIDTH + BOX_TO_GROOVE_GAP + BTN_BOX_WIDTH; + int boxHeight = BTN_BOX_HEIGHT; +// int boxWidth = BTN_BOX_WIDTH + BOX_TO_GROOVE_GAP + BTN_BOX_WIDTH; - // collapse and close box are not placed on fixed bars + // collapse and close box are not placed on fixed bars - if ( info.IsFixed() || ( !mCloseBoxOn && !mCollapseBoxOn ) ) - { - boxHeight = 0; - boxWidth = 0; - } - else - if ( !mCloseBoxOn || !mCollapseBoxOn ) + if ( info.IsFixed() || ( !mCloseBoxOn && !mCollapseBoxOn ) ) + { + boxHeight = 0; +// boxWidth = 0; + } +/* + else + if ( !mCloseBoxOn || !mCollapseBoxOn ) - boxWidth = BTN_BOX_WIDTH; + boxWidth = BTN_BOX_WIDTH; +*/ + int grooveHeight = mGrooveCount*(GROOVE_WIDTH + GROOVE_TO_GROOVE_GAP) + - GROOVE_TO_GROOVE_GAP; - int grooveHeight = mGrooveCount*(GROOVE_WIDTH + GROOVE_TO_GROOVE_GAP) - - GROOVE_TO_GROOVE_GAP; + int height = wxMax( grooveHeight, boxHeight ); - int height = wxMax( grooveHeight, boxHeight ); + // center boxs and groves with respect to each other - // center boxs and groves with respect to each other + boxOfs = ( height - boxHeight ) / 2; + grooveOfs = ( height - grooveHeight ) / 2; - boxOfs = ( height - boxHeight ) / 2; - grooveOfs = ( height - grooveHeight ) / 2; + pos = ( mpPane->IsHorizontal() ) ? rect.y + mHintGap + : rect.x + rect.width - mHintGap; - pos = ( mpPane->IsHorizontal() ) ? rect.y + mHintGap - : rect.x + rect.width - mHintGap; + // setup positions for boxes - // setup positions for boxes + if ( !info.IsFixed() ) + { + // what direction "collapse-triangle" should look at? - if ( !info.IsFixed() ) - { - // what direction "collapse-triangle" should look at? + bool& isAtLeft = ((cbCollapseBox*)(mBoxes[COLLAPSE_BOX_IDX]))->mIsAtLeft; + + isAtLeft= info.mBounds.x <= mpPane->mPaneWidth - ( info.mBounds.x + info.mBounds.width ); - bool& isAtLeft = ((cbCollapseBox*)(mBoxes[COLLAPSE_BOX_IDX]))->mIsAtLeft; - - isAtLeft= info.mBounds.x <= mpPane->mPaneWidth - ( info.mBounds.x + info.mBounds.width ); + if ( info.IsExpanded() ) + { + isAtLeft = FALSE; - if ( info.IsExpanded() ) - { - isAtLeft = FALSE; + cbBarInfo* pCur = info.mpPrev; - cbBarInfo* pCur = info.mpPrev; + while( pCur ) + { + if ( !pCur->IsFixed() ) + { + isAtLeft = TRUE; break; + } - while( pCur ) - { - if ( !pCur->IsFixed() ) - { - isAtLeft = TRUE; break; - } + pCur = pCur->mpPrev; + } + } - pCur = pCur->mpPrev; - } - } + // collapse/expand works only when more not-fixed bars are present in the same row - // collapse/expand works only when more not-fixed bars are present in the same row - - mBoxes[COLLAPSE_BOX_IDX]->Enable( info.mpRow->mNotFixedBarsCnt > 1 ); - - int i; - for( i = 0; i != BOXES_IN_HINT; ++i ) - - mBoxes[i]->mpPane = mpPane; + mBoxes[COLLAPSE_BOX_IDX]->Enable( info.mpRow->mNotFixedBarsCnt > 1 ); + int i; + for ( i = 0; i != BOXES_IN_HINT; ++i ) + { + mBoxes[i]->mpPane = mpPane; + } - if ( mpPane->IsHorizontal() ) - { - if ( mCloseBoxOn ) - { - mBoxes[CLOSE_BOX_IDX]->mPos = wxPoint( rect.x + mHintGap + boxOfs, pos ); + if ( mpPane->IsHorizontal() ) + { + if ( mCloseBoxOn ) + { + mBoxes[CLOSE_BOX_IDX]->mPos = wxPoint( rect.x + mHintGap + boxOfs, pos ); - pos += BTN_BOX_HEIGHT; - } + pos += BTN_BOX_HEIGHT; + } - if ( mCollapseBoxOn ) - { - if ( mCloseBoxOn ) pos += BOX_T_BOX_GAP; + if ( mCollapseBoxOn ) + { + if ( mCloseBoxOn ) pos += BOX_T_BOX_GAP; - mBoxes[COLLAPSE_BOX_IDX]->mPos = wxPoint( rect.x + mHintGap + boxOfs, pos ); + mBoxes[COLLAPSE_BOX_IDX]->mPos = wxPoint( rect.x + mHintGap + boxOfs, pos ); - pos += BTN_BOX_HEIGHT; + pos += BTN_BOX_HEIGHT; - pos += BOX_TO_GROOVE_GAP; - } - } - else - { - if ( mCloseBoxOn ) - { - pos -= BTN_BOX_WIDTH; + pos += BOX_TO_GROOVE_GAP; + } + } + else + { + if ( mCloseBoxOn ) + { + pos -= BTN_BOX_WIDTH; - mBoxes[CLOSE_BOX_IDX]->mPos = wxPoint( pos , rect.y + mHintGap + boxOfs ); - } + mBoxes[CLOSE_BOX_IDX]->mPos = wxPoint( pos , rect.y + mHintGap + boxOfs ); + } - if ( mCollapseBoxOn ) - { - if ( mCloseBoxOn ) pos -= BOX_T_BOX_GAP; + if ( mCollapseBoxOn ) + { + if ( mCloseBoxOn ) pos -= BOX_T_BOX_GAP; - pos -= BTN_BOX_WIDTH; + pos -= BTN_BOX_WIDTH; - mBoxes[COLLAPSE_BOX_IDX]->mPos = wxPoint( pos, rect.y + mHintGap + boxOfs ); + mBoxes[COLLAPSE_BOX_IDX]->mPos = wxPoint( pos, rect.y + mHintGap + boxOfs ); - pos -= BOX_TO_GROOVE_GAP; - } - } - } + pos -= BOX_TO_GROOVE_GAP; + } + } + } } static inline bool is_in_box( const wxPoint& rectPos, const wxPoint& mousePos ) { - return ( mousePos.x >= rectPos.x && - mousePos.y >= rectPos.y && - mousePos.x < rectPos.x + BTN_BOX_WIDTH && - mousePos.y < rectPos.y + BTN_BOX_HEIGHT ); + return ( mousePos.x >= rectPos.x && + mousePos.y >= rectPos.y && + mousePos.x < rectPos.x + BTN_BOX_WIDTH && + mousePos.y < rectPos.y + BTN_BOX_HEIGHT ); } int cbBarHintsPlugin::HitTestHints( cbBarInfo& info, const wxPoint& pos ) { - wxPoint inPane = pos; - mpPane->PaneToFrame( &inPane.x, &inPane.y ); + wxPoint inPane = pos; + mpPane->PaneToFrame( &inPane.x, &inPane.y ); - wxRect& rect = info.mBoundsInParent; + wxRect& rect = info.mBoundsInParent; - if ( info.IsFixed() ) return FALSE; + if ( info.IsFixed() ) return FALSE; - int boxOfs, grooveOfs, coord; + int boxOfs, grooveOfs, coord; - GetHintsLayout( rect, info, boxOfs, grooveOfs, coord ); + GetHintsLayout( rect, info, boxOfs, grooveOfs, coord ); - if ( mpPane->IsHorizontal() ) - { - if ( mCloseBoxOn ) - { - if ( is_in_box( wxPoint( rect.x + mHintGap + boxOfs, coord ), inPane ) ) + if ( mpPane->IsHorizontal() ) + { + if ( mCloseBoxOn ) + { + if ( is_in_box( wxPoint( rect.x + mHintGap + boxOfs, coord ), inPane ) ) - return CLOSE_BOX_HITTED; + return CLOSE_BOX_HITTED; - coord += BTN_BOX_HEIGHT; - } + coord += BTN_BOX_HEIGHT; + } - if ( mCollapseBoxOn ) - { - if ( mCloseBoxOn ) coord += BOX_T_BOX_GAP; + if ( mCollapseBoxOn ) + { + if ( mCloseBoxOn ) coord += BOX_T_BOX_GAP; - if ( is_in_box( wxPoint( rect.x + mHintGap + boxOfs, coord ), inPane ) ) + if ( is_in_box( wxPoint( rect.x + mHintGap + boxOfs, coord ), inPane ) ) - return COLLAPSE_BOX_HITTED; + return COLLAPSE_BOX_HITTED; - coord += BTN_BOX_HEIGHT; - } - } - else - { - if ( mCloseBoxOn ) - { - coord -= BTN_BOX_WIDTH; + coord += BTN_BOX_HEIGHT; + } + } + else + { + if ( mCloseBoxOn ) + { + coord -= BTN_BOX_WIDTH; - if ( is_in_box( wxPoint( coord , rect.y + mHintGap + boxOfs ), inPane ) ) + if ( is_in_box( wxPoint( coord , rect.y + mHintGap + boxOfs ), inPane ) ) - return CLOSE_BOX_HITTED; - } + return CLOSE_BOX_HITTED; + } - if ( mCollapseBoxOn ) - { - if ( mCloseBoxOn ) coord -= BOX_T_BOX_GAP; - coord -= BTN_BOX_WIDTH; + if ( mCollapseBoxOn ) + { + if ( mCloseBoxOn ) coord -= BOX_T_BOX_GAP; + coord -= BTN_BOX_WIDTH; - if ( is_in_box( wxPoint( coord, rect.y + mHintGap + boxOfs ), inPane ) ) + if ( is_in_box( wxPoint( coord, rect.y + mHintGap + boxOfs ), inPane ) ) - return COLLAPSE_BOX_HITTED; - } - } + return COLLAPSE_BOX_HITTED; + } + } - return FALSE; + return FALSE; } // handlers for plugin-events void cbBarHintsPlugin::OnSizeBarWindow( cbSizeBarWndEvent& event ) { - wxRect& rect = event.mBoundsInParent; - mpPane = event.mpPane; + wxRect& rect = event.mBoundsInParent; + mpPane = event.mpPane; - ExcludeHints( rect, *event.mpBar ); + ExcludeHints( rect, *event.mpBar ); - event.Skip(); // pass event to the next plugin in the chain + event.Skip(); // pass event to the next plugin in the chain } void cbBarHintsPlugin::OnDrawBarDecorations( cbDrawBarDecorEvent& event ) { - wxRect& rect = event.mBoundsInParent; - mpPane = event.mpPane; + wxRect& rect = event.mBoundsInParent; + mpPane = event.mpPane; - int boxOfs, grooveOfs, pos; + int boxOfs, grooveOfs, pos; - GetHintsLayout( rect, *event.mpBar, boxOfs, grooveOfs, pos ); + GetHintsLayout( rect, *event.mpBar, boxOfs, grooveOfs, pos ); - DoDrawHint( *event.mpDc, rect, pos, boxOfs, grooveOfs, event.mpBar->IsFixed() ); + DoDrawHint( *event.mpDc, rect, pos, boxOfs, grooveOfs, event.mpBar->IsFixed() ); - // let other plugins add on their decorations + // let other plugins add on their decorations - event.Skip(); + event.Skip(); } void cbBarHintsPlugin::OnLeftDown( cbLeftDownEvent& event ) { - mpPane = event.mpPane; + mpPane = event.mpPane; + wxPoint inFrame = event.mPos; - wxPoint inFrame = event.mPos; - mpPane->PaneToFrame( &inFrame.x, &inFrame.y ); + mpPane->PaneToFrame( &inFrame.x, &inFrame.y ); - wxBarIterator iter( mpPane->GetRowList() ); + wxBarIterator iter( mpPane->GetRowList() ); - mpClickedBar = NULL; + mpClickedBar = NULL; - while ( iter.Next() ) - { - cbBarInfo& bar = iter.BarInfo(); + while ( iter.Next() ) + { + cbBarInfo& bar = iter.BarInfo(); - int boxOfs, grooveOfs, pos; + int boxOfs, grooveOfs, pos; - GetHintsLayout( bar.mBoundsInParent, bar, boxOfs, grooveOfs, pos ); + GetHintsLayout( bar.mBoundsInParent, bar, boxOfs, grooveOfs, pos ); - if ( !bar.IsFixed() ) - { - int i; - for( i = 0; i != BOXES_IN_HINT; ++i ) - { - mBoxes[i]->OnLeftDown( inFrame ); + if ( !bar.IsFixed() ) + { + int i; + for ( i = 0; i != BOXES_IN_HINT; ++i ) + { + mBoxes[i]->OnLeftDown( inFrame ); - if ( mBoxes[i]->mPressed ) - { - mBtnPressed = TRUE; - mpClickedBar = &bar; + if ( mBoxes[i]->mPressed ) + { + mBtnPressed = TRUE; + mpClickedBar = &bar; - return; // event handled - } - } - } - } + return; // event handled + } + } + } + } - event.Skip(); + event.Skip(); } void cbBarHintsPlugin::OnLeftUp( cbLeftUpEvent& event ) { - if ( mBtnPressed ) - { - wxPoint inFrame = event.mPos; - mpPane->PaneToFrame( &inFrame.x, &inFrame.y ); + if ( mBtnPressed ) + { + wxPoint inFrame = event.mPos; + mpPane->PaneToFrame( &inFrame.x, &inFrame.y ); - int boxOfs, grooveOfs, pos; + int boxOfs, grooveOfs, pos; - GetHintsLayout( mpClickedBar->mBoundsInParent, *mpClickedBar, boxOfs, grooveOfs, pos ); + GetHintsLayout( mpClickedBar->mBoundsInParent, *mpClickedBar, boxOfs, grooveOfs, pos ); - int result = HitTestHints( *mpClickedBar, event.mPos ); + int result = HitTestHints( *mpClickedBar, event.mPos ); int i; - for( i = 0; i != BOXES_IN_HINT; ++i ) - { - mBoxes[i]->OnLeftUp( inFrame ); - - if ( mBoxes[i]->WasClicked() ) - { - if ( i == 0 ) - - mpLayout->SetBarState( mpClickedBar, wxCBAR_HIDDEN, TRUE ); - else - { - if ( mpClickedBar->IsExpanded() ) - - mpPane->ContractBar( mpClickedBar ); - else - mpPane->ExpandBar( mpClickedBar ); - } - } - } - - mBtnPressed = FALSE; - return; - } - else - event.Skip(); + for ( i = 0; i != BOXES_IN_HINT; ++i ) + { + mBoxes[i]->OnLeftUp( inFrame ); + + if ( mBoxes[i]->WasClicked() ) + { + if ( i == 0 ) + { + mpLayout->SetBarState( mpClickedBar, wxCBAR_HIDDEN, TRUE ); + } + else + { + if ( mpClickedBar->IsExpanded() ) + mpPane->ContractBar( mpClickedBar ); + else + mpPane->ExpandBar( mpClickedBar ); + } + } + } + + mBtnPressed = FALSE; + return; + } + else + event.Skip(); } void cbBarHintsPlugin::OnMotion( cbMotionEvent& event ) { - if ( mBtnPressed ) - { - wxPoint inFrame = event.mPos; - mpPane->PaneToFrame( &inFrame.x, &inFrame.y ); - - mpPane = event.mpPane; - - int i; - for( i = 0; i != BOXES_IN_HINT; ++i ) - - mBoxes[i]->OnMotion( inFrame ); - } - else - event.Skip(); + if ( mBtnPressed ) + { + wxPoint inFrame = event.mPos; + mpPane->PaneToFrame( &inFrame.x, &inFrame.y ); + + mpPane = event.mpPane; + + int i; + for ( i = 0; i != BOXES_IN_HINT; ++i ) + { + mBoxes[i]->OnMotion( inFrame ); + } + } + else + event.Skip(); } void cbBarHintsPlugin::OnInitPlugin() { - cbPluginBase::OnInitPlugin(); - - cbDockPane** panes = mpLayout->GetPanesArray(); - - int i; - for( i = 0; i != MAX_PANES; ++i ) - { - if ( panes[i]->MatchesMask( mPaneMask ) ) - { - panes[i]->mProps.mMinCBarDim.x = 25; - panes[i]->mProps.mMinCBarDim.y = 16; - } - } - CreateBoxes(); + cbPluginBase::OnInitPlugin(); + + cbDockPane** panes = mpLayout->GetPanesArray(); + + int i; + for ( i = 0; i != MAX_PANES; ++i ) + { + if ( panes[i]->MatchesMask( mPaneMask ) ) + { + panes[i]->mProps.mMinCBarDim.x = 25; + panes[i]->mProps.mMinCBarDim.y = 16; + } + } + CreateBoxes(); } diff --git a/contrib/src/fl/gcupdatesmgr.cpp b/contrib/src/fl/gcupdatesmgr.cpp index 3da75dff21..dfe73d3811 100644 --- a/contrib/src/fl/gcupdatesmgr.cpp +++ b/contrib/src/fl/gcupdatesmgr.cpp @@ -141,7 +141,8 @@ void cbGCUpdatesMgr::UpdateNow() wxList mBarsToResize; - for( int n = 0; n != MAX_PANES; ++n ) + int n; + for ( n = 0; n != MAX_PANES; ++n ) { cbDockPane& pane = *(panes[n]); @@ -164,7 +165,7 @@ void cbGCUpdatesMgr::UpdateNow() cbBarInfo* pBar = pRow->GetFirstBar(); bool rowChanged = FALSE; - bool rowBkPainted = FALSE; +// bool rowBkPainted = FALSE; // FIXME:: the below should not be fixed cbBarInfo* barsToRepaint[128]; @@ -207,7 +208,7 @@ void cbGCUpdatesMgr::UpdateNow() cbBarInfo* pCurBar = pRow->GetFirstBar(); - while( pCurBar ) + while ( pCurBar ) { if ( WasChanged( pCurBar->mUMgrData, pCurBar->mBoundsInParent ) ) @@ -226,7 +227,7 @@ void cbGCUpdatesMgr::UpdateNow() else if ( nBars != 0 ) { - for( int i = 0; i != nBars; ++i ) + for ( int i = 0; i != nBars; ++i ) // postphone the resizement and refreshing the changed // bar windows diff --git a/contrib/src/fl/panedrawpl.cpp b/contrib/src/fl/panedrawpl.cpp index 8a20e05737..7feaa75290 100644 --- a/contrib/src/fl/panedrawpl.cpp +++ b/contrib/src/fl/panedrawpl.cpp @@ -381,14 +381,7 @@ void cbPaneDrawPlugin::OnLDblClick( cbLeftDClickEvent& event ) &pBarToFloat ) == CB_BAR_CONTENT_HITTED ) { - // TBD: ???? - return; - - mpLayout->SetBarState( pBarToFloat, wxCBAR_FLOATING, TRUE ); - - mpLayout->RepositionFloatedBar( pBarToFloat ); - - return; // event is "eaten" by this plugin + return; } event.Skip(); @@ -439,7 +432,7 @@ void cbPaneDrawPlugin::OnLButtonDown( cbLeftDownEvent& event ) { // otehrwise if bar handle dragged - cbRowInfo& rowInfo = *mpDraggedBar->mpRow; +// cbRowInfo& rowInfo = *mpDraggedBar->mpRow; wxRect& bounds = mpDraggedBar->mBounds; mHandleIsVertical = ( event.mpPane->IsHorizontal() ) ? TRUE : FALSE; @@ -735,27 +728,27 @@ void cbPaneDrawPlugin::OnDrawRowBackground ( cbDrawRowBkGroundEvent& event ) wxRect rowBounds = pRow->mBoundsInParent; bool isHorizontal = event.mpPane->IsHorizontal(); - int prevPos; +// int prevPos; if ( isHorizontal ) { - prevPos = rowBounds.x; - // include one line obove and below the row +// prevPos = rowBounds.x; + // include one line above and below the row --rowBounds.y; - rowBounds.height +=2; + rowBounds.height += 2; --rowBounds.x; - rowBounds.width += 2; + rowBounds.width += 2; } else { - prevPos = rowBounds.y; - // include one line obove and below the row +// prevPos = rowBounds.y; + // include one line above and below the row --rowBounds.x; - rowBounds.width += 2; + rowBounds.width += 2; --rowBounds.y; - rowBounds.height +=2; + rowBounds.height += 2; } //#define TEST_BK_ERASING @@ -1170,7 +1163,7 @@ void cbPaneDrawPlugin::OnDrawPaneDecorations( cbDrawPaneDecorEvent& event ) void cbPaneDrawPlugin::OnDrawBarDecorations( cbDrawBarDecorEvent& event ) { - cbBarInfo* pBar = event.mpBar; +// cbBarInfo* pBar = event.mpBar; wxDC& dc = *event.mpDc; // draw brick borders diff --git a/contrib/src/fl/rowdragpl.cpp b/contrib/src/fl/rowdragpl.cpp index e0ea5ad12f..3e095121a9 100644 --- a/contrib/src/fl/rowdragpl.cpp +++ b/contrib/src/fl/rowdragpl.cpp @@ -229,7 +229,7 @@ void cbRowDragPlugin::OnMouseMove( cbMotionEvent& event ) // DBG:: wxPoint p = event.mPos; wxPoint d = mDragOrigin; - int dif = event.mPos.x - mDragOrigin.x; +// int dif = event.mPos.x - mDragOrigin.x; // row is dragged up or down; ShowDraggedRow( pos.y - mDragOrigin.y ); @@ -239,7 +239,7 @@ void cbRowDragPlugin::OnMouseMove( cbMotionEvent& event ) // DBG:: wxPoint p = event.mPos; wxPoint d = mDragOrigin; - int dif = event.mPos.x - mDragOrigin.x; +// int dif = event.mPos.x - mDragOrigin.x; // row is dragged left or right ShowDraggedRow( pos.x - mDragOrigin.x ); diff --git a/contrib/src/fl/rowlayoutpl.cpp b/contrib/src/fl/rowlayoutpl.cpp index 0ca0f45181..064a35a67d 100644 --- a/contrib/src/fl/rowlayoutpl.cpp +++ b/contrib/src/fl/rowlayoutpl.cpp @@ -6,7 +6,7 @@ // Created: 09/09/98 // RCS-ID: $Id$ // Copyright: (c) Aleksandras Gluchovas -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -35,1186 +35,1181 @@ IMPLEMENT_DYNAMIC_CLASS( cbRowLayoutPlugin, cbPluginBase ) BEGIN_EVENT_TABLE( cbRowLayoutPlugin, cbPluginBase ) - EVT_PL_LAYOUT_ROW ( cbRowLayoutPlugin::OnLayoutRow ) - EVT_PL_LAYOUT_ROWS( cbRowLayoutPlugin::OnLayoutRows ) - EVT_PL_RESIZE_ROW ( cbRowLayoutPlugin::OnResizeRow ) + EVT_PL_LAYOUT_ROW ( cbRowLayoutPlugin::OnLayoutRow ) + EVT_PL_LAYOUT_ROWS( cbRowLayoutPlugin::OnLayoutRows ) + EVT_PL_RESIZE_ROW ( cbRowLayoutPlugin::OnResizeRow ) - EVT_PL_INSERT_BAR ( cbRowLayoutPlugin::OnInsertBar ) - EVT_PL_REMOVE_BAR ( cbRowLayoutPlugin::OnRemoveBar ) + EVT_PL_INSERT_BAR ( cbRowLayoutPlugin::OnInsertBar ) + EVT_PL_REMOVE_BAR ( cbRowLayoutPlugin::OnRemoveBar ) END_EVENT_TABLE() cbRowLayoutPlugin::cbRowLayoutPlugin(void) - : mpPane( 0 ) + : mpPane( 0 ) {} cbRowLayoutPlugin::cbRowLayoutPlugin( wxFrameLayout* pPanel, int paneMask ) - : cbPluginBase( pPanel, paneMask ), - mpPane( 0 ) + : cbPluginBase( pPanel, paneMask ), + mpPane( 0 ) {} void cbRowLayoutPlugin::CheckIfAtTheBoundary( cbBarInfo* pTheBar, cbRowInfo& rowInfo ) { - // this method handles situation, when fixed bar is inserted - // into the row, where among fixed bars not-fixed ones are present. - // In this case we need to check if the pBarNode appears to be inserted - // chain of fixed-bars on the very right or left side of the row, - // then all the white-space, such chain should be eliminated, - // and the resulting chain justified to the right or the left - // side of the row + // this method handles situation, when fixed bar is inserted + // into the row, where among fixed bars not-fixed ones are present. + // In this case we need to check if the pBarNode appears to be inserted + // chain of fixed-bars on the very right or left side of the row, + // then all the white-space, such chain should be eliminated, + // and the resulting chain justified to the right or the left + // side of the row - if ( !pTheBar->IsFixed() || rowInfo.mHasOnlyFixedBars ) + if ( !pTheBar->IsFixed() || rowInfo.mHasOnlyFixedBars ) - return; + return; - cbBarInfo* pBar = rowInfo.mBars[ rowInfo.mBars.Count() - 1 ]; + cbBarInfo* pBar = rowInfo.mBars[ rowInfo.mBars.Count() - 1 ]; - // slide fixed bars to the right on the right side relative to the pBarNode + // slide fixed bars to the right on the right side relative to the pBarNode - int prevX = mpPane->mPaneWidth; + int prevX = mpPane->mPaneWidth; - do - { - if ( !pBar->IsFixed() ) - break; + do + { + if ( !pBar->IsFixed() ) + break; - wxRect& bounds = pBar->mBounds; + wxRect& bounds = pBar->mBounds; - bounds.x = prevX - bounds.width; + bounds.x = prevX - bounds.width; - prevX = bounds.x; + prevX = bounds.x; - if ( pBar == pTheBar ) break; + if ( pBar == pTheBar ) break; - pBar = pBar->mpPrev; - } - while( 1 ); + pBar = pBar->mpPrev; + } + while( 1 ); - // slide fixed bars to the left on the left side relative to the pBarNode + // slide fixed bars to the left on the left side relative to the pBarNode - pBar = rowInfo.mBars[0]; + pBar = rowInfo.mBars[0]; - prevX = 0; - - do - { - if ( pBar->IsFixed() ) + prevX = 0; + + do + { + if ( pBar->IsFixed() ) - break; + break; - wxRect& bounds = pBar->mBounds; + wxRect& bounds = pBar->mBounds; - bounds.x = prevX; + bounds.x = prevX; - prevX = bounds.x + bounds.width; + prevX = bounds.x + bounds.width; - if ( pBar == pTheBar ) break; + if ( pBar == pTheBar ) break; - pBar = pBar->mpNext; - } - while( 1 ); + pBar = pBar->mpNext; + } + while( 1 ); } void cbRowLayoutPlugin::ExpandNotFixedBars( cbRowInfo* pRow ) { - ApplyLengthRatios( pRow ); - - // FIXME:: something's wrong? - return; - - double freeSpc = (double)GetRowFreeSpace( pRow ); - - // calculate sum of precents + ApplyLengthRatios( pRow ); - double pcntSum = 0.0; + // FIXME:: something's wrong? + return; - size_t i = 0; + double freeSpc = (double)GetRowFreeSpace( pRow ); - for( i = 0; i != pRow->mBars.Count(); ++i ) - { - if ( !pRow->mBars[i]->IsFixed() ) - pcntSum += pRow->mBars[i]->mLenRatio; - } + // calculate sum of precents - // setup bar lengths + double pcntSum = 0.0; - int curX = 0; + size_t i; + for ( i = 0; i != pRow->mBars.Count(); ++i ) + { + if ( !pRow->mBars[i]->IsFixed() ) + pcntSum += pRow->mBars[i]->mLenRatio; + } - for( i = 0; i != pRow->mBars.Count(); ++i ) - { - cbBarInfo& bar = *pRow->mBars[i]; + // setup bar lengths - if ( !bar.IsFixed() ) - { - bar.mLenRatio = bar.mLenRatio/(pcntSum); + int curX = 0; - bar.mBounds.width = - - wxMax( mpPane->mProps.mMinCBarDim.x, int( freeSpc*bar.mLenRatio ) ); - } - - bar.mBounds.x = curX; - curX = bar.mBounds.x + bar.mBounds.width; - } + for ( i = 0; i != pRow->mBars.Count(); ++i ) + { + cbBarInfo& bar = *pRow->mBars[i]; + + if ( !bar.IsFixed() ) + { + bar.mLenRatio = bar.mLenRatio/(pcntSum); + + bar.mBounds.width = + + wxMax( mpPane->mProps.mMinCBarDim.x, int( freeSpc*bar.mLenRatio ) ); + } + + bar.mBounds.x = curX; + curX = bar.mBounds.x + bar.mBounds.width; + } } void cbRowLayoutPlugin::AdjustLengthOfInserted( cbRowInfo* pRow, cbBarInfo* pTheBar ) { - return; + return; // TBD: Makes following code unreachable - // pTheBar is not-fixed + // pTheBar is not-fixed - // FIXME:: what is this for?? + // FIXME:: what is this for?? #if 1 - int totalLen = 0; + int totalLen = 0; size_t i; - for( i = 0; i != pRow->mBars.Count(); ++i ) + for ( i = 0; i != pRow->mBars.Count(); ++i ) { - if ( !pRow->mBars[i]->IsFixed() ) - totalLen += pRow->mBars[i]->mBounds.width; + if ( !pRow->mBars[i]->IsFixed() ) + totalLen += pRow->mBars[i]->mBounds.width; } - double curWidth = pTheBar->mBounds.width; - - if ( pRow->mBars.Count() ) + double curWidth = pTheBar->mBounds.width; - pTheBar->mBounds.width = int( mpPane->mPaneWidth * (curWidth / double(totalLen)) ); + if ( pRow->mBars.Count() ) + pTheBar->mBounds.width = int( mpPane->mPaneWidth * (curWidth / double(totalLen)) ); #else - double freeSpc = (double)GetRowFreeSpace( pRow ); + double freeSpc = (double)GetRowFreeSpace( pRow ); - double pcntSum = 0.0; + double pcntSum = 0.0; - size_t i; - for( i = 0; i != pRow->mBars.Count(); ++i ) - { - if ( !pRow->mBars[i]->IsFixed() ) - pcntSum += pRow->mBars[i]->mLenRatio; - } + size_t i; + for ( i = 0; i != pRow->mBars.Count(); ++i ) + { + if ( !pRow->mBars[i]->IsFixed() ) + pcntSum += pRow->mBars[i]->mLenRatio; + } - // if no longer "balanced", assume that `pTheBar' was previously - // removed from this row (kind of AI...) + // if no longer "balanced", assume that `pTheBar' was previously + // removed from this row (kind of AI...) - if ( pcntSum < 0.98 ) - - pTheBar->mBounds.width = freeSpc * (1.0 - pcntSum); + if ( pcntSum < 0.98 ) + + pTheBar->mBounds.width = freeSpc * (1.0 - pcntSum); #endif } -void cbRowLayoutPlugin::FitBarsToRange( int from, int till, - cbBarInfo* pTheBar, cbRowInfo* pRow ) +void cbRowLayoutPlugin::FitBarsToRange( int from, int till, + cbBarInfo* pTheBar, cbRowInfo* pRow ) { - cbBarInfo* pFromBar = NULL; - cbBarInfo* pTillBar = NULL; - - if ( pTheBar->mBounds.x > from ) - { - // it's range from the left - pFromBar = pRow->mBars[0]; - pTillBar = pTheBar; - } - else - { - pFromBar = pTheBar->mpNext; - pTillBar = NULL; - } - - // calc free space in the range - - cbBarInfo* pBar = pFromBar; - int freeSpc = till-from; - double pcntSum = 0; - - while( pBar != pTillBar ) - { - if ( pBar->IsFixed() ) - - freeSpc -= pBar->mBounds.width; - else - pcntSum += pBar->mLenRatio; - - pBar = pBar->mpNext; - } - - // adjust not-fixed bar sizes in the range - - pBar = pFromBar; - - while( pBar != pTillBar ) - { - if ( !pBar->IsFixed() ) - - pBar->mBounds.width = - - wxMax( mpPane->mProps.mMinCBarDim.x, - int( double(freeSpc) * (pBar->mLenRatio/pcntSum) ) - ); - - pBar = pBar->mpNext; - } - - // layout range, starting from the left-most bar - - pBar = pFromBar; - int prevX = from; - bool hasNotFixedBars = FALSE; - - while ( pBar != pTillBar ) - { - wxRect& bounds = pBar->mBounds; - - if ( !pBar->IsFixed() ) - { - hasNotFixedBars = TRUE; - - freeSpc -= bounds.width; - } - - bounds.x = prevX; - - prevX = bounds.x + bounds.width; - - pBar = pBar->mpNext; - } - - // make width adjustment for the right-most bar in the range, due to - // lost precision when seting widths using f.p. length-ratios - - if ( hasNotFixedBars ) - { - if ( pTheBar->mBounds.x > from ) - { - if ( pTillBar->mpPrev ) - { - wxRect& tillBar = pTillBar->mpPrev->mBounds; - - //tillBar.width = bar.mBounds.x - tillBar.x; - tillBar.width += freeSpc; - } - } - else - { - cbBarInfo* pLast = pRow->mBars[ pRow->mBars.Count() - 1 ]; - - if ( pLast != pTheBar ) - { - pTheBar->mBounds.width += freeSpc; - - SlideRightSideBars( pTheBar ); - } - } - } + cbBarInfo* pFromBar = NULL; + cbBarInfo* pTillBar = NULL; + + if ( pTheBar->mBounds.x > from ) + { + // it's range from the left + pFromBar = pRow->mBars[0]; + pTillBar = pTheBar; + } + else + { + pFromBar = pTheBar->mpNext; + pTillBar = NULL; + } + + // calc free space in the range + + cbBarInfo* pBar = pFromBar; + int freeSpc = till-from; + double pcntSum = 0; + + while( pBar != pTillBar ) + { + if ( pBar->IsFixed() ) + freeSpc -= pBar->mBounds.width; + else + pcntSum += pBar->mLenRatio; + + pBar = pBar->mpNext; + } + + // adjust not-fixed bar sizes in the range + + pBar = pFromBar; + + while ( pBar != pTillBar ) + { + if ( !pBar->IsFixed() ) + { + pBar->mBounds.width = + wxMax( mpPane->mProps.mMinCBarDim.x, + int( double(freeSpc) * (pBar->mLenRatio/pcntSum) ) + ); + } + pBar = pBar->mpNext; + } + + // layout range, starting from the left-most bar + + pBar = pFromBar; + int prevX = from; + bool hasNotFixedBars = FALSE; + + while ( pBar != pTillBar ) + { + wxRect& bounds = pBar->mBounds; + + if ( !pBar->IsFixed() ) + { + hasNotFixedBars = TRUE; + + freeSpc -= bounds.width; + } + + bounds.x = prevX; + + prevX = bounds.x + bounds.width; + + pBar = pBar->mpNext; + } + + // make width adjustment for the right-most bar in the range, due to + // lost precision when seting widths using f.p. length-ratios + + if ( hasNotFixedBars ) + { + if ( pTheBar->mBounds.x > from ) + { + if ( pTillBar->mpPrev ) + { + wxRect& tillBar = pTillBar->mpPrev->mBounds; + + //tillBar.width = bar.mBounds.x - tillBar.x; + tillBar.width += freeSpc; + } + } + else + { + cbBarInfo* pLast = pRow->mBars[ pRow->mBars.Count() - 1 ]; + + if ( pLast != pTheBar ) + { + pTheBar->mBounds.width += freeSpc; + + SlideRightSideBars( pTheBar ); + } + } + } } void cbRowLayoutPlugin::MinimzeNotFixedBars( cbRowInfo* pRow, cbBarInfo* pBarToPreserve ) { size_t i; - for( i = 0; i != pRow->mBars.Count(); ++i ) + for ( i = 0; i != pRow->mBars.Count(); ++i ) { - if ( !pRow->mBars[i]->IsFixed() && pRow->mBars[i] != pBarToPreserve ) - pRow->mBars[i]->mBounds.width = mpPane->mProps.mMinCBarDim.x; + if ( !pRow->mBars[i]->IsFixed() && pRow->mBars[i] != pBarToPreserve ) + pRow->mBars[i]->mBounds.width = mpPane->mProps.mMinCBarDim.x; } } int cbRowLayoutPlugin::GetRowFreeSpace( cbRowInfo* pRow ) { - int freeSpc = mpPane->mPaneWidth; + int freeSpc = mpPane->mPaneWidth; size_t i; - for( i = 0; i != pRow->mBars.Count(); ++i ) + for ( i = 0; i != pRow->mBars.Count(); ++i ) { - // not-fixed bars variable length, thus their - // dimensions are ignored - if ( pRow->mBars[i]->IsFixed() ) - freeSpc -= pRow->mBars[i]->mBounds.width; + // not-fixed bars variable length, thus their + // dimensions are ignored + if ( pRow->mBars[i]->IsFixed() ) + freeSpc -= pRow->mBars[i]->mBounds.width; } - return freeSpc; + return freeSpc; } void cbRowLayoutPlugin::RecalcLengthRatios( cbRowInfo* pRow ) { - double freeSpc = double( GetRowFreeSpace( pRow ) ); + double freeSpc = double( GetRowFreeSpace( pRow ) ); - cbBarInfo* pBar = pRow->mBars[0]; - cbBarInfo* pLastNotFixed = NULL; + cbBarInfo* pBar = pRow->mBars[0]; + cbBarInfo* pLastNotFixed = NULL; - double pcntLeft = 1.0; // (100%) + double pcntLeft = 1.0; // (100%) #ifdef __EXPERIMENTAL - int totalLen = 0; + int totalLen = 0; size_t i; - for( i = 0; i != pRow->mBars.Count(); ++i ) + for ( i = 0; i != pRow->mBars.Count(); ++i ) { - if ( !pRow->mBars[i]->IsFixed() ) - totalLen += pRow->mBars[i]->mBounds.width; + if ( !pRow->mBars[i]->IsFixed() ) + totalLen += pRow->mBars[i]->mBounds.width; } #endif size_t i; - for( i = 0; i != pRow->mBars.Count(); ++i ) - { - cbBarInfo& bar = *pRow->mBars[i]; + for ( i = 0; i != pRow->mBars.Count(); ++i ) + { + cbBarInfo& bar = *pRow->mBars[i]; - if ( !bar.IsFixed() ) - { + if ( !bar.IsFixed() ) + { #ifdef __EXPERIMENTAL - bar.mLenRatio = double(bar.mBounds.width)/double(totalLen); + bar.mLenRatio = double(bar.mBounds.width)/double(totalLen); #else - bar.mLenRatio = double(bar.mBounds.width)/freeSpc; + bar.mLenRatio = double(bar.mBounds.width)/freeSpc; #endif - pcntLeft -= bar.mLenRatio; - pLastNotFixed = pBar; - } - } + pcntLeft -= bar.mLenRatio; + pLastNotFixed = pBar; + } + } - // attach remainder (the result of lost precision) to the - // last not-fixed bar + // attach remainder (the result of lost precision) to the + // last not-fixed bar -#if !defined(__EXPERIMENTAL) +#if !defined(__EXPERIMENTAL) - if ( pLastNotFixed ) - - pLastNotFixed->mLenRatio += pcntLeft; + if ( pLastNotFixed ) + + pLastNotFixed->mLenRatio += pcntLeft; #endif } void cbRowLayoutPlugin::ApplyLengthRatios( cbRowInfo* pRow ) { - double pcntSum = 0; + double pcntSum = 0; - // FOR NOW:: all-in-one + // FOR NOW:: all-in-one - size_t i = 0; - for( i = 0; i != pRow->mBars.Count(); ++i ) + size_t i = 0; + for ( i = 0; i != pRow->mBars.Count(); ++i ) { - if ( !pRow->mBars[i]->IsFixed() ) - pcntSum += pRow->mBars[i]->mLenRatio; + if ( !pRow->mBars[i]->IsFixed() ) + pcntSum += pRow->mBars[i]->mLenRatio; } - /* - pBar = node_to_first_bar_node( pRow ); - - while( pBar ) - { - cbBarInfo& bar = node_to_bar( pBar ); - - if ( !bar.IsFixed() ) - - bar.mLenRatio = pcntSum / bar.mLenRatio; - - pBar = pBar->Next(); - } - */ - - int prevX = 0; - double freeSpc = GetRowFreeSpace( pRow ); - - // tricky stuff (improtant!): - // when not-fixed bar is removed from the row and there are - // still some other not-fixed ones left in that row, then - // the sum of mLenRatio's is no longer 1.0 - this is left - // intintionally to handle the case when the removed bar - // is returned right back to the row - so that it would retain - // it's original dimensions in this row (this is kind of AI...) - // - // The problem is - when it's remvoed, the sum of - // mLenRatio's is not in "balance", i.e. is < 1.0, - // it's possible to restore balance, but instead of that - // we artifically ajdust freeSpc value in a way that it would - // look like total of mLetRatio's is 1.0, thus original - // len. ratios are _preserved_: - - double unit = freeSpc / pcntSum; - - bool haveSquished = FALSE; - - for( i = 0; i != pRow->mBars.Count(); ++i ) + /* + pBar = node_to_first_bar_node( pRow ); + + while( pBar ) + { + cbBarInfo& bar = node_to_bar( pBar ); + + if ( !bar.IsFixed() ) + + bar.mLenRatio = pcntSum / bar.mLenRatio; + + pBar = pBar->Next(); + } + */ + + int prevX = 0; + double freeSpc = GetRowFreeSpace( pRow ); + + // tricky stuff (improtant!): + // when not-fixed bar is removed from the row and there are + // still some other not-fixed ones left in that row, then + // the sum of mLenRatio's is no longer 1.0 - this is left + // intintionally to handle the case when the removed bar + // is returned right back to the row - so that it would retain + // it's original dimensions in this row (this is kind of AI...) + // + // The problem is - when it's remvoed, the sum of + // mLenRatio's is not in "balance", i.e. is < 1.0, + // it's possible to restore balance, but instead of that + // we artifically ajdust freeSpc value in a way that it would + // look like total of mLetRatio's is 1.0, thus original + // len. ratios are _preserved_: + + double unit = freeSpc / pcntSum; + + bool haveSquished = FALSE; + + for ( i = 0; i != pRow->mBars.Count(); ++i ) { - if ( !pRow->mBars[i]->IsFixed() ) - { - cbBarInfo& bar = *pRow->mBars[i]; - - if ( int( unit * bar.mLenRatio ) < mpPane->mProps.mMinCBarDim.x ) - { - haveSquished = TRUE; + if ( !pRow->mBars[i]->IsFixed() ) + { + cbBarInfo& bar = *pRow->mBars[i]; + + if ( int( unit * bar.mLenRatio ) < mpPane->mProps.mMinCBarDim.x ) + { + haveSquished = TRUE; - bar.mBounds.width = -1; // mark as "squished" + bar.mBounds.width = -1; // mark as "squished" - pcntSum -= bar.mLenRatio; + pcntSum -= bar.mLenRatio; - freeSpc -= mpPane->mProps.mMinCBarDim.x; - } - } + freeSpc -= mpPane->mProps.mMinCBarDim.x; + } + } } // for - if ( haveSquished ) - - unit = freeSpc / pcntSum; + if ( haveSquished ) + unit = freeSpc / pcntSum; - for( i = 0; i != pRow->mBars.Count(); ++i ) - { - cbBarInfo& bar = *pRow->mBars[i]; + for ( i = 0; i != pRow->mBars.Count(); ++i ) + { + cbBarInfo& bar = *pRow->mBars[i]; - bar.mBounds.x = prevX; + bar.mBounds.x = prevX; - if ( !bar.IsFixed() ) - { - if ( bar.mBounds.width == -1 ) + if ( !bar.IsFixed() ) + { + if ( bar.mBounds.width == -1 ) - bar.mBounds.width = mpPane->mProps.mMinCBarDim.x; - else - bar.mBounds.width = int( unit * bar.mLenRatio ); + bar.mBounds.width = mpPane->mProps.mMinCBarDim.x; + else + bar.mBounds.width = int( unit * bar.mLenRatio ); - // a little bit of AI: - // memorize bar's height and width, when docked in - // the current orientation - by making the current - // dimensions to be "preffered" ones for this docking state + // a little bit of AI: + // memorize bar's height and width, when docked in + // the current orientation - by making the current + // dimensions to be "preffered" ones for this docking state - if ( !bar.IsFixed() ) - { - bar.mDimInfo.mSizes[ bar.mState ].x = bar.mBounds.width; - bar.mDimInfo.mSizes[ bar.mState ].y = bar.mBounds.height; - } - } + if ( !bar.IsFixed() ) + { + bar.mDimInfo.mSizes[ bar.mState ].x = bar.mBounds.width; + bar.mDimInfo.mSizes[ bar.mState ].y = bar.mBounds.height; + } + } - prevX = bar.mBounds.x + bar.mBounds.width; - } + prevX = bar.mBounds.x + bar.mBounds.width; + } } void cbRowLayoutPlugin::DetectBarHandles( cbRowInfo* pRow ) { - // first pass from left to right (detect left-side handles) + // first pass from left to right (detect left-side handles) - bool foundNotFixed = FALSE; + bool foundNotFixed = FALSE; size_t i; - for( i = 0; i != pRow->mBars.Count(); ++i ) - { - cbBarInfo& bar = *pRow->mBars[i]; - - bar.mHasLeftHandle = FALSE; - - if ( !bar.IsFixed() ) - { - if ( foundNotFixed ) - - if ( bar.mpPrev && - bar.mpPrev->IsFixed() ) - - bar.mHasLeftHandle = TRUE; - - foundNotFixed = TRUE; - } - } + for ( i = 0; i != pRow->mBars.Count(); ++i ) + { + cbBarInfo& bar = *pRow->mBars[i]; + + bar.mHasLeftHandle = FALSE; + + if ( !bar.IsFixed() ) + { + if ( foundNotFixed ) + + if ( bar.mpPrev && + bar.mpPrev->IsFixed() ) + + bar.mHasLeftHandle = TRUE; + + foundNotFixed = TRUE; + } + } - // pass from right to left (detect right-side handles) + // pass from right to left (detect right-side handles) - foundNotFixed = FALSE; + foundNotFixed = FALSE; - cbBarInfo* pBar = pRow->mBars[ pRow->mBars.Count() - 1 ]; + cbBarInfo* pBar = pRow->mBars[ pRow->mBars.Count() - 1 ]; - while( pBar ) - { - pBar->mHasRightHandle = FALSE; + while( pBar ) + { + pBar->mHasRightHandle = FALSE; - if ( !pBar->IsFixed() ) - { - if ( foundNotFixed ) + if ( !pBar->IsFixed() ) + { + if ( foundNotFixed ) - if ( pBar->mpNext ) + if ( pBar->mpNext ) - pBar->mHasRightHandle = TRUE; + pBar->mHasRightHandle = TRUE; - foundNotFixed = TRUE; - } + foundNotFixed = TRUE; + } - pBar = pBar->mpPrev; - } + pBar = pBar->mpPrev; + } } void cbRowLayoutPlugin::RelayoutNotFixedBarsAround( cbBarInfo* pTheBar, cbRowInfo* pRow ) { - if ( !pTheBar->mpPrev ) - { - if ( !pTheBar->IsFixed() ) - { - // this bar the first in the row, move it's - // left edge to the very left - pTheBar->mBounds.width += pTheBar->mBounds.x; - pTheBar->mBounds.x = 0; - } - } - else - FitBarsToRange( 0, pTheBar->mBounds.x, pTheBar, pRow ); - - if ( !pTheBar->mpNext ) - { - if ( !pTheBar->IsFixed() ) - { - // this bar is the last one, move it's - // right edge to the very right - - pTheBar->mBounds.width = mpPane->mPaneWidth - pTheBar->mBounds.x; - } - } - else - FitBarsToRange( pTheBar->mBounds.x + pTheBar->mBounds.width, mpPane->mPaneWidth, - pTheBar, pRow - ); + if ( !pTheBar->mpPrev ) + { + if ( !pTheBar->IsFixed() ) + { + // this bar the first in the row, move it's + // left edge to the very left + pTheBar->mBounds.width += pTheBar->mBounds.x; + pTheBar->mBounds.x = 0; + } + } + else + FitBarsToRange( 0, pTheBar->mBounds.x, pTheBar, pRow ); + + if ( !pTheBar->mpNext ) + { + if ( !pTheBar->IsFixed() ) + { + // this bar is the last one, move it's + // right edge to the very right + + pTheBar->mBounds.width = mpPane->mPaneWidth - pTheBar->mBounds.x; + } + } + else + FitBarsToRange( pTheBar->mBounds.x + pTheBar->mBounds.width, mpPane->mPaneWidth, + pTheBar, pRow + ); } void cbRowLayoutPlugin::LayoutItemsVertically( cbRowInfo& row ) { size_t i; - for( i = 0; i != row.mBars.Count(); ++i ) - { - cbBarInfo& bar = *row.mBars[i]; + for ( i = 0; i != row.mBars.Count(); ++i ) + { + cbBarInfo& bar = *row.mBars[i]; - bar.mBounds.y = row.mRowY; + bar.mBounds.y = row.mRowY; - if ( !bar.IsFixed() ) + if ( !bar.IsFixed() ) - // make all not-fixed bars of equal height - bar.mBounds.height = row.mRowHeight; + // make all not-fixed bars of equal height + bar.mBounds.height = row.mRowHeight; - if ( row.mHasUpperHandle ) + if ( row.mHasUpperHandle ) - bar.mBounds.y += mpPane->mProps.mResizeHandleSize; - } + bar.mBounds.y += mpPane->mProps.mResizeHandleSize; + } } int cbRowLayoutPlugin::CalcRowHeight( cbRowInfo& row ) { - int maxHeight = 0; + int maxHeight = 0; size_t i; - for( i = 0; i != row.mBars.Count(); ++i ) - - maxHeight = wxMax( maxHeight, row.mBars[i]->mBounds.height ); + for ( i = 0; i != row.mBars.Count(); ++i ) + + maxHeight = wxMax( maxHeight, row.mBars[i]->mBounds.height ); - return maxHeight; + return maxHeight; } void cbRowLayoutPlugin::StickRightSideBars( cbBarInfo* pToBar ) { - cbBarInfo* pBar = pToBar->mpNext; - cbBarInfo* pPrev = pToBar; + cbBarInfo* pBar = pToBar->mpNext; + cbBarInfo* pPrev = pToBar; - while( pBar ) - { - wxRect& cur = pBar->mBounds; - wxRect& prev = pPrev->mBounds; + while( pBar ) + { + wxRect& cur = pBar->mBounds; + wxRect& prev = pPrev->mBounds; - cur.x = prev.x + prev.width; + cur.x = prev.x + prev.width; - pPrev = pBar; - pBar = pBar->mpNext; - } + pPrev = pBar; + pBar = pBar->mpNext; + } } void cbRowLayoutPlugin::SlideLeftSideBars( cbBarInfo* pTheBar ) { - // shift left-side-bars to the left (with respect to "theBar"), - // so that they would not obscured by each other + // shift left-side-bars to the left (with respect to "theBar"), + // so that they would not obscured by each other - cbBarInfo* pBar = pTheBar->mpPrev; - cbBarInfo* pPrev = pTheBar; + cbBarInfo* pBar = pTheBar->mpPrev; + cbBarInfo* pPrev = pTheBar; - while( pBar ) - { - wxRect& cur = pBar->mBounds; - wxRect& prev = pPrev->mBounds; + while( pBar ) + { + wxRect& cur = pBar->mBounds; + wxRect& prev = pPrev->mBounds; - if ( cur.x + cur.width > prev.x ) + if ( cur.x + cur.width > prev.x ) - cur.x = prev.x - cur.width; + cur.x = prev.x - cur.width; - pPrev = pBar; - pBar = pBar->mpPrev; - } + pPrev = pBar; + pBar = pBar->mpPrev; + } } void cbRowLayoutPlugin::SlideRightSideBars( cbBarInfo* pTheBar ) { - // shift right-side-bars to the right (with respect to "theBar"), - // so that they would not be obscured by each other + // shift right-side-bars to the right (with respect to "theBar"), + // so that they would not be obscured by each other - cbBarInfo* pBar = pTheBar->mpNext; - cbBarInfo* pPrev = pTheBar; + cbBarInfo* pBar = pTheBar->mpNext; + cbBarInfo* pPrev = pTheBar; - while( pBar ) - { - wxRect& cur = pBar->mBounds; - wxRect& prev = pPrev->mBounds; + while( pBar ) + { + wxRect& cur = pBar->mBounds; + wxRect& prev = pPrev->mBounds; - if ( cur.x < prev.x + prev.width ) + if ( cur.x < prev.x + prev.width ) - cur.x = prev.x + prev.width; + cur.x = prev.x + prev.width; - pPrev = pBar; - pBar = pBar->mpNext; - } + pPrev = pBar; + pBar = pBar->mpNext; + } } void cbRowLayoutPlugin::ShiftLeftTrashold( cbBarInfo* pTheBar, cbRowInfo& row ) { - wxRect& first = row.mBars[0]->mBounds; + wxRect& first = row.mBars[0]->mBounds; - if ( first.x < 0 ) - { - row.mBars[0]->mBounds.x = 0; + if ( first.x < 0 ) + { + row.mBars[0]->mBounds.x = 0; - SlideRightSideBars( row.mBars[0] ); - } + SlideRightSideBars( row.mBars[0] ); + } } void cbRowLayoutPlugin::ShiftRightTrashold( cbBarInfo* pTheBar, cbRowInfo& row ) { - wxRect& theBar = pTheBar->mBounds; + wxRect& theBar = pTheBar->mBounds; - do - { - cbBarInfo* pBar = pTheBar; + do + { + cbBarInfo* pBar = pTheBar; - // calculate free spece on the left side + // calculate free spece on the left side - int leftFreeSpc = 0; + int leftFreeSpc = 0; - while( pBar ) - { - wxRect& cur = pBar->mBounds; + while( pBar ) + { + wxRect& cur = pBar->mBounds; - if ( pBar->mpPrev ) - { - wxRect& prev = pBar->mpPrev->mBounds; + if ( pBar->mpPrev ) + { + wxRect& prev = pBar->mpPrev->mBounds; - leftFreeSpc += cur.x - prev.x - prev.width; - } - else - leftFreeSpc += cur.x; + leftFreeSpc += cur.x - prev.x - prev.width; + } + else + leftFreeSpc += cur.x; - if ( cur.x < 0 ) - { - leftFreeSpc = 0; - break; - } + if ( cur.x < 0 ) + { + leftFreeSpc = 0; + break; + } - pBar = pBar->mpPrev; - } + pBar = pBar->mpPrev; + } - pBar = pTheBar; + pBar = pTheBar; - int rightOverflow = 0; + int rightOverflow = 0; - if ( pTheBar->IsFixed() ) + if ( pTheBar->IsFixed() ) - while( pBar ) - { - if ( !pBar->mpNext ) - { - wxRect& cur = pBar->mBounds; + while( pBar ) + { + if ( !pBar->mpNext ) + { + wxRect& cur = pBar->mBounds; - if ( cur.x + cur.width > mpPane->mPaneWidth ) + if ( cur.x + cur.width > mpPane->mPaneWidth ) - rightOverflow = cur.x + cur.width - mpPane->mPaneWidth; - } + rightOverflow = cur.x + cur.width - mpPane->mPaneWidth; + } - pBar = pBar->mpNext; - } + pBar = pBar->mpNext; + } - if ( rightOverflow > 0 ) - { - if ( leftFreeSpc <= 0 ) return; + if ( rightOverflow > 0 ) + { + if ( leftFreeSpc <= 0 ) return; - if ( pTheBar->mpNext ) - { - wxRect& next = pTheBar->mpNext->mBounds; + if ( pTheBar->mpNext ) + { + wxRect& next = pTheBar->mpNext->mBounds; - // if there's enough space on the left, move over one half-obscured - // bar from the right to the left side with respect to "theBar" + // if there's enough space on the left, move over one half-obscured + // bar from the right to the left side with respect to "theBar" - if ( next.width < leftFreeSpc ) - { - cbBarInfo* pNext = pTheBar->mpNext; + if ( next.width < leftFreeSpc ) + { + cbBarInfo* pNext = pTheBar->mpNext; - row.mBars.Remove( pNext ); + row.mBars.Remove( pNext ); - row.mBars.Insert( pNext, row.mBars.Index( pTheBar ) ); + row.mBars.Insert( pNext, row.mBars.Index( pTheBar ) ); - next.x = theBar.x - next.width; + next.x = theBar.x - next.width; - // re-setup mpPrev/mpNext references after insertion + // re-setup mpPrev/mpNext references after insertion - mpPane->InitLinksForRow( &row ); + mpPane->InitLinksForRow( &row ); - // tighten things + // tighten things - StickRightSideBars( pTheBar ); - SlideLeftSideBars ( pTheBar ); + StickRightSideBars( pTheBar ); + SlideLeftSideBars ( pTheBar ); - continue; - } - } + continue; + } + } - int leftShift = ( rightOverflow > leftFreeSpc ) - ? leftFreeSpc - : rightOverflow; + int leftShift = ( rightOverflow > leftFreeSpc ) + ? leftFreeSpc + : rightOverflow; - theBar.x -= leftShift; + theBar.x -= leftShift; - StickRightSideBars( pTheBar ); - SlideLeftSideBars ( pTheBar ); + StickRightSideBars( pTheBar ); + SlideLeftSideBars ( pTheBar ); - break; + break; - } // end of if ( rightOverflow ) - else - break; + } // end of if ( rightOverflow ) + else + break; - } while(1); + } while(1); } void cbRowLayoutPlugin::InsertBefore( cbBarInfo* pBeforeBar, - cbBarInfo* pTheBar, - cbRowInfo& row ) + cbBarInfo* pTheBar, + cbRowInfo& row ) { - if ( pBeforeBar ) + if ( pBeforeBar ) - row.mBars.Insert( pTheBar, row.mBars.Index( pBeforeBar ) ); - else - row.mBars.Add( pTheBar ); + row.mBars.Insert( pTheBar, row.mBars.Index( pBeforeBar ) ); + else + row.mBars.Add( pTheBar ); - pTheBar->mpRow = &row; + pTheBar->mpRow = &row; } void cbRowLayoutPlugin::DoInsertBar( cbBarInfo* pTheBar, cbRowInfo& row ) { - wxRect& theBar = pTheBar->mBounds; + wxRect& theBar = pTheBar->mBounds; - /* OLD STUFF:: - if ( theBar.x < 0 && !node_to_bar( pTheBar ).IsFixed() ) - { - // AI:: - theBar.width += theBar.x; - theBar.x = 0; - } */ + /* OLD STUFF:: + if ( theBar.x < 0 && !node_to_bar( pTheBar ).IsFixed() ) + { + // AI:: + theBar.width += theBar.x; + theBar.x = 0; + } */ size_t i; - for( i = 0; i != row.mBars.Count(); ++i ) - { - cbBarInfo& bar = *row.mBars[i]; - - wxRect& cur = bar.mBounds; - - // if bar hits the left edge - if ( theBar.x <= cur.x ) - { - InsertBefore( &bar, pTheBar, row ); - return; - } - - else - // if bar hits the right edge - if ( theBar.x <= cur.x + cur.width ) - { - if ( theBar.x + theBar.width > cur.x + cur.width ) - { - InsertBefore( bar.mpNext, pTheBar, row ); - return; - } - - // otherwise the bar lies within the bounds of current bar - - int leftDist = theBar.x - cur.x; - int rightDist = cur.x + cur.width - (theBar.x + theBar.width); - - if ( leftDist < rightDist ) - - InsertBefore( &bar, pTheBar, row ); - else - InsertBefore( bar.mpNext, pTheBar, row ); - - return; - } - } - - InsertBefore( NULL, pTheBar, row ); // insert at the end + for ( i = 0; i != row.mBars.Count(); ++i ) + { + cbBarInfo& bar = *row.mBars[i]; + + wxRect& cur = bar.mBounds; + + // if bar hits the left edge + if ( theBar.x <= cur.x ) + { + InsertBefore( &bar, pTheBar, row ); + return; + } + + else + // if bar hits the right edge + if ( theBar.x <= cur.x + cur.width ) + { + if ( theBar.x + theBar.width > cur.x + cur.width ) + { + InsertBefore( bar.mpNext, pTheBar, row ); + return; + } + + // otherwise the bar lies within the bounds of current bar + + int leftDist = theBar.x - cur.x; + int rightDist = cur.x + cur.width - (theBar.x + theBar.width); + + if ( leftDist < rightDist ) + + InsertBefore( &bar, pTheBar, row ); + else + InsertBefore( bar.mpNext, pTheBar, row ); + + return; + } + } + + InsertBefore( NULL, pTheBar, row ); // insert at the end } // evnet handlers void cbRowLayoutPlugin::OnInsertBar( cbInsertBarEvent& event ) { - cbBarInfo* pBarToInsert = event.mpBar; - cbRowInfo* pIntoRow = event.mpRow; - mpPane = event.mpPane; + cbBarInfo* pBarToInsert = event.mpBar; + cbRowInfo* pIntoRow = event.mpRow; + mpPane = event.mpPane; - if ( !pBarToInsert->IsFixed() ) + if ( !pBarToInsert->IsFixed() ) - AdjustLengthOfInserted( pIntoRow, pBarToInsert ); + AdjustLengthOfInserted( pIntoRow, pBarToInsert ); - DoInsertBar( pBarToInsert, *pIntoRow ); + DoInsertBar( pBarToInsert, *pIntoRow ); - mpPane->InitLinksForRow( pIntoRow ); // relink "mpNext/mpPrev"s + mpPane->InitLinksForRow( pIntoRow ); // relink "mpNext/mpPrev"s - // perform relayouting of the bars after insertion + // perform relayouting of the bars after insertion - // init bar location info - pBarToInsert->mAlignment = event.mpPane->mAlignment; - pBarToInsert->mRowNo = event.mpPane->GetRowIndex( pIntoRow ); + // init bar location info + pBarToInsert->mAlignment = event.mpPane->mAlignment; + pBarToInsert->mRowNo = event.mpPane->GetRowIndex( pIntoRow ); #ifdef __EXPERIMENTAL - if ( !pIntoRow->mHasOnlyFixedBars || !pBarToInsert->IsFixed() ) + if ( !pIntoRow->mHasOnlyFixedBars || !pBarToInsert->IsFixed() ) - RecalcLengthRatios( pIntoRow ); + RecalcLengthRatios( pIntoRow ); #endif - MinimzeNotFixedBars( pIntoRow, pBarToInsert ); + MinimzeNotFixedBars( pIntoRow, pBarToInsert ); - SlideLeftSideBars ( pBarToInsert ); - SlideRightSideBars( pBarToInsert ); + SlideLeftSideBars ( pBarToInsert ); + SlideRightSideBars( pBarToInsert ); - ShiftLeftTrashold ( pBarToInsert, *pIntoRow ); - ShiftRightTrashold( pBarToInsert, *pIntoRow ); + ShiftLeftTrashold ( pBarToInsert, *pIntoRow ); + ShiftRightTrashold( pBarToInsert, *pIntoRow ); - mpPane->SyncRowFlags( pIntoRow ); + mpPane->SyncRowFlags( pIntoRow ); - CheckIfAtTheBoundary( pBarToInsert, *pIntoRow ); + CheckIfAtTheBoundary( pBarToInsert, *pIntoRow ); - if ( event.mpPane->IsHorizontal() ) + if ( event.mpPane->IsHorizontal() ) - pBarToInsert->mState = wxCBAR_DOCKED_HORIZONTALLY; - else - pBarToInsert->mState = wxCBAR_DOCKED_VERTICALLY; + pBarToInsert->mState = wxCBAR_DOCKED_HORIZONTALLY; + else + pBarToInsert->mState = wxCBAR_DOCKED_VERTICALLY; - if ( !pIntoRow->mHasOnlyFixedBars ) - { + if ( !pIntoRow->mHasOnlyFixedBars ) + { #ifdef __EXPERIMENTAL - ExpandNotFixedBars( pIntoRow ); + ExpandNotFixedBars( pIntoRow ); #else - RelayoutNotFixedBarsAround( pBarToInsert, pIntoRow ); - RecalcLengthRatios( pIntoRow ); + RelayoutNotFixedBarsAround( pBarToInsert, pIntoRow ); + RecalcLengthRatios( pIntoRow ); #endif - DetectBarHandles( pIntoRow ); + DetectBarHandles( pIntoRow ); - // do proportional resizing of not-fixed bars - ApplyLengthRatios( pIntoRow ); - } + // do proportional resizing of not-fixed bars + ApplyLengthRatios( pIntoRow ); + } - // adjust the bar's docking state + // adjust the bar's docking state - // a little bit of AI: - // memorize bar's height and width, when docked in - // the current orientation - by making the current - // dimensions to be "preferred" ones for this docking state + // a little bit of AI: + // memorize bar's height and width, when docked in + // the current orientation - by making the current + // dimensions to be "preferred" ones for this docking state - if ( !pBarToInsert->IsFixed() ) - { - cbBarInfo& bar = *pBarToInsert; + if ( !pBarToInsert->IsFixed() ) + { + cbBarInfo& bar = *pBarToInsert; - bar.mDimInfo.mSizes[ bar.mState ].x = bar.mBounds.width; - bar.mDimInfo.mSizes[ bar.mState ].y = bar.mBounds.height; - } + bar.mDimInfo.mSizes[ bar.mState ].x = bar.mBounds.width; + bar.mDimInfo.mSizes[ bar.mState ].y = bar.mBounds.height; + } } void cbRowLayoutPlugin::OnRemoveBar ( cbRemoveBarEvent& event ) { - cbBarInfo* pBar = event.mpBar; - mpPane = event.mpPane; + cbBarInfo* pBar = event.mpBar; + mpPane = event.mpPane; - cbRowInfo* pRow = pBar->mpRow; + cbRowInfo* pRow = pBar->mpRow; - mpLayout->GetUpdatesManager().OnBarWillChange( pBar, pRow, event.mpPane ); + mpLayout->GetUpdatesManager().OnBarWillChange( pBar, pRow, event.mpPane ); - // invalidate the whole row - //pFirst->mpRowInfo->mMgrData.mPrevBounds.x = -1; + // invalidate the whole row + //pFirst->mpRowInfo->mMgrData.mPrevBounds.x = -1; - pRow->mBars.Remove( pBar ); + pRow->mBars.Remove( pBar ); - // rest bar information after removing it from the row - pBar->mpRow = NULL; - pBar->mHasLeftHandle = FALSE; - pBar->mHasRightHandle = FALSE; + // rest bar information after removing it from the row + pBar->mpRow = NULL; + pBar->mHasLeftHandle = FALSE; + pBar->mHasRightHandle = FALSE; - mpPane->InitLinksForRow( pRow ); // relink "mpNext/mpPrev"s + mpPane->InitLinksForRow( pRow ); // relink "mpNext/mpPrev"s - if ( pRow->mBars.Count() == 0 ) - { - // empty rows should not exist + if ( pRow->mBars.Count() == 0 ) + { + // empty rows should not exist - event.mpPane->GetRowList().Remove( pRow ); + event.mpPane->GetRowList().Remove( pRow ); - delete pRow; + delete pRow; - mpPane->InitLinksForRows(); - } - else - { - // force repainting of bars, in the row, from which the bar was removed + mpPane->InitLinksForRows(); + } + else + { + // force repainting of bars, in the row, from which the bar was removed - // FIXME:: really needed? - pRow->mBars[0]->mUMgrData.SetDirty(TRUE); + // FIXME:: really needed? + pRow->mBars[0]->mUMgrData.SetDirty(TRUE); - // re-setup mHasOnlyFixedBars flag for the row information - event.mpPane->SyncRowFlags( pRow ); + // re-setup mHasOnlyFixedBars flag for the row information + event.mpPane->SyncRowFlags( pRow ); - DetectBarHandles( pRow ); + DetectBarHandles( pRow ); - if ( !pRow->mHasOnlyFixedBars ) + if ( !pRow->mHasOnlyFixedBars ) - ExpandNotFixedBars( pRow ); - } + ExpandNotFixedBars( pRow ); + } } void cbRowLayoutPlugin::OnLayoutRow( cbLayoutRowEvent& event ) { - cbRowInfo* pRow = event.mpRow; - mpPane = event.mpPane; + cbRowInfo* pRow = event.mpRow; + mpPane = event.mpPane; - MinimzeNotFixedBars( pRow, NULL ); + MinimzeNotFixedBars( pRow, NULL ); - if ( !pRow->mHasOnlyFixedBars ) - { - // do proportional resizing of not-fixed bars - ApplyLengthRatios( pRow ); - } + if ( !pRow->mHasOnlyFixedBars ) + { + // do proportional resizing of not-fixed bars + ApplyLengthRatios( pRow ); + } - cbBarInfo& lastBar = *pRow->mBars[ pRow->mBars.Count() - 1 ]; - cbBarInfo& firstBar = *pRow->mBars[ 0 ]; + cbBarInfo& lastBar = *pRow->mBars[ pRow->mBars.Count() - 1 ]; + cbBarInfo& firstBar = *pRow->mBars[ 0 ]; - // FIXME:: Next line not used + // FIXME:: Next line not used // wxRect& bounds = lastBar.mBounds; - if ( lastBar.mBounds.x + lastBar.mBounds.width > mpPane->mPaneWidth ) - { - lastBar.mBounds.x = mpPane->mPaneWidth - lastBar.mBounds.width; + if ( lastBar.mBounds.x + lastBar.mBounds.width > mpPane->mPaneWidth ) + { + lastBar.mBounds.x = mpPane->mPaneWidth - lastBar.mBounds.width; - // first simulate left-row-edge friction + // first simulate left-row-edge friction - SlideLeftSideBars( &lastBar ); + SlideLeftSideBars( &lastBar ); - if ( firstBar.mBounds.x < 0 ) + if ( firstBar.mBounds.x < 0 ) firstBar.mBounds.x = 0; - // then left-row-edge function, though this - // may cause some of the right-side bars going - // out of row bounds, but left-side always - // has the highest "priority" + // then left-row-edge function, though this + // may cause some of the right-side bars going + // out of row bounds, but left-side always + // has the highest "priority" - SlideRightSideBars( &firstBar ); - } + SlideRightSideBars( &firstBar ); + } - event.Skip(); // pass event to the next handler + event.Skip(); // pass event to the next handler } void cbRowLayoutPlugin::OnLayoutRows( cbLayoutRowsEvent& event ) { - mpPane = event.mpPane; + mpPane = event.mpPane; - int curY = 0; + int curY = 0; // FIXME:: Next line not used. - // RowArrayT& arr = mpPane->GetRowList(); + // RowArrayT& arr = mpPane->GetRowList(); size_t i; - for( i = 0; i != mpPane->GetRowList().Count(); ++i ) - { - cbRowInfo& row = *mpPane->GetRowList()[ i ]; - - // setup "has-handle" flags for rows, which depend on the existance - // of not-fixed bars in the row - - if ( !row.mHasOnlyFixedBars ) - { - if ( mpPane->mAlignment == FL_ALIGN_TOP || - mpPane->mAlignment == FL_ALIGN_LEFT ) - { - row.mHasLowerHandle = TRUE; - - row.mHasUpperHandle = FALSE; - } - else - { - row.mHasUpperHandle = TRUE; - - row.mHasLowerHandle = FALSE; - } - } - else - { - // otherwise, rows with fixed-bars only, have no height-resizing handles - row.mHasUpperHandle = FALSE; - row.mHasLowerHandle = FALSE; - } - - // setup vertical positions for items in the row - - row.mRowY = curY; - - row.mRowWidth = mpPane->mPaneWidth; - row.mRowHeight = CalcRowHeight( row ); - - LayoutItemsVertically( row ); - - if ( row.mHasUpperHandle ) + for ( i = 0; i != mpPane->GetRowList().Count(); ++i ) + { + cbRowInfo& row = *mpPane->GetRowList()[ i ]; + + // setup "has-handle" flags for rows, which depend on the existance + // of not-fixed bars in the row + + if ( !row.mHasOnlyFixedBars ) + { + if ( mpPane->mAlignment == FL_ALIGN_TOP || + mpPane->mAlignment == FL_ALIGN_LEFT ) + { + row.mHasLowerHandle = TRUE; + + row.mHasUpperHandle = FALSE; + } + else + { + row.mHasUpperHandle = TRUE; + + row.mHasLowerHandle = FALSE; + } + } + else + { + // otherwise, rows with fixed-bars only, have no height-resizing handles + row.mHasUpperHandle = FALSE; + row.mHasLowerHandle = FALSE; + } + + // setup vertical positions for items in the row + + row.mRowY = curY; + + row.mRowWidth = mpPane->mPaneWidth; + row.mRowHeight = CalcRowHeight( row ); + + LayoutItemsVertically( row ); + + if ( row.mHasUpperHandle ) row.mRowHeight += mpPane->mProps.mResizeHandleSize; - if ( row.mHasLowerHandle ) + if ( row.mHasLowerHandle ) row.mRowHeight += mpPane->mProps.mResizeHandleSize; - curY += row.mRowHeight; - } + curY += row.mRowHeight; + } - event.Skip(); // pass event to the next handler - other hookeds plugin - // may also add some "refinements" to the layout now + event.Skip(); // pass event to the next handler - other hookeds plugin + // may also add some "refinements" to the layout now } void cbRowLayoutPlugin::OnResizeRow( cbResizeRowEvent& event ) { - // extract resize-event info - int ofs = event.mHandleOfs; - bool forUpperHandle = event.mForUpperHandle; - cbRowInfo* pTheRow = event.mpRow; - mpPane = event.mpPane; + // extract resize-event info + int ofs = event.mHandleOfs; + bool forUpperHandle = event.mForUpperHandle; + cbRowInfo* pTheRow = event.mpRow; + mpPane = event.mpPane; // FIXME:: Next line not used. - //int newHeight = pTheRow->mRowHeight; + //int newHeight = pTheRow->mRowHeight; - int freeSpc = 0; + int freeSpc = 0; - if ( forUpperHandle ) - { - // calculate available free space from above, - // which can be obtained by squeezing not-fixed height rows + if ( forUpperHandle ) + { + // calculate available free space from above, + // which can be obtained by squeezing not-fixed height rows - cbRowInfo* pRow = pTheRow->mpPrev; + cbRowInfo* pRow = pTheRow->mpPrev; - while( pRow ) - { - freeSpc += pRow->mRowHeight - event.mpPane->GetMinimalRowHeight( pRow ); + while( pRow ) + { + freeSpc += pRow->mRowHeight - event.mpPane->GetMinimalRowHeight( pRow ); - pRow = pRow->mpPrev; - } - } - else - { - // calculate available free space from below, - // which can be obtained by squeezing not-fixed height rows + pRow = pRow->mpPrev; + } + } + else + { + // calculate available free space from below, + // which can be obtained by squeezing not-fixed height rows - cbRowInfo* pRow = pTheRow->mpNext; + cbRowInfo* pRow = pTheRow->mpNext; - while( pRow ) - { - freeSpc += pRow->mRowHeight - mpPane->GetMinimalRowHeight( pRow ); + while( pRow ) + { + freeSpc += pRow->mRowHeight - mpPane->GetMinimalRowHeight( pRow ); - pRow = pRow->mpNext; - } - } + pRow = pRow->mpNext; + } + } - mpLayout->GetUpdatesManager().OnStartChanges(); + mpLayout->GetUpdatesManager().OnStartChanges(); - int clientSize; + int clientSize; - // allow user adjusting pane vs. client-area space, for upper-handle + // allow user adjusting pane vs. client-area space, for upper-handle - if ( mpPane->IsHorizontal() ) + if ( mpPane->IsHorizontal() ) - clientSize = mpLayout->GetClientHeight(); - else - clientSize = mpLayout->GetClientWidth(); + clientSize = mpLayout->GetClientHeight(); + else + clientSize = mpLayout->GetClientWidth(); - if ( forUpperHandle && ofs < -clientSize ) - { - int needed = -(ofs + clientSize); + if ( forUpperHandle && ofs < -clientSize ) + { + int needed = -(ofs + clientSize); - cbRowInfo* pRow = mpPane->GetRowList()[ 0 ]; + cbRowInfo* pRow = mpPane->GetRowList()[ 0 ]; - // start squeezing rows from the top row towards bottom + // start squeezing rows from the top row towards bottom - while( pRow != pTheRow && needed ) - { - // only not-fixed rows can be squeezed + while( pRow != pTheRow && needed ) + { + // only not-fixed rows can be squeezed - if ( !pRow->mHasOnlyFixedBars ) - { - int prevHeight = pRow->mRowHeight; + if ( !pRow->mHasOnlyFixedBars ) + { + int prevHeight = pRow->mRowHeight; - int newHeight = wxMax( event.mpPane->GetMinimalRowHeight( pRow ), - prevHeight - needed ); + int newHeight = wxMax( event.mpPane->GetMinimalRowHeight( pRow ), + prevHeight - needed ); - if ( newHeight != prevHeight ) - { - event.mpPane->SetRowHeight( pRow, newHeight ); + if ( newHeight != prevHeight ) + { + event.mpPane->SetRowHeight( pRow, newHeight ); - needed -= prevHeight - pRow->mRowHeight; - } - } + needed -= prevHeight - pRow->mRowHeight; + } + } - pRow = pRow->mpNext; - } - } + pRow = pRow->mpNext; + } + } - // allow user adjusting pane vs. client-area space, for lower-handle + // allow user adjusting pane vs. client-area space, for lower-handle - if ( !forUpperHandle && ofs > clientSize ) - { - int needed = ofs - clientSize; + if ( !forUpperHandle && ofs > clientSize ) + { + int needed = ofs - clientSize; - cbRowInfo* pRow = mpPane->GetRowList()[ mpPane->GetRowList().Count() - 1 ]; + cbRowInfo* pRow = mpPane->GetRowList()[ mpPane->GetRowList().Count() - 1 ]; - // start squeezing rows from the bottom towards the top row + // start squeezing rows from the bottom towards the top row - while( pRow && needed ) - { - // only not-fixed rows can be squeezed + while( pRow && needed ) + { + // only not-fixed rows can be squeezed - if ( !pRow->mHasOnlyFixedBars ) - { - int prevHeight = pRow->mRowHeight; + if ( !pRow->mHasOnlyFixedBars ) + { + int prevHeight = pRow->mRowHeight; - int newHeight = wxMax( event.mpPane->GetMinimalRowHeight( pRow ), - prevHeight - needed ); + int newHeight = wxMax( event.mpPane->GetMinimalRowHeight( pRow ), + prevHeight - needed ); - if ( newHeight != prevHeight ) - { - event.mpPane->SetRowHeight( pRow, newHeight ); + if ( newHeight != prevHeight ) + { + event.mpPane->SetRowHeight( pRow, newHeight ); - needed -= prevHeight - pRow->mRowHeight; - } - } + needed -= prevHeight - pRow->mRowHeight; + } + } - pRow = pRow->mpPrev; - } - } + pRow = pRow->mpPrev; + } + } - if ( forUpperHandle ) - - event.mpPane->SetRowHeight( pTheRow, pTheRow->mRowHeight + (-ofs) ); - else - event.mpPane->SetRowHeight( pTheRow, pTheRow->mRowHeight + ofs ); + if ( forUpperHandle ) + + event.mpPane->SetRowHeight( pTheRow, pTheRow->mRowHeight + (-ofs) ); + else + event.mpPane->SetRowHeight( pTheRow, pTheRow->mRowHeight + ofs ); - mpLayout->RecalcLayout(FALSE); + mpLayout->RecalcLayout(FALSE); - mpLayout->GetUpdatesManager().OnFinishChanges(); - mpLayout->GetUpdatesManager().UpdateNow(); + mpLayout->GetUpdatesManager().OnFinishChanges(); + mpLayout->GetUpdatesManager().UpdateNow(); } diff --git a/contrib/src/fl/updatesmgr.cpp b/contrib/src/fl/updatesmgr.cpp index c742670ca7..426144840b 100644 --- a/contrib/src/fl/updatesmgr.cpp +++ b/contrib/src/fl/updatesmgr.cpp @@ -289,3 +289,4 @@ void cbSimpleUpdatesMgr::UpdateNow() } } + -- 2.45.2