void DjVuApp::ReadyToRun() { InstallMimeType("image/x-djvu"); if (CountWindows() == WINDOWS_TO_IGNORE) fOpenPanel->Show(); else StartPulse(); }
void DjVuApp::MessageReceived(BMessage *message) { switch(message->what) { case MSG_FILE_OPEN: fOpenPanel->Show(); break; case B_CANCEL: // File open panel was closed, // start checking count of open windows StartPulse(); break; default: BApplication::MessageReceived(message); break; } }
/*! \fn float Sonar::Run() * \brief The main loop/function of the Sonar class. * \return The distance measurement of from the sonar. */ float Sonar::Run() { StartPulse(); _gpio->SetEdge(RISING); usleep(500); if (_gpio->Poll(POLL_TIMEOUT, _risingTOI) > 0) { _gpio->SetEdge(FALLING); if (_gpio->Poll(POLL_TIMEOUT, _fallingTOI) <= 0) { return -1.f; } } else { return -1.f; } return DisplayMeasurement(); }
//------------------------------------------------------------------------------ void CNetscapeStatusBar::DrawProgressBar() { int idx = CommandToIndex( IDS_TRANSFER_STATUS ); if (idx < 0) return; RECT rcBarArea; GetItemRect( idx, &rcBarArea ); CClientDC dc( this ); if( m_nDone == 0 ) { StopPulse(); ::InflateRect( &rcBarArea, -1, -1 ); dc.FillRect( &rcBarArea, CBrush::FromHandle( sysInfo.m_hbrBtnFace ) ); return; } if( m_nDone == -1 ) { if( !m_uTimerId ) { StartPulse(); } return; } // Decide the correct size of the thermo. InflateRect( &rcBarArea, -5, -2 ); CDC dcMem; dcMem.CreateCompatibleDC( &dc ); // Create a bitmap big enough for progress bar area CBitmap bmMem; bmMem.CreateCompatibleBitmap( &dc, rcBarArea.right-rcBarArea.left, rcBarArea.bottom-rcBarArea.top ); CBitmap *pbmOld = dcMem.SelectObject( &bmMem ); // Select the font CFont *pOldFont = NULL; if( GetFont() ) { pOldFont = dcMem.SelectObject( GetFont() ); } char szPercent[8]; wsprintf( szPercent, "%u%%", m_nDone ); dcMem.SetBkMode( TRANSPARENT ); RECT rcBm = { 0, 0, rcBarArea.right-rcBarArea.left, rcBarArea.bottom-rcBarArea.top }; int iNumColors = dc.GetDeviceCaps( NUMCOLORS ); if( iNumColors == -1 || iNumColors > 256 ) { // Render the image into the mem DC dcMem.FillRect( &rcBm, CBrush::FromHandle( sysInfo.m_hbrBtnFace ) ); dcMem.SetTextColor( GetSysColor( COLOR_BTNTEXT ) ); dcMem.DrawText( szPercent, -1, &rcBm, DT_CENTER | DT_VCENTER | DT_SINGLELINE ); RECT rcBar = { 0, 0, CASTINT(rcBm.right * m_nDone / 100), CASTINT(rcBm.bottom) }; dcMem.InvertRect( &rcBar ); } else { // There's reasonable probability that the inverse color of btnface and btnshadow could be the same // when we are dealing with a palette of 256 colors or less. So instead of using the invertrect // algorithm above, we'll just ensure the text is legible by painting a white background for it. // Render the image into the mem DC dcMem.FillRect( &rcBm, CBrush::FromHandle( (HBRUSH)GetStockObject( WHITE_BRUSH ) ) ); dcMem.SetTextColor( RGB(0,0,0) ); dcMem.DrawText( szPercent, -1, &rcBm, DT_CENTER | DT_VCENTER | DT_SINGLELINE ); RECT rcBar = { 0, 0, CASTINT(rcBm.right * m_nDone / 100), CASTINT(rcBm.bottom) }; dcMem.InvertRect( &rcBar ); } dc.BitBlt( rcBarArea.left, rcBarArea.top, rcBarArea.right-rcBarArea.left, rcBarArea.bottom-rcBarArea.top, &dcMem, 0, 0, SRCCOPY ); // Tidy up if( pOldFont ) { dcMem.SelectObject( pOldFont ); } dcMem.SelectObject( pbmOld ); }