📄 controlbar.cpp
字号:
void wxFrameLayout::CaptureEventsForPane( cbDockPane* toPane )
{
// cannot capture events twice (without releasing)
wxASSERT( mpPaneInFocus == NULL );
mpFrame->CaptureMouse();
mpPaneInFocus = toPane;
}
void wxFrameLayout::ReleaseEventsFromPane( cbDockPane* WXUNUSED(fromPane) )
{
// cannot release events without capturing them
wxASSERT( mpPaneInFocus != NULL );
mpFrame->ReleaseMouse();
mpPaneInFocus = NULL;
}
cbPluginBase& wxFrameLayout::GetTopPlugin()
{
if ( !mpTopPlugin )
PushDefaultPlugins(); // automatic configuration
return *mpTopPlugin;
}
void wxFrameLayout::SetTopPlugin( cbPluginBase* pPlugin )
{
mpTopPlugin = pPlugin;
}
bool wxFrameLayout::HasTopPlugin()
{
return ( mpTopPlugin != NULL );
}
void wxFrameLayout::PushPlugin( cbPluginBase* pPlugin )
{
if ( !mpTopPlugin )
mpTopPlugin = pPlugin;
else
{
pPlugin->SetNextHandler( mpTopPlugin );
mpTopPlugin->SetPreviousHandler( pPlugin );
mpTopPlugin = pPlugin;
}
mpTopPlugin->OnInitPlugin(); // notification
}
void wxFrameLayout::PopPlugin()
{
wxASSERT( mpTopPlugin ); // DBG:: at least one plugin should be present
cbPluginBase* pPopped = mpTopPlugin;
mpTopPlugin = (cbPluginBase*)mpTopPlugin->GetNextHandler();
delete pPopped;
}
void wxFrameLayout::PopAllPlugins()
{
while( mpTopPlugin ) PopPlugin();
}
void wxFrameLayout::PushDefaultPlugins()
{
// FIXME:: to much of the stuff for the default...
AddPlugin( CLASSINFO( cbRowLayoutPlugin ) );
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 )
{}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -