bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem ) { if( aHotKey == 0 ) return false; wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); bool itemInEdit = m_drawItem && m_drawItem->InEditMode(); /* Convert lower to upper case (the usual toupper function has problem * with non ascii codes like function keys */ if( (aHotKey >= 'a') && (aHotKey <= 'z') ) aHotKey += 'A' - 'a'; EDA_HOTKEY* hotKey = GetDescriptorFromHotkey( aHotKey, common_Hotkey_List ); if( hotKey == NULL ) hotKey = GetDescriptorFromHotkey( aHotKey, libEdit_Hotkey_List ); if( hotKey == NULL ) return false; switch( hotKey->m_Idcommand ) { default: case HK_NOT_FOUND: return false; case HK_HELP: // Display Current hotkey list DisplayHotkeyList( this, g_Libedit_Hokeys_Descr ); break; case HK_RESET_LOCAL_COORD: // Reset the relative coord GetScreen()->m_O_Curseur = GetCrossHairPosition(); break; case HK_LEFT_CLICK: OnLeftClick( aDC, aPosition ); break; case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events OnLeftClick( aDC, aPosition ); OnLeftDClick( aDC, aPosition ); break; case HK_ZOOM_IN: case HK_ZOOM_OUT: case HK_ZOOM_REDRAW: case HK_ZOOM_CENTER: case HK_ZOOM_AUTO: cmd.SetId( hotKey->m_IdMenuEvent ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_UNDO: case HK_REDO: if( !itemInEdit ) { cmd.SetId( hotKey->m_IdMenuEvent ); GetEventHandler()->ProcessEvent( cmd ); } break; case HK_REPEAT_LAST: if( ! itemInEdit ) { if( m_lastDrawItem && !m_lastDrawItem->InEditMode() && ( m_lastDrawItem->Type() == LIB_PIN_T ) ) RepeatPinItem( aDC, (LIB_PIN*) m_lastDrawItem ); } break; case HK_EDIT: if( ! itemInEdit ) m_drawItem = LocateItemUsingCursor( aPosition ); if( m_drawItem ) { switch( m_drawItem->Type() ) { case LIB_PIN_T: cmd.SetId( ID_LIBEDIT_EDIT_PIN ); GetEventHandler()->ProcessEvent( cmd ); break; case LIB_ARC_T: case LIB_CIRCLE_T: case LIB_RECTANGLE_T: case LIB_POLYLINE_T: case LIB_TEXT_T: cmd.SetId( ID_POPUP_LIBEDIT_BODY_EDIT_ITEM ); GetEventHandler()->ProcessEvent( cmd ); break; case LIB_FIELD_T: cmd.SetId( ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM ); GetEventHandler()->ProcessEvent( cmd ); break; default: break; } } break; case HK_ROTATE: if( ! itemInEdit ) m_drawItem = LocateItemUsingCursor( aPosition ); if( m_drawItem ) { cmd.SetId( ID_LIBEDIT_ROTATE_ITEM ); GetEventHandler()->ProcessEvent( cmd ); } break; case HK_LIBEDIT_CREATE_PIN: if( ! itemInEdit ) { SetToolID( ID_LIBEDIT_PIN_BUTT, wxCURSOR_PENCIL, _( "Add Pin" ) ); OnLeftClick( aDC, aPosition ); } break; case HK_DELETE: if( !itemInEdit ) m_drawItem = LocateItemUsingCursor( aPosition ); if( m_drawItem && !m_drawItem->InEditMode() ) { cmd.SetId( ID_POPUP_LIBEDIT_DELETE_ITEM ); Process_Special_Functions( cmd ); } break; case HK_LIBEDIT_MOVE_GRAPHIC_ITEM: if( !itemInEdit ) { m_drawItem = LocateItemUsingCursor( aPosition ); if( m_drawItem ) { cmd.SetId( ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST ); Process_Special_Functions( cmd ); } } break; case HK_DRAG: if( !itemInEdit ) { m_drawItem = LocateItemUsingCursor( aPosition ); if( m_drawItem && !m_drawItem->InEditMode() ) { cmd.SetId( ID_POPUP_LIBEDIT_MODIFY_ITEM ); Process_Special_Functions( cmd ); } } break; } // Hot key handled. return true; }
BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hList = GetDlgItem (hwndDlg, IDC_HOTKEY_LIST); HWND hwndMainDlg = hwndDlg; WORD lw = LOWORD (wParam); WORD hw = HIWORD (wParam); static BOOL bKeyScanOn; static BOOL bTPlaySoundOnHotkeyMountDismount; static BOOL bTDisplayMsgBoxOnHotkeyDismount; while (GetParent (hwndMainDlg) != NULL) { hwndMainDlg = GetParent (hwndMainDlg); } switch (msg) { case WM_INITDIALOG: { LVCOLUMNW col; bKeyScanOn = FALSE; nSelectedHotkeyId = -1; currentVKeyCode = 0; memcpy (tmpHotkeys, Hotkeys, sizeof(tmpHotkeys)); SendMessageW (hList,LVM_SETEXTENDEDLISTVIEWSTYLE,0, LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_LABELTIP ); memset (&col,0,sizeof(col)); col.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM|LVCF_FMT; col.pszText = GetString ("ACTION"); col.cx = CompensateXDPI (341); col.fmt = LVCFMT_LEFT; SendMessageW (hList,LVM_INSERTCOLUMNW,0,(LPARAM)&col); col.pszText = GetString ("SHORTCUT"); col.cx = CompensateXDPI (190); col.fmt = LVCFMT_LEFT; SendMessageW (hList,LVM_INSERTCOLUMNW,1,(LPARAM)&col); LocalizeDialog (hwndDlg, "IDD_HOTKEYS_DLG"); SetCheckBox (hwndDlg, IDC_HK_MOD_CTRL, TRUE); SetCheckBox (hwndDlg, IDC_HK_MOD_SHIFT, FALSE); SetCheckBox (hwndDlg, IDC_HK_MOD_ALT, TRUE); SetCheckBox (hwndDlg, IDC_HK_MOD_WIN, FALSE); SetCheckBox (hwndDlg, IDC_DISMOUNT_CONFIRM_PLAY_SOUND, bPlaySoundOnHotkeyMountDismount); SetCheckBox (hwndDlg, IDC_DISMOUNT_CONFIRM_MSG_BOX, bDisplayMsgBoxOnHotkeyDismount); bTPlaySoundOnHotkeyMountDismount = bPlaySoundOnHotkeyMountDismount; bTDisplayMsgBoxOnHotkeyDismount = bDisplayMsgBoxOnHotkeyDismount; EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_ASSIGN), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_REMOVE), FALSE); DisplayHotkeyList(hwndDlg); SetTimer (hwndDlg, 0xfe, 10, NULL); return 1; } case WM_TIMER: { if (nSelectedHotkeyId > -1) { wchar_t keyName [MAX_KEY_COMB_NAME_LEN]; UINT tmpVKeyCode; keyName[0] = 0; ScanAndProcessKey (&tmpVKeyCode, &keyName[0]); if (keyName[0] != 0) { currentVKeyCode = tmpVKeyCode; SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), keyName); EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_ASSIGN), TRUE); } } return 1; } case WM_COMMAND: case WM_NOTIFY: if (lw == IDC_HOTKEY_KEY && hw == EN_CHANGE) { if (!bKeyScanOn && nSelectedHotkeyId < 0 && GetWindowTextLengthW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY))) SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), L""); } if (msg == WM_NOTIFY && wParam == IDC_HOTKEY_LIST) { if (((LPNMHDR) lParam)->code == LVN_ITEMACTIVATE || ((LPNMHDR) lParam)->code == LVN_ITEMCHANGED && (((LPNMLISTVIEW) lParam)->uNewState & LVIS_FOCUSED)) { LVITEM item; memset(&item,0,sizeof(item)); nSelectedHotkeyId = ((LPNMLISTVIEW) lParam)->iItem; SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), GetString ("PRESS_A_KEY_TO_ASSIGN")); EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_REMOVE), (tmpHotkeys[nSelectedHotkeyId].vKeyCode > 0)); EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_ASSIGN), FALSE); bKeyScanOn = TRUE; return 1; } } if (lw == IDC_HOTKEY_ASSIGN) { BOOL bOwnActiveShortcut = FALSE; if (nSelectedHotkeyId >= 0 && currentVKeyCode != 0) { UINT modifiers = 0; if (GetCheckBox (hwndDlg, IDC_HK_MOD_CTRL)) modifiers = MOD_CONTROL; if (GetCheckBox (hwndDlg, IDC_HK_MOD_ALT)) modifiers |= MOD_ALT; if (GetCheckBox (hwndDlg, IDC_HK_MOD_SHIFT)) modifiers |= MOD_SHIFT; if (GetCheckBox (hwndDlg, IDC_HK_MOD_WIN)) modifiers |= MOD_WIN; // Check if it's not already assigned if (ShortcutInUse (currentVKeyCode, modifiers, tmpHotkeys)) { Error ("SHORTCUT_ALREADY_IN_USE"); return 1; } // Check for reserved system keys switch (currentVKeyCode) { case VK_F1: case VK_F12: /* F1 is help and F12 is reserved for use by the debugger at all times */ if (modifiers == 0) { Error ("CANNOT_USE_RESERVED_KEY"); return 1; } break; } bOwnActiveShortcut = ShortcutInUse (currentVKeyCode, modifiers, Hotkeys); // Test if the shortcut can be assigned without errors if (!bOwnActiveShortcut && !RegisterHotKey (hwndDlg, nSelectedHotkeyId, modifiers, currentVKeyCode)) { handleWin32Error(hwndDlg); return 1; } else { if (!bOwnActiveShortcut && !UnregisterHotKey (hwndDlg, nSelectedHotkeyId)) handleWin32Error(hwndDlg); tmpHotkeys[nSelectedHotkeyId].vKeyCode = currentVKeyCode; tmpHotkeys[nSelectedHotkeyId].vKeyModifiers = modifiers; SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), L""); EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_ASSIGN), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_REMOVE), FALSE); nSelectedHotkeyId = -1; bKeyScanOn = FALSE; } } DisplayHotkeyList(hwndDlg); return 1; } if (lw == IDC_HOTKEY_REMOVE) { if (nSelectedHotkeyId >= 0) { tmpHotkeys[nSelectedHotkeyId].vKeyCode = 0; tmpHotkeys[nSelectedHotkeyId].vKeyModifiers = 0; SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), L""); EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_ASSIGN), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_REMOVE), FALSE); nSelectedHotkeyId = -1; bKeyScanOn = FALSE; DisplayHotkeyList(hwndDlg); } return 1; } if (lw == IDC_RESET_HOTKEYS) { int i; for (i = 0; i < NBR_HOTKEYS; i++) { tmpHotkeys[i].vKeyCode = 0; tmpHotkeys[i].vKeyModifiers = 0; } SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), L""); EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_ASSIGN), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDC_HOTKEY_REMOVE), FALSE); nSelectedHotkeyId = -1; bKeyScanOn = FALSE; DisplayHotkeyList(hwndDlg); return 1; } if (lw == IDC_DISMOUNT_CONFIRM_PLAY_SOUND) { bTPlaySoundOnHotkeyMountDismount = GetCheckBox (hwndDlg, IDC_DISMOUNT_CONFIRM_PLAY_SOUND); } if (lw == IDC_DISMOUNT_CONFIRM_MSG_BOX) { bTDisplayMsgBoxOnHotkeyDismount = GetCheckBox (hwndDlg, IDC_DISMOUNT_CONFIRM_MSG_BOX); } if (lw == IDCANCEL || lw == IDCLOSE) { KillTimer (hwndDlg, 0xfe); EndDialog (hwndDlg, IDCANCEL); return 1; } if (lw == IDOK) { UnregisterAllHotkeys (hwndMainDlg, Hotkeys); memcpy (Hotkeys, tmpHotkeys, sizeof(Hotkeys)); RegisterAllHotkeys (hwndMainDlg, Hotkeys); KillTimer (hwndDlg, 0xfe); bPlaySoundOnHotkeyMountDismount = bTPlaySoundOnHotkeyMountDismount; bDisplayMsgBoxOnHotkeyDismount = bTDisplayMsgBoxOnHotkeyDismount; SaveSettings (hwndDlg); EndDialog (hwndDlg, IDCANCEL); return 1; } return 0; case WM_CLOSE: KillTimer (hwndDlg, 0xfe); EndDialog (hwndDlg, IDCANCEL); return 1; } return 0; }
/* * Hot keys. Some commands are relative to the item under the mouse cursor * Commands are case insensitive */ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem ) { if( aHotKey == 0 ) return false; wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); SCH_SCREEN* screen = GetScreen(); // itemInEdit == false means no item currently edited. We can ask for editing a new item bool itemInEdit = screen->GetCurItem() && screen->GetCurItem()->GetFlags(); // blocInProgress == false means no block in progress. // Because a drag command uses a drag block, false means also no drag in progress // If false, we can ask for editing a new item bool blocInProgress = screen->m_BlockLocate.GetState() != STATE_NO_BLOCK; // notBusy == true means no item currently edited and no other command in progress // We can change active tool and ask for editing a new item bool notBusy = (!itemInEdit) && (!blocInProgress); /* Convert lower to upper case (the usual toupper function has problem * with non ascii codes like function keys */ if( (aHotKey >= 'a') && (aHotKey <= 'z') ) aHotKey += 'A' - 'a'; // Search command from key : EDA_HOTKEY* hotKey = GetDescriptorFromHotkey( aHotKey, common_Hotkey_List ); if( hotKey == NULL ) hotKey = GetDescriptorFromHotkey( aHotKey, schematic_Hotkey_List ); if( hotKey == NULL ) return false; switch( hotKey->m_Idcommand ) { default: case HK_NOT_FOUND: return false; case HK_HELP: // Display Current hotkey list DisplayHotkeyList( this, g_Schematic_Hokeys_Descr ); break; case HK_RESET_LOCAL_COORD: // Reset the relative coord GetScreen()->m_O_Curseur = GetCrossHairPosition(); break; case HK_LEFT_CLICK: case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE ) { GetCanvas()->SetAutoPanRequest( false ); HandleBlockPlace( aDC ); } else if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK ) { OnLeftClick( aDC, aPosition ); if( hotKey->m_Idcommand == HK_LEFT_DCLICK ) OnLeftDClick( aDC, aPosition ); } break; case HK_ZOOM_IN: case HK_ZOOM_OUT: case HK_ZOOM_REDRAW: case HK_ZOOM_CENTER: case HK_ZOOM_AUTO: case HK_LEAVE_SHEET: case HK_DELETE_NODE: case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving case HK_SAVE_BLOCK: // Copy block to paste buffer. cmd.SetId( hotKey->m_IdMenuEvent ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_DELETE: if( notBusy ) DeleteItemAtCrossHair( aDC ); break; case HK_REPEAT_LAST: if( notBusy ) RepeatDrawItem( aDC ); break; case HK_END_CURR_LINEWIREBUS: // this key terminates a new line/bus/wire in progress if( aItem && aItem->IsNew() && aItem->Type() == SCH_LINE_T ) { cmd.SetId( hotKey->m_IdMenuEvent ); GetEventHandler()->ProcessEvent( cmd ); } break; case HK_UNDO: case HK_REDO: case HK_FIND_ITEM: case HK_FIND_REPLACE: if( notBusy ) { cmd.SetId( hotKey->m_IdMenuEvent ); GetEventHandler()->ProcessEvent( cmd ); } break; case HK_FIND_NEXT_ITEM: case HK_FIND_NEXT_DRC_MARKER: if( notBusy ) { wxFindDialogEvent event( hotKey->m_IdMenuEvent, GetId() ); event.SetEventObject( this ); event.SetFlags( m_findReplaceData->GetFlags() ); event.SetFindString( m_findReplaceData->GetFindString() ); GetEventHandler()->ProcessEvent( event ); } break; case HK_ADD_NEW_COMPONENT: // Add component case HK_ADD_NEW_POWER: // Add power component case HK_ADD_LABEL: case HK_ADD_HLABEL: case HK_ADD_GLABEL: case HK_ADD_JUNCTION: case HK_ADD_WIRE_ENTRY: case HK_ADD_BUS_ENTRY: case HK_ADD_HIER_SHEET: case HK_ADD_GRAPHIC_TEXT: case HK_ADD_GRAPHIC_POLYLINE: case HK_ADD_NOCONN_FLAG: // Add a no connected flag case HK_BEGIN_BUS: case HK_BEGIN_WIRE: if( notBusy ) { EDA_HOTKEY_CLIENT_DATA data( aPosition ); cmd.SetInt( aHotKey ); cmd.SetClientObject( &data ); cmd.SetId( hotKey->m_IdMenuEvent ); GetEventHandler()->ProcessEvent( cmd ); } else if( aItem && aItem->IsNew() ) { // If the item is a bus or a wire, a begin command is not possible. if( (GetToolId() == ID_BUS_BUTT) && (aItem->Type() == SCH_LINE_T) ) { SCH_LINE* segment = (SCH_LINE*) aItem; if( segment->GetLayer() != LAYER_BUS ) break; // Bus in progress: OnLeftClick( aDC, aPosition ); } else if( (GetToolId() == ID_WIRE_BUTT ) && (aItem->Type() == SCH_LINE_T) ) { SCH_LINE* segment = (SCH_LINE*) aItem; if( segment->GetLayer() != LAYER_WIRE ) break; // Wire in progress: OnLeftClick( aDC, aPosition ); } } break; case HK_COPY_COMPONENT_OR_LABEL: // Duplicate component or text/label if( itemInEdit ) break; if( aItem == NULL ) { aItem = LocateAndShowItem( aPosition, SCH_COLLECTOR::MovableItems ); if( aItem == NULL ) break; } cmd.SetId( hotKey->m_IdMenuEvent ); wxPostEvent( this, cmd ); break; case HK_DRAG: // Start drag case HK_MOVE_COMPONENT_OR_ITEM: // Start move schematic item. if( ! notBusy ) break; // Fall through case HK_EDIT: // Edit schematic item. Do not allow sheet edition when mowing // Because a sheet edition can be complex. if( itemInEdit && screen->GetCurItem()->Type() == SCH_SHEET_T ) break; // Fall through case HK_EDIT_COMPONENT_VALUE: // Edit component value field. case HK_EDIT_COMPONENT_REFERENCE: // Edit component value reference. case HK_EDIT_COMPONENT_FOOTPRINT: // Edit component footprint field. case HK_MIRROR_Y: // Mirror Y case HK_MIRROR_X: // Mirror X case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component) case HK_ROTATE: // Rotate schematic item. case HK_EDIT_COMPONENT_WITH_LIBEDIT: // Call Libedit and load the current component case HK_AUTOPLACE_FIELDS: // Autoplace all fields around component { // force a new item search on hot keys at current position, // if there is no currently edited item, // to avoid using a previously selected item if( ! itemInEdit ) screen->SetCurItem( NULL ); EDA_HOTKEY_CLIENT_DATA data( aPosition ); cmd.SetInt( hotKey->m_Idcommand ); cmd.SetClientObject( &data ); cmd.SetId( hotKey->m_IdMenuEvent ); GetEventHandler()->ProcessEvent( cmd ); } break; } // Hot key handled. return true; }
void FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem ) { if( aHotKey == 0 ) return; bool blockActive = GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE; BOARD_ITEM* item = GetCurItem(); bool ItemFree = (item == 0) || (item->GetFlags() == 0); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); /* Convert lower to upper case (the usual toupper function has problem with non ascii * codes like function keys */ if( (aHotKey >= 'a') && (aHotKey <= 'z') ) aHotKey += 'A' - 'a'; EDA_HOTKEY* HK_Descr = GetDescriptorFromHotkey( aHotKey, common_Hotkey_List ); if( HK_Descr == NULL ) HK_Descr = GetDescriptorFromHotkey( aHotKey, module_edit_Hotkey_List ); if( HK_Descr == NULL ) return; switch( HK_Descr->m_Idcommand ) { default: case HK_NOT_FOUND: return; break; case HK_HELP: // Display Current hotkey list DisplayHotkeyList( this, g_Module_Editor_Hokeys_Descr ); break; case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); break; case HK_SWITCH_UNITS: cmd.SetId( (g_UserUnit == INCHES) ? ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_IN: cmd.SetId( ID_POPUP_ZOOM_IN ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_OUT: cmd.SetId( ID_POPUP_ZOOM_OUT ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_REDRAW: cmd.SetId( ID_ZOOM_REDRAW ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_CENTER: cmd.SetId( ID_POPUP_ZOOM_CENTER ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_UNDO: case HK_REDO: if( ItemFree && !blockActive ) { wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent ); wxPostEvent( this, event ); } break; case HK_ZOOM_AUTO: cmd.SetId( ID_ZOOM_PAGE ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_EDIT_ITEM: OnHotkeyEditItem( HK_EDIT_ITEM ); break; case HK_DELETE: OnHotkeyDeleteItem( HK_DELETE ); break; case HK_MOVE_ITEM: OnHotkeyMoveItem( HK_MOVE_ITEM ); break; case HK_ROTATE_ITEM: OnHotkeyRotateItem( HK_ROTATE_ITEM ); break; } }
void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) { int id = event.GetId(); wxFileName fn; switch( id ) { case ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG: m_show_layer_manager_tools = ! m_show_layer_manager_tools; m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools ); m_auimgr.Update(); GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG, m_show_layer_manager_tools ? _("Hide &Layers Manager" ) : _("Show &Layers Manager" )); break; case ID_PCB_LAYERS_SETUP: InstallDialogLayerSetup(); break; case ID_CONFIG_REQ: InstallConfigFrame(); break; case ID_PCB_MASK_CLEARANCE: { DIALOG_PADS_MASK_CLEARANCE dlg( this ); dlg.ShowModal(); } break; case wxID_PREFERENCES: { Dialog_GeneralOptions dlg( this ); dlg.ShowModal(); } break; case ID_PCB_PAD_SETUP: InstallPadOptionsFrame( NULL ); break; case ID_CONFIG_SAVE: SaveProjectSettings(); break; case ID_CONFIG_READ: { fn = GetScreen()->GetFileName(); fn.SetExt( ProjectFileExtension ); wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), fn.GetFullName(), ProjectFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) break; if( !wxFileExists( dlg.GetPath() ) ) { wxString msg; msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); DisplayError( this, msg ); break; } LoadProjectSettings( dlg.GetPath() ); } break; // Hotkey IDs case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG: ExportHotkeyConfigToFile( g_Board_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG: ImportHotkeyConfigFromFile( g_Board_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_SHOW_EDITOR: InstallHotkeyFrame( this, g_Board_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display current hotkey list for Pcbnew. DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr ); break; // Macros IDs case ID_PREFRENCES_MACROS_SAVE: SaveMacros(); break; case ID_PREFRENCES_MACROS_READ: ReadMacros(); break; default: DisplayError( this, wxT( "PCB_EDIT_FRAME::Process_Config error" ) ); } }
void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) { int id = event.GetId(); wxFileName fn; switch( id ) { case ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG: m_show_layer_manager_tools = ! m_show_layer_manager_tools; m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools ); m_auimgr.Update(); GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG, m_show_layer_manager_tools ? _("Hide &Layers Manager" ) : _("Show &Layers Manager" )); break; case ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR: m_show_microwave_tools = ! m_show_microwave_tools; m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).Show( m_show_microwave_tools ); m_auimgr.Update(); GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR, m_show_microwave_tools ? _( "Hide Microwave Toolbar" ): _( "Show Microwave Toolbar" )); break; case ID_PCB_LAYERS_SETUP: if( InvokeLayerSetup( this, GetBoard() ) ) { LAYER_ID cur_layer = GetActiveLayer(); // If after showing the dialog the user has removed the active layer, // then select a new active layer (front copper layer). if( !GetBoard()->GetEnabledLayers()[ cur_layer ] ) cur_layer = F_Cu; SetActiveLayer( cur_layer ); OnModify(); ReCreateLayerBox(); ReFillLayerWidget(); if( IsGalCanvasActive() ) static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( GetBoard() ); } break; case ID_PCB_LIB_WIZARD: case ID_PCB_LIB_TABLE_EDIT: { bool tableChanged = false; int r = 0; if( id == ID_PCB_LIB_TABLE_EDIT ) r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() ); else r = InvokeFootprintWizard( this, &GFootprintTable, Prj().PcbFootprintLibs() ); if( r & 1 ) { try { FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() ); GFootprintTable.Format( &sf, 0 ); tableChanged = true; } catch( const IO_ERROR& ioe ) { wxString msg = wxString::Format( _( "Error occurred saving the global footprint library " "table:\n\n%s" ), GetChars( ioe.errorText.GetData() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } // If no board file is defined, do not save the project specific library table. It // is kept in memory and created in the path when the new board is saved. if( (r & 2) && !GetBoard()->GetFileName().IsEmpty() ) { wxString tblName = Prj().FootprintLibTblName(); try { Prj().PcbFootprintLibs()->Save( tblName ); tableChanged = true; } catch( const IO_ERROR& ioe ) { wxString msg = wxString::Format( _( "Error occurred saving project specific footprint library " "table:\n\n%s" ), GetChars( ioe.errorText ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } FOOTPRINT_VIEWER_FRAME* viewer; if( tableChanged && (viewer = (FOOTPRINT_VIEWER_FRAME*)Kiway().Player( FRAME_PCB_MODULE_VIEWER, false )) != NULL ) { viewer->ReCreateLibraryList(); } } break; case ID_PCB_MASK_CLEARANCE: { DIALOG_PADS_MASK_CLEARANCE dlg( this ); if( dlg.ShowModal() == 1 && IsGalCanvasActive() ) { for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() ) module->ViewUpdate(); GetGalCanvas()->Refresh(); } } break; case wxID_PREFERENCES: { DIALOG_GENERALOPTIONS dlg( this ); dlg.ShowModal(); } break; case ID_PCB_PAD_SETUP: InstallPadOptionsFrame( NULL ); break; case ID_CONFIG_SAVE: SaveProjectSettings( true ); break; case ID_CONFIG_READ: { fn = GetBoard()->GetFileName(); fn.SetExt( ProjectFileExtension ); wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), fn.GetFullName(), ProjectFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) break; if( !wxFileExists( dlg.GetPath() ) ) { wxString msg = wxString::Format( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); DisplayError( this, msg ); break; } wxString pro_file = dlg.GetPath(); Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters(), pro_file ); } break; // Hotkey IDs case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG: ExportHotkeyConfigToFile( g_Board_Editor_Hokeys_Descr, wxT( "pcbnew" ) ); break; case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG: ImportHotkeyConfigFromFile( g_Board_Editor_Hokeys_Descr, wxT( "pcbnew" ) ); break; case ID_PREFERENCES_HOTKEY_SHOW_EDITOR: InstallHotkeyFrame( this, g_Board_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display current hotkey list for Pcbnew. DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr ); break; // Macros IDs case ID_PREFRENCES_MACROS_SAVE: SaveMacros(); break; case ID_PREFRENCES_MACROS_READ: ReadMacros(); break; default: DisplayError( this, wxT( "PCB_EDIT_FRAME::Process_Config error" ) ); } }
bool PL_EDITOR_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem ) { bool busy = GetScreen()->GetCurItem() != NULL; wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); /* Convert lower to upper case (the usual toupper function has problem with non ascii * codes like function keys */ if( (aHotkeyCode >= 'a') && (aHotkeyCode <= 'z') ) aHotkeyCode += 'A' - 'a'; EDA_HOTKEY * HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, s_PlEditor_Hotkey_List ); if( HK_Descr == NULL ) HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, s_Common_Hotkey_List ); if( HK_Descr == NULL ) return false; WORKSHEET_DATAITEM* item; switch( HK_Descr->m_Idcommand ) { case HK_NOT_FOUND: return false; case HK_LEFT_CLICK: OnLeftClick( aDC, aPosition ); break; case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events OnLeftClick( aDC, aPosition ); OnLeftDClick( aDC, aPosition ); break; case HK_HELP: // Display Current hotkey list DisplayHotkeyList( this, s_PlEditor_Hokeys_Descr ); break; case HK_UNDO: case HK_REDO: if( busy ) break; cmd.SetId( HK_Descr->m_IdMenuEvent ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_IN: cmd.SetId( ID_POPUP_ZOOM_IN ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_OUT: cmd.SetId( ID_POPUP_ZOOM_OUT ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_REDRAW: cmd.SetId( ID_ZOOM_REDRAW ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_CENTER: cmd.SetId( ID_POPUP_ZOOM_CENTER ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_AUTO: cmd.SetId( ID_ZOOM_PAGE ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_RESET_LOCAL_COORD: // Reset the relative coord GetScreen()->m_O_Curseur = GetCrossHairPosition(); break; case HK_SET_GRID_ORIGIN: SetGridOrigin( GetCrossHairPosition() ); break; case HK_MOVE_ITEM: case HK_MOVE_START_POINT: case HK_MOVE_END_POINT: case HK_DELETE_ITEM: if( busy ) break; if( (item = Locate( aPosition )) == NULL ) break; // Only rect and lines have a end point. if( HK_Descr->m_Idcommand == HK_MOVE_END_POINT && !item->HasEndPoint() ) break; if( m_treePagelayout->GetPageLayoutSelectedItem() != item ) m_treePagelayout->SelectCell( item ); cmd.SetId( HK_Descr->m_IdMenuEvent ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_PLACE_ITEM: if( busy ) { cmd.SetId( HK_Descr->m_IdMenuEvent ); GetEventHandler()->ProcessEvent( cmd ); } break; default: wxMessageBox( wxT( "Unknown hotkey" ) ); return false; } return true; }
void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event ) { int id = event.GetId(); wxFileName fn; switch( id ) { case ID_CONFIG_SAVE: SaveProjectSettings( true ); break; case ID_CONFIG_READ: { fn = g_RootSheet->GetScreen()->GetFileName(); fn.SetExt( ProjectFileExtension ); wxFileDialog dlg( this, _( "Load Project File" ), fn.GetPath(), fn.GetFullName(), ProjectFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) break; wxString chosen = dlg.GetPath(); if( chosen == Prj().GetProjectFullName() ) LoadProjectFile(); else { // Read library list and library path list Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH, GetProjectFileParametersList() ); // Read schematic editor setup Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH_EDITOR, GetProjectFileParametersList() ); } } break; // Hotkey IDs case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG: ExportHotkeyConfigToFile( g_Eeschema_Hokeys_Descr, wxT( "eeschema" ) ); break; case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG: ImportHotkeyConfigFromFile( g_Eeschema_Hokeys_Descr, wxT( "eeschema" ) ); break; case ID_PREFERENCES_HOTKEY_SHOW_EDITOR: InstallHotkeyFrame( this, g_Eeschema_Hokeys_Descr, g_Schematic_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display current hotkey list for eeschema. DisplayHotkeyList( this, g_Schematic_Hokeys_Descr ); break; default: DisplayError( this, wxT( "SCH_EDIT_FRAME::Process_Config error" ) ); } }
bool LIB_VIEW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem ) { if( aHotKey == 0 ) return false; wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); /* Convert lower to upper case (the usual toupper function has problem with non ascii * codes like function keys */ if( (aHotKey >= 'a') && (aHotKey <= 'z') ) aHotKey += 'A' - 'a'; EDA_HOTKEY* HK_Descr = GetDescriptorFromHotkey( aHotKey, common_basic_Hotkey_List ); if( HK_Descr == NULL ) HK_Descr = GetDescriptorFromHotkey( aHotKey, viewlib_Hotkey_List ); if( HK_Descr == NULL ) return false; switch( HK_Descr->m_Idcommand ) { default: case HK_NOT_FOUND: return false; case HK_HELP: // Display Current hotkey list DisplayHotkeyList( this, g_Viewlib_Hokeys_Descr ); break; case HK_RESET_LOCAL_COORD: // set local (relative) coordinate origin GetScreen()->m_O_Curseur = GetCrossHairPosition(); break; case HK_LEFT_CLICK: OnLeftClick( aDC, aPosition ); break; case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events OnLeftClick( aDC, aPosition ); OnLeftDClick( aDC, aPosition ); break; case HK_ZOOM_IN: cmd.SetId( ID_POPUP_ZOOM_IN ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_OUT: cmd.SetId( ID_POPUP_ZOOM_OUT ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_REDRAW: cmd.SetId( ID_ZOOM_REDRAW ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_CENTER: cmd.SetId( ID_POPUP_ZOOM_CENTER ); GetEventHandler()->ProcessEvent( cmd ); break; case HK_ZOOM_AUTO: cmd.SetId( ID_ZOOM_PAGE ); GetEventHandler()->ProcessEvent( cmd ); break; } return true; }
void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event ) { int id = event.GetId(); switch( id ) { // Hotkey IDs case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG: ExportHotkeyConfigToFile( g_Module_Editor_Hokeys_Descr, wxT( "pcbnew" ) ); break; case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG: ImportHotkeyConfigFromFile( g_Module_Editor_Hokeys_Descr, wxT( "pcbnew" ) ); break; case ID_PREFERENCES_HOTKEY_SHOW_EDITOR: InstallHotkeyFrame( this, g_Module_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display current hotkey list for the footprint editor. DisplayHotkeyList( this, g_Module_Editor_Hokeys_Descr ); break; case ID_PCB_LIB_WIZARD: case ID_PCB_LIB_TABLE_EDIT: { bool tableChanged = false; int r = 0; if( id == ID_PCB_LIB_TABLE_EDIT ) r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() ); else r = InvokeFootprintWizard( this, &GFootprintTable, Prj().PcbFootprintLibs() ); if( r & 1 ) { try { FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() ); GFootprintTable.Format( &sf, 0 ); tableChanged = true; } catch( const IO_ERROR& ioe ) { wxString msg = wxString::Format( _( "Error occurred saving the global footprint library " "table:\n\n%s" ), GetChars( ioe.errorText.GetData() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } if( r & 2 ) { wxString tblName = Prj().FootprintLibTblName(); try { Prj().PcbFootprintLibs()->Save( tblName ); tableChanged = true; } catch( const IO_ERROR& ioe ) { wxString msg = wxString::Format( _( "Error occurred saving project specific footprint library " "table:\n\n%s" ), GetChars( ioe.errorText ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } FOOTPRINT_VIEWER_FRAME* viewer; viewer = (FOOTPRINT_VIEWER_FRAME*)Kiway().Player( FRAME_PCB_MODULE_VIEWER, false ); if( tableChanged && viewer != NULL ) viewer->ReCreateLibraryList(); } break; case wxID_PREFERENCES: InvokeFPEditorPrefsDlg( this ); break; default: DisplayError( this, wxT( "FOOTPRINT_EDIT_FRAME::ProcessPreferences error" ) ); } }