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