2007-09-15 04:25:54 +00:00
|
|
|
|
/****************************/
|
2009-09-02 18:12:45 +00:00
|
|
|
|
/* EESchema - libframe.cpp */
|
2007-09-15 04:25:54 +00:00
|
|
|
|
/****************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
/* Gestion de la frame d'edition des composants en librairie
|
2007-09-15 04:25:54 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "appl_wxstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
|
#include "confirm.h"
|
|
|
|
|
#include "eda_doc.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
#include "program.h"
|
|
|
|
|
#include "libcmp.h"
|
|
|
|
|
#include "general.h"
|
|
|
|
|
#include "bitmaps.h"
|
|
|
|
|
#include "protos.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
|
#include "eeschema_id.h"
|
2009-09-18 14:56:05 +00:00
|
|
|
|
#include "class_library.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
|
#include "libeditfrm.h"
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
|
|
#include <boost/foreach.hpp>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
|
/* Library editor wxConfig entry names. */
|
|
|
|
|
const wxString lastLibExportPathEntry( wxT( "LastLibraryExportPath" ) );
|
|
|
|
|
const wxString lastLibImportPathEntry( wxT( "LastLibraryImportPath" ) );
|
|
|
|
|
const wxString showGridPathEntry( wxT( "ShowGrid" ) );
|
|
|
|
|
|
|
|
|
|
/* This method guarentees unique IDs for the library this run of Eeschema
|
|
|
|
|
* which prevents ID conflicts and eliminates the need to recompile every
|
|
|
|
|
* source file in the project when adding IDs to include/id.h. */
|
|
|
|
|
int ExportPartId = ::wxNewId();
|
|
|
|
|
int ImportPartId = ::wxNewId();
|
|
|
|
|
int CreateNewLibAndSavePartId = ::wxNewId();
|
|
|
|
|
|
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
LIB_COMPONENT* WinEDA_LibeditFrame::m_currentComponent = NULL;
|
|
|
|
|
|
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
|
/*****************************/
|
|
|
|
|
/* class WinEDA_LibeditFrame */
|
|
|
|
|
/*****************************/
|
2009-01-07 15:59:49 +00:00
|
|
|
|
BEGIN_EVENT_TABLE( WinEDA_LibeditFrame, WinEDA_DrawFrame )
|
2008-12-08 15:27:13 +00:00
|
|
|
|
EVT_CLOSE( WinEDA_LibeditFrame::OnCloseWindow )
|
|
|
|
|
EVT_SIZE( WinEDA_LibeditFrame::OnSize )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
/* Main horizontal toolbar. */
|
2009-01-07 15:59:49 +00:00
|
|
|
|
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_LibeditFrame::OnZoom )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_LIB,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::SaveActiveLibrary )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::Process_Special_Functions )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_DELETE_PART,
|
2009-09-22 12:27:57 +00:00
|
|
|
|
WinEDA_LibeditFrame::DeleteOnePart )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_NEW_PART,
|
2009-09-22 12:27:57 +00:00
|
|
|
|
WinEDA_LibeditFrame::CreateNewLibraryPart )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_SELECT_PART,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::Process_Special_Functions )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::Process_Special_Functions )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_UNDO,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::GetComponentFromUndoList )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_REDO,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::GetComponentFromRedoList )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_PART,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::OnEditComponentProperties )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
|
2009-09-22 12:27:57 +00:00
|
|
|
|
WinEDA_LibeditFrame::InstallFieldsEditorDialog )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_CHECK_PART,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::Process_Special_Functions )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_DE_MORGAN_NORMAL_BUTT,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::Process_Special_Functions )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_DE_MORGAN_CONVERT_BUTT,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::Process_Special_Functions )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_VIEW_DOC,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::Process_Special_Functions )
|
2009-07-29 13:10:36 +00:00
|
|
|
|
EVT_TOOL( ID_LIBEDIT_EDIT_PIN_BY_PIN,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ExportPartId, WinEDA_LibeditFrame::OnExportPart )
|
|
|
|
|
EVT_TOOL( CreateNewLibAndSavePartId, WinEDA_LibeditFrame::OnExportPart )
|
|
|
|
|
EVT_TOOL( ImportPartId, WinEDA_LibeditFrame::OnImportPart )
|
|
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
|
EVT_KICAD_CHOICEBOX( ID_LIBEDIT_SELECT_PART_NUMBER,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::OnSelectPart )
|
2008-12-08 15:27:13 +00:00
|
|
|
|
EVT_KICAD_CHOICEBOX( ID_LIBEDIT_SELECT_ALIAS,
|
2009-09-14 13:24:17 +00:00
|
|
|
|
WinEDA_LibeditFrame::OnSelectAlias )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
/* Right vertical toolbar. */
|
2008-12-08 15:27:13 +00:00
|
|
|
|
EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_LibeditFrame::Process_Special_Functions )
|
2009-09-22 12:27:57 +00:00
|
|
|
|
EVT_TOOL_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_EXPORT_BODY_BUTT,
|
2008-12-08 15:27:13 +00:00
|
|
|
|
WinEDA_LibeditFrame::Process_Special_Functions )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
/* Context menu events and commands. */
|
2009-09-22 12:27:57 +00:00
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_LIBEDIT_PIN_EDIT,
|
|
|
|
|
ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT,
|
2008-12-08 15:27:13 +00:00
|
|
|
|
WinEDA_LibeditFrame::Process_Special_Functions )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
|
|
|
|
|
WinEDA_LibeditFrame::Process_Special_Functions )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
/* Update user interface elements. */
|
2009-04-05 20:49:15 +00:00
|
|
|
|
EVT_UPDATE_UI( ExportPartId, WinEDA_LibeditFrame::OnUpdateEditingPart )
|
|
|
|
|
EVT_UPDATE_UI( CreateNewLibAndSavePartId,
|
|
|
|
|
WinEDA_LibeditFrame::OnUpdateEditingPart )
|
2009-09-14 13:24:17 +00:00
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_PART,
|
|
|
|
|
WinEDA_LibeditFrame::OnUpdateEditingPart )
|
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
|
|
|
|
|
WinEDA_LibeditFrame::OnUpdateEditingPart )
|
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART,
|
|
|
|
|
WinEDA_LibeditFrame::OnUpdateEditingPart )
|
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_UNDO, WinEDA_LibeditFrame::OnUpdateUndo )
|
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_REDO, WinEDA_LibeditFrame::OnUpdateRedo )
|
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB,
|
|
|
|
|
WinEDA_LibeditFrame::OnUpdateSaveCurrentLib )
|
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, WinEDA_LibeditFrame::OnUpdateViewDoc )
|
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_PIN,
|
|
|
|
|
WinEDA_LibeditFrame::OnUpdatePinByPin )
|
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SELECT_PART_NUMBER,
|
|
|
|
|
WinEDA_LibeditFrame::OnUpdatePartNumber )
|
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SELECT_ALIAS,
|
|
|
|
|
WinEDA_LibeditFrame::OnUpdateSelectAlias )
|
|
|
|
|
EVT_UPDATE_UI( ID_DE_MORGAN_NORMAL_BUTT,
|
|
|
|
|
WinEDA_LibeditFrame::OnUpdateDeMorganNormal )
|
|
|
|
|
EVT_UPDATE_UI( ID_DE_MORGAN_CONVERT_BUTT,
|
|
|
|
|
WinEDA_LibeditFrame::OnUpdateDeMorganConvert )
|
|
|
|
|
EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_EXPORT_BODY_BUTT,
|
|
|
|
|
WinEDA_LibeditFrame::OnUpdateEditingPart )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
|
WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
|
2007-09-15 04:25:54 +00:00
|
|
|
|
const wxString& title,
|
2007-09-19 15:29:50 +00:00
|
|
|
|
const wxPoint& pos,
|
2007-10-27 12:24:09 +00:00
|
|
|
|
const wxSize& size,
|
2009-04-05 20:49:15 +00:00
|
|
|
|
long style ) :
|
2008-12-08 15:27:13 +00:00
|
|
|
|
WinEDA_DrawFrame( father, LIBEDITOR_FRAME, title, pos, size, style )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-15 04:25:54 +00:00
|
|
|
|
m_FrameName = wxT( "LibeditFrame" );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
m_Draw_Axis = true; // true pour avoir les axes dessines
|
|
|
|
|
m_Draw_Grid = true; // true pour avoir la axes dessinee
|
2009-04-05 20:49:15 +00:00
|
|
|
|
m_ConfigPath = wxT( "LibraryEditor" );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
|
|
// Give an icon
|
|
|
|
|
SetIcon( wxIcon( libedit_xpm ) );
|
2008-09-19 08:19:15 +00:00
|
|
|
|
SetBaseScreen( g_ScreenLib );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
GetScreen()->m_Center = true;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
LoadSettings();
|
2007-09-15 04:25:54 +00:00
|
|
|
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
|
|
|
|
if( DrawPanel )
|
2008-12-30 19:18:56 +00:00
|
|
|
|
DrawPanel->m_Block_Enable = true;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
ReCreateHToolbar();
|
|
|
|
|
ReCreateVToolbar();
|
|
|
|
|
DisplayLibInfos();
|
2009-09-18 14:56:05 +00:00
|
|
|
|
DisplayCmpDoc();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
UpdateAliasSelectList();
|
|
|
|
|
UpdatePartSelectList();
|
2008-12-06 19:44:02 +00:00
|
|
|
|
BestZoom();
|
2008-12-30 19:18:56 +00:00
|
|
|
|
Show( true );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
|
WinEDA_LibeditFrame::~WinEDA_LibeditFrame()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
|
WinEDA_SchematicFrame* frame =
|
|
|
|
|
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
|
|
|
|
|
frame->m_LibeditFrame = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
/**
|
|
|
|
|
* Load library editor frame specific configuration settings.
|
|
|
|
|
*
|
|
|
|
|
* Don't forget to call this base method from any derived classes or the
|
|
|
|
|
* settings will not get loaded.
|
|
|
|
|
*/
|
|
|
|
|
void WinEDA_LibeditFrame::LoadSettings( )
|
|
|
|
|
{
|
|
|
|
|
wxConfig* cfg;
|
|
|
|
|
|
|
|
|
|
WinEDA_DrawFrame::LoadSettings();
|
|
|
|
|
|
|
|
|
|
wxConfigPathChanger cpc( wxGetApp().m_EDA_Config, m_ConfigPath );
|
|
|
|
|
cfg = wxGetApp().m_EDA_Config;
|
|
|
|
|
|
|
|
|
|
m_LastLibExportPath = cfg->Read( lastLibExportPathEntry, ::wxGetCwd() );
|
|
|
|
|
m_LastLibImportPath = cfg->Read( lastLibImportPathEntry, ::wxGetCwd() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Save library editor frame specific configuration settings.
|
|
|
|
|
*
|
|
|
|
|
* Don't forget to call this base method from any derived classes or the
|
|
|
|
|
* settings will not get saved.
|
|
|
|
|
*/
|
|
|
|
|
void WinEDA_LibeditFrame::SaveSettings()
|
|
|
|
|
{
|
|
|
|
|
wxConfig* cfg;
|
|
|
|
|
|
|
|
|
|
WinEDA_DrawFrame::SaveSettings();
|
|
|
|
|
|
|
|
|
|
wxConfigPathChanger cpc( wxGetApp().m_EDA_Config, m_ConfigPath );
|
|
|
|
|
cfg = wxGetApp().m_EDA_Config;
|
|
|
|
|
|
|
|
|
|
cfg->Write( lastLibExportPathEntry, m_LastLibExportPath );
|
|
|
|
|
cfg->Write( lastLibImportPathEntry, m_LastLibImportPath );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
|
void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( GetScreen()->IsModify() )
|
2007-09-15 04:25:54 +00:00
|
|
|
|
{
|
2007-11-10 22:36:36 +00:00
|
|
|
|
if( !IsOK( this, _( "Component was modified!\nDiscard changes?" ) ) )
|
2007-09-15 04:25:54 +00:00
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
|
Event.Veto();
|
|
|
|
|
return;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2008-04-17 16:25:29 +00:00
|
|
|
|
GetScreen()->ClrModify();
|
2007-09-15 04:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
|
BOOST_FOREACH( const CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
|
2007-09-15 04:25:54 +00:00
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
|
if( lib.IsModified() )
|
2007-09-15 04:25:54 +00:00
|
|
|
|
{
|
|
|
|
|
wxString msg;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
msg.Printf( _( "Library \"%s\" was modified!\nDiscard changes?" ),
|
2009-09-18 14:56:05 +00:00
|
|
|
|
(const wxChar*) lib.GetName() );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
if( !IsOK( this, msg ) )
|
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
Event.Veto();
|
|
|
|
|
return;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SaveSettings();
|
|
|
|
|
Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
|
int WinEDA_LibeditFrame::BestZoom()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-15 04:25:54 +00:00
|
|
|
|
int dx, dy, ii, jj;
|
|
|
|
|
int bestzoom;
|
|
|
|
|
wxSize size;
|
|
|
|
|
EDA_Rect BoundaryBox;
|
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
if( m_currentComponent )
|
2007-09-15 04:25:54 +00:00
|
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
|
BoundaryBox = m_currentComponent->GetBoundaryBox( CurrentUnit,
|
|
|
|
|
CurrentConvert );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
dx = BoundaryBox.GetWidth();
|
|
|
|
|
dy = BoundaryBox.GetHeight();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
dx = GetScreen()->m_CurrentSheetDesc->m_Size.x;
|
|
|
|
|
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size = DrawPanel->GetClientSize();
|
2009-09-02 18:12:45 +00:00
|
|
|
|
size -= wxSize( 100, 100 ); // reserve 100 mils margin
|
2007-09-15 04:25:54 +00:00
|
|
|
|
ii = abs( dx / size.x );
|
|
|
|
|
jj = abs( dy / size.y );
|
|
|
|
|
|
|
|
|
|
bestzoom = MAX( ii, jj ) + 1;
|
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
if( m_currentComponent )
|
2007-09-15 04:25:54 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
GetScreen()->m_Curseur = BoundaryBox.Centre();
|
2007-09-15 04:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
GetScreen()->m_Curseur.x = 0;
|
|
|
|
|
GetScreen()->m_Curseur.y = 0;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-29 14:26:20 +00:00
|
|
|
|
return bestzoom * GetScreen()->m_ZoomScalar;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
void WinEDA_LibeditFrame::UpdateAliasSelectList()
|
|
|
|
|
{
|
|
|
|
|
if( m_SelAliasBox == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_SelAliasBox->Clear();
|
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
if( m_currentComponent == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
m_SelAliasBox->Append( m_currentComponent->GetName() );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
m_SelAliasBox->SetSelection( 0 );
|
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
if( !m_currentComponent->m_AliasList.IsEmpty() )
|
2009-09-14 13:24:17 +00:00
|
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
|
m_SelAliasBox->Append( m_currentComponent->m_AliasList );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
|
|
int index = m_SelAliasBox->FindString( CurrentAliasName );
|
|
|
|
|
|
|
|
|
|
if( index != wxNOT_FOUND )
|
|
|
|
|
m_SelAliasBox->SetSelection( index );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::UpdatePartSelectList()
|
|
|
|
|
{
|
|
|
|
|
if( m_SelpartBox == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
2009-09-17 17:48:40 +00:00
|
|
|
|
if( m_SelpartBox->GetCount() != 0 )
|
2009-09-14 13:24:17 +00:00
|
|
|
|
m_SelpartBox->Clear();
|
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
if( m_currentComponent == NULL || m_currentComponent->m_UnitCount <= 1 )
|
2009-09-14 13:24:17 +00:00
|
|
|
|
{
|
|
|
|
|
m_SelpartBox->Append( wxEmptyString );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
|
for( int i = 0; i < m_currentComponent->m_UnitCount; i++ )
|
2009-09-14 13:24:17 +00:00
|
|
|
|
{
|
|
|
|
|
wxString msg;
|
|
|
|
|
msg.Printf( _( "Part %c" ), 'A' + i );
|
|
|
|
|
m_SelpartBox->Append( msg );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_SelpartBox->SetSelection( ( CurrentUnit > 0 ) ? CurrentUnit - 1 : 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
void WinEDA_LibeditFrame::OnUpdateEditingPart( wxUpdateUIEvent& event )
|
|
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
|
event.Enable( m_currentComponent != NULL );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
void WinEDA_LibeditFrame::OnUpdateNotEditingPart( wxUpdateUIEvent& event )
|
|
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
|
event.Enable( m_currentComponent == NULL );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
void WinEDA_LibeditFrame::OnUpdateUndo( wxUpdateUIEvent& event )
|
|
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
|
event.Enable( m_currentComponent != NULL && GetScreen() != NULL
|
2009-09-14 13:24:17 +00:00
|
|
|
|
&& GetScreen()->GetUndoCommandCount() != 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::OnUpdateRedo( wxUpdateUIEvent& event )
|
|
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
|
event.Enable( m_currentComponent != NULL && GetScreen() != NULL
|
2009-09-14 13:24:17 +00:00
|
|
|
|
&& GetScreen()->GetRedoCommandCount() != 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::OnUpdateSaveCurrentLib( wxUpdateUIEvent& event )
|
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
|
event.Enable( CurrentLib != NULL
|
|
|
|
|
&& ( CurrentLib->IsModified() || GetScreen()->IsModify() ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::OnUpdateViewDoc( wxUpdateUIEvent& event )
|
|
|
|
|
{
|
|
|
|
|
bool enable = false;
|
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
if( m_currentComponent != NULL && CurrentLib != NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
|
{
|
|
|
|
|
if( !CurrentAliasName.IsEmpty() )
|
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
|
CMP_LIB_ENTRY* entry = CurrentLib->FindEntry( CurrentAliasName );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
|
|
if( entry != NULL )
|
|
|
|
|
enable = !entry->m_DocFile.IsEmpty();
|
|
|
|
|
}
|
2009-09-22 12:27:57 +00:00
|
|
|
|
else if( !m_currentComponent->m_DocFile.IsEmpty() )
|
2009-09-14 13:24:17 +00:00
|
|
|
|
{
|
|
|
|
|
enable = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
event.Enable( enable );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::OnUpdatePinByPin( wxUpdateUIEvent& event )
|
|
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
|
event.Enable( ( m_currentComponent != NULL )
|
|
|
|
|
&& ( ( m_currentComponent->m_UnitCount > 1 )
|
|
|
|
|
|| g_AsDeMorgan ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
|
|
if( m_HToolBar )
|
|
|
|
|
m_HToolBar->ToggleTool( event.GetId(), g_EditPinByPinIsOn );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::OnUpdatePartNumber( wxUpdateUIEvent& event )
|
|
|
|
|
{
|
|
|
|
|
if( m_SelpartBox == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Using the typical event.Enable() call dosen't seem to work with wxGTK
|
|
|
|
|
* so use the pointer to alias combobox to directly enable or disable.
|
|
|
|
|
*/
|
2009-09-22 12:27:57 +00:00
|
|
|
|
m_SelpartBox->Enable( m_currentComponent != NULL
|
|
|
|
|
&& m_currentComponent->m_UnitCount > 1 );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::OnUpdateDeMorganNormal( wxUpdateUIEvent& event )
|
|
|
|
|
{
|
|
|
|
|
if( m_HToolBar == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
event.Enable( m_currentComponent != NULL
|
|
|
|
|
&& m_currentComponent->HasConversion() );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
m_HToolBar->ToggleTool( event.GetId(), CurrentConvert <= 1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::OnUpdateDeMorganConvert( wxUpdateUIEvent& event )
|
|
|
|
|
{
|
|
|
|
|
if( m_HToolBar == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
event.Enable( m_currentComponent != NULL
|
|
|
|
|
&& m_currentComponent->HasConversion() );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
m_HToolBar->ToggleTool( event.GetId(), CurrentConvert > 1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::OnUpdateSelectAlias( wxUpdateUIEvent& event )
|
|
|
|
|
{
|
|
|
|
|
if( m_SelAliasBox == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Using the typical event.Enable() call dosen't seem to work with wxGTK
|
|
|
|
|
* so use the pointer to alias combobox to directly enable or disable.
|
|
|
|
|
*/
|
2009-09-22 12:27:57 +00:00
|
|
|
|
m_SelAliasBox->Enable( m_currentComponent != NULL
|
|
|
|
|
&& !m_currentComponent->m_AliasList.IsEmpty() );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::OnSelectAlias( wxCommandEvent& event )
|
|
|
|
|
{
|
|
|
|
|
if( m_SelAliasBox == NULL
|
|
|
|
|
|| m_SelAliasBox->GetStringSelection().CmpNoCase( CurrentAliasName ) == 0 )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
LibItemToRepeat = NULL;
|
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
if( m_SelAliasBox->GetStringSelection().CmpNoCase(m_currentComponent->GetName() ) == 0 )
|
2009-09-14 13:24:17 +00:00
|
|
|
|
CurrentAliasName.Empty();
|
|
|
|
|
else
|
|
|
|
|
CurrentAliasName = m_SelAliasBox->GetStringSelection();
|
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
|
DisplayCmpDoc();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
DrawPanel->Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::OnSelectPart( wxCommandEvent& event )
|
|
|
|
|
{
|
|
|
|
|
int i = event.GetSelection();
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
|
|
if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == CurrentUnit ) )
|
2009-09-14 13:24:17 +00:00
|
|
|
|
return;
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
LibItemToRepeat = NULL;
|
|
|
|
|
CurrentUnit = i + 1;
|
|
|
|
|
DrawPanel->Refresh();
|
2009-09-18 14:56:05 +00:00
|
|
|
|
DisplayCmpDoc();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
|
void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-19 15:29:50 +00:00
|
|
|
|
int id = event.GetId();
|
|
|
|
|
wxPoint pos;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
|
|
wxClientDC dc( DrawPanel );
|
|
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = true;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
|
|
DrawPanel->PrepareGraphicContext( &dc );
|
|
|
|
|
|
|
|
|
|
wxGetMousePosition( &pos.x, &pos.y );
|
|
|
|
|
pos.y += 20;
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
switch( id ) // Arret de la commande de d<>placement en cours
|
2007-09-15 04:25:54 +00:00
|
|
|
|
{
|
|
|
|
|
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_EDIT:
|
|
|
|
|
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
|
|
|
|
|
case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM:
|
|
|
|
|
case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM:
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
|
|
|
|
|
case ID_POPUP_LIBEDIT_CANCEL_EDITING:
|
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
|
|
|
|
case ID_POPUP_COPY_BLOCK:
|
|
|
|
|
case ID_POPUP_SELECT_ITEMS_BLOCK:
|
2009-08-12 10:40:01 +00:00
|
|
|
|
case ID_POPUP_MIRROR_Y_BLOCK:
|
2007-09-15 04:25:54 +00:00
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
|
|
|
|
|
case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_ITEM:
|
|
|
|
|
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
|
{
|
|
|
|
|
case ID_LIBEDIT_SELECT_CURRENT_LIB:
|
|
|
|
|
SelectActiveLibrary();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_SELECT_PART:
|
|
|
|
|
LibItemToRepeat = NULL;
|
|
|
|
|
if( LoadOneLibraryPart() )
|
|
|
|
|
{
|
2008-12-30 19:18:56 +00:00
|
|
|
|
g_EditPinByPinIsOn = false;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
GetScreen()->ClearUndoRedoList();
|
|
|
|
|
}
|
2008-12-20 13:12:57 +00:00
|
|
|
|
DrawPanel->Refresh();
|
2007-09-15 04:25:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_SAVE_CURRENT_PART:
|
|
|
|
|
SaveOnePartInMemory();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_CHECK_PART:
|
2009-09-22 12:27:57 +00:00
|
|
|
|
if( m_currentComponent && TestPins( m_currentComponent ) == false )
|
2009-09-14 13:24:17 +00:00
|
|
|
|
DisplayInfoMessage( this, _( " Pins Test OK!" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_DE_MORGAN_NORMAL_BUTT:
|
|
|
|
|
LibItemToRepeat = NULL;
|
|
|
|
|
CurrentConvert = 1;
|
2008-12-20 13:12:57 +00:00
|
|
|
|
DrawPanel->Refresh();
|
2007-09-15 04:25:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_DE_MORGAN_CONVERT_BUTT:
|
|
|
|
|
LibItemToRepeat = NULL;
|
|
|
|
|
CurrentConvert = 2;
|
2008-12-20 13:12:57 +00:00
|
|
|
|
DrawPanel->Refresh();
|
2007-09-15 04:25:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_VIEW_DOC:
|
2009-09-22 12:27:57 +00:00
|
|
|
|
if( m_currentComponent )
|
2007-09-15 04:25:54 +00:00
|
|
|
|
{
|
|
|
|
|
wxString docfilename;
|
|
|
|
|
if( !CurrentAliasName.IsEmpty() )
|
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
|
CMP_LIB_ENTRY* entry = CurrentLib->FindEntry( CurrentAliasName );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( entry != NULL )
|
|
|
|
|
docfilename = entry->m_DocFile;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2009-09-22 12:27:57 +00:00
|
|
|
|
docfilename = m_currentComponent->m_DocFile;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
|
|
if( !docfilename.IsEmpty() )
|
2009-09-04 18:57:37 +00:00
|
|
|
|
GetAssociatedDocument( this, docfilename,
|
|
|
|
|
&wxGetApp().GetLibraryPathList() );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_EDIT_PIN_BY_PIN:
|
2008-12-30 19:18:56 +00:00
|
|
|
|
g_EditPinByPinIsOn = g_EditPinByPinIsOn ? false : true;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_EDIT:
|
|
|
|
|
InstallPineditFrame( this, &dc, pos );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_PIN_BUTT:
|
2009-09-22 12:27:57 +00:00
|
|
|
|
if( m_currentComponent )
|
2007-09-15 04:25:54 +00:00
|
|
|
|
{
|
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add Pin" ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-11-10 22:36:36 +00:00
|
|
|
|
SetToolID( id, wxCURSOR_ARROW, _( "Set Pin Options" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
InstallPineditFrame( this, &dc, pos );
|
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_CANCEL_EDITING:
|
|
|
|
|
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
|
|
|
|
else
|
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_NO_SELECT_BUTT:
|
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_TEXT_BUTT:
|
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add Text" ) );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_RECT_BUTT:
|
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add Rectangle" ) );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
|
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add Circle" ) );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_ARC_BUTT:
|
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add Arc" ) );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_LINE_BUTT:
|
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add Line" ) );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
|
|
|
|
|
SetToolID( id, wxCURSOR_HAND, _( "Anchor" ) );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_IMPORT_BODY_BUTT:
|
|
|
|
|
SetToolID( id, wxCURSOR_ARROW, _( "Import" ) );
|
2009-03-04 17:19:08 +00:00
|
|
|
|
LoadOneSymbol( );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_EXPORT_BODY_BUTT:
|
|
|
|
|
SetToolID( id, wxCURSOR_ARROW, _( "Export" ) );
|
|
|
|
|
SaveOneSymbol();
|
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
if( CurrentDrawItem )
|
|
|
|
|
{
|
|
|
|
|
EndDrawGraphicItem( &dc );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
|
|
|
|
|
if( CurrentDrawItem )
|
|
|
|
|
{
|
|
|
|
|
DrawPanel->CursorOff( &dc );
|
|
|
|
|
|
|
|
|
|
switch( CurrentDrawItem->Type() )
|
|
|
|
|
{
|
|
|
|
|
case COMPONENT_ARC_DRAW_TYPE:
|
|
|
|
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
|
|
|
|
case COMPONENT_RECT_DRAW_TYPE:
|
|
|
|
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
|
|
|
|
case COMPONENT_LINE_DRAW_TYPE:
|
|
|
|
|
EditGraphicSymbol( &dc, CurrentDrawItem );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
|
|
|
|
EditSymbolText( &dc, CurrentDrawItem );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawPanel->CursorOn( &dc );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_DELETE_ITEM_BUTT:
|
2009-09-22 12:27:57 +00:00
|
|
|
|
if( m_currentComponent == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
|
{
|
2009-09-02 18:12:45 +00:00
|
|
|
|
wxBell();
|
|
|
|
|
break;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
|
|
|
|
|
// Delete the last created segment, while creating a polyline draw item
|
|
|
|
|
if( CurrentDrawItem == NULL )
|
|
|
|
|
break;
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
DeleteDrawPoly( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_ITEM:
|
|
|
|
|
if( CurrentDrawItem == NULL )
|
|
|
|
|
break;
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
DrawPanel->CursorOff( &dc );
|
2009-09-22 12:27:57 +00:00
|
|
|
|
SaveCopyInUndoList( m_currentComponent );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
if( CurrentDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
|
DeletePin( &dc, m_currentComponent, (LibDrawPin*) CurrentDrawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
|
|
|
|
else
|
2009-09-22 12:27:57 +00:00
|
|
|
|
m_currentComponent->RemoveDrawItem( CurrentDrawItem, DrawPanel,
|
|
|
|
|
&dc );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CurrentDrawItem = NULL;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
GetScreen()->SetModify();
|
2007-09-15 04:25:54 +00:00
|
|
|
|
DrawPanel->CursorOn( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST:
|
|
|
|
|
if( CurrentDrawItem == NULL )
|
|
|
|
|
break;
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
if( CurrentDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
StartMovePin( &dc );
|
|
|
|
|
else if( CurrentDrawItem->Type() == COMPONENT_FIELD_DRAW_TYPE )
|
|
|
|
|
StartMoveField( &dc, (LibDrawField*) CurrentDrawItem );
|
|
|
|
|
else
|
|
|
|
|
StartMoveDrawSymbol( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT:
|
|
|
|
|
if( CurrentDrawItem == NULL )
|
|
|
|
|
break;
|
|
|
|
|
DrawPanel->CursorOff( &dc );
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
if( (CurrentDrawItem->m_Flags & IS_NEW) == 0 )
|
2009-09-22 12:27:57 +00:00
|
|
|
|
SaveCopyInUndoList( m_currentComponent );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
RotateSymbolText( &dc );
|
|
|
|
|
DrawPanel->CursorOn( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM:
|
|
|
|
|
if( CurrentDrawItem == NULL )
|
|
|
|
|
break;
|
|
|
|
|
DrawPanel->CursorOff( &dc );
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
if( CurrentDrawItem->Type() == COMPONENT_FIELD_DRAW_TYPE )
|
|
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
|
SaveCopyInUndoList( m_currentComponent );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
RotateField( &dc, (LibDrawField*) CurrentDrawItem );
|
|
|
|
|
}
|
|
|
|
|
DrawPanel->CursorOn( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM:
|
|
|
|
|
if( CurrentDrawItem == NULL )
|
|
|
|
|
break;
|
|
|
|
|
DrawPanel->CursorOff( &dc );
|
|
|
|
|
if( CurrentDrawItem->Type() == COMPONENT_FIELD_DRAW_TYPE )
|
|
|
|
|
{
|
|
|
|
|
EditField( &dc, (LibDrawField*) CurrentDrawItem );
|
|
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2007-09-15 04:25:54 +00:00
|
|
|
|
DrawPanel->CursorOn( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( (CurrentDrawItem == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|| (CurrentDrawItem->Type() != COMPONENT_PIN_DRAW_TYPE) )
|
|
|
|
|
break;
|
2009-09-22 12:27:57 +00:00
|
|
|
|
SaveCopyInUndoList( m_currentComponent );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
GlobalSetPins( &dc, (LibDrawPin*) CurrentDrawItem, id );
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
2008-12-30 19:18:56 +00:00
|
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2009-07-25 04:53:39 +00:00
|
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
2008-12-30 19:18:56 +00:00
|
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2009-07-25 04:53:39 +00:00
|
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_DELETE;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_COPY_BLOCK:
|
2008-12-30 19:18:56 +00:00
|
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2009-07-25 04:53:39 +00:00
|
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_COPY;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_SELECT_ITEMS_BLOCK:
|
2008-12-30 19:18:56 +00:00
|
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2009-07-25 04:53:39 +00:00
|
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_SELECT_ITEMS_ONLY;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
2009-08-12 10:40:01 +00:00
|
|
|
|
case ID_POPUP_MIRROR_Y_BLOCK:
|
2008-12-30 19:18:56 +00:00
|
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2009-08-12 10:40:01 +00:00
|
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_MIRROR_Y;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
2008-12-30 19:18:56 +00:00
|
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2009-09-04 18:57:37 +00:00
|
|
|
|
DisplayError( this,
|
|
|
|
|
wxT( "WinEDA_LibeditFrame::Process_Special_Functions error" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = false;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
|
|
if( m_ID_current_state == 0 )
|
|
|
|
|
LibItemToRepeat = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|