本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
示例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();
}
示例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();
}
示例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));
}
}
示例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();
}
}
}
}
示例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();
}
}
示例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) );
}
示例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;
}
示例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);
}
}
示例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());
}
示例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;
}