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


C++ Rectangle函数代码示例

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


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

示例1: WndProc

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
    static BOOL fState[DIVISIONS][DIVISIONS];
    static int cxBlock,cyBlock;
    HDC hdc;
    int x,y;
    PAINTSTRUCT ps;
    POINT point;
    RECT rect;

    switch(message){
        case WM_SIZE:
            cxBlock = LOWORD(lParam)/DIVISIONS;
            cyBlock = HIWORD(lParam)/DIVISIONS;
            return 0;

        case WM_SETFOCUS:
            ShowCursor(TRUE);
            return 0;
        case WM_KILLFOCUS:
            ShowCursor(FALSE);
            return 0;

        case WM_KEYDOWN:
            GetCursorPos(&point);
            ScreenToClient(hwnd,&point);
            x = max(0,min(DIVISIONS-1,point.x/cxBlock));
            y = max(0,min(DIVISIONS-1,point.y/cyBlock));
            switch(wParam){
                case VK_UP:
                    --y;
                    break;
                case VK_DOWN:
                    ++y;
                    break;
                case VK_LEFT:
                    --x;
                    break;
                case VK_RIGHT:
                    ++x;
                    break;
                case VK_HOME:
                    x = y = 0;
                    break;
                case VK_END:
                    x = y = DIVISIONS - 1;
                    break;
                case VK_RETURN:
                case VK_SPACE:
                    SendMessage(hwnd,WM_LBUTTONDOWN,MK_LBUTTON,MAKELONG(x*cxBlock,y*cyBlock));
                    break;
            }
            x = (x+DIVISIONS)%DIVISIONS;
            y = (y+DIVISIONS)%DIVISIONS;
            point.x = x*cxBlock + cxBlock/2;
            point.y = y*cyBlock + cyBlock/2;
            ClientToScreen(hwnd,&point);
            SetCursorPos(point.x,point.y);
            return 0;

        case WM_LBUTTONDOWN:
            x = LOWORD(lParam)/cxBlock;
            y = HIWORD(lParam)/cyBlock;
            if(x<DIVISIONS && y<DIVISIONS){
                fState[x][y]^=1;
                rect.left = x*cxBlock;
                rect.top = y*cyBlock;
                rect.right = (x+1)*cxBlock;
                rect.bottom = (y+1)*cyBlock;
                InvalidateRect(hwnd,&rect,TRUE);
            }
            else
                MessageBeep(0);
            return 0;

        case WM_PAINT:
            hdc = BeginPaint(hwnd,&ps);
            for(x=0;x<DIVISIONS;++x)for(y=0;y<DIVISIONS;++y){
                Rectangle(hdc,x*cxBlock,y*cyBlock,(x+1)*cxBlock,(y+1)*cyBlock);
                if(fState[x][y]){
                    MoveToEx(hdc,x*cxBlock,y*cyBlock,NULL);
                    LineTo(hdc,(x+1)*cxBlock,(y+1)*cyBlock);
                    MoveToEx(hdc,x*cxBlock,(y+1)*cyBlock,NULL);
                    LineTo(hdc,(x+1)*cxBlock,y*cyBlock);
                }
            }
            EndPaint(hwnd,&ps);
            return 0;

        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
    }
    return DefWindowProc(hwnd,message,wParam,lParam);
}
开发者ID:tadvent,项目名称:LearningWinProgramming,代码行数:94,代码来源:Checker2.cpp

示例2: DrawPicture

void DrawPicture(HWND hWnd) {
	HDC hDc = GetDC(hWnd);

	HGDIOBJ penGray = CreatePen(NULL, 1, RGB(128, 128, 128));
	HGDIOBJ penBrown = CreatePen(NULL, 1, RGB(128, 128, 0));
	HGDIOBJ penBlack = CreatePen(NULL, 1, RGB(0, 0, 0));
	HGDIOBJ penWhite = CreateSolidBrush(RGB(255, 255, 255));

	HGDIOBJ brushSand = CreateSolidBrush(RGB(236, 223, 180));
	HGDIOBJ brushTurquoise = CreateSolidBrush(RGB(44, 192, 192));
	HGDIOBJ brushGreen = CreateSolidBrush(RGB(128, 255, 128));
	HGDIOBJ brushSwamp = CreateSolidBrush(RGB(154, 144, 114));
	HGDIOBJ brushWhite = CreateSolidBrush(RGB(255, 255, 255));

	SelectObject(hDc, penWhite);
	SelectObject(hDc, brushWhite);
	Rectangle(hDc, 150, 0, 390, 450);

	if (isDrawn) {
		int x = 150, y = 200;
		SelectObject(hDc, penGray); 
		SelectObject(hDc, brushSand);

		Rectangle(hDc, x, y, x + 240, y + 180);	//дом

		SelectObject(hDc, brushSwamp);

		Rectangle(hDc, x + 40, y - 60, x + 60, y - 20);	//труба

		POINT points[3];
		points[0].x = x;
		points[0].y = y;
		points[1].x = x + 120;
		points[1].y = y - 80;
		points[2].x = x + 240;
		points[2].y = y;

		Polygon(hDc, points, 3);	//крыша

		SelectObject(hDc, penGray); 
		SelectObject(hDc, brushTurquoise);

		Ellipse(hDc, x + 100, y - 60, x + 140, y - 20);	// окно на крыше

		SelectObject(hDc, penBlack); 

		MoveToEx(hDc, x + 100, y - 40, NULL);	// рама окна на крыше
		LineTo(hDc, x + 140, y - 40);
		MoveToEx(hDc, x + 120, y - 60, NULL);
		LineTo(hDc, x + 120, y - 20);

		SelectObject(hDc, penGray); 

		Rectangle(hDc, x + 40, y + 40, x + 100, y + 120);	//окно

		SelectObject(hDc, penBlack);

		Rectangle(hDc, x + 60, y + 60, x + 80, y + 120);	//рама

		MoveToEx(hDc, x + 40, y + 60, NULL);	// рама
		LineTo(hDc, x + 100, y + 60);

		Rectangle(hDc, x + 160, y + 60, x + 220, y + 180);	// дверь

		SelectObject(hDc, penBrown);
		SelectObject(hDc, brushGreen);

		Ellipse(hDc, x + 165, y + 115, x + 175, y + 125);	//ручка

		SelectObject(hDc, penGray); 

		Arc(hDc, x + 40, y  - 80, x + 60, y - 60, x + 40, y - 60, x + 50, y  - 80);	//дым
		Arc(hDc, x + 35, y  - 100, x + 50, y - 80, x + 50, y - 80, x + 35, y  - 100);
		Arc(hDc, x + 30, y  - 120, x + 40, y - 100, x + 40, y - 100, x + 30, y  - 120);
	}
}
开发者ID:nancy-bree,项目名称:_bsuir,代码行数:76,代码来源:Lab3.cpp

示例3: switch

LRESULT CALLBACK CLanguageSelector::LangSelectProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    static HBITMAP hbmpBackgroundTop = NULL;
    static HFONT   hTextFont = NULL;
    static CLanguageSelector * lngClass;

    switch (uMsg)
    {
    case WM_INITDIALOG:
    {
        lngClass = (CLanguageSelector *)lParam;

        LanguageList LangList = g_Lang->GetLangList();
        if (LangList.size() == 0)
        {
            EndDialog(hDlg, 0);
        }
        for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++)
        {
            int index = SendMessageW(GetDlgItem(hDlg, IDC_LANG_SEL), CB_ADDSTRING, 0, (WPARAM)Language->LanguageName.c_str());
            if (_wcsicmp(Language->LanguageName.c_str(), L"English") == 0)
            {
                SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_SETCURSEL, index, 0);
            }
        }

        int Index = SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_GETCURSEL, 0, 0);
        if (Index < 0)
        {
            SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_SETCURSEL, 0, 0);
        }

        // Use the size of the image
        hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO));
        BITMAP bmTL;
        GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);

        hTextFont = ::CreateFont
            (
            18,
            0,
            0,
            0,
            FW_NORMAL,
            0,
            0,
            0,
            DEFAULT_CHARSET,
            OUT_DEFAULT_PRECIS,
            CLIP_DEFAULT_PRECIS,
            PROOF_QUALITY,
            DEFAULT_PITCH | FF_DONTCARE,
            "Arial"
            );
        SendDlgItemMessage(hDlg, IDC_SELECT_LANG, WM_SETFONT, (WPARAM)hTextFont, TRUE);
    }
    break;
    case WM_CTLCOLORSTATIC:
    {
        HDC hdcStatic = (HDC)wParam;
        SetTextColor(hdcStatic, RGB(0, 0, 0));
        SetBkMode(hdcStatic, TRANSPARENT);
        return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH));
    }
    break;
    case WM_ERASEBKGND:
    {
        HPEN outline;
        HBRUSH fill;
        RECT rect;

        outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF);
        fill = CreateSolidBrush(0x00FFFFFF);
        SelectObject((HDC)wParam, outline);
        SelectObject((HDC)wParam, fill);

        GetClientRect(hDlg, &rect);

        Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom);
    }
    break;
    case WM_PAINT:
    {
        PAINTSTRUCT ps;

        if (BeginPaint(hDlg, &ps))
        {
            RECT rcClient;
            GetClientRect(hDlg, &rcClient);

            BITMAP bmTL_top;
            GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top);

            HDC     memdc = CreateCompatibleDC(ps.hdc);
            HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop);
            BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY);
            SelectObject(memdc, save);
            DeleteDC(memdc);

            EndPaint(hDlg, &ps);
//.........这里部分代码省略.........
开发者ID:Watilin,项目名称:project64,代码行数:101,代码来源:LanguageSelector.cpp

示例4: Clear

 void Clear() {
   Rectangle(0, 0, GetWidth(), GetHeight());
 }
开发者ID:XCSoar,项目名称:XCSoar,代码行数:3,代码来源:Canvas.hpp

示例5: TranslateMessages

LRESULT CALLBACK TranslateMessages( HWND hWnd, UINT Msg,
                               WPARAM wParam, LPARAM lParam )
{
  static POINT pts[4]=
  {
    {-5, -10}, {0, 5}, {5, -10}, {0, -190}
  }, pt;  
  INT x, y, Xc, Yc, i, j, M=500, N=500 / 2, R=100;
  DOUBLE theta, phi, z;
  HDC hDC;
  CREATESTRUCT *cs;
  PAINTSTRUCT ps;
  static INT WinW, WinH;
  static HDC hMemDCFrame, hMemDC;
  static HBITMAP hBmFrame, hBmBack, hBmAnd, hBmXor;
  RECT pRect;
  switch (Msg)
  {
  case WM_CREATE:
    cs = (CREATESTRUCT *)lParam;
    SetTimer(hWnd, 30, 10, NULL);  
    hDC = GetDC(hWnd);
    hMemDCFrame = CreateCompatibleDC(hDC);
    hMemDC = CreateCompatibleDC(hDC);
    ReleaseDC(hWnd, hDC);
    if (!LoadGlobe())
    {
      MessageBox(NULL, "Error loading globe texture", 0, MB_OK);
      exit(1);
    }
    return 0;
  case WM_SIZE:
    WinW = LOWORD(lParam);
    WinH = HIWORD(lParam);
    if (hBmFrame != NULL)
      DeleteObject(hBmFrame);    
    hDC = GetDC(hWnd);
    hBmFrame = CreateCompatibleBitmap(hDC, WinW, WinH);
    ReleaseDC(hWnd, hDC);    
    SelectObject(hMemDCFrame, hBmFrame);
    SendMessage(hWnd, WM_TIMER, 0, 0);
    return 0;    
  case WM_TIMER:  
    GetCursorPos(&pt);
    ScreenToClient(hWnd, &pt);

    GetWindowRect(hWnd, &pRect);
    Xc = (pRect.right - pRect.left) / 2;
    Yc = (pRect.bottom - pRect.top) / 2;

    SelectObject(hMemDCFrame, GetStockObject(DC_BRUSH));  
    SelectObject(hMemDCFrame, GetStockObject(NULL_PEN));
    SetDCBrushColor(hMemDCFrame, RGB(0, 0, 0));
    Rectangle(hMemDCFrame, 0, 0, WinW, WinH);

    for (i=0; i<=N; i++)
      for (j=0; j<=M; j++)
      {
        INT x1 = 0, y1 = 0;

        theta = (i * M_PI / N +  PhaseShift);
        phi = (j * 2 * M_PI / M + PhaseShift);
        R = (WinW > WinH ? WinH : WinW) / 2;
        x = (int)(sin(theta) * sin(phi) * R) + WinW / 2 ;
        y = -(int)(cos(theta) * R) + WinH / 2 ;
        z = sin(theta) * cos(phi) ;
        if (z > 0)
        {
          x1 = j * w / (M + 1);
          y1 = i * h / (N + 1);
          SetPixel(hMemDCFrame, x, y, RGB(mem[(y1 * w + x1) * 3 + 2], mem[(y1 * w + x1) * 3 + 1], mem[(y1 * w + x1) * 3]));                        
        }        
      } 
    PhaseShift  += 0.005f; 
    InvalidateRect(hWnd, NULL, FALSE);
    return 0;
  case WM_ERASEBKGND:
    return 0;
  case WM_PAINT: 
    hDC = BeginPaint(hWnd, &ps);
    BitBlt(hDC, 0, 0, WinW, WinH, hMemDCFrame, 0, 0, SRCCOPY);
    EndPaint(hWnd, &ps);
    return 0;
  case WM_DESTROY:
    if (hBmFrame != NULL)
      DeleteObject(hBmFrame);
    if (hMemDCFrame != NULL)
      DeleteDC(hMemDCFrame);
    PostQuitMessage(30);
    KillTimer(hWnd, 30);
    return 0;
  } 
  return DefWindowProc(hWnd, Msg, wParam, lParam);
}
开发者ID:IaroslavPKriuchkov,项目名称:SPR2013,代码行数:94,代码来源:T05GLOBE.C

示例6: Rectangle

Ladder::Ladder(float x, float y, float w, float h, const Sprites *s) {
	const Rectangle r = Rectangle(x, y, w, h);
	Init(r, s);
}
开发者ID:Reptarsrage,项目名称:Jetpack,代码行数:4,代码来源:Ladder.cpp

示例7: Rectangle

void PlayingState::draw(HDC& hdc)
{
	_snake.draw(hdc);
	Rectangle(hdc, _food.x, _food.y, _food.x + BLOCK_WIDTH, _food.y + BLOCK_WIDTH);
}
开发者ID:LazyOxen,项目名称:snake,代码行数:5,代码来源:playing_state.cpp

示例8: Parent

/*--------------------------------------------------------------------------*/
void PegGroup::Draw(void)
{
    #ifdef PEG_UNICODE
    PEGCHAR cTest[2] = {'E', '\0'};
    #else
    PEGCHAR cTest[] = "E";
    #endif

    if (Parent())
    {
        muColors[PCI_NORMAL] = Parent()->muColors[PCI_NORMAL];
    }
    BeginDraw();

    PegColor Color(muColors[PCI_NORMAL], muColors[PCI_NORMAL], CF_FILL);
    Rectangle(mClient, Color, 0);

    Color.Set(PCLR_LOWLIGHT, PCLR_LOWLIGHT, CF_NONE);
    
    Color.uForeground = PCLR_LOWLIGHT;
    SIGNED iTextLeft = mReal.wLeft + TextWidth(cTest, mpFont);
    SIGNED iTextRight = iTextLeft + TextWidth(mpText, mpFont) + 4;

    if(mpText)
    {
        Line(mReal.wLeft, mClient.wTop - 2, iTextLeft,
            mClient.wTop - 2, Color);
        Line(iTextRight, mClient.wTop - 2, mReal.wRight,
            mClient.wTop - 2, Color);
    }
    else
    {
        Line(mReal.wLeft, mClient.wTop - 2, mReal.wRight,
             mClient.wTop - 2, Color);
    }
    Line(mReal.wLeft, mClient.wTop - 1, mReal.wLeft,
        mReal.wBottom, Color);
    Line(mReal.wLeft + 1, mReal.wBottom - 1,
        mReal.wRight - 1, mReal.wBottom - 1, Color);
    Line(mReal.wRight - 1, mClient.wTop - 2,
        mReal.wRight - 1, mReal.wBottom - 1, Color);

    Color.uForeground = PCLR_HIGHLIGHT;
    if(mpText)
    {
        Line(mReal.wLeft + 1, mClient.wTop - 1, iTextLeft,
            mClient.wTop - 1, Color);
        Line(iTextRight, mClient.wTop - 1, mReal.wRight - 2,
            mClient.wTop - 1, Color);
    }
    else
    {
        Line(mReal.wLeft + 1, mClient.wTop - 1, mReal.wRight - 2,
             mClient.wTop - 1, Color);
    }
    Line(mReal.wLeft + 1, mClient.wTop, mReal.wLeft + 1,
        mReal.wBottom - 1, Color);
    Line(mReal.wLeft, mReal.wBottom, mReal.wRight,
        mReal.wBottom, Color);
    Line(mReal.wRight, mClient.wTop - 2, mReal.wRight,
        mReal.wBottom, Color);

    if(mpText)
    {
        if (mwStyle & AF_ENABLED)
        {
            Color.uForeground = muColors[PCI_NTEXT];
        }
        else
        {
            Color.uForeground = PCLR_LOWLIGHT;
        }
        PegPoint Put;
        Put.x = iTextLeft + 2;
        Put.y = mReal.wTop;

        DrawText(Put, mpText, Color, mpFont);
    }

    PegThing::Draw();       // to draw children
    EndDraw();
}
开发者ID:garyqinyu,项目名称:abv,代码行数:83,代码来源:pgroup.cpp

示例9: Discrete

    Term* TermFactory::create(const std::string& className,
            const std::vector<scalar>& params) const {
        int requiredParams = -1;
        if (className == Discrete().className()) {
            if ((int)params.size() % 2 == 0) {
                Discrete* term = new Discrete();
                for (int i = 0; i < (int)params.size() - 1; i += 2) {
                    term->x.push_back(params.at(i));
                    term->y.push_back(params.at(i+1));
                }
                return term;
            } else {
                std::ostringstream ex;
                ex << "[syntax error] a discrete term requires an even list of values, "
                        "but found <" << params.size() << "> values";
                throw fl::Exception(ex.str(), FL_AT);
            }
        }

        if (className == Bell().className()) {
            if ((int)params.size() >= (requiredParams = 3)) {
                return new Bell("", params.at(0), params.at(1), params.at(2));
            }
        }

        if (className == Gaussian().className()) {
            if ((int)params.size() >= (requiredParams = 2)) {
                return new Gaussian("", params.at(0), params.at(1));
            }
        }

        if (className == GaussianProduct().className()) {
            if ((int)params.size() >= (requiredParams = 4)) {
                return new GaussianProduct("", params.at(0), params.at(1), params.at(2), params.at(3));
            }
        }

        if (className == PiShape().className()) {
            if ((int)params.size() >= (requiredParams = 4)) {
                return new PiShape("", params.at(0), params.at(1), params.at(2), params.at(3));
            }
        }

        if (className == Ramp().className()) {
            if ((int)params.size() >= (requiredParams = 2)) {
                return new Ramp("", params.at(0), params.at(1));
            }
        }


        if (className == Rectangle().className()) {
            if ((int)params.size() >= (requiredParams = 2)) {
                return new Rectangle("", params.at(0), params.at(1));
            }
        }

        if (className == SShape().className()) {
            if ((int)params.size() >= (requiredParams = 2)) {
                return new SShape("", params.at(0), params.at(1));
            }
        }

        if (className == Sigmoid().className()) {
            if ((int)params.size() >= (requiredParams = 2)) {
                return new Sigmoid("", params.at(0), params.at(1));
            }
        }

        if (className == SigmoidDifference().className()) {
            if ((int)params.size() >= (requiredParams = 4)) {
                return new SigmoidDifference("", params.at(0), params.at(1), params.at(2), params.at(3));
            }
        }

        if (className == SigmoidProduct().className()) {
            if ((int)params.size() >= (requiredParams = 4)) {
                return new SigmoidProduct("", params.at(0), params.at(1), params.at(2), params.at(3));
            }
        }

        if (className == Trapezoid().className()) {
            if ((int)params.size() >= (requiredParams = 4))
                return new Trapezoid("", params.at(0), params.at(1), params.at(2), params.at(3));
        }

        if (className == Triangle().className()) {
            if ((int)params.size() >= (requiredParams = 3))
                return new Triangle("", params.at(0), params.at(1), params.at(2));
        }

        if (className == ZShape().className()) {
            if ((int)params.size() >= (requiredParams = 2)) {
                return new ZShape("", params.at(0), params.at(1));
            }
        }

        if (requiredParams >= 0) {
            std::ostringstream ex;
            ex << "[factory error] Term of class<" + className + "> "
                    "requires " << requiredParams << " parameters";
//.........这里部分代码省略.........
开发者ID:DevasenaInupakutika,项目名称:assn2,代码行数:101,代码来源:TermFactory.cpp

示例10: BeginPaint

void CtrlDisplayListView::onPaint(WPARAM wParam, LPARAM lParam)
{
	if (!validDisplayList || !gpuDebug)
		return;

	PAINTSTRUCT ps;
	HDC actualHdc = BeginPaint(wnd, &ps);
	HDC hdc = CreateCompatibleDC(actualHdc);
	HBITMAP hBM = CreateCompatibleBitmap(actualHdc, rect.right-rect.left, rect.bottom-rect.top);
	SelectObject(hdc, hBM);

	SetBkMode(hdc, TRANSPARENT);

	HPEN nullPen=CreatePen(0,0,0xffffff);
	HPEN condPen=CreatePen(0,0,0xFF3020);
	HBRUSH nullBrush=CreateSolidBrush(0xffffff);
	HBRUSH currentBrush=CreateSolidBrush(0xFFEfE8);

	HPEN oldPen=(HPEN)SelectObject(hdc,nullPen);
	HBRUSH oldBrush=(HBRUSH)SelectObject(hdc,nullBrush);
	HFONT oldFont = (HFONT)SelectObject(hdc,(HGDIOBJ)font);
	
	HICON breakPoint = (HICON)LoadIcon(GetModuleHandle(0),(LPCWSTR)IDI_STOP);

	auto disasm = gpuDebug->DissassembleOpRange(windowStart, windowStart + (visibleRows + 2) * instructionSize);

	for (int i = 0; i < visibleRows+2; i++)
	{
		unsigned int address=windowStart + i*instructionSize;
		bool stall = address == list.stall;

		int rowY1 = rowHeight*i;
		int rowY2 = rowHeight*(i+1);

		// draw background
		COLORREF backgroundColor = stall ? 0xCCCCFF : 0xFFFFFF;
		COLORREF textColor = 0x000000;
		
		if (address >= selectRangeStart && address < selectRangeEnd)
		{
			if (hasFocus)
			{
				backgroundColor = address == curAddress ? 0xFF8822 : 0xFF9933;
				textColor = 0xFFFFFF;
			} else {
				backgroundColor = 0xC0C0C0;
			}
		}

		HBRUSH backgroundBrush = CreateSolidBrush(backgroundColor);
		HPEN backgroundPen = CreatePen(0,0,backgroundColor);
		SelectObject(hdc,backgroundBrush);
		SelectObject(hdc,backgroundPen);
		Rectangle(hdc,0,rowY1,rect.right,rowY1+rowHeight);
		
		SelectObject(hdc,currentBrush);
		SelectObject(hdc,nullPen);

		DeleteObject(backgroundBrush);
		DeleteObject(backgroundPen);

		// display address/symbol
		if (GPUBreakpoints::IsAddressBreakpoint(address))
		{
			textColor = 0x0000FF;
			int yOffset = std::max(-1,(rowHeight-14+1)/2);
			DrawIconEx(hdc,2,rowY1+1+yOffset,breakPoint,32,32,0,0,DI_NORMAL);
		}
		SetTextColor(hdc,textColor);

		GPUDebugOp op = i < (int)disasm.size() ? disasm[i] : GPUDebugOp();

		char addressText[64];
		sprintf(addressText,"%08X %08X",op.pc,op.op);
		TextOutA(hdc,pixelPositions.addressStart,rowY1+2,addressText,(int)strlen(addressText));

		if (address == list.pc)
		{
			TextOut(hdc,pixelPositions.opcodeStart-8,rowY1,L"\x25A0",1);
		}

		const char* opcode = op.desc.c_str();
		SelectObject(hdc,stall ? boldfont : font);
		TextOutA(hdc,pixelPositions.opcodeStart,rowY1+2,opcode,(int)strlen(opcode));
		SelectObject(hdc,font);
	}

	SelectObject(hdc,oldFont);
	SelectObject(hdc,oldPen);
	SelectObject(hdc,oldBrush);

	// copy bitmap to the actual hdc
	BitBlt(actualHdc, 0, 0, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY);
	DeleteObject(hBM);
	DeleteDC(hdc);

	DeleteObject(nullPen);
	DeleteObject(condPen);

	DeleteObject(nullBrush);
//.........这里部分代码省略.........
开发者ID:RisingFog,项目名称:ppsspp,代码行数:101,代码来源:CtrlDisplayListView.cpp

示例11: Rectangle

/**
 * @brief Returns the size of a frame.
 * @return The size of a frame.
 */
Rectangle SpriteAnimationDirection::get_size() const {

  Debug::check_assertion(nb_frames > 0, "Invalid number of frames");
  return Rectangle(0, 0, frames[0].get_width(), frames[0].get_height());
}
开发者ID:xor-mind,项目名称:solarus,代码行数:9,代码来源:SpriteAnimationDirection.cpp

示例12: WndProc

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static BOOL  fBlocking, fValidBox ;
     static POINT ptBeg, ptEnd, ptBoxBeg, ptBoxEnd ;
     HDC          hdc ;
     PAINTSTRUCT  ps ;
     
     switch (message)
     {
     case WM_LBUTTONDOWN :
          ptBeg.x = ptEnd.x = LOWORD (lParam) ;
          ptBeg.y = ptEnd.y = HIWORD (lParam) ;
          
          DrawBoxOutline (hwnd, ptBeg, ptEnd) ;
          
          SetCursor (LoadCursor (NULL, IDC_CROSS)) ;
          
          fBlocking = TRUE ;
          return 0 ;
          
     case WM_MOUSEMOVE :
          if (fBlocking)
          {
               SetCursor (LoadCursor (NULL, IDC_CROSS)) ;
               
               DrawBoxOutline (hwnd, ptBeg, ptEnd) ;
               
               ptEnd.x = LOWORD (lParam) ;
               ptEnd.y = HIWORD (lParam) ;
               
               DrawBoxOutline (hwnd, ptBeg, ptEnd) ;
          }
          return 0 ;
          
     case WM_LBUTTONUP :
          if (fBlocking)
          {
               DrawBoxOutline (hwnd, ptBeg, ptEnd) ;
               
               ptBoxBeg   = ptBeg ;
               ptBoxEnd.x = LOWORD (lParam) ;
               ptBoxEnd.y = HIWORD (lParam) ;
               
               SetCursor (LoadCursor (NULL, IDC_ARROW)) ;
               
               fBlocking = FALSE ;
               fValidBox  = TRUE ;
               
               InvalidateRect (hwnd, NULL, TRUE) ;
          }
          return 0 ;
          
     case WM_CHAR :
          if (fBlocking & (wParam == '\x1B'))     // i.e., Escape
          {
               DrawBoxOutline (hwnd, ptBeg, ptEnd) ;
               
               SetCursor (LoadCursor (NULL, IDC_ARROW)) ;
               
               fBlocking = FALSE ;
          }
          return 0 ;
          
     case WM_PAINT :
          hdc = BeginPaint (hwnd, &ps) ;
          
          if (fValidBox)
          {
               SelectObject (hdc, GetStockObject (BLACK_BRUSH)) ;
               Rectangle (hdc, ptBoxBeg.x, ptBoxBeg.y,
                    ptBoxEnd.x, ptBoxEnd.y) ;
          }
          
          if (fBlocking)
          {
               SetROP2 (hdc, R2_NOT) ;
               SelectObject (hdc, GetStockObject (NULL_BRUSH)) ;
               Rectangle (hdc, ptBeg.x, ptBeg.y, ptEnd.x, ptEnd.y) ;
          }
          
          EndPaint (hwnd, &ps) ;
          return 0 ;
          
     case WM_DESTROY :
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
开发者ID:AaronFae,项目名称:VimProject,代码行数:89,代码来源:BlokOut1.c

示例13: getBaseColor

    void Button::draw(Graphics* graphics)
    {
        Color faceColor = getBaseColor();
        Color highlightColor, shadowColor;
        int alpha = getBaseColor().a;

        if (isPressed())
        {
            faceColor = faceColor - 0x303030;
            faceColor.a = alpha;
            highlightColor = faceColor - 0x303030;
            highlightColor.a = alpha;
            shadowColor = faceColor + 0x303030;
            shadowColor.a = alpha;
        }
        else
        {
            highlightColor = faceColor + 0x303030;
            highlightColor.a = alpha;
            shadowColor = faceColor - 0x303030;
            shadowColor.a = alpha;
        }

        graphics->setColor(faceColor);
        graphics->fillRectangle(Rectangle(1, 1, getDimension().width-1, getHeight() - 1));

        graphics->setColor(highlightColor);
        graphics->drawLine(0, 0, getWidth() - 1, 0);
        graphics->drawLine(0, 1, 0, getHeight() - 1);

        graphics->setColor(shadowColor);
        graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, getHeight() - 1);
        graphics->drawLine(1, getHeight() - 1, getWidth() - 1, getHeight() - 1);

        graphics->setColor(getForegroundColor());

        int textX;
        int textY = getHeight() / 2 - getFont()->getHeight() / 2;

        switch (getAlignment())
        {
          case Graphics::LEFT:
              textX = mSpacing;
              break;
          case Graphics::CENTER:
              textX = getWidth() / 2;
              break;
          case Graphics::RIGHT:
              textX = getWidth() - mSpacing;
              break;
          default:
              throw GCN_EXCEPTION("Unknown alignment.");
        }

        graphics->setFont(getFont());

        if (isPressed())
        {
            graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment());
        }
        else
        {
            graphics->drawText(getCaption(), textX, textY, getAlignment());

            if (isFocused())
            {
                graphics->drawRectangle(Rectangle(2, 2, getWidth() - 4,
                                                  getHeight() - 4));
            }
        }
    }
开发者ID:IamusNavarathna,项目名称:lv3proj,代码行数:71,代码来源:button.cpp

示例14: DefWindowProc

/*
 * This procedure implements the messages passed by the window
 * manager for default processing on behalf of the window.
 */
LRESULT WINAPI
DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HDC		hdc;
	RECT		rc;
	DWORD		dwStyle;
	HBRUSH		hbr;
	HPEN		hpen, holdpen;
	PAINTSTRUCT	ps;
	POINT		curpt;
	int 		x, y;
	HWND		wp;
	HWND		oldActive;
	COLORREF	crCaption;
	LPNCCALCSIZE_PARAMS lpnc;
	CHAR		szTitle[64];
	static POINT 	startpt;

	switch(msg) {
	case WM_NCCALCSIZE:
		/* calculate client rect from passed window rect in rgrc[0]*/
		lpnc = (LPNCCALCSIZE_PARAMS)lParam;
		dwStyle = GetWindowLong(hwnd, GWL_STYLE);
		if(dwStyle & WS_BORDER) {
			if((dwStyle & WS_CAPTION) == WS_CAPTION) {
				InflateRect(&lpnc->rgrc[0],
					-mwSYSMETRICS_CXFRAME,
					-mwSYSMETRICS_CYFRAME);
				lpnc->rgrc[0].top += mwSYSMETRICS_CYCAPTION + 1;
			} else
				InflateRect(&lpnc->rgrc[0], -1, -1);
		}
		break;

	case WM_NCPAINT:
		/* repaint all non-client area*/
		dwStyle = GetWindowLong(hwnd, GWL_STYLE);

		if(dwStyle & WS_BORDER) {
			hdc = GetWindowDC(hwnd);
			GetWindowRect(hwnd, &rc);

			if((dwStyle & WS_CAPTION) == WS_CAPTION) {
				/* draw 2-line 3d border around window*/
				Draw3dOutset(hdc, rc.left, rc.top,
					rc.right-rc.left, rc.bottom-rc.top);
				InflateRect(&rc, -2, -2);

				/* draw 1-line inset inside border*/
				hpen = CreatePen(PS_SOLID, 1,
					GetSysColor(COLOR_BTNFACE));
				holdpen = SelectObject(hdc, hpen);
				SelectObject(hdc, GetStockObject(NULL_BRUSH));
				Rectangle(hdc, rc.left, rc.top, rc.right,
					rc.bottom);
				InflateRect(&rc, -1, -1);

				/* fill caption*/
				rc.bottom = rc.top + mwSYSMETRICS_CYCAPTION;
				crCaption = GetActiveWindow()==hwnd?
					GetSysColor(COLOR_ACTIVECAPTION):
					GetSysColor(COLOR_INACTIVECAPTION);
				hbr = CreateSolidBrush(crCaption);
				FillRect(hdc, &rc, hbr);
				DeleteObject(hbr);

				/* draw 1 line under caption*/
				MoveToEx(hdc, rc.left, rc.bottom, NULL);
				LineTo(hdc, rc.right, rc.bottom);
				DeleteObject(SelectObject(hdc, holdpen));

				/* draw caption text*/
				if(GetWindowText(hwnd, szTitle,
				   sizeof(szTitle))) {
					SetBkMode(hdc, TRANSPARENT);
					/* set background color even though
					 * transparent in case GdArea is used
					 * to draw text which compares
					 * gr_foreground != gr_background
					 * when transparent...
					 */
					SetBkColor(hdc, crCaption);
					SetTextColor(hdc,
						GetActiveWindow()==hwnd?
						GetSysColor(COLOR_CAPTIONTEXT):
						GetSysColor(COLOR_INACTIVECAPTIONTEXT));
					SelectObject(hdc,
					    GetStockObject(DEFAULT_GUI_FONT));
					GetWindowRect(hwnd, &rc);
					TextOut(hdc, rc.left+4, rc.top+2,
						szTitle, strlen(szTitle));
				}

				/* draw close box*/
				GetCloseBoxRect(hwnd, &rc);
				/*DrawDIB(hdc, rc.right-XSIZE_CLOSEBOX-3,
//.........这里部分代码省略.........
开发者ID:EPiCS,项目名称:reconos_v2,代码行数:101,代码来源:windefw.c

示例15: ILOG_TRACE_W

void
AppCompositor::updateAppCompositorGeometry()
{
    ILOG_TRACE_W(ILX_APPCOMPOSITOR);
    float w = _zoomFactor * width();
    float h = _zoomFactor * height();

    if (w == 0 || h == 0)
        return;

    AppInfo* info = _instance->appInfo();
    ILOG_DEBUG(ILX_APPCOMPOSITOR, " -> name: %s\n", info->name().c_str());
    ILOG_DEBUG(ILX_APPCOMPOSITOR, " -> w: %f h: %f\n", w, h);
    if (info)
    {
        if (info->appFlags() & APP_NO_MAINWINDOW)
        {
            int i = 0;
            ILOG_DEBUG(ILX_APPCOMPOSITOR, " -> APP_NO_MAINWINDOW - ZoomFactor: %f\n", _zoomFactor);
            // calc bounding box.
            Rectangle bounds;
            for (WidgetList::iterator it = _children.begin(); it != _children.end(); ++it)
            {
                SurfaceView* view = dynamic_cast<SurfaceView*>(*it);
                if (view)
                {
                    int x, y;
                    view->dfbWindow()->GetPosition(view->dfbWindow(), &x, &y);
                    Size s = view->preferredSize();
                    bounds.unite(Rectangle(x, y, s.width(), s.height()));
                }
            }

            // resize
            _hScale = width() < _compositor->getAppGeometry().width() ? w / _compositor->getAppGeometry().width() : 1;
            _vScale =
                    height() < _compositor->getAppGeometry().height() ? h / _compositor->getAppGeometry().height() : 1;
            for (WidgetList::iterator it = _children.begin(); it != _children.end(); ++it)
            {
                SurfaceView* view = dynamic_cast<SurfaceView*>(*it);
                if (view)
                {
                    int x, y;
                    view->dfbWindow()->GetPosition(view->dfbWindow(), &x, &y);
                    Size s = view->preferredSize();
                    view->setGeometry(x * _hScale, y * _vScale, s.width() * _hScale, s.height() * _vScale);
                    ILOG_DEBUG(ILX_APPCOMPOSITOR, "  -> window[%d]: %d, %d - %d x %d\n", i, view->x(), view->y(), view->width(), view->height());
                    ++i;
                }
            }
        } else
        {
            int i = 0;
            ILOG_DEBUG(ILX_APPCOMPOSITOR, " -> APP_WITH_MAINWINDOW - ZoomFactor: %f\n", _zoomFactor);
            for (WidgetList::iterator it = _children.begin(); it != _children.end(); ++it)
            {
                SurfaceView* view = dynamic_cast<SurfaceView*>(*it);
                if (view)
                {
                    if (i == 0)
                    {
                        view->setGeometry((width() - w) / 2, (height() - h) / 2, w, h);
                        ILOG_DEBUG(ILX_APPCOMPOSITOR, "  -> window[%d]: %d, %d - %d x %d\n", i, view->x(), view->y(), view->width(), view->height());
                        // Calculate scaling factors using mainwindow as base
                        Size s = view->preferredSize();
                        _hScale = w / s.width();
                        _vScale = h / s.height();
                        ILOG_DEBUG(ILX_APPCOMPOSITOR, "  -> hScale: %f vScale: %f\n", _hScale, _vScale);
                    } else
                    {
                        int x, y;
                        view->dfbWindow()->GetPosition(view->dfbWindow(), &x, &y);
                        Size s = view->preferredSize();
                        view->setGeometry(x * _hScale, y * _vScale, s.width() * _hScale, s.height() * _vScale);
                        ILOG_DEBUG(ILX_APPCOMPOSITOR, "  -> window[%d]: %d, %d - %d x %d\n", i, view->x(), view->y(), view->width(), view->height());
                    }
                    ++i;
                }
            }
        }
    }
}
开发者ID:Ecro,项目名称:ilixi,代码行数:82,代码来源:AppCompositor.cpp


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