From 8b3d5a69cfdfba6894aac7b4753032aaef993e70 Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Sun, 27 Sep 2009 14:09:26 +0000 Subject: [PATCH] =?UTF-8?q?=C3=98yvind's=20patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/hotkeys_basic.cpp | 1 + common/zoom.cpp | 7 ++++++- cvpcb/displayframe.cpp | 17 ++++++++++++----- eeschema/hotkeys.cpp | 22 +++++++++++++++++++++- eeschema/hotkeys.h | 3 +++ eeschema/menubar.cpp | 6 ++++-- eeschema/tool_lib.cpp | 3 ++- eeschema/tool_sch.cpp | 3 ++- eeschema/tool_viewlib.cpp | 19 ++++++++++--------- eeschema/viewlib_frame.cpp | 3 ++- gerbview/hotkeys.cpp | 8 +++++++- gerbview/hotkeys.h | 1 + gerbview/tool_gerber.cpp | 3 ++- pcbnew/hotkeys.cpp | 15 +++++++++++++-- pcbnew/hotkeys.h | 1 + pcbnew/tool_modedit.cpp | 5 +++-- pcbnew/tool_pcb.cpp | 5 +++-- 17 files changed, 93 insertions(+), 29 deletions(-) diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index 97784aa6ef..cbc1ecd7ce 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -77,6 +77,7 @@ static struct hotkey_name_descr s_Hotkey_Name_List[] = { wxT( "Backspace" ), WXK_BACK }, { wxT( "Insert" ), WXK_INSERT }, + { wxT( "Home" ), WXK_HOME }, { wxT( "End" ), WXK_END }, { wxT( "Page Up" ), WXK_PAGEUP }, { wxT( "Page Down" ), WXK_PAGEDOWN }, diff --git a/common/zoom.cpp b/common/zoom.cpp index 1d0687a7c7..9c89c18d53 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -152,7 +152,12 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) break; case ID_ZOOM_PAGE: - Zoom_Automatique( false ); + // With Zoom_Automatique(), the "Zoom Auto" button (and hotkey) + // does nothing if the view is already at the correct + // zoom level, but needs to be shifted (centered). + //Zoom_Automatique( false ); + GetBaseScreen()->SetZoom( BestZoom() ); + Recadre_Trace( false ); break; case ID_POPUP_ZOOM_SELECT: diff --git a/cvpcb/displayframe.cpp b/cvpcb/displayframe.cpp index 720816ace7..96167ed853 100644 --- a/cvpcb/displayframe.cpp +++ b/cvpcb/displayframe.cpp @@ -132,24 +132,24 @@ void WinEDA_DisplayFrame::ReCreateHToolbar() m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, wxBitmap( zoom_in_xpm ), - _( "zoom + (F1)" ) ); + _( "Zoom in (F1)" ) ); m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, wxBitmap( zoom_out_xpm ), - _( "zoom - (F2)" ) ); + _( "Zoom out (F2)" ) ); m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, wxBitmap( zoom_redraw_xpm ), - _( "redraw (F3)" ) ); + _( "Redraw view (F3)" ) ); m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, wxBitmap( zoom_auto_xpm ), - _( "1:1 zoom" ) ); + _( "Zoom auto (Home)" ) ); m_HToolBar->AddSeparator(); m_HToolBar->AddTool( ID_CVPCB_SHOW3D_FRAME, wxEmptyString, wxBitmap( show_3d_xpm ), - _( "1:1 zoom" ) ); + _( "3D Display" ) ); // after adding the buttons to the toolbar, must call Realize() to reflect // the changes @@ -236,6 +236,13 @@ void WinEDA_DisplayFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) curpos = GetScreen()->m_Curseur; break; + case WXK_HOME: + cmd.SetId( ID_ZOOM_PAGE ); + GetEventHandler()->ProcessEvent( cmd ); + flagcurseur = 2; + curpos = GetScreen()->m_Curseur; + break; + case ' ': GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; break; diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index 3cf56bc627..b00c95439b 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -48,6 +48,8 @@ /* Hotkey list: */ // Common commands +static Ki_HotkeyInfo HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, + WXK_HOME ); static Ki_HotkeyInfo HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 ); static Ki_HotkeyInfo HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, @@ -107,7 +109,7 @@ Ki_HotkeyInfo* s_Common_Hotkey_List[] = { &HkHelp, &HkZoomIn, &HkZoomOut, &HkZoomRedraw, - &HkZoomCenter, + &HkZoomCenter, &HkZoomAuto, &HkResetLocalCoord, &HkUndo, &HkRedo, NULL @@ -164,6 +166,14 @@ struct Ki_HotkeyInfoSectionDescriptor s_Libedit_Hokeys_Descr[] = { NULL, NULL, NULL } }; +// list of sections and corresponding hotkey list for the component browser +// (used to list current hotkeys) +struct Ki_HotkeyInfoSectionDescriptor s_Viewlib_Hokeys_Descr[] = +{ + { &g_CommonSectionTag, s_Common_Hotkey_List, NULL }, + { NULL, NULL, NULL } +}; + /* * Hot keys. Some commands are relative to the item under the mouse cursor * Commands are case insensitive @@ -236,6 +246,11 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, GetEventHandler()->ProcessEvent( cmd ); break; + case HK_ZOOM_AUTO: + cmd.SetId( ID_ZOOM_PAGE ); + GetEventHandler()->ProcessEvent( cmd ); + break; + case HK_UNDO: case HK_REDO: if( !ItemInEdit ) @@ -517,6 +532,11 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, GetEventHandler()->ProcessEvent( cmd ); break; + case HK_ZOOM_AUTO: + cmd.SetId( ID_ZOOM_PAGE ); + GetEventHandler()->ProcessEvent( cmd ); + break; + case HK_UNDO: if( !ItemInEdit ) { diff --git a/eeschema/hotkeys.h b/eeschema/hotkeys.h index 68fb72983d..6ed392336c 100644 --- a/eeschema/hotkeys.h +++ b/eeschema/hotkeys.h @@ -14,6 +14,7 @@ enum hotkey_id_commnand { HK_ZOOM_OUT, HK_ZOOM_REDRAW, HK_ZOOM_CENTER, + HK_ZOOM_AUTO, HK_NEXT_SEARCH, HK_DELETE, HK_REPEAT_LAST, @@ -41,5 +42,7 @@ extern struct Ki_HotkeyInfoSectionDescriptor s_Eeschema_Hokeys_Descr[]; extern struct Ki_HotkeyInfoSectionDescriptor s_Schematic_Hokeys_Descr[]; // List of hotkey descriptors for the lib editor only extern struct Ki_HotkeyInfoSectionDescriptor s_Libedit_Hokeys_Descr[]; +// List of hotkey descriptors for the lib browser only +extern struct Ki_HotkeyInfoSectionDescriptor s_Viewlib_Hokeys_Descr[]; #endif // KOTKEYS_H diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index fa070e310b..c8e0c2b049 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -170,8 +170,10 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() item->SetBitmap( zoom_out_xpm ); viewMenu->Append( item ); - item = new wxMenuItem( viewMenu, ID_ZOOM_PAGE, _( "Zoom auto" ), - _( "Zoom auto" ), wxITEM_NORMAL ); + msg = AddHotkeyName( _( "Zoom auto" ), s_Schematic_Hokeys_Descr, + HK_ZOOM_AUTO ); + item = new wxMenuItem( viewMenu, ID_ZOOM_PAGE, msg, _( "Zoom auto" ), + wxITEM_NORMAL ); item->SetBitmap( zoom_auto_xpm ); viewMenu->Append( item ); diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp index 4771dc363b..7a6688e0df 100644 --- a/eeschema/tool_lib.cpp +++ b/eeschema/tool_lib.cpp @@ -169,8 +169,9 @@ void WinEDA_LibeditFrame::ReCreateHToolbar() m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, wxBitmap( zoom_redraw_xpm ), msg ); + msg = AddHotkeyName( _( "Zoom auto" ), s_Libedit_Hokeys_Descr, HK_ZOOM_AUTO ); m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, - wxBitmap( zoom_auto_xpm ), _( "Zoom page" ) ); + wxBitmap( zoom_auto_xpm ), msg ); m_HToolBar->AddSeparator(); m_HToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString, diff --git a/eeschema/tool_sch.cpp b/eeschema/tool_sch.cpp index 08dbbfc02a..24834e8de0 100644 --- a/eeschema/tool_sch.cpp +++ b/eeschema/tool_sch.cpp @@ -96,8 +96,9 @@ void WinEDA_SchematicFrame::ReCreateHToolbar() m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, wxBitmap( zoom_redraw_xpm ), msg ); + msg = AddHotkeyName( _( "Zoom auto" ), s_Schematic_Hokeys_Descr, HK_ZOOM_AUTO ); m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, wxBitmap( zoom_auto_xpm ), - _( "Zoom auto" ) ); + msg ); m_HToolBar->AddSeparator(); m_HToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, wxBitmap( find_xpm ), diff --git a/eeschema/tool_viewlib.cpp b/eeschema/tool_viewlib.cpp index 3aa7806288..f2eb4aa2ab 100644 --- a/eeschema/tool_viewlib.cpp +++ b/eeschema/tool_viewlib.cpp @@ -10,13 +10,14 @@ #include "program.h" #include "general.h" #include "protos.h" +#include "hotkeys.h" #include "class_library.h" #include "libviewfrm.h" void WinEDA_ViewlibFrame::ReCreateHToolbar() { - int ii; + int ii; wxString msg; CMP_LIBRARY* lib; LIB_COMPONENT* component = NULL; CMP_LIB_ENTRY* entry = NULL; @@ -47,21 +48,21 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar() _( "Display next part" ) ); m_HToolBar->AddSeparator(); + msg = AddHotkeyName( _( "Zoom in" ), s_Viewlib_Hokeys_Descr, HK_ZOOM_IN ); m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, - wxBitmap( zoom_in_xpm ), - _( "Zoom in" ) ); + wxBitmap( zoom_in_xpm ), msg ); + msg = AddHotkeyName( _( "Zoom out" ), s_Viewlib_Hokeys_Descr, HK_ZOOM_OUT ); m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, - wxBitmap( zoom_out_xpm ), - _( "Zoom out" ) ); + wxBitmap( zoom_out_xpm ), msg ); + msg = AddHotkeyName( _( "Redraw view" ), s_Viewlib_Hokeys_Descr, HK_ZOOM_REDRAW ); m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, - wxBitmap( zoom_redraw_xpm ), - _( "Redraw view" ) ); + wxBitmap( zoom_redraw_xpm ), msg ); + msg = AddHotkeyName( _( "Zoom auto" ), s_Viewlib_Hokeys_Descr, HK_ZOOM_AUTO ); m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, - wxBitmap( zoom_auto_xpm ), - _( "Best zoom" ) ); + wxBitmap( zoom_auto_xpm ), msg ); m_HToolBar->AddSeparator(); m_HToolBar->AddTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, wxEmptyString, diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 64f25c0f44..4740181b45 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -56,7 +56,8 @@ static wxAcceleratorEntry accels[] = wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F1, ID_ZOOM_IN ), wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F2, ID_ZOOM_OUT ), wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F3, ID_ZOOM_REDRAW ), - wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F4, ID_ZOOM_PAGE ) + wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F4, ID_POPUP_ZOOM_CENTER ), + wxAcceleratorEntry( wxACCEL_NORMAL, WXK_HOME, ID_ZOOM_PAGE ) }; #define ACCEL_TABLE_CNT ( sizeof( accels ) / sizeof( wxAcceleratorEntry ) ) diff --git a/gerbview/hotkeys.cpp b/gerbview/hotkeys.cpp index d057308b7e..2ab3540d2f 100644 --- a/gerbview/hotkeys.cpp +++ b/gerbview/hotkeys.cpp @@ -30,6 +30,7 @@ /* local variables */ /* Hotkey list: */ static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ), HK_RESET_LOCAL_COORD, ' ' ); +static Ki_HotkeyInfo HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME ); static Ki_HotkeyInfo HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 ); static Ki_HotkeyInfo HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 ); static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); @@ -51,7 +52,7 @@ static Ki_HotkeyInfo HkSwitch2PreviousCopperLayer( wxT( Ki_HotkeyInfo* s_Gerbview_Hotkey_List[] = { &HkHelp, &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, - &HkSwitchUnits, &HkResetLocalCoord, + &HkZoomAuto, &HkSwitchUnits, &HkResetLocalCoord, &HkTrackDisplayMode, &HkSwitch2NextCopperLayer, &HkSwitch2PreviousCopperLayer, @@ -123,6 +124,11 @@ void WinEDA_GerberFrame::OnHotKey( wxDC* DC, int hotkey, 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 = GetScreen()->m_Curseur; break; diff --git a/gerbview/hotkeys.h b/gerbview/hotkeys.h index 48e9598210..d36b403f56 100644 --- a/gerbview/hotkeys.h +++ b/gerbview/hotkeys.h @@ -16,6 +16,7 @@ enum hotkey_id_commnand { HK_ZOOM_OUT, HK_ZOOM_REDRAW, HK_ZOOM_CENTER, + HK_ZOOM_AUTO, HK_SWITCH_LAYER_TO_NEXT, HK_SWITCH_LAYER_TO_PREVIOUS }; diff --git a/gerbview/tool_gerber.cpp b/gerbview/tool_gerber.cpp index a8b08c2b27..c96ec1d6e8 100644 --- a/gerbview/tool_gerber.cpp +++ b/gerbview/tool_gerber.cpp @@ -226,9 +226,10 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) wxBitmap( zoom_redraw_xpm ), msg ); + msg = AddHotkeyName( _( "Zoom auto" ), s_Gerbview_Hokeys_Descr, HK_ZOOM_AUTO ); m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, wxBitmap( zoom_auto_xpm ), - _( "Zoom auto" ) ); + msg ); m_HToolBar->AddSeparator(); m_HToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index c70a2c1dcc..5861a60cc0 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -83,6 +83,7 @@ static Ki_HotkeyInfo HkDelete(wxT("Delete Track or Footprint"), HK_DELETE, WXK_DELETE); static Ki_HotkeyInfo HkResetLocalCoord(wxT("Reset local coord."), HK_RESET_LOCAL_COORD, ' '); +static Ki_HotkeyInfo HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME ); static Ki_HotkeyInfo HkZoomCenter(wxT("Zoom Center"), HK_ZOOM_CENTER, WXK_F4); static Ki_HotkeyInfo HkZoomRedraw(wxT("Zoom Redraw"), HK_ZOOM_REDRAW, WXK_F3); static Ki_HotkeyInfo HkZoomOut(wxT("Zoom Out"), HK_ZOOM_OUT, WXK_F2); @@ -99,8 +100,8 @@ static Ki_HotkeyInfo HkToggle(wxT("Toggle Present Command"), HK_TOGGLE, 'E'); // List of common hotkey descriptors Ki_HotkeyInfo * s_Common_Hotkey_List[] = { &HkHelp, &HkZoomIn, &HkZoomOut, - &HkZoomRedraw, &HkZoomCenter, &HkSwitchUnits, - &HkResetLocalCoord, NULL }; + &HkZoomRedraw, &HkZoomCenter, &HkZoomAuto, + &HkSwitchUnits, &HkResetLocalCoord, NULL }; // List of hotkey descriptors for pcbnew Ki_HotkeyInfo* s_board_edit_Hotkey_List[] = { &HkTrackDisplayMode, &HkDelete, @@ -280,6 +281,11 @@ void WinEDA_PcbFrame::OnHotKey(wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct) 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 = GetScreen()->m_Curseur; break; @@ -594,6 +600,11 @@ void WinEDA_ModuleEditFrame::OnHotKey(wxDC* DC, int hotkey, cmd.SetId(ID_POPUP_ZOOM_CENTER); GetEventHandler()->ProcessEvent(cmd); break; + + case HK_ZOOM_AUTO: + cmd.SetId(ID_ZOOM_PAGE); + GetEventHandler()->ProcessEvent(cmd); + break; } } diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h index b14bd05cbd..b45064ccda 100644 --- a/pcbnew/hotkeys.h +++ b/pcbnew/hotkeys.h @@ -14,6 +14,7 @@ enum hotkey_id_commnand { HK_ZOOM_OUT, HK_ZOOM_REDRAW, HK_ZOOM_CENTER, + HK_ZOOM_AUTO, HK_DELETE, HK_BACK_SPACE, HK_ROTATE_FOOTPRINT, diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp index 7aec9eb2df..7c6b4e83aa 100644 --- a/pcbnew/tool_modedit.cpp +++ b/pcbnew/tool_modedit.cpp @@ -118,9 +118,10 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar() m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, wxBitmap( zoom_redraw_xpm ), msg ); + msg = AddHotkeyName( _( "Zoom auto" ), s_Module_Editor_Hokeys_Descr, + HK_ZOOM_AUTO ); m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, - wxBitmap( zoom_auto_xpm ), - _( "Zoom auto" ) ); + wxBitmap( zoom_auto_xpm ), msg ); m_HToolBar->AddSeparator(); m_HToolBar->AddTool( ID_MODEDIT_PAD_SETTINGS, wxEmptyString, diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index eb31f475f9..ade8be7ae4 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -255,9 +255,10 @@ void WinEDA_PcbFrame::ReCreateHToolbar() m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, wxBitmap( zoom_redraw_xpm ), msg ); + msg = AddHotkeyName( _( "Zoom auto" ), s_Board_Editor_Hokeys_Descr, + HK_ZOOM_AUTO ); m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, - wxBitmap( zoom_auto_xpm ), - _( "Zoom auto" ) ); + wxBitmap( zoom_auto_xpm ), msg ); m_HToolBar->AddSeparator(); msg = AddHotkeyName( _( "Find components and texts" ),