From 25720516c9458ff7b6f4cc39cff4fef9a741f505 Mon Sep 17 00:00:00 2001 From: charras Date: Sun, 14 Feb 2010 18:14:33 +0000 Subject: [PATCH] Eeschema, libedit: fixed add/remove alias functions, broken All: added in popup menus hotkeys info for zoom commands --- common/base_screen.cpp | 2 + common/drawframe.cpp | 12 +++-- common/drawpanel.cpp | 2 +- common/hotkeys_basic.cpp | 33 +++++++----- common/zoom.cpp | 49 +++++++++-------- eeschema/class_libentry.cpp | 21 ++++++-- eeschema/class_libentry.h | 8 +-- eeschema/class_library.cpp | 85 +++++++++++++++++------------- eeschema/edit_component_in_lib.cpp | 19 ++----- eeschema/hierarch.cpp | 7 ++- eeschema/hotkeys.h | 15 ++---- eeschema/libframe.cpp | 2 + eeschema/schframe.cpp | 2 + eeschema/viewlib_frame.cpp | 2 + gerbview/gerberframe.cpp | 4 +- gerbview/hotkeys.h | 13 ++--- include/class_base_screen.h | 13 +++-- include/class_drawpanel.h | 1 - include/hotkeys_basic.h | 15 ++++++ include/wxstruct.h | 8 +++ pcbnew/hotkeys.h | 15 ++---- pcbnew/moduleframe.cpp | 2 + pcbnew/pcbframe.cpp | 2 + 23 files changed, 192 insertions(+), 140 deletions(-) diff --git a/common/base_screen.cpp b/common/base_screen.cpp index 2a87e1daf1..a373c175e0 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -38,6 +38,8 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType ) m_Center = true; m_CurrentSheetDesc = &g_Sheet_A4; m_IsPrinting = false; + m_ScrollPixelsPerUnitX = 1; + m_ScrollPixelsPerUnitY = 1; InitDatas(); } diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 312f507446..f392e51b19 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -54,6 +54,7 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, m_AuxiliaryToolBar = NULL; m_SelGridBox = NULL; m_SelZoomBox = NULL; + m_HotkeysZoomAndGridList = NULL; DrawPanel = NULL; MsgPanel = NULL; @@ -442,7 +443,7 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC ) void WinEDA_DrawFrame::AdjustScrollBars() { - int pixelsPerUnitX, pixelsPerUnitY, unitsX, unitsY, posX, posY; + int unitsX, unitsY, posX, posY; wxSize drawingSize, clientSize; BASE_SCREEN* screen = GetBaseScreen(); @@ -488,7 +489,7 @@ void WinEDA_DrawFrame::AdjustScrollBars() * pixels per unit to 10, you have potential for the zoom point to * jump around +/-5 pixels from the nearest grid point. */ - pixelsPerUnitX = pixelsPerUnitY = 1; + screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1; // Calculate the number of scroll bar units for the given zoom level. */ #ifdef USE_WX_ZOOM @@ -524,11 +525,12 @@ void WinEDA_DrawFrame::AdjustScrollBars() #if 0 wxLogDebug( wxT( "SetScrollbars(%d, %d, %d, %d, %d, %d)" ), - pixelsPerUnitX, pixelsPerUnitY, unitsX, unitsY, posX, posY ); + m_ScrollPixelsPerUnitX, m_ScrollPixelsPerUnitY, + unitsX, unitsY, posX, posY ); #endif - DrawPanel->SetScrollbars( pixelsPerUnitX, - pixelsPerUnitY, + DrawPanel->SetScrollbars( screen->m_ScrollPixelsPerUnitX, + screen->m_ScrollPixelsPerUnitY, screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.y, screen->m_ScrollbarPos.x, diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index f6d40f68b7..2fd96dec2a 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -958,7 +958,7 @@ bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event ) if( !m_Parent->OnRightClick( pos, &MasterMenu ) ) return false; - AddMenuZoom( &MasterMenu ); + m_Parent->AddMenuZoomAndGrid( &MasterMenu ); m_IgnoreMouseEvents = TRUE; PopupMenu( &MasterMenu, pos ); diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index 8a9561074a..f0f18a4f92 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -240,11 +240,13 @@ wxString ReturnKeyNameFromKeyCode( int keycode ) * @param CommandId = Command Id value * @return text (key name) in a wxString if found or text without modification */ -wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List, - int CommandId ) +wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList, + int aCommandId ) { - wxString msg = text; - wxString keyname = ReturnKeyNameFromCommandId( List, CommandId ); + wxString msg = aText; + wxString keyname; + if( aList ) + keyname = ReturnKeyNameFromCommandId( aList, aCommandId ); if( !keyname.IsEmpty() ) msg << wxT( "\t" ) << keyname; @@ -259,22 +261,25 @@ wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List, * @param CommandId = Command Id value * @return text (key name) in a wxString if found or text without modification */ -wxString AddHotkeyName( const wxString& text, - struct Ki_HotkeyInfoSectionDescriptor* DescList, - int CommandId ) +wxString AddHotkeyName( const wxString& aText, + struct Ki_HotkeyInfoSectionDescriptor* aDescList, + int aCommandId ) { - wxString msg = text; + wxString msg = aText; wxString keyname; Ki_HotkeyInfo** List; - for( ; DescList->m_HK_InfoList != NULL; DescList++ ) + if( aDescList ) { - List = DescList->m_HK_InfoList; - keyname = ReturnKeyNameFromCommandId( List, CommandId ); - if( !keyname.IsEmpty() ) + for( ; aDescList->m_HK_InfoList != NULL; aDescList++ ) { - msg << wxT( "\t" ) << keyname; - break; + List = aDescList->m_HK_InfoList; + keyname = ReturnKeyNameFromCommandId( List, aCommandId ); + if( !keyname.IsEmpty() ) + { + msg << wxT( "\t" ) << keyname; + break; + } } } diff --git a/common/zoom.cpp b/common/zoom.cpp index 6eafb8509a..d7e15842f2 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -15,6 +15,7 @@ #include "class_base_screen.h" #include "wxstruct.h" #include "kicad_device_context.h" +#include "hotkeys_basic.h" /** Compute draw offset (scroll bars and draw parameters) * in order to have the current graphic cursor position at the screen center @@ -174,7 +175,7 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) /* add the zoom list menu the the MasterMenu. * used in OnRightClick(wxMouseEvent& event) */ -void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) +void WinEDA_DrawFrame::AddMenuZoomAndGrid( wxMenu* MasterMenu ) { size_t i; int maxZoomIds; @@ -184,58 +185,62 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) GRID_TYPE tmp; wxMenu* gridMenu; double gridValue; + BASE_SCREEN * screen = DrawPanel->GetScreen(); + + msg = AddHotkeyName( _( "Center" ), m_HotkeysZoomAndGridList, HK_ZOOM_CENTER ); + ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_CENTER, msg, zoom_center_xpm ); + msg = AddHotkeyName( _( "Zoom in" ), m_HotkeysZoomAndGridList, HK_ZOOM_IN ); + ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_IN, msg, zoom_in_xpm ); + msg = AddHotkeyName( _( "Zoom out" ), m_HotkeysZoomAndGridList, HK_ZOOM_OUT ); + ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_OUT, msg, zoom_out_xpm ); + msg = AddHotkeyName( _( "Redraw view" ), m_HotkeysZoomAndGridList, HK_ZOOM_REDRAW ); + ADD_MENUITEM( MasterMenu, ID_ZOOM_REDRAW, msg, zoom_redraw_xpm ); + msg = AddHotkeyName( _( "Zoom auto" ), m_HotkeysZoomAndGridList, HK_ZOOM_AUTO ); + ADD_MENUITEM( MasterMenu, ID_ZOOM_PAGE, msg, zoom_auto_xpm ); - ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_CENTER, _( "Center" ), - zoom_center_xpm ); - ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_IN, _( "Zoom in" ), zoom_in_xpm ); - ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_OUT, _( "Zoom out" ), zoom_out_xpm ); - ADD_MENUITEM( MasterMenu, ID_ZOOM_PAGE, _( "Zoom auto" ), zoom_auto_xpm ); wxMenu* zoom_choice = new wxMenu; ADD_MENUITEM_WITH_SUBMENU( MasterMenu, zoom_choice, ID_POPUP_ZOOM_SELECT, _( "Zoom select" ), zoom_select_xpm ); - ADD_MENUITEM( MasterMenu, ID_ZOOM_REDRAW, _( "Redraw view" ), - zoom_redraw_xpm ); - - zoom = GetScreen()->GetZoom(); + zoom = screen->GetZoom(); maxZoomIds = ID_POPUP_ZOOM_LEVEL_END - ID_POPUP_ZOOM_LEVEL_START; - maxZoomIds = ( (size_t) maxZoomIds < GetScreen()->m_ZoomList.GetCount() ) ? - maxZoomIds : GetScreen()->m_ZoomList.GetCount(); + maxZoomIds = ( (size_t) maxZoomIds < screen->m_ZoomList.GetCount() ) ? + maxZoomIds : screen->m_ZoomList.GetCount(); /* Populate zoom submenu. */ for( i = 0; i < (size_t) maxZoomIds; i++ ) { - if( ( GetScreen()->m_ZoomList[i] % GetScreen()->m_ZoomScalar ) == 0 ) + if( ( screen->m_ZoomList[i] % screen->m_ZoomScalar ) == 0 ) msg.Printf( wxT( "%u" ), - GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar ); + screen->m_ZoomList[i] / screen->m_ZoomScalar ); else msg.Printf( wxT( "%.1f" ), - (float) GetScreen()->m_ZoomList[i] / - GetScreen()->m_ZoomScalar ); + (float) screen->m_ZoomList[i] / + screen->m_ZoomScalar ); zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg, wxEmptyString, wxITEM_CHECK ); - if( zoom == GetScreen()->m_ZoomList[i] ) + if( zoom == screen->m_ZoomList[i] ) zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true ); } /* Create grid submenu as required. */ - if( !GetScreen()->m_GridList.IsEmpty() ) + if( !screen->m_GridList.IsEmpty() ) { gridMenu = new wxMenu; ADD_MENUITEM_WITH_SUBMENU( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT, _( "Grid Select" ), grid_select_xpm ); - grid = GetScreen()->GetGridSize(); + grid = screen->GetGridSize(); - for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ ) + for( i = 0; i < screen->m_GridList.GetCount(); i++ ) { - tmp = GetScreen()->m_GridList[i]; + tmp = screen->m_GridList[i]; gridValue = To_User_Unit( g_UnitMetric, tmp.m_Size.x, - m_Parent->m_InternalUnits ); + m_InternalUnits ); if( tmp.m_Id == ID_POPUP_GRID_USER ) { diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 5aa16d2676..9083ca5738 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -19,9 +19,17 @@ #include -/*********************/ -/* class CMP_LIB_ENTRY */ -/*********************/ +/** class CMP_LIB_ENTRY + * Base class to describe library components and aliases. + * This class is not to be used directly. + * There are 2 derived classes + * class LIB_COMPONENT that describes a component in library + * class LIB_ALIAS that describes an alias of an existing component + * a LIB_COMPONENT object handle all info to draw a component + * (pins, graphic body items, fields, name, keywords and documentation) + * a LIB_ALIAS object use info of its LIB_COMPONENT parent + * and has just a name, keywords and documentation + */ CMP_LIB_ENTRY::CMP_LIB_ENTRY( LibrEntryType aType, const wxString& aName, CMP_LIBRARY* aLibrary ) : @@ -160,7 +168,12 @@ void LIB_ALIAS::SetComponent( LIB_COMPONENT* aComponent ) /* class LIB_COMPONENT */ /********************************/ -/* This is a standard component (in library) +/** + * Library component object definition. + * + * A library component object is typically saved and loaded + * in a component library file (.lib). + * Library components are different from schematic components. */ LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) : CMP_LIB_ENTRY( ROOT, aName, aLibrary ) diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 77fac08cec..ebf617ab78 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -134,9 +134,11 @@ extern int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY /** * Library component object definition. * - * A library component object is typically save and loaded in a component - * library file (.lib). Library components are different from schematic - * components. + * Library component object definition. + * + * A library component object is typically saved and loaded + * in a component library file (.lib). + * Library components are different from schematic components. */ class LIB_COMPONENT : public CMP_LIB_ENTRY { diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index f0d150e034..65e44773c5 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -221,6 +221,9 @@ bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias ) * so these alias will be added in library. * Conflicts can happen if aliases are already existing. * User is asked to choose what alias is removed (existing, or new) + * a special case is the library cache: + * user is not asked, and old aliases removed. + * this is not perfect, but sufficient to create a library cache project * @param aComponent - Component to add. * @return Added component if successful. */ @@ -235,41 +238,47 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) // Conflict detection: See if already existing aliases exist, // and if yes, ask user for continue or abort - wxString msg; - int conflict_count = 0; - for( size_t i = 0; i < newCmp->m_AliasList.GetCount(); i++ ) + // Special case: if the library is the library cache of the project, + // old aliases are always removed to avoid conflict, + // and user is not prompted ) + if( !IsCache() ) { - LIB_ALIAS* alias = FindAlias( newCmp->m_AliasList[ i ] ); - - if( alias == NULL ) - break; - - if( alias->GetComponent()->GetName().CmpNoCase( newCmp->GetName() ) != 0 ) + wxString msg; + int conflict_count = 0; + for( size_t i = 0; i < newCmp->m_AliasList.GetCount(); i++ ) { - wxString msg1; - msg1.Printf( _("alias <%s> already exists and has root name<%s>"), - GetChars( alias->GetName() ), - GetChars( alias->GetComponent()->GetName() ) ); - msg << msg1 << wxT("\n"); - conflict_count++; + LIB_ALIAS* alias = FindAlias( newCmp->m_AliasList[ i ] ); + + if( alias == NULL ) + continue; + + if( alias->GetComponent()->GetName().CmpNoCase( newCmp->GetName() ) != 0 ) + { + wxString msg1; + msg1.Printf( _("alias <%s> already exists and has root name<%s>"), + GetChars( alias->GetName() ), + GetChars( alias->GetComponent()->GetName() ) ); + msg << msg1 << wxT("\n"); + conflict_count++; + } + + if( conflict_count > 20 ) + break; } - if( conflict_count > 20 ) - break; - } - - if( conflict_count ) // Conflict: ask user what he wants remove all aliases or abort: - { - wxString title; - wxString msg1; - title.Printf( _( "Conflict in library <%s>"), GetChars( fileName.GetName())); - msg1.Printf( _("and appears in alias list of current component <%s>." ), - GetChars( newCmp->GetName() ) ); - msg << wxT("\n\n") << msg1; - msg << wxT("\n\n") << _("All old aliases will be removed. Continue ?"); - int diag = wxMessageBox(msg, title, wxYES | wxICON_QUESTION); - if( diag != wxYES ) - return NULL; + if( conflict_count ) // Conflict: ask user what he wants: remove all aliases or abort: + { + wxString title; + wxString msg1; + title.Printf( _( "Conflict in library <%s>"), GetChars( fileName.GetName())); + msg1.Printf( _("and appears in alias list of current component <%s>." ), + GetChars( newCmp->GetName() ) ); + msg << wxT("\n\n") << msg1; + msg << wxT("\n\n") << _("All old aliases will be removed. Continue ?"); + int diag = wxMessageBox(msg, title, wxYES | wxICON_QUESTION); + if( diag != wxYES ) + return NULL; + } } for( size_t i = 0; i < newCmp->m_AliasList.GetCount(); i++ ) @@ -301,7 +310,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) /** function RemoveEntryName * Remove an /a aName entry from the library list names. - * Warning: this is a partiel remove, because if aname is an alias + * Warning: this is a partiel remove, because if aName is an alias * it is not removed from its root component. * this is for internal use only * Use RemoveEntry( CMP_LIB_ENTRY* aEntry ) to remove safely an entry in library. @@ -349,9 +358,9 @@ void CMP_LIBRARY::RemoveEntryName( const wxString& aName ) root = alias->GetComponent(); /* Remove alias name from the root component alias list */ - if( root == NULL ) + if( root == NULL ) // Should not occur, but is not a fatal error { - wxLogWarning( wxT( "No root component found for alias <%s> in library <%s>." ), + wxLogDebug( wxT( "No root component found for alias <%s> in library <%s>." ), GetChars( aEntry->GetName() ), GetChars( fileName.GetName() ) ); } @@ -359,12 +368,14 @@ void CMP_LIBRARY::RemoveEntryName( const wxString& aName ) { int index = root->m_AliasList.Index( aEntry->GetName(), false ); - if( index == wxNOT_FOUND ) - wxLogWarning( wxT( "Alias <%s> not found in component <%s> alias list in \ + if( index == wxNOT_FOUND ) // Should not occur, but is not a fatal error + { + wxLogDebug( wxT( "Alias <%s> not found in component <%s> alias list in \ library <%s>" ), GetChars( aEntry->GetName() ), GetChars( root->GetName() ), GetChars( fileName.GetName() ) ); + } else root->m_AliasList.RemoveAt( index ); } @@ -458,7 +469,7 @@ LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent, } RemoveEntryName( aOldComponent->GetName() ); - entries.push_back( (CMP_LIB_ENTRY*) newCmp ); + entries.push_back( newCmp ); entries.sort(); SetModifyFlags( ); diff --git a/eeschema/edit_component_in_lib.cpp b/eeschema/edit_component_in_lib.cpp index 2133d50389..55e2309554 100644 --- a/eeschema/edit_component_in_lib.cpp +++ b/eeschema/edit_component_in_lib.cpp @@ -159,10 +159,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) if( m_PartAliasList->GetStrings() != component->m_AliasList ) { - LIB_ALIAS* alias; wxArrayString aliases = m_PartAliasList->GetStrings(); - /* Add names not existing in the old alias list. */ + /* Add names not existing in the current component alias list. */ for( i = 0; i < aliases.GetCount(); i++ ) { index = component->m_AliasList.Index( aliases[ i ], false ); @@ -170,16 +169,10 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) if( index != wxNOT_FOUND ) continue; - alias = new LIB_ALIAS( aliases[ i ], component ); - - if( !library->AddAlias( alias ) ) - { - delete alias; - alias = NULL; + component->m_AliasList.Add( aliases[ i ] ); } - } - /* Remove names and library alias entries not in the new alias list. */ + /* Remove names in the current component that are not in the new alias list. */ for( i = 0; i < component->m_AliasList.GetCount(); i++ ) { index = aliases.Index( component->m_AliasList[ i ], false ); @@ -187,10 +180,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) if( index == wxNOT_FOUND ) continue; - CMP_LIB_ENTRY* alias = - library->FindAlias( component->m_AliasList[ i ] ); - if( alias != NULL ) - library->RemoveEntry( alias ); + component->m_AliasList.RemoveAt( i ); + i--; } component->m_AliasList = aliases; diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index 4bbc546f98..f90bcaf201 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -308,14 +308,13 @@ static bool UpdateScreenFromSheet( WinEDA_SchematicFrame* frame ) // Reset display settings of the new screen // Assumes m_CurrentSheet has already been updated. frame->ClearMsgPanel(); - int pixelsPerUnitX = 1; - int pixelsPerUnitY = 1; - frame->DrawPanel->SetScrollbars( pixelsPerUnitX, pixelsPerUnitY, + frame->DrawPanel->SetScrollbars( NewScreen->m_ScrollPixelsPerUnitX, + NewScreen->m_ScrollPixelsPerUnitY, NewScreen->m_ScrollbarNumber.x, NewScreen->m_ScrollbarNumber.y, NewScreen->m_ScrollbarPos.x, NewScreen->m_ScrollbarPos.y, TRUE ); - + // update the References frame->m_CurrentSheet->UpdateAllScreenReferences(); frame->SetSheetNumberAndCount(); diff --git a/eeschema/hotkeys.h b/eeschema/hotkeys.h index 54471afa98..0a77d84d40 100644 --- a/eeschema/hotkeys.h +++ b/eeschema/hotkeys.h @@ -6,24 +6,17 @@ #include "hotkeys_basic.h" +// List of hot keys id. +// see also enum common_hotkey_id_commnand in hotkeys_basic.h +// for shared hotkeys id enum hotkey_id_commnand { - HK_NOT_FOUND = 0, - HK_RESET_LOCAL_COORD, - HK_HELP, - HK_ZOOM_IN, - HK_ZOOM_OUT, - HK_ZOOM_REDRAW, - HK_ZOOM_CENTER, - HK_ZOOM_AUTO, - HK_NEXT_SEARCH, + HK_NEXT_SEARCH = HK_COMMON_END, HK_DELETE, HK_REPEAT_LAST, HK_EDIT_PIN, HK_LIBEDIT_MOVE_GRAPHIC_ITEM, HK_LIBEDIT_ROTATE_PIN, HK_DELETE_PIN, - HK_UNDO, - HK_REDO, HK_MOVEBLOCK_TO_DRAGBLOCK, HK_ROTATE, HK_EDIT, diff --git a/eeschema/libframe.cpp b/eeschema/libframe.cpp index 846d65091a..f3ffcba1d4 100644 --- a/eeschema/libframe.cpp +++ b/eeschema/libframe.cpp @@ -18,6 +18,7 @@ #include "class_library.h" #include "kicad_device_context.h" +#include "hotkeys.h" #include @@ -167,6 +168,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father, SetShowDeMorgan( false ); m_drawSpecificConvert = true; m_drawSpecificUnit = false; + m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr; // Give an icon SetIcon( wxIcon( libedit_xpm ) ); diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index cfa3358000..c86d5bdd92 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -27,6 +27,7 @@ #include "dialog_erc.h" #include "libeditfrm.h" #include "libviewfrm.h" +#include "hotkeys.h" BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame ) @@ -160,6 +161,7 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father, m_previewSize = wxDefaultSize; m_printMonochrome = true; m_showSheetReference = true; + m_HotkeysZoomAndGridList = s_Schematic_Hokeys_Descr; CreateScreens(); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 9a87b431d8..2e5eb023d5 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -14,6 +14,7 @@ #include "protos.h" #include "libviewfrm.h" #include "class_library.h" +#include "hotkeys.h" /** @@ -92,6 +93,7 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father, // Give an icon SetIcon( wxIcon( library_browse_xpm ) ); + m_HotkeysZoomAndGridList = s_Viewlib_Hokeys_Descr; m_CmpList = NULL; m_LibList = NULL; m_LibListWindow = NULL; diff --git a/gerbview/gerberframe.cpp b/gerbview/gerberframe.cpp index ba11401f7e..8dfc625275 100644 --- a/gerbview/gerberframe.cpp +++ b/gerbview/gerberframe.cpp @@ -17,6 +17,7 @@ #include "bitmaps.h" #include "protos.h" #include "gerbview_id.h" +#include "hotkeys.h" /****************************************/ @@ -128,6 +129,7 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, m_Draw_Axis = true; // true to show X and Y axis on screen m_Draw_Sheet_Ref = FALSE; // TRUE for reference drawings. + m_HotkeysZoomAndGridList = s_Gerbview_Hokeys_Descr; if( DrawPanel ) DrawPanel->m_Block_Enable = TRUE; @@ -415,7 +417,7 @@ void WinEDA_GerberFrame::ReFillLayerWidget() m_auimgr.Update(); else m_LayersManager->SetSize( bestz ); - + syncLayerWidget( ); } diff --git a/gerbview/hotkeys.h b/gerbview/hotkeys.h index d36b403f56..2b408162a8 100644 --- a/gerbview/hotkeys.h +++ b/gerbview/hotkeys.h @@ -6,17 +6,12 @@ #include "hotkeys_basic.h" +// List of hot keys id. +// see also enum common_hotkey_id_commnand in hotkeys_basic.h +// for shared hotkeys id enum hotkey_id_commnand { - HK_NOT_FOUND = 0, - HK_RESET_LOCAL_COORD, - HK_HELP, - HK_SWITCH_UNITS, + HK_SWITCH_UNITS = HK_COMMON_END, HK_SWITCH_TRACK_DISPLAY_MODE, - HK_ZOOM_IN, - 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/include/class_base_screen.h b/include/class_base_screen.h index 6b1ad59741..ac98328e99 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -66,9 +66,16 @@ public: wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) * in user units. * (coordinates from last reset position)*/ - wxPoint m_ScrollbarPos; // Position effective des Curseurs de scroll - wxSize m_ScrollbarNumber; /* Current scroll bar posiition in scroll - * units. */ + // Scrollbars management: + int m_ScrollPixelsPerUnitX; /* Pixels per scroll unit in the horizontal direction. */ + int m_ScrollPixelsPerUnitY; /* Pixels per scroll unit in the vertical direction. */ + wxSize m_ScrollbarNumber; /* Current virtual draw area size in scroll + * units. + * m_ScrollbarNumber * m_ScrollPixelsPerUnit = virtual draw area size in pixels + */ + wxPoint m_ScrollbarPos; /* Current scroll bar position in scroll + * units. */ + wxPoint m_StartVisu; /* Coordinates in drawing units of the current * view position (upper left corner of device) */ diff --git a/include/class_drawpanel.h b/include/class_drawpanel.h index 6ffb33a145..b54cf5ea69 100644 --- a/include/class_drawpanel.h +++ b/include/class_drawpanel.h @@ -159,7 +159,6 @@ public: void SetGrid( const wxRealPoint& size ); wxRealPoint GetGrid(); - void AddMenuZoom( wxMenu* MasterMenu ); bool OnRightClick( wxMouseEvent& event ); void Process_Special_Functions( wxCommandEvent& event ); diff --git a/include/hotkeys_basic.h b/include/hotkeys_basic.h index d06b8c3c15..cadecbc2e9 100644 --- a/include/hotkeys_basic.h +++ b/include/hotkeys_basic.h @@ -75,4 +75,19 @@ void DisplayHotkeyList( WinEDA_DrawFrame* frame, Ki_HotkeyInfo* GetDescriptorFromHotkey( int key, Ki_HotkeyInfo** List ); +// common hotkeys event id +enum common_hotkey_id_commnand { + HK_NOT_FOUND = 0, + HK_RESET_LOCAL_COORD, + HK_HELP, + HK_ZOOM_IN, + HK_ZOOM_OUT, + HK_ZOOM_REDRAW, + HK_ZOOM_CENTER, + HK_ZOOM_AUTO, + HK_UNDO, + HK_REDO, + HK_COMMON_END +}; + #endif // HOTKEYS_BASIC_H diff --git a/include/wxstruct.h b/include/wxstruct.h index 580de3d8da..48c93523c5 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -183,6 +183,7 @@ public: wxPoint m_Auxiliary_Axis_Position; /* position of the auxiliary axis */ protected: + Ki_HotkeyInfoSectionDescriptor * m_HotkeysZoomAndGridList; int m_LastGridSizeId; bool m_DrawGrid; // hide/Show grid int m_GridColor; // Grid color @@ -218,6 +219,13 @@ public: virtual void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct ); + /** Function AddMenuZoomAndGrid (virtual) + * Add standard zoom commands and submenu zoom and grid selection to a popup menu + * uses zoom hotkeys info base to add hotkeys info to menu commands + * @param aMasterMenu = the menu to populate. + */ + virtual void AddMenuZoomAndGrid( wxMenu* aMasterMenu ); + void Affiche_Message( const wxString& message ); void EraseMsgBox(); void Process_PageSettings( wxCommandEvent& event ); diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h index 666edfa642..fbf6878ce0 100644 --- a/pcbnew/hotkeys.h +++ b/pcbnew/hotkeys.h @@ -7,18 +7,11 @@ #include "hotkeys_basic.h" +// List of hot keys id. +// see also enum common_hotkey_id_commnand in hotkeys_basic.h +// for shared hotkeys id enum hotkey_id_commnand { - HK_NOT_FOUND = 0, - HK_RESET_LOCAL_COORD, - HK_HELP, - HK_ZOOM_IN, - HK_ZOOM_OUT, - HK_ZOOM_REDRAW, - HK_ZOOM_CENTER, - HK_ZOOM_AUTO, - HK_UNDO, - HK_REDO, - HK_DELETE, + HK_DELETE = HK_COMMON_END, HK_BACK_SPACE, HK_ROTATE_FOOTPRINT, HK_MOVE_FOOTPRINT, diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 09c9d523ec..d5bc9d9f0c 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -16,6 +16,7 @@ #include "bitmaps.h" #include "protos.h" #include "pcbnew_id.h" +#include "hotkeys.h" #include "3d_viewer.h" @@ -156,6 +157,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, m_FrameName = wxT( "ModEditFrame" ); m_Draw_Sheet_Ref = false; // true to show the frame references m_Draw_Axis = true; // true to show X and Y axis on screen + m_HotkeysZoomAndGridList = s_Module_Editor_Hokeys_Descr; // Give an icon SetIcon( wxICON( icon_modedit ) ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index a263c61560..5f167d27f6 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -46,6 +46,7 @@ #include "layer_widget.h" #include "dialog_design_rules.h" #include "class_pcb_layer_widget.h" +#include "hotkeys.h" @@ -258,6 +259,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, m_TrackAndViasSizesList_Changed = false; m_show_microwave_tools = false; m_show_layer_manager_tools = true; + m_HotkeysZoomAndGridList = s_Board_Editor_Hokeys_Descr; SetBoard( new BOARD( NULL, this ) );