void Meter::RepaintBarsNow() { if (!mLayoutValid) return; wxClientDC dc(this); int i; #ifdef __WXMAC__ // Mac OS X automatically double-buffers the screen for you, // so our bitmap is unneccessary for(i=0; i<mNumBars; i++) DrawMeterBar(dc, &mBar[i]); #else if (!mBitmap) mBitmap = new wxBitmap(mWidth, mHeight); wxMemoryDC memDC; memDC.SelectObject(*mBitmap); for(i=0; i<mNumBars; i++) DrawMeterBar(memDC, &mBar[i]); dc.Blit(mAllBarsRect.x, mAllBarsRect.y, mAllBarsRect.width, mAllBarsRect.height, &memDC, mAllBarsRect.x, mAllBarsRect.y, wxCOPY, false); #endif }
DWORD CreateTestFile( PFILE_PARAMS FileParams ) { PCHAR index = FileParams->TestDrive; PUCHAR buffer; CHAR errBuf[80]; HANDLE file,port; OVERLAPPED overlapped,*overlapped2; DWORD bytesTransferred,bytesTransferred2,key; BOOLEAN status; ULONG i; while (*index == '\\' || *index == '.') { index++; } strcpy(FileParams->TestFile,index); strcat(FileParams->TestFile,"\\test.dat"); DeleteFile(FileParams->TestFile); buffer = VirtualAlloc(NULL, BufferSize, MEM_COMMIT, PAGE_READWRITE); if ( !buffer ) { sprintf(errBuf,"Error allocating buffer %d\n",GetLastError()); MessageBox(NULL,errBuf,"Error",MB_ICONEXCLAMATION|MB_OK); ExitThread(3); return 3; } file = CreateFile(FileParams->TestFile, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, NULL ); if ( file == INVALID_HANDLE_VALUE ) { sprintf(errBuf,"Error opening file %s %d\n",FileParams->TestFile,GetLastError()); MessageBox(NULL,errBuf,"Error",MB_ICONEXCLAMATION|MB_OK); ExitThread(3); return 3; } port = CreateIoCompletionPort(file, NULL, (DWORD)file, 0); if ( !port ) { sprintf(errBuf,"Error creating completion port %d\n",FileParams->TestFile,GetLastError()); MessageBox(NULL,errBuf,"Error",MB_ICONEXCLAMATION|MB_OK); return FALSE; } memset(&overlapped,0,sizeof(overlapped)); for (i = 0; i < NumberIOs; i++) { // // If user aborted file create, exit. // if (KillFileCreate) { DeleteFile(FileParams->TestFile); ExitThread(4); return 4; } retryWrite: status = WriteFile(file, buffer, BufferSize, &bytesTransferred, &overlapped); if ( !status && GetLastError() != ERROR_IO_PENDING ) { if (GetLastError() == ERROR_INVALID_USER_BUFFER || GetLastError() == ERROR_NOT_ENOUGH_QUOTA || GetLastError() == ERROR_NOT_ENOUGH_MEMORY) { goto retryWrite; } sprintf(errBuf,"Error creating test file %d\n",GetLastError()); MessageBox(NULL,errBuf,"Error",MB_ICONEXCLAMATION|MB_OK); ExitThread(3); return 3; } // // Update gauge. // DrawMeterBar(FileParams->Window,GaugeId,i / 2,NumberIOs,FALSE); overlapped.Offset += BufferSize; } for (i = 0; i < NumberIOs; i++ ) { status = GetQueuedCompletionStatus(port, &bytesTransferred2, &key, &overlapped2, (DWORD)-1); if ( !status ) { sprintf(errBuf,"Error picking up completion pre-write %d\n",GetLastError()); MessageBox(NULL,errBuf,"Error",MB_ICONEXCLAMATION|MB_OK); ExitThread(2); return 2; } DrawMeterBar(FileParams->Window,GaugeId, NumberIOs / 2 + i / 2,NumberIOs,FALSE); } CloseHandle(port); CloseHandle(file); ExitThread(1); return 1; }
void Meter::HandlePaint(wxDC &dc) { int i; dc.SetFont(GetFont()); if (mLeftSize.x == 0) { dc.GetTextExtent(mLeftText, &mLeftSize.x, &mLeftSize.y); dc.GetTextExtent(mRightText, &mRightSize.x, &mRightSize.y); } if (!mLayoutValid) HandleLayout(); #ifndef USE_AQUA_THEME #ifdef EXPERIMENTAL_THEMING if( !mMeterDisabled ) { mBkgndBrush.SetColour( GetParent()->GetBackgroundColour() ); } #endif dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(mBkgndBrush); dc.DrawRectangle(0, 0, mWidth, mHeight); #endif dc.DrawBitmap(*mIcon, mIconPos.x, mIconPos.y, true); #if WANT_METER_MENU // Draws a beveled button and a down pointing triangle. // The style and sizing matches the ones in the title // bar of the waveform left-hand-side panels. { wxRect r = mMenuRect; AColor::Bevel(dc, true, r); dc.SetPen(*wxBLACK_PEN); int triWid = 11; int xStart = r.x+3; int yStart = r.y+4; for(i=0;i<=triWid/2;i++){ dc.DrawLine(xStart+i, yStart+i, xStart + triWid - i,yStart+i); } } if (mNumBars>0) mRuler.Draw(dc); #else // Label as "Mix Volume" and "Input Volume" for Camp Jam. int nFontSize = this->GetFont().GetPointSize(); int nXPos = mIconPos.x + mIcon->GetWidth() + 8; int nYPos = mIconPos.y + (mIcon->GetHeight() - nFontSize - 6)/2; if (nYPos < 0) nYPos = 0; if (mIsInput) dc.DrawText(_("Input Volume"), nXPos, nYPos); else dc.DrawText(_("Mix Volume"), nXPos, nYPos); #endif // WANT_METER_MENU dc.SetFont(GetFont()); dc.DrawText(mLeftText, mLeftTextPos.x, mLeftTextPos.y); dc.DrawText(mRightText, mRightTextPos.x, mRightTextPos.y); for(i=0; i<mNumBars; i++) DrawMeterBar(dc, &mBar[i]); }