📄 barhintspl.cpp
字号:
if ( !pCur->IsFixed() )
{
isAtLeft = true; break;
}
pCur = pCur->mpPrev;
}
}
// 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;
}
if ( mpPane->IsHorizontal() )
{
if ( mCloseBoxOn )
{
mBoxes[CLOSE_BOX_IDX]->mPos = wxPoint( rect.x + mHintGap + boxOfs, pos );
pos += BTN_BOX_HEIGHT;
}
if ( mCollapseBoxOn )
{
if ( mCloseBoxOn ) pos += BOX_T_BOX_GAP;
mBoxes[COLLAPSE_BOX_IDX]->mPos = wxPoint( rect.x + mHintGap + boxOfs, pos );
pos += BTN_BOX_HEIGHT;
pos += BOX_TO_GROOVE_GAP;
}
}
else
{
if ( mCloseBoxOn )
{
pos -= BTN_BOX_WIDTH;
mBoxes[CLOSE_BOX_IDX]->mPos = wxPoint( pos , rect.y + mHintGap + boxOfs );
}
if ( mCollapseBoxOn )
{
if ( mCloseBoxOn ) pos -= BOX_T_BOX_GAP;
pos -= BTN_BOX_WIDTH;
mBoxes[COLLAPSE_BOX_IDX]->mPos = wxPoint( pos, rect.y + mHintGap + boxOfs );
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 );
}
int cbBarHintsPlugin::HitTestHints( cbBarInfo& info, const wxPoint& pos )
{
wxPoint inPane = pos;
mpPane->PaneToFrame( &inPane.x, &inPane.y );
wxRect& rect = info.mBoundsInParent;
if ( info.IsFixed() ) return false;
int 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 ) )
return CLOSE_BOX_HITTED;
coord += BTN_BOX_HEIGHT;
}
if ( mCollapseBoxOn )
{
if ( mCloseBoxOn ) coord += BOX_T_BOX_GAP;
if ( is_in_box( wxPoint( rect.x + mHintGap + boxOfs, coord ), inPane ) )
return COLLAPSE_BOX_HITTED;
coord += BTN_BOX_HEIGHT;
}
}
else
{
if ( mCloseBoxOn )
{
coord -= BTN_BOX_WIDTH;
if ( is_in_box( wxPoint( coord , rect.y + mHintGap + boxOfs ), inPane ) )
return CLOSE_BOX_HITTED;
}
if ( mCollapseBoxOn )
{
if ( mCloseBoxOn ) coord -= BOX_T_BOX_GAP;
coord -= BTN_BOX_WIDTH;
if ( is_in_box( wxPoint( coord, rect.y + mHintGap + boxOfs ), inPane ) )
return COLLAPSE_BOX_HITTED;
}
}
return false;
}
// handlers for plugin-events
void cbBarHintsPlugin::OnSizeBarWindow( cbSizeBarWndEvent& event )
{
wxRect& rect = event.mBoundsInParent;
mpPane = event.mpPane;
ExcludeHints( rect, *event.mpBar );
event.Skip(); // pass event to the next plugin in the chain
}
void cbBarHintsPlugin::OnDrawBarDecorations( cbDrawBarDecorEvent& event )
{
wxRect& rect = event.mBoundsInParent;
mpPane = event.mpPane;
int boxOfs, grooveOfs, pos;
GetHintsLayout( rect, *event.mpBar, boxOfs, grooveOfs, pos );
DoDrawHint( *event.mpDc, rect, pos, boxOfs, grooveOfs, event.mpBar->IsFixed() );
// let other plugins add on their decorations
event.Skip();
}
void cbBarHintsPlugin::OnLeftDown( cbLeftDownEvent& event )
{
mpPane = event.mpPane;
wxPoint inFrame = event.mPos;
mpPane->PaneToFrame( &inFrame.x, &inFrame.y );
wxBarIterator iter( mpPane->GetRowList() );
mpClickedBar = NULL;
while ( iter.Next() )
{
cbBarInfo& bar = iter.BarInfo();
int 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]->mPressed = false;
mBoxes[i]->mWasClicked = false;
}
for ( i = 0; i != BOXES_IN_HINT; ++i )
{
mBoxes[i]->OnLeftDown( inFrame );
if ( mBoxes[i]->mPressed )
{
mBtnPressed = true;
mpClickedBar = &bar;
return; // event handled
}
}
}
}
event.Skip();
}
void cbBarHintsPlugin::OnLeftUp( cbLeftUpEvent& event )
{
if ( mBtnPressed )
{
wxPoint inFrame = event.mPos;
mpPane->PaneToFrame( &inFrame.x, &inFrame.y );
int boxOfs, grooveOfs, pos;
GetHintsLayout( mpClickedBar->mBoundsInParent, *mpClickedBar, boxOfs, grooveOfs, pos );
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 );
// Notify bar child window of close event:
if(mpClickedBar->mpBarWnd!=NULL)
mpClickedBar->mpBarWnd->Close();
}
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();
}
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();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -