本文整理汇总了C++中Rect::GetW方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::GetW方法的具体用法?C++ Rect::GetW怎么用?C++ Rect::GetW使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect::GetW方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowDecorations
void Window::ShowDecorations()
{
Hide();
Rect clr = GetClientRect();
SetWindowLong( _window_handle, GWL_STYLE, WS_TILEDWINDOW);
Rect dr = GetWindowRect() - GetClientRect();
Resize( clr.GetW() + dr.GetW(), clr.GetH() + dr.GetH() );
Show();
}
示例2: RepaintImpl
void WidgetTableWidget::RepaintImpl( const WidgetPainter &painter )
{
//HubWidget::Repaint(painter); -- nonsense
Rect client_area = GetParent()->GetClientRect(this)-GetPosition();
Rect influenced = GetCrossing( client_area );
Pos p( influenced.GetX1(), influenced.GetY1() );
for ( int j=0; j!=influenced.GetW(); ++j, ++p.x )
{
SettlerMap::Iterator iter;
_settlers.Find( p, (SettlerMap::ConstIterator*)&iter);
for ( int i=0; i!=influenced.GetH(); ++i, ++iter )
{
if (!iter) { break; }//< W/A GetCrossing() does not work corectly
Widget &child = *iter->_settler;
if ( child.IsVisible() )
{
WidgetPainter child_painter( painter, child );
if ( child_painter.Intersect() )
{
child.Repaint(child_painter);
child_painter.RestoreClipper();
}
}
}
}
}
示例3: PaintClients
void TableListedItems::PaintClients( const WidgetPainter &painter )
{
Pos p;
Dim2i d( GetWidth(), 0);
Rect client_area = GetParent()->GetClientRect(this)-GetPosition();
Rect visibile = TableWidget::GetCrossing( client_area );
p.y = RowRect( visibile.GetY1() ).GetY();
for ( int i=visibile.GetY1(); i<visibile.GetY2(); ++i )
{
d.y = GetRowHeight(i);
int last_col = GetNumColumns() -1;
Rect fa = RowRect( i );
if ( _skins.Select( GetState(i) ) )
{
_skins.SetSize( Dim2i(fa.GetW(),fa.GetH()) );
}
_skins.Paint( painter, fa.GetPos(), fa );
p.y += d.y;
}
}
示例4: CorrectCollision
/**
* Corrects the box position relative to a given tileBox
* and the previous position of the box.
*/
void MovementMap::CorrectCollision(Rect& box, Rect tileBox)
{
if (!Collision::IsColliding(box, tileBox, 0, 0)) return;
// If the previous position was to the left of the tile
if (previousPos.GetX()+previousPos.GetW() <= tileBox.GetX())
box.MoveRect(tileBox.GetX() - (box.GetX()+box.GetW()), 0);
// If the previous position was to the right of the tile
else if (previousPos.GetX() >= tileBox.GetX()+tileBox.GetW())
box.MoveRect((tileBox.GetX()+tileBox.GetW()) - box.GetX(), 0);
// If the previous position was below the tile
else if (previousPos.GetY() > tileBox.GetY())
box.MoveRect(0, tileBox.GetY()+tileBox.GetH() - box.GetY());
// If the previous position was above the tile
else
box.MoveRect(0, tileBox.GetY()-(box.GetY()+box.GetH()));
}
示例5: Update
void MainState::Update() {
// Moves the player in the specified direction
if (m_PlayerDirState[kPlayerDirLeft]) {
m_Player->TranslateBy(Vec2(-5.0, 0.0));
}
else if (m_PlayerDirState[kPlayerDirRight]) {
m_Player->TranslateBy(Vec2(5.0, 0.0));
}
else if (m_PlayerDirState[kPlayerDirUp]) {
m_Player->TranslateBy(Vec2(0.0, -5.0));
}
else if (m_PlayerDirState[kPlayerDirDown]) {
m_Player->TranslateBy(Vec2(0.0, 5.0));
}
for (int i = 0; i < m_ProjectileArray.GetSize(); ++i) {
Rect screenRect = m_EnginePtr->GetScene()->GetScreenRect();
Projectile* projectile = m_ProjectileArray[i];
Vec2 pos = projectile->GetWorldPosition();
if (pos.GetX() < screenRect.GetX() ||
pos.GetX() > (screenRect.GetX() + screenRect.GetW()) ||
pos.GetY() < screenRect.GetY() ||
pos.GetY() > (screenRect.GetY() + screenRect.GetH())) {
LOG_PRINT("removed");
}
}
}
示例6: HideDecorations
void Window::HideDecorations()
{
Hide();
Rect clr = GetClientRect();
SetWindowLong( _window_handle, GWL_STYLE, WS_POPUP);
Resize( clr.GetW(), clr.GetH());
Show();
}
示例7: RowRect
Rect TableWidget::RowRect( int row ) const
{
int last_col = GetNumColumns() -1;
Rect R = CellRect( 0, row) | CellRect( last_col, row);
Rect r = ClientRect( 0, row) | ClientRect( last_col, row);
return Rect( R.GetX1(), r.GetY1(), R.GetW(), r.GetH() );
}
示例8: ColumnRect
Rect TableWidget::ColumnRect( int column ) const
{
int last_row = GetNumRows() -1;
Rect R = CellRect( column, 0) | CellRect( column, last_row);
Rect r = ClientRect( column, 0) | ClientRect( column, last_row);
return Rect( r.GetX1(), R.GetY1(), r.GetW(), R.GetH() );
}
示例9: IsOnGround
/**
* Returns true if the given box is directly above the ground
*/
bool MovementMap::IsOnGround(const Rect box)
{
// Checks the lower limit
if (!IsZero(box.Center().GetX(), box.GetY()+box.GetH()+1)) return true;
// Checks the lower-right limit
if (!IsZero(box.GetX()+box.GetW(), box.GetY()+box.GetH()+1)) return true;
// Checks the lower-left limit
if (!IsZero(box.GetX(), box.GetY()+box.GetH()+1)) return true;
return false;
}
示例10: assert
Point<double> DDScreen::GetZoomFactors() const
{
DDSurface *p_back = DDrawWindow::GetDisplay().GetBackBuffer();
Rect client = Window::GetClientRect();
assert( p_back );
double factor_x = client.GetW()/ (double)p_back->GetWidth();
double factor_y = client.GetH()/ (double)p_back->GetHeight();
return Point<double>( factor_x, factor_y );
}
示例11: AABBToAABB
Vec2 CollisionDetector::AABBToAABB(const Rect& rect1, const Rect& rect2) {
// Prevents false collision if either rects has no width and height
if ((rect1.GetW() == 0 && rect1.GetH() == 0) ||
(rect2.GetW() == 0 && rect2.GetH() == 0)) {
return Vec2(0.0, 0.0);
}
Vec2 min1(rect1.GetX(), rect1.GetY());
Vec2 max1(rect1.GetX() + rect1.GetW(), rect1.GetY() + rect1.GetH());
Vec2 min2(rect2.GetX(), rect2.GetY());
Vec2 max2(rect2.GetX() + rect2.GetW(), rect2.GetY() + rect2.GetH());
if ((max1.GetX() < min2.GetX()) || (max1.GetY() < min2.GetY())) {
return Vec2(0.0, 0.0);
}
if ((max2.GetX() < min1.GetX()) || (max2.GetY() < min1.GetY())) {
return Vec2(0.0, 0.0);
}
// Potential resolution offsets
double negX = max1.GetX() - min2.GetX();
double posX = max2.GetX() - min1.GetX();
double negY = max1.GetY() - min2.GetY();
double posY = max2.GetY() - min1.GetY();
// Returns the component vector that needs the least offset to resolve the collision
if (negX <= posX && negX <= negY && negX <= posY) {
return Vec2(-negX, 0.0);
}
else if (posX <= negY && posX <= posY) {
return Vec2(posX, 0.0);
}
else if (negY <= posY) {
return Vec2(0.0, -negY);
}
else {
return Vec2(0.0, posY);
}
return Vec2(0.0, 0.0);
}
示例12: PaintArea
void ListedTextItems::PaintArea( const Painter &painter, const Rect &area, int stateID)
{
if ( _skins.Select(stateID) )
{
int cur_w = _skins.GetWidth();
int cur_h = _skins.GetHeight();
_skins.SetSize( Dim2i( area.GetW(), area.GetH()));
_skins.Paint( painter, area.GetPos());
_skins.SetSize( Dim2i( cur_w, cur_h));
}
}
示例13:
/**
* Returns a vector of Rects corresponding to the tiles
* that are colliding with the given box
*/
std::vector<Rect> MovementMap::GetCollidingTiles(const Rect& box)
{
std::vector<Rect> collidingTiles;
// Check the upper point
if (!IsZero(box.GetX()+box.GetW()/2, box.GetY()))
collidingTiles.push_back(TileToRect(box.GetX(), box.GetY()));
// Check the right point
if (!IsZero(box.GetX()+box.GetW(), box.GetY()+box.GetH()/2))
collidingTiles.push_back(TileToRect(box.GetX()+box.GetW(), box.GetY()));
// Check the left point
if (!IsZero(box.GetX(), box.GetY()+box.GetH()/2))
collidingTiles.push_back(TileToRect(box.GetX(), box.GetY()+box.GetH()));
// Check the lower point
if (!IsZero(box.GetX()+box.GetW()/2, box.GetY()+box.GetH()))
collidingTiles.push_back(TileToRect(box.GetX()+box.GetW(), box.GetY()+box.GetH()));
// for (int i = 0; i < collidingTiles.size(); i++)
// {
// std::cout << std::endl;
// std::cout << "(" << collidingTiles[i].GetX() << "," << collidingTiles[i].GetY() << ")" << std::endl;
// std::cout << "Width: " << collidingTiles[i].GetW() << " Height: " << collidingTiles[i].GetH() << std::endl;
// }
return collidingTiles;
}
示例14: IsColliding
/**
* This method uses the new position of the given object,
* its previous position and the map to determine whether
* the object is colliding with the walls
*/
bool MovementMap::IsColliding(const Rect box)
{
// // Checks the center
// if (!IsZero(box.Center().GetX(), box.Center().GetY())) return true;
// Checks the above limit
if (!IsZero(box.GetX()+box.GetW()/2, box.GetY())) return true;
// Checks the right limit
if (!IsZero(box.GetX() + box.GetW(), box.GetY() + box.GetH()/2)) return true;
// Checks the left limit
if (!IsZero(box.GetX(), box.GetY()+box.GetH()/2)) return true;
// Checks the upper-right limit
if (!IsZero(box.GetX()+box.GetW(), box.GetY())) return true;
// Checks the upper-left limit
if (!IsZero(box.GetX(), box.GetY())) return true;
// Checks the lower limit
if (!IsZero(box.Center().GetX(), box.Center().GetY() + box.GetH()/2)) return true;
// Checks the lower-right limit
if (!IsZero(box.GetX()+box.GetW(), box.GetY()+box.GetH())) return true;
// Checks the lower-left limit
if (!IsZero(box.GetX(), box.GetY()+box.GetH())) return true;
return false;
// return IsCollidingWithGround(box);
}
示例15: TableDice
void TableSkin::TableDice( const Rect &bound, int x1, int x2, int x3, int y1, int y2, int y3, bool no_interrior)
{
AssocVector<int ,Rect> assoc_rects;
Pos p0;// = bound.GetPos();
int x[5] = { 0, x1, x2, x3, bound.GetW() };
int y[5] = { 0, y1, y2, y3, bound.GetH() };
assoc_rects.Insert( TOP+HEAD, CheckedRect( x[0], y[0], x[1]-x[0], y[1]-y[0]) +p0);
assoc_rects.Insert( TOP+BODY, CheckedRect( x[1], y[0], x[2]-x[1], y[1]-y[0]) +p0);
assoc_rects.Insert( TOP+TAIL, CheckedRect( x[3], y[0], x[4]-x[3], y[1]-y[0]) +p0);
assoc_rects.Insert( MIDDLE+HEAD, CheckedRect( x[0], y[1], x[1]-x[0], y[2]-y[1]) +p0);
if ( !no_interrior )
assoc_rects.Insert( MIDDLE+BODY, CheckedRect( x[1], y[1], x[2]-x[1], y[2]-y[1]) +p0);
assoc_rects.Insert( MIDDLE+TAIL, CheckedRect( x[3], y[1], x[4]-x[3], y[2]-y[1]) +p0);
assoc_rects.Insert( BOTTOM+HEAD, CheckedRect(x[0], y[3], x[1]-x[0], y[4]-y[3]) +p0);
assoc_rects.Insert( BOTTOM+BODY, CheckedRect(x[1], y[3], x[2]-x[1], y[4]-y[3]) +p0);
assoc_rects.Insert( BOTTOM+TAIL, CheckedRect(x[3], y[3], x[4]-x[3], y[4]-y[3]) +p0);
assoc_rects.Insert( HEAD+HDIV , CheckedRect( x[0], y[2], x[1]-x[0], y[3]-y[2]) +p0);
assoc_rects.Insert( BODY+HDIV , CheckedRect( x[1], y[2], x[2]-x[1], y[3]-y[2]) +p0);
assoc_rects.Insert( TAIL+HDIV , CheckedRect( x[3], y[2], x[4]-x[3], y[3]-y[2]) +p0);
assoc_rects.Insert( HEAD+VDIV , CheckedRect( x[2], y[0], x[3]-x[2], y[1]-y[0]) +p0);
assoc_rects.Insert( BODY+VDIV , CheckedRect( x[2], y[1], x[3]-x[2], y[2]-y[1]) +p0);
assoc_rects.Insert( TAIL+VDIV , CheckedRect( x[2], y[3], x[3]-x[2], y[4]-y[3]) +p0);
assoc_rects.Insert( CROSSING , CheckedRect( x[2], y[2], x[3]-x[2], y[3]-y[2]) +p0);
ImageDicer::Dice(assoc_rects);
SetSize( Dim2i(bound.GetW(), bound.GetH()) );
}