本文整理汇总了C++中Panel::SetBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ Panel::SetBounds方法的具体用法?C++ Panel::SetBounds怎么用?C++ Panel::SetBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Panel
的用法示例。
在下文中一共展示了Panel::SetBounds方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnSizeChanged
//-----------------------------------------------------------------------------
// Purpose: Callback for when the panel size has been changed
//-----------------------------------------------------------------------------
void EditablePanel::OnSizeChanged(int wide, int tall)
{
BaseClass::OnSizeChanged(wide, tall);
InvalidateLayout();
int dx = wide - _baseWide;
int dy = tall - _baseTall;
for (int i = 0; i < GetChildCount(); i++)
{
// perform auto-layout on the child panel
Panel *child = GetChild(i);
int x, y, w, t;
child->GetBounds(x, y, w, t);
if (child->GetPinCorner() == PIN_TOPRIGHT || child->GetPinCorner() == PIN_BOTTOMRIGHT)
{
// move along with the right edge
x += dx;
}
if (child->GetPinCorner() == PIN_BOTTOMLEFT || child->GetPinCorner() == PIN_BOTTOMRIGHT)
{
// move along with the lower edge
y += dy;
}
// check for resize
if (child->GetAutoResize() == AUTORESIZE_RIGHT || child->GetAutoResize() == AUTORESIZE_DOWNANDRIGHT)
{
w += dx;
}
if (child->GetAutoResize() == AUTORESIZE_DOWN || child->GetAutoResize() == AUTORESIZE_DOWNANDRIGHT)
{
t += dy;
}
// make sure the child isn't too big...
if(x+w>wide)
{
continue;
}
if(y+t>tall)
{
continue;
}
child->SetBounds(x, y, w, t);
child->InvalidateLayout();
}
Repaint();
// update the baselines
_baseWide = wide;
_baseTall = tall;
}
示例2: PerformLayout
//-----------------------------------------------------------------------------
// Creates a widget using editor attribute info
//-----------------------------------------------------------------------------
void CBaseAttributePanel::PerformLayout()
{
BaseClass::PerformLayout();
CUtlVector< Panel * > vispanels;
if ( HasFlag( HIDETYPE ) )
{
m_pType->SetVisible( false );
}
else
{
vispanels.AddToTail( m_pType );
}
vgui::Panel *dataPanel = GetDataPanel();
if ( dataPanel )
{
if ( HasFlag( HIDEVALUE ) )
{
dataPanel->SetVisible( false );
}
else
{
vispanels.AddToTail( dataPanel );
}
}
int c = vispanels.Count();
Assert( c >= 0 );
if ( c == 0 )
{
return;
}
int w, h;
GetSize( w, h );
int x = 1;
int y = 0;
w-= 2;
for ( int i = 0; i < c; ++i )
{
Panel *panel = vispanels[ i ];
int width = GetSizeForColumn( panel );
if ( i == c - 1 )
{
width = w - x;
}
panel->SetBounds( x, y, width, h );
x += width;
}
}
示例3: DemoPage
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
SampleTabs::SampleTabs(Panel *parent, const char *name) : DemoPage(parent, name)
{
m_pPropertySheet = new PropertySheet(this, "Tabs");
m_pPropertySheet->SetBounds(90,25, 375, 200);
m_pPropertySheet->SetTabWidth(75);
Panel *testPanel = new PropertyPage (this, "tab1");
testPanel->SetBounds(90,50, 375, 200);
m_pPropertySheet->AddPage(testPanel, "Keyboard");
Panel *testPanel2 = new PropertyPage (this, "tab2");
testPanel->SetBounds(90,50,375,200);
m_pPropertySheet->AddPage(testPanel2, "Mouse");
Panel *testPanel3 = new PropertyPage (this, "tab3");
testPanel->SetBounds(90,50,375,200);
m_pPropertySheet->AddPage(testPanel3, "Audio");
Panel *testPanel4 = new PropertyPage (this, "tab4");
testPanel->SetBounds(90,50, 375,200);
m_pPropertySheet->AddPage(testPanel4, "Video");
}
示例4: RepositionContents
void CGrid::RepositionContents()
{
for(int x=0; x < m_xCols; x++)
{
for(int y=0; y < m_yRows; y++)
{
Panel *pPanel = GridEntry(x,y)->m_pPanel;
if(!pPanel)
continue;
pPanel->SetBounds(
m_ColOffsets[x],
m_RowOffsets[y],
m_Widths[x],
m_Heights[y]);
}
}
m_bDirty = false;
}
示例5: FixupBackgroundPanels
//-----------------------------------------------------------------------------
// Purpose: Re-aligns background image panels so they are touching.
//-----------------------------------------------------------------------------
static void FixupBackgroundPanels( EditablePanel *pWindow, int offsetX, int offsetY )
{
if ( !pWindow )
return;
int screenWide, screenTall;
pWindow->GetSize( screenWide, screenTall );
int inset = GetAlternateProportionalValueFromNormal( 20 );
int cornerSize = GetAlternateProportionalValueFromNormal( 10 );
int titleHeight = GetAlternateProportionalValueFromNormal( 42 );
int mainHeight = GetAlternateProportionalValueFromNormal( 376 );
int logoSize = titleHeight;
int captionInset = GetAlternateProportionalValueFromNormal( 76 );
Panel *pPanel;
// corners --------------------------------------------
pPanel = pWindow->FindChildByName( "TopLeftPanel" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( offsetX + inset, offsetY + inset, cornerSize, cornerSize );
}
pPanel = pWindow->FindChildByName( "TopRightPanel" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( screenWide - offsetX - inset - cornerSize, offsetY + inset, cornerSize, cornerSize );
}
pPanel = pWindow->FindChildByName( "BottomLeftPanel" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( offsetX + inset, screenTall - offsetY - inset - cornerSize, cornerSize, cornerSize );
}
pPanel = pWindow->FindChildByName( "BottomRightPanel" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( screenWide - offsetX - inset - cornerSize, screenTall - offsetY - inset - cornerSize, cornerSize, cornerSize );
}
// background -----------------------------------------
pPanel = pWindow->FindChildByName( "TopSolid" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( offsetX + inset + cornerSize, offsetY + inset, screenWide - 2*offsetX - 2*inset - 2*cornerSize, cornerSize );
}
pPanel = pWindow->FindChildByName( "UpperMiddleSolid" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( offsetX + inset, offsetY + inset + cornerSize, screenWide - 2*offsetX - 2*inset, titleHeight );
}
pPanel = pWindow->FindChildByName( "LowerMiddleSolid" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( offsetX + inset + cornerSize, screenTall - offsetY - inset - cornerSize, screenWide - 2*offsetX - 2*inset - 2*cornerSize, cornerSize );
}
pPanel = pWindow->FindChildByName( "BottomSolid" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( offsetX + inset, screenTall - offsetY - inset - cornerSize - mainHeight, screenWide - 2*offsetX - 2*inset, mainHeight );
}
// transparent border ---------------------------------
pPanel = pWindow->FindChildByName( "TopClear" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( 0, 0, screenWide, offsetY + inset );
}
pPanel = pWindow->FindChildByName( "BottomClear" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( 0, screenTall - offsetY - inset, screenWide, offsetY + inset );
}
pPanel = pWindow->FindChildByName( "LeftClear" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
//.........这里部分代码省略.........
示例6: OnSizeChanged
//-----------------------------------------------------------------------------
// Purpose: Callback for when the panel size has been changed
//-----------------------------------------------------------------------------
void EditablePanel::OnSizeChanged(int wide, int tall)
{
BaseClass::OnSizeChanged(wide, tall);
InvalidateLayout();
for (int i = 0; i < GetChildCount(); i++)
{
// perform auto-layout on the child panel
Panel *child = GetChild(i);
if ( !child )
continue;
int x, y, w, h;
child->GetBounds( x, y, w, h );
int px, py;
child->GetPinOffset( px, py );
int ox, oy;
child->GetResizeOffset( ox, oy );
int ex;
int ey;
AutoResize_e resize = child->GetAutoResize();
bool bResizeHoriz = ( resize == AUTORESIZE_RIGHT || resize == AUTORESIZE_DOWNANDRIGHT );
bool bResizeVert = ( resize == AUTORESIZE_DOWN || resize == AUTORESIZE_DOWNANDRIGHT );
PinCorner_e pinCorner = child->GetPinCorner();
if ( pinCorner == PIN_TOPRIGHT || pinCorner == PIN_BOTTOMRIGHT )
{
// move along with the right edge
ex = wide + px;
x = bResizeHoriz ? ox : ex - w;
}
else
{
x = px;
ex = bResizeHoriz ? wide + ox : px + w;
}
if ( pinCorner == PIN_BOTTOMLEFT || pinCorner == PIN_BOTTOMRIGHT )
{
// move along with the right edge
ey = tall + py;
y = bResizeVert ? oy : ey - h;
}
else
{
y = py;
ey = bResizeVert ? tall + oy : py + h;
}
// Clamp..
if ( ex < x )
{
ex = x;
}
if ( ey < y )
{
ey = y;
}
child->SetBounds( x, y, ex - x, ey - y );
child->InvalidateLayout();
}
Repaint();
}