KiCad PCB EDA Suite
PANEL_SETUP_RULES Class Reference

#include <panel_setup_rules.h>

Inheritance diagram for PANEL_SETUP_RULES:
PANEL_SETUP_RULES_BASE

Public Member Functions

 PANEL_SETUP_RULES (PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame)
 
 ~PANEL_SETUP_RULES () override
 

Protected Attributes

wxBoxSizer * m_leftMargin
 
wxBoxSizer * m_topMargin
 
wxStaticText * m_title
 
wxHyperlinkCtrl * m_syntaxHelp
 
wxStyledTextCtrl * m_textEditor
 
wxBitmapButton * m_compileButton
 
WX_HTML_REPORT_BOXm_errorsReport
 

Private Member Functions

void onScintillaCharAdded (wxStyledTextEvent &aEvent)
 
void OnSyntaxHelp (wxHyperlinkEvent &aEvent) override
 
void OnCompile (wxCommandEvent &event) override
 
void OnErrorLinkClicked (wxHtmlLinkEvent &event) override
 
void onCharHook (wxKeyEvent &aEvent)
 
void OnContextMenu (wxMouseEvent &event) override
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 

Private Attributes

PAGED_DIALOGm_Parent
 
PCB_EDIT_FRAMEm_frame
 
SCINTILLA_TRICKSm_scintillaTricks
 
wxString m_originalText
 
wxRegEx m_netClassRegex
 
wxRegEx m_netNameRegex
 
wxRegEx m_typeRegex
 
wxRegEx m_padTypeRegex
 
wxRegEx m_pinTypeRegex
 
wxRegEx m_fabPropRegex
 
HTML_MESSAGE_BOXm_helpWindow
 

Detailed Description

Definition at line 38 of file panel_setup_rules.h.

Constructor & Destructor Documentation

◆ PANEL_SETUP_RULES()

PANEL_SETUP_RULES::PANEL_SETUP_RULES ( PAGED_DIALOG aParent,
PCB_EDIT_FRAME aFrame 
)

Definition at line 43 of file panel_setup_rules.cpp.

43 :
45 m_Parent( aParent ),
46 m_frame( aFrame ),
47 m_scintillaTricks( nullptr ),
48 m_helpWindow( nullptr )
49{
50 m_scintillaTricks = new SCINTILLA_TRICKS( m_textEditor, wxT( "()" ), false,
51 [this]()
52 {
53 wxPostEvent( m_Parent, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
54 } );
55
56 m_textEditor->AutoCompSetSeparator( '|' );
57
58 m_netClassRegex.Compile( "^NetClass\\s*[!=]=\\s*$", wxRE_ADVANCED );
59 m_netNameRegex.Compile( "^NetName\\s*[!=]=\\s*$", wxRE_ADVANCED );
60 m_typeRegex.Compile( "^Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
61 m_padTypeRegex.Compile( "^Pad_Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
62 m_pinTypeRegex.Compile( "^Pin_Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
63 m_fabPropRegex.Compile( "^Fabrication_Property\\s*[!=]=\\s*$", wxRE_ADVANCED );
64
65 m_compileButton->SetBitmap( KiBitmap( BITMAPS::drc ) );
66
67 m_textEditor->SetZoom( Pgm().GetCommonSettings()->m_Appearance.text_editor_zoom );
68
69 m_textEditor->UsePopUp( 0 );
70 m_textEditor->Bind( wxEVT_STC_CHARADDED, &PANEL_SETUP_RULES::onScintillaCharAdded, this );
71 m_textEditor->Bind( wxEVT_STC_AUTOCOMP_CHAR_DELETED, &PANEL_SETUP_RULES::onScintillaCharAdded, this );
72 m_textEditor->Bind( wxEVT_CHAR_HOOK, &PANEL_SETUP_RULES::onCharHook, this );
73}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
wxTreebook * GetTreebook()
Definition: paged_dialog.h:37
wxStyledTextCtrl * m_textEditor
PANEL_SETUP_RULES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxBitmapButton * m_compileButton
PAGED_DIALOG * m_Parent
void onScintillaCharAdded(wxStyledTextEvent &aEvent)
PCB_EDIT_FRAME * m_frame
HTML_MESSAGE_BOX * m_helpWindow
void onCharHook(wxKeyEvent &aEvent)
SCINTILLA_TRICKS * m_scintillaTricks
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References drc, KiBitmap(), PANEL_SETUP_RULES_BASE::m_compileButton, m_fabPropRegex, m_netClassRegex, m_netNameRegex, m_padTypeRegex, m_Parent, m_pinTypeRegex, m_scintillaTricks, PANEL_SETUP_RULES_BASE::m_textEditor, m_typeRegex, onCharHook(), onScintillaCharAdded(), and Pgm().

◆ ~PANEL_SETUP_RULES()

PANEL_SETUP_RULES::~PANEL_SETUP_RULES ( )
override

Definition at line 76 of file panel_setup_rules.cpp.

77{
78 Pgm().GetCommonSettings()->m_Appearance.text_editor_zoom = m_textEditor->GetZoom();
79
80 delete m_scintillaTricks;
81
82 if( m_helpWindow )
83 m_helpWindow->Destroy();
84};

References m_helpWindow, m_scintillaTricks, PANEL_SETUP_RULES_BASE::m_textEditor, and Pgm().

Member Function Documentation

◆ onCharHook()

void PANEL_SETUP_RULES::onCharHook ( wxKeyEvent &  aEvent)
private

Definition at line 87 of file panel_setup_rules.cpp.

88{
89 if( aEvent.GetKeyCode() == WXK_ESCAPE && !m_textEditor->AutoCompActive() )
90 {
91 if( m_originalText != m_textEditor->GetText() )
92 {
93 if( !IsOK( this, _( "Cancel Changes?" ) ) )
94 return;
95 }
96 }
97
98 aEvent.Skip();
99}
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:342
#define _(s)

References _, IsOK(), m_originalText, and PANEL_SETUP_RULES_BASE::m_textEditor.

Referenced by PANEL_SETUP_RULES().

◆ OnCompile()

void PANEL_SETUP_RULES::OnCompile ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_RULES_BASE.

Definition at line 531 of file panel_setup_rules.cpp.

532{
534
535 try
536 {
537 std::vector<std::shared_ptr<DRC_RULE>> dummyRules;
538
539 DRC_RULES_PARSER parser( m_textEditor->GetText(), _( "DRC rules" ) );
540
541 parser.Parse( dummyRules, m_errorsReport );
542 }
543 catch( PARSE_ERROR& pe )
544 {
545 wxString msg = wxString::Format( wxT( "%s <a href='%d:%d'>%s</a>%s" ),
546 _( "ERROR:" ),
547 pe.lineNumber,
548 pe.byteIndex,
549 pe.ParseProblem(),
550 wxEmptyString );
551
553 }
554
556}
WX_HTML_REPORT_BOX * m_errorsReport
void Clear()
Delete the stored messages.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
void Flush()
Build the HTML messages page.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
@ RPT_SEVERITY_ERROR
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:119
int lineNumber
at which line number, 1 based index.
Definition: ki_exception.h:120
const wxString ParseProblem()
Definition: ki_exception.h:150
int byteIndex
at which byte offset within the line, 1 based index
Definition: ki_exception.h:121

References _, PARSE_ERROR::byteIndex, WX_HTML_REPORT_BOX::Clear(), WX_HTML_REPORT_BOX::Flush(), Format(), PARSE_ERROR::lineNumber, PANEL_SETUP_RULES_BASE::m_errorsReport, PANEL_SETUP_RULES_BASE::m_textEditor, DRC_RULES_PARSER::Parse(), PARSE_ERROR::ParseProblem(), WX_HTML_REPORT_BOX::Report(), and RPT_SEVERITY_ERROR.

Referenced by TransferDataToWindow().

◆ OnContextMenu()

void PANEL_SETUP_RULES::OnContextMenu ( wxMouseEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_RULES_BASE.

Definition at line 102 of file panel_setup_rules.cpp.

103{
104 wxMenu menu;
105
106 menu.Append( wxID_UNDO, _( "Undo" ) );
107 menu.Append( wxID_REDO, _( "Redo" ) );
108
109 menu.AppendSeparator();
110
111 menu.Append( 1, _( "Cut" ) ); // Don't use wxID_CUT, wxID_COPY, etc. On Mac (at least),
112 menu.Append( 2, _( "Copy" ) ); // wxWidgets never delivers them to us.
113 menu.Append( 3, _( "Paste" ) );
114 menu.Append( 4, _( "Delete" ) );
115
116 menu.AppendSeparator();
117
118 menu.Append( 5, _( "Select All" ) );
119
120 menu.AppendSeparator();
121
122 menu.Append( wxID_ZOOM_IN, _( "Zoom In" ) );
123 menu.Append( wxID_ZOOM_OUT, _( "Zoom Out" ) );
124
125
126 switch( GetPopupMenuSelectionFromUser( menu ) )
127 {
128 case wxID_UNDO:
129 m_textEditor->Undo();
130 break;
131 case wxID_REDO:
132 m_textEditor->Redo();
133 break;
134
135 case 1:
136 m_textEditor->Cut();
137 break;
138 case 2:
139 m_textEditor->Copy();
140 break;
141 case 3:
142 m_textEditor->Paste();
143 break;
144 case 4:
145 {
146 long from, to;
147 m_textEditor->GetSelection( &from, &to );
148
149 if( to > from )
150 m_textEditor->DeleteRange( from, to );
151
152 break;
153 }
154
155 case 5:
156 m_textEditor->SelectAll();
157 break;
158
159 case wxID_ZOOM_IN:
160 m_textEditor->ZoomIn();
161 break;
162 case wxID_ZOOM_OUT:
163 m_textEditor->ZoomOut();
164 break;
165 }
166}

References _, and PANEL_SETUP_RULES_BASE::m_textEditor.

◆ OnErrorLinkClicked()

void PANEL_SETUP_RULES::OnErrorLinkClicked ( wxHtmlLinkEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_RULES_BASE.

Definition at line 559 of file panel_setup_rules.cpp.

560{
561 wxString link = event.GetLinkInfo().GetHref();
562 wxArrayString parts;
563 long line = 0, offset = 0;
564
565 wxStringSplit( link, parts, ':' );
566
567 if( parts.size() > 1 )
568 {
569 parts[0].ToLong( &line );
570 parts[1].ToLong( &offset );
571 }
572
573 int pos = m_textEditor->PositionFromLine( line - 1 ) + ( offset - 1 );
574
575 m_textEditor->GotoPos( pos );
576
577 m_textEditor->SetFocus();
578}
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.

References PANEL_SETUP_RULES_BASE::m_textEditor, and wxStringSplit().

◆ onScintillaCharAdded()

void PANEL_SETUP_RULES::onScintillaCharAdded ( wxStyledTextEvent &  aEvent)
private

Definition at line 169 of file panel_setup_rules.cpp.

170{
172 m_textEditor->SearchAnchor();
173
174 wxString rules = m_textEditor->GetText();
175 int currentPos = m_textEditor->GetCurrentPos();
176 int startPos = 0;
177
178 for( int line = m_textEditor->LineFromPosition( currentPos ); line > 0; line-- )
179 {
180 int lineStart = m_textEditor->PositionFromLine( line );
181 wxString beginning = m_textEditor->GetTextRange( lineStart, lineStart + 10 );
182
183 if( beginning.StartsWith( wxT( "(rule " ) ) )
184 {
185 startPos = lineStart;
186 break;
187 }
188 }
189
190 enum
191 {
192 NONE,
193 STRING,
194 SEXPR_OPEN,
195 SEXPR_TOKEN,
196 SEXPR_STRING,
197 STRUCT_REF
198 };
199
200 auto isDisallowToken =
201 []( const wxString& token ) -> bool
202 {
203 return token == wxT( "buried_via" )
204 || token == wxT( "graphic" )
205 || token == wxT( "hole" )
206 || token == wxT( "micro_via" )
207 || token == wxT( "pad" )
208 || token == wxT( "text" )
209 || token == wxT( "track" )
210 || token == wxT( "via" )
211 || token == wxT( "zone" );
212 };
213
214 std::stack<wxString> sexprs;
215 wxString partial;
216 wxString last;
217 int context = NONE;
218 int expr_context = NONE;
219
220 for( int i = startPos; i < currentPos; ++i )
221 {
222 wxChar c = m_textEditor->GetCharAt( i );
223
224 if( c == '\\' )
225 {
226 i++; // skip escaped char
227 }
228 else if( context == STRING )
229 {
230 if( c == '"' )
231 {
232 context = NONE;
233 }
234 else
235 {
236 if( expr_context == STRING )
237 {
238 if( c == '\'' )
239 expr_context = NONE;
240 else
241 partial += c;
242 }
243 else if( c == '\'' )
244 {
245 last = partial;
246 partial = wxEmptyString;
247 expr_context = STRING;
248 }
249 else if( c == '.' )
250 {
251 partial = wxEmptyString;
252 expr_context = STRUCT_REF;
253 }
254 else
255 {
256 partial += c;
257 }
258 }
259 }
260 else if( c == '"' )
261 {
262 last = partial;
263 partial = wxEmptyString;
264 context = STRING;
265 }
266 else if( c == '(' )
267 {
268 if( context == SEXPR_OPEN && !partial.IsEmpty() )
269 {
270 m_textEditor->AutoCompCancel();
271 sexprs.push( partial );
272 }
273
274 partial = wxEmptyString;
275 context = SEXPR_OPEN;
276 }
277 else if( c == ')' )
278 {
279 while( !sexprs.empty() && ( sexprs.top() == wxT( "assertion" )
280 || sexprs.top() == wxT( "disallow" )
281 || isDisallowToken( sexprs.top() )
282 || sexprs.top() == wxT( "min_resolved_spokes" )
283 || sexprs.top() == wxT( "zone_connection" ) ) )
284 {
285 sexprs.pop();
286 }
287
288 if( !sexprs.empty() )
289 sexprs.pop();
290
291 context = NONE;
292 }
293 else if( c == ' ' )
294 {
295 if( context == SEXPR_OPEN && ( partial == wxT( "constraint" )
296 || partial == wxT( "disallow" )
297 || partial == wxT( "layer" )
298 || partial == wxT( "severity" ) ) )
299 {
300 m_textEditor->AutoCompCancel();
301 sexprs.push( partial );
302
303 partial = wxEmptyString;
304 context = SEXPR_TOKEN;
305 continue;
306 }
307 else if( partial == wxT( "disallow" )
308 || isDisallowToken( partial )
309 || partial == wxT( "min_resolved_spokes" )
310 || partial == wxT( "zone_connection" ) )
311 {
312 m_textEditor->AutoCompCancel();
313 sexprs.push( partial );
314
315 partial = wxEmptyString;
316 context = SEXPR_TOKEN;
317 continue;
318 }
319 else if( partial == wxT( "rule" )
320 || partial == wxT( "assertion" )
321 || partial == wxT( "condition" ) )
322 {
323 m_textEditor->AutoCompCancel();
324 sexprs.push( partial );
325
326 partial = wxEmptyString;
327 context = SEXPR_STRING;
328 continue;
329 }
330
331 context = NONE;
332 }
333 else
334 {
335 partial += c;
336 }
337 }
338
339 wxString tokens;
340
341 if( context == SEXPR_OPEN )
342 {
343 if( sexprs.empty() )
344 {
345 tokens = wxT( "rule|"
346 "version" );
347 }
348 else if( sexprs.top() == wxT( "rule" ) )
349 {
350 tokens = wxT( "condition|"
351 "constraint|"
352 "layer|"
353 "severity" );
354 }
355 else if( sexprs.top() == wxT( "constraint" ) )
356 {
357 tokens = wxT( "max|min|opt" );
358 }
359 }
360 else if( context == SEXPR_TOKEN )
361 {
362 if( sexprs.empty() )
363 {
364 /* badly formed grammar */
365 }
366 else if( sexprs.top() == wxT( "constraint" ) )
367 {
368 tokens = wxT( "annular_width|"
369 "assertion|"
370 "clearance|"
371 "connection_width|"
372 "courtyard_clearance|"
373 "diff_pair_gap|"
374 "diff_pair_uncoupled|"
375 "disallow|"
376 "edge_clearance|"
377 "length|"
378 "hole_clearance|"
379 "hole_size|"
380 "hole_to_hole|"
381 "min_resolved_spokes|"
382 "physical_clearance|"
383 "physical_hole_clearance|"
384 "silk_clearance|"
385 "skew|"
386 "text_height|"
387 "text_thickness|"
388 "thermal_relief_gap|"
389 "thermal_spoke_width|"
390 "track_width|"
391 "via_count|"
392 "via_diameter|"
393 "zone_connection" );
394 }
395 else if( sexprs.top() == wxT( "disallow" ) || isDisallowToken( sexprs.top() ) )
396 {
397 tokens = wxT( "buried_via|"
398 "graphic|"
399 "hole|"
400 "micro_via|"
401 "pad|"
402 "text|"
403 "track|"
404 "via|"
405 "zone" );
406 }
407 else if( sexprs.top() == wxT( "zone_connection" ) )
408 {
409 tokens = wxT( "none|solid|thermal_reliefs" );
410 }
411 else if( sexprs.top() == wxT( "min_resolved_spokes" ) )
412 {
413 tokens = wxT( "0|1|2|3|4" );
414 }
415 else if( sexprs.top() == wxT( "layer" ) )
416 {
417 tokens = wxT( "inner|outer|\"x\"" );
418 }
419 else if( sexprs.top() == wxT( "severity" ) )
420 {
421 tokens = wxT( "warning|error|ignore|exclusion" );
422 }
423 }
424 else if( context == SEXPR_STRING && !sexprs.empty()
425 && ( sexprs.top() == wxT( "condition" ) || sexprs.top() == wxT( "assertion" ) ) )
426 {
427 m_textEditor->AddText( wxT( "\"" ) );
428 }
429 else if( context == STRING && !sexprs.empty()
430 && ( sexprs.top() == wxT( "condition" ) || sexprs.top() == wxT( "assertion" ) ) )
431 {
432 if( expr_context == STRUCT_REF )
433 {
435 std::set<wxString> propNames;
436
437 for( const PROPERTY_MANAGER::CLASS_INFO& cls : propMgr.GetAllClasses() )
438 {
439 const PROPERTY_LIST& props = propMgr.GetProperties( cls.type );
440
441 for( PROPERTY_BASE* prop : props )
442 {
443 wxString ref( prop->Name() );
444 ref.Replace( wxT( " " ), wxT( "_" ) );
445 propNames.insert( ref );
446 }
447 }
448
449 for( const wxString& propName : propNames )
450 tokens += wxT( "|" ) + propName;
451
453
454 for( const wxString& funcSig : functions.GetSignatures() )
455 {
456 if( !funcSig.Contains( "DEPRECATED" ) )
457 tokens += wxT( "|" ) + funcSig;
458 }
459 }
460 else if( expr_context == STRING )
461 {
462 if( m_netClassRegex.Matches( last ) )
463 {
465 std::shared_ptr<NET_SETTINGS>& netSettings = bds.m_NetSettings;
466
467 for( const auto& [ name, netclass ] : netSettings->m_NetClasses )
468 tokens += wxT( "|" ) + name;
469 }
470 else if( m_netNameRegex.Matches( last ) )
471 {
472 BOARD* board = m_frame->GetBoard();
473
474 for( const wxString& netnameCandidate : board->GetNetClassAssignmentCandidates() )
475 tokens += wxT( "|" ) + netnameCandidate;
476 }
477 else if( m_typeRegex.Matches( last ) )
478 {
479 tokens = wxT( "Dimension|"
480 "Footprint|"
481 "Graphic|"
482 "Group|"
483 "Leader|"
484 "Pad|"
485 "Target|"
486 "Text|"
487 "Track|"
488 "Via|"
489 "Zone" );
490 }
491 else if( m_padTypeRegex.Matches( last ) )
492 {
493 tokens = wxT( "Through-hole|"
494 "SMD|"
495 "Edge connector|"
496 "NPTH, mechanical" );
497 }
498 else if( m_pinTypeRegex.Matches( last ) )
499 {
500 tokens = wxT( "Input|"
501 "Output|"
502 "Bidirectional|"
503 "Tri-state|"
504 "Passive|"
505 "Free|"
506 "Unspecified|"
507 "Power input|"
508 "Power output|"
509 "Open collector|"
510 "Open emitter|"
511 "Unconnected" );
512 }
513 else if( m_fabPropRegex.Matches( last ) )
514 {
515 tokens = wxT( "None|"
516 "BGA pad|"
517 "Fiducial, global to board|"
518 "Fiducial, local to footprint|"
519 "Test point pad|"
520 "Heatsink pad|"
521 "Castellated pad" );
522 }
523 }
524 }
525
526 if( !tokens.IsEmpty() )
527 m_scintillaTricks->DoAutocomplete( partial, wxSplit( tokens, '|' ) );
528}
const char * name
Definition: DXF_plotter.cpp:56
Container for design settings for a BOARD object.
std::shared_ptr< NET_SETTINGS > m_NetSettings
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
std::set< wxString > GetNetClassAssignmentCandidates() const
Return the set of netname candidates for netclass assignment.
Definition: board.cpp:1462
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:643
void SetModified()
Definition: paged_dialog.h:41
BOARD * GetBoard() const
const wxArrayString GetSignatures() const
static PCB_EXPR_BUILTIN_FUNCTIONS & Instance()
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:67
CLASSES_INFO GetAllClasses()
const PROPERTY_LIST & GetProperties(TYPE_ID aType) const
Return all properties for a specific type.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:69
void DoAutocomplete(const wxString &aPartial, const wxArrayString &aTokens)
std::vector< PROPERTY_BASE * > PROPERTY_LIST
Definition: property_mgr.h:46

References SCINTILLA_TRICKS::DoAutocomplete(), PROPERTY_MANAGER::GetAllClasses(), PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), BOARD::GetNetClassAssignmentCandidates(), PROPERTY_MANAGER::GetProperties(), PCB_EXPR_BUILTIN_FUNCTIONS::GetSignatures(), PROPERTY_MANAGER::Instance(), PCB_EXPR_BUILTIN_FUNCTIONS::Instance(), m_fabPropRegex, m_frame, m_netClassRegex, m_netNameRegex, BOARD_DESIGN_SETTINGS::m_NetSettings, m_padTypeRegex, m_Parent, m_pinTypeRegex, m_scintillaTricks, PANEL_SETUP_RULES_BASE::m_textEditor, m_typeRegex, name, NONE, PAGED_DIALOG::SetModified(), and STRING.

Referenced by PANEL_SETUP_RULES().

◆ OnSyntaxHelp()

void PANEL_SETUP_RULES::OnSyntaxHelp ( wxHyperlinkEvent &  aEvent)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_RULES_BASE.

Definition at line 646 of file panel_setup_rules.cpp.

647{
648 if( m_helpWindow )
649 {
651 return;
652 }
653
654 wxString msg =
656 ;
657
658#ifdef __WXMAC__
659 msg.Replace( wxT( "Ctrl+" ), wxT( "Cmd+" ) );
660#endif
661
662 m_helpWindow = new HTML_MESSAGE_BOX( nullptr, _( "Syntax Help" ) );
663 m_helpWindow->SetDialogSizeInDU( 320, 320 );
664
665 wxString html_txt;
666 ConvertMarkdown2Html( wxGetTranslation( msg ), html_txt );
667 m_helpWindow->AddHTML_Text( html_txt );
668
670}
void SetDialogSizeInDU(int aWidth, int aHeight)
Set the dialog size, using a "logical" value.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
void ShowModeless()
Show a modeless version of the dialog (without an OK button).
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)

References _, HTML_MESSAGE_BOX::AddHTML_Text(), ConvertMarkdown2Html(), m_helpWindow, HTML_MESSAGE_BOX::SetDialogSizeInDU(), and HTML_MESSAGE_BOX::ShowModeless().

◆ TransferDataFromWindow()

bool PANEL_SETUP_RULES::TransferDataFromWindow ( )
overrideprivate

Definition at line 617 of file panel_setup_rules.cpp.

618{
619 if( m_originalText == m_textEditor->GetText() )
620 return true;
621
622 if( m_frame->Prj().IsNullProject() )
623 return true;
624
625 wxString rulesFilepath = m_frame->GetDesignRulesPath();
626
627 try
628 {
629 if( m_textEditor->SaveFile( rulesFilepath ) )
630 {
631 m_frame->GetBoard()->GetDesignSettings().m_DRCEngine->InitEngine( rulesFilepath );
632 return true;
633 }
634 }
635 catch( PARSE_ERROR& )
636 {
637 // Don't lock them in to the Setup dialog if they have bad rules. They've already
638 // saved them so we can allow an exit.
639 return true;
640 }
641
642 return false;
643}
std::shared_ptr< DRC_ENGINE > m_DRCEngine
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
Definition: project.cpp:138

References PCB_BASE_FRAME::GetBoard(), PCB_BASE_EDIT_FRAME::GetDesignRulesPath(), BOARD::GetDesignSettings(), PROJECT::IsNullProject(), BOARD_DESIGN_SETTINGS::m_DRCEngine, m_frame, m_originalText, PANEL_SETUP_RULES_BASE::m_textEditor, and KIWAY_HOLDER::Prj().

◆ TransferDataToWindow()

bool PANEL_SETUP_RULES::TransferDataToWindow ( )
overrideprivate

Definition at line 581 of file panel_setup_rules.cpp.

582{
583 wxFileName rulesFile( m_frame->GetDesignRulesPath() );
584
585 if( rulesFile.FileExists() )
586 {
587 wxTextFile file( rulesFile.GetFullPath() );
588
589 if( file.Open() )
590 {
591 for ( wxString str = file.GetFirstLine(); !file.Eof(); str = file.GetNextLine() )
592 {
594 m_textEditor->AddText( str << '\n' );
595 }
596
597 m_textEditor->EmptyUndoBuffer();
598
599 wxCommandEvent dummy;
600 OnCompile( dummy );
601 }
602 }
603
604 m_originalText = m_textEditor->GetText();
605
606 if( m_frame->Prj().IsNullProject() )
607 {
608 m_textEditor->ClearAll();
609 m_textEditor->AddText( _( "Design rules cannot be added without a project" ) );
610 m_textEditor->Disable();
611 }
612
613 return true;
614}
void OnCompile(wxCommandEvent &event) override
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74
bool ConvertSmartQuotesAndDashes(wxString *aString)
Convert curly quotes and em/en dashes to straight quotes and dashes.

References _, ConvertSmartQuotesAndDashes(), dummy(), PCB_BASE_EDIT_FRAME::GetDesignRulesPath(), PROJECT::IsNullProject(), m_frame, m_originalText, PANEL_SETUP_RULES_BASE::m_textEditor, OnCompile(), and KIWAY_HOLDER::Prj().

Member Data Documentation

◆ m_compileButton

wxBitmapButton* PANEL_SETUP_RULES_BASE::m_compileButton
protectedinherited

◆ m_errorsReport

WX_HTML_REPORT_BOX* PANEL_SETUP_RULES_BASE::m_errorsReport
protectedinherited

◆ m_fabPropRegex

wxRegEx PANEL_SETUP_RULES::m_fabPropRegex
private

Definition at line 66 of file panel_setup_rules.h.

Referenced by onScintillaCharAdded(), and PANEL_SETUP_RULES().

◆ m_frame

PCB_EDIT_FRAME* PANEL_SETUP_RULES::m_frame
private

◆ m_helpWindow

HTML_MESSAGE_BOX* PANEL_SETUP_RULES::m_helpWindow
private

Definition at line 68 of file panel_setup_rules.h.

Referenced by OnSyntaxHelp(), and ~PANEL_SETUP_RULES().

◆ m_leftMargin

wxBoxSizer* PANEL_SETUP_RULES_BASE::m_leftMargin
protectedinherited

◆ m_netClassRegex

wxRegEx PANEL_SETUP_RULES::m_netClassRegex
private

Definition at line 61 of file panel_setup_rules.h.

Referenced by onScintillaCharAdded(), and PANEL_SETUP_RULES().

◆ m_netNameRegex

wxRegEx PANEL_SETUP_RULES::m_netNameRegex
private

Definition at line 62 of file panel_setup_rules.h.

Referenced by onScintillaCharAdded(), and PANEL_SETUP_RULES().

◆ m_originalText

wxString PANEL_SETUP_RULES::m_originalText
private

Definition at line 59 of file panel_setup_rules.h.

Referenced by onCharHook(), TransferDataFromWindow(), and TransferDataToWindow().

◆ m_padTypeRegex

wxRegEx PANEL_SETUP_RULES::m_padTypeRegex
private

Definition at line 64 of file panel_setup_rules.h.

Referenced by onScintillaCharAdded(), and PANEL_SETUP_RULES().

◆ m_Parent

PAGED_DIALOG* PANEL_SETUP_RULES::m_Parent
private

Definition at line 56 of file panel_setup_rules.h.

Referenced by onScintillaCharAdded(), and PANEL_SETUP_RULES().

◆ m_pinTypeRegex

wxRegEx PANEL_SETUP_RULES::m_pinTypeRegex
private

Definition at line 65 of file panel_setup_rules.h.

Referenced by onScintillaCharAdded(), and PANEL_SETUP_RULES().

◆ m_scintillaTricks

SCINTILLA_TRICKS* PANEL_SETUP_RULES::m_scintillaTricks
private

Definition at line 58 of file panel_setup_rules.h.

Referenced by onScintillaCharAdded(), PANEL_SETUP_RULES(), and ~PANEL_SETUP_RULES().

◆ m_syntaxHelp

wxHyperlinkCtrl* PANEL_SETUP_RULES_BASE::m_syntaxHelp
protectedinherited

◆ m_textEditor

◆ m_title

wxStaticText* PANEL_SETUP_RULES_BASE::m_title
protectedinherited

◆ m_topMargin

wxBoxSizer* PANEL_SETUP_RULES_BASE::m_topMargin
protectedinherited

◆ m_typeRegex

wxRegEx PANEL_SETUP_RULES::m_typeRegex
private

Definition at line 63 of file panel_setup_rules.h.

Referenced by onScintillaCharAdded(), and PANEL_SETUP_RULES().


The documentation for this class was generated from the following files: