コード例 #1
0
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);
}
コード例 #2
0
ファイル: Lab3.cpp プロジェクト: nancy-bree/_bsuir
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);
	}
}
コード例 #3
0
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);
        }
    }
    break;
    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDOK:
            if (hbmpBackgroundTop)
            {
                DeleteObject(hbmpBackgroundTop);
            }

            if (hTextFont)
            {
                ::DeleteObject(hTextFont);
            }

            {
                int Index = SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_GETCURSEL, 0, 0);

                if (Index >= 0)
                {
                    wchar_t String[255];
                    SendMessageW(GetDlgItem(hDlg, IDC_LANG_SEL), CB_GETLBTEXT, Index, (LPARAM)String);
                    g_Lang->SetLanguage(String);
                }
            }

            EndDialog(hDlg, 0);
            break;
        }
    default:
        return FALSE;
    }
    return TRUE;
}
コード例 #4
0
ファイル: Canvas.hpp プロジェクト: XCSoar/XCSoar
 void Clear() {
   Rectangle(0, 0, GetWidth(), GetHeight());
 }
コード例 #5
0
 void Clear() {
   Rectangle(0, 0, get_width(), get_height());
 }
コード例 #6
0
ファイル: T05GLOBE.C プロジェクト: IaroslavPKriuchkov/SPR2013
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);
}
コード例 #7
0
ファイル: Ladder.cpp プロジェクト: Reptarsrage/Jetpack
Ladder::Ladder(float x, float y, float w, float h, const Sprites *s) {
	const Rectangle r = Rectangle(x, y, w, h);
	Init(r, s);
}
コード例 #8
0
ファイル: playing_state.cpp プロジェクト: LazyOxen/snake
void PlayingState::draw(HDC& hdc)
{
	_snake.draw(hdc);
	Rectangle(hdc, _food.x, _food.y, _food.x + BLOCK_WIDTH, _food.y + BLOCK_WIDTH);
}
コード例 #9
0
ファイル: pgroup.cpp プロジェクト: garyqinyu/abv
/*--------------------------------------------------------------------------*/
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();
}
コード例 #10
0
    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";
            throw fl::Exception(ex.str(), FL_AT);
        }
        throw fl::Exception("[factory error] Term of class <" + className + "> not recognized", FL_AT);
    }
コード例 #11
0
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);
	DeleteObject(currentBrush);
	
	DestroyIcon(breakPoint);

	EndPaint(wnd, &ps);
}
コード例 #12
0
/**
 * @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());
}
コード例 #13
0
ファイル: BlokOut1.c プロジェクト: AaronFae/VimProject
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) ;
}
コード例 #14
0
ファイル: button.cpp プロジェクト: IamusNavarathna/lv3proj
    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));
            }
        }
    }
コード例 #15
0
ファイル: windefw.c プロジェクト: EPiCS/reconos_v2
/*
 * 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,
					rc.top+3, &image_close4);*/
				Draw3dBox(hdc, rc.left, rc.top,
					rc.right-rc.left, rc.bottom-rc.top,
					GetSysColor(COLOR_BTNHIGHLIGHT),
					GetSysColor(COLOR_WINDOWFRAME));
				InflateRect(&rc, -1, -1);
				hbr = CreateSolidBrush(
					GetSysColor(COLOR_BTNFACE));
				FillRect(hdc, &rc, hbr);
				DeleteObject(hbr);

				InflateRect(&rc, -1, -1);
				MoveToEx(hdc, rc.left, rc.top, NULL);
				LineTo(hdc, rc.right-1, rc.bottom-1);
				MoveToEx(hdc, rc.left, rc.bottom-1, NULL);
				LineTo(hdc, rc.right-1, rc.top);
			} else {
				SelectObject(hdc, GetStockObject(NULL_BRUSH));
				Rectangle(hdc, rc.left, rc.top, rc.right,
					rc.bottom);
			}
			ReleaseDC(hwnd, hdc);
		}
		break;

	case WM_NCHITTEST:
		/* if system is dragging a window, always return caption*/
		if(dragwp)
			return HTCAPTION;

		/* Determine what part of the window the mouse is over*/
		POINTSTOPOINT(curpt, lParam);

		if(PtInRect(&hwnd->clirect, curpt))
			return HTCLIENT;

		if(PtInRect(&hwnd->vscroll.rc, curpt))
			return HTVSCROLL;
		if(PtInRect(&hwnd->hscroll.rc, curpt))
			return HTHSCROLL; 

		dwStyle = GetWindowLong(hwnd, GWL_STYLE);
		if((dwStyle & WS_CAPTION) == WS_CAPTION) {
			GetCloseBoxRect(hwnd, &rc);
			if(PtInRect(&rc, curpt))
				return HTCLOSE;

			GetWindowRect(hwnd, &rc);
			InflateRect(&rc, -2, -2);
			rc.bottom = rc.top + mwSYSMETRICS_CYCAPTION;
			if(PtInRect(&rc, curpt))
				return HTCAPTION;

			GetWindowRect(hwnd, &rc);
			InflateRect(&rc, -2, -2);
			rc.top += mwSYSMETRICS_CYCAPTION;
			if(PtInRect(&rc, curpt))
				return HTCLIENT;

			return HTBORDER;
		}
		return HTNOWHERE;

	case WM_NCLBUTTONDOWN:
		/* Handle default actions for mouse down on window*/
		if(wParam == HTCLOSE) {
			SendMessage(hwnd, WM_CLOSE, 0, 0L);
			break;
		}

		/* set focus on mouse down, repaint if necessary*/
		oldActive = GetActiveWindow();
		if(wParam == HTCLIENT || wParam == HTVSCROLL ||
		   wParam == HTHSCROLL)
			/* activate and raise window if in client area*/
			/* kaffe port requires this commented out*/
			SetForegroundWindow(hwnd);
		else {
			/* otherwise just change focus window, same z order*/
			/* this will activate it's top level parent*/
			SetFocus(hwnd);
		}
		/* repaint captions now because of activation change*/
		UpdateWindow(oldActive);
		UpdateWindow(hwnd);

		if(wParam == HTVSCROLL || wParam == HTHSCROLL) {
			MwHandleNCMessageScrollbar(hwnd, msg, wParam, lParam);
			break;
		}

		/* start window drag if in caption area*/
		if(wParam == HTCAPTION && hwnd != rootwp) {
			POINTSTOPOINT(startpt, lParam);
			if(!(GetWindowLong(hwnd, GWL_STYLE) & WS_MAXIMIZE))
				dragwp = hwnd;
			SetRectEmpty(&lastrc);	/* XORMOVE only*/
		}
		break;

	case WM_NCMOUSEMOVE:
		if(wParam == HTVSCROLL || wParam == HTHSCROLL) {
			MwHandleNCMessageScrollbar(hwnd, msg, wParam, lParam);
			break;
		}

		/* drag window with mousemove after mousedown*/
		if(dragwp == hwnd) {
			POINTSTOPOINT(curpt, lParam);
			x = curpt.x - startpt.x;
			y = curpt.y - startpt.y;

			if(mwERASEMOVE) {
				GetWindowRect(hwnd, &rc);
				MoveWindow(hwnd, rc.left+x, rc.top+y,
					rc.right-rc.left, rc.bottom-rc.top,
					TRUE);
				startpt = curpt;
			} else
				DrawXORFrame(hwnd, x, y, TRUE);
		}
		break;

	case WM_NCLBUTTONUP:
		/* stop window drag*/
		if(dragwp == hwnd) {
			dragwp = NULL;

			if(mwERASEMOVE) {
				/*
				 * User stopped moving window, repaint 
				 * windows previously queued for painting.
				 */
				for(wp=listwp; wp; wp=wp->next)
					if(wp->gotPaintMsg == PAINT_DELAYPAINT)
					    wp->gotPaintMsg = PAINT_NEEDSPAINT;
			} else {
				POINTSTOPOINT(curpt, lParam);
				x = curpt.x - startpt.x;
				y = curpt.y - startpt.y;
				DrawXORFrame(hwnd, x, y, FALSE);
				GetWindowRect(hwnd, &rc);
				MoveWindow(hwnd, rc.left+x, rc.top+y,
				    rc.right-rc.left, rc.bottom-rc.top, TRUE);
			}
		}

		if(wParam == HTVSCROLL || wParam == HTHSCROLL) {
			MwHandleNCMessageScrollbar(hwnd, msg, wParam, lParam);
			break;
		}
		break;

	case WM_NCLBUTTONDBLCLK:
		if(wParam == HTVSCROLL || wParam == HTHSCROLL) {
			MwHandleNCMessageScrollbar(hwnd, msg, wParam, lParam);
			break;
		}

		/* maximize/restore processing*/
		if(wParam != HTCAPTION)
			break;

		if((hwnd->style & WS_CAPTION) == WS_CAPTION) {
			if(hwnd->style & WS_MAXIMIZE) {
				rc = hwnd->restorerc;
				MoveWindow(hwnd, rc.left, rc.top,
					rc.right-rc.left, rc.bottom-rc.top,
					TRUE);
				hwnd->style &= ~WS_MAXIMIZE;
			} else {
				hwnd->restorerc = hwnd->winrect;
				GetWindowRect(rootwp, &rc);
				MoveWindow(hwnd, -mwSYSMETRICS_CXFRAME,
					-mwSYSMETRICS_CYFRAME,
					rc.right+2*mwSYSMETRICS_CXFRAME,
					rc.bottom+2*mwSYSMETRICS_CYFRAME, TRUE);
				hwnd->style |= WS_MAXIMIZE;
			}
		}
		break;

	case WM_GETTEXTLENGTH:
		/* Get window text length.  This routine requires
		 * knowledge of the internal window structure
		 */
		return strlen(hwnd->szTitle);

	case WM_GETTEXT:
		/* Get window text.  This routine requires
		 * knowledge of the internal window structure
		 */
		return strzcpy((LPSTR)lParam, hwnd->szTitle, wParam);

	case WM_SETTEXT:
		/* Set window text.  This routine requires
		 * knowledge of the internal window structure.
		 * Note that setting text doesn't invalidate the window.
		 */
		strzcpy(hwnd->szTitle, (LPSTR)lParam, sizeof(hwnd->szTitle));
		return TRUE;

	case WM_CLOSE:
		DestroyWindow(hwnd);
		if(hwnd == rootwp)
			PostQuitMessage(0);
		break;

	case WM_ERASEBKGND:
		/* erase background with class background brush*/
		hbr = (HBRUSH)GetClassLong(hwnd, GCL_HBRBACKGROUND);
		if(!hbr)
			return 0;
		/* don't exclude update region*/
		hdc = GetDCEx(hwnd, NULL, DCX_DEFAULTCLIP);
		FillRect(hdc, NULL, hbr);
		ReleaseDC(hwnd, hdc);
		return 1;

	case WM_PAINT:
		/* required to send erasebkgnd for desktop window*/
		hdc = BeginPaint(hwnd, &ps);

		/* draw desktop wallpaper*/
		if(hwnd == rootwp && pImageWallpaper) {
			GetWindowRect(hwnd, &rc);
			DrawDIB(hdc,
				(rc.right-rc.left-pImageWallpaper->width)/2,
				(rc.bottom-rc.top-pImageWallpaper->height)/2,
				pImageWallpaper);
		}

		EndPaint(hwnd, &ps);
		break;
	}
	return 0;
}
コード例 #16
0
ファイル: AppCompositor.cpp プロジェクト: Ecro/ilixi
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;
                }
            }
        }
    }
}
コード例 #17
0
ファイル: stop_watch.c プロジェクト: sparrow1058/cc1110
void stop_watch_main(void){
#else
void main(void){
#endif
   STATE state = START_STATE;
   initStopWatch();
   TIMER3_RUN(FALSE);
   ClearScreen();
   Print(0,5,"--STOP WATCH--",1);

   Rectangle(2 , 4 , 108 , 7);

   while(!stopApplication()){
      switch (state)
      {
                case START_STATE:
                {
                        t.h = t.m = t.s = 0;
                        overflow = 0;
                        printTime();
                        if(LanguageSel == 1)
                        {
                                Print6(2,10," OK for START    ",1);
                        }
                        else
                        {
                                Print(2,8,"按OK键开始:",1);
                        }
                        if(ScanKey() == K_OK)
                        {
                                while(ScanKey() != 0xff);
                                halWait(5);
                                TIMER3_RUN(TRUE);
                                state = RUN_STATE;
                                if(LanguageSel == 1)
                                {
                                        Print6(2,10," OK for STOP   ",1);
                                }
                                else
                                {
                                        Print(2,8,"按OK键停止:",1);
                                }

                        }
                }break;

                case RUN_STATE:
                {
                        INT_GLOBAL_ENABLE(INT_OFF);

                        if(overflow > 0 && overflow < 0x09)
                        {
                                GLED = LED_ON;
                        }
                        else if(overflow > (UINT16)1000)
                        {
                                //overflow = 0;
                                overflow -= 1000;

                                incrementTime();
                                printTime();
                        }
                        else
                        {
                                GLED = LED_OFF;
                        }
                        if(ScanKey() == K_OK)
                        {
                                while(ScanKey() != 0xff);
                                halWait(5);
                                TIMER3_RUN(FALSE);
                                state = STOP_STATE;
                                GLED = LED_OFF;
                        }

                        INT_GLOBAL_ENABLE(INT_ON);
                }break;
                case STOP_STATE:
                {
                        printTime();
                        if(LanguageSel == 1)
                        {
                                Print6(2,10," Total time is:",1);
                        }
                        else
                        {
                                Print(2,8,"总计时间为:",1);
                        }
                        if(ScanKey() == K_OK)
                        {
                                while(ScanKey() != 0xff);
                                halWait(5);
                                state = START_STATE;
                        }
                }break;
                default:
                break;
        }
   }
   while(ScanKey() != 0xff);
   halWait(5);
   INT_GLOBAL_ENABLE(INT_OFF);
   return;
}
コード例 #18
0
void EnemyPlane::ShowPlane()
{
	if (g_Time - m_ShowTime < m_Delay)
	{
		return;
	}

	switch (m_iState)
	{
	case P_EXPLODE:
		PlaneExplode();
		break;

	default:
		if (m_PlaneImage)
		{
			BITMAP bitmap;
			GetObject(m_PlaneImage[m_iNowImageIndex], sizeof(bitmap), &bitmap);
			HPEN oldPen = (HPEN)SelectObject(g_hdcMem, m_PlaneImage[m_iNowImageIndex]);
			SetBkColor(g_hdcMem, RGB(0, 123, 139));

			g_bmpMask = CreateBitmap(bitmap.bmWidth, bitmap.bmHeight, 1, 1, NULL);
			HPEN oldMaskPen = (HPEN)SelectObject(g_hdcMask, g_bmpMask);
			BitBlt(g_hdcMask, 0, 0, bitmap.bmWidth, bitmap.bmHeight, g_hdcMem, 0, 0, SRCCOPY);

			BitBlt(g_hdcBuffer, m_iX-m_iOffsetX, m_iY-m_iOffsetY, bitmap.bmWidth, bitmap.bmHeight, g_hdcMem, 0, 0, SRCINVERT);
			BitBlt(g_hdcBuffer, m_iX-m_iOffsetX, m_iY-m_iOffsetY, bitmap.bmWidth, bitmap.bmHeight, g_hdcMask, 0, 0, SRCAND);
			BitBlt(g_hdcBuffer, m_iX-m_iOffsetX, m_iY-m_iOffsetY, bitmap.bmWidth, bitmap.bmHeight, g_hdcMem, 0, 0, SRCINVERT);

			SelectObject(g_hdcMask, oldMaskPen);
			DeleteObject(g_bmpMask);
			SelectObject(g_hdcMem, oldPen);

			m_iNowImageIndex++;
			if (m_iNowImageIndex >= m_iImageIndexMax)
			{
				m_iNowImageIndex = 0;
			}
		}
		else
		{
			HBRUSH hBrush = CreateSolidBrush(RGB(255, 0, 0));
			HPEN oldPen = (HPEN)SelectObject(g_hdcBuffer, hBrush);

			Rectangle(g_hdcBuffer, m_iX, m_iY, m_ImpactBox.right, m_ImpactBox.bottom);

			SelectObject(g_hdcBuffer, oldPen);
			DeleteObject(hBrush);
		}

		if (m_bIsBoss)
		{
			HBRUSH hBrush = CreateSolidBrush(RGB(255, 0, 0));
			HPEN oldPen = (HPEN)SelectObject(g_hdcBuffer, hBrush);

			int length = (ScreenWidth-40)*m_iHp/m_iHpMax;
			Rectangle(g_hdcBuffer, 20, 50, 20+length, 55);

			SelectObject(g_hdcBuffer, oldPen);
			DeleteObject(hBrush);
		}
		break;
	}
}
コード例 #19
0
ファイル: XApplication.cpp プロジェクト: johannalee/cs349
  void XApplication::CheckForXEvents() {

    /*
     * TODO for CS349 assignment:
     * Check if there is an X event pending. If so, package it up
     * using our own Event classes, and add it to the eventQueue.
     *
     * See the documentation at
     * http://tronche.com/gui/x/xlib/events/types.html to learn how to
     * identify the different types of X events. We have shown how to
     * get the Expose event (which indicates your window should
     * repaint itself) and package it up as a PaintEvent.
     *
     * Note that XEvent is a union of structs. This union is
     * documented on the page following the one above:
     * http://tronche.com/gui/x/xlib/events/structures.html
     *
     * If you are unfamiliar with C/C++ unions, or need a refresher,
     * see:
     * http://www.tutorialspoint.com/cprogramming/c_unions.htm
     * http://stackoverflow.com/questions/346536/difference-between-a-structure-and-a-union-in-c 
     *
     * Another thing to note is that nothing will paint on your window
     * until it is mapped on the screen. You don't necessarily need to
     * be aware of when it is mapped, just be aware that until it's
     * displayed, any painting operations will have no effect when
     * it's actually put on the screen.
     *
     * One thing you may be wondering is why we package up an event
     * and add it to the event queue, rather than dispatching it right
     * away. The reason is that events may be added to the queue by
     * other objects (such as TimerEvents). Thus, to preserve proper
     * temporal ordering of events, you need to add events to the
     * queue and dispath them one by one.
     */
    if (XPending(this->display)) {
      // Get event, package it up, add it to the queue
      Event* newEvent = NULL;
      XEvent event;
      int i = 0;
      XNextEvent(this->display, &event);
      XWindow* window = XWindow::GetXWindowForWindow(event.xany.window);

      // LOG_TODO << "TODO CS349: Implement XApplication::CheckForXEvents (remove when implemented)";
      switch (event.type) {

      case Expose:
        newEvent = new PaintEvent(window, Rectangle(event.xexpose.x, event.xexpose.y, event.xexpose.width, event.xexpose.height));
        break;

// TODO CS349
      case ButtonPress:
        newEvent = new MouseEvent(window, MouseEvent::mouseDown, Point(event.xbutton.x, event.xbutton.y));
        // LOG(INFO) << "(DOWN\t\t" << event.xbutton.x << ", " << event.xbutton.y << ")";
      break;

      case ButtonRelease:
        newEvent = new MouseEvent(window, MouseEvent::mouseUp, Point(event.xbutton.x, event.xbutton.y));
        // LOG(INFO) << "(UP\t\t" << event.xbutton.x << ", " << event.xbutton.y << ")";
      break;

      case MotionNotify:
        newEvent = new MouseEvent(window, MouseEvent::mouseDrag, Point(event.xbutton.x, event.xbutton.y));
        // LOG(INFO) << "(DRAG\t\t" << event.xbutton.x << ", " << event.xbutton.y << ")";
      break;

      case KeyPress:
      //ESC exits the program
      if(event.xkey.keycode == 9){
        exit(0);
      }
      break;

      case DestroyNotify:
        // You can ignore this
        // LOG(INFO) << "Destroy notify event received";
        break;
      }

      if (newEvent != NULL) {
        eventQueue->AddEventToQueue(newEvent);
      }
    }
  }
コード例 #20
0
ファイル: Gtest.cpp プロジェクト: Interiya/Lines
TEST(Rectangle, Length){
    ASSERT_DOUBLE_EQ(Rectangle(1,1,4,1,2).length(),10);
};
コード例 #21
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message)
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case ID_DRAW_LINE:
			d_flag=1;
			break;
		case ID_DRAW_REC:
			d_flag=2;
			break;
		case ID_DRAW_Ellipse:
			d_flag=3;
			break;
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_LBUTTONDOWN :		
		{
			xPaintpos[0]=GET_X_LPARAM(lParam);      
			yPaintpos[0]=GET_Y_LPARAM(lParam);	

		}
		break;

	case WM_LBUTTONUP :
		{
			xPaintpos[1]=GET_X_LPARAM(lParam);      
			yPaintpos[1]=GET_Y_LPARAM(lParam);
			GetClientRect(hWnd,&rect);

			InvalidateRect(hWnd,&rect,TRUE);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		
		switch(d_flag)
		{
		case 1:
		MoveToEx(hdc,xPaintpos[0],yPaintpos[0],0);
		LineTo(hdc,xPaintpos[1],yPaintpos[1]);
			
		break;
	   case 2:
		Rectangle(hdc,xPaintpos[0],yPaintpos[0],xPaintpos[1],yPaintpos[1]) ;
		
		break;
		case 3:
		Ellipse(hdc,xPaintpos[0],yPaintpos[0],xPaintpos[1],yPaintpos[1]) ;
		
		break;
		default:
			//Rectangle(hdc,40,40,100,100) ;
			break;
		}
		/*if (d_flag==1)
		{
		MoveToEx(hdc,xPaintpos[0],yPaintpos[0],0);
		LineTo(hdc,xPaintpos[1],yPaintpos[1]);
		}
		else if (d_flag==2)
		{
		Rectangle(hdc,xPaintpos[0],yPaintpos[0],xPaintpos[1],yPaintpos[1]) ;
		}
		else if (d_flag==3)
		{
		Ellipse(hdc,xPaintpos[0],yPaintpos[0],xPaintpos[1],yPaintpos[1]) ;
		}*/
			//MoveToEx(hdc,xPaintpos[0],yPaintpos[0],0);
			//LineTo(hdc,xPaintpos[1],yPaintpos[1]);
		//	Rectangle(hdc,40,40,100,100) ;
		//	break;
		//case 2:
		//	//Rectangle(hdc,xPaintpos[0],yPaintpos[0],xPaintpos[1],yPaintpos[1]) ;
		//	Rectangle(hdc,40,40,100,100) ;
		//	break;
		//case 3:
		//	//Ellipse(hdc,xPaintpos[0],yPaintpos[0],xPaintpos[1],yPaintpos[1]) ;
		//	Rectangle(hdc,40,40,100,100) ;
		//	break;
		//default:
		//	Rectangle(hdc,40,40,100,100) ;
		//	break;
		//}
		
		EndPaint(hWnd, &ps);
		break;
	
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
コード例 #22
0
ファイル: Gtest.cpp プロジェクト: Interiya/Lines
TEST(Rectangle, Projection){
    ASSERT_EQ(Segment(2,2,4.5,4.5), Rectangle(1,3,4,3,2).projection(Point(2,2)));
};
コード例 #23
0
ファイル: Geometry.cpp プロジェクト: Arseth/solarus
/**
 * \brief Returns the cartesian coordinates of a vector that starts from the origin, given its angle and distance.
 * \param angle angle of the vector in radians
 * \param distance length of the vector in pixels
 * \return the coordinates of the second point
 */
const Rectangle Geometry::get_xy(double angle, int distance) {

  return Rectangle((int) (distance * std::cos(angle)), (int) (-distance * std::sin(angle)));
}
コード例 #24
0
void ZLBlockTreeNode::addHyperlink(std::size_t left, std::size_t top, std::size_t right, std::size_t bottom, shared_ptr<ZLRunnableWithKey> action) {
	myHyperlinks[Rectangle(left, top, right, bottom)] = action;
}
コード例 #25
0
ファイル: plot.c プロジェクト: MarkieMark/netsurf-git-svn
static bool rectangle(int x0, int y0, int x1, int y1, const plot_style_t 
		*style)
{
	x1++;
	y1++;
	x0 = MAX(x0, 0);
	y0 = MAX(y0, 0);
	if (!((current_gui == NULL) || (thumbnail))) {
		x1 = MIN(x1, gui_window_width(current_gui));
		y1 = MIN(y1, gui_window_height(current_gui));
	}
	
#if NSWS_PLOT_DEBUG	
	LOG(("rectangle from %d,%d to %d,%d thumbnail %d", x0, y0, x1, y1,
			thumbnail));
#endif
	HDC hdc = doublebuffering ? bufferdc : GetDC(current_hwnd);
	if (hdc == NULL) {
		return false;
	}
	RECT *clipr = gui_window_clip_rect(current_gui);
	if (clipr == NULL)
		clipr = &localhistory_clip;
	HRGN clipregion = CreateRectRgnIndirect(clipr);
	if (clipregion == NULL) {
		if (!doublebuffering)
			ReleaseDC(current_hwnd, hdc);
		return false;
	}
	COLORREF pencol = (DWORD)(style->stroke_colour & 0x00FFFFFF);
	DWORD penstyle = PS_GEOMETRIC | 
			(style->stroke_type == PLOT_OP_TYPE_DOT ? PS_DOT :
			(style->stroke_type == PLOT_OP_TYPE_DASH ? PS_DASH :
			(style->stroke_type == PLOT_OP_TYPE_NONE ? PS_NULL : 
			0)));
	LOGBRUSH lb = {BS_SOLID, pencol, 0};
	LOGBRUSH lb1 = {BS_SOLID, style->fill_colour, 0};
	if (style->fill_type == PLOT_OP_TYPE_NONE)
		lb1.lbStyle = BS_HOLLOW;
	
	HPEN pen = ExtCreatePen(penstyle, style->stroke_width, &lb, 0, NULL);
	if (pen == NULL) {
		DeleteObject(clipregion);
		if (!doublebuffering)
			ReleaseDC(current_hwnd, hdc);
		return false;
	}
	HGDIOBJ penbak = SelectObject(hdc, (HGDIOBJ) pen);
	if (penbak == NULL) {
		DeleteObject(clipregion);
		DeleteObject(pen);
		if (!doublebuffering)
			ReleaseDC(current_hwnd, hdc);
		return false;
	}
	HBRUSH brush = CreateBrushIndirect(&lb1);
	if (brush  == NULL) {
		DeleteObject(clipregion);
		SelectObject(hdc, penbak);
		DeleteObject(pen);
		if (!doublebuffering)
			ReleaseDC(current_hwnd, hdc);
		return false;
	}
	HGDIOBJ brushbak = SelectObject(hdc, (HGDIOBJ) brush);
	if (brushbak == NULL) {
		DeleteObject(clipregion);
		SelectObject(hdc, penbak);
		DeleteObject(pen);
		DeleteObject(brush);
		if (!doublebuffering)
			ReleaseDC(current_hwnd, hdc);
		return false;
	}
	RECT r;
	r.left = x0;
	r.top = y0;
	r.right = x1;
	r.bottom = y1;

	SelectClipRgn(hdc, clipregion);
	
	Rectangle(hdc, x0, y0, x1, y1);

	SelectClipRgn(hdc, NULL);
/*	ValidateRect(current_hwnd, &r);
*/	
	pen = SelectObject(hdc, penbak);
	brush = SelectObject(hdc, brushbak);
	DeleteObject(clipregion);
	DeleteObject(pen);
	DeleteObject(brush);
	if (!doublebuffering)
		ReleaseDC(current_hwnd, hdc);
	return true;
}
コード例 #26
0
ファイル: cpl.cpp プロジェクト: ForbiddenEra/kx-audio-driver
INT_PTR CALLBACK DialogProc(
    HWND hwndDlg,	// handle to dialog box
    UINT uMsg,	// message
    WPARAM wParam,	// first message parameter
    LPARAM lParam 	// second message parameter
   )
{

 WPARAM wp=IDC_FORMAT|(CBN_SELCHANGE<<16);

 switch(uMsg)
 {
 	case WM_ERASEBKGND:
 		HDC dc;
 		dc=(HDC)wParam;
 		RECT r;
 		GetWindowRect(hwndDlg,&r);

 		HBRUSH c_b,prev_b;
 		c_b=CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
        prev_b=(HBRUSH)SelectObject(dc,c_b);
        Rectangle(dc,0,0,r.right-r.left,r.bottom-r.top);
        SelectObject(dc,prev_b);                
        DeleteObject(c_b);
 		return 1; // erased

 	case WM_COMMAND:
 		if(wParam==wp) // format has changed?
 		{
                // update buffer size after format change:
        		HWND bufsize_combo=GetDlgItem(hwndDlg,IDC_BUFFER_SIZE);
        		LRESULT bufsize_selection=SendMessage(bufsize_combo, CB_GETCURSEL,0,0);
        		SendMessage(bufsize_combo, CB_RESETCONTENT,0,0);

        		float sr;

        		LRESULT cursel=SendMessage(GetDlgItem(hwndDlg,IDC_FORMAT), CB_GETCURSEL,0,0);
                sr = (float)device_caps[cursel].sample_rate;

         		int l_1=32,l_2=48;
                for(int l=0;l<9;l++)
                {
                            char txt[64];

                            sprintf(txt,"%0.2f ms (%d samples)",l_1*1000.0f/sr,l_1);
                            add_item(bufsize_combo,txt);
                            l_1=l_1*2;

                            sprintf(txt,"%0.2f ms (%d samples)",l_2*1000.0f/sr,l_2);
                            add_item(bufsize_combo,txt);
                            l_2=l_2*2;
                 }

                 SendMessage(bufsize_combo, CB_SETCURSEL, bufsize_selection, 0);
 		}
 		else
 		switch(wParam)
 		{
 		 case IDOK:
 		    {
 		 	     LRESULT b_fr=SendMessage(GetDlgItem(hwndDlg,IDC_BUFFER_SIZE),CB_GETCURSEL,0,0);
        		 
        		 int id=0;
         		 int l_1=32,l_2=48;

                 for(int l=0;l<9;l++)
                 {
                            if(id==b_fr)
                            {
                             b_fr=l_1;
                             break;
                            }
                            l_1=l_1*2;
                            id++;

                            if(id==b_fr)
                            {
                             b_fr=l_2;
                             break;
                            }
                            l_2=l_2*2;
                            id++;
                 }
                 driver_parameters.block_frames=(int)b_fr;


                 LRESULT mode=SendMessage(GetDlgItem(hwndDlg,IDC_FORMAT),CB_GETCURSEL,0,0);
                 if(mode<0) mode=0;

                 driver_parameters.sampleRate=(ASIOSampleRate)device_caps[mode].sample_rate;
                 driver_parameters.bps=device_caps[mode].bps;
                 driver_parameters.num_inputs=device_caps[mode].n_ins;
                 driver_parameters.num_outputs=device_caps[mode].n_outs;


                 LRESULT method=SendMessage(GetDlgItem(hwndDlg,IDC_SYNC_METHOD),CB_GETCURSEL,0,0);
                 if(method_list[method].name!=0 && method_list[method].mask!=0)
                   driver_parameters.asio_method=method_list[method].mask;

 		         EndDialog(hwndDlg,1);
 		     }
 		     break;
 		 case IDCANCEL:
 		     EndDialog(hwndDlg,-1);
 		     break;
 		 case IDDEFAULTS:
 		     {
 		         SendMessage(GetDlgItem(hwndDlg,IDC_FORMAT), CB_SETCURSEL, 0, 0);
 		         SendMessage(GetDlgItem(hwndDlg,IDC_BUFFER_SIZE), CB_SETCURSEL, 7, 0);
 		         SendMessage(GetDlgItem(hwndDlg,IDC_SYNC_METHOD), CB_SETCURSEL, 0, 0);
 		     }
 		  break;
 		 case IDASIO:
 		  {
       		   // try running kX Mixer
       		   int kx_found=0;
                 EnumWindows(MyEnumWindowsProc,(LPARAM)&kx_found); // look for KX Windows
                 if(kx_found==0)
                 {
                   MessageBox(NULL,"Launch kX Mixer first!","kX ASIO",MB_OK|MB_ICONINFORMATION);
                   // launch kX Mixer -now-
                   EnumWindows(MyEnumWindowsProc,0); // look for KX Windows
                 }
       	  }
          break;
 		} // switch wParam

 		return TRUE;
 	case WM_INITDIALOG:
 		 SetDlgItemText(hwndDlg,IDC_COPYRIGHT,
 		     "kX ASIO Driver Version:"KX_DRIVER_VERSION_STR"\n"KX_COPYRIGHT_STR_R"\nASIO Technology by Steinberg");
 		
 		 KXAsio *pseudo_this=(KXAsio *)lParam;
 		 tmp_device=pseudo_this->device_num;

         float cur_sr=(float)pseudo_this->sampleRate;
         int cur_buf_size=pseudo_this->get_config(KXASIO_LATENCY);

         // buffer size combo:
         {
                 HWND bufsize_combo=GetDlgItem(hwndDlg,IDC_BUFFER_SIZE);
                 int l_1=32,l_2=48;
                 for(int l=0;l<9;l++)
                 {
                   char txt[64];
                   LRESULT id=0;

                   sprintf(txt,"%0.2f ms (%d samples)",l_1*1000.0f/cur_sr,l_1);
                   id=add_item(bufsize_combo,txt);
                   if(cur_buf_size==l_1)
                    SendMessage(bufsize_combo, CB_SETCURSEL, id, 0);
                   l_1=l_1*2;

                   sprintf(txt,"%0.2f ms (%d samples)",l_2*1000.0f/cur_sr,l_2);
                   id=add_item(bufsize_combo,txt);
                   if(cur_buf_size==l_2)
                    SendMessage(bufsize_combo, CB_SETCURSEL, id, 0);
                   l_2=l_2*2;
                 }
                 SendMessage(bufsize_combo, CB_SETDROPPEDWIDTH, 40, 0);
                 ShowWindow(bufsize_combo,SW_SHOW);
         }

         // format combo:
         {
                 HWND fmt_combo=GetDlgItem(hwndDlg,IDC_FORMAT);
                 EnableWindow(fmt_combo,TRUE);

                 int caps_sz=sizeof(device_caps);
                 if(pseudo_this->ikx->get_device_caps(device_caps,&caps_sz)==0 && caps_sz>0)
                 {
                   total_caps=caps_sz/sizeof(kx_caps);

                   for(int i=0;i<total_caps;i++)
                   {
                       LRESULT id=add_item(fmt_combo,device_caps[i].friendly_name);

                       if(pseudo_this->bps==device_caps[i].bps &&
                          (int)pseudo_this->sampleRate==device_caps[i].sample_rate &&
                          pseudo_this->num_outputs==device_caps[i].n_outs &&
                          pseudo_this->num_inputs==device_caps[i].n_ins)
                       {
                         SendMessage(fmt_combo, CB_SETCURSEL, id, 0);
                       }
                   }

                 } else EnableWindow(fmt_combo,FALSE);

                 SendMessage(fmt_combo, CB_SETDROPPEDWIDTH, 40, 0);
                 ShowWindow(fmt_combo,SW_SHOW);
         }

         // cardname
         {
                 HWND card=GetDlgItem(hwndDlg,IDC_CARD_NAME);
                 // actually, edit
                 SetWindowText(card,pseudo_this->ikx->get_device_name());
         }

         // method
         {
                 HWND sync_method=GetDlgItem(hwndDlg,IDC_SYNC_METHOD);
                 EnableWindow(sync_method,TRUE);

                 int cur_method=pseudo_this->get_config(KXASIO_ASIO_METHOD);

                 int i=0;
                 while(method_list[i].name)
                 {
                    LRESULT cur_item=SendMessage(sync_method, CB_ADDSTRING, 0, (LPARAM)method_list[i].name);
                    if(method_list[i].mask==cur_method)
                    {
                     SendMessage(sync_method, CB_SETCURSEL, cur_item, 0);
                     cur_method=-2;
                    }
                    i++;
                 }

                 if(cur_method!=-2) // not found?
                 {
                     LRESULT cur_item=SendMessage(sync_method, CB_ADDSTRING, 0, (LPARAM)"(Custom)");
                     SendMessage(sync_method, CB_SETCURSEL, cur_item, 0);
                 }

                 SendMessage(sync_method, CB_SETDROPPEDWIDTH, 40, 0);
                 ShowWindow(sync_method,SW_SHOW);
         }

 		 BringWindowToTop(hwndDlg);

 		 return TRUE;
 }

 return FALSE;
}
コード例 #27
0
ファイル: MainDemo.c プロジェクト: jshowa/KetteringUniversity
    int main(void)
{
    SHORT       width, height;	// variables to store the height and width of the 16-bit bitmap image
    SHORT       counter;		// loop control variable for each shape that controls how many shapes are printed and their scale
    SHORT  		triangle[] = {160,120,160,120,160,120,160,120};		// triangle polygon points (start triangle in center of LCD)
    
    #if defined(__dsPIC33F__) || defined(__PIC24H__)

    // Configure Oscillator to operate the device at 40Mhz
    // Fosc= Fin*M/(N1*N2), Fcy=Fosc/2
    // Fosc= 8M*40(2*2)=80Mhz for 8M input clock
    PLLFBD = 38;                    // M=40
    CLKDIVbits.PLLPOST = 0;         // N1=2
    CLKDIVbits.PLLPRE = 0;          // N2=2
    OSCTUN = 0;                     // Tune FRC oscillator, if FRC is used

    // Disable Watch Dog Timer
    RCONbits.SWDTEN = 0;

    // Clock switching to incorporate PLL
    __builtin_write_OSCCONH(0x03);  // Initiate Clock Switch to Primary

    // Oscillator with PLL (NOSC=0b011)
    __builtin_write_OSCCONL(0x01);  // Start clock switching
    while(OSCCONbits.COSC != 0b011);

    // Wait for Clock switch to occur	
    // Wait for PLL to lock
    while(OSCCONbits.LOCK != 1)
    { };
    #elif defined(__PIC32MX__)
    INTEnableSystemMultiVectoredInt();
    SYSTEMConfigPerformance(GetSystemClock());
    #ifdef MULTI_MEDIA_BOARD_DM00123
    CPLDInitialize();
    CPLDSetGraphicsConfiguration(GRAPHICS_HW_CONFIG);
    CPLDSetSPIFlashConfiguration(SPI_FLASH_CHANNEL);
    #endif
    #endif

    #if defined (PIC24FJ256DA210_DEV_BOARD)
    
    // _ANSG8 = 0; /* S1 */
    // _ANSE9 = 0; /* S2 */
    // _ANSB5 = 0; /* S3 */
        
    #else

    /////////////////////////////////////////////////////////////////////////////
    // ADC Explorer 16 Development Board Errata (work around 2)
    // RB15 should be output
    /////////////////////////////////////////////////////////////////////////////
    LATBbits.LATB15 = 0;
    TRISBbits.TRISB15 = 0;

    #endif

    /////////////////////////////////////////////////////////////////////////////
    #if defined(__dsPIC33FJ128GP804__) || defined(__PIC24HJ128GP504__)
    AD1PCFGL = 0xffff;
    #endif
    InitGraph();

    while(1)
    {
	    /* Display the Kettering Logo bit image with the Welcome to the ECE in the center 
	    /* The image was taken from a JPEG and converted to a 16-bit bitmap in order to meet 
	    /* the display requirement of 16-bits per pixel. This can be done by resaving the
	    /* JPEG as 16-bit bitmap in a image editing program and then converting it using
	    /* the graphics library resource converter. The LCD only supports 4-bit, 8-bit, and
	    /* 16-bits per pixel images 
	    */
	    width = GetImageWidth((void *) &kulogo);
		SetFont((void *) &Font25);
	    WAIT_UNTIL_FINISH(PutImage(45, 20 , (void *) &kulogo,  1)); // image location is relative to the top left corner of the image
        SetColor(WHITE);
        Bar(45, 110, width + 45, 135);	// Draw a bar over the image to place the text over.
        SetColor(BLUE);
        OutTextXY(65, 110, "WELCOME TO THE ECE");
        
        DelayMs(DEMODELAY);	// delay for 1 sec and clear the screen
        SetColor(BLACK);
        ClearDevice();

		/* Display multiple circles, starting at the center and increasing in size at 
        /* each draw until the LCD borders are met. Increasing the counter value will 
        /* expand the shape size more quickly. */
        for(counter = 0; counter < MIN(GetMaxX(), GetMaxY()) >> 1; counter += 14)
        {
	        SetColor(BLACK);	// refresh the screen
	        ClearDevice();	
	        SetColor(BRIGHTRED);
	        SetFont((void *) &Font25);		// draw the name of the shape in the center
	        OutTextXY(135, 110, "Circle");
            WAIT_UNTIL_FINISH(Circle(GetMaxX() >> 1, GetMaxY() >> 1, counter + 5));	// draw the shape
            DelayMs(50);	// display for 50 ms
        }

        DelayMs(DEMODELAY);	// delay for 1 sec and clear the screen
        SetColor(BLACK);
        ClearDevice();

		/* Display multiple rectangles, starting at the center and increasing in size at 
        /* each draw until the LCD borders are met. Increasing the counter value will 
        /* expand the shape size more quickly. */
        for(counter = 0; counter < MIN(GetMaxX() / 2, GetMaxY() / 2) >> 1; counter += 5)
        {	
	        SetColor(BLACK);	// refresh the screen
	        ClearDevice();	
	        SetColor(BRIGHTBLUE);
	        OutTextXY(120, 110, "Rectangle");	// draw the name of the shape in the center
            WAIT_UNTIL_FINISH
            (
                Rectangle
                    (
                        GetMaxX() / 2 - counter * 3 + 6,	// x value of top left corner of rectangle
                        GetMaxY() / 2 - counter * 2 - 8,	// y value of top left corner of rectangle
                        GetMaxX() / 2 + counter * 3 - 6,	// x value of bottom right corner of rectangle
                        GetMaxY() / 2 + counter * 2 + 8     // y value of bottom right corner of rectangle        
                    )
            );
            DelayMs(20); // Display for 20 ms
            
        }

        DelayMs(DEMODELAY); // delay for 1 sec and clear the screen
        SetColor(BLACK);
        ClearDevice();
        
        /* Display multiple triangles, starting at the center and increasing in size at 
        /* each draw until the LCD borders are met. Increasing the counter value will 
        /* expand the shape size more quickly. */
        int i;
		for(counter = 0; counter < MIN(GetMaxX() / 2, GetMaxY() / 2) >> 1; counter += 10)
		{
			SetColor(BLACK);	// refresh the screen
			ClearDevice();
			SetColor(GREEN);	// draw the name of the shape at the center
			OutTextXY(125, 110, "Triangle");
			
			//{160,120,160,120,160,120,160,120} start in center of screen
			triangle[1] = triangle[1] - counter * 2 - 20; 	 // top point y
			triangle[7] = triangle[1];				 		 // top point y (close triangle)
			triangle[2] = triangle[2] - counter * 2 - 58; 	 // left corner point x
			triangle[3] = triangle[3] + counter * 2 + 16;	 // left corner point y
			triangle[4] = triangle[4] + counter * 2 + 58; 	 // right corner point x
			triangle[5] = triangle[5] + counter * 2 + 16;	 // right corner point y
			
			DrawPoly(4, triangle);	// draw the triangle (4 points to enclose it)
			
			// reset each of the triangle points to the center to prevent over expansion
			for (i = 0; i < 8; i++)
				if (i % 2 == 0)
					triangle[i] = 160;
				else
					triangle[i] = 120;
				
			DelayMs(50);	// display for 50 ms
		}
		
       
		DelayMs(DEMODELAY); // delay for 1 sec and clear the screen
    	SetColor(BLACK);
    	ClearDevice();
        
    }
}
コード例 #28
0
ファイル: Rectangle.cpp プロジェクト: kashi29/POSD_HW7
Rectangle Rectangle::getBoundingBox() {
    return Rectangle(x,y,l,w);
}
コード例 #29
0
    void DropDown::drawButton(Graphics *graphics)
    {
        Color faceColor, highlightColor, shadowColor;
        int offset;
        int alpha = getBaseColor().a;

        if (mPushed)
        {
            faceColor = getBaseColor() - 0x303030;
            faceColor.a = alpha;
            highlightColor = faceColor - 0x303030;
            highlightColor.a = alpha;
            shadowColor = faceColor + 0x303030;
            shadowColor.a = alpha;
            offset = 1;
        }
        else
        {
            faceColor = getBaseColor();
            faceColor.a = alpha;
            highlightColor = faceColor + 0x303030;
            highlightColor.a = alpha;
            shadowColor = faceColor - 0x303030;
            shadowColor.a = alpha;
            offset = 0;
        }

        int h;
        if (mDroppedDown)
        {
            h = mOldH;
        }
        else
        {
            h = getHeight();
        }
        int x = getWidth() - h;
        int y = 0;

        graphics->setColor(faceColor);
        graphics->fillRectangle(Rectangle(x+1, y+1, h-2, h-2));

        graphics->setColor(highlightColor);
        graphics->drawLine(x, y, x+h-1, y);
        graphics->drawLine(x, y+1, x, y+h-1);

        graphics->setColor(shadowColor);
        graphics->drawLine(x+h-1, y+1, x+h-1, y+h-1);
        graphics->drawLine(x+1, y+h-1, x+h-2, y+h-1);

        graphics->setColor(getForegroundColor());

        int i;
        int hh = h / 3;
        int hx = x + h / 2;
        int hy = y + (h * 2) / 3;
        for (i=0; i<hh; i++)
        {
            graphics->drawLine(hx - i + offset,
                               hy - i + offset,
                               hx + i + offset,
                               hy - i + offset);
        }
    }
コード例 #30
0
	void DebugGuiWindowDebugProp::create( DebugGui& debugGui )
	{
		m_inputAction	= InputAction_Invalid;
		m_inputTimer	= 0.0;
		m_holdTimer		= 0.0;
		m_pInputNode	= nullptr;
		m_pSelectedNode	= nullptr;

		m_baseLayout.create();
		m_baseLayout.setExpandChildren( false );

		DebugGuiWindow::create( debugGui, "Debug Properties", m_baseLayout );

		LinkedList< DebugProp >& debugProperties = debugprop::getProperties();

		SizedArray<string> folderNames;
		folderNames.create( debugProperties.getCount() * 5u );

		for (DebugProp& prop : debugProperties)
		{
			string pathName;
			pathName += prop.getModule();
			pathName += "/";
			pathName += prop.getFullName();
			pathName = pathName.toLower();

			int currentIndex = 0;
			while ( currentIndex < (int)pathName.getLength() )
			{
				int nextIndex = pathName.indexOf( '/', currentIndex );
				if ( nextIndex == -1 )
				{
					break;
				}

				const string folderName = pathName.subString( 0, nextIndex );
				if ( folderNames.getIndexOf( folderName ) == TIKI_SIZE_T_MAX )
				{
					folderNames.push( folderName );
				}

				currentIndex = nextIndex + 1;
			}

		}

		m_folderNodes.create( folderNames.getCount() );
		m_propNodes.create( debugProperties.getCount() );

		for (uint folderIndex = 0u; folderIndex < m_folderNodes.getCount(); ++folderIndex)
		{
			const string& name = folderNames[ folderIndex ];
			TreeFolderNode& node = m_folderNodes[ folderIndex ];

			node.id		= folderIndex;
			node.type	= TreeNodeType_Folder;

			int lastIndex = name.lastIndexOf( '/' ) + 1;
			const string nodeName = name.subString( lastIndex, name.getLength() - lastIndex );

			node.fullLayout.create();
			node.nodeLayout.create();
			node.spaceLayout.create();
			node.chilrenLayout.create();

			setLayoutParameters( node.fullLayout );
			setLayoutParameters( node.nodeLayout );
			setLayoutParameters( node.spaceLayout );
			setLayoutParameters( node.chilrenLayout );

			node.expandButton.create( "+" );
			node.nameLabel.create( nodeName.cStr() );

			node.nodeLayout.addChildControl( &node.expandButton );
			node.nodeLayout.addChildControl( &node.nameLabel );

			node.spacer.create( vector::create( 25.0f, 0.0f ) );

			node.spaceLayout.addChildControl( &node.spacer );
			node.spaceLayout.addChildControl( &node.chilrenLayout );

			node.fullLayout.addChildControl( &node.nodeLayout );
			node.fullLayout.addChildControl( &node.spaceLayout );

			node.parentIndex = TIKI_SIZE_T_MAX;
			if ( lastIndex == 0 )
			{
				m_baseLayout.addChildControl( &node.fullLayout );
			}
			else
			{
				const string parentName = name.subString( 0, lastIndex - 1 );
				for (uint parentIndex = 0u; parentIndex < folderIndex; ++parentIndex)
				{
					if ( folderNames[ parentIndex ] == parentName )
					{
						node.parentIndex = parentIndex;
					}
				}
				TIKI_ASSERT( node.parentIndex != TIKI_SIZE_T_MAX );
			}
		}

		uint propIndex = 0;
		for (DebugProp& prop : debugProperties)
		{
			TreePropNode& node = m_propNodes[ propIndex ];

			node.id			= propIndex;
			node.type		= TreeNodeType_Property;
			node.pProperty	= &prop;

			node.nodeLayout.create();
			setLayoutParameters( node.nodeLayout );

			node.nameLabel.create( prop.getName() );
			node.valueAlignment.create( DebugGuiAlignment::OrientationFlags_X, vector::create( 400.0f, 0.0f ) );
			setDebugPropText( node.valueLabel, prop );

			node.nodeLayout.addChildControl( &node.nameLabel );
			node.nodeLayout.addChildControl( &node.valueAlignment );
			node.nodeLayout.addChildControl( &node.valueLabel );

			string pathName;
			pathName += prop.getModule();
			pathName += "/";
			pathName += prop.getFullName();
			pathName = pathName.toLower();
			pathName = pathName.subString( 0, pathName.lastIndexOf( '/' ) );

			node.parentIndex = TIKI_SIZE_T_MAX;
			for (uint parentIndex = 0u; parentIndex < m_folderNodes.getCount(); ++parentIndex)
			{
				if (folderNames[ parentIndex ] == pathName )
				{
					node.parentIndex = parentIndex;
				}
			}
			TIKI_ASSERT( node.parentIndex != TIKI_SIZE_T_MAX );

			propIndex++;
		}

		folderNames.dispose();

		setRectangle( Rectangle( 20.0, 40.0f, 200.0f, 400.0f ) );
	}