bool Button::pressed(int mx, int my) { if(callback != NULL) { if(mSoundSource != "none") gSound->playEffect(mSoundSource.c_str()); //if(!callback(getID(), getValue())) if(!callback(getID(), WindowMessage(true))) return false; } return true; }
int main(int argc, char *argv[]) { axPipeClient client(FIFO_FILE); axInterProcess msg; msg.pid = getpid(); msg.type = axINTER_PROCESS_MOUSE_MESSAGE; msg.mouse_message = MouseMessage(32.53, 32.92); client.SendMsg(msg); msg.type = axINTER_PROCESS_WINDOW_MESSAGE; msg.window_message = WindowMessage(31, 39); client.SendMsg(msg); return(0); }
bool DropBox::pressed(int mx, int my) { mx = gDInput->getCursorX(); my = gDInput->getCursorY(); // expanded? if(!mExpanded) { if((mx > mActivationRect.left && mx < (mActivationRect.right + mSignSide) && my > mActivationRect.top && my < mActivationRect.bottom)) { // expand it mExpanded = true; mY += ((mItems * mItemHeight) - mItemHeight); mHeight += (mItems * mItemHeight) ; } } else if(mExpanded) { // if the arrow gets pressed if(mx > mActivationRect.left && mx < (mActivationRect.right + mSignSide) && my > mActivationRect.top && my < mActivationRect.bottom) { mExpanded = false; mY = mActivationRect.top + (mActivationRect.bottom - mActivationRect.top)/2; mHeight -= (mItems * mItemHeight); } for(int i = 0; i<mItemList.size();i++) { if(mx > mItemList[i].getRect().left && mx < mItemList[i].getRect().right && my > mItemList[i].getRect().top && my < mItemList[i].getRect().bottom) { mY = mActivationRect.top + (mActivationRect.bottom - mActivationRect.top)/2; mHeight -= (mItems * mItemHeight) ; mExpanded = false; setValue(mItemList[i].itemName); // do what's needed callback(getID(), WindowMessage(getValue())); } } } return true; }
/*virtual*/ void CMainWnd::OnTimer() { // every 200ms static int nSubCounter = 0; if ( ++nSubCounter == 5 ) { nSubCounter = 0; static ui32 nChecksum = -1; static int nSeconds = 0; nSeconds++; if ( Settings.Runtime.m_nStandby != 0 ) { if ( (int)BIOS::SYS::GetTick() > m_nLastKey + Settings.Runtime.m_nStandby*60000 ) { // enter sleep mode BIOS::SYS::SetVolume(0); m_wndMessage.Show(this, "Information", "Entering sleep mode", RGB565(ffff00)); BIOS::ADC::Enable( FALSE ); for ( int i = Settings.Runtime.m_nBacklight; i > 0; i--) { BIOS::SYS::SetBacklight( i ); BIOS::SYS::DelayMs(10); } BIOS::SYS::Standby( TRUE ); m_bSleeping = TRUE; KillTimer(); } } if ( nChecksum == (ui32)-1 ) { int nUptime = Settings.Runtime.m_nUptime; Settings.Runtime.m_nUptime = 0; nChecksum = Settings.GetChecksum(); Settings.Runtime.m_nUptime = nUptime; } if ( Settings.m_lLastChange != 0 ) { // save settings in 20 seconds nSeconds = 120 - 20; Settings.m_lLastChange = 0; } if ( nSeconds >= 120 ) { nSeconds = 0; ui32 nNewChecksum = Settings.GetStaticChecksum(); if ( nNewChecksum != nChecksum ) { //m_wndMessage.Show(this, "Information", "Saving settings...", RGB565(ffff00)); Settings.Save(); nChecksum = nNewChecksum; } } if ( Settings.Runtime.m_bUartTest ) { char test[32]; static int nCounter=0; BIOS::DBG::sprintf(test, "Ready.(%d)\n", nCounter++); BIOS::SERIAL::Send("TEST!"); BIOS::SERIAL::Send(test); } } if ( BIOS::ADC::Enabled() && Settings.Trig.Sync == CSettings::Trigger::_Auto ) { if ( m_lLastAcquired != -1 && BIOS::SYS::GetTick() - m_lLastAcquired > 150 ) { bool bScreenReady = BIOS::ADC::GetPointer() > (300 + Settings.Time.InvalidFirst); BIOS::ADC::Copy( BIOS::ADC::GetCount() ); // redraw the screen even when the sampler is not full //BIOS::LCD::Print(0, 0, RGB565(ff0000), 0, "U"); WindowMessage( CWnd::WmBroadcast, ToWord('d', 'g') ); //BIOS::LCD::Print(0, 0, RGB565(808080), 0, "u"); // force restart if the write pointer is behind current window // TODO: the FPGA program is unreliable and stupid!, the restart wont reset the WPTR to begin of buffer if ( bScreenReady ) { //BIOS::LCD::Print(0, 0, RGB565(ff0000), 0, "R"); BIOS::ADC::Restart(); } } } }
/*virtual*/ void CMainWnd::WindowMessage(int nMsg, int nParam /*=0*/) { // BIOS::LCD::Printf( 0, 0, RGB565(ff0000), RGB565(ffffff), "%d", BIOS::ADC::GetState() ); if ( nMsg == WmTick ) { if ( m_bSleeping ) return; m_Mouse.Hide(); if ( m_Mouse.Clicked() ) OnMouseClick(); // timers update CWnd::WindowMessage( nMsg, nParam ); bool bEnableSdk = Settings.Runtime.m_bUartSdk ? true : false; #ifdef ENABLE_MONITOR // When the user is in UART monitor screen, do not intercept UART traffic if ( MainWnd.m_wndToolBar.GetCurrentLayout() == &MainWnd.m_wndUserCWndUserMonitor ) bEnableSdk = false; #endif #ifdef ENABLE_MODULE_GPIOTEST if ( MainWnd.m_wndToolBar.GetCurrentLayout() == &MainWnd.m_wndUserCWndGpioTest ) bEnableSdk = false; #endif if ( bEnableSdk ) SdkUartProc(); if ( (Settings.Trig.Sync != CSettings::Trigger::_None) && BIOS::ADC::Enabled() && BIOS::ADC::Ready() ) { // ADC::Ready means that the write pointer is at the end of buffer, we can restart sampler BIOS::ADC::Copy( BIOS::ADC::GetCount() ); BIOS::ADC::Restart(); Resample(); // trig stuff m_lLastAcquired = BIOS::SYS::GetTick(); if ( BIOS::ADC::Enabled() && Settings.Trig.Sync == CSettings::Trigger::_Single ) { BIOS::ADC::Enable( false ); Settings.Trig.State = CSettings::Trigger::_Stop; if ( m_wndMenuInput.m_itmTrig.IsVisible() ) m_wndMenuInput.m_itmTrig.Invalidate(); } // broadcast message for windows that process waveform data WindowMessage( CWnd::WmBroadcast, ToWord('d', 'g') ); } m_Mouse.Show(); return; } if ( nMsg == WmKey ) { if ( m_bSleeping ) { SetTimer( 200 ); m_bSleeping = false; BIOS::SYS::Standby( FALSE ); CCoreOscilloscope::ConfigureAdc(); CCoreGenerator::Update(); m_wndMessage.Hide(); Invalidate(); for ( int i = 0; i < Settings.Runtime.m_nBacklight; i++) { BIOS::SYS::SetBacklight( i ); BIOS::SYS::DelayMs(10); } m_nLastKey = BIOS::SYS::GetTick(); CCoreSettings::Update(); // display backlight return; } m_nLastKey = BIOS::SYS::GetTick(); if ( nParam & ( BIOS::KEY::KeyFunction | BIOS::KEY::KeyFunction2 | BIOS::KEY::KeyS2 | BIOS::KEY::KeyS1 ) ) { m_Mouse.Hide(); if ( nParam == BIOS::KEY::KeyFunction ) CMainWnd::CallShortcut(Settings.Runtime.m_nShortcutCircle); if ( nParam == BIOS::KEY::KeyFunction2 ) CMainWnd::CallShortcut(Settings.Runtime.m_nShortcutTriangle); if ( nParam == BIOS::KEY::KeyS2 ) CMainWnd::CallShortcut(Settings.Runtime.m_nShortcutS2); if ( nParam == BIOS::KEY::KeyS1 ) CMainWnd::CallShortcut(Settings.Runtime.m_nShortcutS1); m_Mouse.Show(); return; } } m_Mouse.Hide(); CWnd::WindowMessage( nMsg, nParam ); m_Mouse.Show(); }
void CWnd::Invalidate() { // TODO: we should only mark this windows and redraw it a while later, but for keeping // things simple, invalidate causes window to redraw WindowMessage(WmPaint); }
void Slidebar::update(double dt) { static char temp[10]; // ugly hack if(gDInput->mouseButtonDown(LEFTBUTTON)) { if(gDInput->cursorInsideRect(mSlider) || mMovingSlider) { if(gDInput->mouseDX() < 0) { // slider has a valid position if(mSliderPos > 0 + mSliderWidth/2) { moveSlider(gDInput->mouseDX()); // set the value, dx in 0-1 range * value span mValue += (mMaxValue - mMinValue)*((gDInput->mouseDX()) / (mSlideBackground.right - mSlideBackground.left - mSliderWidth)); // - mSliderWidth på vänster sidan?:O callback(getID(), WindowMessage(mValue)); // stop invalid movement if(mSliderPos <= 0 + mSliderWidth/2) { stopSlider(LEFT); } sprintf(temp, "%.2f", mValue); // hack >_> string temp2 = string(temp); mInputBox->setValue(temp2); } else { stopSlider(LEFT); } } else if(gDInput->mouseDX() > 0) { if(mSliderPos < (mSlideBackground.right - mSlideBackground.left - mSliderWidth/2)) { moveSlider(gDInput->mouseDX()); // set the value, dx in 0-1 range * value span mValue += (mMaxValue - mMinValue)*((gDInput->mouseDX()) / (mSlideBackground.right - mSlideBackground.left - mSliderWidth)); callback(getID(), WindowMessage(mValue)); // stop invalid movement if(mSliderPos >= (mSlideBackground.right - mSlideBackground.left - mSliderWidth/2)) { stopSlider(RIGHT); } sprintf(temp, "%.2f", mValue); // hack >_> string temp2 = string(temp); mInputBox->setValue(temp2); } else { stopSlider(RIGHT); } } // dont allow Y movement while sliding gDInput->setCursorY(gDInput->getCursorY() - gDInput->mouseDY()); } } if(gDInput->mouseButtonReleased(LEFTBUTTON)) mMovingSlider = false; }