Commit 79c9be25 authored by stambaughw's avatar stambaughw

Replace PriorQue with boost::ptr_vector for component library entries.

* Replaced WinEDAListBox buttons with wxStdDialogButtonSizer.
* Moved library draw entries GenCopy method to base class.
* Remove priorque.cpp and priorque.h from CMakeLists.txt.
* The usual code cleaning and uncrustification.
parent 27a0c73c
...@@ -40,17 +40,13 @@ END_EVENT_TABLE() ...@@ -40,17 +40,13 @@ END_EVENT_TABLE()
*/ */
WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title, WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title,
const wxChar** itemlist, const wxChar** itemlist, const wxString& reftext,
const wxString& reftext,
void(* movefct)(wxString& Text) , void(* movefct)(wxString& Text) ,
const wxColour& colour, wxPoint dialog_position ) : const wxColour& colour, wxPoint dialog_position ) :
wxDialog( parent, -1, title, dialog_position, wxDefaultSize, wxDialog( parent, -1, title, dialog_position, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER )
)
{ {
wxSize size;
const wxChar** names; const wxChar** names;
int ii;
m_ItemList = itemlist; m_ItemList = itemlist;
m_Parent = parent; m_Parent = parent;
...@@ -58,34 +54,12 @@ WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title, ...@@ -58,34 +54,12 @@ WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title,
m_WinMsg = NULL; m_WinMsg = NULL;
SetReturnCode( -1 ); SetReturnCode( -1 );
if( itemlist )
for( names = m_ItemList, ii = 0; *names != NULL; names++ )
ii++;
else
ii = 30;
wxBoxSizer* GeneralBoxSizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* GeneralBoxSizer = new wxBoxSizer( wxVERTICAL );
SetSizer( GeneralBoxSizer ); SetSizer( GeneralBoxSizer );
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); m_List = new wxListBox( this, ID_LISTBOX_LIST, wxDefaultPosition,
wxSize( 300, 200 ), 0, NULL,
GeneralBoxSizer->Add( MainBoxSizer, 0, wxGROW | wxEXPAND | wxALL, 1 );
wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
size.x = 200;
size.y = 350;
m_List = new wxListBox( this,
ID_LISTBOX_LIST,
wxDefaultPosition, size,
0, NULL,
wxLB_NEEDED_SB | wxLB_SINGLE | wxLB_HSCROLL ); wxLB_NEEDED_SB | wxLB_SINGLE | wxLB_HSCROLL );
if( colour != wxNullColour ) if( colour != wxNullColour )
...@@ -93,38 +67,33 @@ WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title, ...@@ -93,38 +67,33 @@ WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title,
m_List->SetBackgroundColour( colour ); m_List->SetBackgroundColour( colour );
m_List->SetForegroundColour( *wxBLACK ); m_List->SetForegroundColour( *wxBLACK );
} }
LeftBoxSizer->Add( m_List, 0, wxGROW | wxALL, 5 );
GeneralBoxSizer->Add( m_List, 0, wxGROW | wxALL, 5 );
if( itemlist ) if( itemlist )
for( names = m_ItemList, ii = 0; *names != NULL; names++, ii++ )
{ {
for( names = m_ItemList; *names != NULL; names++ )
m_List->Append( *names ); m_List->Append( *names );
} }
wxButton* butt = new wxButton( this, wxID_OK, _( "OK" ) );
RightBoxSizer->Add( butt, 0, wxGROW | wxALL, 5 );
butt->SetDefault();
butt = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
RightBoxSizer->Add( butt, 0, wxGROW | wxALL, 5 );
if( m_MoveFct ) if( m_MoveFct )
{ {
size.x = -1; m_WinMsg = new wxTextCtrl( this, -1, wxEmptyString,
size.y = 60; wxDefaultPosition, wxSize( -1, 60 ),
m_WinMsg = new wxTextCtrl( this, -1, wxEmptyString, wxDefaultPosition, wxTE_READONLY | wxTE_MULTILINE );
size, wxTE_READONLY | wxTE_MULTILINE );
GeneralBoxSizer->Add( m_WinMsg, 0, wxGROW | wxALL, 5 ); GeneralBoxSizer->Add( m_WinMsg, 0, wxGROW | wxALL, 5 );
} }
wxSizer* buttonSizer = CreateButtonSizer( wxOK | wxCANCEL );
if( buttonSizer )
GeneralBoxSizer->Add( buttonSizer, 0, wxGROW | wxALL, 5 );
GetSizer()->Fit( this ); GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
if( dialog_position == wxDefaultPosition ) // Put the window on the parent centre if( dialog_position == wxDefaultPosition )
{ {
Centre(); Centre();
} }
......
...@@ -101,7 +101,6 @@ set(EESCHEMA_SRCS ...@@ -101,7 +101,6 @@ set(EESCHEMA_SRCS
plothpgl.cpp plothpgl.cpp
plotps.cpp plotps.cpp
plotdxf.cpp plotdxf.cpp
priorque.cpp
read_from_file_schematic_items_descriptions.cpp read_from_file_schematic_items_descriptions.cpp
savelib.cpp savelib.cpp
save_schemas.cpp save_schemas.cpp
......
...@@ -512,7 +512,7 @@ void CopyMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) ...@@ -512,7 +512,7 @@ void CopyMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
if( item->m_Selected == 0 ) if( item->m_Selected == 0 )
continue; continue;
item->m_Selected = 0; item->m_Selected = 0;
LibEDA_BaseStruct* newitem = CopyDrawEntryStruct( item ); LibEDA_BaseStruct* newitem = item->GenCopy();
newitem->m_Selected = IS_SELECTED; newitem->m_Selected = IS_SELECTED;
newitem->SetNext( LibEntry->m_Drawings ); newitem->SetNext( LibEntry->m_Drawings );
LibEntry->m_Drawings = newitem; LibEntry->m_Drawings = newitem;
......
...@@ -168,7 +168,7 @@ bool LibDrawText::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[ ...@@ -168,7 +168,7 @@ bool LibDrawText::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[
} }
LibDrawText* LibDrawText::GenCopy() LibEDA_BaseStruct* LibDrawText::DoGenCopy()
{ {
LibDrawText* newitem = new LibDrawText(NULL); LibDrawText* newitem = new LibDrawText(NULL);
...@@ -185,7 +185,7 @@ LibDrawText* LibDrawText::GenCopy() ...@@ -185,7 +185,7 @@ LibDrawText* LibDrawText::GenCopy()
newitem->m_Bold = m_Bold; newitem->m_Bold = m_Bold;
newitem->m_HJustify = m_HJustify; newitem->m_HJustify = m_HJustify;
newitem->m_VJustify = m_VJustify; newitem->m_VJustify = m_VJustify;
return newitem; return (LibEDA_BaseStruct*) newitem;
} }
...@@ -247,4 +247,3 @@ void LibDrawText::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -247,4 +247,3 @@ void LibDrawText::DisplayInfo( WinEDA_DrawFrame* frame )
frame->MsgPanel->Affiche_1_Parametre( 20, _( "Line width" ), msg, BLUE ); frame->MsgPanel->Affiche_1_Parametre( 20, _( "Line width" ), msg, BLUE );
} }
...@@ -179,13 +179,13 @@ bool LibCmpEntry::operator==( const wxChar* name ) const ...@@ -179,13 +179,13 @@ bool LibCmpEntry::operator==( const wxChar* name ) const
} }
bool operator<( LibCmpEntry& item1, LibCmpEntry& item2 ) bool operator<( const LibCmpEntry& item1, const LibCmpEntry& item2 )
{ {
return item1.m_Name.m_Text.CmpNoCase( item2.m_Name.m_Text ) == -1; return item1.m_Name.m_Text.CmpNoCase( item2.m_Name.m_Text ) < 0;
} }
int LibraryEntryCompare( LibCmpEntry* LE1, LibCmpEntry* LE2 ) int LibraryEntryCompare( const LibCmpEntry* LE1, const LibCmpEntry* LE2 )
{ {
return LE1->m_Name.m_Text.CmpNoCase( LE2->m_Name.m_Text ); return LE1->m_Name.m_Text.CmpNoCase( LE2->m_Name.m_Text );
} }
......
...@@ -16,13 +16,15 @@ ...@@ -16,13 +16,15 @@
/* Types for components in libraries /* Types for components in libraries
* components can be a true component or an alias of a true component. * components can be a true component or an alias of a true component.
*/ */
enum LibrEntryType { enum LibrEntryType
{
ROOT, /* This is a true component standard EDA_LibComponentStruct */ ROOT, /* This is a true component standard EDA_LibComponentStruct */
ALIAS /* This is an alias of a true component */ ALIAS /* This is an alias of a true component */
}; };
/* values for member .m_Options */ /* values for member .m_Options */
enum LibrEntryOptions { enum LibrEntryOptions
{
ENTRY_NORMAL, // Libentry is a standard component (real or alias) ENTRY_NORMAL, // Libentry is a standard component (real or alias)
ENTRY_POWER // Libentry is a power symbol ENTRY_POWER // Libentry is a power symbol
}; };
...@@ -76,9 +78,10 @@ public: ...@@ -76,9 +78,10 @@ public:
typedef boost::ptr_vector< LibCmpEntry > LIB_ENTRY_LIST; typedef boost::ptr_vector< LibCmpEntry > LIB_ENTRY_LIST;
extern bool operator<( LibCmpEntry& item1, LibCmpEntry& item2 ); extern bool operator<( const LibCmpEntry& item1, const LibCmpEntry& item2 );
extern int LibraryEntryCompare( LibCmpEntry* LE1, LibCmpEntry* LE2 ); extern int LibraryEntryCompare( const LibCmpEntry* LE1,
const LibCmpEntry* LE2 );
/** /**
...@@ -173,7 +176,7 @@ public: ...@@ -173,7 +176,7 @@ public:
* *
* @todo Alias objects should really be defined as children of a component * @todo Alias objects should really be defined as children of a component
* object not as children of a library object. This would greatly * object not as children of a library object. This would greatly
* simply searching for components in libraries. * simplify searching for components in libraries.
*/ */
class EDA_LibCmpAliasStruct : public LibCmpEntry class EDA_LibCmpAliasStruct : public LibCmpEntry
{ {
......
...@@ -347,13 +347,13 @@ bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat ...@@ -347,13 +347,13 @@ bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat
} }
// Creation et Duplication d'un field // Creation et Duplication d'un field
LibDrawField* LibDrawField::GenCopy() LibEDA_BaseStruct* LibDrawField::DoGenCopy()
{ {
LibDrawField* newfield = new LibDrawField( m_FieldId ); LibDrawField* newfield = new LibDrawField( m_FieldId );
Copy( newfield ); Copy( newfield );
return newfield; return (LibEDA_BaseStruct*) newfield;
} }
......
...@@ -58,8 +58,6 @@ public: ...@@ -58,8 +58,6 @@ public:
virtual bool Save( FILE* aFile ) const; virtual bool Save( FILE* aFile ) const;
virtual bool Load( char* line, wxString& errorMsg ); virtual bool Load( char* line, wxString& errorMsg );
LibDrawField* GenCopy();
/** Function Copy /** Function Copy
* copy parameters of this to Target. Pointers are not copied * copy parameters of this to Target. Pointers are not copied
* @param aTarget = the LibDrawField to set with "this" values * @param aTarget = the LibDrawField to set with "this" values
...@@ -104,6 +102,9 @@ public: ...@@ -104,6 +102,9 @@ public:
m_VJustify = field.m_VJustify; m_VJustify = field.m_VJustify;
m_Parent = field.m_Parent; m_Parent = field.m_Parent;
} }
protected:
virtual LibEDA_BaseStruct* DoGenCopy();
}; };
#endif // CLASS_LIBENTRY_FIELDS_H #endif // CLASS_LIBENTRY_FIELDS_H
This diff is collapsed.
...@@ -9,9 +9,12 @@ ...@@ -9,9 +9,12 @@
#include "class_libentry.h" #include "class_libentry.h"
/******************************/ /**
/* Class to handle a library */ * Component library object.
/******************************/ *
* Component libraries are used to load, save, search, and otherwise manipulate
* component library files.
*/
class LibraryStruct class LibraryStruct
{ {
...@@ -20,10 +23,7 @@ public: ...@@ -20,10 +23,7 @@ public:
wxString m_Name; /* Library file name (without path). */ wxString m_Name; /* Library file name (without path). */
wxString m_FullFileName; /* Full File Name (with path) of library. */ wxString m_FullFileName; /* Full File Name (with path) of library. */
wxString m_Header; /* first line of loaded library. */ wxString m_Header; /* first line of loaded library. */
int m_NumOfParts; /* Number of parts this library has. */
LibraryStruct* m_Pnext; /* Point on next lib in chain. */ LibraryStruct* m_Pnext; /* Point on next lib in chain. */
int m_Modified; /* flag indicateur d'edition */
int m_Size; // Size in bytes (for statistics)
unsigned long m_TimeStamp; // Signature temporelle unsigned long m_TimeStamp; // Signature temporelle
int m_Flags; // variable used in some functions int m_Flags; // variable used in some functions
bool m_IsLibCache; /* False for the "standard" libraries, bool m_IsLibCache; /* False for the "standard" libraries,
...@@ -46,14 +46,26 @@ public: ...@@ -46,14 +46,26 @@ public:
* *
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool SaveLibrary( const wxString& aFullFileName ); bool Save( const wxString& aFullFileName );
bool ReadHeader( FILE* file, int* LineNum );
/**
* Load library from file.
*
* @param errMsg - Error message if load fails.
*
* @return bool - True if load was successful otherwise false.
*/
bool Load( wxString& errMsg ); bool Load( wxString& errMsg );
void InsertAliases( PriorQue** PQ, EDA_LibComponentStruct* component );
bool LoadDocs( wxString& errMsg );
private: private:
bool WriteHeader( FILE* file ); bool SaveHeader( FILE* file );
bool LoadHeader( FILE* file, int* LineNum );
void LoadAliases( EDA_LibComponentStruct* component );
void RemoveEntry( const wxString& name );
public: public:
LibraryStruct( const wxChar* fileName = NULL ); LibraryStruct( const wxChar* fileName = NULL );
...@@ -65,7 +77,22 @@ public: ...@@ -65,7 +77,22 @@ public:
*/ */
bool IsEmpty() bool IsEmpty()
{ {
return m_Entries == NULL; return m_Entries.empty();
}
/**
* Get the number of entries in the library.
*
* @return The number of component and alias entries.
*/
int GetCount()
{
return m_Entries.size();
}
bool IsModified()
{
return m_IsModified;
} }
/** /**
...@@ -73,8 +100,10 @@ public: ...@@ -73,8 +100,10 @@ public:
* *
* @param names - String array to place entry names into. * @param names - String array to place entry names into.
* @param sort - Sort names if true. * @param sort - Sort names if true.
* @param makeUpperCase - Force entry names to upper case.
*/ */
void GetEntryNames( wxArrayString& names, bool sort = true ); void GetEntryNames( wxArrayString& names, bool sort = true,
bool makeUpperCase = true );
/** /**
* Load string array with entry names matching name and/or key word. * Load string array with entry names matching name and/or key word.
...@@ -150,7 +179,7 @@ public: ...@@ -150,7 +179,7 @@ public:
*/ */
LibCmpEntry* GetFirstEntry() LibCmpEntry* GetFirstEntry()
{ {
return (LibCmpEntry*) PQFirst( &m_Entries, false ); return &m_Entries.front();
} }
/** /**
...@@ -180,23 +209,19 @@ public: ...@@ -180,23 +209,19 @@ public:
*/ */
LibCmpEntry* GetPreviousEntry( const wxChar* name ); LibCmpEntry* GetPreviousEntry( const wxChar* name );
bool Save( const wxString& saveAsFile );
wxString GetName(); wxString GetName();
protected: protected:
wxFileName m_fileName; /* Library file name. */ wxFileName m_fileName; /* Library file name. */
wxDateTime m_DateTime; /* Library save time and date. */ wxDateTime m_DateTime; /* Library save time and date. */
wxString m_Version; /* Library save version. */ wxString m_Version; /* Library save version. */
PriorQue* m_Entries; /* Parts themselves are saved here. */ LIB_ENTRY_LIST m_Entries; /* Parts themselves are saved here. */
bool m_IsModified; /* Library modification status. */
friend class EDA_LibComponentStruct; friend class EDA_LibComponentStruct;
}; };
extern void FreeLibraryEntry( LibCmpEntry* Entry );
/** /**
* Case insensitive library name comparison. * Case insensitive library name comparison.
*/ */
......
...@@ -73,7 +73,8 @@ bool LibDrawPin::HitTest( const wxPoint& aRefPos ) ...@@ -73,7 +73,8 @@ bool LibDrawPin::HitTest( const wxPoint& aRefPos )
* @param aThreshold = max distance to a segment * @param aThreshold = max distance to a segment
* @param aTransMat = the transform matrix * @param aTransMat = the transform matrix
*/ */
bool LibDrawPin::HitTest( wxPoint aRefPos, int aThreshold, const int aTransMat[2][2] ) bool LibDrawPin::HitTest( wxPoint aRefPos, int aThreshold,
const int aTransMat[2][2] )
{ {
wxPoint pinPos = TransformCoordinate( aTransMat, m_Pos ); wxPoint pinPos = TransformCoordinate( aTransMat, m_Pos );
wxPoint pinEnd = TransformCoordinate( aTransMat, ReturnPinEndPoint() ); wxPoint pinEnd = TransformCoordinate( aTransMat, ReturnPinEndPoint() );
...@@ -286,7 +287,6 @@ int LibDrawPin::GetPenSize( ) ...@@ -286,7 +287,6 @@ int LibDrawPin::GetPenSize( )
} }
/**********************************************************************************************/
void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel, void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
wxDC* aDC, wxDC* aDC,
const wxPoint& aOffset, const wxPoint& aOffset,
...@@ -294,10 +294,9 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel, ...@@ -294,10 +294,9 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
int aDrawMode, int aDrawMode,
void* aData, void* aData,
const int aTransformMatrix[2][2] ) const int aTransformMatrix[2][2] )
/**********************************************************************************************/
{ {
// Invisibles pins are only drawn on request. // Invisible pins are only drawn on request. In libedit they are drawn
// But in libedit they are drawn in g_InvisibleItemColor because we must see them // in g_InvisibleItemColor because we must see them.
WinEDA_SchematicFrame* frame = WinEDA_SchematicFrame* frame =
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow(); (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
...@@ -312,7 +311,7 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel, ...@@ -312,7 +311,7 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
EDA_LibComponentStruct* Entry = ( (DrawPinPrms*) aData )->m_Entry; EDA_LibComponentStruct* Entry = ( (DrawPinPrms*) aData )->m_Entry;
bool DrawPinText = ( (DrawPinPrms*) aData )->m_DrawPinText; bool DrawPinText = ( (DrawPinPrms*) aData )->m_DrawPinText;
/* Calculate Pin orient takin in account the component orientation */ /* Calculate pin orient taking in account the component orientation. */
int orient = ReturnPinDrawOrient( aTransformMatrix ); int orient = ReturnPinDrawOrient( aTransformMatrix );
/* Calculate the pin position */ /* Calculate the pin position */
...@@ -655,8 +654,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -655,8 +654,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
if( DrawPinName ) if( DrawPinName )
{ {
x = (x1 + pin_pos.x) / 2; x = (x1 + pin_pos.x) / 2;
DrawGraphicText( panel, DC, wxPoint( x, DrawGraphicText( panel, DC, wxPoint( x, y1 - TXTMARGE ),
y1 - TXTMARGE ),
NameColor, m_PinName, NameColor, m_PinName,
TEXT_ORIENT_HORIZ, PinNameSize, TEXT_ORIENT_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
...@@ -666,8 +664,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -666,8 +664,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
if( DrawPinNum ) if( DrawPinNum )
{ {
x = (x1 + pin_pos.x) / 2; x = (x1 + pin_pos.x) / 2;
DrawGraphicText( panel, DC, wxPoint( x, DrawGraphicText( panel, DC, wxPoint( x, y1 + TXTMARGE ),
y1 + TXTMARGE ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
...@@ -680,8 +677,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -680,8 +677,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
if( DrawPinName ) if( DrawPinName )
{ {
y = (y1 + pin_pos.y) / 2; y = (y1 + pin_pos.y) / 2;
DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE, DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE, y ),
y ),
NameColor, m_PinName, NameColor, m_PinName,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
...@@ -692,8 +688,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -692,8 +688,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
if( DrawPinNum ) if( DrawPinNum )
{ {
DrawGraphicText( panel, DC, DrawGraphicText( panel, DC,
wxPoint( x1 + TXTMARGE, wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ),
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
...@@ -784,7 +779,8 @@ void LibDrawPin::PlotPinTexts( PLOTTER *plotter, ...@@ -784,7 +779,8 @@ void LibDrawPin::PlotPinTexts( PLOTTER *plotter,
} }
if( DrawPinNum ) if( DrawPinNum )
{ {
plotter->text( wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ), plotter->text( wxPoint( (x1 + pin_pos.x) / 2,
y1 - TXTMARGE ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
...@@ -1018,7 +1014,7 @@ void LibDrawPin::SetPinNumFromString( wxString& buffer ) ...@@ -1018,7 +1014,7 @@ void LibDrawPin::SetPinNumFromString( wxString& buffer )
/*************************************/ /*************************************/
LibDrawPin* LibDrawPin::GenCopy() LibEDA_BaseStruct* LibDrawPin::DoGenCopy()
/*************************************/ /*************************************/
{ {
LibDrawPin* newpin = new LibDrawPin( GetParent() ); LibDrawPin* newpin = new LibDrawPin( GetParent() );
...@@ -1043,7 +1039,7 @@ LibDrawPin* LibDrawPin::GenCopy() ...@@ -1043,7 +1039,7 @@ LibDrawPin* LibDrawPin::GenCopy()
newpin->m_PinName = m_PinName; newpin->m_PinName = m_PinName;
return newpin; return (LibEDA_BaseStruct*) newpin;
} }
......
...@@ -218,7 +218,7 @@ bool LibDrawArc::HitTest( wxPoint aRefPoint, int aThreshold, const int aTransMat ...@@ -218,7 +218,7 @@ bool LibDrawArc::HitTest( wxPoint aRefPoint, int aThreshold, const int aTransMat
} }
LibDrawArc* LibDrawArc::GenCopy() LibEDA_BaseStruct* LibDrawArc::DoGenCopy()
{ {
LibDrawArc* newitem = new LibDrawArc( GetParent() ); LibDrawArc* newitem = new LibDrawArc( GetParent() );
...@@ -233,7 +233,7 @@ LibDrawArc* LibDrawArc::GenCopy() ...@@ -233,7 +233,7 @@ LibDrawArc* LibDrawArc::GenCopy()
newitem->m_Convert = m_Convert; newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill; newitem->m_Fill = m_Fill;
return newitem; return (LibEDA_BaseStruct*) newitem;
} }
...@@ -477,7 +477,7 @@ bool LibDrawCircle::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMa ...@@ -477,7 +477,7 @@ bool LibDrawCircle::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMa
} }
LibDrawCircle* LibDrawCircle::GenCopy() LibEDA_BaseStruct* LibDrawCircle::DoGenCopy()
{ {
LibDrawCircle* newitem = new LibDrawCircle( GetParent() ); LibDrawCircle* newitem = new LibDrawCircle( GetParent() );
...@@ -488,7 +488,7 @@ LibDrawCircle* LibDrawCircle::GenCopy() ...@@ -488,7 +488,7 @@ LibDrawCircle* LibDrawCircle::GenCopy()
newitem->m_Convert = m_Convert; newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill; newitem->m_Fill = m_Fill;
return newitem; return (LibEDA_BaseStruct*) newitem;
} }
...@@ -619,7 +619,7 @@ bool LibDrawSquare::Load( char* line, wxString& errorMsg ) ...@@ -619,7 +619,7 @@ bool LibDrawSquare::Load( char* line, wxString& errorMsg )
} }
LibDrawSquare* LibDrawSquare::GenCopy() LibEDA_BaseStruct* LibDrawSquare::DoGenCopy()
{ {
LibDrawSquare* newitem = new LibDrawSquare( GetParent() ); LibDrawSquare* newitem = new LibDrawSquare( GetParent() );
...@@ -630,7 +630,7 @@ LibDrawSquare* LibDrawSquare::GenCopy() ...@@ -630,7 +630,7 @@ LibDrawSquare* LibDrawSquare::GenCopy()
newitem->m_Convert = m_Convert; newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill; newitem->m_Fill = m_Fill;
return newitem; return (LibEDA_BaseStruct*) newitem;
} }
...@@ -788,7 +788,7 @@ bool LibDrawSegment::Load( char* line, wxString& errorMsg ) ...@@ -788,7 +788,7 @@ bool LibDrawSegment::Load( char* line, wxString& errorMsg )
} }
LibDrawSegment* LibDrawSegment::GenCopy() LibEDA_BaseStruct* LibDrawSegment::DoGenCopy()
{ {
LibDrawSegment* newitem = new LibDrawSegment( GetParent() ); LibDrawSegment* newitem = new LibDrawSegment( GetParent() );
...@@ -798,7 +798,7 @@ LibDrawSegment* LibDrawSegment::GenCopy() ...@@ -798,7 +798,7 @@ LibDrawSegment* LibDrawSegment::GenCopy()
newitem->m_Unit = m_Unit; newitem->m_Unit = m_Unit;
newitem->m_Convert = m_Convert; newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
return newitem; return (LibEDA_BaseStruct*) newitem;
} }
...@@ -976,7 +976,7 @@ bool LibDrawPolyline::Load( char* line, wxString& errorMsg ) ...@@ -976,7 +976,7 @@ bool LibDrawPolyline::Load( char* line, wxString& errorMsg )
} }
LibDrawPolyline* LibDrawPolyline::GenCopy() LibEDA_BaseStruct* LibDrawPolyline::DoGenCopy()
{ {
LibDrawPolyline* newitem = new LibDrawPolyline( GetParent() ); LibDrawPolyline* newitem = new LibDrawPolyline( GetParent() );
...@@ -986,7 +986,7 @@ LibDrawPolyline* LibDrawPolyline::GenCopy() ...@@ -986,7 +986,7 @@ LibDrawPolyline* LibDrawPolyline::GenCopy()
newitem->m_Convert = m_Convert; newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill; newitem->m_Fill = m_Fill;
return newitem; return (LibEDA_BaseStruct*) newitem;
} }
...@@ -1238,7 +1238,7 @@ bool LibDrawBezier::Load( char* line, wxString& errorMsg ) ...@@ -1238,7 +1238,7 @@ bool LibDrawBezier::Load( char* line, wxString& errorMsg )
} }
LibDrawBezier* LibDrawBezier::GenCopy() LibEDA_BaseStruct* LibDrawBezier::DoGenCopy()
{ {
LibDrawBezier* newitem = new LibDrawBezier(GetParent()); LibDrawBezier* newitem = new LibDrawBezier(GetParent());
...@@ -1248,7 +1248,7 @@ LibDrawBezier* LibDrawBezier::GenCopy() ...@@ -1248,7 +1248,7 @@ LibDrawBezier* LibDrawBezier::GenCopy()
newitem->m_Convert = m_Convert; newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill; newitem->m_Fill = m_Fill;
return newitem; return (LibEDA_BaseStruct*) newitem;
} }
/** Function GetPenSize /** Function GetPenSize
......
This diff is collapsed.
...@@ -77,13 +77,22 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys, ...@@ -77,13 +77,22 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
void DisplayCmpDoc( wxString& Name ) void DisplayCmpDoc( wxString& Name )
{ {
LibCmpEntry* CmpEntry; LibCmpEntry* CmpEntry = NULL;
LibraryStruct* Lib = g_LibraryList;
CmpEntry = FindLibPart( Name, wxEmptyString, ALIAS ); while( Lib != NULL && CmpEntry == NULL )
{
CmpEntry = Lib->FindEntry( Name );
Lib = Lib->m_Pnext;
}
if( CmpEntry == NULL ) if( CmpEntry == NULL )
return; return;
wxLogDebug( wxT( "Selected component <%s>, m_Doc: <%s>, m_KeyWord: <%s>." ),
(const wxChar*) Name, (const wxChar*) CmpEntry->m_Doc,
(const wxChar*) CmpEntry->m_KeyWord );
Name = wxT( "Description: " ) + CmpEntry->m_Doc; Name = wxT( "Description: " ) + CmpEntry->m_Doc;
Name += wxT( "\nKey Words: " ) + CmpEntry->m_KeyWord; Name += wxT( "\nKey Words: " ) + CmpEntry->m_KeyWord;
} }
...@@ -452,7 +452,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit ) ...@@ -452,7 +452,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
{ {
for( ii = OldNumUnits + 1; ii <= MaxUnit; ii++ ) for( ii = OldNumUnits + 1; ii <= MaxUnit; ii++ )
{ {
NextDrawItem = CopyDrawEntryStruct( DrawItem ); NextDrawItem = DrawItem->GenCopy();
NextDrawItem->SetNext( CurrentLibEntry->m_Drawings ); NextDrawItem->SetNext( CurrentLibEntry->m_Drawings );
CurrentLibEntry->m_Drawings = NextDrawItem; CurrentLibEntry->m_Drawings = NextDrawItem;
NextDrawItem->m_Unit = ii; NextDrawItem->m_Unit = ii;
...@@ -499,7 +499,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert() ...@@ -499,7 +499,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
g_AsDeMorgan = 0; return FALSE; g_AsDeMorgan = 0; return FALSE;
} }
} }
NextDrawItem = CopyDrawEntryStruct( DrawItem ); NextDrawItem = DrawItem->GenCopy();
NextDrawItem->SetNext( CurrentLibEntry->m_Drawings ); NextDrawItem->SetNext( CurrentLibEntry->m_Drawings );
CurrentLibEntry->m_Drawings = NextDrawItem; CurrentLibEntry->m_Drawings = NextDrawItem;
NextDrawItem->m_Convert = 2; NextDrawItem->m_Convert = 2;
......
...@@ -18,15 +18,15 @@ ...@@ -18,15 +18,15 @@
#include "dialog_load_error.h" #include "dialog_load_error.h"
/****************************************************************************/ /**
* Function LoadLibraryName
/** Function LoadLibraryName *
* Routine to load the given library name. FullLibName should hold full path * Routine to load the given library name. FullLibName should hold full path
* of file name to open, while LibName should hold only its name. * of file name to open, while LibName should hold only its name.
* If library already exists, it is NOT reloaded. * If library already exists, it is NOT reloaded.
*
* @return : new lib or NULL * @return : new lib or NULL
*/ */
/****************************************************************************/
LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame, LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
const wxString& FullLibName, const wxString& FullLibName,
const wxString& LibName ) const wxString& LibName )
...@@ -60,9 +60,7 @@ LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame, ...@@ -60,9 +60,7 @@ LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
tmplib->m_Pnext = NewLib; tmplib->m_Pnext = NewLib;
} }
fn = FullLibName; NewLib->LoadDocs( errMsg );
fn.SetExt( DOC_EXT );
LoadDocLib( frame, fn.GetFullPath(), NewLib->m_Name );
} }
else else
{ {
...@@ -79,7 +77,9 @@ library <%s>" ), ...@@ -79,7 +77,9 @@ library <%s>" ),
} }
/** Function LoadLibraries /**
* Function LoadLibraries
*
* Clear all already loaded libraries and load all librairies * Clear all already loaded libraries and load all librairies
* given in frame->m_ComponentLibFiles * given in frame->m_ComponentLibFiles
*/ */
...@@ -200,12 +200,11 @@ void LoadLibraries( WinEDA_SchematicFrame* frame ) ...@@ -200,12 +200,11 @@ void LoadLibraries( WinEDA_SchematicFrame* frame )
} }
/**************************************************************/ /**
* Function FreeCmpLibrary
/** Function FreeCmpLibrary *
* Routine to remove and free a library from the current loaded libraries. * Routine to remove and free a library from the current loaded libraries.
*/ */
/**************************************************************/
void FreeCmpLibrary( wxWindow* frame, const wxString& LibName ) void FreeCmpLibrary( wxWindow* frame, const wxString& LibName )
{ {
int NumOfLibs = NumOfLibraries(); int NumOfLibs = NumOfLibraries();
...@@ -247,7 +246,9 @@ void FreeCmpLibrary( wxWindow* frame, const wxString& LibName ) ...@@ -247,7 +246,9 @@ void FreeCmpLibrary( wxWindow* frame, const wxString& LibName )
} }
/** Function LibraryEntryCompare /**
* Function LibraryEntryCompare
*
* Routine to compare two EDA_LibComponentStruct for the PriorQue module. * Routine to compare two EDA_LibComponentStruct for the PriorQue module.
* Comparison (insensitive case) is based on Part name. * Comparison (insensitive case) is based on Part name.
*/ */
...@@ -259,8 +260,8 @@ int LibraryEntryCompare( EDA_LibComponentStruct* LE1, ...@@ -259,8 +260,8 @@ int LibraryEntryCompare( EDA_LibComponentStruct* LE1,
/***************************************************************************** /*****************************************************************************
* Routine to find the library given its name. * * Routine to find the library given its name.
*****************************************************************************/ *****************************************************************************/
LibraryStruct* FindLibrary( const wxString& Name ) LibraryStruct* FindLibrary( const wxString& Name )
{ {
LibraryStruct* Lib = g_LibraryList; LibraryStruct* Lib = g_LibraryList;
...@@ -277,8 +278,8 @@ LibraryStruct* FindLibrary( const wxString& Name ) ...@@ -277,8 +278,8 @@ LibraryStruct* FindLibrary( const wxString& Name )
/***************************************************************************** /*****************************************************************************
* Routine to find the number of libraries currently loaded. * * Routine to find the number of libraries currently loaded.
*****************************************************************************/ *****************************************************************************/
int NumOfLibraries() int NumOfLibraries()
{ {
int ii; int ii;
...@@ -289,83 +290,3 @@ int NumOfLibraries() ...@@ -289,83 +290,3 @@ int NumOfLibraries()
return ii; return ii;
} }
/*******************************************************/
/* Routines de lecture des Documentation de composants */
/*******************************************************/
/* Routine to load a library from given open file.*/
int LoadDocLib( WinEDA_DrawFrame* frame, const wxString& FullDocLibName,
const wxString& Libname )
{
int LineNum = 0;
char Line[1024], * Name, * Text;
LibCmpEntry* Entry;
FILE* f;
wxString msg;
f = wxFopen( FullDocLibName, wxT( "rt" ) );
if( f == NULL )
return 0;
if( GetLine( f, Line, &LineNum, sizeof(Line) ) == NULL )
{
/* pas de lignes utiles */
fclose( f );
return 0;
}
if( strnicmp( Line, DOCFILE_IDENT, 10 ) != 0 )
{
DisplayError( frame, wxT( "File is NOT EESCHEMA doclib!" ) );
fclose( f );
return 0;
}
while( GetLine( f, Line, &LineNum, sizeof(Line) ) )
{
if( strncmp( Line, "$CMP", 4 ) != 0 )
{
msg.Printf( wxT( "$CMP command expected in line %d, aborted." ),
LineNum );
DisplayError( frame, msg );
fclose( f );
return 0;
}
/* Read one $CMP/$ENDCMP part entry from library: */
Name = strtok( Line + 5, "\n\r" );
wxString cmpname;
cmpname = CONV_FROM_UTF8( Name );
Entry = FindLibPart( cmpname, Libname, ALIAS );
while( GetLine( f, Line, &LineNum, sizeof(Line) ) )
{
if( strncmp( Line, "$ENDCMP", 7 ) == 0 )
break;
Text = strtok( Line + 2, "\n\r" );
switch( Line[0] )
{
case 'D':
if( Entry )
Entry->m_Doc = CONV_FROM_UTF8( Text );
break;
case 'K':
if( Entry )
Entry->m_KeyWord = CONV_FROM_UTF8( Text );
break;
case 'F':
if( Entry )
Entry->m_DocFile = CONV_FROM_UTF8( Text );
break;
}
}
}
fclose( f );
return 1;
}
This diff is collapsed.
...@@ -127,7 +127,7 @@ void WinEDA_LibeditFrame::OnExportPart( wxCommandEvent& event ) ...@@ -127,7 +127,7 @@ void WinEDA_LibeditFrame::OnExportPart( wxCommandEvent& event )
/* Sauvegarde du composant: */ /* Sauvegarde du composant: */
CurrentLib = NewLib; CurrentLib = NewLib;
SaveOnePartInMemory(); SaveOnePartInMemory();
bool success = NewLib->SaveLibrary( fn.GetFullPath() ); bool success = NewLib->Save( fn.GetFullPath() );
if( success ) if( success )
{ {
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef LIBCMP_H #ifndef LIBCMP_H
#define LIBCMP_H #define LIBCMP_H
#include "priorque.h"
#define LIB_VERSION_MAJOR 2 #define LIB_VERSION_MAJOR 2
#define LIB_VERSION_MINOR 3 #define LIB_VERSION_MINOR 3
...@@ -14,7 +13,7 @@ ...@@ -14,7 +13,7 @@
#define DOC_EXT wxT( "dcm" ) /* Ext. of documentation files */ #define DOC_EXT wxT( "dcm" ) /* Ext. of documentation files */
//Offsets used in editing library component, for handle aliad dats //Offsets used in editing library component, for handle alias data
#define ALIAS_NAME 0 #define ALIAS_NAME 0
#define ALIAS_DOC 1 #define ALIAS_DOC 1
#define ALIAS_KEYWORD 2 #define ALIAS_KEYWORD 2
......
...@@ -86,7 +86,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart() ...@@ -86,7 +86,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart()
if( g_ScreenLib->IsModify() ) if( g_ScreenLib->IsModify() )
{ {
if( !IsOK( this, _( "Current Part not saved.\nContinue?" ) ) ) if( !IsOK( this, _( "Current part not saved.\nContinue?" ) ) )
return FALSE; return FALSE;
} }
...@@ -115,7 +115,8 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart() ...@@ -115,7 +115,8 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart()
if( LibEntry == NULL ) if( LibEntry == NULL )
{ {
msg = _( "Component \"" ); msg << CmpName << _( "\" not found." ); msg = _( "Component \"" );
msg << CmpName << _( "\" not found." );
DisplayError( this, msg ); DisplayError( this, msg );
return FALSE; return FALSE;
} }
...@@ -144,7 +145,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( LibCmpEntry* LibEntry, ...@@ -144,7 +145,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( LibCmpEntry* LibEntry,
{ {
wxString msg, cmpName, rootName; wxString msg, cmpName, rootName;
if( (LibEntry == NULL) || (Library == NULL) ) if( ( LibEntry == NULL ) || ( Library == NULL ) )
return false; return false;
if( LibEntry->m_Name.m_Text.IsEmpty() ) if( LibEntry->m_Name.m_Text.IsEmpty() )
...@@ -263,33 +264,33 @@ void WinEDA_LibeditFrame::SaveActiveLibrary() ...@@ -263,33 +264,33 @@ void WinEDA_LibeditFrame::SaveActiveLibrary()
if( CurrentLib == NULL ) if( CurrentLib == NULL )
{ {
DisplayError( this, wxT( "No Library specified" ) ); DisplayError( this, wxT( "No library specified" ) );
return; return;
} }
fn = wxFileName( CurrentLib->m_FullFileName ); fn = wxFileName( CurrentLib->m_FullFileName );
msg = _( "Modify Library File \"" ) + fn.GetFullPath() + _( "\"?" ); msg = _( "Modify library file \"" ) + fn.GetFullPath() + _( "\"?" );
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
return; return;
bool success = CurrentLib->SaveLibrary( fn.GetFullPath() ); bool success = CurrentLib->Save( fn.GetFullPath() );
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
if( !success ) if( !success )
{ {
msg = _( "Error while saving Library File \"" ) + fn.GetFullPath() + msg = _( "Error while saving library file \"" ) + fn.GetFullPath() +
_( "\"." ); _( "\"." );
Affiche_1_Parametre( this, 1, wxT( " *** ERROR : **" ), msg, BLUE ); Affiche_1_Parametre( this, 1, wxT( " *** ERROR : **" ), msg, BLUE );
DisplayError( this, msg ); DisplayError( this, msg );
} }
else else
{ {
msg = _( "Library File \"" ) + fn.GetFullName() + wxT( "\" Ok" ); msg = _( "Library file \"" ) + fn.GetFullName() + wxT( "\" Ok" );
fn.SetExt( DOC_EXT ); fn.SetExt( DOC_EXT );
wxString msg1 = _( "Document File \"" ) + fn.GetFullPath() + wxString msg1 = _( "Document file \"" ) + fn.GetFullPath() +
wxT( "\" Ok" ); wxT( "\" Ok" );
Affiche_1_Parametre( this, 1, msg, msg1, BLUE ); Affiche_1_Parametre( this, 1, msg, msg1, BLUE );
} }
...@@ -476,7 +477,7 @@ void WinEDA_LibeditFrame::SaveOnePartInMemory() ...@@ -476,7 +477,7 @@ void WinEDA_LibeditFrame::SaveOnePartInMemory()
if( CurrentLib == NULL ) if( CurrentLib == NULL )
{ {
DisplayError( this, _( "No Library specified." ) ); DisplayError( this, _( "No library specified." ) );
return; return;
} }
......
...@@ -200,7 +200,7 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -200,7 +200,7 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event )
for( Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext ) for( Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
{ {
if( Lib->m_Modified ) if( Lib->IsModified() )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Library \"%s\" was modified!\nDiscard changes?" ), msg.Printf( _( "Library \"%s\" was modified!\nDiscard changes?" ),
...@@ -352,7 +352,7 @@ int WinEDA_LibeditFrame::BestZoom() ...@@ -352,7 +352,7 @@ int WinEDA_LibeditFrame::BestZoom()
} }
size = DrawPanel->GetClientSize(); size = DrawPanel->GetClientSize();
size -= wxSize(100,100); // reserve 100 mils margin size -= wxSize( 100, 100 ); // reserve 100 mils margin
ii = abs( dx / size.x ); ii = abs( dx / size.x );
jj = abs( dy / size.y ); jj = abs( dy / size.y );
...@@ -659,7 +659,8 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -659,7 +659,8 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_LIBEDIT_DELETE_ITEM_BUTT: case ID_LIBEDIT_DELETE_ITEM_BUTT:
if( CurrentLibEntry == NULL ) if( CurrentLibEntry == NULL )
{ {
wxBell(); break; wxBell();
break;
} }
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) ); SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
break; break;
......
...@@ -68,13 +68,16 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event ) ...@@ -68,13 +68,16 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event )
LastPinNoDraw = m_NoDraw->GetValue(); LastPinNoDraw = m_NoDraw->GetValue();
msg = m_PinSizeCtrl->GetValue(); msg = m_PinSizeCtrl->GetValue();
LastPinSize = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits ); LastPinSize = ReturnValueFromString( g_UnitMetric, msg,
m_Parent->m_InternalUnits );
msg = m_PinNameSizeCtrl->GetValue(); msg = m_PinNameSizeCtrl->GetValue();
LastPinNameSize = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits ); LastPinNameSize = ReturnValueFromString( g_UnitMetric, msg,
m_Parent->m_InternalUnits );
msg = m_PinNumSizeCtrl->GetValue(); msg = m_PinNumSizeCtrl->GetValue();
LastPinNumSize = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits ); LastPinNumSize = ReturnValueFromString( g_UnitMetric, msg,
m_Parent->m_InternalUnits );
if( CurrentDrawItem ) // Set Pin Name & Num if( CurrentDrawItem ) // Set Pin Name & Num
{ {
...@@ -82,7 +85,8 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event ) ...@@ -82,7 +85,8 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event )
m_Parent->SaveCopyInUndoList( CurrentLibEntry ); m_Parent->SaveCopyInUndoList( CurrentLibEntry );
SetPinName( m_PinNameCtrl->GetValue(), LastPinNameSize ); SetPinName( m_PinNameCtrl->GetValue(), LastPinNameSize );
msg = m_PinNumCtrl->GetValue(); if( msg.IsEmpty() ) msg = m_PinNumCtrl->GetValue();
if( msg.IsEmpty() )
msg = wxT( "~" ); msg = wxT( "~" );
SetPinNum( msg, LastPinNumSize ); SetPinNum( msg, LastPinNumSize );
NewSizePin( LastPinSize ); NewSizePin( LastPinSize );
...@@ -126,10 +130,10 @@ void WinEDA_LibeditFrame::InitEditOnePin() ...@@ -126,10 +130,10 @@ void WinEDA_LibeditFrame::InitEditOnePin()
continue; continue;
if( Pin == CurrentPin ) if( Pin == CurrentPin )
continue; continue;
if( (Pin->m_Pos == CurrentPin->m_Pos) if( ( Pin->m_Pos == CurrentPin->m_Pos )
&& (Pin->m_Orient == CurrentPin->m_Orient) && ( Pin->m_Orient == CurrentPin->m_Orient )
&& ( !(CurrentPin->m_Flags & IS_NEW) ) && ( !( CurrentPin->m_Flags & IS_NEW ) )
&& (g_EditPinByPinIsOn == false) // This is set by the tool of the main toolbar && ( g_EditPinByPinIsOn == false ) // This is set by the tool of the main toolbar
) )
Pin->m_Flags |= IS_LINKED | IN_EDIT; Pin->m_Flags |= IS_LINKED | IN_EDIT;
else else
...@@ -150,7 +154,8 @@ static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -150,7 +154,8 @@ static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC )
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem; LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
if( CurrentPin && ( CurrentPin->m_Flags & IS_NEW ) ) if( CurrentPin && ( CurrentPin->m_Flags & IS_NEW ) )
DeleteOneLibraryDrawStruct( Panel, DC, CurrentLibEntry, CurrentPin, true ); DeleteOneLibraryDrawStruct( Panel, DC, CurrentLibEntry,
CurrentPin, true );
/* clear edit flags */ /* clear edit flags */
LibEDA_BaseStruct* item = CurrentLibEntry->m_Drawings; LibEDA_BaseStruct* item = CurrentLibEntry->m_Drawings;
...@@ -235,8 +240,8 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC ) ...@@ -235,8 +240,8 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
} }
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( DC );
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), CurrentPin, DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
GR_DEFAULT_DRAWMODE ); CurrentPin, GR_DEFAULT_DRAWMODE );
DrawPanel->CursorOn( DC ); DrawPanel->CursorOn( DC );
CurrentDrawItem = NULL; CurrentDrawItem = NULL;
...@@ -294,8 +299,9 @@ void WinEDA_LibeditFrame::StartMovePin( wxDC* DC ) ...@@ -294,8 +299,9 @@ void WinEDA_LibeditFrame::StartMovePin( wxDC* DC )
continue; continue;
if( Pin == CurrentPin ) if( Pin == CurrentPin )
continue; continue;
if( (Pin->m_Pos == CurrentPin->m_Pos) && (Pin->m_Orient == CurrentPin->m_Orient) if( ( Pin->m_Pos == CurrentPin->m_Pos )
&& (g_EditPinByPinIsOn == false ) ) && ( Pin->m_Orient == CurrentPin->m_Orient )
&& ( g_EditPinByPinIsOn == false ) )
Pin->m_Flags |= IS_LINKED | IS_MOVED; Pin->m_Flags |= IS_LINKED | IS_MOVED;
} }
...@@ -326,7 +332,7 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -326,7 +332,7 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
wxPoint pinpos = CurrentPin->m_Pos; wxPoint pinpos = CurrentPin->m_Pos;
/* Erase pin in old position */ /* Erase pin in old position */
if( erase || (CurrentPin->m_Flags & IS_NEW) ) if( erase || ( CurrentPin->m_Flags & IS_NEW ) )
{ {
CurrentPin->m_Pos = PinPreviousPos; CurrentPin->m_Pos = PinPreviousPos;
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint(0, 0), DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint(0, 0),
...@@ -336,7 +342,8 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -336,7 +342,8 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/* Redraw pin in new position */ /* Redraw pin in new position */
CurrentPin->m_Pos.x = panel->GetScreen()->m_Curseur.x; CurrentPin->m_Pos.x = panel->GetScreen()->m_Curseur.x;
CurrentPin->m_Pos.y = -panel->GetScreen()->m_Curseur.y; CurrentPin->m_Pos.y = -panel->GetScreen()->m_Curseur.y;
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint(0, 0), CurrentPin, g_XorMode ); DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentPin, g_XorMode );
PinPreviousPos = CurrentPin->m_Pos; PinPreviousPos = CurrentPin->m_Pos;
...@@ -481,7 +488,7 @@ void WinEDA_PinPropertiesFrame::SetPinNum( const wxString& newnum, int newsize ) ...@@ -481,7 +488,7 @@ void WinEDA_PinPropertiesFrame::SetPinNum( const wxString& newnum, int newsize )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue; continue;
if( (Pin->m_Flags & IS_LINKED) == 0 ) if( ( Pin->m_Flags & IS_LINKED ) == 0 )
continue; continue;
if( Pin->m_Unit != CurrentPin->m_Unit ) if( Pin->m_Unit != CurrentPin->m_Unit )
continue; continue;
...@@ -659,7 +666,8 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw, ...@@ -659,7 +666,8 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
continue; continue;
if( Pin == CurrentPin ) if( Pin == CurrentPin )
continue; continue;
if( CurrentPin->m_Convert && (CurrentPin->m_Convert != Pin->m_Convert) ) if( CurrentPin->m_Convert
&& (CurrentPin->m_Convert != Pin->m_Convert) )
continue; continue;
if( CurrentPin->m_Pos != Pin->m_Pos ) if( CurrentPin->m_Pos != Pin->m_Pos )
continue; continue;
...@@ -683,7 +691,8 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw, ...@@ -683,7 +691,8 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
DrawItem = CurrentLibEntry->m_Drawings; DrawItem = CurrentLibEntry->m_Drawings;
for( ; DrawItem != NULL; ) for( ; DrawItem != NULL; )
{ {
Pin = (LibDrawPin*) DrawItem; DrawItem = DrawItem->Next(); Pin = (LibDrawPin*) DrawItem;
DrawItem = DrawItem->Next();
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue; continue;
if( Pin->m_Flags == 0 ) if( Pin->m_Flags == 0 )
...@@ -787,7 +796,7 @@ static void CreateImagePins( LibDrawPin* Pin ) ...@@ -787,7 +796,7 @@ static void CreateImagePins( LibDrawPin* Pin )
/* Creation de la pin " convert " pour la part courante */ /* Creation de la pin " convert " pour la part courante */
if( CreateConv == true ) if( CreateConv == true )
{ {
NewPin = Pin->GenCopy(); NewPin = (LibDrawPin*) Pin->GenCopy();
if( Pin->m_Convert > 1 ) if( Pin->m_Convert > 1 )
NewPin->m_Convert = 1; NewPin->m_Convert = 1;
else else
...@@ -804,7 +813,7 @@ static void CreateImagePins( LibDrawPin* Pin ) ...@@ -804,7 +813,7 @@ static void CreateImagePins( LibDrawPin* Pin )
continue; /* Pin commune a toutes les unites */ continue; /* Pin commune a toutes les unites */
/* Creation pour la representation "normale" */ /* Creation pour la representation "normale" */
NewPin = Pin->GenCopy(); NewPin = (LibDrawPin*) Pin->GenCopy();
if( CurrentConvert != 0 ) if( CurrentConvert != 0 )
NewPin->m_Convert = 1; NewPin->m_Convert = 1;
NewPin->m_Unit = ii; NewPin->m_Unit = ii;
...@@ -815,7 +824,7 @@ static void CreateImagePins( LibDrawPin* Pin ) ...@@ -815,7 +824,7 @@ static void CreateImagePins( LibDrawPin* Pin )
if( CreateConv == false ) if( CreateConv == false )
continue; continue;
NewPin = Pin->GenCopy(); NewPin = (LibDrawPin*)Pin->GenCopy();
NewPin->m_Convert = 2; NewPin->m_Convert = 2;
if( Pin->m_Unit != 0 ) if( Pin->m_Unit != 0 )
NewPin->m_Unit = ii; NewPin->m_Unit = ii;
...@@ -838,7 +847,7 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC, ...@@ -838,7 +847,7 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC,
*/ */
{ {
LibDrawPin* Pin; LibDrawPin* Pin;
bool selected = (MasterPin->m_Selected & IS_SELECTED) != 0; bool selected = ( MasterPin->m_Selected & IS_SELECTED ) != 0;
if( (CurrentLibEntry == NULL) || (MasterPin == NULL) ) if( (CurrentLibEntry == NULL) || (MasterPin == NULL) )
return; return;
...@@ -852,14 +861,15 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC, ...@@ -852,14 +861,15 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC,
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue; continue;
if( (Pin->m_Convert) && (Pin->m_Convert != CurrentConvert) ) if( ( Pin->m_Convert ) && ( Pin->m_Convert != CurrentConvert ) )
continue; continue;
// Is it the "selected mode" ? // Is it the "selected mode" ?
if( selected && (Pin->m_Selected & IS_SELECTED) == 0 ) if( selected && (Pin->m_Selected & IS_SELECTED) == 0 )
continue; continue;
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), Pin, g_XorMode ); DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry,
wxPoint( 0, 0 ), Pin, g_XorMode );
switch( id ) switch( id )
{ {
...@@ -897,13 +907,15 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LibDrawPin* SourcePin ) ...@@ -897,13 +907,15 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LibDrawPin* SourcePin )
if( SourcePin->Type() != COMPONENT_PIN_DRAW_TYPE ) if( SourcePin->Type() != COMPONENT_PIN_DRAW_TYPE )
return; return;
Pin = SourcePin->GenCopy(); Pin = (LibDrawPin*)SourcePin->GenCopy();
Pin->SetNext( CurrentLibEntry->m_Drawings ); Pin->SetNext( CurrentLibEntry->m_Drawings );
CurrentLibEntry->m_Drawings = Pin; CurrentLibEntry->m_Drawings = Pin;
Pin->m_Flags = IS_NEW; Pin->m_Flags = IS_NEW;
Pin->m_Pos.x += g_RepeatStep.x; ox = Pin->m_Pos.x; Pin->m_Pos.x += g_RepeatStep.x;
Pin->m_Pos.y += -g_RepeatStep.y; oy = Pin->m_Pos.y; // ici axe Y comme en math ox = Pin->m_Pos.x;
Pin->m_Pos.y += -g_RepeatStep.y;
oy = Pin->m_Pos.y; // ici axe Y comme en math
/*** Increment du numero de label ***/ /*** Increment du numero de label ***/
IncrementLabelMember( Pin->m_PinName ); IncrementLabelMember( Pin->m_PinName );
......
This diff is collapsed.
/*****************************************************************************
* Definitions, visible to others, of Priority Queue module: *
*****************************************************************************/
#ifndef PRIOR_Q_GH
#define PRIOR_Q_GH
typedef struct PriorQue
{
struct PriorQue *Right, *Left; /* Pointers to two sons of this node. */
void * Data; /* Pointers to the data itself. */
} PriorQue;
typedef int (*PQCompFuncType)( void *, void *); /* Comparison function. */
/* And global function prototypes: */
void PQInit(PriorQue **PQ);
int PQEmpty(PriorQue *PQ);
void PQCompFunc(PQCompFuncType NewCompFunc);
void * PQFirst(PriorQue **PQ, int Delete);
void * PQInsert(PriorQue **PQ, void * NewItem);
void * PQDelete(PriorQue **PQ, void * NewItem);
void * PQFind(PriorQue *PQ, void * OldItem);
void * PQNext(PriorQue *PQ, void * CmpItem, void * BiggerThan);
void PQPrint(PriorQue *PQ, void (*PrintFunc)());
void PQFree(PriorQue *PQ, int FreeItems);
void PQFreeFunc(PriorQue *PQ, void (*FreeFunc)(void *));
#endif /* PRIOR_Q_GH */
...@@ -91,9 +91,6 @@ wxPoint TransformCoordinate( const int aTransformMatrix[2][2], ...@@ -91,9 +91,6 @@ wxPoint TransformCoordinate( const int aTransformMatrix[2][2],
const wxPoint& aPosition ); const wxPoint& aPosition );
LibraryStruct* FindLibrary( const wxString& Name ); LibraryStruct* FindLibrary( const wxString& Name );
int LoadDocLib( WinEDA_DrawFrame* frame,
const wxString& FullDocLibName,
const wxString& Libname );
LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame, LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
const wxString& FullLibName, const wxString& FullLibName,
const wxString& LibName ); const wxString& LibName );
...@@ -236,18 +233,6 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose ); ...@@ -236,18 +233,6 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose );
/* SAVELIB.CPP */ /* SAVELIB.CPP */
/**************/ /**************/
LibEDA_BaseStruct* CopyDrawEntryStruct( LibEDA_BaseStruct* DrawItem );
/* Routine de Duplication d'une structure DrawLibItem d'une partlib
* Parametres d'entree:
* DrawEntry = pointeur sur la structure a dupliquer
* La structure nouvelle est creee, mais n'est pas inseree dans le
* chainage
* Retourne:
* Pointeur sur la structure creee (ou NULL si impossible)
*/
EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry ); EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry );
/* Routine de copie d'une partlib /* Routine de copie d'une partlib
......
...@@ -19,61 +19,6 @@ ...@@ -19,61 +19,6 @@
#include "protos.h" #include "protos.h"
/** Function CopyDrawEntryStruct
* Duplicate a DrawLibItem
* the new item is only created, it is not put in the current component linked
* list
* @param DrawEntry = DrawLibItem * item to duplicate
* @return a pointer to the new item
* A better way to duplicate a DrawLibItem is to have a virtual GenCopy() in
* LibEDA_BaseStruct class (ToDo).
*/
LibEDA_BaseStruct* CopyDrawEntryStruct( LibEDA_BaseStruct* DrawItem )
{
wxString msg;
LibEDA_BaseStruct* NewDrawItem = NULL;
switch( DrawItem->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
NewDrawItem = ( (LibDrawArc*) DrawItem )->GenCopy();
break;
case COMPONENT_CIRCLE_DRAW_TYPE:
NewDrawItem = ( (LibDrawCircle*) DrawItem )->GenCopy();
break;
case COMPONENT_RECT_DRAW_TYPE:
NewDrawItem = ( (LibDrawSquare*) DrawItem )->GenCopy();
break;
case COMPONENT_PIN_DRAW_TYPE:
NewDrawItem = ( (LibDrawPin*) DrawItem )->GenCopy();
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
NewDrawItem = ( (LibDrawText*) DrawItem )->GenCopy();
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
NewDrawItem = ( (LibDrawPolyline*) DrawItem )->GenCopy();
break;
case COMPONENT_BEZIER_DRAW_TYPE:
NewDrawItem = ( (LibDrawBezier*) DrawItem )->GenCopy();
break;
default:
msg.Printf( wxT( "CopyDrawLibEntryStruct: unknown Draw Type %d" ),
DrawItem->Type() );
wxLogError( msg );
break;
}
return NewDrawItem;
}
/* /*
* Routine de copie d'une partlib * Routine de copie d'une partlib
* Parametres d'entree: pointeur sur la structure de depart * Parametres d'entree: pointeur sur la structure de depart
...@@ -118,7 +63,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry ) ...@@ -118,7 +63,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry )
for( OldField = OldEntry->m_Fields; OldField != NULL; for( OldField = OldEntry->m_Fields; OldField != NULL;
OldField = OldField->Next() ) OldField = OldField->Next() )
{ {
NewField = OldField->GenCopy(); NewField = (LibDrawField*) OldField->GenCopy();
NewStruct->m_Fields.PushBack( NewField ); NewStruct->m_Fields.PushBack( NewField );
} }
...@@ -130,7 +75,8 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry ) ...@@ -130,7 +75,8 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry )
if( ( OldDrawings->m_Flags & IS_NEW ) != 0 ) if( ( OldDrawings->m_Flags & IS_NEW ) != 0 )
continue; continue;
NewDrawings = CopyDrawEntryStruct( OldDrawings ); NewDrawings = OldDrawings->GenCopy();
if( NewDrawings ) if( NewDrawings )
{ {
if( LastItem == NULL ) if( LastItem == NULL )
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
/* EESchema - selpart.cpp */ /* EESchema - selpart.cpp */
/**************************/ /**************************/
/* Routine de selection d'un composant en librairie
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
...@@ -16,32 +13,24 @@ ...@@ -16,32 +13,24 @@
#include "protos.h" #include "protos.h"
/* Routines locales */
/* Variables locales */
/***************************************************************/
LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame ) LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame )
/***************************************************************/
{ {
int ii, NumOfLibs = NumOfLibraries();
LibraryStruct* Lib = NULL;
static wxString OldLibName; static wxString OldLibName;
wxString LibName; wxString LibName, msg;
int count = NumOfLibraries();
LibraryStruct* Lib = NULL;
if( NumOfLibs == 0 ) if( count == 0 )
{ {
DisplayError( frame, _( "No libraries are loaded" ) ); DisplayError( frame, _( "No libraries are loaded" ) );
return NULL; return NULL;
} }
WinEDAListBox ListBox( frame, _( "Select Lib" ), msg.Printf( _( " Select 1 of %d libraries." ), count );
NULL, OldLibName, NULL,
wxColour( 255, 255, 255 ) ); // Library browser background color
wxArrayString libNamesList; wxArrayString libNamesList;
LibraryStruct* libcache = NULL; LibraryStruct* libcache = NULL;
for( LibraryStruct* Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext ) for( LibraryStruct* Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
{ {
if( Lib->m_IsLibCache ) if( Lib->m_IsLibCache )
...@@ -56,17 +45,20 @@ LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame ) ...@@ -56,17 +45,20 @@ LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame )
if( libcache ) if( libcache )
libNamesList.Add( libcache->m_Name ); libNamesList.Add( libcache->m_Name );
ListBox.InsertItems( libNamesList ); wxSingleChoiceDialog dlg( frame, msg, _( "Select Library" ), libNamesList );
int index = libNamesList.Index( OldLibName );
ListBox.MoveMouseToOrigin(); if( index != wxNOT_FOUND )
dlg.SetSelection( index );
ii = ListBox.ShowModal(); if( dlg.ShowModal() == wxID_CANCEL || dlg.GetStringSelection().IsEmpty() )
return NULL;
if( ii >= 0 ) /* Recherche de la librairie */ Lib = FindLibrary( dlg.GetStringSelection() );
{
Lib = FindLibrary( libNamesList[ii] ); if( Lib != NULL )
} OldLibName = dlg.GetStringSelection();
return Lib; return Lib;
} }
...@@ -77,7 +69,6 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame, ...@@ -77,7 +69,6 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
wxString& Buffer, wxString& OldName ) wxString& Buffer, wxString& OldName )
{ {
size_t i; size_t i;
wxString msg;
wxArrayString nameList; wxArrayString nameList;
const wxChar** ListNames; const wxChar** ListNames;
...@@ -92,14 +83,11 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame, ...@@ -92,14 +83,11 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
ListNames = (const wxChar**) MyZMalloc( ( nameList.GetCount() + 1 ) * ListNames = (const wxChar**) MyZMalloc( ( nameList.GetCount() + 1 ) *
sizeof( wxChar* ) ); sizeof( wxChar* ) );
msg.Printf( _( "Select 1 of %d components from library <%s>" ),
nameList.GetCount(), (const wxChar*) Library->m_Name );
for( i = 0; i < nameList.GetCount(); i++ ) for( i = 0; i < nameList.GetCount(); i++ )
ListNames[i] = (const wxChar*) nameList[i]; ListNames[i] = (const wxChar*) nameList[i];
WinEDAListBox dlg( frame, msg, ListNames, OldName, DisplayCmpDoc, WinEDAListBox dlg( frame, _( "Select Component" ), ListNames, OldName,
wxColour( 255, 255, 255 ) ); DisplayCmpDoc, wxColour( 255, 255, 255 ) );
dlg.MoveMouseToOrigin(); dlg.MoveMouseToOrigin();
...@@ -117,10 +105,8 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame, ...@@ -117,10 +105,8 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
} }
/************************************************************/ int GetNameOfPartToLoad( WinEDA_DrawFrame* frame, LibraryStruct* Library,
int GetNameOfPartToLoad( WinEDA_DrawFrame* frame, wxString& BufName )
LibraryStruct* Library, wxString& BufName )
/************************************************************/
{ {
int ii; int ii;
static wxString OldCmpName; static wxString OldCmpName;
......
...@@ -109,7 +109,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) ...@@ -109,7 +109,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
return; return;
} }
if( Lib->m_NumOfParts > 1 ) if( Lib->GetCount() > 1 )
DisplayError( this, _( "Warning: more than 1 part in Symbol File" ) ); DisplayError( this, _( "Warning: more than 1 part in Symbol File" ) );
Component = (EDA_LibComponentStruct*) Lib->GetFirstEntry(); Component = (EDA_LibComponentStruct*) Lib->GetFirstEntry();
...@@ -240,10 +240,10 @@ void WinEDA_LibeditFrame::SaveOneSymbol() ...@@ -240,10 +240,10 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
for( ; DrawEntry != NULL; DrawEntry = DrawEntry->Next() ) for( ; DrawEntry != NULL; DrawEntry = DrawEntry->Next() )
{ {
/* Elimination des elements non relatifs a l'unite */ /* Elimination des elements non relatifs a l'unite */
if( Unit && DrawEntry->m_Unit && (DrawEntry->m_Unit != Unit) ) if( Unit && DrawEntry->m_Unit && ( DrawEntry->m_Unit != Unit ) )
continue; continue;
if( convert && DrawEntry->m_Convert if( convert && DrawEntry->m_Convert
&& (DrawEntry->m_Convert != convert) ) && ( DrawEntry->m_Convert != convert ) )
continue; continue;
DrawEntry->Save( ExportFile ); DrawEntry->Save( ExportFile );
......
...@@ -111,7 +111,8 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father, ...@@ -111,7 +111,8 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
m_LibList = m_LibList =
new wxListBox( m_LibListWindow, ID_LIBVIEW_LIB_LIST, new wxListBox( m_LibListWindow, ID_LIBVIEW_LIB_LIST,
wxPoint( 0, 0 ), wxPoint( 0, 0 ),
m_LibListWindow->GetClientSize() - wxSize(EXTRA_BORDER_SIZE*2,0), m_LibListWindow->GetClientSize() -
wxSize( EXTRA_BORDER_SIZE * 2, 0 ),
0, NULL, wxLB_HSCROLL ); 0, NULL, wxLB_HSCROLL );
} }
else else
...@@ -135,7 +136,8 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father, ...@@ -135,7 +136,8 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
m_CmpListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE ); m_CmpListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
m_CmpList = new wxListBox( m_CmpListWindow, ID_LIBVIEW_CMP_LIST, m_CmpList = new wxListBox( m_CmpListWindow, ID_LIBVIEW_CMP_LIST,
wxPoint( 0, 0 ), wxPoint( 0, 0 ),
m_CmpListWindow->GetClientSize() - wxSize(EXTRA_BORDER_SIZE*2,0), m_CmpListWindow->GetClientSize() -
wxSize( EXTRA_BORDER_SIZE * 2, 0 ),
0, NULL, wxLB_HSCROLL ); 0, NULL, wxLB_HSCROLL );
if( m_LibList ) if( m_LibList )
...@@ -231,7 +233,8 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv ) ...@@ -231,7 +233,8 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
if( m_VToolBar ) if( m_VToolBar )
{ {
Vtoolbar_size = m_VToolBar->GetSize(); Vtoolbar_size = m_VToolBar->GetSize();
m_VToolBar->SetSize( clientsize.x - maintoolbar_size.y, 0, -1, clientsize.y ); m_VToolBar->SetSize( clientsize.x - maintoolbar_size.y, 0, -1,
clientsize.y );
} }
if( MsgPanel ) if( MsgPanel )
...@@ -242,7 +245,8 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv ) ...@@ -242,7 +245,8 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
if( DrawPanel ) if( DrawPanel )
{ {
DrawPanel->SetSize( m_LibListSize.x + m_CmpListSize.x, 0, DrawPanel->SetSize( m_LibListSize.x + m_CmpListSize.x, 0,
clientsize.x - Vtoolbar_size.x - m_LibListSize.x - m_CmpListSize.x, clientsize.x - Vtoolbar_size.x -
m_LibListSize.x - m_CmpListSize.x,
clientsize.y ); clientsize.y );
} }
...@@ -250,7 +254,8 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv ) ...@@ -250,7 +254,8 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
{ {
m_LibListSize.y = clientsize.y - 2; m_LibListSize.y = clientsize.y - 2;
m_LibListWindow->SetSize( m_LibListSize ); m_LibListWindow->SetSize( m_LibListSize );
m_LibList->SetSize( m_LibListWindow->GetClientSize() - wxSize(EXTRA_BORDER_SIZE*2,0) ); m_LibList->SetSize( m_LibListWindow->GetClientSize() -
wxSize( EXTRA_BORDER_SIZE * 2, 0 ) );
} }
if( m_CmpList && m_CmpListWindow ) if( m_CmpList && m_CmpListWindow )
...@@ -258,7 +263,8 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv ) ...@@ -258,7 +263,8 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
m_CmpListSize.y = clientsize.y - 2; m_CmpListSize.y = clientsize.y - 2;
m_CmpListWindow->SetSize( m_CmpListSize ); m_CmpListWindow->SetSize( m_CmpListSize );
m_CmpListWindow->SetPosition( wxPoint( m_LibListSize.x, 0 ) ); m_CmpListWindow->SetPosition( wxPoint( m_LibListSize.x, 0 ) );
m_CmpList->SetSize( m_CmpListWindow->GetClientSize() - wxSize(EXTRA_BORDER_SIZE*2,0) ); m_CmpList->SetSize( m_CmpListWindow->GetClientSize() -
wxSize( EXTRA_BORDER_SIZE * 2, 0 ) );
} }
SizeEv.Skip(); SizeEv.Skip();
...@@ -285,7 +291,8 @@ int WinEDA_ViewlibFrame::BestZoom() ...@@ -285,7 +291,8 @@ int WinEDA_ViewlibFrame::BestZoom()
return bestzoom; return bestzoom;
} }
EDA_Rect BoundaryBox = CurrentLibEntry->GetBoundaryBox( g_ViewUnit, g_ViewConvert ); EDA_Rect BoundaryBox = CurrentLibEntry->GetBoundaryBox( g_ViewUnit,
g_ViewConvert );
itemsize = BoundaryBox.GetSize(); itemsize = BoundaryBox.GetSize();
size = DrawPanel->GetClientSize(); size = DrawPanel->GetClientSize();
...@@ -331,12 +338,12 @@ void WinEDA_ViewlibFrame::ReCreateListLib() ...@@ -331,12 +338,12 @@ void WinEDA_ViewlibFrame::ReCreateListLib()
if ( libcache ) if ( libcache )
libNamesList.Add( libcache->m_Name ); libNamesList.Add( libcache->m_Name );
m_LibList->Append(libNamesList); m_LibList->Append( libNamesList );
// Search for a previous selection: // Search for a previous selection:
for ( unsigned ii = 0; ii < m_LibList->GetCount(); ii++ ) for ( unsigned ii = 0; ii < m_LibList->GetCount(); ii++ )
{ {
if( g_CurrentViewLibraryName.Cmp( m_LibList->GetString(ii) ) == 0 ) if( g_CurrentViewLibraryName.Cmp( m_LibList->GetString( ii ) ) == 0 )
{ {
m_LibList->SetSelection( ii, TRUE ); m_LibList->SetSelection( ii, TRUE );
found = TRUE; found = TRUE;
...@@ -344,7 +351,8 @@ void WinEDA_ViewlibFrame::ReCreateListLib() ...@@ -344,7 +351,8 @@ void WinEDA_ViewlibFrame::ReCreateListLib()
} }
} }
/* If not found, clear current library selection because it can be deleted after a config change /* If not found, clear current library selection because it can be
* deleted after a config change.
*/ */
if( !found ) if( !found )
{ {
...@@ -364,7 +372,7 @@ void WinEDA_ViewlibFrame::ReCreateListCmp() ...@@ -364,7 +372,7 @@ void WinEDA_ViewlibFrame::ReCreateListCmp()
if( m_CmpList == NULL ) if( m_CmpList == NULL )
return; return;
LibraryStruct* Library = FindLibrary( g_CurrentViewLibraryName.GetData() ); LibraryStruct* Library = FindLibrary( g_CurrentViewLibraryName );
wxArrayString nameList; wxArrayString nameList;
m_CmpList->Clear(); m_CmpList->Clear();
...@@ -378,9 +386,7 @@ void WinEDA_ViewlibFrame::ReCreateListCmp() ...@@ -378,9 +386,7 @@ void WinEDA_ViewlibFrame::ReCreateListCmp()
} }
/********************************************************************/
void WinEDA_ViewlibFrame::ClickOnLibList( wxCommandEvent& event ) void WinEDA_ViewlibFrame::ClickOnLibList( wxCommandEvent& event )
/********************************************************************/
{ {
int ii = m_LibList->GetSelection(); int ii = m_LibList->GetSelection();
...@@ -398,9 +404,7 @@ void WinEDA_ViewlibFrame::ClickOnLibList( wxCommandEvent& event ) ...@@ -398,9 +404,7 @@ void WinEDA_ViewlibFrame::ClickOnLibList( wxCommandEvent& event )
} }
/****************************************************************/
void WinEDA_ViewlibFrame::ClickOnCmpList( wxCommandEvent& event ) void WinEDA_ViewlibFrame::ClickOnCmpList( wxCommandEvent& event )
/****************************************************************/
{ {
int ii = m_CmpList->GetSelection(); int ii = m_CmpList->GetSelection();
...@@ -418,12 +422,11 @@ void WinEDA_ViewlibFrame::ClickOnCmpList( wxCommandEvent& event ) ...@@ -418,12 +422,11 @@ void WinEDA_ViewlibFrame::ClickOnCmpList( wxCommandEvent& event )
} }
/****************************************************************************/
void WinEDA_ViewlibFrame::ExportToSchematicLibraryPart( wxCommandEvent& event )
/****************************************************************************/
/* Export the current component to schematic and close the library browser /*
* Export the current component to schematic and close the library browser
*/ */
void WinEDA_ViewlibFrame::ExportToSchematicLibraryPart( wxCommandEvent& event )
{ {
int ii = m_CmpList->GetSelection(); int ii = m_CmpList->GetSelection();
......
...@@ -22,13 +22,7 @@ ...@@ -22,13 +22,7 @@
#define PREVIOUS_PART -1 #define PREVIOUS_PART -1
/* Routines locales */
/* Variables locales */
/*************************************************************************/
void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event ) void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
/*************************************************************************/
{ {
wxString msg; wxString msg;
EDA_LibComponentStruct* LibEntry; EDA_LibComponentStruct* LibEntry;
...@@ -63,7 +57,7 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -63,7 +57,7 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
ALIAS ); ALIAS );
if( LibEntry && ( !LibEntry->m_DocFile.IsEmpty() ) ) if( LibEntry && ( !LibEntry->m_DocFile.IsEmpty() ) )
GetAssociatedDocument( this, LibEntry->m_DocFile, GetAssociatedDocument( this, LibEntry->m_DocFile,
& wxGetApp().GetLibraryPathList()); &wxGetApp().GetLibraryPathList() );
break; break;
case ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT: case ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT:
...@@ -96,26 +90,20 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -96,26 +90,20 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
} }
/*************************************************************************/
void WinEDA_ViewlibFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) void WinEDA_ViewlibFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
/*************************************************************************/
{ {
} }
/********************************************************************************/
bool WinEDA_ViewlibFrame::OnRightClick( const wxPoint& MousePos, bool WinEDA_ViewlibFrame::OnRightClick( const wxPoint& MousePos,
wxMenu* PopMenu ) wxMenu* PopMenu )
/********************************************************************************/
{ {
return true; return true;
} }
/**********************************************/
void WinEDA_ViewlibFrame::DisplayLibInfos()
/**********************************************/
/* Affiche en Ligne d'info la librairie en cours de visualisation */ /* Affiche en Ligne d'info la librairie en cours de visualisation */
void WinEDA_ViewlibFrame::DisplayLibInfos()
{ {
wxString msg; wxString msg;
LibraryStruct* Lib; LibraryStruct* Lib;
...@@ -162,10 +150,10 @@ void WinEDA_ViewlibFrame::SelectCurrentLibrary() ...@@ -162,10 +150,10 @@ void WinEDA_ViewlibFrame::SelectCurrentLibrary()
} }
/**************************************************************/ /*
* Routine to select and view library Part (NEW, NEXT or PREVIOUS)
*/
void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option ) void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option )
/**************************************************************/
/* Routine to select and view library Part (NEW, NEXT or PREVIOUS) */
{ {
LibraryStruct* Lib; LibraryStruct* Lib;
...@@ -209,15 +197,14 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( LibraryStruct* Lib, int Flag ) ...@@ -209,15 +197,14 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( LibraryStruct* Lib, int Flag )
wxString CmpName; wxString CmpName;
wxClientDC dc( DrawPanel ); wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext( &dc ); DrawPanel->PrepareGraphicContext( &dc );
if( Lib ) if( Lib )
NumOfParts = Lib->m_NumOfParts; NumOfParts = Lib->GetCount();
if( NumOfParts == 0 ) if( NumOfParts == 0 )
{ {
DisplayError( this, wxT( "No Library or Library is empty!" ) ); DisplayError( this, wxT( "No library or library is empty!" ) );
return; return;
} }
...@@ -226,9 +213,7 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( LibraryStruct* Lib, int Flag ) ...@@ -226,9 +213,7 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( LibraryStruct* Lib, int Flag )
if( Flag == NEW_PART ) if( Flag == NEW_PART )
{ {
DisplayComponentsNamesInLib( this, DisplayComponentsNamesInLib( this, Lib, CmpName,
Lib,
CmpName,
g_CurrentViewComponentName ); g_CurrentViewComponentName );
} }
......
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