void gridPanel::onClick(wxMouseEvent& event) { do{ if(isMouseOverGrid()){ wxPoint pt = ScreenToClient( wxGetMousePosition() ); //récupère la position de la souris dans le panel long posX,posY; getCellHoveredByMouse(pt.x,pt.y,posX,posY); //renvoi les valeurs x et y pour remplir une case sur posX et posY wxPaintDC monDc(this); wxBrush maBrush(*couleur ,wxSOLID ); // brush rempli la case d'une couleur monDc.SetBrush(maBrush); wxColour maCouleur(100,100,100); wxPen monCrayon(maCouleur,1,wxSOLID); monDc.SetPen(monCrayon); monDc.DrawRectangle(posX,posY,21,21); //créé un carré qui rempli une case de la grille (actuellement en blanc) } }while(wxGetMouseState().LeftDown()); //boucle tant que le bouton gauche de la souris est enfoncé }
void SpinControl::OnSpinButton(bool up) { static const unsigned int SHIFT = 1; static const unsigned int ALT = 2; static const unsigned int META = 4; static const unsigned int CTRLCMD = 8; double increment = 0.0f; wxMouseState mouseState = wxGetMouseState(); unsigned int keys = 0; if (mouseState.ShiftDown()) keys |= SHIFT; if (mouseState.AltDown()) keys |= ALT; if (mouseState.MetaDown()) keys |= META; if (mouseState.ControlDown() || mouseState.CmdDown()) keys |= CTRLCMD; if (keys == 0) increment = m_regularIncrement; else if (keys == SHIFT) increment = m_shiftIncrement; else if (keys == CTRLCMD) increment = m_ctrlIncrement; double newValue = up ? m_value + increment : m_value - increment; newValue = AdjustToRange(newValue); if (DoSetValue(newValue)) DoSendEvent(); m_spin->SetValue(0); }
bool CAsyncRequestQueue::CheckWindowState() { m_timer.Stop(); wxMouseState mouseState = wxGetMouseState(); if (mouseState.LeftIsDown() || mouseState.MiddleIsDown() || mouseState.RightIsDown()) { m_timer.Start(100, true); return false; } #ifndef __WXMAC__ if (m_pMainFrame->IsIconized()) { #ifndef __WXGTK__ m_pMainFrame->Show(); m_pMainFrame->Iconize(true); m_pMainFrame->RequestUserAttention(); #endif return false; } wxWindow* pFocus = m_pMainFrame->FindFocus(); while (pFocus && pFocus != m_pMainFrame) pFocus = pFocus->GetParent(); if (!pFocus) m_pMainFrame->RequestUserAttention(); #endif return true; }
void wxGISMapView::OnSize(wxSizeEvent & event) { m_pTrackCancel->Cancel(); if(m_pThread) m_pThread->Delete(); wxClientDC CDC(this); IDisplayTransformation* pDisplayTransformation = pGISScreenDisplay->GetDisplayTransformation(); pDisplayTransformation->SetPPI(CDC.GetPPI()); wxMouseState state = wxGetMouseState(); if(state.LeftDown()) { wxRect rc = GetClientRect(); pGISScreenDisplay->OnStretchDraw(CDC, rc.width, rc.height); m_MouseState |= enumGISMouseLeftDown; m_timer.Start(300); } else { m_MouseState &= ~enumGISMouseLeftDown;//enumGISMouseNone; //set map init envelope pDisplayTransformation->SetDeviceFrame(GetClientRect()); pGISScreenDisplay->SetDerty(true); } Refresh(false); event.Skip(); }
void watchdog_pi::SetCursorLatLon(double lat, double lon) { wxPoint pos = wxGetMouseState().GetPosition(); if(pos == m_cursor_position) return; m_cursor_position = pos; m_cursor_time = wxDateTime::Now(); }
void MouseHover::OnMotion(wxMouseEvent &event) { // Stop and restart timer. wxTimer::Stop(); wxMouseState mouseState = wxGetMouseState(); if (!mouseState.LeftIsDown() && !mouseState.MiddleIsDown() && !mouseState.RightIsDown()) wxTimer::Start(interval, true); event.Skip(); }
void CheckMousePosition() { mouse = wxGetMouseState(); int x=mouse.GetX(); int y=mouse.GetY(); if ( XYOverFeed(x,y,live_feeds[2]) ) {} else if ( XYOverFeed(x,y,live_feeds[3]) ) {} }
Vector2i WxWindow::getCursorPosition() const { const wxMouseState& mouseState = wxGetMouseState(); int x = mouseState.GetX(); int y = mouseState.GetY(); canvas->ScreenToClient( &x, &y ); return Vector2i(x, y); }
void wxGISMapView::OnTimer( wxTimerEvent& event ) { wxMouseState state = wxGetMouseState(); IDisplayTransformation* pDisplayTransformation = pGISScreenDisplay->GetDisplayTransformation(); if(!state.LeftDown() && (m_MouseState & enumGISMouseLeftDown)) { m_MouseState &= ~enumGISMouseLeftDown; //set map init envelope pDisplayTransformation->SetDeviceFrame(GetClientRect()); } else if(m_MouseState & enumGISMouseWheel) { m_MouseState &= ~enumGISMouseWheel; //set new map envelope //OGREnvelope virtualbounds;// = pDisplayTransformation->GetBounds(); //wxRect rc = GetClientRect(); //double zoomfactor = MIN((double)m_virtualrc.width / rc.width, (double)m_virtualrc.height / rc.height); //if(m_zoomfactor < 0) // m_zoomfactor = 2 / fabs(m_zoomfactor); //double delta_x = (virtualbounds.MaxX - virtualbounds.MinX) /*/ 2*/ * m_zoomfactor; //double delta_y = (virtualbounds.MaxY - virtualbounds.MinY) /*/ 2*/ * m_zoomfactor; //virtualbounds.MinX += delta_x; //virtualbounds.MaxX -= delta_x; //virtualbounds.MinY += delta_y; //virtualbounds.MaxY -= delta_y; //m_virtualrc2.CenterIn(GetClientRect()); //wxPoint points[2]; //points[0].x = m_virtualrc2.GetLeft(); //points[0].y = m_virtualrc2.GetTop(); //points[1].x = m_virtualrc2.GetRight(); //points[1].y = m_virtualrc2.GetBottom(); //OGRRawPoint* pPoints = pDisplayTransformation->TransformCoordDC2World(points, 2); //virtualbounds.MinX = pPoints[0].x; //virtualbounds.MinY = pPoints[1].y; //virtualbounds.MaxX = pPoints[1].x; //virtualbounds.MaxY = pPoints[0].y; //delete [] pPoints; // pDisplayTransformation->SetBounds(m_virtualbounds); m_timer.Stop(); m_pExtenStack->Do(m_virtualbounds); return; } else return; pGISScreenDisplay->SetDerty(true); m_timer.Stop(); Refresh(false); }
bool wxDialogEx::CanShowPopupDialog() { if( ShownDialogs() || IsShowingMessageBox() ) { return false; } wxMouseState mouseState = wxGetMouseState(); if( mouseState.LeftIsDown() || mouseState.MiddleIsDown() || mouseState.RightIsDown() ) { return false; } #ifdef __WXMSW__ // Don't check for changes if mouse is captured, // e.g. if user is dragging a file if (GetCapture()) { return false; } #endif return true; }
///> Checks the current state of the button. bool GetState() const { wxMouseState mouseState = wxGetMouseState(); switch( button ) { case BUT_LEFT: return mouseState.LeftIsDown(); case BUT_MIDDLE: return mouseState.MiddleIsDown(); case BUT_RIGHT: return mouseState.RightIsDown(); default: assert( false ); break; } return false; }
void DisplayVariableDlg::OnCheckMousePosTimer(wxTimerEvent& e) { if ( m_editDlgIsUp ) { return; } wxRect rect = GetScreenRect().Inflate(20, 30); wxPoint pt = ::wxGetMousePosition(); bool mouseLeftWidow = !rect.Contains( pt ); if(mouseLeftWidow) { wxMouseState state = wxGetMouseState(); // This is to fix a 'MouseCapture' bug on Linux while leaving the mouse Window // and mouse button is clicked and scrolling the scrollbar (H or Vertical) // The UI hangs if (state.LeftIsDown()) { // Don't Hide, just restart the timer return; } HideDialog(); } }
bool PollKeyboardMouseEvent(u32 &pkey) { // Cancel? if (wxGetKeyState(WXK_ESCAPE)) { pkey = 0; return true; } // Keyboard key states for (u32 i = WXK_NONE; i != WXK_SPECIAL20; i++) { if (wxGetKeyState(static_cast<wxKeyCode>(i))) { PAD_LOG("State %i\n", i); pkey = i; return true; } } // Mouse button states u32 initial = -1; wxMouseState state = wxGetMouseState(); if (state.LeftIsDown()) { initial = pkey = 1; } else if (state.MiddleIsDown()) { initial = pkey = 2; } else if (state.RightIsDown()) { initial = pkey = 3; } else if (state.Aux1IsDown()) { initial = pkey = 4; } else if (state.Aux2IsDown()) { initial = pkey = 5; } return (initial!=-1); }
void wxGISMapView::OnTimer( wxTimerEvent& event ) { //event.Skip(); //wxSafeYield(this, true); #ifdef __WXGTK__ wxWakeUpIdle(); #endif switch(m_nDrawingState) { case enumGISMapZooming: { //stop zooming action if(m_pGISDisplay && !wxGetMouseState().LeftIsDown()) //user release mouse button, so draw contents { wxRect rc = GetClientRect(); m_pGISDisplay->SetDeviceFrame(rc); m_pGISDisplay->SetDerty(true); m_nDrawingState = enumGISMapDrawing; CreateAndRunDrawThread(); //wxCommandEvent evt(wxEVT_COMMAND_STARTDRAWING);wxEVT_COMMAND_DATA_SENT //GetEventHandler()->ProcessEvent( evt ); // if(!m_pMapDrawingThread)//m_nDrawingState = enumGISMapDrawing // { // StartDraingThread(); // } m_timer.Stop(); //Thaw(); } } break; case enumGISMapWheeling: m_nDrawingState = enumGISMapWheelingStop; return; case enumGISMapWheelingStop: //stop wheeling action if(m_pGISDisplay) { double dZoom = 1; if(m_nFactor < 0) dZoom = fabs(1.0 / (m_nFactor - 1)); else if(m_nFactor > 0) dZoom = 1 + m_nFactor; OGREnvelope Env = CreateEnvelopeFromZoomFactor(dZoom); if(Env.IsInit())//set new bounds Do(Env); m_nDrawingState = enumGISMapDrawing; } m_nFactor = 0; m_timer.Stop(); return; break; case enumGISMapFlashing: if(m_staFlashGeoms.empty()) { m_nDrawingState = enumGISMapDrawing; m_pGISDisplay->SetDrawCache(m_pGISDisplay->GetLastCacheID(), true); m_timer.Stop(); } else { Flash(m_eFlashStyle); } break; case enumGISMapDrawing: break;//not stop timer case enumGISMapNone: default: m_timer.Stop(); break; }; Refresh(); }
void AutoMapSaver::checkSave() { // Check if we have a proper map if (!GlobalMap().isValid() || !GlobalMainFrame().screenUpdatesEnabled()) { return; } // greebo: Check if we have a valid main window to grab the pointer wxFrame* mainWindow = GlobalMainFrame().getWxTopLevelWindow(); if (mainWindow == NULL || !mainWindow->IsActive()) { rMessage() << "AutoSaver: Main window not present or not shown on screen, " << "will wait for another period." << std::endl; return; } // Check, if changes have been made since the last autosave if (_changes == GlobalSceneGraph().root()->getUndoChangeTracker().changes()) { return; } // Check if the user is currently pressing a mouse button // Don't start the save if the user is holding a mouse button if (wxGetMouseState().ButtonIsDown(wxMOUSE_BTN_ANY)) { return; } _changes = GlobalSceneGraph().root()->getUndoChangeTracker().changes(); // Stop the timer before saving stopTimer(); if (_enabled) { // only snapshot if not working on an unnamed map if (_snapshotsEnabled && !GlobalMap().isUnnamed()) { try { saveSnapshot(); } catch (boost::filesystem::filesystem_error& f) { rError() << "AutoSaver::saveSnapshot: " << f.what() << std::endl; } } else { if (GlobalMap().isUnnamed()) { // Get the maps path (within the mod path) std::string autoSaveFilename = GlobalRegistry().get(RKEY_MAP_PATH); // Try to create the map folder, in case there doesn't exist one os::makeDirectory(autoSaveFilename); // Append the "autosave.map" to the filename autoSaveFilename += "autosave."; autoSaveFilename += game::current::getValue<std::string>(GKEY_MAP_EXTENSION); rMessage() << "Autosaving unnamed map to " << autoSaveFilename << std::endl; // Invoke the save call GlobalMap().saveDirect(autoSaveFilename); } else { // Construct the new filename (e.g. "test_autosave.map") std::string filename = GlobalMap().getMapName(); std::string extension = os::getExtension(filename); // Cut off the extension filename = filename.substr(0, filename.rfind('.')); filename += "_autosave"; filename += "." + extension; rMessage() << "Autosaving map to " << filename << std::endl; // Invoke the save call GlobalMap().saveDirect(filename); } } } else { rMessage() << "Autosave skipped..." << std::endl; } // Re-start the timer after saving has finished startTimer(); }
// utility function which determines the state of the mouse button // (independant of having a wxMouseEvent handy) - utimately a better // mechanism for this should be found (possibly by adding the // functionality to wxWidgets itself) bool wxAuiFloatingFrame::isMouseDown() { return wxGetMouseState().LeftIsDown(); }