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()
*/
WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title,
const wxChar** itemlist,
const wxString& reftext,
const wxChar** itemlist, const wxString& reftext,
void(* movefct)(wxString& Text) ,
const wxColour& colour, wxPoint dialog_position ) :
wxDialog( parent, -1, title, dialog_position, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER
)
wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER )
{
wxSize size;
const wxChar** names;
int ii;
m_ItemList = itemlist;
m_Parent = parent;
......@@ -58,34 +54,12 @@ WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title,
m_WinMsg = NULL;
SetReturnCode( -1 );
if( itemlist )
for( names = m_ItemList, ii = 0; *names != NULL; names++ )
ii++;
else
ii = 30;
wxBoxSizer* GeneralBoxSizer = new wxBoxSizer( wxVERTICAL );
SetSizer( GeneralBoxSizer );
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
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,
m_List = new wxListBox( this, ID_LISTBOX_LIST, wxDefaultPosition,
wxSize( 300, 200 ), 0, NULL,
wxLB_NEEDED_SB | wxLB_SINGLE | wxLB_HSCROLL );
if( colour != wxNullColour )
......@@ -93,38 +67,33 @@ WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title,
m_List->SetBackgroundColour( colour );
m_List->SetForegroundColour( *wxBLACK );
}
LeftBoxSizer->Add( m_List, 0, wxGROW | wxALL, 5 );
GeneralBoxSizer->Add( m_List, 0, wxGROW | wxALL, 5 );
if( itemlist )
for( names = m_ItemList, ii = 0; *names != NULL; names++, ii++ )
{
for( names = m_ItemList; *names != NULL; 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 )
{
size.x = -1;
size.y = 60;
m_WinMsg = new wxTextCtrl( this, -1, wxEmptyString, wxDefaultPosition,
size, wxTE_READONLY | wxTE_MULTILINE );
m_WinMsg = new wxTextCtrl( this, -1, wxEmptyString,
wxDefaultPosition, wxSize( -1, 60 ),
wxTE_READONLY | wxTE_MULTILINE );
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()->SetSizeHints( this );
if( dialog_position == wxDefaultPosition ) // Put the window on the parent centre
if( dialog_position == wxDefaultPosition )
{
Centre();
}
......
......@@ -101,7 +101,6 @@ set(EESCHEMA_SRCS
plothpgl.cpp
plotps.cpp
plotdxf.cpp
priorque.cpp
read_from_file_schematic_items_descriptions.cpp
savelib.cpp
save_schemas.cpp
......
......@@ -512,7 +512,7 @@ void CopyMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
if( item->m_Selected == 0 )
continue;
item->m_Selected = 0;
LibEDA_BaseStruct* newitem = CopyDrawEntryStruct( item );
LibEDA_BaseStruct* newitem = item->GenCopy();
newitem->m_Selected = IS_SELECTED;
newitem->SetNext( LibEntry->m_Drawings );
LibEntry->m_Drawings = newitem;
......
......@@ -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);
......@@ -185,7 +185,7 @@ LibDrawText* LibDrawText::GenCopy()
newitem->m_Bold = m_Bold;
newitem->m_HJustify = m_HJustify;
newitem->m_VJustify = m_VJustify;
return newitem;
return (LibEDA_BaseStruct*) newitem;
}
......@@ -247,4 +247,3 @@ void LibDrawText::DisplayInfo( WinEDA_DrawFrame* frame )
frame->MsgPanel->Affiche_1_Parametre( 20, _( "Line width" ), msg, BLUE );
}
......@@ -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 );
}
......
......@@ -16,13 +16,15 @@
/* Types for components in libraries
* 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 */
ALIAS /* This is an alias of a true component */
};
/* values for member .m_Options */
enum LibrEntryOptions {
enum LibrEntryOptions
{
ENTRY_NORMAL, // Libentry is a standard component (real or alias)
ENTRY_POWER // Libentry is a power symbol
};
......@@ -76,9 +78,10 @@ public:
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:
*
* @todo Alias objects should really be defined as children of a component
* 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
{
......
......@@ -347,13 +347,13 @@ bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat
}
// Creation et Duplication d'un field
LibDrawField* LibDrawField::GenCopy()
LibEDA_BaseStruct* LibDrawField::DoGenCopy()
{
LibDrawField* newfield = new LibDrawField( m_FieldId );
Copy( newfield );
return newfield;
return (LibEDA_BaseStruct*) newfield;
}
......
......@@ -58,8 +58,6 @@ public:
virtual bool Save( FILE* aFile ) const;
virtual bool Load( char* line, wxString& errorMsg );
LibDrawField* GenCopy();
/** Function Copy
* copy parameters of this to Target. Pointers are not copied
* @param aTarget = the LibDrawField to set with "this" values
......@@ -104,6 +102,9 @@ public:
m_VJustify = field.m_VJustify;
m_Parent = field.m_Parent;
}
protected:
virtual LibEDA_BaseStruct* DoGenCopy();
};
#endif // CLASS_LIBENTRY_FIELDS_H
This diff is collapsed.
......@@ -9,9 +9,12 @@
#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
{
......@@ -20,10 +23,7 @@ public:
wxString m_Name; /* Library file name (without path). */
wxString m_FullFileName; /* Full File Name (with path) of 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. */
int m_Modified; /* flag indicateur d'edition */
int m_Size; // Size in bytes (for statistics)
unsigned long m_TimeStamp; // Signature temporelle
int m_Flags; // variable used in some functions
bool m_IsLibCache; /* False for the "standard" libraries,
......@@ -46,14 +46,26 @@ public:
*
* @return bool - true if success writing else false.
*/
bool SaveLibrary( const wxString& aFullFileName );
bool ReadHeader( FILE* file, int* LineNum );
bool Save( const wxString& aFullFileName );
/**
* Load library from file.
*
* @param errMsg - Error message if load fails.
*
* @return bool - True if load was successful otherwise false.
*/
bool Load( wxString& errMsg );
void InsertAliases( PriorQue** PQ, EDA_LibComponentStruct* component );
bool LoadDocs( wxString& errMsg );
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:
LibraryStruct( const wxChar* fileName = NULL );
......@@ -65,7 +77,22 @@ public:
*/
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:
*
* @param names - String array to place entry names into.
* @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.
......@@ -150,7 +179,7 @@ public:
*/
LibCmpEntry* GetFirstEntry()
{
return (LibCmpEntry*) PQFirst( &m_Entries, false );
return &m_Entries.front();
}
/**
......@@ -180,23 +209,19 @@ public:
*/
LibCmpEntry* GetPreviousEntry( const wxChar* name );
bool Save( const wxString& saveAsFile );
wxString GetName();
protected:
wxFileName m_fileName; /* Library file name. */
wxDateTime m_DateTime; /* Library save time and date. */
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;
};
extern void FreeLibraryEntry( LibCmpEntry* Entry );
/**
* Case insensitive library name comparison.
*/
......
......@@ -73,7 +73,8 @@ bool LibDrawPin::HitTest( const wxPoint& aRefPos )
* @param aThreshold = max distance to a segment
* @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 pinEnd = TransformCoordinate( aTransMat, ReturnPinEndPoint() );
......@@ -286,7 +287,6 @@ int LibDrawPin::GetPenSize( )
}
/**********************************************************************************************/
void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
const wxPoint& aOffset,
......@@ -294,10 +294,9 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
int aDrawMode,
void* aData,
const int aTransformMatrix[2][2] )
/**********************************************************************************************/
{
// Invisibles pins are only drawn on request.
// But in libedit they are drawn in g_InvisibleItemColor because we must see them
// Invisible pins are only drawn on request. In libedit they are drawn
// in g_InvisibleItemColor because we must see them.
WinEDA_SchematicFrame* frame =
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
......@@ -312,7 +311,7 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
EDA_LibComponentStruct* Entry = ( (DrawPinPrms*) aData )->m_Entry;
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 );
/* Calculate the pin position */
......@@ -655,8 +654,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
if( DrawPinName )
{
x = (x1 + pin_pos.x) / 2;
DrawGraphicText( panel, DC, wxPoint( x,
y1 - TXTMARGE ),
DrawGraphicText( panel, DC, wxPoint( x, y1 - TXTMARGE ),
NameColor, m_PinName,
TEXT_ORIENT_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER,
......@@ -666,8 +664,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
if( DrawPinNum )
{
x = (x1 + pin_pos.x) / 2;
DrawGraphicText( panel, DC, wxPoint( x,
y1 + TXTMARGE ),
DrawGraphicText( panel, DC, wxPoint( x, y1 + TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
......@@ -680,8 +677,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
if( DrawPinName )
{
y = (y1 + pin_pos.y) / 2;
DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE,
y ),
DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE, y ),
NameColor, m_PinName,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER,
......@@ -692,8 +688,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
if( DrawPinNum )
{
DrawGraphicText( panel, DC,
wxPoint( x1 + TXTMARGE,
(y1 + pin_pos.y) / 2 ),
wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
......@@ -784,7 +779,8 @@ void LibDrawPin::PlotPinTexts( PLOTTER *plotter,
}
if( DrawPinNum )
{
plotter->text( wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ),
plotter->text( wxPoint( (x1 + pin_pos.x) / 2,
y1 - TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER,
......@@ -1018,7 +1014,7 @@ void LibDrawPin::SetPinNumFromString( wxString& buffer )
/*************************************/
LibDrawPin* LibDrawPin::GenCopy()
LibEDA_BaseStruct* LibDrawPin::DoGenCopy()
/*************************************/
{
LibDrawPin* newpin = new LibDrawPin( GetParent() );
......@@ -1043,7 +1039,7 @@ LibDrawPin* LibDrawPin::GenCopy()
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
}
LibDrawArc* LibDrawArc::GenCopy()
LibEDA_BaseStruct* LibDrawArc::DoGenCopy()
{
LibDrawArc* newitem = new LibDrawArc( GetParent() );
......@@ -233,7 +233,7 @@ LibDrawArc* LibDrawArc::GenCopy()
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
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
}
LibDrawCircle* LibDrawCircle::GenCopy()
LibEDA_BaseStruct* LibDrawCircle::DoGenCopy()
{
LibDrawCircle* newitem = new LibDrawCircle( GetParent() );
......@@ -488,7 +488,7 @@ LibDrawCircle* LibDrawCircle::GenCopy()
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill;
return newitem;
return (LibEDA_BaseStruct*) newitem;
}
......@@ -619,7 +619,7 @@ bool LibDrawSquare::Load( char* line, wxString& errorMsg )
}
LibDrawSquare* LibDrawSquare::GenCopy()
LibEDA_BaseStruct* LibDrawSquare::DoGenCopy()
{
LibDrawSquare* newitem = new LibDrawSquare( GetParent() );
......@@ -630,7 +630,7 @@ LibDrawSquare* LibDrawSquare::GenCopy()
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill;
return newitem;
return (LibEDA_BaseStruct*) newitem;
}
......@@ -788,7 +788,7 @@ bool LibDrawSegment::Load( char* line, wxString& errorMsg )
}
LibDrawSegment* LibDrawSegment::GenCopy()
LibEDA_BaseStruct* LibDrawSegment::DoGenCopy()
{
LibDrawSegment* newitem = new LibDrawSegment( GetParent() );
......@@ -798,7 +798,7 @@ LibDrawSegment* LibDrawSegment::GenCopy()
newitem->m_Unit = m_Unit;
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
return newitem;
return (LibEDA_BaseStruct*) newitem;
}
......@@ -976,7 +976,7 @@ bool LibDrawPolyline::Load( char* line, wxString& errorMsg )
}
LibDrawPolyline* LibDrawPolyline::GenCopy()
LibEDA_BaseStruct* LibDrawPolyline::DoGenCopy()
{
LibDrawPolyline* newitem = new LibDrawPolyline( GetParent() );
......@@ -986,7 +986,7 @@ LibDrawPolyline* LibDrawPolyline::GenCopy()
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill;
return newitem;
return (LibEDA_BaseStruct*) newitem;
}
......@@ -1238,7 +1238,7 @@ bool LibDrawBezier::Load( char* line, wxString& errorMsg )
}
LibDrawBezier* LibDrawBezier::GenCopy()
LibEDA_BaseStruct* LibDrawBezier::DoGenCopy()
{
LibDrawBezier* newitem = new LibDrawBezier(GetParent());
......@@ -1248,7 +1248,7 @@ LibDrawBezier* LibDrawBezier::GenCopy()
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill;
return newitem;
return (LibEDA_BaseStruct*) newitem;
}
/** Function GetPenSize
......
This diff is collapsed.
......@@ -77,13 +77,22 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
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 )
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( "\nKey Words: " ) + CmpEntry->m_KeyWord;
}
......@@ -452,7 +452,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
{
for( ii = OldNumUnits + 1; ii <= MaxUnit; ii++ )
{
NextDrawItem = CopyDrawEntryStruct( DrawItem );
NextDrawItem = DrawItem->GenCopy();
NextDrawItem->SetNext( CurrentLibEntry->m_Drawings );
CurrentLibEntry->m_Drawings = NextDrawItem;
NextDrawItem->m_Unit = ii;
......@@ -499,7 +499,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
g_AsDeMorgan = 0; return FALSE;
}
}
NextDrawItem = CopyDrawEntryStruct( DrawItem );
NextDrawItem = DrawItem->GenCopy();
NextDrawItem->SetNext( CurrentLibEntry->m_Drawings );
CurrentLibEntry->m_Drawings = NextDrawItem;
NextDrawItem->m_Convert = 2;
......
......@@ -18,15 +18,15 @@
#include "dialog_load_error.h"
/****************************************************************************/
/** Function LoadLibraryName
/**
* Function LoadLibraryName
*
* Routine to load the given library name. FullLibName should hold full path
* of file name to open, while LibName should hold only its name.
* If library already exists, it is NOT reloaded.
*
* @return : new lib or NULL
*/
/****************************************************************************/
LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
const wxString& FullLibName,
const wxString& LibName )
......@@ -60,9 +60,7 @@ LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
tmplib->m_Pnext = NewLib;
}
fn = FullLibName;
fn.SetExt( DOC_EXT );
LoadDocLib( frame, fn.GetFullPath(), NewLib->m_Name );
NewLib->LoadDocs( errMsg );
}
else
{
......@@ -79,7 +77,9 @@ library <%s>" ),
}
/** Function LoadLibraries
/**
* Function LoadLibraries
*
* Clear all already loaded libraries and load all librairies
* given in frame->m_ComponentLibFiles
*/
......@@ -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.
*/
/**************************************************************/
void FreeCmpLibrary( wxWindow* frame, const wxString& LibName )
{
int NumOfLibs = NumOfLibraries();
......@@ -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.
* Comparison (insensitive case) is based on Part name.
*/
......@@ -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* Lib = g_LibraryList;
......@@ -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 ii;
......@@ -289,83 +290,3 @@ int NumOfLibraries()
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 )
/* Sauvegarde du composant: */
CurrentLib = NewLib;
SaveOnePartInMemory();
bool success = NewLib->SaveLibrary( fn.GetFullPath() );
bool success = NewLib->Save( fn.GetFullPath() );
if( success )
{
......
......@@ -5,7 +5,6 @@
#ifndef LIBCMP_H
#define LIBCMP_H
#include "priorque.h"
#define LIB_VERSION_MAJOR 2
#define LIB_VERSION_MINOR 3
......@@ -14,7 +13,7 @@
#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_DOC 1
#define ALIAS_KEYWORD 2
......
......@@ -86,7 +86,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart()
if( g_ScreenLib->IsModify() )
{
if( !IsOK( this, _( "Current Part not saved.\nContinue?" ) ) )
if( !IsOK( this, _( "Current part not saved.\nContinue?" ) ) )
return FALSE;
}
......@@ -115,7 +115,8 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart()
if( LibEntry == NULL )
{
msg = _( "Component \"" ); msg << CmpName << _( "\" not found." );
msg = _( "Component \"" );
msg << CmpName << _( "\" not found." );
DisplayError( this, msg );
return FALSE;
}
......@@ -144,7 +145,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( LibCmpEntry* LibEntry,
{
wxString msg, cmpName, rootName;
if( (LibEntry == NULL) || (Library == NULL) )
if( ( LibEntry == NULL ) || ( Library == NULL ) )
return false;
if( LibEntry->m_Name.m_Text.IsEmpty() )
......@@ -263,33 +264,33 @@ void WinEDA_LibeditFrame::SaveActiveLibrary()
if( CurrentLib == NULL )
{
DisplayError( this, wxT( "No Library specified" ) );
DisplayError( this, wxT( "No library specified" ) );
return;
}
fn = wxFileName( CurrentLib->m_FullFileName );
msg = _( "Modify Library File \"" ) + fn.GetFullPath() + _( "\"?" );
msg = _( "Modify library file \"" ) + fn.GetFullPath() + _( "\"?" );
if( !IsOK( this, msg ) )
return;
bool success = CurrentLib->SaveLibrary( fn.GetFullPath() );
bool success = CurrentLib->Save( fn.GetFullPath() );
MsgPanel->EraseMsgBox();
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 );
DisplayError( this, msg );
}
else
{
msg = _( "Library File \"" ) + fn.GetFullName() + wxT( "\" Ok" );
msg = _( "Library file \"" ) + fn.GetFullName() + wxT( "\" Ok" );
fn.SetExt( DOC_EXT );
wxString msg1 = _( "Document File \"" ) + fn.GetFullPath() +
wxString msg1 = _( "Document file \"" ) + fn.GetFullPath() +
wxT( "\" Ok" );
Affiche_1_Parametre( this, 1, msg, msg1, BLUE );
}
......@@ -476,7 +477,7 @@ void WinEDA_LibeditFrame::SaveOnePartInMemory()
if( CurrentLib == NULL )
{
DisplayError( this, _( "No Library specified." ) );
DisplayError( this, _( "No library specified." ) );
return;
}
......
......@@ -200,7 +200,7 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event )
for( Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
{
if( Lib->m_Modified )
if( Lib->IsModified() )
{
wxString msg;
msg.Printf( _( "Library \"%s\" was modified!\nDiscard changes?" ),
......@@ -352,7 +352,7 @@ int WinEDA_LibeditFrame::BestZoom()
}
size = DrawPanel->GetClientSize();
size -= wxSize(100,100); // reserve 100 mils margin
size -= wxSize( 100, 100 ); // reserve 100 mils margin
ii = abs( dx / size.x );
jj = abs( dy / size.y );
......@@ -659,7 +659,8 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_LIBEDIT_DELETE_ITEM_BUTT:
if( CurrentLibEntry == NULL )
{
wxBell(); break;
wxBell();
break;
}
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
break;
......
......@@ -68,13 +68,16 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event )
LastPinNoDraw = m_NoDraw->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();
LastPinNameSize = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits );
LastPinNameSize = ReturnValueFromString( g_UnitMetric, msg,
m_Parent->m_InternalUnits );
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
{
......@@ -82,7 +85,8 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event )
m_Parent->SaveCopyInUndoList( CurrentLibEntry );
SetPinName( m_PinNameCtrl->GetValue(), LastPinNameSize );
msg = m_PinNumCtrl->GetValue(); if( msg.IsEmpty() )
msg = m_PinNumCtrl->GetValue();
if( msg.IsEmpty() )
msg = wxT( "~" );
SetPinNum( msg, LastPinNumSize );
NewSizePin( LastPinSize );
......@@ -126,10 +130,10 @@ void WinEDA_LibeditFrame::InitEditOnePin()
continue;
if( Pin == CurrentPin )
continue;
if( (Pin->m_Pos == CurrentPin->m_Pos)
&& (Pin->m_Orient == CurrentPin->m_Orient)
&& ( !(CurrentPin->m_Flags & IS_NEW) )
&& (g_EditPinByPinIsOn == false) // This is set by the tool of the main toolbar
if( ( Pin->m_Pos == CurrentPin->m_Pos )
&& ( Pin->m_Orient == CurrentPin->m_Orient )
&& ( !( CurrentPin->m_Flags & IS_NEW ) )
&& ( g_EditPinByPinIsOn == false ) // This is set by the tool of the main toolbar
)
Pin->m_Flags |= IS_LINKED | IN_EDIT;
else
......@@ -150,7 +154,8 @@ static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC )
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
if( CurrentPin && ( CurrentPin->m_Flags & IS_NEW ) )
DeleteOneLibraryDrawStruct( Panel, DC, CurrentLibEntry, CurrentPin, true );
DeleteOneLibraryDrawStruct( Panel, DC, CurrentLibEntry,
CurrentPin, true );
/* clear edit flags */
LibEDA_BaseStruct* item = CurrentLibEntry->m_Drawings;
......@@ -235,8 +240,8 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
}
DrawPanel->CursorOff( DC );
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), CurrentPin,
GR_DEFAULT_DRAWMODE );
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentPin, GR_DEFAULT_DRAWMODE );
DrawPanel->CursorOn( DC );
CurrentDrawItem = NULL;
......@@ -294,8 +299,9 @@ void WinEDA_LibeditFrame::StartMovePin( wxDC* DC )
continue;
if( Pin == CurrentPin )
continue;
if( (Pin->m_Pos == CurrentPin->m_Pos) && (Pin->m_Orient == CurrentPin->m_Orient)
&& (g_EditPinByPinIsOn == false ) )
if( ( Pin->m_Pos == CurrentPin->m_Pos )
&& ( Pin->m_Orient == CurrentPin->m_Orient )
&& ( g_EditPinByPinIsOn == false ) )
Pin->m_Flags |= IS_LINKED | IS_MOVED;
}
......@@ -326,7 +332,7 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
wxPoint pinpos = CurrentPin->m_Pos;
/* Erase pin in old position */
if( erase || (CurrentPin->m_Flags & IS_NEW) )
if( erase || ( CurrentPin->m_Flags & IS_NEW ) )
{
CurrentPin->m_Pos = PinPreviousPos;
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint(0, 0),
......@@ -336,7 +342,8 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/* Redraw pin in new position */
CurrentPin->m_Pos.x = panel->GetScreen()->m_Curseur.x;
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;
......@@ -481,7 +488,7 @@ void WinEDA_PinPropertiesFrame::SetPinNum( const wxString& newnum, int newsize )
{
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( (Pin->m_Flags & IS_LINKED) == 0 )
if( ( Pin->m_Flags & IS_LINKED ) == 0 )
continue;
if( Pin->m_Unit != CurrentPin->m_Unit )
continue;
......@@ -659,7 +666,8 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
continue;
if( Pin == CurrentPin )
continue;
if( CurrentPin->m_Convert && (CurrentPin->m_Convert != Pin->m_Convert) )
if( CurrentPin->m_Convert
&& (CurrentPin->m_Convert != Pin->m_Convert) )
continue;
if( CurrentPin->m_Pos != Pin->m_Pos )
continue;
......@@ -683,7 +691,8 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
DrawItem = CurrentLibEntry->m_Drawings;
for( ; DrawItem != NULL; )
{
Pin = (LibDrawPin*) DrawItem; DrawItem = DrawItem->Next();
Pin = (LibDrawPin*) DrawItem;
DrawItem = DrawItem->Next();
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( Pin->m_Flags == 0 )
......@@ -787,7 +796,7 @@ static void CreateImagePins( LibDrawPin* Pin )
/* Creation de la pin " convert " pour la part courante */
if( CreateConv == true )
{
NewPin = Pin->GenCopy();
NewPin = (LibDrawPin*) Pin->GenCopy();
if( Pin->m_Convert > 1 )
NewPin->m_Convert = 1;
else
......@@ -804,7 +813,7 @@ static void CreateImagePins( LibDrawPin* Pin )
continue; /* Pin commune a toutes les unites */
/* Creation pour la representation "normale" */
NewPin = Pin->GenCopy();
NewPin = (LibDrawPin*) Pin->GenCopy();
if( CurrentConvert != 0 )
NewPin->m_Convert = 1;
NewPin->m_Unit = ii;
......@@ -815,7 +824,7 @@ static void CreateImagePins( LibDrawPin* Pin )
if( CreateConv == false )
continue;
NewPin = Pin->GenCopy();
NewPin = (LibDrawPin*)Pin->GenCopy();
NewPin->m_Convert = 2;
if( Pin->m_Unit != 0 )
NewPin->m_Unit = ii;
......@@ -838,7 +847,7 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC,
*/
{
LibDrawPin* Pin;
bool selected = (MasterPin->m_Selected & IS_SELECTED) != 0;
bool selected = ( MasterPin->m_Selected & IS_SELECTED ) != 0;
if( (CurrentLibEntry == NULL) || (MasterPin == NULL) )
return;
......@@ -852,14 +861,15 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC,
{
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( (Pin->m_Convert) && (Pin->m_Convert != CurrentConvert) )
if( ( Pin->m_Convert ) && ( Pin->m_Convert != CurrentConvert ) )
continue;
// Is it the "selected mode" ?
if( selected && (Pin->m_Selected & IS_SELECTED) == 0 )
continue;
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), Pin, g_XorMode );
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry,
wxPoint( 0, 0 ), Pin, g_XorMode );
switch( id )
{
......@@ -897,13 +907,15 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LibDrawPin* SourcePin )
if( SourcePin->Type() != COMPONENT_PIN_DRAW_TYPE )
return;
Pin = SourcePin->GenCopy();
Pin = (LibDrawPin*)SourcePin->GenCopy();
Pin->SetNext( CurrentLibEntry->m_Drawings );
CurrentLibEntry->m_Drawings = Pin;
Pin->m_Flags = IS_NEW;
Pin->m_Pos.x += g_RepeatStep.x; ox = Pin->m_Pos.x;
Pin->m_Pos.y += -g_RepeatStep.y; oy = Pin->m_Pos.y; // ici axe Y comme en math
Pin->m_Pos.x += g_RepeatStep.x;
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 ***/
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],
const wxPoint& aPosition );
LibraryStruct* FindLibrary( const wxString& Name );
int LoadDocLib( WinEDA_DrawFrame* frame,
const wxString& FullDocLibName,
const wxString& Libname );
LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
const wxString& FullLibName,
const wxString& LibName );
......@@ -236,18 +233,6 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose );
/* 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 );
/* Routine de copie d'une partlib
......
......@@ -19,61 +19,6 @@
#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
* Parametres d'entree: pointeur sur la structure de depart
......@@ -118,7 +63,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry )
for( OldField = OldEntry->m_Fields; OldField != NULL;
OldField = OldField->Next() )
{
NewField = OldField->GenCopy();
NewField = (LibDrawField*) OldField->GenCopy();
NewStruct->m_Fields.PushBack( NewField );
}
......@@ -130,7 +75,8 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry )
if( ( OldDrawings->m_Flags & IS_NEW ) != 0 )
continue;
NewDrawings = CopyDrawEntryStruct( OldDrawings );
NewDrawings = OldDrawings->GenCopy();
if( NewDrawings )
{
if( LastItem == NULL )
......
......@@ -2,9 +2,6 @@
/* EESchema - selpart.cpp */
/**************************/
/* Routine de selection d'un composant en librairie
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
......@@ -16,32 +13,24 @@
#include "protos.h"
/* Routines locales */
/* Variables locales */
/***************************************************************/
LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame )
/***************************************************************/
{
int ii, NumOfLibs = NumOfLibraries();
LibraryStruct* Lib = NULL;
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" ) );
return NULL;
}
WinEDAListBox ListBox( frame, _( "Select Lib" ),
NULL, OldLibName, NULL,
wxColour( 255, 255, 255 ) ); // Library browser background color
msg.Printf( _( " Select 1 of %d libraries." ), count );
wxArrayString libNamesList;
LibraryStruct* libcache = NULL;
for( LibraryStruct* Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
{
if( Lib->m_IsLibCache )
......@@ -56,17 +45,20 @@ LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame )
if( libcache )
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( libNamesList[ii] );
}
Lib = FindLibrary( dlg.GetStringSelection() );
if( Lib != NULL )
OldLibName = dlg.GetStringSelection();
return Lib;
}
......@@ -77,7 +69,6 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
wxString& Buffer, wxString& OldName )
{
size_t i;
wxString msg;
wxArrayString nameList;
const wxChar** ListNames;
......@@ -92,14 +83,11 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
ListNames = (const wxChar**) MyZMalloc( ( nameList.GetCount() + 1 ) *
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++ )
ListNames[i] = (const wxChar*) nameList[i];
WinEDAListBox dlg( frame, msg, ListNames, OldName, DisplayCmpDoc,
wxColour( 255, 255, 255 ) );
WinEDAListBox dlg( frame, _( "Select Component" ), ListNames, OldName,
DisplayCmpDoc, wxColour( 255, 255, 255 ) );
dlg.MoveMouseToOrigin();
......@@ -117,10 +105,8 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
}
/************************************************************/
int GetNameOfPartToLoad( WinEDA_DrawFrame* frame,
LibraryStruct* Library, wxString& BufName )
/************************************************************/
int GetNameOfPartToLoad( WinEDA_DrawFrame* frame, LibraryStruct* Library,
wxString& BufName )
{
int ii;
static wxString OldCmpName;
......
......@@ -109,7 +109,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
return;
}
if( Lib->m_NumOfParts > 1 )
if( Lib->GetCount() > 1 )
DisplayError( this, _( "Warning: more than 1 part in Symbol File" ) );
Component = (EDA_LibComponentStruct*) Lib->GetFirstEntry();
......@@ -240,10 +240,10 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
for( ; DrawEntry != NULL; DrawEntry = DrawEntry->Next() )
{
/* 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;
if( convert && DrawEntry->m_Convert
&& (DrawEntry->m_Convert != convert) )
&& ( DrawEntry->m_Convert != convert ) )
continue;
DrawEntry->Save( ExportFile );
......
......@@ -111,7 +111,8 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
m_LibList =
new wxListBox( m_LibListWindow, ID_LIBVIEW_LIB_LIST,
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 );
}
else
......@@ -135,7 +136,8 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
m_CmpListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
m_CmpList = new wxListBox( m_CmpListWindow, ID_LIBVIEW_CMP_LIST,
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 );
if( m_LibList )
......@@ -231,7 +233,8 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
if( m_VToolBar )
{
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 )
......@@ -242,7 +245,8 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
if( DrawPanel )
{
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 );
}
......@@ -250,7 +254,8 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
{
m_LibListSize.y = clientsize.y - 2;
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 )
......@@ -258,7 +263,8 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
m_CmpListSize.y = clientsize.y - 2;
m_CmpListWindow->SetSize( m_CmpListSize );
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();
......@@ -285,7 +291,8 @@ int WinEDA_ViewlibFrame::BestZoom()
return bestzoom;
}
EDA_Rect BoundaryBox = CurrentLibEntry->GetBoundaryBox( g_ViewUnit, g_ViewConvert );
EDA_Rect BoundaryBox = CurrentLibEntry->GetBoundaryBox( g_ViewUnit,
g_ViewConvert );
itemsize = BoundaryBox.GetSize();
size = DrawPanel->GetClientSize();
......@@ -331,12 +338,12 @@ void WinEDA_ViewlibFrame::ReCreateListLib()
if ( libcache )
libNamesList.Add( libcache->m_Name );
m_LibList->Append(libNamesList);
m_LibList->Append( libNamesList );
// Search for a previous selection:
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 );
found = TRUE;
......@@ -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 )
{
......@@ -364,7 +372,7 @@ void WinEDA_ViewlibFrame::ReCreateListCmp()
if( m_CmpList == NULL )
return;
LibraryStruct* Library = FindLibrary( g_CurrentViewLibraryName.GetData() );
LibraryStruct* Library = FindLibrary( g_CurrentViewLibraryName );
wxArrayString nameList;
m_CmpList->Clear();
......@@ -378,9 +386,7 @@ void WinEDA_ViewlibFrame::ReCreateListCmp()
}
/********************************************************************/
void WinEDA_ViewlibFrame::ClickOnLibList( wxCommandEvent& event )
/********************************************************************/
{
int ii = m_LibList->GetSelection();
......@@ -398,9 +404,7 @@ void WinEDA_ViewlibFrame::ClickOnLibList( wxCommandEvent& event )
}
/****************************************************************/
void WinEDA_ViewlibFrame::ClickOnCmpList( wxCommandEvent& event )
/****************************************************************/
{
int ii = m_CmpList->GetSelection();
......@@ -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();
......
......@@ -22,13 +22,7 @@
#define PREVIOUS_PART -1
/* Routines locales */
/* Variables locales */
/*************************************************************************/
void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
/*************************************************************************/
{
wxString msg;
EDA_LibComponentStruct* LibEntry;
......@@ -63,7 +57,7 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
ALIAS );
if( LibEntry && ( !LibEntry->m_DocFile.IsEmpty() ) )
GetAssociatedDocument( this, LibEntry->m_DocFile,
& wxGetApp().GetLibraryPathList());
&wxGetApp().GetLibraryPathList() );
break;
case ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT:
......@@ -96,26 +90,20 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
}
/*************************************************************************/
void WinEDA_ViewlibFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
/*************************************************************************/
{
}
/********************************************************************************/
bool WinEDA_ViewlibFrame::OnRightClick( const wxPoint& MousePos,
wxMenu* PopMenu )
/********************************************************************************/
{
return true;
}
/**********************************************/
void WinEDA_ViewlibFrame::DisplayLibInfos()
/**********************************************/
/* Affiche en Ligne d'info la librairie en cours de visualisation */
void WinEDA_ViewlibFrame::DisplayLibInfos()
{
wxString msg;
LibraryStruct* Lib;
......@@ -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 )
/**************************************************************/
/* Routine to select and view library Part (NEW, NEXT or PREVIOUS) */
{
LibraryStruct* Lib;
......@@ -209,15 +197,14 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( LibraryStruct* Lib, int Flag )
wxString CmpName;
wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext( &dc );
if( Lib )
NumOfParts = Lib->m_NumOfParts;
NumOfParts = Lib->GetCount();
if( NumOfParts == 0 )
{
DisplayError( this, wxT( "No Library or Library is empty!" ) );
DisplayError( this, wxT( "No library or library is empty!" ) );
return;
}
......@@ -226,9 +213,7 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( LibraryStruct* Lib, int Flag )
if( Flag == NEW_PART )
{
DisplayComponentsNamesInLib( this,
Lib,
CmpName,
DisplayComponentsNamesInLib( this, Lib, CmpName,
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