bool LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey ) { bool eventHandled = true; // Filter out the 'fake' mouse motion after a keyboard movement if( !aHotKey && m_movingCursorWithKeyboard ) { m_movingCursorWithKeyboard = false; return false; } wxPoint pos = aPosition; GeneralControlKeyMovement( aHotKey, &pos, true ); // Update cursor position. m_canvas->CrossHairOn( aDC ); SetCrossHairPosition( pos, true ); if( aHotKey ) { SCH_SCREEN* screen = GetScreen(); if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() ) eventHandled = OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() ); else eventHandled = OnHotKey( aDC, aHotKey, aPosition, NULL ); } UpdateStatusBar(); // Display cursor coordinates info. return eventHandled; }
bool FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { bool eventHandled = true; // Filter out the 'fake' mouse motion after a keyboard movement if( !aHotKey && m_movingCursorWithKeyboard ) { m_movingCursorWithKeyboard = false; return false; } // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed // for next cursor position // ( shift or ctrl key down are PAN command with mouse wheel) bool snapToGrid = true; if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) ) snapToGrid = false; wxPoint oldpos = GetCrossHairPosition(); wxPoint pos = aPosition; GeneralControlKeyMovement( aHotKey, &pos, snapToGrid ); SetCrossHairPosition( pos, snapToGrid ); RefreshCrossHair( oldpos, aPosition, aDC ); if( aHotKey ) { eventHandled = OnHotKey( aDC, aHotKey, aPosition ); } UpdateStatusBar(); return eventHandled; }
static LRESULT CALLBACK TaskWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: OnCreate(hWnd); return 0; case WM_ERASEBKGND: return 0; case WM_PAINT: OnPaint(hWnd); return 0; case WM_TIMER: OnTimer(wParam); return 0; case WM_HOTKEY: return OnHotKey(HTaskWnd, wParam, lParam); case WM_DESTROY: OnDestroy(); return 0; default: return DefWindowProc(hWnd, msg, wParam, lParam); } }
void PL_EDITOR_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { // Filter out the 'fake' mouse motion after a keyboard movement if( !aHotKey && m_movingCursorWithKeyboard ) { m_movingCursorWithKeyboard = false; return; } wxPoint pos = aPosition; wxPoint oldpos = GetCrossHairPosition(); GeneralControlKeyMovement( aHotKey, &pos, true ); // Update cursor position. SetCrossHairPosition( pos, true ); RefreshCrossHair( oldpos, aPosition, aDC ); if( aHotKey ) { OnHotKey( aDC, aHotKey, aPosition ); } UpdateStatusBar(); }
bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { bool eventHandled = true; // Filter out the 'fake' mouse motion after a keyboard movement if( !aHotKey && m_movingCursorWithKeyboard ) { m_movingCursorWithKeyboard = false; return false; } // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed // for next cursor position // ( shift or ctrl key down are PAN command with mouse wheel) bool snapToGrid = true; if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) ) snapToGrid = false; // Cursor is left off grid only if no block in progress if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) snapToGrid = true; wxPoint pos = aPosition; wxPoint oldpos = GetCrossHairPosition(); GeneralControlKeyMovement( aHotKey, &pos, snapToGrid ); // Update cursor position. SetCrossHairPosition( pos, snapToGrid ); RefreshCrossHair( oldpos, aPosition, aDC ); if( aHotKey ) { SCH_SCREEN* screen = GetScreen(); if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() ) eventHandled = OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() ); else eventHandled = OnHotKey( aDC, aHotKey, aPosition, NULL ); } UpdateStatusBar(); /* Display cursor coordinates info */ return eventHandled; }
LRESULT CWin::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lRes = 0; BOOL bHandled = TRUE; switch (uMsg) { case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break; case WM_CLOSE: lRes = OnClose(uMsg, wParam, lParam, bHandled); break; case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break; #if defined(WIN32) && !defined(UNDER_CE) //case WM_NCCREATE: lRes = OnNcCreate(uMsg, wParam, lParam, bHandled); break; case WM_NCMOUSEMOVE: lRes = OnNCMouseMove(uMsg, wParam, lParam, bHandled); break; case WM_NCMOUSELEAVE: lRes = OnNCMouseLeave(uMsg, wParam, lParam, bHandled); break; case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break; case WM_NCCALCSIZE: lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break; case WM_NCPAINT: lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break; case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break; case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break; case WM_MOUSEWHEEL: lRes = OnMouseWheel(uMsg, wParam, lParam, bHandled); break; #endif case WM_ERASEBKGND: lRes = OnEraseBkGnd(uMsg, wParam, lParam, bHandled); break; case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break; case WM_CHAR: lRes = OnChar(uMsg, wParam, lParam, bHandled); break; case WM_SYSCOMMAND: lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); break; case WM_KEYDOWN: lRes = OnKeyDown(uMsg, wParam, lParam, bHandled); break; case WM_KILLFOCUS: lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); break; case WM_SETFOCUS: lRes = OnSetFocus(uMsg, wParam, lParam, bHandled); break; case WM_LBUTTONUP: lRes = OnLButtonUp(uMsg, wParam, lParam, bHandled); break; case WM_LBUTTONDOWN: lRes = OnLButtonDown(uMsg, wParam, lParam, bHandled); break; case WM_MOUSEMOVE: lRes = OnMouseMove(uMsg, wParam, lParam, bHandled); break; case WM_MOUSELEAVE: lRes = OnMouseLeave(uMsg, wParam, lParam, bHandled); break; case WM_MOUSEHOVER: lRes = OnMouseHover(uMsg, wParam, lParam, bHandled); break; case WM_HOTKEY: lRes = OnHotKey(uMsg, wParam, lParam, bHandled); break; // case WM_TIMER: lRes = OnTimer(uMsg, wParam, lParam, bHandled); break;//OnTimer响应有小问题 case WM_MOVING: lRes = OnMoving(uMsg, wParam, lParam, bHandled); break; case WM_SIZING: lRes = OnSizing(uMsg, wParam, lParam, bHandled); break; case WM_SHOWWINDOW: lRes = OnShowWindow(uMsg, wParam, lParam, bHandled); break; case WM_COMMAND: lRes = OnCommand(uMsg, wParam, lParam, bHandled); break; // case WM_PAINT: lRes = OnPaint(uMsg, wParam, lParam, bHandled); break;//OnPaint响应有问题 case WM_MENUCOMMAND: lRes = OnMenuCommand(uMsg, wParam, lParam, bHandled); break; default: bHandled = FALSE; break; } if (bHandled) return lRes; lRes = ProcessWindowMessage(uMsg, wParam, lParam, bHandled); if (bHandled) return lRes; if(_paintManager && _paintManager->MessageHandler(uMsg,wParam,lParam,lRes)) return lRes; return __super::HandleMessage(uMsg,wParam,lParam); }
void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { // Filter out the 'fake' mouse motion after a keyboard movement if( !aHotKey && m_movingCursorWithKeyboard ) { m_movingCursorWithKeyboard = false; return; } // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed // for next cursor position // ( shift or ctrl key down are PAN command with mouse wheel) bool snapToGrid = true; if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) ) snapToGrid = false; wxPoint oldpos = GetCrossHairPosition(); wxPoint pos = aPosition; GeneralControlKeyMovement( aHotKey, &pos, snapToGrid ); // Put cursor in new position, according to the zoom keys (if any). SetCrossHairPosition( pos, snapToGrid ); /* Put cursor on grid or a pad centre if requested. If the tool DELETE is active the * cursor is left off grid this is better to reach items to delete off grid, */ if( GetToolId() == ID_PCB_DELETE_ITEM_BUTT ) snapToGrid = false; // Cursor is left off grid if no block in progress if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) snapToGrid = true; wxPoint curs_pos = pos; wxRealPoint gridSize = GetScreen()->GetGridSize(); wxSize igridsize; igridsize.x = KiROUND( gridSize.x ); igridsize.y = KiROUND( gridSize.y ); if( Magnetize( this, GetToolId(), igridsize, curs_pos, &pos ) ) { SetCrossHairPosition( pos, false ); } else { // If there's no intrusion and DRC is active, we pass the cursor // "as is", and let ShowNewTrackWhenMovingCursor figure out what to do. if( !g_Drc_On || !g_CurrentTrackSegment || (BOARD_ITEM*)g_CurrentTrackSegment != this->GetCurItem() || !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment, GetScreen()->m_Active_Layer, RefPos( true ) ) ) { SetCrossHairPosition( curs_pos, snapToGrid ); } } RefreshCrossHair( oldpos, aPosition, aDC ); if( aHotKey ) { OnHotKey( aDC, aHotKey, aPosition ); } UpdateStatusBar(); // Display new cursor coordinates }
void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; wxPoint oldpos; wxPoint pos = aPosition; // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed // for next cursor position // ( shift or ctrl key down are PAN command with mouse wheel) bool snapToGrid = true; if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) ) snapToGrid = false; if( snapToGrid ) pos = GetNearestGridPosition( pos ); oldpos = GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); switch( aHotKey ) { case WXK_NUMPAD8: case WXK_UP: pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: case WXK_DOWN: pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: case WXK_LEFT: pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: case WXK_RIGHT: pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; default: break; } // Put cursor in new position, according to the zoom keys (if any). SetCrossHairPosition( pos, snapToGrid ); /* Put cursor on grid or a pad centre if requested. If the tool DELETE is active the * cursor is left off grid this is better to reach items to delete off grid, */ if( GetToolId() == ID_PCB_DELETE_ITEM_BUTT ) snapToGrid = false; // Cursor is left off grid if no block in progress if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) snapToGrid = true; wxPoint curs_pos = pos; wxSize igridsize; igridsize.x = KiROUND( gridSize.x ); igridsize.y = KiROUND( gridSize.y ); if( Magnetize( this, GetToolId(), igridsize, curs_pos, &pos ) ) { SetCrossHairPosition( pos, false ); } else { // If there's no intrusion and DRC is active, we pass the cursor // "as is", and let ShowNewTrackWhenMovingCursor figure out what to do. if( !g_Drc_On || !g_CurrentTrackSegment || (BOARD_ITEM*)g_CurrentTrackSegment != this->GetCurItem() || !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment, GetScreen()->m_Active_Layer, RefPos( true ) ) ) { SetCrossHairPosition( curs_pos, snapToGrid ); } } if( oldpos != GetCrossHairPosition() ) { pos = GetCrossHairPosition(); SetCrossHairPosition( oldpos, false ); m_canvas->CrossHairOff( aDC ); SetCrossHairPosition( pos, false ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) { #ifdef USE_WX_OVERLAY wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC ); oDC.Clear(); m_canvas->CallMouseCapture( aDC, aPosition, false ); #else m_canvas->CallMouseCapture( aDC, aPosition, true ); #endif } #ifdef USE_WX_OVERLAY else { m_overlay.Reset(); } #endif } if( aHotKey ) { OnHotKey( aDC, aHotKey, aPosition ); } UpdateStatusBar(); // Display new cursor coordinates }
bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey ) { // Filter out the 'fake' mouse motion after a keyboard movement if( !aHotKey && m_movingCursorWithKeyboard ) { m_movingCursorWithKeyboard = false; return false; } // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed // for next cursor position // ( shift or ctrl key down are PAN command with mouse wheel) bool snapToGrid = true; if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) ) snapToGrid = false; // Cursor is left off grid only if no block in progress if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) snapToGrid = true; wxPoint pos = aPosition; bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, snapToGrid ); if( GetToolId() == ID_NO_TOOL_SELECTED ) m_canvas->CrossHairOff( aDC ); else m_canvas->CrossHairOn( aDC ); GetGalCanvas()->GetViewControls()->SetSnapping( snapToGrid ); SetCrossHairPosition( pos, snapToGrid ); if( m_canvas->IsMouseCaptured() ) m_canvas->CallMouseCapture( aDC, aPosition, true ); if( aHotKey ) { if( m_movingCursorWithKeyboard ) // The hotkey was a move crossahir cursor command { // The crossair was moved. move the mouse cursor to the new crosshair position: GetGalCanvas()->GetViewControls()->WarpCursor( GetCrossHairPosition(), true ); m_movingCursorWithKeyboard = 0; } else { SCH_SCREEN* screen = GetScreen(); bool hk_handled; if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() ) hk_handled = OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() ); else hk_handled = OnHotKey( aDC, aHotKey, aPosition, NULL ); if( hk_handled ) keyHandled = true; } } UpdateStatusBar(); /* Display cursor coordinates info */ return keyHandled; }
void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; wxPoint oldpos; wxPoint pos = aPosition; // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed // for next cursor position // ( shift or ctrl key down are PAN command with mouse wheel) bool snapToGrid = true; if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) ) snapToGrid = false; if( snapToGrid ) pos = GetNearestGridPosition( pos ); oldpos = GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); switch( aHotKey ) { case WXK_NUMPAD8: case WXK_UP: pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: case WXK_DOWN: pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: case WXK_LEFT: pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: case WXK_RIGHT: pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; default: break; } SetCrossHairPosition( pos, snapToGrid ); if( oldpos != GetCrossHairPosition() ) { pos = GetCrossHairPosition(); SetCrossHairPosition( oldpos, false ); m_canvas->CrossHairOff( aDC ); SetCrossHairPosition( pos, snapToGrid ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) { #ifdef USE_WX_OVERLAY wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC ); oDC.Clear(); m_canvas->CallMouseCapture( aDC, aPosition, false ); #else m_canvas->CallMouseCapture( aDC, aPosition, true ); #endif } #ifdef USE_WX_OVERLAY else { m_overlay.Reset(); } #endif } if( aHotKey ) { OnHotKey( aDC, aHotKey, aPosition ); } UpdateStatusBar(); }
void WinEDA_BasePcbFrame::GeneralControle(wxDC *DC, wxPoint Mouse) /****************************************************************/ /* traitement des touches de fonctions utilisees ds tous les menus Zoom Redessin d'ecran Cht Unites Cht couches Remise a 0 de l'origine des coordonnees relatives */ { wxSize delta; wxPoint curpos, oldpos; int hotkey = 0; if( GetScreen()->IsRefreshReq() ) { RedrawActiveWindow(DC, TRUE); // We must return here, instead of proceeding. // If we let the cursor move during a refresh request, // the cursor be displayed in the wrong place // during delayed repaint events that occur when // you move the mouse when a message dialog is on // the screen, and then you dismiss the dialog by // typing the Enter key. return; } curpos = DrawPanel->CursorRealPosition(Mouse); oldpos = GetScreen()->m_Curseur; delta.x = GetScreen()->GetGrid().x / GetScreen()->GetZoom(); delta.y = GetScreen()->GetGrid().y / GetScreen()->GetZoom(); if( delta.x == 0 ) delta.x = 1; if( delta.y == 0 ) delta.y = 1; switch(g_KeyPressed) { case WXK_NUMPAD_SUBTRACT : case WXK_SUBTRACT : case '-' : if(GetScreen()->m_Active_Layer > 0) GetScreen()->m_Active_Layer--; break ; case WXK_NUMPAD_ADD : case WXK_ADD : case '+' : if(GetScreen()->m_Active_Layer < 31) GetScreen()->m_Active_Layer ++; break ; case 'F' | GR_KB_CTRL : case 'f' | GR_KB_CTRL : DisplayOpt.DisplayPcbTrackFill ^= 1; DisplayOpt.DisplayPcbTrackFill &= 1 ; GetScreen()->SetRefreshReq(); break ; case ' ' : /* Mise a jour de l'origine des coord relatives */ GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; break ; case 'U' | GR_KB_CTRL : case 'u' | GR_KB_CTRL : if (g_UnitMetric == INCHES ) g_UnitMetric = MILLIMETRE ; else g_UnitMetric = INCHES ; break ; case WXK_F1 : OnZoom(ID_ZOOM_PLUS_KEY); curpos = GetScreen()->m_Curseur; break; case WXK_F2 : OnZoom(ID_ZOOM_MOINS_KEY); curpos = GetScreen()->m_Curseur; break; case WXK_F3 : OnZoom(ID_ZOOM_REDRAW_KEY); break; case WXK_F4 : OnZoom(ID_ZOOM_CENTER_KEY); curpos = GetScreen()->m_Curseur; break; case WXK_NUMPAD8 : /* Deplacement curseur vers le haut */ case WXK_UP : Mouse.y -= delta.y; DrawPanel->MouseTo(Mouse); break ; case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_DOWN: Mouse.y += delta.y; DrawPanel->MouseTo(Mouse); break ; case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_LEFT : Mouse.x -= delta.x; DrawPanel->MouseTo(Mouse); break ; case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_RIGHT : Mouse.x += delta.x; DrawPanel->MouseTo(Mouse); break ; default: hotkey = g_KeyPressed; break; } /* Recalcul de la position du curseur schema */ GetScreen()->m_Curseur = curpos; /* Placement sur la grille generale */ PutOnGrid( & GetScreen()->m_Curseur); if ( (oldpos.x != GetScreen()->m_Curseur.x) || (oldpos.y != GetScreen()->m_Curseur.y) ) { curpos = GetScreen()->m_Curseur; GetScreen()->m_Curseur = oldpos; GetScreen()->CursorOff(DrawPanel, DC); GetScreen()->m_Curseur = curpos; GetScreen()->CursorOn(DrawPanel, DC); if(GetScreen()->ManageCurseur) { GetScreen()->ManageCurseur(DrawPanel, DC, TRUE); } } SetToolbars(); Affiche_Status_Box(); /* Affichage des coord curseur */ if ( hotkey ) { OnHotKey(DC, hotkey, NULL); } }
void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; SCH_SCREEN* screen = GetScreen(); wxPoint oldpos; wxPoint pos = aPosition; pos = screen->GetNearestGridPosition( pos ); oldpos = screen->GetCrossHairPosition(); gridSize = screen->GetGridSize(); switch( aHotKey ) { case 0: break; case WXK_NUMPAD8: case WXK_UP: pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: case WXK_DOWN: pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: case WXK_LEFT: pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: case WXK_RIGHT: pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; default: break; } // Update cursor position. screen->SetCrossHairPosition( pos ); if( oldpos != screen->GetCrossHairPosition() ) { pos = screen->GetCrossHairPosition(); screen->SetCrossHairPosition( oldpos ); m_canvas->CrossHairOff( aDC ); screen->SetCrossHairPosition( pos ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) { m_canvas->CallMouseCapture( aDC, aPosition, true ); } } if( aHotKey ) { if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() ) OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() ); else OnHotKey( aDC, aHotKey, aPosition, NULL ); } UpdateStatusBar(); }
void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; SCH_SCREEN* screen = GetScreen(); wxPoint oldpos; wxPoint pos = aPosition; // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed // for next cursor position // ( shift or ctrl key down are PAN command with mouse wheel) bool snapToGrid = true; if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) ) snapToGrid = false; // Cursor is left off grid only if no block in progress if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) snapToGrid = true; if( snapToGrid ) pos = screen->GetNearestGridPosition( pos ); oldpos = screen->GetCrossHairPosition(); gridSize = screen->GetGridSize(); switch( aHotKey ) { case 0: break; case WXK_NUMPAD8: case WXK_UP: pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: case WXK_DOWN: pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: case WXK_LEFT: pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: case WXK_RIGHT: pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; default: break; } // Update cursor position. screen->SetCrossHairPosition( pos, snapToGrid ); if( oldpos != screen->GetCrossHairPosition() ) { pos = screen->GetCrossHairPosition(); screen->SetCrossHairPosition( oldpos, false); m_canvas->CrossHairOff( aDC ); screen->SetCrossHairPosition( pos, snapToGrid ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) { #ifdef USE_WX_OVERLAY wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC ); oDC.Clear(); m_canvas->CallMouseCapture( aDC, aPosition, false ); #else m_canvas->CallMouseCapture( aDC, aPosition, true ); #endif } #ifdef USE_WX_OVERLAY else { m_overlay.Reset(); } #endif } if( aHotKey ) { if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() ) OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() ); else OnHotKey( aDC, aHotKey, aPosition, NULL ); } UpdateStatusBar(); /* Display cursor coordinates info */ }
void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; wxPoint oldpos; wxPoint pos = aPosition; pos = GetScreen()->GetNearestGridPosition( aPosition ); oldpos = GetScreen()->GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); switch( aHotKey ) { case WXK_NUMPAD8: case WXK_UP: pos.y -= wxRound( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: case WXK_DOWN: pos.y += wxRound( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: case WXK_LEFT: pos.x -= wxRound( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: case WXK_RIGHT: pos.x += wxRound( gridSize.x ); m_canvas->MoveCursor( pos ); break; default: break; } GetScreen()->SetCrossHairPosition( pos ); if( oldpos != GetScreen()->GetCrossHairPosition() ) { pos = GetScreen()->GetCrossHairPosition(); GetScreen()->SetCrossHairPosition( oldpos ); m_canvas->CrossHairOff( aDC ); GetScreen()->SetCrossHairPosition( pos ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) { #ifdef USE_WX_OVERLAY wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC ); oDC.Clear(); m_canvas->CallMouseCapture( aDC, aPosition, false ); #else m_canvas->CallMouseCapture( aDC, aPosition, true ); #endif } #ifdef USE_WX_OVERLAY else { m_overlay.Reset(); } #endif } if( aHotKey ) { OnHotKey( aDC, aHotKey, aPosition ); } UpdateStatusBar(); }
bool CCWidget::Event(CCEvent* pEvent){ if(m_bVisible==false) return false; sRect r = GetRect(); r.x = r.y = 0; if(pEvent->iMessage==CCWM_LBUTTONDOWN) int k=0; CCEvent LocalEvent; MakeLocalEvent(&LocalEvent, pEvent); if(m_iDebugType==2){ if(pEvent->iMessage==CCWM_LBUTTONDOWN ) int k=0; } if(r.InPoint(LocalEvent.sPos)==true && (CCWidget::m_pCapturedWidget==NULL || CCWidget::m_pCapturedWidget==this) && IsVisible()==true){ if(m_pCursor!=NULL) CCCursorSystem::Set(m_pCursor); else CCCursorSystem::Set(CCCURSOR_ARROW); if(m_pToolTip!=NULL){ SetZOrder(CC_TOP); m_pToolTip->Show(true); } } else{ if(m_pToolTip!=NULL){ m_pToolTip->Show(false); } } if(m_bEnable==false) return false; if(GetLatestExclusive()!=NULL){ if(GetLatestExclusive()->Event(pEvent)==true) return true; if(GetLatestExclusive()!=NULL) return false; } if(pEvent->iMessage==CCWM_LBUTTONDOWN){ if ( r.InPoint(LocalEvent.sPos)==true){ SetFocus(); if((m_bFocusEnable)&&(m_bZOrderChangable==true)) SetZOrder(CC_TOP); } else // ReleaseFocus { // ReleaseFocus(); // OnReleaseFocus(); // ReleaseCapture(); } } if(GetLatestExclusive()==NULL){ for(int i=m_Children.GetCount()-1; i>=0; i--){ CCWidget* pCurWnd = m_Children.Get(i); if(pCurWnd->Event(pEvent)==true) { return true; } } } if(EventResize(pEvent)==true) return true; if(pEvent->iMessage==CCWM_HOTKEY){ if(OnHotKey(pEvent->uKey)==true) return true; } if(pEvent->iMessage==CCWM_CHAR || pEvent->iMessage==CCWM_KEYDOWN || pEvent->iMessage==CCWM_IMECOMPOSE || pEvent->iMessage==CCWM_ACTIONKEYDOWN || pEvent->iMessage==CCWM_ACTIONKEYUP || pEvent->iMessage==CCWM_ACTIONPRESSED || pEvent->iMessage==CCWM_ACTIONRELEASED){ if (IsFocus()) { if(OnEvent(&LocalEvent, GetListener())==true) return true; // Tab Key if(pEvent->iMessage==CCWM_KEYDOWN && pEvent->uKey==VK_TAB){ if(OnTab(!pEvent->GetShiftState())==true) return true; } } } else{ if((CCWidget::m_pCapturedWidget==NULL || CCWidget::m_pCapturedWidget==this)) if(OnEvent(&LocalEvent, GetListener())==true) return true; } if(pEvent->iMessage==CCWM_LBUTTONUP) ReleaseCapture(); return false; }
void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; wxPoint oldpos; wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition ); oldpos = GetScreen()->GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); switch( aHotKey ) { case WXK_NUMPAD8: case WXK_UP: pos.y -= wxRound( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: case WXK_DOWN: pos.y += wxRound( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: case WXK_LEFT: pos.x -= wxRound( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: case WXK_RIGHT: pos.x += wxRound( gridSize.x ); m_canvas->MoveCursor( pos ); break; default: break; } // Put cursor in new position, according to the zoom keys (if any). GetScreen()->SetCrossHairPosition( pos ); /* Put cursor on grid or a pad centre if requested. If the tool DELETE is active the * cursor is left off grid this is better to reach items to delete off grid, */ bool keep_on_grid = true; if( GetToolId() == ID_PCB_DELETE_ITEM_BUTT ) keep_on_grid = false; /* Cursor is left off grid if no block in progress and no moving object */ if( GetScreen()->m_BlockLocate.m_State != STATE_NO_BLOCK ) keep_on_grid = true; EDA_ITEM* DrawStruct = GetScreen()->GetCurItem(); if( DrawStruct && DrawStruct->GetFlags() ) keep_on_grid = true; if( keep_on_grid ) { wxPoint on_grid = GetScreen()->GetNearestGridPosition( pos ); wxSize grid; grid.x = (int) GetScreen()->GetGridSize().x; grid.y = (int) GetScreen()->GetGridSize().y; if( Magnetize( m_Pcb, this, GetToolId(), grid, on_grid, &pos ) ) { GetScreen()->SetCrossHairPosition( pos, false ); } else { // If there's no intrusion and DRC is active, we pass the cursor // "as is", and let ShowNewTrackWhenMovingCursor figure out what to do. if( !Drc_On || !g_CurrentTrackSegment || (BOARD_ITEM*)g_CurrentTrackSegment != this->GetCurItem() || !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment, GetScreen()->m_Active_Layer, GetScreen()->RefPos( true ) ) ) { GetScreen()->SetCrossHairPosition( on_grid ); } } } if( oldpos != GetScreen()->GetCrossHairPosition() ) { pos = GetScreen()->GetCrossHairPosition(); GetScreen()->SetCrossHairPosition( oldpos, false ); m_canvas->CrossHairOff( aDC ); GetScreen()->SetCrossHairPosition( pos, false ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) { #ifdef USE_WX_OVERLAY wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC ); oDC.Clear(); m_canvas->CallMouseCapture( aDC, aPosition, false ); #else m_canvas->CallMouseCapture( aDC, aPosition, true ); #endif } #ifdef USE_WX_OVERLAY else { m_overlay.Reset(); } #endif } if( aHotKey ) { OnHotKey( aDC, aHotKey, aPosition ); } UpdateStatusBar(); /* Display new cursor coordinates */ }