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

📄 controlbar.cpp

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    AddPlugin( CLASSINFO( cbBarDragPlugin         ) );    AddPlugin( CLASSINFO( cbPaneDrawPlugin ) );}void wxFrameLayout::AddPlugin( wxClassInfo* pPlInfo, int paneMask ){    if ( FindPlugin ( pPlInfo ) ) return; // same type of plugin cannot be added twice    cbPluginBase* pObj = (cbPluginBase*)pPlInfo->CreateObject();    wxASSERT(pObj); // DBG:: plugin's class should be dynamic    pObj->mPaneMask = paneMask;    pObj->mpLayout  = this;    PushPlugin( pObj );}void wxFrameLayout::AddPluginBefore( wxClassInfo* pNextPlInfo, wxClassInfo* pPlInfo,                                       int paneMask ){    wxASSERT( pNextPlInfo != pPlInfo ); // DBG:: no sense    cbPluginBase* pNextPl = FindPlugin( pNextPlInfo );    if ( !pNextPl )    {        AddPlugin( pPlInfo, paneMask );        return;    }    // remove existing one if present    cbPluginBase* pExistingPl = FindPlugin( pPlInfo );    if ( pExistingPl ) RemovePlugin( pPlInfo );    // create an instance    cbPluginBase* pNewPl = (cbPluginBase*)pPlInfo->CreateObject();    wxASSERT(pNewPl); // DBG:: plugin's class should be dynamic    // insert it to the chain    if ( pNextPl->GetPreviousHandler() )        pNextPl->GetPreviousHandler()->SetNextHandler( pNewPl );    else        mpTopPlugin = pNewPl;    pNewPl->SetNextHandler( pNextPl );    pNewPl->SetPreviousHandler( pNextPl->GetPreviousHandler() );    pNextPl->SetPreviousHandler( pNewPl );    // set it up    pNewPl->mPaneMask = paneMask;    pNewPl->mpLayout  = this;    pNewPl->OnInitPlugin();}void wxFrameLayout::RemovePlugin( wxClassInfo* pPlInfo ){    cbPluginBase* pPlugin = FindPlugin( pPlInfo );    if ( !pPlugin ) return; // it's OK to remove not-existing plugin ;-)    if ( pPlugin->GetPreviousHandler() == NULL )        mpTopPlugin = (cbPluginBase*)pPlugin->GetNextHandler();    delete pPlugin;}cbPluginBase* wxFrameLayout::FindPlugin( wxClassInfo* pPlInfo ){    cbPluginBase *pCur = mpTopPlugin;    while( pCur )    {        // NOTE:: it might appear useful matching plugin        //        classes "polymorphically":        if ( pCur->GetClassInfo()->IsKindOf( pPlInfo ) )            return pCur;        pCur = (cbPluginBase*)pCur->GetNextHandler();    }    return NULL;}/***** Implementation for class cbUpdateMgrData *****/IMPLEMENT_DYNAMIC_CLASS( cbUpdateMgrData, wxObject )cbUpdateMgrData::cbUpdateMgrData()    : mPrevBounds( -1,-1,0,0 ),      mIsDirty( true ),           // inidicate initial change      mpCustomData(0){}void cbUpdateMgrData::StoreItemState( const wxRect& boundsInParent ){    mPrevBounds = boundsInParent;}void cbUpdateMgrData::SetDirty( bool isDirty ){    mIsDirty = isDirty;}void cbUpdateMgrData::SetCustomData( wxObject* pCustomData ){    mpCustomData = pCustomData;}/***** Implementation for class cbDockPane *****/void wxBarIterator::Reset(){    mpRow = ( mpRows->Count() ) ? (*mpRows)[0] : NULL;    mpBar = NULL;}wxBarIterator::wxBarIterator( RowArrayT& rows )    : mpRows( &rows ),      mpRow ( NULL  ),      mpBar ( NULL  ){    Reset();}bool wxBarIterator::Next(){    if ( mpRow )    {        if ( mpBar )            mpBar = mpBar->mpNext;        else        {            if ( mpRow->mBars.GetCount() == 0 )            {                return false;            }            mpBar = mpRow->mBars[0];        }        if ( !mpBar )        {            // skip to the next row            mpRow = mpRow->mpNext;            if ( mpRow )                mpBar = mpRow->mBars[0];            else                return false;        }        return true;    }    else        return false;}cbBarInfo& wxBarIterator::BarInfo(){    return *mpBar;}cbRowInfo& wxBarIterator::RowInfo(){    return *mpRow;}/***** Implementation for class cbBarDimHandlerBase *****/IMPLEMENT_ABSTRACT_CLASS( cbBarDimHandlerBase, wxObject )cbBarDimHandlerBase::cbBarDimHandlerBase()    : mRefCount(0){}void cbBarDimHandlerBase::AddRef(){    ++mRefCount;}void cbBarDimHandlerBase::RemoveRef(){    if ( --mRefCount <= 0 ) delete this;}/***** Implementation for class cbDimInfo *****/IMPLEMENT_DYNAMIC_CLASS( cbDimInfo, wxObject )cbDimInfo::cbDimInfo()    : mVertGap ( 0 ),      mHorizGap( 0 ),      mIsFixed(true),      mpHandler( NULL ){    size_t i;    for ( i = 0; i != MAX_BAR_STATES; ++i )    {        mSizes[i].x = 20;        mSizes[i].y = 20;        mBounds[i] = wxRect( -1,-1,-1,-1 );    }}cbDimInfo::cbDimInfo( cbBarDimHandlerBase* pDimHandler,                      bool                 isFixed  )    : mVertGap ( 0 ),      mHorizGap( 0 ),      mIsFixed ( isFixed  ),      mpHandler( pDimHandler ){    if ( mpHandler )    {        // int vtad = *((int*)mpHandler);        mpHandler->AddRef();    }    size_t i;    for ( i = 0; i != MAX_BAR_STATES; ++i )    {        mSizes[i].x = -1;        mSizes[i].y = -1;        mBounds[i] = wxRect( -1,-1,-1,-1 );    }}cbDimInfo::cbDimInfo( int dh_x, int dh_y,                      int dv_x, int dv_y,                      int f_x,  int f_y,                      bool isFixed,                      int horizGap,                      int vertGap,                      cbBarDimHandlerBase* pDimHandler                    )    : mVertGap  ( vertGap   ),      mHorizGap ( horizGap  ),      mIsFixed  ( isFixed   ),      mpHandler( pDimHandler ){    if ( mpHandler )    {        // int vtad = *((int*)mpHandler);        mpHandler->AddRef();    }    mSizes[wxCBAR_DOCKED_HORIZONTALLY].x = dh_x;    mSizes[wxCBAR_DOCKED_HORIZONTALLY].y = dh_y;    mSizes[wxCBAR_DOCKED_VERTICALLY  ].x = dv_x;    mSizes[wxCBAR_DOCKED_VERTICALLY  ].y = dv_y;    mSizes[wxCBAR_FLOATING           ].x = f_x;    mSizes[wxCBAR_FLOATING           ].y = f_y;    size_t i;    for ( i = 0; i != MAX_BAR_STATES; ++i )        mBounds[i] = wxRect( -1,-1,-1,-1 );}cbDimInfo::cbDimInfo( int x, int y,                      bool isFixed, int gap,                      cbBarDimHandlerBase* pDimHandler)  : mVertGap  ( gap ),    mHorizGap ( gap ),    mIsFixed  ( isFixed ),    mpHandler( pDimHandler ){    if ( mpHandler )    {        // int vtad = *((int*)mpHandler);        mpHandler->AddRef();    }    mSizes[wxCBAR_DOCKED_HORIZONTALLY].x = x;    mSizes[wxCBAR_DOCKED_HORIZONTALLY].y = y;    mSizes[wxCBAR_DOCKED_VERTICALLY  ].x = x;    mSizes[wxCBAR_DOCKED_VERTICALLY  ].y = y;    mSizes[wxCBAR_FLOATING           ].x = x;    mSizes[wxCBAR_FLOATING           ].y = y;    size_t i;    for ( i = 0; i != MAX_BAR_STATES; ++i )        mBounds[i] = wxRect( -1,-1,-1,-1 );}cbDimInfo::~cbDimInfo(){    if ( mpHandler )        mpHandler->RemoveRef();}const cbDimInfo& cbDimInfo::operator=( const cbDimInfo& other ){    if ( this == &other )        return *this;    int i;    for ( i = 0; i != MAX_BAR_STATES; ++i )        mSizes[i] = other.mSizes[i];    mIsFixed  = other.mIsFixed;    mpHandler = other.mpHandler;    mVertGap  = other.mVertGap;    mHorizGap = other.mHorizGap;    if ( mpHandler )        mpHandler->AddRef();    return *this;}/***** Implementation for structure cbCommonPaneProperties *****/IMPLEMENT_DYNAMIC_CLASS( cbCommonPaneProperties, wxObject )cbCommonPaneProperties::cbCommonPaneProperties(void)    : mRealTimeUpdatesOn    ( true  ),      mOutOfPaneDragOn      ( true  ),      mExactDockPredictionOn( false ),      mNonDestructFrictionOn( false ),      mShow3DPaneBorderOn   ( true  ),      mBarFloatingOn        ( false ),      mRowProportionsOn     ( false ),      mColProportionsOn     ( true  ),      mBarCollapseIconsOn   ( false ),      mBarDragHintsOn       ( false ),      mMinCBarDim( 16, 16 ),      mResizeHandleSize( 4 ){}cbCommonPaneProperties::cbCommonPaneProperties(const cbCommonPaneProperties& props)    : wxObject(),      mRealTimeUpdatesOn    (props.mRealTimeUpdatesOn),      mOutOfPaneDragOn      (props.mOutOfPaneDragOn),      mExactDockPredictionOn(props.mExactDockPredictionOn),      mNonDestructFrictionOn(props.mNonDestructFrictionOn),      mShow3DPaneBorderOn   (props.mShow3DPaneBorderOn),      mBarFloatingOn        (props.mBarFloatingOn),      mRowProportionsOn     (props.mRowProportionsOn),      mColProportionsOn     (props.mColProportionsOn),      mBarCollapseIconsOn   (props.mBarCollapseIconsOn),      mBarDragHintsOn       (props.mBarDragHintsOn),      mMinCBarDim(props.mMinCBarDim),      mResizeHandleSize(props.mResizeHandleSize){}cbCommonPaneProperties& cbCommonPaneProperties::operator=(const cbCommonPaneProperties& props){    mRealTimeUpdatesOn     = props.mRealTimeUpdatesOn;    mOutOfPaneDragOn       = props.mOutOfPaneDragOn;    mExactDockPredictionOn = props.mExactDockPredictionOn;    mNonDestructFrictionOn = props.mNonDestructFrictionOn;    mShow3DPaneBorderOn    = props.mShow3DPaneBorderOn;    mBarFloatingOn         = props.mBarFloatingOn;    mRowProportionsOn      = props.mRowProportionsOn;    mColProportionsOn      = props.mColProportionsOn;    mBarCollapseIconsOn    = props.mBarCollapseIconsOn;    mBarDragHintsOn        = props.mBarDragHintsOn;    mMinCBarDim            = props.mMinCBarDim;    mResizeHandleSize      = props.mResizeHandleSize;    return *this;}/***** Implementation for class cbRowInfo *****/IMPLEMENT_DYNAMIC_CLASS( cbRowInfo, wxObject )cbRowInfo::cbRowInfo(void)    : mNotFixedBarsCnt( false ),      mpNext          ( NULL ),      mpPrev          ( NULL ),      mpExpandedBar   ( NULL ){}cbRowInfo::~cbRowInfo(){    // nothing! all bars are removed using global bar    // list in wxFrameLayout class}/***** Implementation for class cbBarInfo *****/IMPLEMENT_DYNAMIC_CLASS( cbBarInfo, wxObject )cbBarInfo::cbBarInfo(void)    : mpRow( NULL ),      mFloatingOn( true ),      mpNext( NULL ),      mpPrev( NULL ){}cbBarInfo::~cbBarInfo(){    // nothing}/***** Implementation for class cbDockPane *****/IMPLEMENT_DYNAMIC_CLASS( cbDockPane, wxObject )// FIXME:: how to eliminate these cut&pasted constructors?cbDockPane::cbDockPane(void)    : mLeftMargin  ( 1 ),      mRightMargin ( 1 ),      mTopMargin   ( 1 ),      mBottomMargin( 1 ),      mPaneWidth ( 32768     ), // fake-up very large pane dims,                                // since the real dimensions of the pane may not                                // be known, while inserting bars initially      mPaneHeight( 32768     ),      mAlignment ( -1   ),      mpLayout   ( 0 ),      mpStoredRow( NULL ){}cbDockPane::cbDockPane( int alignment, wxFrameLayout* pPanel )    :  mLeftMargin  ( 1 ),      mRightMargin ( 1 ),      mTopMargin   ( 1 ),      mBottomMargin( 1 ),      mPaneWidth ( 32768     ), // fake-up very large pane dims,                                // since the real dimensions of the pane may not                                // be known, while inserting bars initially      mPaneHeight( 32768     ),      mAlignment ( alignment ),      mpLayout   ( pPanel    ),      mpStoredRow( NULL ){}cbDockPane::~cbDockPane(){    size_t i;    for ( i = 0; i != mRows.Count(); ++i )        delete mRows[i];    WX_CLEAR_LIST(wxList,mRowShapeData)    // NOTE:: control bar infromation structures are cleaned-up    //        in wxFrameLayout's destructor, using global control-bar list}void cbDockPane::SetMargins( int top, int bottom, int left, int right ){    mTopMargin    = top;    mBottomMargin = bottom;    mLeftMargin   = left;    mRightMargin  = right;}/*** helpers of cbDockPane ***/void cbDockPane::PaintBarDecorations( cbBarInfo* pBar, wxDC& dc ){    cbDrawBarDecorEvent evt( pBar, dc, this );    mpLayout->FirePluginEvent( evt );}void cbDockPane::PaintBarHandles( cbBarInfo* pBar, wxDC& dc ){    cbDrawBarHandlesEvent evt( pBar, dc, this );    mpLayout->FirePluginEvent( evt );}void cbDockPane::PaintBar( cbBarInfo* pBar, wxDC& dc ){    PaintBarDecorations( pBar, dc );    PaintBarHandles( pBar, dc );}void cbDockPane::PaintRowHandles( cbRowInfo* pRow, wxDC& dc ){    cbDrawRowHandlesEvent evt( pRow, dc, this );    mpLayout->FirePluginEvent( evt );    cbDrawRowDecorEvent evt1( pRow, dc, this );    mpLayout->FirePluginEvent( evt1 );}void cbDockPane::PaintRowBackground ( cbRowInfo* pRow, wxDC& dc ){    cbDrawRowBkGroundEvent evt( pRow, dc, this );    mpLayout->FirePluginEvent( evt );}void cbDockPane::PaintRowDecorations( cbRowInfo* pRow, wxDC& dc ){    size_t i;    // decorations first    for ( i = 0; i != pRow->mBars.Count(); ++i )        PaintBarDecorations( pRow->mBars[i], dc );    // then handles if present    for ( i = 0; i != pRow->mBars.Count(); ++i )        PaintBarHandles( pRow->mBars[i], dc );}void cbDockPane::PaintRow( cbRowInfo* pRow, wxDC& dc ){    PaintRowBackground ( pRow, dc );    PaintRowDecorations( pRow, dc );    PaintRowHandles    ( pRow, dc );}void cbDockPane::PaintPaneBackground( wxDC& dc ){    cbDrawPaneBkGroundEvent evt( dc, this );    mpLayout->FirePluginEvent( evt );}

⌨️ 快捷键说明

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