本文整理汇总了C++中ToolBar::GetRect方法的典型用法代码示例。如果您正苦于以下问题:C++ ToolBar::GetRect方法的具体用法?C++ ToolBar::GetRect怎么用?C++ ToolBar::GetRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToolBar
的用法示例。
在下文中一共展示了ToolBar::GetRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnMotion
void ToolBarResizer::OnMotion( wxMouseEvent & event )
{
// Go ahead and set the event to propagate
event.Skip();
// Retrieve the mouse position
wxPoint raw_pos = event.GetPosition();
wxPoint pos = ClientToScreen( raw_pos );
if( event.Dragging() )
{
wxRect r = mBar->GetRect();
wxSize msz = mBar->GetMinSize();
wxSize psz = mBar->GetParent()->GetClientSize();
// Adjust the size by the difference between the
// last mouse and current mouse positions.
r.width += ( pos.x - mResizeStart.x );
// Constrain
if( r.width < msz.x )
{
// Don't allow resizing to go too small
r.width = msz.x;
}
else if( r.GetRight() > psz.x - 3 )
{
// Don't allow resizing to go too large
//
// The 3 magic pixels are because I'm too chicken to change the
// calculations in ToolDock::LayoutToolBars() even though I'm
// the one that set them up. :-)
r.SetRight( psz.x - 3 );
}
else
{
// Remember for next go round
mResizeStart = pos;
}
// Resize the bar
mBar->SetSize( r.GetSize() );
// Tell everyone we've changed sizes
mBar->Updated();
// Refresh our world
mBar->GetParent()->Refresh();
mBar->GetParent()->Update();
}
}
示例2: PositionBar
//
// Determine the location and bar before which a new bar would be placed
//
// 'rect' will be the rectangle for the dock marker.
int ToolDock::PositionBar( ToolBar *t, wxPoint & pos, wxRect & rect )
{
struct
{
wxRect rect;
wxSize min;
} tinfo[ ToolBarCount + 1 ];
wxRect stack[ ToolBarCount + 1 ];
wxPoint cpos, lpos;
int ct, lt = 0;
int ndx, stkcnt = 0;
int tindx = -1;
int cnt = mDockedBars.GetCount();
int width, height;
// Get size of our parent since we haven't been sized yet
GetParent()->GetClientSize( &width, &height );
width -= toolbarGap;
height -= toolbarGap;
// Set initial stack entry to maximum size
stack[ 0 ].SetX( toolbarGap );
stack[ 0 ].SetY( toolbarGap );
// The stack width and height are the remaining width and height.
stack[ 0 ].SetWidth( width );
stack[ 0 ].SetHeight( height );
// Process all docked and visible toolbars
//
// Careful...slightly different from above in that we expect to
// process one more bar than is currently docked (<= in for)
for (ndx = 0, ct = 0; ndx <= cnt; ndx++, ct++)
{
// If last entry, then it is the
if (ndx == cnt)
{
// ...so check to see if the new bar has been placed yet
if (tindx == -1)
{
// Add the new bars' dimensions to the mix
tinfo[ct].rect = t->GetRect();
tinfo[ct].min = t->GetDockedSize();
tindx = ct;
}
}
else
{
// Cache toolbar pointer
ToolBar *b = (ToolBar *)mDockedBars[ndx];
// Remember current bars' dimensions
tinfo[ct].rect = b->GetRect();
tinfo[ct].min = b->GetSize();
// Maybe insert the new bar if it hasn't already been done
// and is in the right place.
if (tindx == -1)
{
wxRect r;
// Get bar rect and make gap part of it
r.SetPosition(b->GetParent()->ClientToScreen(b->GetPosition()));
r.SetSize(b->IsResizable() ? b->GetSize() : b->GetSize());
r.width += toolbarGap;
r.height += toolbarGap;
// Does the location fall within this bar?
if (r.Contains(pos) || pos.y <= r.y)
{
// Add the new bars' dimensions to the mix
tinfo[ct].rect = t->GetRect();
tinfo[ct].min = t->GetDockedSize();
tindx = ct;
ndx--;
}
}
}
// Get and cache the toolbar sizes
wxSize sz = tinfo[ct].min;
int tw = sz.GetWidth() + toolbarGap;
int th = sz.GetHeight() + toolbarGap;
// This loop reduces stkcnt until it gives a box
// that we fit in.
while (stkcnt > 0)
{
// Get out if it will fit
bool bTooWide = tw > stack[stkcnt].GetWidth();
// We'd like to be able to add a tall toolbar in at the start of a row,
// even if there isn't enough height for it.
// If so, we'd have to at least change how we calculate 'bTooHigh'.
bool bTooHigh = th > stack[stkcnt].GetHeight();
//bTooHigh &= stack[stkcnt].GetWidth() < (width - toolbarGap);
//bTooHigh = false;
//.........这里部分代码省略.........
示例3: PositionBar
//
// Determine the location and bar before which a new bar would be placed
//
int ToolDock::PositionBar( ToolBar *t, wxPoint & pos, wxRect & rect )
{
struct
{
wxRect rect;
wxSize min;
} tinfo[ ToolBarCount + 1 ];
wxRect stack[ ToolBarCount + 1 ];
wxPoint cpos, lpos;
int ct, lt = 0;
int ndx, stkcnt = 0;
int tindx = -1;
int cnt = mDockedBars.GetCount();
int width, height;
// Get size of our parent since we haven't been sized yet
GetParent()->GetClientSize( &width, &height );
width -= toolbarGap;
height -= toolbarGap;
// Set initial stack entry to maximum size
stack[ 0 ].SetX( toolbarGap );
stack[ 0 ].SetY( toolbarGap );
stack[ 0 ].SetWidth( width );
stack[ 0 ].SetHeight( height );
// Process all docked and visible toolbars
//
// Careful...slightly different from above in that we expect to
// process one more bar than is currently docked (<= in for)
for( ndx = 0, ct = 0; ndx <= cnt; ndx++, ct++ )
{
// We're on the last entry...
if( ndx == cnt )
{
// ...so check to see if the new bar has been placed yet
if( tindx == -1 )
{
// Add the new bars' dimensions to the mix
tinfo[ ct ].rect = t->GetRect();
tinfo[ ct ].min = t->GetMinSize();
tindx = ct;
}
}
else
{
// Cache toolbar pointer
ToolBar *b = (ToolBar *) mDockedBars[ ndx ];
// Remember current bars' dimensions
tinfo[ ct ].rect = b->GetRect();
tinfo[ ct ].min = b->GetSize();
// Insert the new bar if it hasn't already been done
if( tindx == -1 )
{
wxRect r;
// Get bar rect and make gap part of it
r.SetPosition( b->GetParent()->ClientToScreen( b->GetPosition() ) );
r.SetSize( b->IsResizable() ? b->GetSize() : b->GetSize() );
r.width += toolbarGap;
r.height += toolbarGap;
// Does the location fall within this bar?
if( r.Contains( pos ) || pos.y <= r.y )
{
// Add the new bars' dimensions to the mix
tinfo[ ct ].rect = t->GetRect();
tinfo[ ct ].min = t->GetSize();
tindx = ct;
ndx--;
}
}
}
// Get and cache the toolbar sizes
wxSize sz = tinfo[ ct ].min;
int tw = sz.GetWidth() + toolbarGap;
int th = sz.GetHeight() + toolbarGap;
// Will this one fit in remaining horizontal space?
if( ( tw > stack[ stkcnt ].GetWidth() ) ||
( th > stack[ stkcnt ].GetHeight() ) )
{
// Destack entries until one is found in which this bar
// will fit or until we run out of stacked entries
while( stkcnt > 0 )
{
stkcnt--;
// Get out if it will fit
if( ( tw <= stack[ stkcnt ].GetWidth() ) &&
( th <= stack[ stkcnt ].GetHeight() ) )
{
break;
//.........这里部分代码省略.........