当前位置: 首页>>代码示例>>C++>>正文


C++ Left函数代码示例

本文整理汇总了C++中Left函数的典型用法代码示例。如果您正苦于以下问题:C++ Left函数的具体用法?C++ Left怎么用?C++ Left使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Left函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: display_tape

/*
 * display_tape() shows the local area of the tape around the head.
 */
void display_tape(int nLeft) {
    int         pos;
    static int  count = 0;

    for(pos = 0; pos < nLeft; pos++) {
        putchar(' ');
    }

    putchar('v');
    putchar('\n');

    for(pos = 0; pos < nLeft; pos++) {
        Left();
    }
    for(pos = 0; pos < 79; pos++) {
        putchar(tape->symbol);
        Right();
    }
    for(pos = 0; pos <(79 - nLeft); pos++) {
        Left();
    }

    putchar('\n');
    ++count;
}
开发者ID:jcolag,项目名称:PosTuring,代码行数:28,代码来源:post-tur.c

示例2: main

int main()
{
    COORD pos;
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    int i, leftB, rightB, upB, downB;
    leftB = 11;
    rightB = 67;
    upB = 11;
    downB = 13;
    pos.Y = 12;
    pos.X = 66;
    for (i = 0; i < 12; i++)
    {
        pos = Left (pos, leftB);
        leftB--;
        pos = Up (pos, upB);
        upB--;
        pos = Right (pos, rightB);
        rightB++;
        pos = Down (pos, downB);
        downB++;
    }
        pos = Left (pos, leftB);
        leftB--;
        if (leftB == 0)
      {
        printf("*");
      }
    pos.X = 0;
    pos.Y = 25;
    SetConsoleCursorPosition(hConsole, pos);
    SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    return 0;
}
开发者ID:Blackstee,项目名称:Blackstee,代码行数:34,代码来源:main.c

示例3: Intersects

            bool Intersects (Room &other,
                             int  *adjust_x = NULL,
                             int  *adjust_y = NULL)
            {
                if (Left() < other.Right() && Right() > other.Left() &&
                    Top() < other.Bottom() && Bottom() > other.Top()) {
                    // Intersects, find the intersection distance if required.

                    if (adjust_x != NULL) {
                        // Work out if moving left or right is shorter.
                        if (std::abs(Right() - other.Left()) >
                            std::abs(other.Right() - Left())) {
                            *adjust_x = other.Left() - Right();
                        } else {
                            *adjust_x = other.Right() - Left();
                        }
                    }
                    
                    if (adjust_y != NULL) {
                        // Work out if moving up or down is shorter.
                        if (std::abs(Bottom() - other.Top()) >
                            std::abs(other.Bottom() - Top())) {
                            *adjust_y = other.Top() - Bottom();
                        } else {
                            *adjust_y = other.Bottom() - Top();
                        }
                    }

                    return true;
                }

                return false;
            }
开发者ID:Juzley,项目名称:dungeon,代码行数:33,代码来源:generator.hpp

示例4: switch

void CCell::DrawTracker(CDC *pDC)
{
	LOGPEN tLogPen;
	tLogPen.lopnColor=RGB(0,0,0);
	tLogPen.lopnStyle=PS_DOT;
	tLogPen.lopnWidth.x=1;
	CPen tPen;
	tPen.CreatePenIndirect(&tLogPen);
	CPen *pOldPen=(CPen *)pDC->SelectObject(&tPen);
	CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH);
	pDC->SetROP2(R2_NOTXORPEN);

	long x1,y1,x2,y2;

	switch(m_lHitTarget){
	case TK_CT:
		break;
	case TK_MOV:
		UPtoLP(Left(),Top(),&x1,&y1);
		UPtoLP(Right(),Bottom(),&x2,&y2);
		pDC->Rectangle(x1,y1,x2,y2);
		MoveInCell(m_potTracker);
		UPtoLP(Left(),Top(),&x1,&y1);
		UPtoLP(Right(),Bottom(),&x2,&y2);
		pDC->Rectangle(x1,y1,x2,y2);
		break;
	}
	
	pDC->SetROP2(R2_COPYPEN);
	pDC->SelectObject(pOldPen);
	pDC->SelectObject(pOldBrush);
}
开发者ID:eseawind,项目名称:CNCS_PMC-Conductor,代码行数:32,代码来源:Cell.cpp

示例5: Collinear

bool PolyChecker::IntersectProp(const DPoint2 &a, const DPoint2 &b, const DPoint2 &c, const DPoint2 &d)
{
	if (Collinear(a, b, c) || Collinear(a, b, d) ||
		Collinear(c, d, a) || Collinear(c, d, b))
		return false;

	return Xor(Left(a, b, c), Left(a, b, d)) && Xor(Left(c, d, a), Left(c, d, b));
}
开发者ID:kamalsirsa,项目名称:vtp,代码行数:8,代码来源:PolyChecker.cpp

示例6: Left

void CSoundOptionsMenu::Right()
{
	if (!m_pRiotMenu || !m_pClientDE) return;

	CRiotClientShell* pClientShell = m_pRiotMenu->GetClientShell();
	if (!pClientShell) return;

	CRiotSettings* pSettings = m_pRiotMenu->GetSettings();
	if (!pSettings) return;

	if (m_nSelection == 0)
	{
		Left();
		return;
	}
	else if (m_nSelection == 1)
	{
		if (!pSettings->MusicEnabled())
		{
			pClientShell->DoMessageBox (IDS_NOMUSICCHANGE, TH_ALIGN_CENTER);
			return;
		}

		int nPos = m_sliderMusicVolume.GetPos();
		if (nPos == m_sliderMusicVolume.GetMax()) return;

		m_sliderMusicVolume.SetPos (nPos + 1);
		pSettings->Sound[RS_SND_MUSICVOL].nValue = (LTFLOAT)m_sliderMusicVolume.GetPos() * 10;
		pSettings->ImplementMusicVolume();
	}
	else if (m_nSelection == 2)
	{
		Left();
		return;
	}
	else if (m_nSelection == 3)
	{
		if (!pSettings->SoundEnabled())
		{
			pClientShell->DoMessageBox (IDS_NOSOUNDCHANGE, TH_ALIGN_CENTER);
			return;
		}

		int nPos = m_sliderSoundVolume.GetPos();
		if (nPos == m_sliderSoundVolume.GetMax()) return;

		m_sliderSoundVolume.SetPos (nPos + 1);
		pSettings->Sound[RS_SND_SOUNDVOL].nValue = (LTFLOAT)m_sliderSoundVolume.GetPos() * 9;
		pSettings->ImplementSoundVolume();
	}
	else if (m_nSelection == 4)
	{
		Left();
		return;
	}
	
	CBaseMenu::Right();
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:58,代码来源:SoundOptionsMenu.cpp

示例7: Height

//---------------------------------------------------------------------------//
// DerivDraw
//
//---------------------------------------------------------------------------//
void CMGTreeView::DerivDraw()
{
  int Offset = m_ScrollBar->IsVisible() ? (int)(m_ScrollBar->GetPos() * (m_Root->GetTotalHeight() - Height() + 4)) : 0;
  g_pMGDD->FillRect(TRect(Left()+1, Top()+1, Width()-2, Height()-2), g_pMGDD->Skin()->Color(COL_EDIT_BG));
  g_pMGDD->Rect(TRect(Left()+1, Top()+1, Width()-2, Height()-2), g_pMGDD->Skin()->Color(COL_EDIT_BORDER));
  g_pMGDD->SetClipRect(TRect(Left()+2, Top()+6, Width()-4, Height()-8));
  m_Root->Draw(Offset);
  g_pMGDD->SetClipRect();
}
开发者ID:EQ4,项目名称:neonv2,代码行数:13,代码来源:MGTreeView.cpp

示例8: display

	App::PointInt Viewer::calculateWindowTopLeft(ResizePositionMethod method, const SizeInt &newSize ) {
		wxDisplay display(DisplayFromPointFallback(PositionScreen()));
		auto rtDesktop = wxToRect(display.GetClientArea());

		switch (method) {
		case ResizePositionMethod::PositionToScreen:
			return rtDesktop.TopLeft() + RoundCast((rtDesktop.Dimensions() - newSize) * 0.5f);

		case ResizePositionMethod::PositionToCurrent:
			{
				auto pt = AnchorCenter() + RoundCast(newSize * -0.5f);
				if ((pt.X + newSize.Width) > rtDesktop.Right()) {
					pt.X = rtDesktop.Right() - newSize.Width;
				}
				else if (pt.X < rtDesktop.Left()) {
					pt.X = rtDesktop.Left();
				}

				if (pt.Y + newSize.Height > rtDesktop.Bottom()) {
					pt.Y = rtDesktop.Bottom() - newSize.Height;
				}
				else if (pt.Y < rtDesktop.Top()) {
					pt.Y = rtDesktop.Top();
				}

				AnchorTL(pt);

				return pt;
			}

		case ResizePositionMethod::PositionNothing:
			{
				// Cap to screen
				PointInt pt = AnchorTL();

				if ((pt.X + newSize.Width) > rtDesktop.Right())
					pt.X=rtDesktop.Right()-newSize.Width;
				else if (pt.X < rtDesktop.Left())
					pt.X = rtDesktop.Left();

				if ((pt.Y + newSize.Height) > rtDesktop.Bottom())
					pt.Y=rtDesktop.Bottom()-newSize.Height;
				else if (pt.Y < rtDesktop.Top())
					pt.Y=rtDesktop.Top();

				AnchorCenter(pt + RoundCast(newSize * 0.5f));

				return pt;
			}

		default:
			DO_THROW(Err::InvalidParam, "Invalid reposition method: " + ToAString(method));
		}
	}
开发者ID:poppeman,项目名称:Pictus,代码行数:54,代码来源:viewer.cpp

示例9: Flush

	virtual void Flush(void)
	{
		if (!Active() || !m_fb)
			return;

		if (IsTrueColor())
		{
			LOCK_PIXMAPS;
			while (cPixmapMemory *pm =
					dynamic_cast<cPixmapMemory *>(RenderPixmaps()))
			{
				const uint8_t *src = pm->Data();
				char *dst = m_fb + (Left() + pm->ViewPort().Left()) *
						(m_vinfo.bits_per_pixel / 8 ) +
						(Top() + pm->ViewPort().Top()) * m_finfo.line_length;

				for (int y = 0; y < pm->DrawPort().Height(); y++)
				{
					memcpy(dst, src, pm->DrawPort().Width() * sizeof(tColor));
					src += pm->DrawPort().Width() * sizeof(tColor);
					dst += m_finfo.line_length;
				}
#if APIVERSNUM >= 20110
				DestroyPixmap(pm);
#else
				delete pm;
#endif
			}
		}
		else
		{
			for (int i = 0; cBitmap *bitmap = GetBitmap(i); ++i)
			{
				int x1, y1, x2, y2;
				if (bitmap->Dirty(x1, y1, x2, y2))
				{
					char *dst = m_fb + (Left() + bitmap->X0() + x1) *
							(m_vinfo.bits_per_pixel / 8 ) +
							(Top() + bitmap->Y0() + y1) * m_finfo.line_length;

					for (int y = y1; y <= y2; ++y)
					{
						tColor *p = (tColor *)dst;
						for (int x = x1; x <= x2; ++x)
							*p++ = bitmap->GetColor(x, y);

						dst += m_finfo.line_length;
					}
					bitmap->Clean();
				}
			}
		}
	}
开发者ID:vitmod,项目名称:vdr-plugin-amlhddevice1,代码行数:53,代码来源:fbosd.c

示例10: Top

//---------------------------------------------------------------------------//
// DerivDraw
//
//---------------------------------------------------------------------------//
void CMGHotKey::DerivDraw()
{
  string text = "None";
  if (m_Char >= 0)
  {
    text = "";
    //if (m_Ctrl ) text = "Ctrl + ";
    //if (m_Shift) text+= "Shift + ";
    text+= m_Char;
  }
  
  if (IsFocused())
  {
    g_pMGDD->Rect    (TRect(Left(),   Top(),   Width(),   20), g_pMGDD->Skin()->Color(COL_EDIT_BORDER_ACTIVE));
    g_pMGDD->FillRect(TRect(Left()+1, Top()+1, Width()-2, 18), g_pMGDD->Skin()->Color(COL_EDIT_BG_ACTIVE));
    g_pMGDD->SetClipRect(TRect(Left()+1, Top()+1, Width()-2, Height()-2));
    g_pMGDD->TextDraw   (FONT_NORMAL, Left()+3, Top(), 0,20, CMGFont::LEFT, CMGFont::VCENTER, g_pMGDD->Skin()->Color(COL_FONT_EDIT_ACTIVE), text);
    g_pMGDD->SetClipRect();
  }
  else
  {
    g_pMGDD->Rect    (TRect(Left(),   Top(),   Width(),   20), g_pMGDD->Skin()->Color(COL_EDIT_BORDER));
    g_pMGDD->FillRect(TRect(Left()+1, Top()+1, Width()-2, 18), g_pMGDD->Skin()->Color(COL_EDIT_BG));
    g_pMGDD->SetClipRect(TRect(Left()+1, Top()+1, Width()-2, Height()-2));
    g_pMGDD->TextDraw   (FONT_NORMAL, Left()+3, Top(), 0,20, CMGFont::LEFT, CMGFont::VCENTER, g_pMGDD->Skin()->Color(COL_FONT_EDIT), text);
    g_pMGDD->SetClipRect();
  }
}
开发者ID:EQ4,项目名称:neonv2,代码行数:32,代码来源:MGHotKey.cpp

示例11: IntersectProp

/*---------------------------------------------------------------------
Returns true iff ab properly intersects cd: they share
a point interior to both segments.  The properness of the
intersection is ensured by using strict leftness.
---------------------------------------------------------------------*/
bool	IntersectProp( tPointi a, tPointi b, tPointi c, tPointi d )
{
   /* Eliminate improper cases. */
   if (
      Collinear(a,b,c) ||
      Collinear(a,b,d) ||
      Collinear(c,d,a) ||
      Collinear(c,d,b)
      )
      return FALSE;

   return
         Xor( Left(a,b,c), Left(a,b,d) )
      && Xor( Left(c,d,a), Left(c,d,b) );
}
开发者ID:Bmcentee148,项目名称:C-Programming,代码行数:20,代码来源:tri.c

示例12: ASSERT

TBool CPage::KeyEvent(int aKeyCode)
{
	ASSERT(iLayout);
	TBool result = ETrue;
	switch(aKeyCode)
	{
	case EKeyDevice3:
		Execute();
		break;

	case EKeyLeftArrow:
		Left();
		break;

	case EKeyRightArrow:
		Right();
		break;

	case EKeyUpArrow:
		Up();
		break;

	case EKeyDownArrow:
		Down();
		break;

	default:
		result = EFalse;
		break;
	}
	return result;
}
开发者ID:flaithbheartaigh,项目名称:wapbrowser,代码行数:32,代码来源:Page.cpp

示例13: SwapContents

void LeftistHeap::Merge (MergeablePriorityQueue& queue)
{
    LeftistHeap& arg = dynamic_cast<LeftistHeap&> (queue);
    if (IsEmpty ())
	SwapContents (arg);
    else if (!arg.IsEmpty ())
    {
	if (*key > *arg.key)
	    SwapContents (arg);
	Right ().Merge (arg);
	if (Left ().nullPathLength < Right ().nullPathLength)
	    Swap (left, right);
	nullPathLength = 1 + Min (Left ().nullPathLength,
	    Right ().nullPathLength);
    }
}
开发者ID:lbaby,项目名称:codeGarden,代码行数:16,代码来源:LeftistHeap.cpp

示例14: ToStruct

 void ToStruct(JOYSTICK_FEATURE& feature) const
 {
     feature.name = new char[m_name.length() + 1];
     feature.type = m_type;
     switch (m_type)
     {
     case JOYSTICK_FEATURE_TYPE_SCALAR:
         Primitive().ToStruct(feature.scalar.primitive);
         break;
     case JOYSTICK_FEATURE_TYPE_ANALOG_STICK:
         Up().ToStruct(feature.analog_stick.up);
         Down().ToStruct(feature.analog_stick.down);
         Right().ToStruct(feature.analog_stick.right);
         Left().ToStruct(feature.analog_stick.left);
         break;
     case JOYSTICK_FEATURE_TYPE_ACCELEROMETER:
         PositiveX().ToStruct(feature.accelerometer.positive_x);
         PositiveY().ToStruct(feature.accelerometer.positive_y);
         PositiveZ().ToStruct(feature.accelerometer.positive_z);
         break;
     case JOYSTICK_FEATURE_TYPE_MOTOR:
         Primitive().ToStruct(feature.motor.primitive);
         break;
     default:
         break;
     }
     std::strcpy(feature.name, m_name.c_str());
 }
开发者ID:bas-t,项目名称:xbmc,代码行数:28,代码来源:kodi_peripheral_utils.hpp

示例15: CollisionBoundingBox

	// Collision
	bool Sprite::CollisionBoundingBox(System::Graphics::Sprite* Other, int offset){
		if (Bottom() - Other->Top() <= offset) return false;
		if (Other->Bottom() - Top() <= offset) return false;
		if (Right() - Other->Left() <= offset) return false;
		if (Other->Right() - Left() <= offset) return false;
		return true;
	}
开发者ID:RobLoach,项目名称:Blastoids,代码行数:8,代码来源:sprite.cpp


注:本文中的Left函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。