📄 rowdragpl.cpp
字号:
{ int xOfs = (inRect.width - ICON_TRIAN_WIDTH)/2; wxBrush br( mTrianInnerColor, wxSOLID ); dc.SetBrush( br ); dc.SetPen( mpLayout->mBlackPen ); wxPoint points[3]; points[0].x = inRect.x + xOfs; points[0].y = inRect.y; points[1].x = inRect.x + xOfs + ICON_TRIAN_WIDTH; points[1].y = inRect.y; points[2].x = inRect.x + xOfs + ICON_TRIAN_WIDTH/2; points[2].y = inRect.y + ICON_TRIAN_HEIGHT; dc.DrawPolygon( 3, points ); // higlight upper-right edge of triangle dc.SetPen( mpLayout->mLightPen ); dc.DrawLine( points[2].x, points[2].y, points[1].x, points[1].y ); dc.SetBrush( wxNullBrush );}void cbRowDragPlugin::DrawTrianRight( wxRect& inRect, wxDC& dc ){ int yOfs = (inRect.height - ICON_TRIAN_WIDTH)/2; wxBrush br( mTrianInnerColor, wxSOLID ); dc.SetBrush( br ); dc.SetPen( mpLayout->mBlackPen ); wxPoint points[3]; points[0].x = inRect.x; points[0].y = inRect.y + yOfs + ICON_TRIAN_WIDTH; points[1].x = inRect.x; points[1].y = inRect.y + yOfs; points[2].x = inRect.x + ICON_TRIAN_HEIGHT; points[2].y = inRect.y + yOfs + ICON_TRIAN_WIDTH/2; dc.DrawPolygon( 3, points ); // higlight upper-right edge of triangle dc.SetPen( mpLayout->mLightPen ); dc.DrawLine( points[0].x, points[0].y, points[2].x, points[2].y ); dc.SetBrush( wxNullBrush );}void cbRowDragPlugin::Draw3DPattern( wxRect& inRect, wxDC& dc ){ for( int y = inRect.y; y < inRect.y + inRect.height; y+=3 ) for( int x = inRect.x; x < inRect.x + inRect.width; x+=3 ) { dc.SetPen( mpLayout->mLightPen ); dc.DrawPoint( x,y ); dc.SetPen( mpLayout->mBlackPen ); dc.DrawPoint( x+1, y+1 ); }}void cbRowDragPlugin::DrawRombShades( wxPoint& p1, wxPoint& p2, wxPoint& p3, wxPoint& p4, wxDC& dc ){ dc.SetPen( mpLayout->mLightPen ); dc.DrawLine( p1.x, p1.y, p2.x, p2.y ); dc.DrawLine( p2.x, p2.y, p3.x, p3.y ); dc.SetPen( mpLayout->mDarkPen ); dc.DrawLine( p3.x, p3.y, p4.x, p4.y ); dc.DrawLine( p4.x, p4.y, p1.x, p1.y );}void cbRowDragPlugin::DrawOrtoRomb( wxRect& inRect, wxDC& dc, const wxBrush& bkBrush ){ dc.SetBrush( bkBrush ); dc.SetPen( mpLayout->mBlackPen ); wxPoint points[4]; if ( inRect.width > inRect.height ) { // horizontal orienation points[0].x = inRect.x; points[0].y = inRect.y + inRect.height; points[1].x = inRect.x; points[1].y = inRect.y; points[2].x = inRect.x + inRect.width; points[2].y = inRect.y; points[3].x = inRect.x + inRect.width - COLLAPSED_ICON_HEIGHT; points[3].y = inRect.y + inRect.height; dc.DrawPolygon( 4, points ); // squeeze romb's bounds to create an inner-shade shape ++points[0].x; --points[0].y; ++points[1].x; ++points[1].y; --points[2].x; --points[2].x; ++points[2].y; --points[3].y; DrawRombShades( points[0], points[1], points[2], points[3], dc ); } else { // vertical orientation points[0].x = inRect.x + inRect.width; points[0].y = inRect.y + inRect.height; points[1].x = inRect.x; points[1].y = inRect.y + inRect.height; points[2].x = inRect.x; points[2].y = inRect.y; points[3].x = inRect.x + inRect.width; points[3].y = inRect.y + COLLAPSED_ICON_HEIGHT; dc.DrawPolygon( 4, points ); // squeeze romb's bounds to create an inner-shade shape --points[0].y ; --points[0].x; ++points[1].x; --points[1].y; ++points[2].y; ++points[2].y; ++points[2].x; --points[3].x; DrawRombShades( points[1], points[2], points[3], points[0], dc ); } dc.SetBrush( wxNullBrush );}void cbRowDragPlugin::DrawRomb( wxRect& inRect, wxDC& dc, const wxBrush& bkBrush ){ wxPoint points[4]; dc.SetBrush( bkBrush ); dc.SetPen( mpLayout->mBlackPen ); if ( inRect.width > inRect.height ) { // horizontal orientation points[0].x = inRect.x; points[0].y = inRect.y + inRect.height; points[1].x = inRect.x + COLLAPSED_ICON_HEIGHT; points[1].y = inRect.y; points[2].x = inRect.x + inRect.width; points[2].y = inRect.y; points[3].x = inRect.x + inRect.width - COLLAPSED_ICON_HEIGHT; points[3].y = inRect.y + inRect.height; dc.DrawPolygon( 4, points ); // squeeze romb's bounds to create an inner-shade shape ++points[0].x ;++points[0].x ; --points[0].y; ++points[1].y; --points[2].x; --points[2].x; ++points[2].y; //--points[3].x ; --points[3].y; DrawRombShades( points[0], points[1], points[2], points[3], dc ); } else { // vertical orientation points[0].x = inRect.x + inRect.width; points[0].y = inRect.y + inRect.height; points[1].x = inRect.x; points[1].y = inRect.y + inRect.height - COLLAPSED_ICON_HEIGHT; points[2].x = inRect.x; points[2].y = inRect.y; points[3].x = inRect.x + inRect.width; points[3].y = inRect.y + COLLAPSED_ICON_HEIGHT; dc.DrawPolygon( 4, points ); // squeeze romb's bounds to create an inner-shade shape --points[0].y ;--points[0].y ; --points[0].x; ++points[1].x; ++points[2].y; ++points[2].y; ++points[2].x; --points[3].x; DrawRombShades( points[1], points[2], points[3], points[0], dc ); } dc.SetBrush( wxNullBrush );}void cbRowDragPlugin::DrawRectShade( wxRect& inRect, wxDC& dc, int level, const wxPen& upperPen, const wxPen& lowerPen ){ // upper shade dc.SetPen( upperPen ); dc.DrawLine( inRect.x - level, inRect.y - level, inRect.x + inRect.width - 1 + level, inRect.y - level); dc.DrawLine( inRect.x - level, inRect.y - level, inRect.x - level, inRect.y + inRect.height - 1 + level ); // lower shade dc.SetPen( lowerPen ); dc.DrawLine( inRect.x - level, inRect.y + inRect.height - 1 + level, inRect.x + inRect.width + level, inRect.y + inRect.height - 1 + level); dc.DrawLine( inRect.x + inRect.width - 1 + level, inRect.y - level, inRect.x + inRect.width - 1 + level, inRect.y + inRect.height + level); dc.SetBrush( wxNullBrush );}void cbRowDragPlugin::Draw3DRect( wxRect& inRect, wxDC& dc, const wxBrush& bkBrush ){ dc.SetPen( mpLayout->mNullPen ); dc.SetBrush( bkBrush ); dc.DrawRectangle( inRect.x, inRect.y, inRect.width, inRect.height ); DrawRectShade( inRect, dc, 0, mpLayout->mLightPen, mpLayout->mDarkPen );}int cbRowDragPlugin::GetCollapsedIconsPos(){ RowArrayT& rows = mpPane->GetRowList(); if ( rows.GetCount() == 0 ) { if ( mpPane->IsHorizontal() ) return mpPane->mBoundsInParent.y + mpPane->mTopMargin; else return mpPane->mBoundsInParent.x + mpPane->mLeftMargin; } wxRect& bounds = rows[ rows.GetCount() - 1 ]->mBoundsInParent; if ( mpPane->IsHorizontal() ) return bounds.y + bounds.height + 1; else return bounds.x + bounds.width + 1;}void cbRowDragPlugin::GetRowHintRect( cbRowInfo* pRow, wxRect& rect ){ wxRect& bounds = pRow->mBoundsInParent; if ( mpPane->IsHorizontal() ) { rect.x = bounds.x - ROW_DRAG_HINT_WIDTH - 1; rect.y = bounds.y; rect.width = ROW_DRAG_HINT_WIDTH; rect.height = bounds.height; } else { rect.x = bounds.x; rect.y = bounds.y + bounds.height + 1; rect.width = bounds.width; rect.height = ROW_DRAG_HINT_WIDTH; }}void cbRowDragPlugin::GetCollapsedInconRect( int iconIdx, wxRect& rect ){ int upper = GetCollapsedIconsPos(); int right = (iconIdx == 0 ) ? 0 : iconIdx * (COLLAPSED_ICON_WIDTH - COLLAPSED_ICON_HEIGHT); if ( mpPane->IsHorizontal() ) { rect.x = mpPane->mBoundsInParent.x + mpPane->mLeftMargin - ROW_DRAG_HINT_WIDTH - 1 + right; rect.y = upper; rect.width = COLLAPSED_ICON_WIDTH; rect.height = COLLAPSED_ICON_HEIGHT; } else { rect.x = upper; rect.y = mpPane->mBoundsInParent.y + mpPane->mBoundsInParent.height - mpPane->mBottomMargin + ROW_DRAG_HINT_WIDTH + 1 - right - COLLAPSED_ICON_WIDTH; rect.height = COLLAPSED_ICON_WIDTH; rect.width = COLLAPSED_ICON_HEIGHT; }}/*** overridables ***/void cbRowDragPlugin::DrawCollapsedRowIcon( int index, wxDC& dc, bool isHighlighted ){ wxRect rect; GetCollapsedInconRect( index, rect ); wxBrush hiBrush ( mHightColor, wxSOLID ); wxBrush lowBrush( mLowColor, wxSOLID ); wxBrush& curBrush = ( isHighlighted ) ? hiBrush : lowBrush; if ( mpPane->IsHorizontal() ) { if ( index == 0 ) DrawOrtoRomb( rect, dc, curBrush ); else DrawRomb( rect, dc, curBrush ); int triOfs = (index == 0) ? TRIANGLE_OFFSET : TRIANGLE_OFFSET + COLLAPSED_ICON_HEIGHT; wxRect triRect; triRect.x = triOfs + rect.x; triRect.width = ICON_TRIAN_HEIGHT; triRect.y = rect.y; triRect.height = rect.height; DrawTrianRight( triRect, dc ); wxRect patRect; patRect.x = triOfs + ICON_TRIAN_HEIGHT + TRIANGLE_TO_PAT_GAP + rect.x; patRect.y = rect.y + PAT_OFFSET; patRect.width = rect.width - (patRect.x - rect.x) - COLLAPSED_ICON_HEIGHT - PAT_OFFSET; patRect.height = rect.height - PAT_OFFSET*2; Draw3DPattern( patRect, dc ); } else { if ( index == 0 ) DrawOrtoRomb( rect, dc, curBrush ); else DrawRomb( rect, dc, curBrush ); int triOfs = (index == 0) ? TRIANGLE_OFFSET + ICON_TRIAN_HEIGHT : TRIANGLE_OFFSET + COLLAPSED_ICON_HEIGHT + ICON_TRIAN_HEIGHT; wxRect triRect; triRect.y = rect.y + rect.height - triOfs; triRect.x = rect.x; triRect.width = rect.width; triRect.height = ICON_TRIAN_HEIGHT; DrawTrianUp( triRect, dc ); wxRect patRect; patRect.y = rect.y + COLLAPSED_ICON_HEIGHT + PAT_OFFSET; patRect.x = rect.x + PAT_OFFSET; patRect.width = rect.width - 2*PAT_OFFSET ; patRect.height = rect.height - triOfs - 2*PAT_OFFSET - COLLAPSED_ICON_HEIGHT; Draw3DPattern( patRect, dc ); }}void cbRowDragPlugin::DrawRowDragHint( cbRowInfo* pRow , wxDC& dc, bool isHighlighted ){ wxRect rect; GetRowHintRect( pRow, rect ); wxBrush hiBrush ( mHightColor, wxSOLID ); wxBrush lowBrush( mLowColor, wxSOLID ); wxBrush& curBrush = ( isHighlighted ) ? hiBrush : lowBrush; Draw3DRect( rect, dc, curBrush ); if ( mpPane->IsHorizontal() ) { wxRect triRect; triRect.y = rect.y + TRIANGLE_OFFSET; triRect.x = rect.x; triRect.width = rect.width; triRect.height = ICON_TRIAN_HEIGHT; DrawTrianDown( triRect, dc ); wxRect patRect; patRect.x = rect.x + PAT_OFFSET; patRect.y = rect.y + TRIANGLE_OFFSET + ICON_TRIAN_HEIGHT + TRIANGLE_TO_PAT_GAP; patRect.width = rect.width - 2*PAT_OFFSET; patRect.height = rect.height - ( patRect.y - rect.y ) - PAT_OFFSET; Draw3DPattern( patRect, dc ); dc.SetPen( mpLayout->mLightPen ); dc.DrawLine( rect.x, rect.y + rect.height, rect.x + rect.width, rect.y + rect.height ); } else { wxRect triRect; triRect.x = rect.x + TRIANGLE_OFFSET; triRect.y = rect.y; triRect.height = rect.height; triRect.width = ICON_TRIAN_HEIGHT; DrawTrianRight( triRect, dc ); wxRect patRect; patRect.y = rect.y + PAT_OFFSET; patRect.x = rect.x + TRIANGLE_OFFSET + ICON_TRIAN_HEIGHT + TRIANGLE_TO_PAT_GAP; patRect.height = rect.height - 2*PAT_OFFSET; patRect.width = rect.width - ( patRect.x - rect.x ) - PAT_OFFSET; Draw3DPattern( patRect, dc ); dc.SetPen( mpLayout->mLightPen ); dc.DrawLine( rect.x + rect.width, rect.y, rect.x + rect.width, rect.y + rect.height ); }}void cbRowDragPlugin::DrawRowsDragHintsBorder( wxDC& WXUNUSED(dc) ){ // FIXME:: what was that?}void cbRowDragPlugin::DrawCollapsedRowsBorder( wxDC& dc ){ int colRowOfs = GetCollapsedIconsPos(); wxRect& bounds = mpPane->mBoundsInParent; wxBrush bkBrush( mpLayout->mGrayPen.GetColour(), wxSOLID ); dc.SetBrush( bkBrush ); dc.SetPen( mpLayout->mDarkPen ); if ( mpPane->IsHorizontal() ) dc.DrawRectangle( bounds.x + mpPane->mLeftMargin - ROW_DRAG_HINT_WIDTH - 1, colRowOfs, bounds.width - mpPane->mLeftMargin - mpPane->mRightMargin + 2 + ROW_DRAG_HINT_WIDTH, COLLAPSED_ICON_HEIGHT + 1); else dc.DrawRectangle( colRowOfs, bounds.y + mpPane->mTopMargin - 1, COLLAPSED_ICON_HEIGHT + 1, bounds.height - mpPane->mTopMargin - mpPane->mBottomMargin - ROW_DRAG_HINT_WIDTH - 2 ); dc.SetBrush( wxNullBrush );}static inline bool rect_contains_point( const wxRect& rect, int x, int y ){ return ( x >= rect.x && y >= rect.y && x < rect.x + rect.width && y < rect.y + rect.height );}bool cbRowDragPlugin::HitTestCollapsedRowIcon( int iconIdx, const wxPoint& pos ){ wxRect bounds; GetCollapsedInconRect( iconIdx, bounds ); return rect_contains_point( bounds, pos.x, pos.y );}bool cbRowDragPlugin::HitTestRowDragHint( cbRowInfo* pRow, const wxPoint& pos ){ wxRect bounds; GetRowHintRect( pRow, bounds ); return rect_contains_point( bounds, pos.x, pos.y );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -