Stop using wxDialog::EndModal() from inside dialogs.

Calling wxDialog::EndModal() directly from inside the dialog is a
potential bug if the dialog is shown in the modeless or window modal
(quasi-modal).  Use the internal button events where possible and
check for the appropriate mode before calling the correct end dialog
function.
This commit is contained in:
Wayne Stambaugh 2021-07-21 17:37:49 -04:00
parent 0fb864d596
commit 1a301d8eea
60 changed files with 698 additions and 1011 deletions

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version v3.8.0)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -35,13 +35,11 @@ DIALOG_DISPLAY_HTML_TEXT_BASE::DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent,
// Connect Events
m_htmlWindow->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnHTMLLinkClicked ), NULL, this );
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnOKButtonClick ), NULL, this );
}
DIALOG_DISPLAY_HTML_TEXT_BASE::~DIALOG_DISPLAY_HTML_TEXT_BASE()
{
// Disconnect Events
m_htmlWindow->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnHTMLLinkClicked ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnOKButtonClick ), NULL, this );
}

View File

@ -14,6 +14,7 @@
<property name="file">dialog_display_info_HTML_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_display_info_HTML</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -133,7 +135,6 @@
<property name="minimum_size"></property>
<property name="name">m_sdbSizer1</property>
<property name="permission">protected</property>
<event name="OnOKButtonClick">OnOKButtonClick</event>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version v3.8.0)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -37,7 +37,6 @@ class DIALOG_DISPLAY_HTML_TEXT_BASE : public DIALOG_SHIM
// Virtual event handlers, overide them in your derived class
virtual void OnHTMLLinkClicked( wxHtmlLinkEvent& event ) { event.Skip(); }
virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,6 +24,7 @@
#include <dialogs/dialog_locked_items_query.h>
#include <bitmaps.h>
DIALOG_LOCKED_ITEMS_QUERY::DIALOG_LOCKED_ITEMS_QUERY( wxWindow* aParent, int aLockedItemCount ) :
DIALOG_LOCKED_ITEMS_QUERY_BASE( aParent )
{
@ -46,19 +47,8 @@ DIALOG_LOCKED_ITEMS_QUERY::DIALOG_LOCKED_ITEMS_QUERY( wxWindow* aParent, int aLo
void DIALOG_LOCKED_ITEMS_QUERY::onOverrideLocks( wxCommandEvent& event )
{
EndModal( wxID_APPLY );
}
void DIALOG_LOCKED_ITEMS_QUERY::onOkClick( wxCommandEvent& event )
{
EndModal( wxID_OK );
}
void DIALOG_LOCKED_ITEMS_QUERY::onCancelClick( wxCommandEvent& event )
{
EndModal( wxID_CANCEL );
// This will choose the correct way to end the dialog no matter how is was shown.
EndDialog( wxID_APPLY );
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -55,7 +55,7 @@ DIALOG_LOCKED_ITEMS_QUERY_BASE::DIALOG_LOCKED_ITEMS_QUERY_BASE( wxWindow* parent
m_overrideBtn = new wxButton( this, wxID_ANY, _("Override Locks"), wxDefaultPosition, wxDefaultSize, 0 );
m_overrideBtn->SetToolTip( _("Override locks and apply the operation on all the items selected.\nAny locked items will remain locked after the operation is complete.") );
bButtonSizer->Add( m_overrideBtn, 0, wxALL, 10 );
bButtonSizer->Add( m_overrideBtn, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
@ -64,10 +64,10 @@ DIALOG_LOCKED_ITEMS_QUERY_BASE::DIALOG_LOCKED_ITEMS_QUERY_BASE( wxWindow* parent
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bButtonSizer->Add( m_sdbSizer, 1, wxALL, 5 );
bButtonSizer->Add( m_sdbSizer, 1, wxBOTTOM|wxTOP, 5 );
bSizerMain->Add( bButtonSizer, 0, wxEXPAND|wxALL, 5 );
bSizerMain->Add( bButtonSizer, 0, wxEXPAND, 5 );
this->SetSizer( bSizerMain );
@ -77,8 +77,6 @@ DIALOG_LOCKED_ITEMS_QUERY_BASE::DIALOG_LOCKED_ITEMS_QUERY_BASE( wxWindow* parent
// Connect Events
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::OnInitDlg ) );
m_overrideBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onOverrideLocks ), NULL, this );
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onCancelClick ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onOkClick ), NULL, this );
}
DIALOG_LOCKED_ITEMS_QUERY_BASE::~DIALOG_LOCKED_ITEMS_QUERY_BASE()
@ -86,7 +84,5 @@ DIALOG_LOCKED_ITEMS_QUERY_BASE::~DIALOG_LOCKED_ITEMS_QUERY_BASE()
// Disconnect Events
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::OnInitDlg ) );
m_overrideBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onOverrideLocks ), NULL, this );
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onCancelClick ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onOkClick ), NULL, this );
}

View File

@ -14,6 +14,7 @@
<property name="file">dialog_locked_items_query_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_locked_items_query</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -344,7 +346,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
@ -353,7 +355,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">10</property>
<property name="flag">wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="0">
<property name="BottomDockable">1</property>
@ -364,6 +366,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -426,7 +429,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="flag">wxBOTTOM|wxTOP</property>
<property name="proportion">1</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
@ -440,8 +443,6 @@
<property name="minimum_size"></property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnCancelButtonClick">onCancelClick</event>
<event name="OnOKButtonClick">onOkClick</event>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -49,8 +49,6 @@ class DIALOG_LOCKED_ITEMS_QUERY_BASE : public DIALOG_SHIM
// Virtual event handlers, overide them in your derived class
virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); }
virtual void onOverrideLocks( wxCommandEvent& event ) { event.Skip(); }
virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2018 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify it
@ -127,6 +127,7 @@ double DIALOG_PRINT_GENERIC::getScaleValue()
wxString::Format( _( "Warning: Scale option set to a very small value.\n"
" Clamped to %f" ), scale ) );
}
return scale;
}
@ -268,17 +269,11 @@ void DIALOG_PRINT_GENERIC::onPrintButtonClick( wxCommandEvent& event )
}
void DIALOG_PRINT_GENERIC::onCloseButton( wxCommandEvent& event )
void DIALOG_PRINT_GENERIC::onCancelButtonClick( wxCommandEvent& event )
{
saveSettings();
if( IsQuasiModal() )
EndQuasiModal( wxID_CANCEL );
if( IsModal() )
EndModal( wxID_CANCEL );
Close();
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -118,6 +118,7 @@ DIALOG_PRINT_GENERIC_BASE::DIALOG_PRINT_GENERIC_BASE( wxWindow* parent, wxWindow
this->SetSizer( bMainSizer );
this->Layout();
bMainSizer->Fit( this );
this->Centre( wxBOTH );
@ -126,7 +127,7 @@ DIALOG_PRINT_GENERIC_BASE::DIALOG_PRINT_GENERIC_BASE( wxWindow* parent, wxWindow
m_scaleCustomText->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onSetCustomScale ), NULL, this );
m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPageSetup ), NULL, this );
m_sdbSizer1Apply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPrintPreview ), NULL, this );
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onCloseButton ), NULL, this );
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onCancelButtonClick ), NULL, this );
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPrintButtonClick ), NULL, this );
}
@ -137,7 +138,7 @@ DIALOG_PRINT_GENERIC_BASE::~DIALOG_PRINT_GENERIC_BASE()
m_scaleCustomText->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onSetCustomScale ), NULL, this );
m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPageSetup ), NULL, this );
m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPrintPreview ), NULL, this );
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onCloseButton ), NULL, this );
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onCancelButtonClick ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPrintButtonClick ), NULL, this );
}

View File

@ -14,6 +14,7 @@
<property name="file">dialog_print_generic_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">DIALOG_PRINT_GENERIC</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">1</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -45,7 +47,7 @@
<property name="minimum_size">-1,-1</property>
<property name="name">DIALOG_PRINT_GENERIC_BASE</property>
<property name="pos"></property>
<property name="size">410,476</property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Print</property>
@ -692,6 +694,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -769,7 +772,7 @@
<property name="name">m_sdbSizer1</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick">onPrintPreview</event>
<event name="OnCancelButtonClick">onCloseButton</event>
<event name="OnCancelButtonClick">onCancelButtonClick</event>
<event name="OnOKButtonClick">onPrintButtonClick</event>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -25,10 +25,10 @@
#include <wx/radiobut.h>
#include <wx/textctrl.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@ -69,13 +69,13 @@ class DIALOG_PRINT_GENERIC_BASE : public DIALOG_SHIM
virtual void onSetCustomScale( wxCommandEvent& event ) { event.Skip(); }
virtual void onPageSetup( wxCommandEvent& event ) { event.Skip(); }
virtual void onPrintPreview( wxCommandEvent& event ) { event.Skip(); }
virtual void onCloseButton( wxCommandEvent& event ) { event.Skip(); }
virtual void onCancelButtonClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onPrintButtonClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_PRINT_GENERIC_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 410,476 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_PRINT_GENERIC_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_PRINT_GENERIC_BASE();
};

View File

@ -29,7 +29,7 @@
#include <macros.h>
// wxWidgets spends *far* too long calcuating column widths (most of it, believe it or
// wxWidgets spends *far* too long calculating column widths (most of it, believe it or
// not, in repeatedly creating/destroying a wxDC to do the measurement in).
// Use default column widths instead.
static int DEFAULT_SINGLE_COL_WIDTH = 260;
@ -215,11 +215,12 @@ void EDA_LIST_DIALOG::InsertItems( const std::vector< wxArrayString >& itemList,
void EDA_LIST_DIALOG::onListItemActivated( wxListEvent& event )
{
EndModal( wxID_OK );
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
}
/* Sort alphabetically, case insensitive.
/*
* Sort alphabetically, case insensitive.
*/
static int wxCALLBACK myCompareFunction( wxIntPtr aItem1, wxIntPtr aItem2,
wxIntPtr WXUNUSED( aSortData ) )

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -131,7 +131,7 @@ bool EDA_VIEW_SWITCHER::TryBefore( wxEvent& aEvent )
// Check for control key trailing edge
if( !wxGetKeyState( WXK_RAW_CONTROL ) )
{
EndModal( wxID_OK );
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
}
return DIALOG_SHIM::TryBefore( aEvent );

View File

@ -53,19 +53,6 @@ HTML_MESSAGE_BOX::~HTML_MESSAGE_BOX()
}
void HTML_MESSAGE_BOX::OnOKButtonClick( wxCommandEvent& event )
{
// the dialog can be shown quasi-model, modal, or not modeless.
// therefore, use the right way to close it.
if( IsQuasiModal() )
EndQuasiModal( wxID_OK );
else if( IsModal() )
EndModal( wxID_OK );
else
Destroy();
}
void HTML_MESSAGE_BOX::ListClear()
{
m_htmlWindow->SetPage( wxEmptyString );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Chris Pavlina <pavlina.chris@gmail.com>
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -69,8 +69,6 @@ public:
*/
class HK_PROMPT_DIALOG : public DIALOG_SHIM
{
wxKeyEvent m_event;
public:
HK_PROMPT_DIALOG( wxWindow* aParent, wxWindowID aId, const wxString& aTitle,
const wxString& aName, const wxString& aCurrentKey ) :
@ -136,17 +134,6 @@ public:
SetInitialFocus( panel );
}
/**
* End the dialog whether modal or quasimodal
*/
void EndFlexible( int aRtnCode )
{
if( IsQuasiModal() )
EndQuasiModal( aRtnCode );
else
EndModal( aRtnCode );
}
static wxKeyEvent PromptForKey( wxWindow* aParent, const wxString& aName,
const wxString& aCurrentKey )
{
@ -203,13 +190,16 @@ protected:
void OnChar( wxKeyEvent& aEvent )
{
m_event = aEvent;
EndFlexible( wxID_OK );
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
}
private:
wxKeyEvent m_event;
};
/**
* Class to manage logic for filtering hotkeys based on user input
* Manage logic for filtering hotkeys based on user input.
*/
class HOTKEY_FILTER
{

View File

@ -355,7 +355,7 @@
}
],
"meta": {
"version": 0
"version": 1
},
"net_colors": null
},

View File

@ -33,22 +33,17 @@
BEGIN_EVENT_TABLE( DIALOG_BUS_MANAGER, DIALOG_SHIM )
EVT_BUTTON( wxID_OK, DIALOG_BUS_MANAGER::OnOkClick )
EVT_BUTTON( wxID_CANCEL, DIALOG_BUS_MANAGER::OnCancelClick )
END_EVENT_TABLE()
DIALOG_BUS_MANAGER::DIALOG_BUS_MANAGER( SCH_EDIT_FRAME* aParent )
: DIALOG_SHIM( aParent, wxID_ANY, _( "Bus Definitions" ),
wxDefaultPosition, wxSize( 640, 480 ),
wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
m_parent( aParent )
{
auto sizer = new wxBoxSizer( wxVERTICAL );
auto buttons = new wxStdDialogButtonSizer();
wxButton* okButton = new wxButton( this, wxID_OK );
buttons->AddButton( new wxButton( this, wxID_OK ) );
buttons->AddButton( okButton );
buttons->AddButton( new wxButton( this, wxID_CANCEL ) );
buttons->Realize();
@ -186,6 +181,7 @@ DIALOG_BUS_MANAGER::DIALOG_BUS_MANAGER( SCH_EDIT_FRAME* aParent )
m_signal_edit->SetHint( _( "Net or Bus Name" ) );
finishDialogSettings();
okButton->SetDefault();
}
@ -235,22 +231,6 @@ bool DIALOG_BUS_MANAGER::TransferDataToWindow()
}
void DIALOG_BUS_MANAGER::OnOkClick( wxCommandEvent& aEvent )
{
if( TransferDataFromWindow() )
{
( ( SCH_EDIT_FRAME* )GetParent() )->OnModify();
EndModal( wxID_OK );
}
}
void DIALOG_BUS_MANAGER::OnCancelClick( wxCommandEvent& aEvent )
{
EndModal( wxID_CANCEL );
}
bool DIALOG_BUS_MANAGER::TransferDataFromWindow()
{
for( SCH_SCREEN* screen : m_screens )
@ -259,6 +239,7 @@ bool DIALOG_BUS_MANAGER::TransferDataFromWindow()
for( const std::shared_ptr<BUS_ALIAS>& alias : m_aliases )
alias->GetParent()->AddBusAlias( alias );
( ( SCH_EDIT_FRAME* )GetParent() )->OnModify();
return true;
}

View File

@ -54,8 +54,6 @@ protected:
void OnSelectSignal( wxListEvent& event );
private:
virtual void OnOkClick( wxCommandEvent& aEvent );
virtual void OnCancelClick( wxCommandEvent& aEvent );
wxString getAliasDisplayText( std::shared_ptr< BUS_ALIAS > aAlias );
protected:
@ -78,8 +76,6 @@ private:
std::vector< std::shared_ptr< BUS_ALIAS > > m_aliases;
std::unordered_set<SCH_SCREEN*> m_screens;
std::shared_ptr< BUS_ALIAS > m_active_alias;
DECLARE_EVENT_TABLE()
};

View File

@ -357,12 +357,7 @@ void DIALOG_CHOOSE_SYMBOL::OnUseBrowser( wxCommandEvent& aEvent )
{
m_external_browser_requested = true;
if( IsQuasiModal() )
EndQuasiModal( wxID_OK );
else if( IsModal() )
EndModal( wxID_OK );
else
wxFAIL_MSG( "Dialog called with neither Modal nor QuasiModal" );
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
}
@ -382,12 +377,7 @@ void DIALOG_CHOOSE_SYMBOL::OnCloseTimer( wxTimerEvent& aEvent )
}
else
{
if( IsQuasiModal() )
EndQuasiModal( wxID_OK );
else if( IsModal() )
EndModal( wxID_OK );
else
wxFAIL_MSG( "Dialog called with neither Modal nor QuasiModal" );
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
}
}

View File

@ -766,7 +766,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnClose( wxCloseEvent& event )
if( IsQuasiModal() )
EndQuasiModal( retval );
else
EndModal( retval );
EndDialog( retval );
return;
}
@ -781,7 +781,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnClose( wxCloseEvent& event )
if( IsQuasiModal() )
EndQuasiModal( retval );
else
EndModal( retval );
EndDialog( retval );
return;
}

View File

@ -181,12 +181,9 @@ public:
const wxString GetGeneratorTitle() { return m_textCtrlName->GetValue(); }
const wxString GetGeneratorTCommandLine() { return m_textCtrlCommand->GetValue(); }
private:
/**
* Validate info relative to a new netlist plugin
*/
void OnOKClick( wxCommandEvent& event ) override;
bool TransferDataFromWindow() override;
private:
/*
* Browse plugin files, and set m_CommandStringCtrl field
*/
@ -210,7 +207,6 @@ BEGIN_EVENT_TABLE( NETLIST_DIALOG, NETLIST_DIALOG_BASE )
END_EVENT_TABLE()
NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title,
NETLIST_TYPE_ID id_NetType ) :
wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
@ -243,7 +239,6 @@ NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& ti
}
NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) :
NETLIST_DIALOG_BASE( parent )
{
@ -483,9 +478,9 @@ bool NETLIST_DIALOG::TransferDataFromWindow()
fileExt = extRE.GetMatch( command, 1 );
title.Printf( _( "%s Export" ), currPage->m_TitleStringCtrl->GetValue().GetData() );
}
break;
}
}
fn.SetExt( fileExt );
@ -603,7 +598,11 @@ void NETLIST_DIALOG::OnDelGenerator( wxCommandEvent& event )
m_DefaultNetFmtName = m_PanelNetType[PANELPCBNEW]->GetPageNetFmtName();
WriteCurrentNetlistSetup();
EndModal( NET_PLUGIN_CHANGE );
if( IsQuasiModal() )
EndQuasiModal( NET_PLUGIN_CHANGE );
else
EndDialog( NET_PLUGIN_CHANGE );
}
@ -641,8 +640,10 @@ void NETLIST_DIALOG::OnAddGenerator( wxCommandEvent& event )
m_PanelNetType[netTypeId] = currPage;
WriteCurrentNetlistSetup();
// Close and reopen dialog to rebuild the dialog after changes
EndModal( NET_PLUGIN_CHANGE );
if( IsQuasiModal() )
EndQuasiModal( NET_PLUGIN_CHANGE );
else
EndDialog( NET_PLUGIN_CHANGE );
}
@ -655,21 +656,24 @@ NETLIST_DIALOG_ADD_GENERATOR::NETLIST_DIALOG_ADD_GENERATOR( NETLIST_DIALOG* pare
}
void NETLIST_DIALOG_ADD_GENERATOR::OnOKClick( wxCommandEvent& event )
bool NETLIST_DIALOG_ADD_GENERATOR::TransferDataFromWindow()
{
if( !wxDialog::TransferDataFromWindow() )
return false;
if( m_textCtrlCommand->GetValue() == wxEmptyString )
{
wxMessageBox( _( "Error. You must provide a command String" ) );
return;
wxMessageBox( _( "You must provide a netlist generator command string" ) );
return false;
}
if( m_textCtrlName->GetValue() == wxEmptyString )
{
wxMessageBox( _( "Error. You must provide a Title" ) );
return;
wxMessageBox( _( "You must provide a netlist generator title" ) );
return false;
}
EndModal( wxID_OK );
return true;
}
@ -694,14 +698,14 @@ void NETLIST_DIALOG_ADD_GENERATOR::OnBrowseGenerators( wxCommandEvent& event )
wxFileName fn( FullFileName );
wxString ext = fn.GetExt();
if( ext == wxT("xsl" ) )
cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), FullFileName );
else if( ext == wxT("exe" ) || ext.IsEmpty() )
cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), FullFileName );
else if( ext == wxT("py" ) || ext.IsEmpty() )
cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), FullFileName );
if( ext == wxT( "xsl" ) )
cmdLine.Printf( wxT( "xsltproc -o \"%%O\" \"%s\" \"%%I\"" ), FullFileName );
else if( ext == wxT( "exe" ) || ext.IsEmpty() )
cmdLine.Printf( wxT( "\"%s\" > \"%%O\" < \"%%I\"" ), FullFileName );
else if( ext == wxT( "py" ) || ext.IsEmpty() )
cmdLine.Printf( wxT( "python \"%s\" \"%%I\" \"%%O\"" ), FullFileName );
else
cmdLine.Printf(wxT("\"%s\""), FullFileName );
cmdLine.Printf( wxT( "\"%s\"" ), FullFileName );
m_textCtrlCommand->SetValue( cmdLine );

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -18,47 +18,47 @@ END_EVENT_TABLE()
NETLIST_DIALOG_BASE::NETLIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bUpperSizer;
bUpperSizer = new wxBoxSizer( wxVERTICAL );
m_NoteBook = new wxNotebook( this, ID_CHANGE_NOTEBOOK_PAGE, wxDefaultPosition, wxDefaultSize, 0 );
m_NoteBook->SetMinSize( wxSize( 540,-1 ) );
bUpperSizer->Add( m_NoteBook, 1, wxEXPAND | wxALL, 5 );
bMainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 );
m_buttonSizer = new wxBoxSizer( wxHORIZONTAL );
m_buttonAddGenerator = new wxButton( this, ID_ADD_PLUGIN, _("Add Generator..."), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonSizer->Add( m_buttonAddGenerator, 0, wxALL|wxEXPAND, 5 );
m_buttonDelGenerator = new wxButton( this, ID_DEL_PLUGIN, _("Remove Generator"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonSizer->Add( m_buttonDelGenerator, 0, wxALL|wxEXPAND, 5 );
m_sdbSizer2 = new wxStdDialogButtonSizer();
m_sdbSizer2OK = new wxButton( this, wxID_OK );
m_sdbSizer2->AddButton( m_sdbSizer2OK );
m_sdbSizer2Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer2->AddButton( m_sdbSizer2Cancel );
m_sdbSizer2->Realize();
m_buttonSizer->Add( m_sdbSizer2, 1, wxEXPAND, 5 );
bMainSizer->Add( m_buttonSizer, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 );
this->SetSizer( bMainSizer );
this->Layout();
bMainSizer->Fit( this );
this->Centre( wxBOTH );
}
@ -68,62 +68,60 @@ NETLIST_DIALOG_BASE::~NETLIST_DIALOG_BASE()
BEGIN_EVENT_TABLE( NETLIST_DIALOG_ADD_GENERATOR_BASE, DIALOG_SHIM )
EVT_BUTTON( wxID_BROWSE_PLUGINS, NETLIST_DIALOG_ADD_GENERATOR_BASE::_wxFB_OnBrowseGenerators )
EVT_BUTTON( wxID_CANCEL, NETLIST_DIALOG_ADD_GENERATOR_BASE::_wxFB_OnCancelClick )
EVT_BUTTON( wxID_OK, NETLIST_DIALOG_ADD_GENERATOR_BASE::_wxFB_OnOKClick )
END_EVENT_TABLE()
NETLIST_DIALOG_ADD_GENERATOR_BASE::NETLIST_DIALOG_ADD_GENERATOR_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerTop;
bSizerTop = new wxBoxSizer( wxVERTICAL );
m_staticTextName = new wxStaticText( this, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextName->Wrap( -1 );
bSizerTop->Add( m_staticTextName, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_textCtrlName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerTop->Add( m_textCtrlName, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticTextCmd = new wxStaticText( this, wxID_ANY, _("Command line to run the generator:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextCmd->Wrap( -1 );
bSizerTop->Add( m_staticTextCmd, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_textCtrlCommand = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrlCommand->SetMinSize( wxSize( 500,-1 ) );
bSizerTop->Add( m_textCtrlCommand, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( bSizerTop, 1, wxEXPAND|wxALL, 5 );
wxBoxSizer* bSizerBottom;
bSizerBottom = new wxBoxSizer( wxHORIZONTAL );
m_buttonGenerator = new wxButton( this, wxID_BROWSE_PLUGINS, _("Browse Generators..."), wxDefaultPosition, wxDefaultSize, 0 );
bSizerBottom->Add( m_buttonGenerator, 0, wxALL|wxEXPAND, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bSizerBottom->Add( m_sdbSizer, 1, wxEXPAND, 5 );
bSizerMain->Add( bSizerBottom, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 );
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
this->Centre( wxBOTH );
}

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,11 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_NETLIST_BASE_H__
#define __DIALOG_NETLIST_BASE_H__
#pragma once
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
@ -20,6 +19,9 @@
#include <wx/string.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/dialog.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
@ -33,13 +35,13 @@ class NETLIST_DIALOG_BASE : public DIALOG_SHIM
{
DECLARE_EVENT_TABLE()
private:
// Private event handlers
void _wxFB_OnNetlistTypeSelection( wxNotebookEvent& event ){ OnNetlistTypeSelection( event ); }
void _wxFB_OnAddGenerator( wxCommandEvent& event ){ OnAddGenerator( event ); }
void _wxFB_OnDelGenerator( wxCommandEvent& event ){ OnDelGenerator( event ); }
protected:
enum
{
@ -47,7 +49,7 @@ class NETLIST_DIALOG_BASE : public DIALOG_SHIM
ID_ADD_PLUGIN,
ID_DEL_PLUGIN
};
wxNotebook* m_NoteBook;
wxBoxSizer* m_buttonSizer;
wxButton* m_buttonAddGenerator;
@ -55,18 +57,18 @@ class NETLIST_DIALOG_BASE : public DIALOG_SHIM
wxStdDialogButtonSizer* m_sdbSizer2;
wxButton* m_sdbSizer2OK;
wxButton* m_sdbSizer2Cancel;
// Virtual event handlers, overide them in your derived class
virtual void OnNetlistTypeSelection( wxNotebookEvent& event ) { event.Skip(); }
virtual void OnAddGenerator( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDelGenerator( wxCommandEvent& event ) { event.Skip(); }
public:
NETLIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Export Netlist"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
NETLIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Export Netlist"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~NETLIST_DIALOG_BASE();
};
///////////////////////////////////////////////////////////////////////////////
@ -76,19 +78,17 @@ class NETLIST_DIALOG_ADD_GENERATOR_BASE : public DIALOG_SHIM
{
DECLARE_EVENT_TABLE()
private:
// Private event handlers
void _wxFB_OnBrowseGenerators( wxCommandEvent& event ){ OnBrowseGenerators( event ); }
void _wxFB_OnCancelClick( wxCommandEvent& event ){ OnCancelClick( event ); }
void _wxFB_OnOKClick( wxCommandEvent& event ){ OnOKClick( event ); }
protected:
enum
{
wxID_BROWSE_PLUGINS = 1000
};
wxStaticText* m_staticTextName;
wxTextCtrl* m_textCtrlName;
wxStaticText* m_staticTextCmd;
@ -97,18 +97,15 @@ class NETLIST_DIALOG_ADD_GENERATOR_BASE : public DIALOG_SHIM
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnBrowseGenerators( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }
public:
NETLIST_DIALOG_ADD_GENERATOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Script Generator Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
NETLIST_DIALOG_ADD_GENERATOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Script Generator Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~NETLIST_DIALOG_ADD_GENERATOR_BASE();
};
#endif //__DIALOG_NETLIST_BASE_H__

View File

@ -217,7 +217,7 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent )
m_editFrame->RebuildView();
m_editFrame->OnModify();
EndModal( wxID_OK );
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
}

View File

@ -221,7 +221,7 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_toolBar->Realize();
#ifndef wxHAS_NATIVE_TABART
// Non-native default tab art has ulgy gradients we don't want
// Non-native default tab art has ugly gradients we don't want
m_workbook->SetArtProvider( new wxAuiSimpleTabArt() );
#endif
@ -368,7 +368,7 @@ void SIM_PLOT_FRAME::updateTitle()
}
// A small helper struct to handle bitmaps initialisation in menus
// A small helper struct to handle bitmaps initialization in menus
struct BM_MENU_INIT_ITEM
{
int m_MenuId;
@ -895,7 +895,7 @@ void SIM_PLOT_FRAME::applyTuners()
{
for( auto& tuner : m_tuners )
{
/// @todo no ngspice hardcoding
/// @todo no ngspice hard coding
std::string command( "alter @" + tuner->GetSpiceName()
+ "=" + tuner->GetValue().ToSpiceString() );
@ -997,7 +997,7 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
file.Close();
// Successfully loading a workbook does not count as modyfying it.
// Successfully loading a workbook does not count as modifying it.
m_workbook->ClrModified();
return true;
}
@ -1512,7 +1512,7 @@ void SIM_PLOT_FRAME::onShowNetlist( wxCommandEvent& event )
void onClose( wxCloseEvent& evt )
{
EndModal( GetReturnCode() );
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
}
NETLIST_VIEW_DIALOG( wxWindow* parent, wxString source) :

View File

@ -209,7 +209,6 @@ void LAYERS_MAP_DIALOG::initDialog()
if( config->m_GerberToPcbLayerMapping.size() == 0 )
m_buttonRetrieve->Enable( false );
std::vector<int> gerber2KicadMapping;
// See how many of the loaded Gerbers can be mapped to KiCad layers automatically
@ -269,7 +268,7 @@ void LAYERS_MAP_DIALOG::normalizeBrdLayersCount()
void LAYERS_MAP_DIALOG::OnBrdLayersCountSelection( wxCommandEvent& event )
{
int id = event.GetSelection();
m_exportBoardCopperLayersCount = (id+1) * 2;
m_exportBoardCopperLayersCount = ( id + 1 ) * 2;
}
@ -278,6 +277,7 @@ void LAYERS_MAP_DIALOG::OnResetClick( wxCommandEvent& event )
wxString msg;
int ii;
LAYER_NUM layer;
for( ii = 0, layer = 0; ii < m_gerberActiveLayersCount; ii++, ++layer )
{
m_layersLookUpTable[ii] = UNSELECTED_LAYER;
@ -347,6 +347,7 @@ void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
}
}
void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event )
{
int ii;
@ -408,35 +409,35 @@ void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event )
}
void LAYERS_MAP_DIALOG::OnOkClick( wxCommandEvent& event )
bool LAYERS_MAP_DIALOG::TransferDataFromWindow()
{
/* Make some test about copper layers:
* Board must have enough copper layers to handle selected internal layers
*/
if( !wxDialog::TransferDataFromWindow() )
return false;
// Board must have enough copper layers to handle selected internal layers.
normalizeBrdLayersCount();
int inner_layer_max = 0;
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
{
if( m_layersLookUpTable[ii] < F_Cu )
{
if( m_layersLookUpTable[ii ] > inner_layer_max )
inner_layer_max = m_layersLookUpTable[ii];
}
if( m_layersLookUpTable[ii] < F_Cu )
{
if( m_layersLookUpTable[ii ] > inner_layer_max )
inner_layer_max = m_layersLookUpTable[ii];
}
}
// inner_layer_max must be less than (or equal to) the number of
// internal copper layers
// inner_layer_max must be less than (or equal to the number of internal copper layers
// internal copper layers = m_exportBoardCopperLayersCount-2
if( inner_layer_max > m_exportBoardCopperLayersCount-2 )
{
wxMessageBox( _("Exported board does not have enough copper layers to handle selected "
"inner layers") );
return;
return false;
}
EndModal( wxID_OK );
return true;
}
@ -568,6 +569,7 @@ int LAYERS_MAP_DIALOG::findNumAltiumGerbersLoaded( std::vector<int>& aGerber2Kic
return numAltiumMatches;
}
int LAYERS_MAP_DIALOG::findNumKiCadGerbersLoaded( std::vector<int>& aGerber2KicadMapping )
{
// The next comment preserves initializer formatting below it
@ -689,6 +691,7 @@ int LAYERS_MAP_DIALOG::findNumKiCadGerbersLoaded( std::vector<int>& aGerber2Kica
return numKicadMatches;
}
int LAYERS_MAP_DIALOG::findNumX2GerbersLoaded( std::vector<int>& aGerber2KicadMapping )
{
// The next comment preserves initializer formatting below it

View File

@ -33,9 +33,8 @@
class GERBVIEW_FRAME;
/*
* This dialog shows the gerber files loaded, and allows user to choose
* equivalence between gerber layers and pcb layers
/**
* Show the Gerber files loaded and allow the user to choose between Gerber layers and pcb layers.
*/
class LAYERS_MAP_DIALOG : public LAYERS_MAP_DIALOG_BASE
{
@ -45,19 +44,21 @@ public: LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent );
LAYER_NUM * GetLayersLookUpTable() { return m_layersLookUpTable; }
static int GetCopperLayersCount() { return m_exportBoardCopperLayersCount; }
protected:
bool TransferDataFromWindow() override;
private:
void initDialog();
void normalizeBrdLayersCount();
void OnBrdLayersCountSelection( wxCommandEvent& event ) override;
void OnSelectLayer( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event ) override;
void OnStoreSetup( wxCommandEvent& event ) override;
void OnGetSetup( wxCommandEvent& event ) override;
void OnResetClick( wxCommandEvent& event ) override;
/**
* Finds number of loaded Gerbers where the matching KiCad layer can be identified
* Find number of loaded Gerbers where the matching KiCad layer can be identified.
*
* The passed vector<int> will be returned with the same number of elements
* as there are Gerber files. The indices into it are 1:1 with the loaded Gerber
@ -72,7 +73,7 @@ private:
int findKnownGerbersLoaded( std::vector<int>& aGerber2KicadMapping );
/**
* Finds number of loaded Gerbers using Altium file extensions
* Find number of loaded Gerbers using Altium file extensions.
*
* The passed vector<int> will be returned with the same number of elements
* as there are Gerber files. The indices into it are 1:1 with the loaded Gerber
@ -87,7 +88,7 @@ private:
int findNumAltiumGerbersLoaded( std::vector<int>& aGerber2KicadMapping );
/**
* Finds number of loaded Gerbers using KiCad naming convention
* Find number of loaded Gerbers using KiCad naming convention.
*
* The passed vector<int> will be returned with the same number of elements
* as there are Gerber files. The indices into it are 1:1 with the loaded Gerber
@ -102,7 +103,7 @@ private:
int findNumKiCadGerbersLoaded( std::vector<int>& aGerber2KicadMapping );
/**
* Finds number of loaded Gerbers using X2 File Functions to define layers
* Find number of loaded Gerbers using X2 File Functions to define layers.
*
* The passed vector<int> will be returned with the same number of elements
* as there are Gerber files. The indices into it are 1:1 with the loaded Gerber
@ -120,7 +121,7 @@ private:
private:
GERBVIEW_FRAME* m_Parent;
int m_gerberActiveLayersCount; // Number of initialized gerber layers
int m_gerberActiveLayersCount; // Number of initialized Gerber layers
static int m_exportBoardCopperLayersCount;
// Indexes Gerber layers to PCB file layers the last value in table is the number of

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -14,7 +14,6 @@ BEGIN_EVENT_TABLE( LAYERS_MAP_DIALOG_BASE, DIALOG_SHIM )
EVT_BUTTON( ID_STORE_CHOICE, LAYERS_MAP_DIALOG_BASE::_wxFB_OnStoreSetup )
EVT_BUTTON( ID_GET_PREVIOUS_CHOICE, LAYERS_MAP_DIALOG_BASE::_wxFB_OnGetSetup )
EVT_BUTTON( ID_RESET_CHOICE, LAYERS_MAP_DIALOG_BASE::_wxFB_OnResetClick )
EVT_BUTTON( wxID_OK, LAYERS_MAP_DIALOG_BASE::_wxFB_OnOkClick )
END_EVENT_TABLE()
LAYERS_MAP_DIALOG_BASE::LAYERS_MAP_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )

View File

@ -14,6 +14,7 @@
<property name="file">dialog_layers_select_to_pcb_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_layers_select_to_pcb_base</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -433,6 +435,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -506,6 +509,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -579,6 +583,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -719,7 +724,6 @@
<property name="minimum_size"></property>
<property name="name">m_sdbSizerButtons</property>
<property name="permission">protected</property>
<event name="OnOKButtonClick">OnOkClick</event>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -20,10 +20,10 @@
#include <wx/sizer.h>
#include <wx/statline.h>
#include <wx/combobox.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@ -49,7 +49,6 @@ class LAYERS_MAP_DIALOG_BASE : public DIALOG_SHIM
void _wxFB_OnStoreSetup( wxCommandEvent& event ){ OnStoreSetup( event ); }
void _wxFB_OnGetSetup( wxCommandEvent& event ){ OnGetSetup( event ); }
void _wxFB_OnResetClick( wxCommandEvent& event ){ OnResetClick( event ); }
void _wxFB_OnOkClick( wxCommandEvent& event ){ OnOkClick( event ); }
protected:
@ -73,7 +72,6 @@ class LAYERS_MAP_DIALOG_BASE : public DIALOG_SHIM
virtual void OnStoreSetup( wxCommandEvent& event ) { event.Skip(); }
virtual void OnGetSetup( wxCommandEvent& event ) { event.Skip(); }
virtual void OnResetClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -49,68 +49,47 @@ enum layer_sel_id {
class SELECT_LAYER_DIALOG : public DIALOG_SHIM
{
private:
int m_PassedDefaultLayer; // Remember this in case user hits Cancel
wxRadioBox* m_layerRadioBox;
std::vector <int> m_layerId;
public:
// Constructor and destructor
SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLayer, int aCopperLayerCount,
wxString aGerberName );
wxString aGerberName );
~SELECT_LAYER_DIALOG() { };
int GetSelectedLayer() { return m_selectedLayer; }
protected:
bool TransferDataFromWindow() override;
private:
void OnLayerSelected( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
int m_selectedLayer;
wxRadioBox* m_layerRadioBox;
std::vector <int> m_layerId;
};
BEGIN_EVENT_TABLE( SELECT_LAYER_DIALOG, wxDialog )
EVT_BUTTON( wxID_OK, SELECT_LAYER_DIALOG::OnLayerSelected )
EVT_BUTTON( wxID_CANCEL, SELECT_LAYER_DIALOG::OnCancelClick )
EVT_RADIOBOX( ID_LAYER_SELECT, SELECT_LAYER_DIALOG::OnLayerSelected )
END_EVENT_TABLE()
/** Install the dialog box for layer selection
* @param aDefaultLayer = Preselection (GERBER_DRAWLAYERS_COUNT for "(Deselect)" layer)
* @param aCopperLayerCount = number of copper layers
* @param aShowDeselectOption = display a "(Deselect)" radiobutton (when set to true)
* @return new layer value (GERBER_DRAWLAYERS_COUNT when "(Deselect)" radiobutton selected),
* or -1 if canceled
*
* Providing the option to also display a "(Deselect)" radiobutton makes the
* GerbView's "Export to Pcbnew" command) more "user friendly",
* by permitting any layer to be "deselected" immediately after its
* corresponding radiobutton has been clicked on. (It would otherwise be
* necessary to first cancel the "Select Layer:" dialog box (invoked after a
* different radiobutton is clicked on) prior to then clicking on the "Deselect"
* button provided within the "Layer selection:" dialog box).
*/
int GERBVIEW_FRAME::SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount, wxString aGerberName )
{
SELECT_LAYER_DIALOG* frame =
new SELECT_LAYER_DIALOG( this, aDefaultLayer, aCopperLayerCount, aGerberName );
int layer = frame->ShowModal();
frame->ShowModal();
frame->Destroy();
return layer;
return frame->GetSelectedLayer();
}
/*
* The "OK" and "Cancel" buttons are positioned (in a horizontal line)
* beneath the "Layer" radiobox, unless that contains only one column of
* radiobuttons, in which case they are positioned (in a vertical line)
* to the right of that radiobox.
*/
SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG(
GERBVIEW_FRAME* parent, int aDefaultLayer, int aCopperLayerCount, wxString aGerberName )
: DIALOG_SHIM( parent, -1, wxString::Format( _( "Select Layer: %s" ), aGerberName ),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLayer,
int aCopperLayerCount, wxString aGerberName )
: DIALOG_SHIM( parent, -1, wxString::Format( _( "Select Layer: %s" ), aGerberName ),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
{
wxButton* button;
int ii;
@ -118,7 +97,7 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG(
int selected = -1;
// Store the passed default layer in case the user hits Cancel
m_PassedDefaultLayer = aDefaultLayer;
m_selectedLayer = aDefaultLayer;
// Build the layer list; first build copper layers list
int layerCount = 0;
@ -202,17 +181,20 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG(
void SELECT_LAYER_DIALOG::OnLayerSelected( wxCommandEvent& event )
{
int ii = m_layerId[m_layerRadioBox->GetSelection()];
EndModal( ii );
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
}
void SELECT_LAYER_DIALOG::OnCancelClick( wxCommandEvent& event )
bool SELECT_LAYER_DIALOG::TransferDataFromWindow()
{
EndModal( m_PassedDefaultLayer );
if( !wxDialog::TransferDataFromWindow() )
return false;
m_selectedLayer = m_layerId[m_layerRadioBox->GetSelection()];
return true;
}
// This function is a duplicate of
// const wxChar* LSET::Name( PCB_LAYER_ID aLayerId )
// However it avoids a dependency to Pcbnew code.

View File

@ -37,8 +37,6 @@ public:
private:
void onOverrideLocks( wxCommandEvent& event ) override;
void onCancelClick( wxCommandEvent& event ) override;
void onOkClick( wxCommandEvent& event ) override;
};
#endif // DIALOG_LOCKED_ITEMS_QUERY_H
#endif // DIALOG_LOCKED_ITEMS_QUERY_H

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2018 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify it
@ -66,12 +67,14 @@ protected:
/**
* Return scale value selected in the dialog.
* if this value is outside limits, it will be clamped
*
* If this value is outside limits, it will be clamped.
*/
double getScaleValue();
/**
* Select a corresponding scale radio button and update custom scale value if needed.
*
* @param aValue is the scale value to be selected (0 stands for fit-to-page).
*/
void setScaleValue( double aValue );
@ -80,24 +83,26 @@ protected:
// even if the dialog is closed without printing
bool TransferDataToWindow() override;
APP_SETTINGS_BASE* m_config;
PRINTOUT_SETTINGS* m_settings;
private:
void onPageSetup( wxCommandEvent& event ) override;
void onPrintPreview( wxCommandEvent& event ) override;
void onPrintButtonClick( wxCommandEvent& event ) override;
void onCancelButtonClick( wxCommandEvent& aEvent ) override;
// onClose* handlers are needed to save the dialogs settings as TransferDataFromWindow()
// is not called for 'Cancel' button that closes the window
void onCloseButton( wxCommandEvent& event ) override;
// Needed to save the dialogs settings as TransferDataFromWindow()
// is not called for 'Cancel' button that closes the window.
void onClose( wxCloseEvent& event ) override;
void onSetCustomScale( wxCommandEvent& event ) override;
void initPrintData();
protected:
APP_SETTINGS_BASE* m_config;
PRINTOUT_SETTINGS* m_settings;
private:
wxFloatingPointValidator<double> m_scaleValidator;
static wxPrintData* s_PrintData;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -29,17 +29,8 @@
#include <../common/dialogs/dialog_display_info_HTML_base.h>
/**
* HTML_MESSAGE_BOX
*/
class HTML_MESSAGE_BOX : public DIALOG_DISPLAY_HTML_TEXT_BASE
{
protected:
// Handlers for HTML_MESSAGE_BOX_BASE events.
void OnOKButtonClick( wxCommandEvent& event ) override;
virtual void OnCharHook( wxKeyEvent& aEvt ) override;
public:
HTML_MESSAGE_BOX( wxWindow* aParent, const wxString& aTitle = wxEmptyString,
const wxPoint& aPosition = wxDefaultPosition,
@ -47,9 +38,11 @@ public:
~HTML_MESSAGE_BOX() override;
/**
* set the dialog size, using a "logical" value.
* the physical size in pixel will depend on the display definition
* so a value used here shoul be OK with any display (HDPI for instance)
* Set the dialog size, using a "logical" value.
*
* The physical size in pixel will depend on the display definition so a value used here
* should be OK with any display (HDPI for instance).
*
* @param aWidth is a "logical" value of the dialog width.
* @param aHeight is a "logical" value of the dialog height.
*/
@ -62,14 +55,14 @@ public:
/**
* Add a list of items.
*
* @param aList = a string containing items. Items are separated by '\n'
* @param aList is a string containing HTML items. Items are separated by '\n'
*/
void ListSet( const wxString& aList );
/**
* Add a list of items.
*
* @param aList = a wxArrayString containing items.
* @param aList is the list of HTML strings to display.
*/
void ListSet( const wxArrayString& aList );
@ -90,6 +83,8 @@ public:
*/
void ShowModeless();
protected:
virtual void OnCharHook( wxKeyEvent& aEvt ) override;
};
#endif // _html_messagebox_

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2011 jean-pierre.charras
* Copyright (C) 1992-2020 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -28,32 +28,30 @@
extern double DoubleFromString( const wxString& TextValue );
void DIALOG_REGULATOR_FORM::OnOKClick( wxCommandEvent& event )
bool DIALOG_REGULATOR_FORM::TransferDataFromWindow()
{
if( !IsOK() )
{
wxMessageBox( _( "Bad or missing parameters!" ) );
return;
}
if( !wxDialog::TransferDataFromWindow() )
return false;
EndModal( wxID_OK );
}
bool DIALOG_REGULATOR_FORM::IsOK()
{
bool success = true;
if( m_textCtrlName->GetValue().IsEmpty() )
{
success = false;
}
if( m_textCtrlVref->GetValue().IsEmpty() )
{
success = false;
}
else
{
double vref = DoubleFromString( m_textCtrlVref->GetValue() );
if( fabs( vref ) < 0.01 )
success = false;
}
if( m_choiceRegType->GetSelection() == 1 )
{
if( m_RegulIadjValue->GetValue().IsEmpty() )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2011 jean-pierre.charras
* Copyright (C) 1992-2020 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -20,10 +20,6 @@
/**
* @file dialog_regulator_form.h
* Subclass of DIALOG_REGULATOR_FORM_BASE, which is generated by wxFormBuilder.
*
* This dialog is used to add / edit regulators to the list on the
* regulator tab of the pcb calculator
*/
#ifndef DIALOG_REGULATOR_FORM_H
@ -34,6 +30,12 @@
class PCB_CALCULATOR_FRAME;
class REGULATOR_DATA;
/**
* Subclass of DIALOG_REGULATOR_FORM_BASE, which is generated by wxFormBuilder.
*
* Dialog used to add / edit regulators to the list on the regulator tab of the pcb calculator.
*/
class DIALOG_REGULATOR_FORM : public DIALOG_REGULATOR_FORM_BASE
{
public:
@ -52,37 +54,32 @@ public:
~DIALOG_REGULATOR_FORM(){};
// Event called functions:
void OnOKClick( wxCommandEvent& event ) override;
/**
* Function IsOK()
* @return true if regulator parameters are acceptable
* @return true if regulator parameters are acceptable.
*/
bool IsOK();
bool TransferDataFromWindow();
/**
* Function CopyRegulatorDataToDialog
* Transfer data from dialog to aItem
* @param aItem = a pointer to the REGULATOR_DATA
* Transfer data from dialog to aItem.
*
* @param aItem is the #REGULATOR_DATA to copy to dialog.
*/
void CopyRegulatorDataToDialog( REGULATOR_DATA* aItem );
/**
* Function BuildRegulatorFromData
* Creates a new REGULATOR_DATA from dialog
* @return a pointer to the new REGULATOR_DATA
* Create a new #REGULATOR_DATA from dialog data.
*
* @return a the new #REGULATOR_DATA.
*/
REGULATOR_DATA* BuildRegulatorFromData();
/**
* Enable/disable Iadj related widgets, according to
* the regulator type
* Enable/disable Iadj related widgets, according to the regulator type.
*/
void UpdateDialog();
/**
* called when the current regulator type is changed
* Called when the current regulator type is changed.
*/
void OnRegTypeSelection( wxCommandEvent& event ) override
{
@ -90,4 +87,4 @@ public:
}
};
#endif // DIALOG_REGULATOR_FORM_H
#endif // DIALOG_REGULATOR_FORM_H

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -96,13 +96,11 @@ DIALOG_REGULATOR_FORM_BASE::DIALOG_REGULATOR_FORM_BASE( wxWindow* parent, wxWind
// Connect Events
m_choiceRegType->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_REGULATOR_FORM_BASE::OnRegTypeSelection ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_REGULATOR_FORM_BASE::OnOKClick ), NULL, this );
}
DIALOG_REGULATOR_FORM_BASE::~DIALOG_REGULATOR_FORM_BASE()
{
// Disconnect Events
m_choiceRegType->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_REGULATOR_FORM_BASE::OnRegTypeSelection ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_REGULATOR_FORM_BASE::OnOKClick ), NULL, this );
}

View File

@ -14,6 +14,7 @@
<property name="file">dialog_regulator_form_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_regulator_form_base</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -53,7 +55,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size">300,-1</property>
<property name="name">bSizerMain</property>
<property name="orient">wxVERTICAL</property>
@ -803,7 +805,6 @@
<property name="minimum_size"></property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnOKButtonClick">OnOKClick</event>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -52,7 +52,6 @@ class DIALOG_REGULATOR_FORM_BASE : public DIALOG_SHIM
// Virtual event handlers, overide them in your derived class
virtual void OnRegTypeSelection( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -52,9 +52,9 @@ void PCB_CALCULATOR_FRAME::OnRegulatorResetButtonClick( wxCommandEvent& event )
m_RegulVrefValue->SetValue( wxT( "3" ) );
m_RegulVoutValue->SetValue( wxT( "12" ) );
m_choiceRegType->SetSelection( 0 );
m_rbRegulR1->SetValue(1);
m_rbRegulR2->SetValue(0);
m_rbRegulVout->SetValue(0);
m_rbRegulR1->SetValue( 1 );
m_rbRegulR2->SetValue( 0 );
m_rbRegulVout->SetValue( 0 );
RegulatorPageUpdate();
}
@ -107,9 +107,9 @@ void PCB_CALCULATOR_FRAME::OnRegulatorSelection( wxCommandEvent& event )
m_lastSelectedRegulatorName = item->m_Name;
m_choiceRegType->SetSelection( item->m_Type );
wxString value;
value.Printf( wxT("%g"), item->m_Vref );
value.Printf( wxT( "%g" ), item->m_Vref );
m_RegulVrefValue->SetValue( value );
value.Printf( wxT("%g"), item->m_Iadj );
value.Printf( wxT( "%g" ), item->m_Iadj );
m_RegulIadjValue->SetValue( value );
}
@ -127,10 +127,8 @@ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event )
wildcard.Printf( _("PCB Calculator data file (*.%s)|*.%s"),
DataFileNameExt, DataFileNameExt );
wxFileDialog dlg( m_panelRegulators,
_("Select PCB Calculator Data File"),
wxEmptyString, fullfilename,
wildcard, wxFD_OPEN );
wxFileDialog dlg( m_panelRegulators, _("Select PCB Calculator Data File"),
wxEmptyString, fullfilename, wildcard, wxFD_OPEN );
if (dlg.ShowModal() == wxID_CANCEL)
return;
@ -144,8 +142,8 @@ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event )
if( wxFileExists( fullfilename ) && m_RegulatorList.GetCount() > 0 ) // Read file
{
if( wxMessageBox( _("Do you want to load this file and replace current regulator list?" ) )
!= wxID_OK )
if( wxMessageBox( _( "Do you want to load this file and replace current regulator list?" ) )
!= wxID_OK )
return;
}
@ -168,16 +166,11 @@ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event )
void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event )
{
DIALOG_REGULATOR_FORM dlg( this, wxEmptyString );
if( dlg.ShowModal() != wxID_OK )
return;
if( !dlg.IsOK() )
{
wxMessageBox( _("Bad or missing parameters!") );
return;
}
REGULATOR_DATA * new_item = dlg.BuildRegulatorFromData();
REGULATOR_DATA* new_item = dlg.BuildRegulatorFromData();
// Add new item, if not existing
if( m_RegulatorList.GetReg( new_item->m_Name ) == nullptr )
@ -398,5 +391,4 @@ void PCB_CALCULATOR_FRAME::Regulators_WriteConfig( PCB_CALCULATOR_SETTINGS* aCfg
break;
}
}
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -60,8 +60,11 @@ void DIALOG_FILTER_SELECTION::checkBoxClicked( wxCommandEvent& aEvent )
}
void DIALOG_FILTER_SELECTION::ExecuteCommand( wxCommandEvent& event )
bool DIALOG_FILTER_SELECTION::TransferDataFromWindow()
{
if( !wxDialog::TransferDataFromWindow() )
return false;
m_options.includeModules = m_Include_Modules->GetValue();
m_options.includeLockedModules = m_IncludeLockedModules->GetValue();
m_options.includeTracks = m_Include_Tracks->GetValue();
@ -71,5 +74,5 @@ void DIALOG_FILTER_SELECTION::ExecuteCommand( wxCommandEvent& event )
m_options.includeBoardOutlineLayer = m_Include_Edges_Items->GetValue();
m_options.includePcbTexts = m_Include_PcbTextes->GetValue();
EndModal( wxID_OK );
return true;
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -47,23 +47,26 @@ public:
bool includePcbTexts = true;
};
/**
* Create the filter selection dialog.
*
* @param[in] aParent is the parent window that called the dialog.
* @param[in,out] aOptions is the options to populate the dialog with and contains the
* changes made by the dialog on exit.
*/
DIALOG_FILTER_SELECTION( PCB_BASE_FRAME* aParent, OPTIONS& aOptions );
~DIALOG_FILTER_SELECTION()
{
}
protected:
bool TransferDataFromWindow() override;
private:
void ExecuteCommand( wxCommandEvent& event ) override;
void OnCancel( wxCommandEvent& event ) override
{
EndModal( wxID_CANCEL );
}
void checkBoxClicked( wxCommandEvent& aEvent ) override;
///< Reference to the options struct to fill
///< Reference to the options struct to fill.
OPTIONS& m_options;
};

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -74,7 +74,6 @@ DIALOG_FILTER_SELECTION_BASE::DIALOG_FILTER_SELECTION_BASE( wxWindow* parent, wx
m_Include_Edges_Items->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::checkBoxClicked ), NULL, this );
m_Include_Vias->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::checkBoxClicked ), NULL, this );
m_Include_Zones->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::checkBoxClicked ), NULL, this );
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::OnCancel ), NULL, this );
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::ExecuteCommand ), NULL, this );
}
@ -89,7 +88,6 @@ DIALOG_FILTER_SELECTION_BASE::~DIALOG_FILTER_SELECTION_BASE()
m_Include_Edges_Items->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::checkBoxClicked ), NULL, this );
m_Include_Vias->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::checkBoxClicked ), NULL, this );
m_Include_Zones->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::checkBoxClicked ), NULL, this );
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::OnCancel ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::ExecuteCommand ), NULL, this );
}

View File

@ -14,6 +14,7 @@
<property name="file">dialog_filter_selection_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_filter_selection_base</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -666,7 +668,6 @@
<property name="minimum_size"></property>
<property name="name">m_sdbSizer1</property>
<property name="permission">protected</property>
<event name="OnCancelButtonClick">OnCancel</event>
<event name="OnOKButtonClick">ExecuteCommand</event>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -48,7 +48,6 @@ class DIALOG_FILTER_SELECTION_BASE : public DIALOG_SHIM
// Virtual event handlers, overide them in your derived class
virtual void checkBoxClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); }
virtual void ExecuteCommand( wxCommandEvent& event ) { event.Skip(); }

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2012 Marco Mattila <marcom99@gmail.com>
* Copyright (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2018 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -37,6 +37,7 @@
#include <tools/pcb_actions.h>
#include <wx/fdrepdlg.h>
//Defined as global because these values have to survive the destructor
bool FindOptionCase = false;
@ -91,27 +92,32 @@ DIALOG_FIND::DIALOG_FIND( PCB_BASE_FRAME* aFrame ) : DIALOG_FIND_BASE( aFrame )
Center();
}
void DIALOG_FIND::onTextEnter( wxCommandEvent& aEvent )
{
search( true );
}
void DIALOG_FIND::onFindNextClick( wxCommandEvent& aEvent )
{
search( true );
}
void DIALOG_FIND::onFindPreviousClick( wxCommandEvent& aEvent )
{
search( false );
}
void DIALOG_FIND::onSearchAgainClick( wxCommandEvent& aEvent )
{
m_upToDate = false;
search( true );
}
void DIALOG_FIND::search( bool aDirection )
{
PCB_SCREEN* screen = m_frame->GetScreen();
@ -239,7 +245,8 @@ void DIALOG_FIND::search( bool aDirection )
{
FP_TEXT* textItem = dynamic_cast<FP_TEXT*>( item );
if( textItem && textItem->Matches( m_frame->GetFindReplaceData(), nullptr ) )
if( textItem && textItem->Matches( m_frame->GetFindReplaceData(),
nullptr ) )
{
m_hitList.push_back( fp );
}
@ -262,6 +269,7 @@ void DIALOG_FIND::search( bool aDirection )
for( BOARD_ITEM* item : m_frame->GetBoard()->Zones() )
{
ZONE* zoneItem = dynamic_cast<ZONE*>( item );
if( zoneItem && zoneItem->Matches( m_frame->GetFindReplaceData(), nullptr ) )
{
m_hitList.push_back( zoneItem );
@ -364,7 +372,18 @@ void DIALOG_FIND::search( bool aDirection )
m_highlightCallback( GetItem() );
}
void DIALOG_FIND::onClose( wxCommandEvent& aEvent )
void DIALOG_FIND::OnCloseButtonClick( wxCommandEvent& aEvent )
{
wxCloseEvent tmp;
OnClose( tmp );
aEvent.Skip();
}
void DIALOG_FIND::OnClose( wxCloseEvent& aEvent )
{
FindOptionCase = m_matchCase->GetValue();
FindOptionWords = m_matchWords->GetValue();
@ -376,5 +395,5 @@ void DIALOG_FIND::onClose( wxCommandEvent& aEvent )
FindIncludeMarkers = m_includeMarkers->GetValue();
FindIncludeReferences = m_includeReferences->GetValue();
EndModal( 1 );
aEvent.Skip();
}

View File

@ -63,13 +63,15 @@ public:
m_highlightCallback = aCallback;
}
protected:
void OnClose( wxCloseEvent& event ) override;
void OnCloseButtonClick( wxCommandEvent& aEvent ) override;
private:
void onTextEnter( wxCommandEvent& event ) override;
void onFindNextClick( wxCommandEvent& event ) override;
void onFindPreviousClick( wxCommandEvent& event ) override;
void onSearchAgainClick( wxCommandEvent& event ) override;
void onClose( wxCommandEvent& event ) override;
void search( bool direction );
PCB_BASE_FRAME* m_frame;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -132,20 +132,22 @@ DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, wxWindowID id, const wxStr
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FIND_BASE::OnClose ) );
m_searchCombo->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_FIND_BASE::onTextEnter ), NULL, this );
m_findNext->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onFindNextClick ), NULL, this );
m_findPrevious->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onFindPreviousClick ), NULL, this );
m_searchAgain->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onSearchAgainClick ), NULL, this );
m_closeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onClose ), NULL, this );
m_closeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::OnCloseButtonClick ), NULL, this );
}
DIALOG_FIND_BASE::~DIALOG_FIND_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FIND_BASE::OnClose ) );
m_searchCombo->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_FIND_BASE::onTextEnter ), NULL, this );
m_findNext->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onFindNextClick ), NULL, this );
m_findPrevious->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onFindPreviousClick ), NULL, this );
m_searchAgain->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onSearchAgainClick ), NULL, this );
m_closeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onClose ), NULL, this );
m_closeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::OnCloseButtonClick ), NULL, this );
}

View File

@ -14,6 +14,7 @@
<property name="file">dialog_find_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_pcbnew_find</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -53,6 +55,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnClose">OnClose</event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer10</property>
@ -836,6 +839,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -909,6 +913,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -982,6 +987,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -1055,6 +1061,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -1112,7 +1119,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">onClose</event>
<event name="OnButtonClick">OnCloseButtonClick</event>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -20,10 +20,10 @@
#include <wx/combobox.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/statline.h>
#include <wx/dialog.h>
@ -56,11 +56,12 @@ class DIALOG_FIND_BASE : public DIALOG_SHIM
wxStaticText* m_status;
// Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
virtual void onTextEnter( wxCommandEvent& event ) { event.Skip(); }
virtual void onFindNextClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onFindPreviousClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onSearchAgainClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onClose( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCloseButtonClick( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012-2014 Miguel Angel Ajo <miguelangel@nbee.es>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -38,6 +38,7 @@
#include <python/scripting/pcbnew_scripting.h>
enum FPGeneratorRowNames
{
FP_GEN_ROW_NUMBER = 0,
@ -134,7 +135,8 @@ void DIALOG_FOOTPRINT_WIZARD_LIST::initLists()
wxString message;
pcbnewGetScriptsSearchPaths( message );
m_tcSearchPaths->SetValue( message );
// Display info about scripts: unloadable scripts (due to syntax errors is python source)
// Display info about scripts: unloadable scripts (due to syntax errors is python source).
pcbnewGetUnloadableScriptNames( message );
if( message.IsEmpty() )
@ -161,6 +163,7 @@ void DIALOG_FOOTPRINT_WIZARD_LIST::OnCellFpGeneratorClick( wxGridEvent& event )
int click_row = event.GetRow();
m_footprintWizard = FOOTPRINT_WIZARD_LIST::GetWizard( click_row );
m_footprintGeneratorsGrid->SelectRow( event.GetRow(), false );
// Move the grid cursor to the active line, mainly for aesthetic reasons:
m_footprintGeneratorsGrid->GoToCell( event.GetRow(), FP_GEN_ROW_NUMBER );
}
@ -168,9 +171,10 @@ void DIALOG_FOOTPRINT_WIZARD_LIST::OnCellFpGeneratorClick( wxGridEvent& event )
void DIALOG_FOOTPRINT_WIZARD_LIST::OnCellFpGeneratorDoubleClick( wxGridEvent& event )
{
EndModal( wxID_OK );
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
}
void DIALOG_FOOTPRINT_WIZARD_LIST::onShowTrace( wxCommandEvent& event )
{
wxString trace;

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -62,7 +62,10 @@ int GLOBAL_EDIT_TOOL::GlobalDeletions( const TOOL_EVENT& aEvent )
DIALOG_GLOBAL_DELETION dlg( editFrame );
dlg.SetCurrentLayer( frame()->GetActiveLayer() );
dlg.ShowModal();
if( dlg.ShowModal() == wxID_OK )
dlg.DoGlobalDeletions();
return 0;
}
@ -96,7 +99,7 @@ void DIALOG_GLOBAL_DELETION::onCheckDeleteDrawings( wxCommandEvent& event )
}
void DIALOG_GLOBAL_DELETION::doGlobalDeletions()
void DIALOG_GLOBAL_DELETION::DoGlobalDeletions()
{
bool gen_rastnest = false;
@ -107,12 +110,12 @@ void DIALOG_GLOBAL_DELETION::doGlobalDeletions()
if( m_delAll->GetValue() )
{
if( !IsOK( this, _( "Are you sure you want to delete the entire board?" ) ) )
if( !IsOK( GetParent(), _( "Are you sure you want to delete the entire board?" ) ) )
return;
delete_all = true;
}
else if( !IsOK( this, _( "Are you sure you want to delete the selected items?" ) ) )
else if( !IsOK( GetParent(), _( "Are you sure you want to delete the selected items?" ) ) )
{
return;
}
@ -246,6 +249,7 @@ void DIALOG_GLOBAL_DELETION::doGlobalDeletions()
if( gen_rastnest )
m_Parent->Compile_Ratsnest( true );
// There is a chance that some of tracks have changed their nets, so rebuild ratsnest from scratch
// There is a chance that some of tracks have changed their nets, so rebuild ratsnest
// from scratch.
m_Parent->GetCanvas()->Refresh();
}

View File

@ -32,19 +32,10 @@ public:
DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent );
void SetCurrentLayer( LAYER_NUM aLayer );
///< @todo Move this back into the tool rather than having the dialog do the deleting.
void DoGlobalDeletions();
private:
void onOkClick( wxCommandEvent& event ) override
{
doGlobalDeletions();
EndModal( wxID_OK );
}
void onCancelClick( wxCommandEvent& event ) override
{
EndModal( wxID_CANCEL );
}
void doGlobalDeletions();
void onCheckDeleteTracks( wxCommandEvent& event ) override;
void onCheckDeleteFootprints( wxCommandEvent& event ) override;
void onCheckDeleteDrawings( wxCommandEvent& event ) override;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -132,8 +132,6 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi
m_delDrawings->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCheckDeleteDrawings ), NULL, this );
m_delFootprints->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCheckDeleteFootprints ), NULL, this );
m_delTracks->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCheckDeleteTracks ), NULL, this );
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCancelClick ), NULL, this );
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onOkClick ), NULL, this );
}
DIALOG_GLOBAL_DELETION_BASE::~DIALOG_GLOBAL_DELETION_BASE()
@ -142,7 +140,5 @@ DIALOG_GLOBAL_DELETION_BASE::~DIALOG_GLOBAL_DELETION_BASE()
m_delDrawings->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCheckDeleteDrawings ), NULL, this );
m_delFootprints->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCheckDeleteFootprints ), NULL, this );
m_delTracks->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCheckDeleteTracks ), NULL, this );
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCancelClick ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onOkClick ), NULL, this );
}

View File

@ -14,6 +14,7 @@
<property name="file">dialog_global_deletion_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_global_deletion</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -1354,8 +1356,6 @@
<property name="minimum_size"></property>
<property name="name">m_sdbSizer1</property>
<property name="permission">protected</property>
<event name="OnCancelButtonClick">onCancelClick</event>
<event name="OnOKButtonClick">onOkClick</event>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -65,8 +65,6 @@ class DIALOG_GLOBAL_DELETION_BASE : public DIALOG_SHIM
virtual void onCheckDeleteDrawings( wxCommandEvent& event ) { event.Skip(); }
virtual void onCheckDeleteFootprints( wxCommandEvent& event ) { event.Skip(); }
virtual void onCheckDeleteTracks( wxCommandEvent& event ) { event.Skip(); }
virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -63,8 +63,6 @@ DIALOG_PUSH_PAD_PROPERTIES::DIALOG_PUSH_PAD_PROPERTIES( PCB_BASE_FRAME* aParent
}
/* Update the parameters for the component being edited.
*/
void DIALOG_PUSH_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
{
int returncode = 0;
@ -80,7 +78,12 @@ void DIALOG_PUSH_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
m_Pad_Layer_Filter = m_Pad_Layer_Filter_CB->GetValue();
m_Pad_Orient_Filter = m_Pad_Orient_Filter_CB->GetValue();
m_Pad_Type_Filter = m_Pad_Type_Filter_CB->GetValue();
EndModal( returncode );
if( IsQuasiModal() )
EndQuasiModal( returncode );
else
EndDialog( returncode );
break;
}

View File

@ -30,6 +30,7 @@
#include <gestfich.h>
#include <pcb_edit_frame.h>
#include <dialog_helpers.h>
#include <dialog_shim.h>
#include <locale_io.h>
#include <richio.h>
#include <filter_reader.h>
@ -62,14 +63,15 @@ enum id_mw_cmd {
};
class MWAVE_POLYGONAL_SHAPE_DLG : public wxDialog
class MWAVE_POLYGONAL_SHAPE_DLG : public DIALOG_SHIM
{
public:
MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, const wxPoint& pos );
~MWAVE_POLYGONAL_SHAPE_DLG() { };
bool TransferDataFromWindow() override;
private:
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
/**
@ -99,7 +101,6 @@ private:
BEGIN_EVENT_TABLE( MWAVE_POLYGONAL_SHAPE_DLG, wxDialog )
EVT_BUTTON( wxID_OK, MWAVE_POLYGONAL_SHAPE_DLG::OnOkClick )
EVT_BUTTON( wxID_CANCEL, MWAVE_POLYGONAL_SHAPE_DLG::OnCancelClick )
EVT_BUTTON( ID_READ_SHAPE_FILE, MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr )
END_EVENT_TABLE()
@ -107,8 +108,8 @@ END_EVENT_TABLE()
MWAVE_POLYGONAL_SHAPE_DLG::MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent,
const wxPoint& framepos ) :
wxDialog( parent, -1, _( "Complex shape" ), framepos, wxSize( 350, 280 ),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
DIALOG_SHIM( parent, -1, _( "Complex shape" ), framepos, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
{
m_Parent = parent;
@ -149,15 +150,19 @@ MWAVE_POLYGONAL_SHAPE_DLG::MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent,
void MWAVE_POLYGONAL_SHAPE_DLG::OnCancelClick( wxCommandEvent& event )
{
PolyEdges.clear();
EndModal( wxID_CANCEL );
event.Skip();
}
void MWAVE_POLYGONAL_SHAPE_DLG::OnOkClick( wxCommandEvent& event )
bool MWAVE_POLYGONAL_SHAPE_DLG::TransferDataFromWindow()
{
if( !wxDialog::TransferDataFromWindow() )
return false;
ShapeSize = m_SizeCtrl->GetValue();
PolyShapeType = m_ShapeOptionCtrl->GetSelection();
EndModal( wxID_OK );
return true;
}
@ -342,6 +347,7 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape()
pt.y = -pt.y; // mirror about X axis
polyPoints.push_back( pt );
}
break;
}

View File

@ -6,7 +6,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@ -38,7 +38,8 @@
#define LAYERNAME_COLNUM 2
/* classes to display a layer list using a wxGrid.
/*
* Display a layer list using a wxGrid.
*/
class PCB_LAYER_SELECTOR: public LAYER_SELECTOR
{
@ -52,20 +53,19 @@ public:
protected:
PCB_BASE_FRAME* m_frame;
// Returns true if the layer id is enabled (i.e. is it should be displayed)
///< @return true if the layer id is enabled (i.e. is it should be displayed).
bool isLayerEnabled( LAYER_NUM aLayer ) const override
{
return m_frame->GetBoard()->IsLayerEnabled( PCB_LAYER_ID( aLayer ) );
}
// Returns a color index from the layer id
// Virtual function
// Return the color index from the layer ID.
COLOR4D getLayerColor( LAYER_NUM aLayer ) const override
{
return m_frame->GetColorSettings()->GetColor( aLayer );
}
// Returns the name of the layer id
// Return the name of the layer ID.
wxString getLayerName( LAYER_NUM aLayer ) const override
{
return m_frame->GetBoard()->GetLayerName( ToLAYER_ID( aLayer ) );
@ -73,19 +73,11 @@ protected:
};
/*
* This class display a pcb layers list in a dialog,
* to select one layer from this list
/**
* Display a PCB layers list in a dialog to select one layer from this list.
*/
class PCB_ONE_LAYER_SELECTOR : public PCB_LAYER_SELECTOR,
public DIALOG_LAYER_SELECTION_BASE
class PCB_ONE_LAYER_SELECTOR : public PCB_LAYER_SELECTOR, public DIALOG_LAYER_SELECTION_BASE
{
PCB_LAYER_ID m_layerSelected;
LSET m_notAllowedLayersMask;
BOARD* m_brd;
std::vector<PCB_LAYER_ID> m_layersIdLeftColumn;
std::vector<PCB_LAYER_ID> m_layersIdRightColumn;
public:
PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD * aBrd, PCB_LAYER_ID aDefaultLayer,
LSET aNotAllowedLayersMask );
@ -102,6 +94,12 @@ private:
void onCharHook( wxKeyEvent& event );
void buildList();
PCB_LAYER_ID m_layerSelected;
LSET m_notAllowedLayersMask;
BOARD* m_brd;
std::vector<PCB_LAYER_ID> m_layersIdLeftColumn;
std::vector<PCB_LAYER_ID> m_layersIdRightColumn;
};
@ -211,14 +209,22 @@ void PCB_ONE_LAYER_SELECTOR::buildList()
void PCB_ONE_LAYER_SELECTOR::OnLeftGridCellClick( wxGridEvent& event )
{
m_layerSelected = m_layersIdLeftColumn[ event.GetRow() ];
EndModal( 1 );
if( IsQuasiModal() )
EndQuasiModal( 1 );
else
EndDialog( 1 );
}
void PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick( wxGridEvent& event )
{
m_layerSelected = m_layersIdRightColumn[ event.GetRow() ];
EndModal( 2 );
if( IsQuasiModal() )
EndQuasiModal( 2 );
else
EndDialog( 2 );
}
@ -243,22 +249,11 @@ PCB_LAYER_ID PCB_BASE_FRAME::SelectOneLayer( PCB_LAYER_ID aDefaultLayer, LSET aN
/**
* SELECT_COPPER_LAYERS_PAIR_DIALOG
* displays a double pcb copper layers list in a dialog,
* to select a layer pair from these lists
* Display a pair PCB copper layers list in a dialog to select a layer pair from these lists.
*/
class SELECT_COPPER_LAYERS_PAIR_DIALOG: public PCB_LAYER_SELECTOR,
public DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE
{
private:
BOARD* m_brd;
PCB_LAYER_ID m_frontLayer;
PCB_LAYER_ID m_backLayer;
int m_leftRowSelected;
int m_rightRowSelected;
std::vector<PCB_LAYER_ID> m_layersId;
public:
SELECT_COPPER_LAYERS_PAIR_DIALOG( PCB_BASE_FRAME* aParent, BOARD* aPcb,
PCB_LAYER_ID aFrontLayer, PCB_LAYER_ID aBackLayer );
@ -274,6 +269,14 @@ private:
void OnRightGridCellClick( wxGridEvent& event ) override;
void buildList();
BOARD* m_brd;
PCB_LAYER_ID m_frontLayer;
PCB_LAYER_ID m_backLayer;
int m_leftRowSelected;
int m_rightRowSelected;
std::vector<PCB_LAYER_ID> m_layersId;
};