Commit 25720516 authored by charras's avatar charras

Eeschema, libedit: fixed add/remove alias functions, broken

All: added in popup menus hotkeys info for zoom commands
parent 3624034f
...@@ -38,6 +38,8 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType ) ...@@ -38,6 +38,8 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType )
m_Center = true; m_Center = true;
m_CurrentSheetDesc = &g_Sheet_A4; m_CurrentSheetDesc = &g_Sheet_A4;
m_IsPrinting = false; m_IsPrinting = false;
m_ScrollPixelsPerUnitX = 1;
m_ScrollPixelsPerUnitY = 1;
InitDatas(); InitDatas();
} }
......
...@@ -54,6 +54,7 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, ...@@ -54,6 +54,7 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
m_AuxiliaryToolBar = NULL; m_AuxiliaryToolBar = NULL;
m_SelGridBox = NULL; m_SelGridBox = NULL;
m_SelZoomBox = NULL; m_SelZoomBox = NULL;
m_HotkeysZoomAndGridList = NULL;
DrawPanel = NULL; DrawPanel = NULL;
MsgPanel = NULL; MsgPanel = NULL;
...@@ -442,7 +443,7 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC ) ...@@ -442,7 +443,7 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_DrawFrame::AdjustScrollBars() void WinEDA_DrawFrame::AdjustScrollBars()
{ {
int pixelsPerUnitX, pixelsPerUnitY, unitsX, unitsY, posX, posY; int unitsX, unitsY, posX, posY;
wxSize drawingSize, clientSize; wxSize drawingSize, clientSize;
BASE_SCREEN* screen = GetBaseScreen(); BASE_SCREEN* screen = GetBaseScreen();
...@@ -488,7 +489,7 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -488,7 +489,7 @@ void WinEDA_DrawFrame::AdjustScrollBars()
* pixels per unit to 10, you have potential for the zoom point to * pixels per unit to 10, you have potential for the zoom point to
* jump around +/-5 pixels from the nearest grid point. * 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. */ // Calculate the number of scroll bar units for the given zoom level. */
#ifdef USE_WX_ZOOM #ifdef USE_WX_ZOOM
...@@ -524,11 +525,12 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -524,11 +525,12 @@ void WinEDA_DrawFrame::AdjustScrollBars()
#if 0 #if 0
wxLogDebug( wxT( "SetScrollbars(%d, %d, %d, %d, %d, %d)" ), wxLogDebug( wxT( "SetScrollbars(%d, %d, %d, %d, %d, %d)" ),
pixelsPerUnitX, pixelsPerUnitY, unitsX, unitsY, posX, posY ); m_ScrollPixelsPerUnitX, m_ScrollPixelsPerUnitY,
unitsX, unitsY, posX, posY );
#endif #endif
DrawPanel->SetScrollbars( pixelsPerUnitX, DrawPanel->SetScrollbars( screen->m_ScrollPixelsPerUnitX,
pixelsPerUnitY, screen->m_ScrollPixelsPerUnitY,
screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.x,
screen->m_ScrollbarNumber.y, screen->m_ScrollbarNumber.y,
screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.x,
......
...@@ -958,7 +958,7 @@ bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event ) ...@@ -958,7 +958,7 @@ bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event )
if( !m_Parent->OnRightClick( pos, &MasterMenu ) ) if( !m_Parent->OnRightClick( pos, &MasterMenu ) )
return false; return false;
AddMenuZoom( &MasterMenu ); m_Parent->AddMenuZoomAndGrid( &MasterMenu );
m_IgnoreMouseEvents = TRUE; m_IgnoreMouseEvents = TRUE;
PopupMenu( &MasterMenu, pos ); PopupMenu( &MasterMenu, pos );
......
...@@ -240,11 +240,13 @@ wxString ReturnKeyNameFromKeyCode( int keycode ) ...@@ -240,11 +240,13 @@ wxString ReturnKeyNameFromKeyCode( int keycode )
* @param CommandId = Command Id value * @param CommandId = Command Id value
* @return text (key name) in a wxString if found or text without modification * @return text (key name) in a wxString if found or text without modification
*/ */
wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List, wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList,
int CommandId ) int aCommandId )
{ {
wxString msg = text; wxString msg = aText;
wxString keyname = ReturnKeyNameFromCommandId( List, CommandId ); wxString keyname;
if( aList )
keyname = ReturnKeyNameFromCommandId( aList, aCommandId );
if( !keyname.IsEmpty() ) if( !keyname.IsEmpty() )
msg << wxT( "\t" ) << keyname; msg << wxT( "\t" ) << keyname;
...@@ -259,24 +261,27 @@ wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List, ...@@ -259,24 +261,27 @@ wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List,
* @param CommandId = Command Id value * @param CommandId = Command Id value
* @return text (key name) in a wxString if found or text without modification * @return text (key name) in a wxString if found or text without modification
*/ */
wxString AddHotkeyName( const wxString& text, wxString AddHotkeyName( const wxString& aText,
struct Ki_HotkeyInfoSectionDescriptor* DescList, struct Ki_HotkeyInfoSectionDescriptor* aDescList,
int CommandId ) int aCommandId )
{ {
wxString msg = text; wxString msg = aText;
wxString keyname; wxString keyname;
Ki_HotkeyInfo** List; Ki_HotkeyInfo** List;
for( ; DescList->m_HK_InfoList != NULL; DescList++ ) if( aDescList )
{ {
List = DescList->m_HK_InfoList; for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
keyname = ReturnKeyNameFromCommandId( List, CommandId ); {
List = aDescList->m_HK_InfoList;
keyname = ReturnKeyNameFromCommandId( List, aCommandId );
if( !keyname.IsEmpty() ) if( !keyname.IsEmpty() )
{ {
msg << wxT( "\t" ) << keyname; msg << wxT( "\t" ) << keyname;
break; break;
} }
} }
}
return msg; return msg;
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "class_base_screen.h" #include "class_base_screen.h"
#include "wxstruct.h" #include "wxstruct.h"
#include "kicad_device_context.h" #include "kicad_device_context.h"
#include "hotkeys_basic.h"
/** Compute draw offset (scroll bars and draw parameters) /** Compute draw offset (scroll bars and draw parameters)
* in order to have the current graphic cursor position at the screen center * in order to have the current graphic cursor position at the screen center
...@@ -174,7 +175,7 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) ...@@ -174,7 +175,7 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
/* add the zoom list menu the the MasterMenu. /* add the zoom list menu the the MasterMenu.
* used in OnRightClick(wxMouseEvent& event) * used in OnRightClick(wxMouseEvent& event)
*/ */
void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) void WinEDA_DrawFrame::AddMenuZoomAndGrid( wxMenu* MasterMenu )
{ {
size_t i; size_t i;
int maxZoomIds; int maxZoomIds;
...@@ -184,58 +185,62 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) ...@@ -184,58 +185,62 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
GRID_TYPE tmp; GRID_TYPE tmp;
wxMenu* gridMenu; wxMenu* gridMenu;
double gridValue; 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; wxMenu* zoom_choice = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( MasterMenu, zoom_choice, ADD_MENUITEM_WITH_SUBMENU( MasterMenu, zoom_choice,
ID_POPUP_ZOOM_SELECT, _( "Zoom select" ), ID_POPUP_ZOOM_SELECT, _( "Zoom select" ),
zoom_select_xpm ); zoom_select_xpm );
ADD_MENUITEM( MasterMenu, ID_ZOOM_REDRAW, _( "Redraw view" ), zoom = screen->GetZoom();
zoom_redraw_xpm );
zoom = GetScreen()->GetZoom();
maxZoomIds = ID_POPUP_ZOOM_LEVEL_END - ID_POPUP_ZOOM_LEVEL_START; maxZoomIds = ID_POPUP_ZOOM_LEVEL_END - ID_POPUP_ZOOM_LEVEL_START;
maxZoomIds = ( (size_t) maxZoomIds < GetScreen()->m_ZoomList.GetCount() ) ? maxZoomIds = ( (size_t) maxZoomIds < screen->m_ZoomList.GetCount() ) ?
maxZoomIds : GetScreen()->m_ZoomList.GetCount(); maxZoomIds : screen->m_ZoomList.GetCount();
/* Populate zoom submenu. */ /* Populate zoom submenu. */
for( i = 0; i < (size_t) maxZoomIds; i++ ) 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" ), msg.Printf( wxT( "%u" ),
GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar ); screen->m_ZoomList[i] / screen->m_ZoomScalar );
else else
msg.Printf( wxT( "%.1f" ), msg.Printf( wxT( "%.1f" ),
(float) GetScreen()->m_ZoomList[i] / (float) screen->m_ZoomList[i] /
GetScreen()->m_ZoomScalar ); screen->m_ZoomScalar );
zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg, zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg,
wxEmptyString, wxITEM_CHECK ); 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 ); zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true );
} }
/* Create grid submenu as required. */ /* Create grid submenu as required. */
if( !GetScreen()->m_GridList.IsEmpty() ) if( !screen->m_GridList.IsEmpty() )
{ {
gridMenu = new wxMenu; gridMenu = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( MasterMenu, gridMenu, ADD_MENUITEM_WITH_SUBMENU( MasterMenu, gridMenu,
ID_POPUP_GRID_SELECT, _( "Grid Select" ), ID_POPUP_GRID_SELECT, _( "Grid Select" ),
grid_select_xpm ); 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, gridValue = To_User_Unit( g_UnitMetric, tmp.m_Size.x,
m_Parent->m_InternalUnits ); m_InternalUnits );
if( tmp.m_Id == ID_POPUP_GRID_USER ) if( tmp.m_Id == ID_POPUP_GRID_USER )
{ {
......
...@@ -19,9 +19,17 @@ ...@@ -19,9 +19,17 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
/*********************/ /** 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_LIB_ENTRY::CMP_LIB_ENTRY( LibrEntryType aType, const wxString& aName,
CMP_LIBRARY* aLibrary ) : CMP_LIBRARY* aLibrary ) :
...@@ -160,7 +168,12 @@ void LIB_ALIAS::SetComponent( LIB_COMPONENT* aComponent ) ...@@ -160,7 +168,12 @@ void LIB_ALIAS::SetComponent( LIB_COMPONENT* aComponent )
/* class LIB_COMPONENT */ /* 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 ) : LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) :
CMP_LIB_ENTRY( ROOT, aName, aLibrary ) CMP_LIB_ENTRY( ROOT, aName, aLibrary )
......
...@@ -134,9 +134,11 @@ extern int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY ...@@ -134,9 +134,11 @@ extern int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY
/** /**
* Library component object definition. * Library component object definition.
* *
* A library component object is typically save and loaded in a component * Library component object definition.
* library file (.lib). Library components are different from schematic *
* components. * 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 class LIB_COMPONENT : public CMP_LIB_ENTRY
{ {
......
...@@ -221,6 +221,9 @@ bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias ) ...@@ -221,6 +221,9 @@ bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias )
* so these alias will be added in library. * so these alias will be added in library.
* Conflicts can happen if aliases are already existing. * Conflicts can happen if aliases are already existing.
* User is asked to choose what alias is removed (existing, or new) * 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. * @param aComponent - Component to add.
* @return Added component if successful. * @return Added component if successful.
*/ */
...@@ -235,6 +238,11 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) ...@@ -235,6 +238,11 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
// Conflict detection: See if already existing aliases exist, // Conflict detection: See if already existing aliases exist,
// and if yes, ask user for continue or abort // and if yes, ask user for continue or abort
// 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() )
{
wxString msg; wxString msg;
int conflict_count = 0; int conflict_count = 0;
for( size_t i = 0; i < newCmp->m_AliasList.GetCount(); i++ ) for( size_t i = 0; i < newCmp->m_AliasList.GetCount(); i++ )
...@@ -242,7 +250,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) ...@@ -242,7 +250,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
LIB_ALIAS* alias = FindAlias( newCmp->m_AliasList[ i ] ); LIB_ALIAS* alias = FindAlias( newCmp->m_AliasList[ i ] );
if( alias == NULL ) if( alias == NULL )
break; continue;
if( alias->GetComponent()->GetName().CmpNoCase( newCmp->GetName() ) != 0 ) if( alias->GetComponent()->GetName().CmpNoCase( newCmp->GetName() ) != 0 )
{ {
...@@ -258,7 +266,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) ...@@ -258,7 +266,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
break; break;
} }
if( conflict_count ) // Conflict: ask user what he wants remove all aliases or abort: if( conflict_count ) // Conflict: ask user what he wants: remove all aliases or abort:
{ {
wxString title; wxString title;
wxString msg1; wxString msg1;
...@@ -271,6 +279,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) ...@@ -271,6 +279,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
if( diag != wxYES ) if( diag != wxYES )
return NULL; return NULL;
} }
}
for( size_t i = 0; i < newCmp->m_AliasList.GetCount(); i++ ) for( size_t i = 0; i < newCmp->m_AliasList.GetCount(); i++ )
{ {
...@@ -301,7 +310,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) ...@@ -301,7 +310,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
/** function RemoveEntryName /** function RemoveEntryName
* Remove an /a aName entry from the library list names. * 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. * it is not removed from its root component.
* this is for internal use only * this is for internal use only
* Use RemoveEntry( CMP_LIB_ENTRY* aEntry ) to remove safely an entry in library. * Use RemoveEntry( CMP_LIB_ENTRY* aEntry ) to remove safely an entry in library.
...@@ -349,9 +358,9 @@ void CMP_LIBRARY::RemoveEntryName( const wxString& aName ) ...@@ -349,9 +358,9 @@ void CMP_LIBRARY::RemoveEntryName( const wxString& aName )
root = alias->GetComponent(); root = alias->GetComponent();
/* Remove alias name from the root component alias list */ /* 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( aEntry->GetName() ),
GetChars( fileName.GetName() ) ); GetChars( fileName.GetName() ) );
} }
...@@ -359,12 +368,14 @@ void CMP_LIBRARY::RemoveEntryName( const wxString& aName ) ...@@ -359,12 +368,14 @@ void CMP_LIBRARY::RemoveEntryName( const wxString& aName )
{ {
int index = root->m_AliasList.Index( aEntry->GetName(), false ); int index = root->m_AliasList.Index( aEntry->GetName(), false );
if( index == wxNOT_FOUND ) if( index == wxNOT_FOUND ) // Should not occur, but is not a fatal error
wxLogWarning( wxT( "Alias <%s> not found in component <%s> alias list in \ {
wxLogDebug( wxT( "Alias <%s> not found in component <%s> alias list in \
library <%s>" ), library <%s>" ),
GetChars( aEntry->GetName() ), GetChars( aEntry->GetName() ),
GetChars( root->GetName() ), GetChars( root->GetName() ),
GetChars( fileName.GetName() ) ); GetChars( fileName.GetName() ) );
}
else else
root->m_AliasList.RemoveAt( index ); root->m_AliasList.RemoveAt( index );
} }
...@@ -458,7 +469,7 @@ LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent, ...@@ -458,7 +469,7 @@ LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent,
} }
RemoveEntryName( aOldComponent->GetName() ); RemoveEntryName( aOldComponent->GetName() );
entries.push_back( (CMP_LIB_ENTRY*) newCmp ); entries.push_back( newCmp );
entries.sort(); entries.sort();
SetModifyFlags( ); SetModifyFlags( );
......
...@@ -159,10 +159,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -159,10 +159,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
if( m_PartAliasList->GetStrings() != component->m_AliasList ) if( m_PartAliasList->GetStrings() != component->m_AliasList )
{ {
LIB_ALIAS* alias;
wxArrayString aliases = m_PartAliasList->GetStrings(); 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++ ) for( i = 0; i < aliases.GetCount(); i++ )
{ {
index = component->m_AliasList.Index( aliases[ i ], false ); index = component->m_AliasList.Index( aliases[ i ], false );
...@@ -170,16 +169,10 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -170,16 +169,10 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
if( index != wxNOT_FOUND ) if( index != wxNOT_FOUND )
continue; continue;
alias = new LIB_ALIAS( aliases[ i ], component ); component->m_AliasList.Add( aliases[ i ] );
if( !library->AddAlias( alias ) )
{
delete alias;
alias = NULL;
}
} }
/* 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++ ) for( i = 0; i < component->m_AliasList.GetCount(); i++ )
{ {
index = aliases.Index( component->m_AliasList[ i ], false ); index = aliases.Index( component->m_AliasList[ i ], false );
...@@ -187,10 +180,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -187,10 +180,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
if( index == wxNOT_FOUND ) if( index == wxNOT_FOUND )
continue; continue;
CMP_LIB_ENTRY* alias = component->m_AliasList.RemoveAt( i );
library->FindAlias( component->m_AliasList[ i ] ); i--;
if( alias != NULL )
library->RemoveEntry( alias );
} }
component->m_AliasList = aliases; component->m_AliasList = aliases;
......
...@@ -308,9 +308,8 @@ static bool UpdateScreenFromSheet( WinEDA_SchematicFrame* frame ) ...@@ -308,9 +308,8 @@ static bool UpdateScreenFromSheet( WinEDA_SchematicFrame* frame )
// Reset display settings of the new screen // Reset display settings of the new screen
// Assumes m_CurrentSheet has already been updated. // Assumes m_CurrentSheet has already been updated.
frame->ClearMsgPanel(); frame->ClearMsgPanel();
int pixelsPerUnitX = 1; frame->DrawPanel->SetScrollbars( NewScreen->m_ScrollPixelsPerUnitX,
int pixelsPerUnitY = 1; NewScreen->m_ScrollPixelsPerUnitY,
frame->DrawPanel->SetScrollbars( pixelsPerUnitX, pixelsPerUnitY,
NewScreen->m_ScrollbarNumber.x, NewScreen->m_ScrollbarNumber.x,
NewScreen->m_ScrollbarNumber.y, NewScreen->m_ScrollbarNumber.y,
NewScreen->m_ScrollbarPos.x, NewScreen->m_ScrollbarPos.x,
......
...@@ -6,24 +6,17 @@ ...@@ -6,24 +6,17 @@
#include "hotkeys_basic.h" #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 { enum hotkey_id_commnand {
HK_NOT_FOUND = 0, HK_NEXT_SEARCH = HK_COMMON_END,
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_DELETE, HK_DELETE,
HK_REPEAT_LAST, HK_REPEAT_LAST,
HK_EDIT_PIN, HK_EDIT_PIN,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM, HK_LIBEDIT_MOVE_GRAPHIC_ITEM,
HK_LIBEDIT_ROTATE_PIN, HK_LIBEDIT_ROTATE_PIN,
HK_DELETE_PIN, HK_DELETE_PIN,
HK_UNDO,
HK_REDO,
HK_MOVEBLOCK_TO_DRAGBLOCK, HK_MOVEBLOCK_TO_DRAGBLOCK,
HK_ROTATE, HK_ROTATE,
HK_EDIT, HK_EDIT,
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "class_library.h" #include "class_library.h"
#include "kicad_device_context.h" #include "kicad_device_context.h"
#include "hotkeys.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
...@@ -167,6 +168,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father, ...@@ -167,6 +168,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
SetShowDeMorgan( false ); SetShowDeMorgan( false );
m_drawSpecificConvert = true; m_drawSpecificConvert = true;
m_drawSpecificUnit = false; m_drawSpecificUnit = false;
m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr;
// Give an icon // Give an icon
SetIcon( wxIcon( libedit_xpm ) ); SetIcon( wxIcon( libedit_xpm ) );
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "dialog_erc.h" #include "dialog_erc.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "libviewfrm.h" #include "libviewfrm.h"
#include "hotkeys.h"
BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame ) BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
...@@ -160,6 +161,7 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father, ...@@ -160,6 +161,7 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
m_previewSize = wxDefaultSize; m_previewSize = wxDefaultSize;
m_printMonochrome = true; m_printMonochrome = true;
m_showSheetReference = true; m_showSheetReference = true;
m_HotkeysZoomAndGridList = s_Schematic_Hokeys_Descr;
CreateScreens(); CreateScreens();
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "protos.h" #include "protos.h"
#include "libviewfrm.h" #include "libviewfrm.h"
#include "class_library.h" #include "class_library.h"
#include "hotkeys.h"
/** /**
...@@ -92,6 +93,7 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father, ...@@ -92,6 +93,7 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
// Give an icon // Give an icon
SetIcon( wxIcon( library_browse_xpm ) ); SetIcon( wxIcon( library_browse_xpm ) );
m_HotkeysZoomAndGridList = s_Viewlib_Hokeys_Descr;
m_CmpList = NULL; m_CmpList = NULL;
m_LibList = NULL; m_LibList = NULL;
m_LibListWindow = NULL; m_LibListWindow = NULL;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "bitmaps.h" #include "bitmaps.h"
#include "protos.h" #include "protos.h"
#include "gerbview_id.h" #include "gerbview_id.h"
#include "hotkeys.h"
/****************************************/ /****************************************/
...@@ -128,6 +129,7 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, ...@@ -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_Axis = true; // true to show X and Y axis on screen
m_Draw_Sheet_Ref = FALSE; // TRUE for reference drawings. m_Draw_Sheet_Ref = FALSE; // TRUE for reference drawings.
m_HotkeysZoomAndGridList = s_Gerbview_Hokeys_Descr;
if( DrawPanel ) if( DrawPanel )
DrawPanel->m_Block_Enable = TRUE; DrawPanel->m_Block_Enable = TRUE;
......
...@@ -6,17 +6,12 @@ ...@@ -6,17 +6,12 @@
#include "hotkeys_basic.h" #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 { enum hotkey_id_commnand {
HK_NOT_FOUND = 0, HK_SWITCH_UNITS = HK_COMMON_END,
HK_RESET_LOCAL_COORD,
HK_HELP,
HK_SWITCH_UNITS,
HK_SWITCH_TRACK_DISPLAY_MODE, 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_NEXT,
HK_SWITCH_LAYER_TO_PREVIOUS HK_SWITCH_LAYER_TO_PREVIOUS
}; };
......
...@@ -66,9 +66,16 @@ public: ...@@ -66,9 +66,16 @@ public:
wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid)
* in user units. * in user units.
* (coordinates from last reset position)*/ * (coordinates from last reset position)*/
wxPoint m_ScrollbarPos; // Position effective des Curseurs de scroll // Scrollbars management:
wxSize m_ScrollbarNumber; /* Current scroll bar posiition in scroll 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. */ * units. */
wxPoint m_StartVisu; /* Coordinates in drawing units of the current wxPoint m_StartVisu; /* Coordinates in drawing units of the current
* view position (upper left corner of device) * view position (upper left corner of device)
*/ */
......
...@@ -159,7 +159,6 @@ public: ...@@ -159,7 +159,6 @@ public:
void SetGrid( const wxRealPoint& size ); void SetGrid( const wxRealPoint& size );
wxRealPoint GetGrid(); wxRealPoint GetGrid();
void AddMenuZoom( wxMenu* MasterMenu );
bool OnRightClick( wxMouseEvent& event ); bool OnRightClick( wxMouseEvent& event );
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
......
...@@ -75,4 +75,19 @@ void DisplayHotkeyList( WinEDA_DrawFrame* frame, ...@@ -75,4 +75,19 @@ void DisplayHotkeyList( WinEDA_DrawFrame* frame,
Ki_HotkeyInfo* GetDescriptorFromHotkey( int key, Ki_HotkeyInfo** List ); 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 #endif // HOTKEYS_BASIC_H
...@@ -183,6 +183,7 @@ public: ...@@ -183,6 +183,7 @@ public:
wxPoint m_Auxiliary_Axis_Position; /* position of the auxiliary axis */ wxPoint m_Auxiliary_Axis_Position; /* position of the auxiliary axis */
protected: protected:
Ki_HotkeyInfoSectionDescriptor * m_HotkeysZoomAndGridList;
int m_LastGridSizeId; int m_LastGridSizeId;
bool m_DrawGrid; // hide/Show grid bool m_DrawGrid; // hide/Show grid
int m_GridColor; // Grid color int m_GridColor; // Grid color
...@@ -218,6 +219,13 @@ public: ...@@ -218,6 +219,13 @@ public:
virtual void OnHotKey( wxDC* DC, int hotkey, virtual void OnHotKey( wxDC* DC, int hotkey,
EDA_BaseStruct* DrawStruct ); 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 Affiche_Message( const wxString& message );
void EraseMsgBox(); void EraseMsgBox();
void Process_PageSettings( wxCommandEvent& event ); void Process_PageSettings( wxCommandEvent& event );
......
...@@ -7,18 +7,11 @@ ...@@ -7,18 +7,11 @@
#include "hotkeys_basic.h" #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 { enum hotkey_id_commnand {
HK_NOT_FOUND = 0, HK_DELETE = HK_COMMON_END,
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_BACK_SPACE, HK_BACK_SPACE,
HK_ROTATE_FOOTPRINT, HK_ROTATE_FOOTPRINT,
HK_MOVE_FOOTPRINT, HK_MOVE_FOOTPRINT,
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "bitmaps.h" #include "bitmaps.h"
#include "protos.h" #include "protos.h"
#include "pcbnew_id.h" #include "pcbnew_id.h"
#include "hotkeys.h"
#include "3d_viewer.h" #include "3d_viewer.h"
...@@ -156,6 +157,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, ...@@ -156,6 +157,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
m_FrameName = wxT( "ModEditFrame" ); m_FrameName = wxT( "ModEditFrame" );
m_Draw_Sheet_Ref = false; // true to show the frame references 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_Draw_Axis = true; // true to show X and Y axis on screen
m_HotkeysZoomAndGridList = s_Module_Editor_Hokeys_Descr;
// Give an icon // Give an icon
SetIcon( wxICON( icon_modedit ) ); SetIcon( wxICON( icon_modedit ) );
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "layer_widget.h" #include "layer_widget.h"
#include "dialog_design_rules.h" #include "dialog_design_rules.h"
#include "class_pcb_layer_widget.h" #include "class_pcb_layer_widget.h"
#include "hotkeys.h"
...@@ -258,6 +259,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, ...@@ -258,6 +259,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
m_TrackAndViasSizesList_Changed = false; m_TrackAndViasSizesList_Changed = false;
m_show_microwave_tools = false; m_show_microwave_tools = false;
m_show_layer_manager_tools = true; m_show_layer_manager_tools = true;
m_HotkeysZoomAndGridList = s_Board_Editor_Hokeys_Descr;
SetBoard( new BOARD( NULL, this ) ); SetBoard( new BOARD( NULL, this ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment