本文整理匯總了C++中DrawRect函數的典型用法代碼示例。如果您正苦於以下問題:C++ DrawRect函數的具體用法?C++ DrawRect怎麽用?C++ DrawRect使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DrawRect函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: DrawRect
void CDDrawRecord::ClearScreen(DWORD color)
{
DrawRect(color, NULL, lpDDSBack);
}
示例2: drawRect
Drawing drawRect( const QPen & pen, const QBrush & brush, const QRectF & rect )
{
return DrawRect( pen, brush, rect );
}
示例3: DrawRect
void AeroControlBase::DrawFocusRect(LPRECT prcFocus, HDC hdcPaint)
{
DrawRect(prcFocus, hdcPaint, DashStyleDot, Color(0xFF, 0,0,0), 1.0);
}
示例4: EraseRect
void RingDragger::Drag(int xMouse,int yMouse)
{
EraseRect(xMouse,yMouse);
DrawRect(m_width);
}
示例5: White
void FormView::Paint(Draw& w)
{
if (!IsLayout())
{
w.DrawRect(GetRect(), White());
return;
}
Rect r = Zoom(GetPageRect());
DrawGrid(w);
DrawRect(w, r, 1, LtBlue());
w.DrawRect(0, 0, r.left, 3000, White());
w.DrawRect(r.right + 1, 0, 3000, 3000, White());
w.DrawRect(r.left, 0, 5000, r.top, White());
w.DrawRect(r.left, r.bottom + 1, 3000, 3000, White());
// if (_showInfo)
// {
// r.SetSize( Zoom(Size(804, 604)) );
// DrawRect(w, r.Offseted( Zoom(Size(-2, -2)) ), 1, LtMagenta());
// r = Zoom(GetPageRect());
// }
if (GetObjectCount() > 0 && _showInfo == 2)
{
Rect b = Zoom(GetObjectsRect()).Offseted(1, 1);
b.SetSize( b.GetSize() + Size(-2, -2) );
DrawRect(w, b, 1, Yellow());
}
Vector<int> sel = GetSelected();
bool coloring = GetBool("View.Coloring");
int ci = 0;
if (sel.GetCount() > 0)
{
if (sel.GetCount() == 1)
{
for (int i = 0; i < GetObjectCount(); ++i)
{
if (ci++ == _colors.GetCount() - 1) ci = 0;
if (coloring && i != sel[0])
DrawObject(w, i, _colors[ci], false);
else
DrawObject(w, i, (!coloring && (i == sel[0])) ? _colors[ci] : LtGray(),
i == sel[0]);
}
}
else
{
for (int i = 0; i < GetObjectCount(); ++i)
{
if (ci++ == _colors.GetCount() - 1) ci = 0;
bool found = false;
for (int j = 0; j < sel.GetCount(); ++j)
if ( i == sel[j])
{
found = true;
break;
}
if (coloring && !found)
DrawObject(w, i, _colors[ci], false);
else
DrawObject(w, i, (!coloring && found) ? _colors[ci] : LtGray(), false);
}
Size g = GetGridSize();
Rect s = GetSelectionRect().Offseted(-g.cx / 2, -g.cy / 2);
s.SetSize(s.GetSize() + Size(g.cx, g.cy));
Vector<int> sel = GetSelected();
bool a1 = true; // allow horz align
bool a2 = true; // allow vert align
dword f1; // first horz align
dword f2; // first vert align
for (int i = 0; i < sel.GetCount(); ++i)
{
FormObject *pI = GetObject(sel[i]);
if (!pI) continue;
if (i == 0) { f1 = pI->GetHAlign(); f2 = pI->GetVAlign(); }
if (f1 != pI->GetHAlign()) { a1 = false; }
if (f2 != pI->GetVAlign()) { a2 = false; }
}
DrawSprings(w, Zoom(s), f1, f2, a1, a2, a1, a2, false);
DrawRect(w, Zoom(s), 1, LtRed());
s = GetSelectionRect().Offseted(-g.cx, -g.cy);
s.SetSize(s.GetSize() + Size(g.cx * 2, g.cy * 2));
DrawGroupTools(w, Zoom(s));
}
//.........這裏部分代碼省略.........
示例6: temp
//---------------------------------------------------------------------------
void TRForm::HandleSelRect(int X ,int Y)
{
TPoint temp(X ,Y);
temp -= leftDownPt;
switch(Image1->Cursor)
{
case TCursor(crSizeAll_): // crSizeAll
{
DrawRect(originPt, movePt, pmNotXor);
//DrawRect(Point(selectedRt.left,selectedRt.top) ,
// Point(selectedRt.right,selectedRt.bottom) , pmNotXor);
// 重新構造originPt movePt,左上角,右下角
originPt = TPoint(selectedRt.left,selectedRt.top);
originPt += temp;
movePt = TPoint(selectedRt.right,selectedRt.bottom);
movePt += temp;
DrawRect(originPt, movePt, pmNotXor);
break;
}
case TCursor(crSizeNWSE_): //crSizeNWSE
{
if(selectdPos==epLeftUp)
{
//ShowMessage("selectdPos==epLeftUp");
DrawRect(originPt, movePt, pmNotXor);
originPt = TPoint(selectedRt.right,selectedRt.bottom);
movePt = TPoint(selectedRt.left,selectedRt.top);
movePt += temp;
DrawRect(originPt, movePt, pmNotXor);
}
else
{
DrawRect(originPt, movePt, pmNotXor);
originPt = TPoint(selectedRt.left,selectedRt.top);
movePt = TPoint(selectedRt.right,selectedRt.bottom);
movePt += temp;
DrawRect(originPt, movePt, pmNotXor);
}
break;
}
case TCursor(crSizeNESW_): // crSizeNESW
{
if(selectdPos==epLeftDown)
{
//ShowMessage("selectdPos==epLeftUp");
DrawRect(originPt, movePt, pmNotXor);
originPt = TPoint(selectedRt.right,selectedRt.top);
movePt = TPoint(selectedRt.left,selectedRt.bottom);
movePt += temp;
DrawRect(originPt, movePt, pmNotXor);
}
else
{
DrawRect(originPt, movePt, pmNotXor);
originPt = TPoint(selectedRt.left,selectedRt.bottom);
movePt = TPoint(selectedRt.right,selectedRt.top);
movePt += temp;
DrawRect(originPt, movePt, pmNotXor);
}
break;
}
case crCross:
{
/*------ */
break;
}
case TCursor(crCursor_):
break;
default :
break;
}
}
示例7: lineStart
void MyApp::DrawSingleMode()
{
FvRobotClientAppPtr spApp = FvRobotMainApp::Instance().GetRobotInSingleMode();
int lineStart(LINE_START);
int lineStep(LINE_STEP);
//! 顯示地圖信息
DrawString(0, lineStart, CLR_WHITE, "-------Single Mode-------");
lineStart += lineStep;
DrawString(0, lineStart, CLR_WHITE, "ShowHelpInfo: H");
lineStart += lineStep;
if(!spApp)
{
DrawString(0, lineStart, CLR_WHITE, "Err: No Selected Robot");
lineStart += lineStep;
return;
}
if(1)
{
DrawString(0, lineStart, CLR_WHITE, "ServerTime:%.1f", spApp->GetServerConnection()->ServerTime());
lineStart += lineStep;
DrawString(0, lineStart, CLR_WHITE, "ServerToDScaling:%.2f,ServerToD:%.2f", spApp->GetToDScaling(), spApp->GetToD());
lineStart += lineStep;
DrawString(0, lineStart, CLR_WHITE, "SpaceID:%d, Type:%d, RobotID:%d", spApp->SpaceID(), spApp->SpaceType(), spApp->RobotID());
lineStart += lineStep;
//! 顯示Space
const FvRobotMainApp::SpaceInfo* pkSpaceInfo = FvRobotMainApp::Instance().FindSpaceInfo(spApp->SpaceType());
if(!pkSpaceInfo)
{
DrawString(0, lineStart, CLR_WHITE, "Err:No Space Info");
lineStart += lineStep;
return;
}
else
{
if(m_bResetWindow4Space)
{
m_bResetWindow4Space = false;
SetWindowFit2Rect(pkSpaceInfo->kSpaceRect);
}
for(int i=0; i<(int)pkSpaceInfo->kCells.size(); ++i)
{
DrawRect(pkSpaceInfo->kCells[i], CLR_YELLOW);
}
DrawRect(pkSpaceInfo->kSpaceRect, CLR_YELLOW);
}
//! 顯示實體
if(1)
{
const FvRobotClientApp::EntityMap& kEntityMap = spApp->GetEntityMap();
//! 顯示實體數量
DrawString(0, lineStart, CLR_WHITE, "Entities:%d", kEntityMap.size());
lineStart += lineStep;
FvRobotClientApp::EntityMap::const_iterator itrB = kEntityMap.begin();
FvRobotClientApp::EntityMap::const_iterator itrE = kEntityMap.end();
while(itrB != itrE)
{
FvEntity* pkEntity = itrB->second;
p2Clr clr;
const FvVector3& p3 = pkEntity->GetPos();
FvVector2 p2(p3.x, p3.y);
int x,y;
char charID[32] = {0};
char robotID[32] = {0};
char charPos[64] = {0};
bool bConvertPos(false);
if(m_bShowEntityID)
{
bConvertPos = true;
sprintf(charID, "%d", pkEntity->GetEntityID());
}
if(m_bShowRobotID)
{
bConvertPos = true;
sprintf(robotID, "%d", pkEntity->GetRobotID());
}
if(m_bShowEntityPos)
{
bConvertPos = true;
sprintf(charPos, "%.2f,%.2f,%.2f", p3.x, p3.y, p3.z);
}
if(bConvertPos)
{
ConvertWorldToScreen(p2, x, y);
}
if(pkEntity->IsCtrler())//! ctrler
{
clr = CLR_RED;
DrawPoint(p3, clr);
if(m_bShowEntityID)
{
DrawString(x, y, clr, charID);
}
//.........這裏部分代碼省略.........
示例8: FillRect
void TextInput::Draw( Rect area )
{
FillRect( Bounds(), 0x888888 );
DrawRect( Bounds(), 0x999999 );
DrawString( 2,2, m_text, 0 );
}
示例9: Update
void Car::Draw()
{
Update();
if (yDraw < (float)(y - 1) || yDraw >(float)(y + 1))
{
yDraw += ((float)y - yDraw) / 10.0f;
}
int yInt = (int)yDraw;
if (mode == 'n' && y <= -200)
{
DrawRect(x, y, 122, 135, color.r, color.g, color.b);
if (btnBubble->ClickedOnThisFrame() && gPause)
{
mode = 'w';
chargeCurrent = 0.0;
timeDue = gTime + addTime;
active = false;
}
btnBubble->Draw();
}
else
{
active = true;
//sprite->Draw(x, yInt);
DrawRect(x, yInt, 122, 192, color.r, color.g, color.b);
text->Draw(x + 5, yInt + 10, "Chrg: " + std::to_string(((int)chargeCurrent)) + "%");
text->Draw(x + 5, yInt + 25, "ChrgRate: " + std::to_string((int)(chargeRate*gFramesToSeconds)) + "ps");
text->Draw(x + 5, yInt + 50, "TimeWait: " + SecondsToTime(waitTime));
if (timeDue + GetChargeTime() >= gTime) text->Draw(x + 5, yInt + 80, "TimeToCh: " + ToTime(GetChargeTime()), 0, 150, 0);
else text->Draw(x + 5, yInt + 80, "TimeToCh: " + ToTime(GetChargeTime()), 150, 0, 0);
if (timeDue >= gTime) text->Draw(x + 5, yInt + 95, "TimeDue: " + SecondsToTime(timeDue), 0, 225, 0);
else text->Draw(x + 5, yInt + 95, "TimeDue: " + SecondsToTime(timeDue), 225, 0, 0);
//text->Draw(x + 20, yInt + 30, "Max: " + std::to_string((int)(chargeMax)) + "kWh");
//text->Draw(x + 20, yInt + 110, "Use: " + std::to_string((int)(chargeUse*100.0f)) + "pf");
std::string bar = "";
for (unsigned i = 0; i < (int)chargeCurrent; i += 10)
{
bar += "|";
}
text->Draw(x + 24, yInt + 140, bar, 0, 200, 0);
if (gPause)
{
btnReturn->y = yInt + 160;
btnReturn->Draw();
}
if (btnReturn->ClickedOnThisFrame() && gPause)
{
Reset();
}
if (gPause)
{
btnL1->y = yInt + 75;
btnR1->y = yInt + 75;
btnL2->y = yInt + 92;
btnR2->y = yInt + 92;
if (btnL1->Clicked())
{
if (GetChargeTime() > 0.01)
{
chargeRate += 0.0005;
}
}
if (btnR1->Clicked())
{
if (chargeRate > 0.005)
{
chargeRate -= 0.0005;
if (timeDue < gTime + GetMaxChargeTime() + 1)
{
addTime = GetMaxChargeTime() + 1;
timeDue = gTime + addTime;
}
}
}
if (btnR2->Clicked())
{
addTime += 0.1;
timeDue = gTime + addTime;
}
//.........這裏部分代碼省略.........
示例10: DrawRect
NS_IMETHODIMP
nsThebesRenderingContext::DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
DrawRect(nsRect(aX, aY, aWidth, aHeight));
return NS_OK;
}
示例11: DrawRect
void Renderer::DrawRect(const Vector2D& lefttop, const Vector2D& rightbottom, float lineWidth)
{
DrawRect(Rect2D(lefttop, rightbottom), lineWidth);
}
示例12: WatchJoystick
//.........這裏部分代碼省略.........
break;
case SDL_JOYBALLMOTION:
printf("Joystick %d ball %d delta: (%d,%d)\n",
event.jball.which,
event.jball.ball, event.jball.xrel, event.jball.yrel);
break;
case SDL_JOYBUTTONDOWN:
printf("Joystick %d button %d down\n",
event.jbutton.which, event.jbutton.button);
break;
case SDL_JOYBUTTONUP:
printf("Joystick %d button %d up\n",
event.jbutton.which, event.jbutton.button);
break;
case SDL_KEYDOWN:
if ((event.key.keysym.sym != SDLK_ESCAPE) &&
(event.key.keysym.sym != SDLK_AC_BACK)) {
break;
}
/* Fall through to signal quit */
case SDL_FINGERDOWN:
case SDL_MOUSEBUTTONDOWN:
case SDL_QUIT:
done = SDL_TRUE;
break;
default:
break;
}
}
/* Update visual joystick state */
SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE);
for (i = 0; i < SDL_JoystickNumButtons(joystick); ++i) {
if (SDL_JoystickGetButton(joystick, i) == SDL_PRESSED) {
DrawRect(screen, (i%20) * 34, SCREEN_HEIGHT - 68 + (i/20) * 34, 32, 32);
}
}
SDL_SetRenderDrawColor(screen, 0xFF, 0x00, 0x00, SDL_ALPHA_OPAQUE);
for (i = 0; i < SDL_JoystickNumAxes(joystick); ++i) {
/* Draw the X/Y axis */
int x, y;
x = (((int) SDL_JoystickGetAxis(joystick, i)) + 32768);
x *= SCREEN_WIDTH;
x /= 65535;
if (x < 0) {
x = 0;
} else if (x > (SCREEN_WIDTH - 16)) {
x = SCREEN_WIDTH - 16;
}
++i;
if (i < SDL_JoystickNumAxes(joystick)) {
y = (((int) SDL_JoystickGetAxis(joystick, i)) + 32768);
} else {
y = 32768;
}
y *= SCREEN_HEIGHT;
y /= 65535;
if (y < 0) {
y = 0;
} else if (y > (SCREEN_HEIGHT - 16)) {
y = SCREEN_HEIGHT - 16;
}
DrawRect(screen, x, y, 16, 16);
}
示例13: CheckBox_Paint
//----CheckBox繪製函數----------------------------------------------------------
//功能:這是CheckBox控件的MSG_PAINT消息響應函數
//參數:pMsg,消息指針
//返回:固定true
//-----------------------------------------------------------------------------
static bool_t CheckBox_Paint(struct WindowMsg *pMsg)
{
HWND hwnd;
HDC hdc;
RECT rc;
RECT rc0;
hwnd=pMsg->hwnd;
hdc =BeginPaint(hwnd);
if(NULL!=hdc)
{
GetClientRect(hwnd,&rc0);
SetTextColor(hdc,RGB(1,1,1));
SetDrawColor(hdc,RGB(40,40,40));
SetFillColor(hdc,RGB(200,200,200));
FillRect(hdc,&rc0);
if(hwnd->Style&CBS_SELECTED)
{
CopyRect(&rc,&rc0);
rc.right =rc.left+RectH(&rc0);
InflateRect(&rc,-2,-2);
SetDrawColor(hdc,RGB(70,70,70));
DrawRect(hdc,&rc);
InflateRect(&rc,-1,-1);
SetDrawColor(hdc,RGB(110,110,110));
DrawRect(hdc,&rc);
InflateRect(&rc,-1,-1);
SetFillColor(hdc,RGB(240,240,240));
FillRect(hdc,&rc);
InflateRect(&rc,-4,-4);
SetDrawColor(hdc,RGB(150,150,240));
DrawRect(hdc,&rc);
InflateRect(&rc,-1,-1);
SetDrawColor(hdc,RGB(100,100,220));
DrawRect(hdc,&rc);
InflateRect(&rc,-1,-1);
SetFillColor(hdc,RGB(50,50,200));
FillRect(hdc,&rc);
}
else
{
CopyRect(&rc,&rc0);
rc.right =rc.left+RectH(&rc0);
InflateRect(&rc,-2,-2);
SetDrawColor(hdc,RGB(100,100,100));
DrawRect(hdc,&rc);
InflateRect(&rc,-1,-1);
SetDrawColor(hdc,RGB(160,160,160));
DrawRect(hdc,&rc);
InflateRect(&rc,-1,-1);
SetFillColor(hdc,RGB(220,220,220));
FillRect(hdc,&rc);
}
CopyRect(&rc,&rc0);
InflateRectEx(&rc,-RectH(&rc),0,0,0);
DrawText(hdc,hwnd->Text,-1,&rc,DT_LEFT|DT_VCENTER);
EndPaint(hwnd,hdc);
}
return true;
}
示例14: switch
void enemyS::Draw(int tex_id, int tex_id_bala, int estat)
{
float xo = 0.0f, yo = 0.0f, xf = 0.0f, yf = 0.0f;
char psentit = 'X';
if (estat == 0) {
switch (GetState())
{
//1
case STATE_LOOKLEFT: xo = 0.0f; yo = 0.0f;
psentit = 'L';
break;
//4
case STATE_LOOKRIGHT: xo = 0.0f; yo = 0.0f;
psentit = 'R';
break;
//1..3
//11 sprites en dues files 1/11=0.0909
case STATE_WALKLEFT: xo = 0.093f + (GetFrame()*0.0909f);
if (xo > 0.92f) yo = 0.5f;
psentit = 'L';
NextFrame(22);
break;
//4..6
case STATE_WALKRIGHT: xo = 0.093f + (GetFrame()*0.0909f);
if (xo > 0.92f) yo = 0.5f;
psentit = 'R';
NextFrame(22);
break;
}
xf = xo + 0.0909f;
yf = yo + 0.5f;
if (psentit == 'L') {
DrawRect(tex_id, xo, yo, xf, yf, psentit, false);
for (int i = 0; i < 100; ++i) {
if (i <= aaa) {
DrawRectBullet(psentit, tex_id_bala, i);
}
}
if (aaa < 99) {
if (GetFrame() == 1) bL = true;
if (bL && GetFrame() != 1) {
aaa = aaa + 1;
bL = false;
}
}
else aaa = 0;
}
else {
DrawRect(tex_id, xo, yo, xf, yf, psentit, false);
for (int i = 0; i < 100; ++i) {
if (i <= bbb) {
DrawRectBullet(psentit, tex_id_bala, i);
}
}
if (bbb < 99) {
if (GetFrame() == 1) bR = true;
if (bR && GetFrame() != 1) {
bbb = bbb + 1;
bR = false;
}
}
else bbb = 0;
}
}
else if (estat == 1) { //mort
if (GetFrame() == 5) {
xo = 0.833333f;
xf = 1.0f;
yo = 0.0f;
yf = 1.0f;
switch (GetState())
{
case STATE_LOOKLEFT:
psentit = 'L';
break;
case STATE_LOOKRIGHT:
psentit = 'R';
break;
case STATE_WALKLEFT:
psentit = 'L';
break;
case STATE_WALKRIGHT:
psentit = 'R';
break;
}
}
else {
switch (GetState())
{
case STATE_LOOKLEFT: xo = 0.0f; yo = 0.0f;
psentit = 'L';
break;
case STATE_LOOKRIGHT: xo = 0.0f; yo = 0.0f;
psentit = 'R';
break;
//1/6=0.16667
case STATE_WALKLEFT: xo = 0.16667f + (GetFrame()*0.16667f);
//.........這裏部分代碼省略.........
示例15: ATLASSERT
//------------------------------------------------------
BOOL CRectTracker::TrackHandle( HWND hWnd, const LPPOINT point, int HitTest )
{
ATLASSERT(point);
if ((HitTest != hitBegin) && (HitTest != hitEnd) && (HitTest != hitMiddle))
return FALSE;
if (!IsValidPos())
return FALSE;
// set mouse cursor parameters
RECT CursorRect;
if (IsRectEmpty(&ValidRect))
{
GetClientRect(hWnd, &CursorRect);
}
else
{
// valid rectangle is not empty
if (HitTest == hitMiddle)
{
RECT BeginRect = ValidRect;
OffsetRect(&BeginRect, point->x, point->y);
OffsetRect(&BeginRect, -CurPos.Begin.x, -CurPos.Begin.y);
NormalizeRect(&BeginRect);
RECT EndRect = ValidRect;
OffsetRect(&EndRect, point->x, point->y);
OffsetRect(&EndRect, -CurPos.End.x, -CurPos.End.y);
NormalizeRect(&EndRect);
CursorRect = ValidRect;
IntersectRect(&CursorRect, &CursorRect, &BeginRect);
IntersectRect(&CursorRect, &CursorRect, &EndRect);
}
else
CursorRect = ValidRect;
};
if (IsRectEmpty(&CursorRect))
return FALSE;
ClientToScreen(hWnd, (LPPOINT)&CursorRect );
ClientToScreen(hWnd, ((LPPOINT)&CursorRect)+1 );
ClipCursor(&CursorRect);
SetCapture(hWnd);
// get DC for drawing
HDC dc = GetDC(hWnd);
// set dc parameters
HPEN LinePen = CreatePen( PS_SOLID, LineWidth, CLR_WHITE );
HPEN hOldPen = (HPEN)SelectObject(dc, LinePen);
SetROP2(dc, R2_XORPEN );
KLinePos OriginalPos = CurPos;
BOOL bCanceled = FALSE;
// draw the rectangle for the first time
DrawRect(dc, &CurPos.Begin, &CurPos.End);
// get messages until capture lost or cancelled/accepted
BOOL bExit = FALSE;
KLinePos NewPos;
while (!bExit)
{
MSG msg;
BOOL b = ::GetMessage(&msg, NULL, 0, 0);
ATLASSERT(b);
if (GetCapture() != hWnd)
break; // exit loop
switch (msg.message)
{
// handle movement/accept messages
case WM_LBUTTONUP:
case WM_MOUSEMOVE:
{
NewPos = CurPos;
POINT MousePoint = { (int)(short)LOWORD(msg.lParam), (int)(short)HIWORD(msg.lParam) };
switch (HitTest)
{
case hitBegin:
NewPos.Begin = MousePoint;
break;
case hitEnd:
NewPos.End = MousePoint;
break;
case hitMiddle:
NewPos.Begin.x = OriginalPos.Begin.x + (MousePoint.x-point->x);
NewPos.Begin.y = OriginalPos.Begin.y + (MousePoint.y-point->y);
NewPos.End.x = OriginalPos.End.x + (MousePoint.x-point->x);
//.........這裏部分代碼省略.........