⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 panedrawpl.cpp

📁 wxGTK 是 wxWidgets 的 linux GTK+ (>2.2.3)版本。wxWidgets 是一个跨平台的 GUI 框架
💻 CPP
📖 第 1 页 / 共 3 页
字号:
            if ( mIsUpperHandle )                mHandleOfs = mpResizedRow->mRowY;            else                mHandleOfs = mpResizedRow->mRowY +                              mpResizedRow->mRowHeight -                             event.mpPane->mProps.mResizeHandleSize;        }        else        {            // otehrwise if bar handle dragged//            cbRowInfo& rowInfo     = *mpDraggedBar->mpRow;            wxRect& bounds         = mpDraggedBar->mBounds;            mHandleIsVertical = ( event.mpPane->IsHorizontal() ) ? true : false;            mHandleDragArea.x      = from;            mHandleDragArea.width  = till - from;            mHandleDragArea.y      = bounds.y;            mHandleDragArea.height = bounds.height;            // left-side-handle mBounds            if ( mIsLeftHandle )                mHandleOfs = bounds.x;            else                mHandleOfs = bounds.x +                              bounds.width - event.mpPane->mProps.mResizeHandleSize;        }        event.mpPane->PaneToFrame( &mHandleDragArea );        DrawDraggedHandle(mDragOrigin, *event.mpPane);        mPrevPos = mDragOrigin;        return;        // handled is dragged, thus event is "eaten" by this plugin    }    else    {        cbBarInfo* pDraggedBar;        if ( event.mpPane->HitTestPaneItems( event.mPos,       // in pane's coordiantes                                             &mpResizedRow,                                             &pDraggedBar ) == CB_BAR_CONTENT_HITTED            )        {            int x = event.mPos.x,                y = event.mPos.y;            event.mpPane->PaneToFrame( &x, &y );            cbStartBarDraggingEvent dragEvt( pDraggedBar, wxPoint(x,y), event.mpPane );            mpLayout->FirePluginEvent( dragEvt );            return; // event is "eaten" by this plugin        }    }    event.Skip(); // pass event to the next plugin in the chain}void cbPaneDrawPlugin::OnLButtonUp( cbLeftUpEvent& event ) {    if ( mResizeStarted )    {        DrawDraggedHandle( event.mPos, *event.mpPane );        mResizeStarted  = false;        mResizeCursorOn = false;        mpLayout->ReleaseEventsFromPane( event.mpPane );        mpLayout->ReleaseEventsFromPlugin( this );        // In Windows, at least, the frame needs to have a null cursor        // else child windows (such as text windows) inherit the cursor#if 1        mpLayout->GetParentFrame().SetCursor( wxNullCursor );#else        mpLayout->GetParentFrame().SetCursor( *mpLayout->mpNormalCursor );#endif        if ( mRowHandleHitted )        {            event.mpPane->ResizeRow( mpResizedRow,                                      mDraggedDelta,                                     mIsUpperHandle );        }        else        {            event.mpPane->ResizeBar( mpDraggedBar,                                      mDraggedDelta,                                     mIsLeftHandle );        }        mpDraggedBar = NULL;        mpResizedRow = NULL;        // handled dragging action was finished by this mouse-up,         // thus event is "eaten" by this plugin        return;    }    event.Skip(); // pass event to the next plugin}void cbPaneDrawPlugin::OnRButtonUp( cbRightUpEvent&   event ){    wxPoint fpos = event.mPos;    event.mpPane->PaneToFrame( &fpos.x, &fpos.y );    cbBarInfo* pDraggedBar;    // user clicks inside the bar contnet, fire bar-customization event    if ( event.mpPane->HitTestPaneItems( event.mPos,       // in pane's coordiantes                                         &mpResizedRow,                                         &pDraggedBar  ) == CB_BAR_CONTENT_HITTED       )    {        cbCustomizeBarEvent cbEvt( pDraggedBar, fpos, event.mpPane );        mpLayout->FirePluginEvent( cbEvt );        return; // event is "eaten" by this plugin    }    // otherwise fire whole-layout customization event    cbCustomizeLayoutEvent csEvt( fpos );    mpLayout->FirePluginEvent( csEvt );    // event is "eaten" by this plugin}void cbPaneDrawPlugin::OnSizeBarWindow( cbSizeBarWndEvent& event ) {    cbBarInfo& bar = *event.mpBar;    mpPane         = event.mpPane;    // it's possible that a bar does not have it's own window!    if ( !bar.mpBarWnd ) return;    wxRect& bounds = event.mBoundsInParent;    // check visibility    if ( bounds.height != 0 )    {        // size smaller than bounds, to leave space for shade lines        // FIXME:: +/- 1s        int nNewHeight = bounds.height - 2 - bar.mDimInfo.mVertGap *2;        if(nNewHeight < 0)           nNewHeight = 0;        bar.mpBarWnd->wxWindow::SetSize( bounds.x      + 1 + bar.mDimInfo.mHorizGap,                                              bounds.y      + 1 + bar.mDimInfo.mVertGap,                                         bounds.width  - 2 - bar.mDimInfo.mHorizGap*2,                                         nNewHeight,                                         0                                        );        if ( !bar.mpBarWnd->IsShown() )            bar.mpBarWnd->Show( true );    }    else        // hide bar if not visible        bar.mpBarWnd->Show( false );    event.Skip(); // pass event to the next plugin in the chain}void cbPaneDrawPlugin::OnDrawRowDecorations( cbDrawRowDecorEvent& event ){    DrawPaneShadeForRow( event.mpRow, *event.mpDc );    event.Skip(); // pass event to the next plugin}void cbPaneDrawPlugin::DrawUpperRowHandle( cbRowInfo* pRow, wxDC& dc ){    wxRect& bounds = pRow->mBoundsInParent;    if ( mpPane->IsHorizontal() )    {         if ( pRow->mHasUpperHandle )                    mpPane->DrawHorizHandle( dc, bounds.x,                                      bounds.y-1,                                       pRow->mRowWidth );    }    else    {        if ( pRow->mHasUpperHandle )            mpPane->DrawVertHandle( dc, bounds.x-1,                                     bounds.y, pRow->mRowWidth );    }}void cbPaneDrawPlugin::DrawLowerRowHandle( cbRowInfo* pRow, wxDC& dc ){    wxRect& bounds = pRow->mBoundsInParent;    // check if iter-row handles present    if ( mpPane->IsHorizontal() )    {        if ( pRow->mHasLowerHandle )                    mpPane->DrawHorizHandle( dc, bounds.x, bounds.y + bounds.height - mpPane->mProps.mResizeHandleSize - 1,                                       pRow->mRowWidth );    }    else    {        if ( pRow->mHasLowerHandle )            mpPane->DrawVertHandle( dc, bounds.x + bounds.width - mpPane->mProps.mResizeHandleSize - 1,                                      bounds.y, pRow->mRowWidth );    }}void cbPaneDrawPlugin::OnDrawRowHandles( cbDrawRowHandlesEvent& event ){    // short-cuts    cbRowInfo* pRow = event.mpRow;    wxDC&   dc      = *event.mpDc;    mpPane          = event.mpPane;    // draw handles of surrounding rows first    if ( pRow->mpPrev && pRow->mpPrev->mHasLowerHandle )            DrawLowerRowHandle( pRow->mpPrev, dc );    if ( pRow->mpNext && pRow->mpNext->mHasUpperHandle )        DrawUpperRowHandle( pRow->mpNext, dc );    // draw handles of the given row    if ( pRow->mHasUpperHandle )            DrawUpperRowHandle( pRow, dc );    if ( pRow->mHasLowerHandle )        DrawLowerRowHandle( pRow, dc );    event.Skip(); // pass event to the next plugin}void cbPaneDrawPlugin::OnDrawPaneBackground ( cbDrawPaneBkGroundEvent& event ){    wxDC& dc = *event.mpDc;    mpPane   = event.mpPane;    // FOR NOW:: hard-coded    wxBrush bkBrush( mpLayout->mBorderPen.GetColour(), wxSOLID );    dc.SetBrush( bkBrush );    dc.SetPen( mpLayout->mNullPen );    wxRect& bounds = mpPane->mBoundsInParent;    if ( mpPane->mTopMargin >= 1 )            dc.DrawRectangle( bounds.x, bounds.y,                          bounds.width+1,                          mpPane->mTopMargin + 1);    if ( mpPane->mBottomMargin >= 1 )            dc.DrawRectangle( bounds.x,                           bounds.y + bounds.height - mpPane->mBottomMargin,                          bounds.width + 1,                          mpPane->mBottomMargin + 1);    if ( mpPane->mLeftMargin >= 1 )            dc.DrawRectangle( bounds.x,                           bounds.y + mpPane->mTopMargin - 1,                          mpPane->mLeftMargin + 1,                          bounds.height - mpPane->mTopMargin - mpPane->mBottomMargin + 2);    if ( mpPane->mRightMargin >= 1 )            dc.DrawRectangle( bounds.x + bounds.width - mpPane->mRightMargin,                          bounds.y + mpPane->mTopMargin - 1,                          mpPane->mRightMargin + 1,                          bounds.height - mpPane->mTopMargin - mpPane->mBottomMargin + 2);    event.Skip(); // pass event to the next plugin}void cbPaneDrawPlugin::OnDrawRowBackground ( cbDrawRowBkGroundEvent& event ){    // short-cuts    cbRowInfo* pRow = event.mpRow;    wxDC&   dc      = *event.mpDc;    mpPane          = event.mpPane;    // get ready    wxRect     rowBounds    = pRow->mBoundsInParent;    bool       isHorizontal    = event.mpPane->IsHorizontal();    //    int prevPos;    if ( isHorizontal )    {//        prevPos = rowBounds.x;        // include one line above and below the row        --rowBounds.y;        rowBounds.height += 2;        --rowBounds.x;        rowBounds.width  += 2;    }    else    {//        prevPos = rowBounds.y;        // include one line above and below the row        --rowBounds.x;        rowBounds.width  += 2;        --rowBounds.y;        rowBounds.height += 2;    }//#define TEST_BK_ERASING#ifdef TEST_BK_ERASING    // DBG::    wxBrush br0( wxColour(0,160,160), wxSOLID );    dc.SetBrush(br0);    dc.SetPen  ( mpLayout->mNullPen );    dc.DrawRectangle( rowBounds.x, rowBounds.y,                      rowBounds.width  + 1,                       rowBounds.height + 1  );#endif    wxBrush bkBrush( mpLayout->mGrayPen.GetColour(), wxSOLID );    dc.SetPen  ( mpLayout->mNullPen );    dc.SetBrush( bkBrush );    // fill background-recatangle of entire row area    dc.DrawRectangle( rowBounds.x, rowBounds.y,                      rowBounds.width  + 1,                       rowBounds.height + 1  );    dc.SetBrush( wxNullBrush );    // draw "shaded-side-bars" for each bar    for( size_t i = 0; i != pRow->mBars.Count(); ++i )    {        wxRect& bounds = pRow->mBars[i]->mBoundsInParent;        if ( isHorizontal )        {            DrawShade( 1, bounds, FL_ALIGN_LEFT, dc );            DrawShade( 1, bounds, FL_ALIGN_RIGHT, dc );        }        else        {            DrawShade( 1, bounds, FL_ALIGN_TOP, dc );            DrawShade( 1, bounds, FL_ALIGN_BOTTOM, dc );        }    }    // draw extra shades to simulate "glued-bricks" effect    // TBD:: reduce exessive drawing of shades, when the    //       row handle is present, and shades will be overr-drawn anyway    DrawUpperRowShades( pRow, dc, 1 ); // outer shade    if ( pRow->mpPrev )    {        DrawLowerRowShades( pRow->mpPrev, dc, 1 ); // outter shade        DrawLowerRowShades( pRow->mpPrev, dc, 0 ); // inner shade    }    DrawLowerRowShades( pRow, dc, 1 );    if ( pRow->mpNext )    {        DrawUpperRowShades( pRow->mpNext, dc, 1 );         DrawUpperRowShades( pRow->mpNext, dc, 0 );    }    event.Skip(); // pass event to the next plugin}void cbPaneDrawPlugin::DrawUpperRowShades( cbRowInfo* pRow, wxDC& dc, int level ){    for( size_t i = 0; i != pRow->mBars.Count(); ++i )    {        wxRect& bounds = pRow->mBars[i]->mBoundsInParent;        if ( mpPane->IsHorizontal() )        {                    DrawShade( level, bounds, FL_ALIGN_TOP, dc );            if ( level == 1 )            {                dc.SetPen( mpLayout->mDarkPen );                dc.DrawPoint( bounds.x - 1, bounds.y );                dc.SetPen( mpLayout->mLightPen );                dc.DrawPoint( bounds.x + bounds.width , bounds.y );            }        }        else        {            DrawShade( level, bounds, FL_ALIGN_LEFT, dc );            if ( level == 1 )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -