EXPORT_C void CEikCapCArray::SetRect(const TRect &aRect) { SetRect(aRect, 0, -1, -1); }
cglApp::cglApp(int nW, int nH, void* hInst, int nCmdShow) : m_hWnd(NULL) , m_hInstance(hInst) , m_nClearColor(0xFF007F00) , m_pD3D(NULL) , m_nFrameCount(0) , m_rPrevTime(0.0f) { // Register window class WNDCLASS wndClass; wndClass.style = 0; wndClass.lpfnWndProc = D3DBaseAppCallback; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 4; wndClass.hInstance = HINSTANCE(hInst); wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); wndClass.hbrBackground = HBRUSH(GetStockObject(WHITE_BRUSH)); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = s_windowClassName; RegisterClass(&wndClass); // Adjust window in regard to client area nW x nH int nStyle = WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; RECT rRect; SetRect(&rRect, 0, 0, nW, nH); AdjustWindowRect(&rRect, nStyle, TRUE); // Create main window m_hWnd = NULL; m_hWnd = (void*)CreateWindow(s_windowClassName, getWindowText(), nStyle, CW_USEDEFAULT, CW_USEDEFAULT, (rRect.right - rRect.left), (rRect.bottom - rRect.top), NULL, NULL, HINSTANCE(hInst), NULL); if (m_hWnd == NULL) return; // Set pointer SetWindowLong(HWND(m_hWnd), 0, LONG(this)); // Show window ShowWindow(HWND(m_hWnd), nCmdShow); UpdateWindow(HWND(m_hWnd)); // We need to determine the BPP of desktop HDC hDC = GetDC(HWND(m_hWnd)); // Get DC of desktop int nBPP = GetDeviceCaps(hDC, BITSPIXEL); // Retrieve BPP ReleaseDC(HWND(m_hWnd), hDC); // Release DC handle // Create our D3D class cglD3D::CreateParams params; params.hWnd = m_hWnd; params.nBPP = (nBPP == 32) ? cglD3D::BPP_32 : cglD3D::BPP_16; params.nWidth = nW; params.nHeight = nH; m_pD3D = new cglD3D(params); // Check creation result if (m_pD3D == NULL || m_pD3D->isFailed()) return; // Init random generator srand(0); }
LRESULT CALLBACK WinProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) { PAINTSTRUCT Ps; switch(msg) { case WM_CREATE: { /** * Create AddFood Button */ HFONT hFont = CreateFont(30,0,0,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS,NULL, VARIABLE_PITCH,TEXT("Impact")); HWND hButtonAddFood = CreateWindowEx(NULL, "BUTTON", "ADD FOOD", WS_TABSTOP|WS_VISIBLE| WS_CHILD|BS_DEFPUSHBUTTON|BS_TOP, 10, 150, 100, 25, hWnd, (HMENU)BUTTON_ADD_FOOD, GetModuleHandle(NULL), NULL); /** * Create button ShowFoodNumber */ HWND hShowFoodNumber = CreateWindowEx(NULL, "BUTTON", "Funny", WS_TABSTOP|WS_VISIBLE| WS_CHILD|BS_DEFPUSHBUTTON|BS_TOP, 10, 180, 300, 40, hWnd, (HMENU)BUTTON_DISPLAY_FOOD_NR, GetModuleHandle(NULL), NULL); SendMessage (hShowFoodNumber, WM_SETFONT, WPARAM (hFont), TRUE); /** * Draw Food List (In a input box) */ hFoodList = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD|WS_VISIBLE|WS_VSCROLL|ES_READONLY| ES_MULTILINE, 10, 40, 300, 100, hWnd, (HMENU)INPUT_TEXT_SHOW_FOOD, GetModuleHandle(NULL), NULL); /** * Draw main Input food field */ hInputFood = CreateWindowEx( (DWORD)NULL, TEXT("edit"), "", WS_VISIBLE | WS_CHILD | WS_BORDER, 120, 150, 190, 25, hWnd, (HMENU)INPUT_TEXT_ADD_FOOD, GetModuleHandle(NULL), NULL); } break; case WM_PAINT: { HDC hdc = BeginPaint(hWnd, &Ps); RECT rect; /** * Draw Text */ // Second Text char foodNrMessage[256] = "Number : "; char nr[50]; strcat(foodNrMessage, itoa(foodNumber, nr, 10)); SetBkMode(hdc, TRANSPARENT); SetRect(&updateRect, 210, 10, 300, 30); DrawText( hdc, foodNrMessage, -1, &updateRect, DT_SINGLELINE | DT_NOCLIP ) ; // First Text HFONT hFont = CreateFont(25,0,0,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS,NULL, VARIABLE_PITCH,TEXT("Impact")); SetRect(&rect, 10, 10, 50, 50); SelectObject(hdc, hFont); SetBkMode(hdc, OPAQUE); SetBkColor(hdc, RGB(0,255,255)); SetTextColor(hdc, RGB(255,0,0)); DrawText(hdc, TEXT(firstText), -1,&rect, DT_NOCLIP); EndPaint(hWnd, &Ps); } break; case WM_CTLCOLOREDIT: { HDC hdc = (HDC)wParam; HWND hwnd = (HWND)lParam; HBRUSH color; if (GetDlgCtrlID(hwnd) == INPUT_TEXT_ADD_FOOD) { color = CreateSolidBrush(RGB(225, 225, 225)); SetTextColor(hdc, RGB(0, 0, 255)); SetBkMode(hdc, TRANSPARENT); SetBkColor(hdc,(LONG)color); } return (LONG) color; } break; case WM_COMMAND: { switch(LOWORD(wParam)) { case BUTTON_ADD_FOOD: { char buffer[256]; SendMessage(hInputFood, WM_GETTEXT, sizeof(buffer)/sizeof(buffer[0]), reinterpret_cast<LPARAM>(buffer)); if(strlen(buffer) > 0){ char newInput[255] = ""; char stat[30]; strcat(newInput, itoa((foodNumber+1), stat, 10) ); strcat(newInput, " ) "); strcat(newInput, buffer); strcat(newInput, "\r\n"); SendMessage(hFoodList, EM_REPLACESEL, FALSE, (LPARAM)newInput); SendMessage(hInputFood, WM_SETTEXT, NULL, (LPARAM)""); foodNumber++; InvalidateRect(hWnd, &updateRect, TRUE); } } break; case BUTTON_DISPLAY_FOOD_NR: { char buffer[255] = ""; switch(foodNumber){ case 0:http://pastebin.com/62fGU90U case 1: case 2: case 3: strcat(buffer, "You are not hungry at all"); break; case 4: case 5: case 6: strcat(buffer, "I see you are hungry now"); break; default: strcat(buffer, "You are starvin... go get something to eat"); break; } MessageBox(NULL, buffer, "Funny", MB_ICONINFORMATION); } break; } } break; case WM_SIZE: { INT nWidth = LOWORD(lParam); HWND hFunnyButton = GetDlgItem(hWnd, BUTTON_DISPLAY_FOOD_NR); MoveWindow(hFunnyButton, 10, 180, nWidth - 17, 40, TRUE); HWND hShowFoodInput = GetDlgItem(hWnd, INPUT_TEXT_SHOW_FOOD); HWND hAddFood = GetDlgItem(hWnd, INPUT_TEXT_ADD_FOOD); MoveWindow(hShowFoodInput, 10, 40, nWidth - 18, 100, TRUE); MoveWindow(hAddFood, 120, 150, nWidth - 128, 25, TRUE); } break; case WM_GETMINMAXINFO: { MINMAXINFO * mmiStruct; mmiStruct = (MINMAXINFO*)lParam; POINT ptPoint; ptPoint.x = 335; //Minimum width of the window. ptPoint.y = 260; //Minimum height of the window. mmiStruct->ptMinTrackSize = ptPoint; ptPoint.x = GetSystemMetrics(SM_CXMAXIMIZED); //Maximum width of the window. ptPoint.y = GetSystemMetrics(SM_CYMAXIMIZED); //Maximum height of the window. mmiStruct->ptMaxTrackSize = ptPoint; } break; case WM_DESTROY: { PostQuitMessage(0); return 0; } break; } return DefWindowProc(hWnd,msg,wParam,lParam); }
static void drawbmp(fz_context *ctx, fz_document *doc, fz_page *page, fz_display_list *list, int pagenum, fz_cookie *cookie) { float zoom; fz_matrix ctm; fz_irect ibounds; fz_rect bounds, tbounds; int w, h; fz_device *dev; HDC dc, dc_main; RECT rc; HBRUSH bg_brush; HBITMAP hbmp; BITMAPINFO bmi = { 0 }; int bmp_data_len; unsigned char *bmp_data; fz_bound_page(doc, page, &bounds); zoom = resolution / 72; fz_pre_scale(fz_rotate(&ctm, rotation), zoom, zoom); tbounds = bounds; fz_round_rect(&ibounds, fz_transform_rect(&tbounds, &ctm)); w = width; h = height; if (res_specified) { fz_round_rect(&ibounds, &tbounds); if (w && ibounds.x1 - ibounds.x0 <= w) w = 0; if (h && ibounds.y1 - ibounds.y0 <= h) h = 0; } if (w || h) { float scalex = w / (tbounds.x1 - tbounds.x0); float scaley = h / (tbounds.y1 - tbounds.y0); fz_matrix scale_mat; if (w == 0) scalex = fit ? 1.0f : scaley; if (h == 0) scaley = fit ? 1.0f : scalex; if (!fit) scalex = scaley = min(scalex, scaley); fz_concat(&ctm, &ctm, fz_scale(&scale_mat, scalex, scaley)); tbounds = bounds; fz_transform_rect(&tbounds, &ctm); } fz_round_rect(&ibounds, &tbounds); fz_rect_from_irect(&tbounds, &ibounds); w = ibounds.x1 - ibounds.x0; h = ibounds.y1 - ibounds.y0; dc_main = GetDC(NULL); dc = CreateCompatibleDC(dc_main); hbmp = CreateCompatibleBitmap(dc_main, w, h); DeleteObject(SelectObject(dc, hbmp)); SetRect(&rc, 0, 0, w, h); bg_brush = CreateSolidBrush(RGB(0xFF,0xFF,0xFF)); FillRect(dc, &rc, bg_brush); DeleteObject(bg_brush); dev = fz_new_gdiplus_device(ctx, dc, &tbounds); if (list) fz_run_display_list(list, dev, &ctm, &tbounds, cookie); else fz_run_page(doc, page, dev, &ctm, cookie); fz_free_device(dev); bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader); bmi.bmiHeader.biWidth = w; bmi.bmiHeader.biHeight = output_format == OUT_TGA ? -h : h; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = output_format == OUT_TGA ? 32 : 24; bmi.bmiHeader.biCompression = BI_RGB; bmp_data_len = output_format == OUT_TGA ? w * h * 4 : ((w * 3 + 3) / 4) * 4 * h; bmp_data = fz_malloc(ctx, bmp_data_len); if (!GetDIBits(dc, hbmp, 0, h, bmp_data, &bmi, DIB_RGB_COLORS)) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot draw page %d in PDF file '%s'", pagenum, filename); DeleteDC(dc); ReleaseDC(NULL, dc_main); DeleteObject(hbmp); if (output) { char buf[512]; FILE *f; sprintf(buf, output, pagenum); f = fopen(buf, "wb"); if (!f) fz_throw(ctx, FZ_ERROR_GENERIC, "could not create raster file '%s'", buf); if (output_format == OUT_TGA) { fz_pixmap *pix = fz_new_pixmap_with_data(ctx, fz_device_bgr(ctx), w, h, bmp_data); fz_write_tga(ctx, pix, buf, 0); fz_drop_pixmap(ctx, pix); } else { BITMAPFILEHEADER bmpfh = { 0 }; static const int one = 1; if (!*(char *)&one) fz_throw(ctx, FZ_ERROR_GENERIC, "rendering to BMP is not supported on big-endian architectures"); bmpfh.bfType = MAKEWORD('B', 'M'); bmpfh.bfOffBits = sizeof(bmpfh) + sizeof(bmi); bmpfh.bfSize = bmpfh.bfOffBits + bmp_data_len; fwrite(&bmpfh, sizeof(bmpfh), 1, f); fwrite(&bmi, sizeof(bmi), 1, f); fwrite(bmp_data, 1, bmp_data_len, f); } fclose(f); } if (showmd5) { fz_pixmap *pix = fz_new_pixmap_with_data(ctx, fz_device_bgr(ctx), bmp_data_len / 4 / h, h, bmp_data); unsigned char digest[16]; int i; fz_md5_pixmap(pix, digest); printf(" "); for (i = 0; i < 16; i++) printf("%02x", digest[i]); fz_drop_pixmap(ctx, pix); } fz_free(ctx, bmp_data); }
/** * Handle global resource changes, such as scalable UI or skin events (override) */ void CNPRListBox::HandleResourceChange( TInt aType ) { CCoeControl::HandleResourceChange( aType ); SetRect( iAvkonViewAppUi->View( TUid::Uid( ENPRListBoxViewId ) )->ClientRect() ); }
static void W32_WindowLayoutSetSize(HWND hWnd, RECT *pRect, int dwWidth, int dwHeight, bool bFullScrn, bool bResizable) // Must be in called at D3Dx window creation { DWORD dwStyle = GetWindowStyle(hWnd); DWORD dwExStyle = GetWindowExStyle( hWnd); RECT rc; // If we are still a WS_POPUP window we should convert to a normal app // window so we look like a windows app. if (!bFullScrn) { #if _WIN32_WCE dwExStyle|= bResizable ? WS_EX_WINDOWEDGE : 0; // Window Extended Style dwStyle|= WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // Windows Style #else dwExStyle|=WS_EX_APPWINDOW | (bResizable ? WS_EX_WINDOWEDGE : 0); // Window Extended Style dwStyle|= WS_OVERLAPPED| WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; // Windows Style if (bResizable) dwStyle|= WS_THICKFRAME | WS_MAXIMIZEBOX; #endif } else { dwStyle|= WS_POPUP; } SetWindowLong(hWnd, GWL_STYLE, dwStyle); SetWindowLong(hWnd, GWL_EXSTYLE, dwExStyle); if (!bFullScrn) { RECT rcWork; // Center Window SetRect( &rc, 0, 0, dwWidth, dwHeight ); SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWork, 0 ); int cx = (rcWork.right - rcWork.left - (rc.right - rc.left)) >>1; int cy = (rcWork.bottom - rcWork.top - (rc.bottom - rc.top)) >>1; rc.left+=cx; rc.right+=cx; rc.top+=cy; rc.bottom+=cy; // Make sure our window does not hang outside of the work area if( rc.left < rcWork.left ) rc.left = rcWork.left; if( rc.top < rcWork.top ) rc.top = rcWork.top; AdjustWindowRectEx( &rc, GetWindowStyle(hWnd), #if _WIN32_WCE 0, #else GetMenu(hWnd) != NULL, #endif GetWindowExStyle(hWnd) ); SetWindowPos( hWnd, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOZORDER | SWP_NOACTIVATE ); }
Bool winPositionWindowMultiWindow (WindowPtr pWin, int x, int y) { Bool fResult = TRUE; int iX, iY, iWidth, iHeight; ScreenPtr pScreen = pWin->drawable.pScreen; winWindowPriv(pWin); winScreenPriv(pScreen); HWND hWnd = pWinPriv->hWnd; RECT rcNew; RECT rcOld; #if CYGMULTIWINDOW_DEBUG RECT rcClient; RECT *lpRc; #endif DWORD dwExStyle; DWORD dwStyle; #if CYGMULTIWINDOW_DEBUG winTrace ("winPositionWindowMultiWindow - pWin: %p\n", pWin); #endif WIN_UNWRAP(PositionWindow); fResult = (*pScreen->PositionWindow)(pWin, x, y); WIN_WRAP(PositionWindow, winPositionWindowMultiWindow); #if CYGWINDOWING_DEBUG ErrorF ("winPositionWindowMultiWindow: (x, y) = (%d, %d)\n", x, y); #endif /* Bail out if the Windows window handle is bad */ if (!hWnd) { #if CYGWINDOWING_DEBUG ErrorF ("\timmediately return since hWnd is NULL\n"); #endif return fResult; } /* Get the Windows window style and extended style */ dwExStyle = GetWindowLongPtr (hWnd, GWL_EXSTYLE); dwStyle = GetWindowLongPtr (hWnd, GWL_STYLE); /* Get the X and Y location of the X window */ iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN); iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN); /* Get the height and width of the X window */ iWidth = pWin->drawable.width; iHeight = pWin->drawable.height; /* Store the origin, height, and width in a rectangle structure */ SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight); #if CYGMULTIWINDOW_DEBUG lpRc = &rcNew; ErrorF ("winPositionWindowMultiWindow - (%d ms)drawable (%d, %d)-(%d, %d)\n", GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom); #endif /* * Calculate the required size of the Windows window rectangle, * given the size of the Windows window client area. */ AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle); /* Get a rectangle describing the old Windows window */ GetWindowRect (hWnd, &rcOld); #if CYGMULTIWINDOW_DEBUG /* Get a rectangle describing the Windows window client area */ GetClientRect (hWnd, &rcClient); lpRc = &rcNew; ErrorF ("winPositionWindowMultiWindow - (%d ms)rcNew (%d, %d)-(%d, %d)\n", GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom); lpRc = &rcOld; ErrorF ("winPositionWindowMultiWindow - (%d ms)rcOld (%d, %d)-(%d, %d)\n", GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom); lpRc = &rcClient; ErrorF ("(%d ms)rcClient (%d, %d)-(%d, %d)\n", GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom); #endif /* Check if the old rectangle and new rectangle are the same */ if (!EqualRect (&rcNew, &rcOld)) { #if CYGMULTIWINDOW_DEBUG ErrorF ("winPositionWindowMultiWindow - Need to move\n"); #endif #if CYGWINDOWING_DEBUG ErrorF ("\tMoveWindow to (%ld, %ld) - %ldx%ld\n", rcNew.left, rcNew.top, rcNew.right - rcNew.left, rcNew.bottom - rcNew.top); #endif /* Change the position and dimensions of the Windows window */ MoveWindow (hWnd, rcNew.left, rcNew.top, rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, TRUE); } else { #if CYGMULTIWINDOW_DEBUG ErrorF ("winPositionWindowMultiWindow - Not need to move\n"); #endif } return fResult; }
BOOL CWinMenu::GetMenuRect(long x, long y, LPRECT pRect) { if ( pRect == NULL ) return FALSE; long w = 0; long h = 8; RECT rect; CText text; HDC hDC = ::GetDC( NULL ); // Punt if no dc if ( hDC == NULL ) return FALSE; m_tw = w; m_th = 20; // What font does the user want for menu's? NONCLIENTMETRICS info; info.cbSize = sizeof(info); SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof( info ), &info, 0 ); text.SetWeight( FW_BOLD ); text.SetFont( &info.lfMenuFont ); // Handle NULL menu if ( m_mitems.Size() == 0 ) { // Get size of empty string SetRect( &rect, 0, 0, 10, 10 ); // text.SetFlags( DT_SINGLELINE | DT_CENTER | DT_VCENTER ); text.SetFlags( 0 ); text.CalcRect( hDC, EMPTY_STR, &rect ); // Save text params w = ( rect.right - rect.left ); if ( rect.bottom - rect.top > 20 ) { m_th = rect.bottom - rect.top; h += m_th; } else h += 20; } // end if LPMITEMINFO pmi = NULL; while( ( pmi = (LPMITEMINFO)m_mitems.GetNext( pmi ) ) != NULL ) { if ( *pmi->name != NULL ) { // Acc. width SetRect( &rect, 0, 0, 10, 10 ); // text.SetFlags( DT_SINGLELINE | DT_CENTER | DT_VCENTER ); text.SetFlags( DT_SINGLELINE | DT_VCENTER ); text.CalcRect( hDC, pmi->name, &rect ); RECT rrect; if ( *pmi->rtext != 0 ) { SetRect( &rect, 0, 0, 10, 10 ); text.CalcRect( hDC, pmi->rtext, &rrect ); } // end if else ZeroMemory( &rrect, sizeof( rrect ) ); long cw = ( ( rect.right - rect.left ) + MARGIN ); // Add toolbar size if ( pmi->toolbar != NULL ) cw += pmi->toolbar->GetWidth(); // Track width if ( cw > w ) w = cw; if ( ( rect.bottom - rect.top ) > 20 ) { m_th = rect.bottom - rect.top; h += m_th; } // end if else h += 20; } // end if else h += 6; } // end while // Correct width w += ( m_th * 3 ); if ( w < 80 ) w = 80; m_tw = w; ::ReleaseDC( NULL, hDC ); pRect->left = x; pRect->right = x + w; pRect->top = y; pRect->bottom = y + h; // Correct if drifting offscreen if ( m_bCorrectOverhang ) { long ox = 0, oy = 0; if ( pRect->left < 10 ) ox = 10 - pRect->left; if ( pRect->top < 10 ) oy = 10 - pRect->top; // Offset rect if needed if ( ox || oy ) OffsetRect( pRect, ox, oy ); } // end if return TRUE; }
BOOL CWinMenu::DrawMenuItems(HDC hDC, LPRECT pRect) { if ( hDC == NULL || pRect == NULL ) return FALSE; BOOL bFirst = m_bFirstDraw; m_bFirstDraw = FALSE; CText text; long x = pRect->left + 4; long y = pRect->top + 4; long w = pRect->right - pRect->left - 8; long bx = x; long by = y; // Set colors COLORREF rgbMenu, rgbMenuText, rgbSel, rgbSelText; if ( m_bSystemColors ) { rgbMenu = GetSysColor( COLOR_MENU ); rgbMenuText = GetSysColor( COLOR_MENUTEXT ); rgbSel = GetSysColor( COLOR_HIGHLIGHT ); rgbSelText = GetSysColor( COLOR_HIGHLIGHTTEXT ); } // end if else { rgbMenu = m_rgbMenu; rgbMenuText = m_rgbMenuText; rgbSel = m_rgbSel; rgbSelText = m_rgbSelText; } // end else COLORREF rgbLightPen = ScaleColor( rgbMenu, 100 ); COLORREF rgbDarkPen = ScaleColor( rgbMenu, -150 ); COLORREF rgbBck = rgbMenu; COLORREF rgbBckLt = ScaleColor( rgbBck, 40 ); COLORREF rgbBckDk = ScaleColor( rgbBck, -40 ); COLORREF rgbSelLt = ScaleColor( rgbSel, 80 ); COLORREF rgbSelDk = ScaleColor( rgbSel, -120 ); COLORREF rgbSelTextLt = ScaleColor( rgbSelText, 80 ); COLORREF rgbSelTextDk = ScaleColor( rgbSelText, -150 ); COLORREF rgbBumpLt = ScaleColor( rgbBck, 120 ); COLORREF rgbBumpDk = ScaleColor( rgbBck, -120 ); COLORREF rgbText = rgbMenuText; COLORREF rgbTextLt = ScaleColor( rgbBck, 100 ); COLORREF rgbTextDk = ScaleColor( rgbBck, -100 ); if ( GetColorAvg( rgbSel ) > 128 ) { COLORREF swap = rgbSelTextLt; rgbSelTextLt = rgbSelTextDk; rgbSelTextDk = swap; } // end if // What font does the user want for menu's? NONCLIENTMETRICS info; info.cbSize = sizeof(info); SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof( info ), &info, 0 ); // Check for empty menu if ( m_mitems.Size() == 0 ) { COLORREF rgbEmptyLt = ScaleColor( rgbBck, 120 ); COLORREF rgbEmptyDk = ScaleColor( rgbBck, -120 ); if ( GetColorAvg( rgbBck ) < 128 ) { COLORREF swap = rgbEmptyLt; rgbEmptyLt = rgbEmptyDk; rgbEmptyDk = swap; } // end if RECT t; CopyRect( &t, pRect ); text.SetWeight( FW_BOLD ); text.SetFont( &info.lfMenuFont ); text.SetFlags( DT_SINGLELINE | DT_CENTER | DT_VCENTER ); // Make text look recessed OffsetRect( &t, -1, -1 ); text.SetColor( rgbEmptyDk ); text.DrawText( hDC, EMPTY_STR, &t ); OffsetRect( &t, 1, 1 ); text.SetColor( rgbEmptyLt ); text.DrawText( hDC, EMPTY_STR, &t ); } // end if // This kinda bites, but we need to know how far to offset the text BOOL islots = 0; LPMITEMINFO pmi = NULL; while( islots < 2 && ( pmi = (LPMITEMINFO)m_mitems.GetNext( pmi ) ) != NULL ) { // Do we need both icon slots? if ( pmi->icon != NULL && pmi->b != NULL ) islots = 2; // Do we have one islot already? else if ( islots < 1 ) { if ( pmi->icon != NULL ) islots = 1; else if ( pmi->b != NULL && m_hCheck == NULL && m_hUncheck == NULL ) islots = 1; } // end else if } // end while // The icon size long iconsize = m_th - 4; // Draw each item pmi = NULL; while( ( pmi = (LPMITEMINFO)m_mitems.GetNext( pmi ) ) != NULL && x < pRect->right && y < pRect->bottom ) { // Set base coords bx = x; by = y; if ( *pmi->name != NULL ) { POINT pt; GetCursorPos( &pt ); ScreenToClient( &pt ); // Is this item being selected? BOOL bSelected = FALSE; RECT hl; hl.left = pRect->left + 3; hl.right = pRect->right - 4; hl.top = by; hl.bottom = by + m_th; // if ( pt.x > hl.left && pt.x < hl.right && // pt.y > hl.top && pt.y < hl.bottom ) // Add for toolbar if ( pmi->toolbar != NULL && pmi->toolbar->GetNumButtons() ) hl.left += pmi->toolbar->GetWidth(); if ( pmi == m_itemover ) { bSelected = TRUE; // HPEN whitepen = CreatePen( PS_SOLID, 1, RGB( 255, 255, 255 ) ); // HPEN dkgraypen = CreatePen( PS_SOLID, 1, RGB( 50, 50, 50 ) ); HPEN whitepen = CreatePen( PS_SOLID, 1, rgbLightPen ); HPEN dkgraypen = CreatePen( PS_SOLID, 1, rgbDarkPen ); HPEN oldpen = (HPEN)SelectObject( hDC, whitepen ); // Draw white line MoveToEx( hDC, hl.right, hl.top, NULL ); LineTo( hDC, hl.right, hl.bottom ); LineTo( hDC, hl.left, hl.bottom ); // Draw dark gray line SelectObject( hDC, dkgraypen ); MoveToEx( hDC, hl.right, hl.top, NULL ); LineTo( hDC, hl.left, hl.top ); LineTo( hDC, hl.left, hl.bottom ); SelectObject( hDC, oldpen ); DeleteObject( whitepen ); DeleteObject( dkgraypen ); // InflateRect( &hl, -1, -1 ); hl.left += 1; hl.top += 1; // GradientFill( hDC, &hl, RGB( 170, 170, 190 ), RGB( 110, 110, 110 ) ); CGrDC::VertGradientFill( hDC, &hl, rgbSelLt, rgbSelDk ); /* HBRUSH brush = CreateSolidBrush( RGB( 120, 120, 120 ) ); FillRect( hDC, &hl, brush ); DeleteObject( brush ); */ } // end if // Draw toolbar if ( pmi->toolbar != NULL && pmi->toolbar->GetNumButtons() ) { pmi->toolbar->SetHeight( m_th ); RECT tbar; SetRect( &tbar, bx, by, bx + pmi->toolbar->GetWidth(), by + pmi->toolbar->GetHeight() ); if ( bFirst ) pmi->toolbar->CreateToolTips( GetSafeHwnd(), &tbar ); pmi->toolbar->SetMessageTarget( GetSafeHwnd(), WM_MENUCMD ); pmi->toolbar->Draw( GetSafeHwnd(), hDC, &tbar ); bx += pmi->toolbar->GetWidth(); } // end if RECT t; // Calc text box t.left = bx + 4; t.left += islots * iconsize; t.right = pRect->right; t.top = by; t.bottom = by + m_th; // Draw Check if ( pmi->b != NULL ) { RECT icon; SetRect( &icon, bx + 2, by + 2, bx + 2 + iconsize, by + 2 + iconsize ); if ( *pmi->b != FALSE ) { if ( bSelected && m_hHotCheck != NULL ) CGrDC::DrawIcon( hDC, &icon, m_hHotCheck ); // DrawIconEx( hDC, bx + 2, by + 2, m_hHotCheck, iconsize, iconsize, 0, 0, DI_NORMAL ); else if ( m_hCheck != NULL ) CGrDC::DrawIcon( hDC, &icon, m_hCheck ); // DrawIconEx( hDC, bx + 2, by + 2, m_hCheck, iconsize, iconsize, 0, 0, DI_NORMAL ); } // end if else { if ( bSelected && m_hHotUncheck != NULL ) CGrDC::DrawIcon( hDC, &icon, m_hHotUncheck ); // DrawIconEx( hDC, bx + 2, by + 2, m_hHotUncheck, iconsize, iconsize, 0, 0, DI_NORMAL ); else if ( m_hUncheck != NULL ) CGrDC::DrawIcon( hDC, &icon, m_hUncheck ); // DrawIconEx( hDC, bx + 2, by + 2, m_hUncheck, iconsize, iconsize, 0, 0, DI_NORMAL ); } // end else } // end if // Draw icon if ( pmi->icon != NULL ) { long xoff = 2; xoff += iconsize * ( islots - 1 ) + 1; // DrawIconEx( hDC, x + xoff, y + 2, pmi->icon, // 16, 16, 0, 0, DI_NORMAL ); DrawIconEx( hDC, bx + xoff, by + 2, pmi->icon, iconsize, iconsize, 0, 0, DI_NORMAL ); } // end if // Setup the text object text.SetFlags( DT_SINGLELINE | DT_VCENTER ); if ( bSelected ) { text.SetWeight( FW_BOLD ); text.SetFont( &info.lfMenuFont ); // Make text look recessed OffsetRect( &t, -1, -1 ); // text.SetColor( RGB( 0, 0, 0 ) ); text.SetColor( rgbSelTextDk ); text.DrawText( hDC, pmi->name, &t ); OffsetRect( &t, 1, 1 ); text.SetColor( rgbSelTextLt ); } // end if else { // text.SetItalic( FALSE ); text.SetWeight( FW_BOLD ); text.SetFont( &info.lfMenuFont ); // text.SetFont( TFONTSIZE, TFONTTYPE ); // text.SetColor( RGB( 0, 50, 128 ) ); text.SetColor( rgbText ); } // end else // else text.SetColor( rgbText ); // text.SetColor( RGB( 0, 50, 128 ) ); text.DrawText( hDC, pmi->name, &t ); // Draw sub menu indicator if ( pmi->submenu != NULL ) { // Do we have a tick mark icon? if ( m_hTick != NULL ) { RECT ic; SetRect( &ic, t.right - 18, t.top + 5, t.right - 8, t.bottom - 7 ); // Colorize tick icon HICON hMono = NULL; if ( !pmi->submenu->IsEmpty() ) hMono = CGrDC::CreateMonoChromeIcon( m_hTick, GetSysColor( COLOR_ACTIVECAPTION ) ); else hMono = CGrDC::CreateMonoChromeIcon( m_hTick, GetSysColor( COLOR_INACTIVECAPTION ) ); // hMono = CGrDC::CreateMonoChromeIcon( m_hTick, rgbSel ); // else hMono = CGrDC::CreateMonoChromeIcon( m_hTick, rgbBck ); // Draw the icon if ( hMono != NULL ) { CGrDC::DrawIcon( hDC, &ic, hMono ); DestroyIcon( hMono ); } // end if } // end if else { HPEN whitepen = CreatePen( PS_SOLID, 1, rgbLightPen ); HPEN dkgraypen = CreatePen( PS_SOLID, 1, ScaleColor( rgbBck, -10 ) ); HPEN blackpen = CreatePen( PS_SOLID, 1, ScaleColor( rgbBck, -40 ) ); HPEN oldpen = (HPEN)SelectObject( hDC, whitepen ); HBRUSH mbrush; if ( !pmi->submenu->IsEmpty() ) mbrush = CreateSolidBrush( rgbBck ); else mbrush = CreateSolidBrush( ScaleColor( rgbBck, -80 ) ); HBRUSH oldbrush = (HBRUSH)SelectObject( hDC, mbrush ); POINT pts[ 3 ]; pts[ 0 ].x = t.right - 14; pts[ 0 ].y = t.top + 5; pts[ 1 ].x = t.right - 14; pts[ 1 ].y = t.bottom - 7; pts[ 2 ].x = t.right - 8; pts[ 2 ].y = t.top + ( ( t.bottom - t.top ) / 2 ); // Draw the shape Polygon( hDC, pts, sizeof( pts ) / sizeof( POINT ) ); // Draw border MoveToEx( hDC, pts[ 0 ].x, pts[ 0 ].y, NULL ); LineTo( hDC, pts[ 1 ].x, pts[ 1 ].y ); SelectObject( hDC, blackpen ); LineTo( hDC, pts[ 2 ].x, pts[ 2 ].y ); SelectObject( hDC, dkgraypen ); LineTo( hDC, pts[ 0 ].x, pts[ 0 ].y ); // Release drawing objects SelectObject( hDC, oldpen ); DeleteObject( whitepen ); DeleteObject( dkgraypen ); DeleteObject( blackpen ); SelectObject( hDC, oldbrush ); DeleteObject( mbrush ); } // end if } // end if // Next menu item position y += m_th; } // end if else // separator { // HPEN whitepen = CreatePen( PS_SOLID, 1, RGB( 255, 255, 255 ) ); // HPEN dkgraypen = CreatePen( PS_SOLID, 1, RGB( 50, 50, 50 ) ); HPEN whitepen = CreatePen( PS_SOLID, 1, rgbBumpLt ); HPEN dkgraypen = CreatePen( PS_SOLID, 1, rgbBumpDk ); HPEN oldpen = (HPEN)SelectObject( hDC, whitepen ); // Draw white line MoveToEx( hDC, bx + 2, by + 2, NULL ); LineTo( hDC, ( pRect->right - pRect->left ) - 2, by + 2 ); // Draw dark gray line SelectObject( hDC, dkgraypen ); MoveToEx( hDC, bx + 2, by + 3, NULL ); LineTo( hDC, ( pRect->right - pRect->left ) - 2, by + 3 ); SelectObject( hDC, oldpen ); DeleteObject( whitepen ); DeleteObject( dkgraypen ); y += 6; } // end else } // end while return TRUE; }
//在錄製OpengL動畫之前,首先需要設置AVI文件名稱、錄製幀的大小、錄製幀率、AVI文件壓縮方式等信息,具體的源代碼如下: bool CAVICapture::start(CString filename,int w, int h,float fps) { if (capturing) return false; width = w; height = h; frameRate = fps; if (HIWORD(VideoForWindowsVersion()) < 0x010a) { // 版本號必須大於1.1 return false; } int rowBytes = (width * 3 + 3) & ~0x3; image = new unsigned char[rowBytes * height]; // 創建AVI文件 HRESULT hr = AVIFileOpen(&aviFile, filename, OF_WRITE | OF_CREATE, NULL); if (hr != AVIERR_OK) { MessageBox(NULL,"創建AVI文件失敗","錯誤",MB_OK); return false; } // AVI文件的頭信息 AVISTREAMINFO info; ZeroMemory(&info, sizeof info); info.fccType = streamtypeVIDEO; info.fccHandler = 0; info.dwScale = 1; info.dwRate = (DWORD) frameRate; info.dwSuggestedBufferSize = rowBytes * height; SetRect(&info.rcFrame, 0, 0, width, height); hr = AVIFileCreateStream(aviFile, &aviStream, &info);//創建AVI文件流 if (hr != AVIERR_OK) { MessageBox(NULL,"創建AVI文件流失敗","錯誤",MB_OK); cleanup(); //清空內存 return false; } // 允許用戶選擇壓縮方式 AVICOMPRESSOPTIONS options; AVICOMPRESSOPTIONS* arrOptions[1] = { &options }; ZeroMemory(&options, sizeof options); if (!AVISaveOptions(NULL, 0, 1, &aviStream, (LPAVICOMPRESSOPTIONS*) &arrOptions)) { cleanup();//清空內存 return false; } //設置AVI壓縮方式 hr = AVIMakeCompressedStream(&compAviStream, aviStream, &options, NULL); if (hr != AVIERR_OK) { MessageBox(NULL,"設置AVI壓縮方式失敗", "錯誤",MB_OK); cleanup();//清空內存 return false; } BITMAPINFOHEADER bi; ZeroMemory(&bi, sizeof bi); bi.biSize = sizeof bi; bi.biWidth = width; bi.biHeight = height; bi.biPlanes = 1; bi.biBitCount = 24; bi.biCompression = BI_RGB; bi.biSizeImage = rowBytes * height; bi.biXPelsPerMeter = 0; bi.biYPelsPerMeter = 0; bi.biClrUsed = 0; bi.biClrImportant = 0; // 設置數據格式 hr = AVIStreamSetFormat(compAviStream, 0, &bi, sizeof bi); if (hr != AVIERR_OK) { MessageBox(NULL,"設置AVI數據格式","錯誤",MB_OK); cleanup();//清空內存 return false; } capturing = true; frameCounter = 0; return true; }
LRESULT CALLBACK PalWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_PAINT: { RECT rc = { 0, 0, 31, 32 }; HDC hDC = GetDC(hwnd); HPEN oldPen; HBRUSH oldBrush; int i, a, b; DefWindowProc(hwnd, message, wParam, lParam); for(b = 2; b < 30; b++) for(a = 2; a < 29; a++) if ((a + b) % 2 == 1) SetPixel(hDC, a, b, GetSysColor(COLOR_BTNHILIGHT)); DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT); DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_TOPLEFT | BF_BOTTOMRIGHT); SetRect(&rc, 11, 12, 26, 27); DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); oldPen = SelectObject(hDC, CreatePen(PS_NULL, 0, 0)); oldBrush = SelectObject(hDC, CreateSolidBrush(bgColor)); Rectangle(hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1); DeleteObject(SelectObject(hDC, oldBrush)); SetRect(&rc, 4, 5, 19, 20); DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); oldBrush = SelectObject(hDC, CreateSolidBrush(fgColor)); Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1); DeleteObject(SelectObject(hDC, oldBrush)); DeleteObject(SelectObject(hDC, oldPen)); for(i = 0; i < 28; i++) { SetRect(&rc, 31 + (i % 14) * 16, 0 + (i / 14) * 16, 16 + 31 + (i % 14) * 16, 16 + 0 + (i / 14) * 16); DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT); DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_RECT); oldPen = SelectObject(hDC, CreatePen(PS_NULL, 0, 0)); oldBrush = SelectObject(hDC, CreateSolidBrush(palColors[i])); Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1); DeleteObject(SelectObject(hDC, oldBrush)); DeleteObject(SelectObject(hDC, oldPen)); } ReleaseDC(hwnd, hDC); break; } case WM_LBUTTONDOWN: if (GET_X_LPARAM(lParam) >= 31) { fgColor = palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14]; InvalidateRect(hwnd, NULL, FALSE); } break; case WM_RBUTTONDOWN: if (GET_X_LPARAM(lParam) >= 31) { bgColor = palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14]; InvalidateRect(hwnd, NULL, FALSE); } break; case WM_LBUTTONDBLCLK: if (GET_X_LPARAM(lParam) >= 31) if (ChooseColor(&choosecolor)) { palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14] = choosecolor.rgbResult; fgColor = choosecolor.rgbResult; InvalidateRect(hwnd, NULL, FALSE); } break; case WM_RBUTTONDBLCLK: if (GET_X_LPARAM(lParam) >= 31) if (ChooseColor(&choosecolor)) { palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14] = choosecolor.rgbResult; bgColor = choosecolor.rgbResult; InvalidateRect(hwnd, NULL, FALSE); } break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }
MapClass::MapClass() { this->m_Weather =0; this->m_WeatherTimer=GetTickCount(); this->m_NextWeatherTimer=(rand()%10000)+10000; this->init(); SetRect(&this->gRegenRect[0], 130, 116, 151, 137); SetRect(&this->gRegenRect[1], 106, 236, 112, 243); SetRect(&this->gRegenRect[2], 197, 35, 218, 50); SetRect(&this->gRegenRect[3], 174, 101, 187, 125); SetRect(&this->gRegenRect[4], 201, 70, 213, 81); SetRect(&this->gRegenRect[5], 89, 135, 90, 136); SetRect(&this->gRegenRect[6], 89, 135, 90, 136); SetRect(&this->gRegenRect[7], 14, 11, 27, 23); SetRect(&this->gRegenRect[8], 187, 54, 203, 69); SetRect(&this->gRegenRect[33], 82, 8, 87, 14); SetRect(&this->gRegenRect[34], 133, 41, 140, 44); SetRect(&this->gRegenRect[51], 40, 214, 43, 224); //Elbeland?? this->m_ItemCount=0; }
int FileDialog::ShowModal() { OSErr err; NavDialogCreationOptions dialogCreateOptions; // set default options ::NavGetDefaultDialogCreationOptions(&dialogCreateOptions); // this was always unset in the old code dialogCreateOptions.optionFlags &= ~kNavSelectDefaultLocation; wxMacCFStringHolder message(m_message, GetFont().GetEncoding()); dialogCreateOptions.windowTitle = message; wxMacCFStringHolder defaultFileName(m_fileName, GetFont().GetEncoding()); dialogCreateOptions.saveFileName = defaultFileName; NavDialogRef dialog; NavObjectFilterUPP navFilterUPP = NULL; CustomData myData; SetRect(&myData.bounds, 0, 0, 0, 0); myData.me = this; myData.defaultLocation = m_dir; myData.userpane = NULL; myData.choice = NULL; myData.button = NULL; myData.saveMode = false; myData.showing = true; Rect r; SInt16 base; SInt16 margin = 3; SInt16 gap = 0; MakeUserDataRec(&myData , m_wildCard); myData.currentfilter = m_filterIndex; size_t numFilters = myData.extensions.GetCount(); if (numFilters) { CreateNewMenu(0, 0, &myData.menu); for ( size_t i = 0 ; i < numFilters ; ++i ) { ::AppendMenuItemTextWithCFString(myData.menu, wxMacCFStringHolder(myData.name[i], GetFont().GetEncoding()), 4, i, NULL); } SetRect(&r, 0, margin, 0, 0); CreatePopupButtonControl(NULL, &r, CFSTR("Format:"), -12345, false, 50, teJustLeft, normal, &myData.choice); SetControlID(myData.choice, &kChoiceID); SetControlPopupMenuRef(myData.choice, myData.menu); SetControl32BitMinimum(myData.choice, 1); SetControl32BitMaximum(myData.choice, myData.name.GetCount()); SetControl32BitValue(myData.choice, myData.currentfilter + 1); GetBestControlRect(myData.choice, &r, &base); SizeControl(myData.choice, r.right - r.left, r.bottom - r.top); UnionRect(&myData.bounds, &r, &myData.bounds); gap = 15; } if (!m_buttonlabel.IsEmpty()) { wxMacCFStringHolder cfString(wxStripMenuCodes(m_buttonlabel).c_str(), wxFONTENCODING_DEFAULT); SetRect(&r, myData.bounds.right + gap, margin, 0, 0); CreatePushButtonControl(NULL, &r, cfString, &myData.button); SetControlID(myData.button, &kButtonID); GetBestControlRect(myData.button, &r, &base); SizeControl(myData.button, r.right - r.left, r.bottom - r.top); UnionRect(&myData.bounds, &r, &myData.bounds); } // Expand bounding rectangle to include a top and bottom margin myData.bounds.top -= margin; myData.bounds.bottom += margin; dialogCreateOptions.optionFlags |= kNavNoTypePopup; if (m_dialogStyle & wxFD_SAVE) { dialogCreateOptions.modality = kWindowModalityWindowModal; dialogCreateOptions.parentWindow = (WindowRef) GetParent()->MacGetTopLevelWindowRef(); myData.saveMode = true; if (!numFilters) { dialogCreateOptions.optionFlags |= kNavNoTypePopup; } dialogCreateOptions.optionFlags |= kNavDontAutoTranslate; dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems; // The extension is important if (numFilters < 2) dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension; #if TARGET_API_MAC_OSX if (!(m_dialogStyle & wxFD_OVERWRITE_PROMPT)) { dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement; } #endif err = ::NavCreatePutFileDialog(&dialogCreateOptions, // Suppresses the 'Default' (top) menu item kNavGenericSignature, kNavGenericSignature, sStandardNavEventFilter, &myData, // for defaultLocation &dialog); } else { //let people select bundles/programs in dialogs dialogCreateOptions.optionFlags |= kNavSupportPackages; navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback); err = ::NavCreateGetFileDialog(&dialogCreateOptions, NULL, // NavTypeListHandle sStandardNavEventFilter, NULL, // NavPreviewUPP navFilterUPP, (void *) &myData, // inClientData &dialog); } if (err == noErr) err = ::NavDialogRun(dialog); if (err == noErr) { WindowRef w = NavDialogGetWindow(dialog); Rect r; // This creates our "fake" dialog with the same dimensions as the sheet so // that Options dialogs will center properly on the sheet. The "fake" dialog // is never actually seen. GetWindowBounds(w,kWindowStructureRgn, &r); wxDialog::Create(NULL, // no parent...otherwise strange things happen wxID_ANY, wxEmptyString, wxPoint(r.left, r.top), wxSize(r.right - r.left, r.bottom - r.top)); BeginAppModalStateForWindow(w); while (myData.showing) { wxTheApp->MacDoOneEvent(); } EndAppModalStateForWindow(w); } // clean up filter related data, etc. if (navFilterUPP) ::DisposeNavObjectFilterUPP(navFilterUPP); if (err != noErr) return wxID_CANCEL; NavReplyRecord navReply; err = ::NavDialogGetReply(dialog, &navReply); if (err == noErr && navReply.validRecord) { AEKeyword theKeyword; DescType actualType; Size actualSize; FSRef theFSRef; wxString thePath ; m_filterIndex = myData.currentfilter; long count; ::AECountItems(&navReply.selection , &count); for (long i = 1; i <= count; ++i) { err = ::AEGetNthPtr(&(navReply.selection), i, typeFSRef, &theKeyword, &actualType, &theFSRef, sizeof(theFSRef), &actualSize); if (err != noErr) break; if (m_dialogStyle & wxFD_SAVE) thePath = wxMacFSRefToPath( &theFSRef , navReply.saveFileName ) ; else thePath = wxMacFSRefToPath( &theFSRef ) ; if (!thePath) { ::NavDisposeReply(&navReply); return wxID_CANCEL; } m_path = ConvertSlashInFileName(thePath); m_paths.Add(m_path); m_fileName = wxFileNameFromPath(m_path); m_fileNames.Add(m_fileName); } // set these to the first hit m_path = m_paths[0]; m_fileName = wxFileNameFromPath(m_path); m_dir = wxPathOnly(m_path); } ::NavDisposeReply(&navReply); return (err == noErr) ? wxID_OK : wxID_CANCEL; }
bool MCImageBitmapToPICT(MCImageBitmap *p_bitmap, MCMacSysPictHandle &r_pict) { #ifdef LIBGRAPHICS_BROKEN bool t_success = true; Pixmap drawdata = nil, drawmask = nil; MCBitmap *maskimagealpha = nil; t_success = MCImageSplitPixmaps(p_bitmap, drawdata, drawmask, maskimagealpha); if (!t_success) return false; Rect t_rect; SetRect(&t_rect, 0, 0, p_bitmap->width, p_bitmap->height); GWorldPtr t_old_gworld; GDHandle t_old_gdevice; GetGWorld(&t_old_gworld, &t_old_gdevice); PixMapHandle t_draw_pixmap; t_draw_pixmap = GetGWorldPixMap((CGrafPtr)drawdata -> handle . pixmap); GWorldPtr t_img_gworld; t_img_gworld = NULL; if (t_success) { QDErr t_err; t_err = NewGWorld(&t_img_gworld, 32, &t_rect, NULL, NULL, 0); if (t_err != noErr) t_success = false; } if (t_success) { SetGWorld(t_img_gworld, GetGDevice()); PenMode(srcCopy); ForeColor(blackColor); BackColor(whiteColor); if (maskimagealpha != NULL) { GWorldPtr t_alpha_gworld; if (NewGWorldFromPtr(&t_alpha_gworld, 8, &t_rect, GetCTable(40), NULL, 0, maskimagealpha -> data, maskimagealpha -> bytes_per_line) == noErr) { const BitMap *t_dst_bits; t_dst_bits = GetPortBitMapForCopyBits(t_img_gworld); const BitMap *t_src_bits; t_src_bits = GetPortBitMapForCopyBits((CGrafPtr)drawdata -> handle . pixmap); const BitMap *t_mask_bits; t_mask_bits = GetPortBitMapForCopyBits(t_alpha_gworld); EraseRect(&t_rect); CopyDeepMask(t_src_bits, t_mask_bits, t_dst_bits, &t_rect, &t_rect, &t_rect, srcCopy, NULL); } } else if (drawmask != NULL) { PixMapHandle t_mask_pixmap; t_mask_pixmap = GetGWorldPixMap((CGrafPtr)drawmask -> handle . pixmap); EraseRect(&t_rect); const BitMap *t_dst_bits; t_dst_bits = GetPortBitMapForCopyBits(t_img_gworld); const BitMap *t_src_bits; LockPixels(t_draw_pixmap); t_src_bits = (BitMap *)*t_draw_pixmap; const BitMap *t_mask_bits; LockPixels(t_mask_pixmap); t_mask_bits = (BitMap *)*t_mask_pixmap; CopyMask(t_src_bits, t_mask_bits, t_dst_bits, &t_rect, &t_rect, &t_rect); UnlockPixels(t_mask_pixmap); UnlockPixels(t_draw_pixmap); } else { const BitMap *t_dst_bits; t_dst_bits = GetPortBitMapForCopyBits(t_img_gworld); const BitMap *t_src_bits; LockPixels(t_draw_pixmap); t_src_bits = (BitMap *)*t_draw_pixmap; CopyBits(t_src_bits, t_dst_bits, &t_rect, &t_rect, srcCopy, NULL); UnlockPixels(t_draw_pixmap); } } PicHandle t_handle; t_handle = NULL; if (t_success) { OpenCPicParams t_params; t_params . srcRect = t_rect; t_params . hRes = 72 << 16; t_params . vRes = 72 << 16; t_params . version = -2; t_params . reserved1 = 0; t_params . reserved2 = 0; t_handle = OpenCPicture(&t_params); if (t_handle == NULL) t_success = false; } if (t_success) { GWorldPtr t_pict_gworld; GDHandle t_pict_gdevice; GetGWorld(&t_pict_gworld, &t_pict_gdevice); PenMode(srcCopy); ForeColor(blackColor); BackColor(whiteColor); const BitMap *t_dst_bits; t_dst_bits = GetPortBitMapForCopyBits(t_pict_gworld); const BitMap *t_src_bits; t_src_bits = GetPortBitMapForCopyBits(t_img_gworld); CopyBits(t_src_bits, t_dst_bits, &t_rect, &t_rect, srcCopy, NULL); ClosePicture(); } if (t_img_gworld != NULL) DisposeGWorld(t_img_gworld); SetGWorld(t_old_gworld, t_old_gdevice); MCscreen->freepixmap(drawdata); MCscreen->freepixmap(drawmask); if (maskimagealpha != nil) MCscreen->destroyimage(maskimagealpha); if (t_success) r_pict = (MCMacSysPictHandle)t_handle; return t_success; #else return false; #endif }
static u32 win_proc(MSG *pMsg) { HWND hwnd; HDC hdc; RECT rc,rc0; u32 i; hwnd =pMsg->hwnd; switch(pMsg->Code) { case MSG_CREATE: GetClientRect(hwnd,&rc0); CreateWindow(BUTTON,"关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,RectW(&rc0)-64,RectH(&rc0)-28,60,24,hwnd,ID_CLOSE,NULL); SetRect(&rc,4,8,120,100); hwndLB1=CreateWindow(LISTBOX,"列表框1",WS_CHILD|WS_BORDER|WS_VISIBLE,rc.left,rc.top,RectW(&rc),RectH(&rc),hwnd,ID_LISTBOX1,NULL); OffsetRect(&rc,RectW(&rc)+8,0); hwndLB2=CreateWindow(LISTBOX,"列表框2",WS_CHILD|WS_BORDER|WS_VISIBLE,rc.left,rc.top,RectW(&rc),RectH(&rc),hwnd,ID_LISTBOX2,NULL); GetWindowRect(hwndLB1,&rc); OffsetRect(&rc,0,RectH(&rc)+4); ScreenToClient(hwnd,(POINT*)&rc,2); CreateWindow(BUTTON,"-->",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,rc.right-50,rc.top,50,20,hwnd,ID_RIGHT,NULL); GetWindowRect(hwndLB2,&rc); OffsetRect(&rc,0,RectH(&rc)+4); ScreenToClient(hwnd,(POINT*)&rc,2); CreateWindow(BUTTON,"<--",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,rc.left,rc.top,50,20,hwnd,ID_LEFT,NULL); SendMessage(hwndLB1,LBM_ADDSTRING,0,(u32)"ListItem-0"); SendMessage(hwndLB1,LBM_ADDSTRING,1,(u32)"ListItem-1"); SendMessage(hwndLB1,LBM_ADDSTRING,2,(u32)"ListItem-2"); SendMessage(hwndLB1,LBM_ADDSTRING,3,(u32)"ListItem-3"); SendMessage(hwndLB1,LBM_ADDSTRING,4,(u32)"ListItem-4"); SendMessage(hwndLB1,LBM_ADDSTRING,5,(u32)"ListItem-5"); SendMessage(hwndLB1,LBM_ADDSTRING,6,(u32)"ListItem-6"); SendMessage(hwndLB1,LBM_ADDSTRING,7,(u32)"ListItem-7"); SendMessage(hwndLB1,LBM_ADDSTRING,8,(u32)"ListItem-8"); SendMessage(hwndLB1,LBM_ADDSTRING,9,(u32)"ListItem-9"); SendMessage(hwndLB1,LBM_SETTOPINDEX,0,0); SendMessage(hwndLB1,LBM_SETCURSEL,3,0); SendMessage(hwndLB2,LBM_ADDSTRING,0,(u32)"ListItem-10"); SendMessage(hwndLB2,LBM_ADDSTRING,1,(u32)"ListItem-11"); SendMessage(hwndLB2,LBM_ADDSTRING,2,(u32)"ListItem-12"); SendMessage(hwndLB2,LBM_ADDSTRING,3,(u32)"ListItem-13"); SendMessage(hwndLB2,LBM_ADDSTRING,4,(u32)"ListItem-14"); SendMessage(hwndLB2,LBM_ADDSTRING,5,(u32)"ListItem-15"); SendMessage(hwndLB2,LBM_ADDSTRING,6,(u32)"ListItem-16"); SendMessage(hwndLB2,LBM_ADDSTRING,7,(u32)"ListItem-17"); SendMessage(hwndLB2,LBM_ADDSTRING,8,(u32)"ListItem-18"); SendMessage(hwndLB2,LBM_ADDSTRING,9,(u32)"ListItem-19"); SendMessage(hwndLB2,LBM_SETTOPINDEX,0,0); SendMessage(hwndLB2,LBM_SETCURSEL,3,0); GDD_CreateTimer(hwnd,1,3000,TMR_START); GDD_CreateTimer(hwnd,2,100,TMR_START); break; //// case MSG_TIMER: { switch(pMsg->Param1) { case 1: { } break; ///// case 2: { } break; ///// } } break; case MSG_NOTIFY: { u16 event,id; event =HI16(pMsg->Param1); id =LO16(pMsg->Param1); if(event==BTN_UP && id==ID_CLOSE) { PostMessage(hwnd,MSG_CLOSE,0,0); }//// if(event==BTN_UP && id==ID_RIGHT) { char *buf; int i; i =SendMessage(hwndLB1,LBM_GETCURSEL,0,0); if(i>=0) { buf =(char*)malloc(SendMessage(hwndLB1,LBM_GETTEXTLEN,i,0)); if(buf!=NULL) { SendMessage(hwndLB1,LBM_GETTEXT,i,(u32)buf); SendMessage(hwndLB1,LBM_DELSTRING,i,0); SendMessage(hwndLB2,LBM_ADDSTRING,-1,(u32)buf); i=SendMessage(hwndLB2,LBM_GETCOUNT,0,0)-1; SendMessage(hwndLB2,LBM_SETTOPINDEX,i-3,0); SendMessage(hwndLB2,LBM_SETCURSEL,-1,0); free(buf); } } }//// if(event==BTN_UP && id==ID_LEFT) { char *buf; int i; i =SendMessage(hwndLB2,LBM_GETCURSEL,0,0); if(i>=0) { buf =(char*)malloc(SendMessage(hwndLB2,LBM_GETTEXTLEN,i,0)); if(buf!=NULL) { SendMessage(hwndLB2,LBM_GETTEXT,i,(u32)buf); SendMessage(hwndLB2,LBM_DELSTRING,i,0); SendMessage(hwndLB1,LBM_ADDSTRING,-1,(u32)buf); i=SendMessage(hwndLB1,LBM_GETCOUNT,0,0)-1; SendMessage(hwndLB1,LBM_SETTOPINDEX,i-3,0); SendMessage(hwndLB1,LBM_SETCURSEL,-1,0); free(buf); } } }//// if(event==LBN_SELCHANGE && id==ID_LISTBOX1) { printf("listbox1 sel change.\r\n"); }//// if(event==LBN_SELCHANGE && id==ID_LISTBOX2) { printf("listbox2 sel change.\r\n"); }//// } break; //// case MSG_PAINT: { hdc =BeginPaint(hwnd); GetClientRect(hwnd,&rc0); SetFillColor(hdc,RGB(200,200,200)); FillRect(hdc,&rc0); EndPaint(hwnd,hdc); } break; //// default: return DefWindowProc(pMsg); } return 0; }
HRGN DibCreateRegion( LPBYTE lpDib, BYTE byColor ) { LPBYTE lpData; int x, y, cx, cy; DWORD dwMaxRect; RECT r; RGNDATA *pRd; HGLOBAL hMem; HRGN hRgn; if ( !lpDib || DIB_BPP( lpDib ) != 8 ) return NULL; cx = DIB_CX( lpDib ); cy = DIB_CY( lpDib ); dwMaxRect = 3000; hMem = GlobalAlloc( GMEM_FIXED, sizeof(RGNDATAHEADER) + sizeof(RECT) * dwMaxRect ); pRd = (RGNDATA *)GlobalLock( hMem ); pRd->rdh.dwSize = sizeof(RGNDATAHEADER); pRd->rdh.iType = RDH_RECTANGLES; pRd->rdh.nCount = 0; pRd->rdh.nRgnSize = 0; SetRect( &(pRd->rdh.rcBound), cx, cy, 0, 0 ); for ( y = 0; y < cy; y++ ) { lpData = DIB_DATA8XY_INV( lpDib, 0, y ); for ( x = 0; x < cx; x++ ) { if ( *lpData == byColor ) { // get run length rect r.left = x; r.top = r.bottom = y; while ( *lpData == byColor && x < cx ) { x++; lpData++; } r.right = x; // update bound rect if ( r.left < pRd->rdh.rcBound.left ) pRd->rdh.rcBound.left = r.left; if ( r.top < pRd->rdh.rcBound.top ) pRd->rdh.rcBound.top = r.top; if ( r.right > pRd->rdh.rcBound.right ) pRd->rdh.rcBound.right = r.right; if ( r.bottom > pRd->rdh.rcBound.bottom ) pRd->rdh.rcBound.bottom = r.bottom; memcpy( &pRd->Buffer[pRd->rdh.nCount++], &r, sizeof(RECT) ); if ( pRd->rdh.nCount >= dwMaxRect ) goto exitLoop; } lpData++; } } exitLoop: pRd->rdh.nRgnSize = sizeof(RECT) * pRd->rdh.nCount; hRgn = ExtCreateRegion( NULL, sizeof(RGNDATAHEADER) + sizeof(RECT) * pRd->rdh.nCount, pRd ); GlobalUnlock( hMem ); GlobalFree( hMem ); return hRgn; }
/* Crop Tool */ HEToolCrop::HEToolCrop(Workspace *wspc, Frame *frame, Tool *tool) : HistoryElement(wspc, frame, tool) { SetRect(&this->canvasChange,0,0,0,0); }
//------------------------------------------------------------------------ bool platform_support::init(unsigned width, unsigned height, unsigned flags) { if(m_specific->m_sys_format == pix_format_undefined) { return false; } m_window_flags = flags; // application EventTypeSpec eventType; EventHandlerUPP handlerUPP; eventType.eventClass = kEventClassApplication; eventType.eventKind = kEventAppQuit; handlerUPP = NewEventHandlerUPP(DoAppQuit); InstallApplicationEventHandler (handlerUPP, 1, &eventType, nil, nil); eventType.eventClass = kEventClassMouse; eventType.eventKind = kEventMouseDown; handlerUPP = NewEventHandlerUPP(DoMouseDown); InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil); eventType.eventKind = kEventMouseUp; handlerUPP = NewEventHandlerUPP(DoMouseUp); InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil); eventType.eventKind = kEventMouseDragged; handlerUPP = NewEventHandlerUPP(DoMouseDragged); InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil); eventType.eventClass = kEventClassKeyboard; eventType.eventKind = kEventRawKeyDown; handlerUPP = NewEventHandlerUPP(DoKeyDown); InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil); eventType.eventKind = kEventRawKeyUp; handlerUPP = NewEventHandlerUPP(DoKeyUp); InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil); eventType.eventKind = kEventRawKeyRepeat; handlerUPP = NewEventHandlerUPP(DoKeyDown); // 'key repeat' is translated to 'key down' InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil); WindowAttributes windowAttrs; Rect bounds; // window windowAttrs = kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute; SetRect (&bounds, 0, 0, width, height); OffsetRect (&bounds, 100, 100); CreateNewWindow (kDocumentWindowClass, windowAttrs, &bounds, &m_specific->m_window); if(m_specific->m_window == nil) { return false; } // I assume the text is ASCII. // Change to kCFStringEncodingMacRoman, kCFStringEncodingISOLatin1, kCFStringEncodingUTF8 or what else you need. SetWindowTitleWithCFString (m_specific->m_window, CFStringCreateWithCStringNoCopy (nil, m_caption, kCFStringEncodingASCII, nil)); eventType.eventClass = kEventClassWindow; eventType.eventKind = kEventWindowClose; handlerUPP = NewEventHandlerUPP(DoWindowClose); InstallWindowEventHandler (m_specific->m_window, handlerUPP, 1, &eventType, this, NULL); eventType.eventKind = kEventWindowDrawContent; handlerUPP = NewEventHandlerUPP(DoWindowDrawContent); InstallWindowEventHandler (m_specific->m_window, handlerUPP, 1, &eventType, this, NULL); // Periodic task // Instead of an idle function I use the Carbon event timer. // You may decide to change the wait value which is currently 50 milliseconds. EventLoopRef mainLoop; EventLoopTimerUPP timerUPP; EventLoopTimerRef theTimer; mainLoop = GetMainEventLoop(); timerUPP = NewEventLoopTimerUPP (DoPeriodicTask); InstallEventLoopTimer (mainLoop, 0, 50 * kEventDurationMillisecond, timerUPP, this, &theTimer); m_specific->create_pmap(width, height, &m_rbuf_window); m_initial_width = width; m_initial_height = height; on_init(); on_resize(width, height); m_specific->m_redraw_flag = true; ShowWindow (m_specific->m_window); SetPortWindowPort (m_specific->m_window); return true; }
int doMain (int argc, char **argv) { osx_AllowForeground(); // OSG init OSG::osgInit(argc, argv); // create the graph // beacon for camera and light OSG::NodeUnrecPtr b1n = OSG::Node::create(); OSG::GroupUnrecPtr b1 = OSG::Group::create(); b1n->setCore( b1 ); // transformation OSG::NodeUnrecPtr t1n = OSG::Node::create(); OSG::TransformUnrecPtr t1 = OSG::Transform::create(); t1n->setCore( t1 ); t1n->addChild( b1n ); cam_trans = t1; // light OSG::NodeUnrecPtr dlight = OSG::Node::create(); OSG::DirectionalLightUnrecPtr dl = OSG::DirectionalLight::create(); dlight->setCore( dl ); dl->setAmbient( .0, .0, .0, 1 ); dl->setDiffuse( .8, .8, .8, .8 ); dl->setDirection(0,0,1); dl->setBeacon( b1n); // root root = OSG::Node::create(); OSG::GroupUnrecPtr gr1 = OSG::Group::create(); root->setCore( gr1 ); root->addChild( t1n ); root->addChild( dlight ); // Load the file OSG::NodeUnrecPtr file = NULL; if ( argc > 1 ) file = OSG::SceneFileHandler::the()->read(argv[1]); if ( file == NULL ) { std::cerr << "Couldn't load file, ignoring" << std::endl; file = OSG::makeTorus( .5, 2, 16, 16 ); } OSG::Thread::getCurrentChangeList()->commitChanges(); file->updateVolume(); OSG::Vec3f min,max; file->getVolume().getBounds( min, max ); std::cout << "Volume: from " << min << " to " << max << std::endl; dlight->addChild( file ); std::cerr << "Tree: " << std::endl; //root->dump(); // Camera cam = OSG::PerspectiveCamera::create(); cam->setBeacon( b1n ); cam->setFov( OSG::osgDegree2Rad( 90 ) ); cam->setNear( 0.1 ); cam->setFar( 100000 ); // Background OSG::SolidBackgroundUnrecPtr bkgnd = OSG::SolidBackground::create(); bkgnd->setColor(OSG::Color3f(0,0,1)); // Viewport vp = OSG::Viewport::create(); vp->setCamera( cam ); vp->setBackground( bkgnd ); vp->setRoot( root ); vp->setSize( 0,0, 1,1 ); // Action ract = OSG::RenderAction::create(); // tball OSG::Vec3f pos; pos.setValues(min[0] + ((max[0] - min[0]) * 0.5), min[1] + ((max[1] - min[1]) * 0.5), max[2] + ( max[2] - min[2] ) * 1.5 ); float scale = (max[2] - min[2] + max[1] - min[1] + max[0] - min[0]) / 6; OSG::Pnt3f tCenter(min[0] + (max[0] - min[0]) / 2, min[1] + (max[1] - min[1]) / 2, min[2] + (max[2] - min[2]) / 2); tball.setMode( OSG::Trackball::OSGObject ); tball.setStartPosition( pos, true ); tball.setSum( true ); tball.setTranslationMode( OSG::Trackball::OSGFree ); tball.setTranslationScale(scale); tball.setRotationCenter(tCenter); // Carbon init // Create window WindowAttributes windowAttrs = kWindowStandardDocumentAttributes | kWindowLiveResizeAttribute | kWindowStandardHandlerAttribute; Rect contentRect; SetRect(&contentRect, 0, 0, 300, 300); WindowRef window; CreateNewWindow(kDocumentWindowClass, windowAttrs, &contentRect, &window); SetWindowTitleWithCFString(window, CFSTR("testWindowCarbon")); // Install event handler EventHandlerUPP eventHandlerUPP = NewEventHandlerUPP(eventHandler); EventTypeSpec eventList[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent }, { kEventClassMouse, kEventMouseDown }, { kEventClassMouse, kEventMouseUp }, { kEventClassMouse, kEventMouseDragged }, { kEventClassWindow, kEventWindowClose }, { kEventClassWindow, kEventWindowDrawContent }, { kEventClassWindow, kEventWindowBoundsChanged } }; InstallWindowEventHandler(window, eventHandlerUPP, GetEventTypeCount(eventList), eventList, /*this*/0, 0); // Initialize OpenGL GLint attribs[] = { AGL_RGBA, AGL_DOUBLEBUFFER, AGL_DEPTH_SIZE, 16, AGL_NONE }; AGLPixelFormat pixelFormat = aglChoosePixelFormat(0, 0, attribs); if (pixelFormat == 0) std::cerr << "Cannot choose pixel format" << std::endl; AGLContext context = aglCreateContext(pixelFormat, 0); aglDestroyPixelFormat(pixelFormat); if (context == 0) std::cerr << "Cannot create context" << std::endl; aglSetDrawable(context, GetWindowPort(window)); // Create OpenSG window win = OSG::CarbonWindow::create(); win->addPort( vp ); win->setContext ( context ); win->init(); win->resize( 300, 300 ); // Show window RepositionWindow(window, 0, kWindowCascadeOnMainScreen); ShowWindow(window); win->activate(); // do some OpenGL init. Will move into State Chunks later. glEnable( GL_DEPTH_TEST ); glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); // Main loop ( event dispatching ) RunApplicationEventLoop(); // Cleanup aglDestroyContext(context); DisposeWindow(window); DisposeEventHandlerUPP(eventHandlerUPP); ract = NULL; win = NULL; root = NULL; file = NULL; vp = NULL; cam_trans = NULL; cam = NULL; return 0; }
void hint::SetRectangle(int x, int y, int width, int height) { SetRect(&rectangle, x, y, x+width, y+height); }
/* * winAdjustXWindow * * Move and resize X window with respect to corresponding Windows window. * This is called from WM_MOVE/WM_SIZE handlers when the user performs * any windowing operation (move, resize, minimize, maximize, restore). * * The functionality is the inverse of winPositionWindowMultiWindow, which * adjusts Windows window with respect to X window. */ int winAdjustXWindow (WindowPtr pWin, HWND hwnd) { RECT rcDraw; /* Rect made from pWin->drawable to be adjusted */ RECT rcWin; /* The source: WindowRect from hwnd */ DrawablePtr pDraw; XID vlist[4]; LONG dX, dY, dW, dH, x, y; DWORD dwStyle, dwExStyle; #define WIDTH(rc) (rc.right - rc.left) #define HEIGHT(rc) (rc.bottom - rc.top) #if CYGWINDOWING_DEBUG ErrorF ("winAdjustXWindow\n"); #endif if (IsIconic (hwnd)) { #if CYGWINDOWING_DEBUG ErrorF ("\timmediately return because the window is iconized\n"); #endif /* * If the Windows window is minimized, its WindowRect has * meaningless values so we don't adjust X window to it. * Instead we put the X window to the bottom in Z order to * be obscured by other windows. */ vlist[0] = Below; return ConfigureWindow (pWin, CWStackMode, vlist, wClient(pWin)); } pDraw = &pWin->drawable; /* Calculate the window rect from the drawable */ x = pDraw->x + GetSystemMetrics (SM_XVIRTUALSCREEN); y = pDraw->y + GetSystemMetrics (SM_YVIRTUALSCREEN); SetRect (&rcDraw, x, y, x + pDraw->width, y + pDraw->height); #ifdef CYGMULTIWINDOW_DEBUG winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n", rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom, rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top); #endif dwExStyle = GetWindowLongPtr (hwnd, GWL_EXSTYLE); dwStyle = GetWindowLongPtr (hwnd, GWL_STYLE); #ifdef CYGMULTIWINDOW_DEBUG winDebug("\tWindowStyle: %08x %08x\n", dwStyle, dwExStyle); #endif AdjustWindowRectEx (&rcDraw, dwStyle, FALSE, dwExStyle); /* The source of adjust */ GetWindowRect (hwnd, &rcWin); #ifdef CYGMULTIWINDOW_DEBUG winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n", rcWin.left, rcWin.top, rcWin.right, rcWin.bottom, rcWin.right - rcWin.left, rcWin.bottom - rcWin.top); winDebug("\tDraw extend {%d, %d, %d, %d}, {%d, %d}\n", rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom, rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top); #endif if (EqualRect (&rcDraw, &rcWin)) { /* Bail if no adjust is needed */ #if CYGWINDOWING_DEBUG ErrorF ("\treturn because already adjusted\n"); #endif return 0; } /* Calculate delta values */ dX = rcWin.left - rcDraw.left; dY = rcWin.top - rcDraw.top; dW = WIDTH(rcWin) - WIDTH(rcDraw); dH = HEIGHT(rcWin) - HEIGHT(rcDraw); /* * Adjust. * We may only need to move (vlist[0] and [1]), or only resize * ([2] and [3]) but currently we set all the parameters and leave * the decision to ConfigureWindow. The reason is code simplicity. */ vlist[0] = pDraw->x + dX - wBorderWidth(pWin); vlist[1] = pDraw->y + dY - wBorderWidth(pWin); vlist[2] = pDraw->width + dW; vlist[3] = pDraw->height + dH; #if CYGWINDOWING_DEBUG ErrorF ("\tConfigureWindow to (%ld, %ld) - %ldx%ld\n", vlist[0], vlist[1], vlist[2], vlist[3]); #endif return ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight, vlist, wClient(pWin)); #undef WIDTH #undef HEIGHT }
HRESULT CAVIGenerator::InitAVICompressionEngine(){ AVISTREAMINFO strHdr; //Information for a single stream AVICOMPRESSOPTIONS opts; HRESULT hr; //Let's make sure we are running on 1.1 DWORD wVer = HIWORD(VideoForWindowsVersion_ptr()); if(wVer < 0x010a){ //oops, we are too old, blow out of here errorMsg="Version of Video for Windows too old. Come on, join the 21th century!"; return S_FALSE; } //Initialize AVI engine AVIFileInit_ptr(); memset(&cv,0,sizeof(COMPVARS)); cv.cbSize=sizeof(COMPVARS); cv.dwFlags=ICMF_COMPVARS_VALID; cv.fccHandler=mmioFOURCC('x','v','i','d');//default video codec cv.lQ=ICQUALITY_DEFAULT; //Set the compression, prompting dialog if necessary if (!ICCompressorChoose_ptr(NULL, ICMF_CHOOSE_DATARATE | ICMF_CHOOSE_KEYFRAME, &bitmapInfo, NULL, &cv, NULL)){ return S_FALSE; } // Fill in the header for the video stream.... memset(&strHdr, 0, sizeof(AVISTREAMINFO)); strHdr.fccType = streamtypeVIDEO; // video stream type strHdr.fccHandler = cv.fccHandler; strHdr.dwScale = 1; // should be one for video strHdr.dwRate = videoFPS; // fps strHdr.dwSuggestedBufferSize = bitmapInfo.biSizeImage; // Recommended buffer size, in bytes, for the stream. SetRect(&strHdr.rcFrame, 0, 0, bitmapInfo.biWidth, bitmapInfo.biHeight); strcpy(strHdr.szName, "Spring video."); memset(&opts, 0, sizeof(AVICOMPRESSOPTIONS)); opts.fccType=streamtypeVIDEO; opts.fccHandler=cv.fccHandler; opts.dwKeyFrameEvery=cv.lKey; opts.dwQuality=cv.lQ; opts.dwBytesPerSecond=cv.lDataRate; opts.dwFlags=(cv.lDataRate>0?AVICOMPRESSF_DATARATE:0)|(cv.lKey>0?AVICOMPRESSF_KEYFRAMES:0); opts.lpFormat=NULL; opts.cbFormat=0; opts.lpParms=cv.lpState; opts.cbParms=cv.cbState; opts.dwInterleaveEvery=0; //Open the movie file for writing hr = AVIFileOpenA_ptr(&m_pAVIFile, // Address to contain the new file interface pointer fileName.c_str(), // Null-terminated string containing the name of the file to open OF_WRITE | OF_CREATE | OF_SHARE_EXCLUSIVE, // Access mode to use when opening the file. NULL); // use handler determined from file extension. if (hr != AVIERR_OK) { errorMsg="AVI Engine failed to initialize. Check filename "; errorMsg+=fileName; //Translate error code switch(hr) { case AVIERR_BADFORMAT: errorMsg+="The file couldn't be read, indicating a corrupt file or an unrecognized format."; break; case AVIERR_MEMORY: errorMsg+="The file could not be opened because of insufficient memory."; break; case AVIERR_FILEREAD: errorMsg+="A disk error occurred while reading the file."; break; case AVIERR_FILEOPEN: errorMsg+="A disk error occurred while opening the file."; break; case REGDB_E_CLASSNOTREG: errorMsg+="According to the registry, the type of file specified in AVIFileOpen does not have a handler to process it"; break; default : errorMsg+="Unknown error."; } return hr; } //Create the stream hr = AVIFileCreateStreamA_ptr(m_pAVIFile, // file pointer &m_pStream, // returned stream pointer &strHdr); // stream header if (hr != AVIERR_OK) { errorMsg="AVI Stream creation failed. Check Bitmap info."; if (hr==AVIERR_READONLY) { errorMsg+=" Read only file."; } return hr; } //Create a compressed stream using codec options. hr = AVIMakeCompressedStream_ptr(&m_pStreamCompressed, m_pStream, &opts, NULL); if (hr != AVIERR_OK) { errorMsg="AVI Compressed Stream creation failed."; switch(hr) { case AVIERR_NOCOMPRESSOR: errorMsg+=" A suitable compressor cannot be found."; break; case AVIERR_MEMORY: errorMsg+=" There is not enough memory to complete the operation."; break; case AVIERR_UNSUPPORTED: errorMsg+="Compression is not supported for this type of data. This error might be returned if you try to compress data that is not audio or video."; break; default : errorMsg+="Unknown error."; } return hr; } //Sets the format of a stream at the specified position hr = AVIStreamSetFormat_ptr(m_pStreamCompressed, 0, // position &bitmapInfo, // stream format bitmapInfo.biSize + // format size bitmapInfo.biClrUsed * sizeof(RGBQUAD)); if (hr != AVIERR_OK) { errorMsg="AVI Compressed Stream format setting failed."; return hr; } return hr; }
void OnPaint(HWND hWnd) { HDC dialogDC; PAINTSTRUCT paint; RECT cRC, textRC; int i, xPos, yPos, CharCount; HFONT dcFont; HICON hIcon; HPEN hPen; COLORREF Color; // check if (nCols == 0 || nItems == 0) return; // begin painting dialogDC = BeginPaint(hWnd, &paint); if (dialogDC == NULL) return; // fill the client area GetClientRect(hWnd, &cRC); FillRect(dialogDC, &cRC, (HBRUSH)(COLOR_3DFACE + 1)); // if the selection index exceeded the display items, then // do display item shifting if (selectedWindow >= nItems) nShift = selectedWindow - nItems + 1; else nShift = 0; for (i = 0; i < nItems; ++i) { // get the icon to display hIcon = iconList[i + nShift]; // calculate the position where we start drawing xPos = DIALOG_MARGIN + CX_ITEM_SPACE * (i % nCols) + ITEM_MARGIN; yPos = DIALOG_MARGIN + CY_ITEM_SPACE * (i / nCols) + ITEM_MARGIN; // centering if (nItems < CoolSwitchColumns) { xPos += (itemsW - nItems * CX_ITEM_SPACE) / 2; } // if this position is selected, if (selectedWindow == i + nShift) { // create a solid pen Color = GetSysColor(COLOR_HIGHLIGHT); hPen = CreatePen(PS_SOLID, 1, Color); // draw a rectangle with using the pen SelectObject(dialogDC, hPen); SelectObject(dialogDC, GetStockObject(NULL_BRUSH)); Rectangle(dialogDC, xPos, yPos, xPos + CX_ITEM, yPos + CY_ITEM); Rectangle(dialogDC, xPos + 1, yPos + 1, xPos + CX_ITEM - 1, yPos + CY_ITEM - 1); // delete the pen DeleteObject(hPen); } // draw icon DrawIconEx(dialogDC, xPos + ICON_MARGIN, yPos + ICON_MARGIN, hIcon, CX_ICON, CY_ICON, 0, NULL, DI_NORMAL); } // set the text rectangle SetRect(&textRC, DIALOG_MARGIN, DIALOG_MARGIN + itemsH, totalW - DIALOG_MARGIN, totalH - DIALOG_MARGIN); // draw the sunken button around text DrawFrameControl(dialogDC, &textRC, DFC_BUTTON, DFCS_BUTTONPUSH | DFCS_PUSHED); // get text CharCount = GetWindowTextW(windowList[selectedWindow], windowText, _countof(windowText)); // draw text dcFont = SelectObject(dialogDC, dialogFont); SetTextColor(dialogDC, GetSysColor(COLOR_BTNTEXT)); SetBkMode(dialogDC, TRANSPARENT); DrawTextW(dialogDC, windowText, CharCount, &textRC, DT_CENTER | DT_VCENTER | DT_END_ELLIPSIS | DT_SINGLELINE); SelectObject(dialogDC, dcFont); // end painting EndPaint(hWnd, &paint); }
/* second-phase constrcutor */ bool WinBitmap::construct(const byte* dataBuf, uint32 nbrBytes) { /* get the current DC format */ m_dc = CreateCompatibleDC(NULL); if(m_dc == NULL) { return(false); } /** TGA Implementation **/ #if 1 register int32 row, col; register int32 index; int32 red, green, blue, alpha; int32 bitDepth; HDC maskDC = NULL; HBITMAP oldMaskBmp = NULL; /* get the BMP file information */ TGAHEADER tgaHeader; ::memcpy(&tgaHeader, dataBuf, sizeof(TGAHEADER)); /* get the location of the color data */ int offset = sizeof(TGAHEADER) + tgaHeader.numCharsID; const byte* colorData = reinterpret_cast<const byte*>(&dataBuf[offset]); bool useColorMap = false; if ( tgaHeader.colorMapType == 1 ) { // Use color map. useColorMap = true; // Read the color map data. int offsetToColorData = readColorMapData( tgaHeader, colorData ); // Add the offset to colorData so that the colorData actually // points to the color data instead of to the color map. colorData += offsetToColorData; } // colorData should now point at the color data! /* set the dimensions */ m_width = tgaHeader.imageWidth; m_height = tgaHeader.imageHeight; /* get the bit-depth of the image */ bitDepth = tgaHeader.bitsPerPixel; /* create the bitmap using the given info */ m_bmp = CreateBitmap(m_width, m_height, 1, GetDeviceCaps(m_dc, BITSPIXEL), NULL); if(m_bmp == NULL) { /* cannot create bitmap */ return(false); } /* select the bitmap into the DC */ m_oldBmp = (HBITMAP)SelectObject(m_dc, m_bmp); /* create the same sized monocrome mask if required */ if(bitDepth == 32) { m_mask = CreateBitmap(m_width, m_height, 1, 1, NULL); /* check for errors */ if(m_mask == NULL) { return(false); } /* create DC, and select the mask into it */ maskDC = CreateCompatibleDC(NULL); /* check for errors */ if(maskDC == NULL) { return(false); } /* select our monochrome mask into it */ oldMaskBmp = (HBITMAP)SelectObject(maskDC, m_mask); } /* Bottom-up TGAs are expected .. read and create */ index = 0; for(row = m_height-1; row >= 0; --row) { for(col = 0; col < m_width; ++col) { /* 32-bit TGAs need different processing from 24-bit */ if(bitDepth == 32) { if ( useColorMap ) { int colorMapIdx = colorData[ index++ ]; PIXEL p = m_colorMap[ colorMapIdx ]; blue = p.blue; green = p.green; red = p.red; alpha = 255; } else { // No color map. /* read the color value in components */ blue = colorData[index++]; green = colorData[index++]; red = colorData[index++]; alpha = colorData[index++]; } /* write the color pixel */ SetPixelV(m_dc, col, row, RGB(red,green,blue)); /* check the alpha component */ if(alpha > 127) { /* solid pixel */ SetPixelV(maskDC, col, row, RGB(255,255,255)); } else { /* transparent pixel */ SetPixelV(maskDC, col, row, RGB(0,0,0)); } } /* expecting 24-bit RGB Image */ else { if ( useColorMap ) { int colorMapIdx = colorData[ index++ ]; PIXEL p = m_colorMap[ colorMapIdx ]; blue = p.blue; green = p.green; red = p.red; } else { // No color map. /* read the color value in components */ blue = colorData[index++]; green = colorData[index++]; red = colorData[index++]; } /* write the color pixel */ SetPixelV(m_dc, col, row, RGB(red,green,blue)); } } } /* release the mask DC if used */ if(bitDepth == 32) { SelectObject(maskDC, oldMaskBmp); DeleteDC(maskDC); } if(bitDepth == 32) { /* set our masked flag */ m_isMasked = true; } else { m_isMasked = false; } /* success */ return(true); #endif /** BMP Implementation **/ #if 0 register int32 row, col; register int32 index; int32 red, green, blue, alpha; HDC maskDC = NULL; HBITMAP oldMaskBmp = NULL; /* get the BMP file information */ BITMAPFILEHEADER bmHeader; BITMAPINFOHEADER bmInfo; ::memcpy(&bmHeader, dataBuf, sizeof(BITMAPFILEHEADER)); ::memcpy(&bmInfo, &dataBuf[sizeof(BITMAPFILEHEADER)], sizeof(BITMAPINFOHEADER)); /* get the location of the color data */ const byte* colorData = reinterpret_cast<const byte*>(&dataBuf[bmHeader.bfOffBits]); /* set the dimensions */ m_width = bmInfo.biWidth; m_height = bmInfo.biHeight; /* create the bitmap using the given info */ m_bmp = CreateBitmap(m_width, m_height, 1, GetDeviceCaps(m_dc, BITSPIXEL), NULL); if(m_bmp == NULL) { /* cannot create bitmap */ return(false); } /* select the bitmap into the DC */ m_oldBmp = (HBITMAP)SelectObject(m_dc, m_bmp); /* create the same sized monocrome mask if required */ if(bmInfo.biBitCount == 32) { m_mask = CreateBitmap(m_width, m_height, 1, 1, NULL); /* check for errors */ if(m_mask == NULL) { return(false); } /* create DC, and select the mask into it */ maskDC = CreateCompatibleDC(NULL); /* check for errors */ if(maskDC == NULL) { return(false); } /* select our monochrome mask into it */ oldMaskBmp = (HBITMAP)SelectObject(maskDC, m_mask); } /* Bottom-up BMP's are expected .. read and create */ index = 0; for(row = m_height-1; row >= 0; --row) { for(col = 0; col < m_width; ++col) { /* 32-bit BMP's need different processing from 24-bit */ if(bmInfo.biBitCount == 32) { /* read the color value in components */ alpha = colorData[index++]; blue = colorData[index++]; green = colorData[index++]; red = colorData[index++]; /* write the color pixel */ SetPixelV(m_dc, col, row, RGB(red,green,blue)); /* check the alpha component */ if(alpha > 127) { /* solid pixel */ SetPixelV(maskDC, col, row, RGB(255,255,255)); } else { /* transparent pixel */ SetPixelV(maskDC, col, row, RGB(0,0,0)); } } /* expecting 24-bit RGB Image */ else { /* read the color value in components */ blue = colorData[index++]; green = colorData[index++]; red = colorData[index++]; /* write the color pixel */ SetPixelV(m_dc, col, row, RGB(red,green,blue)); } } } /* release the mask DC if used */ if(bmInfo.biBitCount == 32) { SelectObject(maskDC, oldMaskBmp); DeleteDC(maskDC); } if(bmInfo.biBitCount == 32) { /* set our masked flag */ m_isMasked = true; } else { m_isMasked = false; } /* success */ return(true); #endif /* TESTING Implemntation */ #if 0 /* try to create the bitmap -- TESTING */ m_bmp = CreateBitmap(7, 7, 1, GetDeviceCaps(m_dc, BITSPIXEL), NULL); if(m_bmp == NULL) { /* delete the DC */ DeleteDC(m_dc); return(false); } /* select the bitmap into the DC */ m_oldBmp = (HBITMAP)SelectObject(m_dc, m_bmp); /* set the dimensions */ m_width = 7; m_height = 7; /* TEST - clear the bitmap */ HBRUSH clrBrush = CreateSolidBrush( RGB(200,20,20) ); RECT bmpRect; SetRect(&bmpRect, 0, 0, m_width, m_height); FillRect(m_dc, &bmpRect, clrBrush); DeleteObject(clrBrush); /* success */ return(true); #endif }
// ----------------------------------------------------------------------------- // CAafAppFileBrowserView::ConstructL() // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void CAafAppFileBrowserView::ConstructL( const TRect& aRect ) { __LOGSTR_TOFILE("CAafAppFileBrowserView::ConstructL() begins"); // Create a window for this application view CreateWindowL(); // Instantiate listbox control iListBox = new (ELeave)CAknSingleGraphicStyleListBox; iListBox->ConstructL( this, EAknListBoxSelectionList); iListBox->SetContainerWindowL( *this ); __LOGSTR_TOFILE("CAafAppFileBrowserView::ConstructL() before setting icon array"); // Creates a GUI icon array CAknIconArray* icons = new (ELeave)CAknIconArray(5); __LOGSTR_TOFILE("CAafAppFileBrowserView::ConstructL() before CleanupStack::PushL(icons)"); CleanupStack::PushL(icons); icons->ConstructFromResourceL(R_BROWSERVIEW_ICONS); // Sets graphics as listbox icons iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons); __LOGSTR_TOFILE("CAafAppFileBrowserView::ConstructL() before CleanupStack::Pop()"); CleanupStack::Pop(); // icons // Enable marquee effect iListBox->ItemDrawer()->ColumnData()->SetMarqueeParams(3, 20, 1000000, 200000); iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); __LOGSTR_TOFILE("CAafAppFileBrowserView::ConstructL() after setting icon array"); // Create the scroll indicator iListBox->CreateScrollBarFrameL(ETrue); iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); iListBox->ActivateL(); // Create the FileBrowserEngine iBrowserEngine = new (ELeave) CFileBrowserEngine; #ifdef __SERIES60_3X__ iBrowserEngine->ConstructL(); #else iBrowserEngine->ConstructL((CEikProcess*)(((CEikAppUi*)iCoeEnv->AppUi())->Application()->Process())); #endif // Set file browser to display only picture files //SetFileListL(EFileBrowserPictures, EFileBrowserDate); TFileName aFolder = TFileName(KNullDesC); SetFileListL(aFolder); // Set the windows size SetRect( aRect ); // Activate the window, which makes it ready to be drawn ActivateL(); __LOGSTR_TOFILE("CAafAppFileBrowserView::ConstructL() begins"); }
void cMainGame::Render() { g_pD3DDevice->Clear(NULL, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(47, 121, 112), //D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0); g_pD3DDevice->BeginScene(); // 그림을 그린다. m_pGrid->Render(); // // for each(D3DXVECTOR3 v in m_vecSpherePosition) // { // if(!m_pFrustum->IsIn(v, 1.0f)) // continue; // // D3DXMATRIXA16 matWorld; // D3DXMatrixTranslation(&matWorld, v.x, v.y, v.z); // g_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld); // g_pD3DDevice->SetMaterial(&m_stWhiteMtl); // m_pSphere->DrawSubset(0); // } // for each(auto p in m_vecDijkstraNode) // { // p->Render(m_pSphere); // } D3DXMATRIXA16 matWorld; D3DXMatrixIdentity(&matWorld); g_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld); m_pSkinnedMesh->Render(); if(m_pFont) { RECT rc; SetRect(&rc, 100, 100, 101, 101); char szTemp[1024] = "ABC 123 ?!"; sprintf(szTemp, "%d", g_pTimeManager->GetFPS()); m_pFont->DrawTextA(NULL, szTemp, strlen(szTemp), &rc, DT_LEFT | DT_TOP | DT_NOCLIP, D3DCOLOR_XRGB(255, 255, 0)); } if(!m_vecEdge.empty()) { g_pD3DDevice->SetRenderState(D3DRS_LIGHTING, false); D3DXMATRIXA16 matWorld; D3DXMatrixIdentity(&matWorld); g_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld); g_pD3DDevice->SetFVF(ST_PC_VERTEX::FVF); g_pD3DDevice->SetTexture(0, NULL); g_pD3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, m_vecEdge.size() / 2, &m_vecEdge[0], sizeof(ST_PC_VERTEX)); } g_pD3DDevice->EndScene(); g_pD3DDevice->Present(NULL, NULL, NULL, NULL); }
void CGLPlanetsAppView::ConstructL(const TRect& aRect) { CreateWindowL(); SetRect(aRect); }
// エントリポイント int WINAPI _tWinMain( HINSTANCE hInst, HINSTANCE, LPTSTR, int ) { LARGE_INTEGER nNowTime, nLastTime; // 現在とひとつ前の時刻 LARGE_INTEGER nTimeFreq; // 時間単位 // 画面サイズ g_nClientWidth = VIEW_WIDTH; // 幅 g_nClientHeight = VIEW_HEIGHT; // 高さ // Register the window class WNDCLASSEX wc = { sizeof( WNDCLASSEX ), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle( NULL ), NULL, NULL, NULL, NULL, _T( "D3D Sample" ), NULL }; RegisterClassEx( &wc ); RECT rcRect; SetRect( &rcRect, 0, 0, g_nClientWidth, g_nClientHeight ); AdjustWindowRect( &rcRect, WS_OVERLAPPEDWINDOW, FALSE ); g_hWnd = CreateWindow( _T( "D3D Sample" ), _T( "Wipe_3_1" ), WS_OVERLAPPEDWINDOW, 100, 20, rcRect.right - rcRect.left, rcRect.bottom - rcRect.top, GetDesktopWindow(), NULL, wc.hInstance, NULL ); // Initialize Direct3D if( SUCCEEDED( InitD3D() ) && SUCCEEDED( MakeShaders() ) ) { // Create the shaders if( SUCCEEDED( InitDrawModes() ) ) { if ( SUCCEEDED( InitGeometry() ) ) { // ジオメトリ作成 // Show the window ShowWindow( g_hWnd, SW_SHOWDEFAULT ); UpdateWindow( g_hWnd ); InitChangingPictures(); // キャラクタ初期化 QueryPerformanceFrequency( &nTimeFreq ); // 時間単位 QueryPerformanceCounter( &nLastTime ); // 1フレーム前時刻初期化 // Enter the message loop MSG msg; ZeroMemory( &msg, sizeof( msg ) ); while( msg.message != WM_QUIT ) { Render(); // DrawChangingPictures(); do { if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } QueryPerformanceCounter( &nNowTime ); } while( ( ( nNowTime.QuadPart - nLastTime.QuadPart ) < ( nTimeFreq.QuadPart / 90 ) ) && ( msg.message != WM_QUIT ) ); while( ( ( nNowTime.QuadPart - nLastTime.QuadPart ) < ( nTimeFreq.QuadPart / 60 ) ) && ( msg.message != WM_QUIT ) ) { QueryPerformanceCounter( &nNowTime ); } nLastTime = nNowTime; g_pSwapChain->Present( 0, 0 ); // 表示 } } } } // Clean up everything and exit the app Cleanup(); UnregisterClass( _T( "D3D Sample" ), wc.hInstance ); return 0; }
void wf_info_invalidate_full_screen(wfInfo* wfi) { SetRect(&wfi->invalid, 0, 0, wfi->servscreen_width, wfi->servscreen_height); }
//----------------------------- void GameInit() { app_run = 1 ; log_file = fopen("LOG\\debug.log","w+") ; if(log_file)fprintf(log_file,"GameInit\n") ; DDraw = new c_DDraw(main_handle,main_hinstance,&DDRestore,screen_WIDTH,screen_HEIGHT,screen_BITDEPTH) ; DDraw->Init(log_file); SetRect(&screen,0,0,screen_WIDTH-1,screen_HEIGHT-1) ; TIME =0 ; ThisTickCount=GetTickCount(); LastTickCount=ThisTickCount; SpriteList = new c_SpriteList() ; SpriteList->Add(DDraw->DDraw,"art\\particicle.bmp",sprite_PARTICICLE_X_COUNT,sprite_PARTICICLE_Y_COUNT,log_file) ; SpriteList->Add(DDraw->DDraw,"art\\buildings.bmp",sprite_BUILDINGS_X_COUNT,sprite_BUILDINGS_Y_COUNT,log_file) ; SpriteList->Add(DDraw->DDraw,"art\\fontBig.bmp",font_STD_X_COUNT,font_STD_Y_COUNT,log_file) ; SpriteList->Add(DDraw->DDraw,"art\\buttons.bmp",sprite_BUTTONS_X_COUNT,sprite_BUTTONS_Y_COUNT,log_file) ; SpriteList->Add(DDraw->DDraw,"art\\panels.bmp",sprite_PANELS_X_COUNT,sprite_PANELS_Y_COUNT,log_file) ; SpriteList->Add(DDraw->DDraw,"art\\fontSmall.bmp",font_STD_X_COUNT,font_STD_Y_COUNT*3,log_file) ; panels = SpriteList->Find(sprite_PANELS_ID) ; player_ID = 0 ; font = new c_Font(SpriteList->Find(sprite_FONTBIG_ID)) ; mouse.x=1; mouse.y=1; mouse.sprite=SpriteList->Find(sprite_BUILDINGS_ID); mouse.x_frame = building_type_SELECT ; mouse.y_frame=building_y_frame_GOODPLACE; world = new c_World(SpriteList->Find(sprite_BUILDINGS_ID)) ; (world->player[player_ID]).current_x_screen=94; (world->player[player_ID]).current_y_screen=94; (world->building[100][100]).type = building_type_MAIN ; (world->building[105][105]).type = building_type_BASE ; (world->building[105][105]).owner = building_type_BASE ; int start_x=105-building_territory_ADD_COUNT, end_x =105+building_territory_ADD_COUNT, start_y=105-building_territory_ADD_COUNT, end_y =105+building_territory_ADD_COUNT; if(start_x<0)start_x=0; if(end_x>=world_X_COUNT)end_x=world_X_COUNT-1; if(start_y<0)start_y=0; if(end_y>=world_Y_COUNT)end_y=world_Y_COUNT-1; FILE *f=fopen("LOG\\territory.log","w+") ; for(int x=start_x;x<=end_x;x++) for(int y=start_y;y<=end_y;y++) { fprintf(f,"coord(%d;%d)\n",x,y) ; if((world->building[x][y]).territory==building_territory_NEUTRAL) { fprintf(f,"set to %d\n",player_ID); (world->building[x][y]).territory=player_ID ; }; } ; fclose(f) ; (world->player[player_ID]).show_territory=1; s_ParticicleInfo PInfo ; PInfo.TurnTime = 1 ; PInfo.GenerateTime = 50 ; PInfo.TurnCount = 1000 ; PInfo.GenerateCountPerTurn = 1 ; PInfo.width = screen_X_CELL_SIZE ; PInfo.height = screen_Y_CELL_SIZE ; PInfo.enable = 1 ; PInfo.dx = 0.5 ; PInfo.dy = 0.0 ; PInfo.dxVariation = 0 ; PInfo.dyVariation = 0 ; PInfo.x_frame_count = 3 ; PInfo.y_frame_count = 3 ; PInfo.ParticicleCount = 100 ; particicle = new c_Particicle(SpriteList->Find(sprite_PARTICICLE_ID),100,100,PInfo) ; HiveElements = new c_HiveElements(world,&mouse,SpriteList->Find(sprite_BUTTONS_ID), build_panel_X,build_panel_Y,common_panel_X,common_panel_Y, SpriteList->Find(sprite_FONTSMALL_ID),player_ID) ; } ;