Commit b0ea88e2 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Added options tool bar to schematic component library editor. Fixes lp:671343

parent d39df052
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
/* Library editor wxConfig entry names. */ /* Library editor wxConfig entry names. */
const wxString lastLibExportPathEntry( wxT( "LastLibraryExportPath" ) ); const wxString lastLibExportPathEntry( wxT( "LastLibraryExportPath" ) );
const wxString lastLibImportPathEntry( wxT( "LastLibraryImportPath" ) ); const wxString lastLibImportPathEntry( wxT( "LastLibraryImportPath" ) );
const wxString showGridPathEntry( wxT( "ShowGrid" ) );
/* This method guarantees unique IDs for the library this run of Eeschema /* This method guarantees unique IDs for the library this run of Eeschema
* which prevents ID conflicts and eliminates the need to recompile every * which prevents ID conflicts and eliminates the need to recompile every
...@@ -122,8 +122,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) ...@@ -122,8 +122,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::Process_Config )
EVT_MENU( ID_LIBEDIT_DIMENSIONS, LIB_EDIT_FRAME::InstallDimensionsDialog ) EVT_MENU( ID_LIBEDIT_DIMENSIONS, LIB_EDIT_FRAME::InstallDimensionsDialog )
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END,
ID_PREFERENCES_HOTKEY_END,
LIB_EDIT_FRAME::Process_Config ) LIB_EDIT_FRAME::Process_Config )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, LIB_EDIT_FRAME::SetLanguage ) EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, LIB_EDIT_FRAME::SetLanguage )
...@@ -184,6 +183,8 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, ...@@ -184,6 +183,8 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
SetIcon( wxIcon( libedit_xpm ) ); SetIcon( wxIcon( libedit_xpm ) );
SetScreen( new SCH_SCREEN() ); SetScreen( new SCH_SCREEN() );
GetScreen()->m_Center = true; GetScreen()->m_Center = true;
GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
LoadSettings(); LoadSettings();
// Initilialize grid id to a default value if not found in config or bad: // Initilialize grid id to a default value if not found in config or bad:
...@@ -201,17 +202,12 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, ...@@ -201,17 +202,12 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
ReCreateVToolbar(); ReCreateVToolbar();
CreateOptionToolbar();
DisplayLibInfos(); DisplayLibInfos();
DisplayCmpDoc(); DisplayCmpDoc();
UpdateAliasSelectList(); UpdateAliasSelectList();
UpdatePartSelectList(); UpdatePartSelectList();
#ifdef USE_WX_GRAPHICS_CONTEXT
GetScreen()->SetZoom( BestZoom() );
#else
Zoom_Automatique( false );
#endif
Show( true ); Show( true );
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
...@@ -235,12 +231,19 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, ...@@ -235,12 +231,19 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
m_auimgr.AddPane( m_VToolBar, m_auimgr.AddPane( m_VToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right() ); wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right() );
m_auimgr.AddPane( m_OptionsToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ).Left() );
m_auimgr.AddPane( DrawPanel, m_auimgr.AddPane( DrawPanel,
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
m_auimgr.AddPane( MsgPanel, m_auimgr.AddPane( MsgPanel,
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() ); wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.Update(); m_auimgr.Update();
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED, ID_ZOOM_PAGE );
wxPostEvent( this, evt );
} }
...@@ -324,6 +327,7 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -324,6 +327,7 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
wxString msg; wxString msg;
msg.Printf( _( "Library \"%s\" was modified!\nDiscard changes?" ), msg.Printf( _( "Library \"%s\" was modified!\nDiscard changes?" ),
GetChars( lib.GetName() ) ); GetChars( lib.GetName() ) );
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
{ {
Event.Veto(); Event.Veto();
...@@ -348,7 +352,7 @@ int LIB_EDIT_FRAME::BestZoom() ...@@ -348,7 +352,7 @@ int LIB_EDIT_FRAME::BestZoom()
BoundaryBox = m_component->GetBoundingBox( m_unit, m_convert ); BoundaryBox = m_component->GetBoundingBox( m_unit, m_convert );
dx = BoundaryBox.GetWidth(); dx = BoundaryBox.GetWidth();
dy = BoundaryBox.GetHeight(); dy = BoundaryBox.GetHeight();
GetScreen()->SetScrollCenterPosition( BoundaryBox.Centre() ); GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
} }
else else
{ {
......
...@@ -96,6 +96,7 @@ public: ...@@ -96,6 +96,7 @@ public:
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
void ReCreateHToolbar(); void ReCreateHToolbar();
void ReCreateVToolbar(); void ReCreateVToolbar();
void CreateOptionToolbar();
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
int BestZoom(); // Returns the best zoom int BestZoom(); // Returns the best zoom
...@@ -329,7 +330,6 @@ protected: ...@@ -329,7 +330,6 @@ protected:
*/ */
void CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg ); void CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg );
/** Virtual function PrintPage /** Virtual function PrintPage
* used to print a page * used to print a page
* Print the page pointed by ActiveScreen, set by the calling print function * Print the page pointed by ActiveScreen, set by the calling print function
......
...@@ -124,8 +124,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) ...@@ -124,8 +124,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_UPDATE_UI( wxID_PASTE, SCH_EDIT_FRAME::OnUpdatePaste ) EVT_UPDATE_UI( wxID_PASTE, SCH_EDIT_FRAME::OnUpdatePaste )
EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnUpdateHiddenPins ) EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnUpdateHiddenPins )
EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnUpdateBusOrientation ) EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnUpdateBusOrientation )
EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SELECT_UNIT_MM, ID_TB_OPTIONS_SELECT_UNIT_INCH,
SCH_EDIT_FRAME::OnUpdateUnits )
EVT_UPDATE_UI_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END, EVT_UPDATE_UI_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
SCH_EDIT_FRAME::OnUpdateSelectTool ) SCH_EDIT_FRAME::OnUpdateSelectTool )
...@@ -655,17 +653,12 @@ void SCH_EDIT_FRAME::OnOpenLibraryViewer( wxCommandEvent& event ) ...@@ -655,17 +653,12 @@ void SCH_EDIT_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
{ {
if( m_LibeditFrame ) if( m_LibeditFrame )
{
m_LibeditFrame->Show( true ); m_LibeditFrame->Show( true );
}
else else
{
m_LibeditFrame = new LIB_EDIT_FRAME( this, m_LibeditFrame = new LIB_EDIT_FRAME( this,
wxT( "Library Editor" ), wxT( "Library Editor" ),
wxPoint( -1, -1 ), wxPoint( -1, -1 ),
wxSize( 600, 400 ) ); wxSize( 600, 400 ) );
m_LibeditFrame->AdjustScrollBars( wxPoint( 0, 0 ) );
}
} }
......
...@@ -83,21 +83,17 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() ...@@ -83,21 +83,17 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, true ); m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, true );
// Set up toolbar // Set up toolbar
m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_LIB, wxEmptyString, m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_LIB, wxEmptyString, wxBitmap( save_library_xpm ),
wxBitmap( save_library_xpm ),
_( "Save current library to disk" ) ); _( "Save current library to disk" ) );
m_HToolBar->AddTool( ID_LIBEDIT_SELECT_CURRENT_LIB, wxEmptyString, m_HToolBar->AddTool( ID_LIBEDIT_SELECT_CURRENT_LIB, wxEmptyString, wxBitmap( library_xpm ),
wxBitmap( library_xpm ),
_( "Select working library" ) ); _( "Select working library" ) );
m_HToolBar->AddTool( ID_LIBEDIT_DELETE_PART, wxEmptyString, m_HToolBar->AddTool( ID_LIBEDIT_DELETE_PART, wxEmptyString, wxBitmap( delete_xpm ),
wxBitmap( delete_xpm ),
_( "Delete component in current library" ) ); _( "Delete component in current library" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString, m_HToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString, wxBitmap( new_component_xpm ),
wxBitmap( new_component_xpm ),
_( "Create a new component" ) ); _( "Create a new component" ) );
m_HToolBar->AddTool( ID_LIBEDIT_SELECT_PART, wxEmptyString, m_HToolBar->AddTool( ID_LIBEDIT_SELECT_PART, wxEmptyString,
...@@ -118,65 +114,48 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() ...@@ -118,65 +114,48 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
m_HToolBar->AddTool( ExportPartId, wxEmptyString, wxBitmap( export_xpm ), m_HToolBar->AddTool( ExportPartId, wxEmptyString, wxBitmap( export_xpm ),
_( "Export component" ) ); _( "Export component" ) );
m_HToolBar->AddTool( CreateNewLibAndSavePartId, wxEmptyString, m_HToolBar->AddTool( CreateNewLibAndSavePartId, wxEmptyString, wxBitmap( new_library_xpm ),
wxBitmap( new_library_xpm ),
_( "Save current component to new library" ) ); _( "Save current component to new library" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
msg = AddHotkeyName( _( "Undo last command" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Undo last command" ), s_Schematic_Hokeys_Descr, HK_UNDO, false );
HK_UNDO, false ); m_HToolBar->AddTool( wxID_UNDO, wxEmptyString, wxBitmap( undo_xpm ), msg );
m_HToolBar->AddTool( wxID_UNDO, wxEmptyString, wxBitmap( undo_xpm ), msg = AddHotkeyName( _( "Redo the last command" ), s_Schematic_Hokeys_Descr, HK_REDO, false );
msg ); m_HToolBar->AddTool( wxID_REDO, wxEmptyString, wxBitmap( redo_xpm ), msg );
msg = AddHotkeyName( _( "Redo the last command" ), s_Schematic_Hokeys_Descr,
HK_REDO, false );
m_HToolBar->AddTool( wxID_REDO, wxEmptyString, wxBitmap( redo_xpm ),
msg );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_PART, wxEmptyString, m_HToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_PART, wxEmptyString,
wxBitmap( part_properties_xpm ), wxBitmap( part_properties_xpm ), _( "Edit component properties" ) );
_( "Edit component properties" ) );
m_HToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, wxEmptyString, m_HToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, wxEmptyString, wxBitmap( add_text_xpm ),
wxBitmap( add_text_xpm ),
_( "Add and remove fields and edit field properties" ) ); _( "Add and remove fields and edit field properties" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString, m_HToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString, wxBitmap( erc_xpm ),
wxBitmap( erc_xpm ),
_( "Test for duplicate pins and off grid pins" ) ); _( "Test for duplicate pins and off grid pins" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
msg = AddHotkeyName( HELP_ZOOM_IN, s_Libedit_Hokeys_Descr, HK_ZOOM_IN, false ); msg = AddHotkeyName( HELP_ZOOM_IN, s_Libedit_Hokeys_Descr, HK_ZOOM_IN, false );
m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, wxBitmap( zoom_in_xpm ), m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, wxBitmap( zoom_in_xpm ), msg );
msg );
msg = AddHotkeyName( HELP_ZOOM_OUT, s_Libedit_Hokeys_Descr, HK_ZOOM_OUT, false ); msg = AddHotkeyName( HELP_ZOOM_OUT, s_Libedit_Hokeys_Descr, HK_ZOOM_OUT, false );
m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, wxBitmap( zoom_out_xpm ), m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, wxBitmap( zoom_out_xpm ), msg );
msg );
msg = AddHotkeyName( HELP_ZOOM_REDRAW, s_Libedit_Hokeys_Descr, msg = AddHotkeyName( HELP_ZOOM_REDRAW, s_Libedit_Hokeys_Descr, HK_ZOOM_REDRAW, false );
HK_ZOOM_REDRAW, false ); m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, wxBitmap( zoom_redraw_xpm ), msg );
m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
wxBitmap( zoom_redraw_xpm ), msg );
msg = AddHotkeyName( HELP_ZOOM_FIT, s_Libedit_Hokeys_Descr, HK_ZOOM_AUTO, false ); msg = AddHotkeyName( HELP_ZOOM_FIT, s_Libedit_Hokeys_Descr, HK_ZOOM_AUTO, false );
m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, wxBitmap( zoom_auto_xpm ), msg );
wxBitmap( zoom_auto_xpm ), msg );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString, m_HToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString, wxBitmap( morgan1_xpm ),
wxBitmap( morgan1_xpm ), _( "Show as \"De Morgan\" normal part" ), wxITEM_CHECK );
_( "Show as \"De Morgan\" normal part" ), m_HToolBar->AddTool( ID_DE_MORGAN_CONVERT_BUTT, wxEmptyString, wxBitmap( morgan2_xpm ),
wxITEM_CHECK ); _( "Show as \"De Morgan\" convert part" ), wxITEM_CHECK );
m_HToolBar->AddTool( ID_DE_MORGAN_CONVERT_BUTT, wxEmptyString,
wxBitmap( morgan2_xpm ),
_( "Show as \"De Morgan\" convert part" ),
wxITEM_CHECK );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_LIBEDIT_VIEW_DOC, wxEmptyString, m_HToolBar->AddTool( ID_LIBEDIT_VIEW_DOC, wxEmptyString, wxBitmap( datasheet_xpm ),
wxBitmap( datasheet_xpm ), _( "Edit document file" ) ); _( "Edit document file" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_SelpartBox = new WinEDAChoiceBox( m_HToolBar, m_SelpartBox = new WinEDAChoiceBox( m_HToolBar,
...@@ -185,8 +164,7 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() ...@@ -185,8 +164,7 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
wxSize( LISTBOX_WIDTH, -1 ) ); wxSize( LISTBOX_WIDTH, -1 ) );
m_HToolBar->AddControl( m_SelpartBox ); m_HToolBar->AddControl( m_SelpartBox );
m_SelAliasBox = new WinEDAChoiceBox( m_HToolBar, ID_LIBEDIT_SELECT_ALIAS, m_SelAliasBox = new WinEDAChoiceBox( m_HToolBar, ID_LIBEDIT_SELECT_ALIAS, wxDefaultPosition,
wxDefaultPosition,
wxSize( LISTBOX_WIDTH, -1 ) ); wxSize( LISTBOX_WIDTH, -1 ) );
m_HToolBar->AddControl( m_SelAliasBox ); m_HToolBar->AddControl( m_SelAliasBox );
...@@ -196,12 +174,34 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() ...@@ -196,12 +174,34 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
msg += _("Usual option = OFF when parts are not locked"); msg += _("Usual option = OFF when parts are not locked");
msg << wxT("\n"); msg << wxT("\n");
msg += _("Usual option = ON when parts are locked"); msg += _("Usual option = ON when parts are locked");
m_HToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, wxEmptyString, m_HToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, wxEmptyString, wxBitmap( pin2pin_xpm ),
wxBitmap( pin2pin_xpm ), msg, wxITEM_CHECK );
msg,
wxITEM_CHECK );
// after adding the buttons to the toolbar, must call Realize() to reflect // after adding the buttons to the toolbar, must call Realize() to reflect the changes
// the changes
m_HToolBar->Realize(); m_HToolBar->Realize();
} }
void LIB_EDIT_FRAME::CreateOptionToolbar()
{
if( m_OptionsToolBar )
return;
m_OptionsToolBar = new WinEDA_Toolbar( TOOLBAR_OPTION, this, ID_OPT_TOOLBAR, false );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, wxBitmap( grid_xpm ),
_( "Turn grid off" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
wxBitmap( unit_inch_xpm ), _( "Units in inches" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
wxBitmap( unit_mm_xpm ),
_( "Units in millimeters" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
wxBitmap( cursor_shape_xpm ),
_( "Change cursor shape" ), wxITEM_CHECK );
m_OptionsToolBar->Realize();
}
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