1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/********************************************/
/* PCBNEW - Gestion des Options et Reglages */
/********************************************/
/* Fichier reglage.cpp */
/*
Affichage et modifications des parametres de travail de PcbNew
Parametres = dimensions des via, pistes, isolements, options...
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
#include "pcbplot.h"
#include "protos.h"
enum {
SAVE_CFG = 1000,
DEL_LIB,
ADD_LIB,
INSERT_LIB,
FORMAT_NETLIST
};
/* Routines Locales */
/*************************************************/
/* classe derivee pour la frame de Configuration */
/*************************************************/
class WinEDA_ConfigFrame: public wxDialog
{
public:
WinEDA_PcbFrame * m_Parent;
wxListBox * ListLibr;
int LibModified;
WinEDA_EnterText * m_TextLibDir;
WinEDA_EnterText * m_TextHelpModulesFileName;
public:
// Constructor and destructor
WinEDA_ConfigFrame(WinEDA_PcbFrame *parent,const wxPoint& pos);
~WinEDA_ConfigFrame() {};
private:
void OnCloseWindow(wxCloseEvent & event);
void SaveCfg(wxCommandEvent& event);
void LibDelFct(wxCommandEvent& event);
void LibInsertFct(wxCommandEvent& event);
void SetNewOptions();
DECLARE_EVENT_TABLE()
};
/* Construction de la table des evenements pour WinEDA_ConfigFrame */
BEGIN_EVENT_TABLE(WinEDA_ConfigFrame, wxDialog)
EVT_BUTTON(SAVE_CFG, WinEDA_ConfigFrame::SaveCfg)
EVT_BUTTON(DEL_LIB, WinEDA_ConfigFrame::LibDelFct)
EVT_BUTTON(ADD_LIB, WinEDA_ConfigFrame::LibInsertFct)
EVT_BUTTON(INSERT_LIB, WinEDA_ConfigFrame::LibInsertFct)
EVT_CLOSE(WinEDA_ConfigFrame::OnCloseWindow)
END_EVENT_TABLE()
/*****************************************************************/
void WinEDA_PcbFrame::InstallConfigFrame(const wxPoint & pos)
/*****************************************************************/
{
WinEDA_ConfigFrame * CfgFrame = new WinEDA_ConfigFrame(this, pos);
CfgFrame->ShowModal(); CfgFrame->Destroy();
}
/************************************************************/
/* Constructeur de WinEDA_ConfigFrame: la fenetre de config */
/************************************************************/
#define X_SIZE 450
#define Y_SIZE 380
WinEDA_ConfigFrame::WinEDA_ConfigFrame(WinEDA_PcbFrame *parent,
const wxPoint& framepos):
wxDialog(parent, -1, "", framepos, wxSize(X_SIZE, Y_SIZE),
DIALOG_STYLE )
{
wxPoint pos;
wxSize size;
wxString title;
wxButton * Button;
m_Parent = parent;
SetFont(*g_DialogFont);
title = _("from ") + EDA_Appl->m_CurrentOptionFile;
SetTitle(title);
LibModified = FALSE;
/* Creation des boutons de commande */
pos.x = 10; pos.y = 5;
Button = new wxButton(this, SAVE_CFG, _("Save Cfg"), pos);
Button->SetForegroundColour(*wxRED);
pos.x = 190;
Button = new wxButton(this, DEL_LIB, _("Del"), pos);
Button->SetForegroundColour(*wxRED);
pos.x += Button->GetSize().x;
Button = new wxButton(this, ADD_LIB, _("Add"), pos );
Button->SetForegroundColour(wxColor(0,80,0));
pos.x += Button->GetSize().x;
Button = new wxButton(this, INSERT_LIB, _("Ins"), pos );
Button->SetForegroundColour(*wxBLUE);
pos.x = 190; pos.y += 35;
wxStaticText * Msg = new wxStaticText(this, -1, _("Lib Modules:"), pos );
pos.y += 15;
ListLibr = new wxListBox(this,
-1,
pos, wxSize(X_SIZE - pos.x -10,190),
0,NULL,
wxLB_ALWAYS_SB|wxLB_SINGLE);
Msg->SetForegroundColour(wxColour(200,0,0) );
if ( g_LibName_List )
{
LibNameItem * libnamestruct = g_LibName_List->FirstLib;
for ( ; libnamestruct != NULL; libnamestruct = libnamestruct->Pnext )
{
ListLibr->Append(libnamestruct->m_Name);
}
}
wxString text;
#define DELTA_VPOS 17
size.x = 120; size.y = 90;
pos.y = 100; pos.x = 10;
new wxStaticBox(this, -1,_("Files ext:"), pos, size);
pos.x += 5; pos.y += DELTA_VPOS;
text = _("Board ext: ") + PcbExtBuffer;
new wxStaticText(this, -1,text , pos);
pos.x += 5; pos.y += DELTA_VPOS;
text = _("Cmp ext: ") + NetCmpExtBuffer;
new wxStaticText(this, -1,text , pos);
pos.y += DELTA_VPOS;
text = _("Lib ext: ") + LibExtBuffer;
new wxStaticText(this, -1,text , pos);
pos.y += DELTA_VPOS;
text = _("Net ext: ") + NetExtBuffer;
new wxStaticText(this, -1,text , pos);
pos.x = 10; pos.y = 260;
size.x = X_SIZE - pos.x - 10; size.y = -1;
m_TextLibDir = new WinEDA_EnterText(this,
_("Lib Modules Dir:"), g_UserLibDirBuffer,
pos, size);
pos.y += m_TextLibDir->GetDimension().y + 25;
wxString DocModuleFileName =
EDA_Appl->m_EDA_CommonConfig->Read("module_doc_file", "pcbnew/footprints.pdf");
m_TextHelpModulesFileName = new WinEDA_EnterText(this,
_("Module Doc File:"), DocModuleFileName,
pos, size);
size.x = X_SIZE;
size.y = pos.y + m_TextHelpModulesFileName->GetDimension().y + 10;
SetClientSize(size);
}
/*****************************************************************/
/* Fonctions de base de WinEDA_ConfigFrame: la fenetre de config */
/*****************************************************************/
void WinEDA_ConfigFrame::OnCloseWindow(wxCloseEvent & event)
{
SetNewOptions();
EndModal(0);
}
/********************************************/
void WinEDA_ConfigFrame::SetNewOptions()
/********************************************/
{
g_UserLibDirBuffer = m_TextLibDir->GetData();
EDA_Appl->m_EDA_CommonConfig->Write("module_doc_file",
m_TextHelpModulesFileName->GetData());
SetRealLibraryPath("modules");
}
/******************************************************/
void WinEDA_ConfigFrame::SaveCfg(wxCommandEvent& event)
/******************************************************/
{
SetNewOptions();
m_Parent->Update_config(this);
}
/********************************************************/
void WinEDA_ConfigFrame::LibDelFct(wxCommandEvent& event)
/********************************************************/
{
int ii;
wxString LibNameSelected;
ii = ListLibr->GetSelection();
if ( ii < 0 ) return;
LibNameSelected = ListLibr->GetStringSelection();
g_LibName_List->RemoveLibName(LibNameSelected);
ListLibr->Delete(ii);
LibModified = TRUE;
}
/*************************************************************/
void WinEDA_ConfigFrame::LibInsertFct(wxCommandEvent& event)
/*************************************************************/
/* Insere ou ajoute une librairie a la liste existante:
La nouvelle librairie est mise avant (insert) ou apres (ajout)
la librairie slectionne
*/
{
int ii;
wxString fullfilename, ShortLibName;
wxString mask ="*";
ii = ListLibr->GetSelection();
if ( ii < 0 ) ii = 0;
if( event.GetId() == ADD_LIB)
{
if( g_LibName_List->FirstLib != NULL ) ii ++; /* Ajout apres selection */
}
SetNewOptions();
mask += LibExtBuffer;
g_RealLibDirBuffer.Replace("\\","/");
fullfilename = EDA_FileSelector( _("library files:"),
g_RealLibDirBuffer, /* Chemin par defaut */
"", /* nom fichier par defaut */
LibExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
0,
TRUE
);
if ( fullfilename == "" ) return;
ShortLibName =
MakeReducedFileName(fullfilename, g_RealLibDirBuffer, LibExtBuffer);
//Addition ou insertion de la librarire
LibModified = TRUE;
wxString SList[1];
SList[0] =wxString(ShortLibName);
if ( g_LibName_List->InsertLibName(SList[0], ii) )
ListLibr->InsertItems(1,SList,ii);
else DisplayError(this, _("Library exists! No Change"));
}