From defac5272ba6db2bd797bb6f608e0cdf00a2acaf Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 18 Jul 2016 17:54:41 +0200 Subject: [PATCH 1/2] refinemenst in dialogs and OSX Cancel button fix --- eeschema/dialogs/dialog_libedit_options.cpp | 5 +++ pcbnew/dialogs/dialog_display_options.cpp | 7 ++-- .../dialog_edit_module_for_BoardEditor.cpp | 2 ++ .../dialog_edit_module_for_Modedit.cpp | 2 ++ pcbnew/dialogs/dialog_enum_pads.cpp | 9 ++--- pcbnew/dialogs/dialog_export_idf.cpp | 9 +++-- pcbnew/dialogs/dialog_export_idf_base.cpp | 34 +++++++++++++------ pcbnew/dialogs/dialog_export_idf_base.fbp | 2 +- pcbnew/dialogs/dialog_export_idf_base.h | 8 ++--- pcbnew/dialogs/dialog_export_vrml.cpp | 7 ++-- 10 files changed, 57 insertions(+), 28 deletions(-) diff --git a/eeschema/dialogs/dialog_libedit_options.cpp b/eeschema/dialogs/dialog_libedit_options.cpp index afd85ecace..4506d772fa 100644 --- a/eeschema/dialogs/dialog_libedit_options.cpp +++ b/eeschema/dialogs/dialog_libedit_options.cpp @@ -42,6 +42,11 @@ DIALOG_LIBEDIT_OPTIONS::DIALOG_LIBEDIT_OPTIONS( LIB_EDIT_FRAME* parent ) : SetRepeatLabelInc( Parent()->GetRepeatDeltaLabel() ); SetItemRepeatStep( Parent()->GetRepeatStep() ); SetPinRepeatStep( Parent()->GetRepeatPinStep() ); + + FixOSXCancelButtonIssue(); + + // Now all widgets have the size fixed, call FinishDialogSettings + FinishDialogSettings(); } void DIALOG_LIBEDIT_OPTIONS::SetGridSizes( const GRIDS& grid_sizes, int grid_id ) diff --git a/pcbnew/dialogs/dialog_display_options.cpp b/pcbnew/dialogs/dialog_display_options.cpp index 285cbe9157..23e535024a 100644 --- a/pcbnew/dialogs/dialog_display_options.cpp +++ b/pcbnew/dialogs/dialog_display_options.cpp @@ -56,9 +56,12 @@ DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS( PCB_EDIT_FRAME* parent ) : m_Parent = parent; init(); - m_sdbSizerOK->SetDefault(); - GetSizer()->SetSizeHints( this ); + + FixOSXCancelButtonIssue(); + + // Now all widgets have the size fixed, call FinishDialogSettings + FinishDialogSettings(); } void DIALOG_DISPLAY_OPTIONS::init() diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 8fb6069a39..bf1b07af09 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -88,6 +88,8 @@ DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR( PCB_EDIT_FRAME* aParent m_OrientValue = 0; Layout(); + + FixOSXCancelButtonIssue(); } diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 88beb93ba4..f5bd166e57 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -83,6 +83,8 @@ DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR( FOOTPRINT_EDIT_FRAME* m_sdbSizerStdButtonsOK->SetDefault(); Layout(); + + FixOSXCancelButtonIssue(); } diff --git a/pcbnew/dialogs/dialog_enum_pads.cpp b/pcbnew/dialogs/dialog_enum_pads.cpp index d222258726..b658f65280 100644 --- a/pcbnew/dialogs/dialog_enum_pads.cpp +++ b/pcbnew/dialogs/dialog_enum_pads.cpp @@ -27,10 +27,11 @@ DIALOG_ENUM_PADS::DIALOG_ENUM_PADS( wxWindow* aParent ) : DIALOG_ENUM_PADS_BASE( aParent ) { - // Calling SetSizeHints after all widgets are built is mandatory - // to set the correct size of the dialog - GetSizer()->SetSizeHints( this ); - Center(); + + FixOSXCancelButtonIssue(); + + // Now all widgets have the size fixed, call FinishDialogSettings + FinishDialogSettings(); } diff --git a/pcbnew/dialogs/dialog_export_idf.cpp b/pcbnew/dialogs/dialog_export_idf.cpp index 1beb178bd8..b38a8bb827 100644 --- a/pcbnew/dialogs/dialog_export_idf.cpp +++ b/pcbnew/dialogs/dialog_export_idf.cpp @@ -106,13 +106,12 @@ public: m_IDF_Yref->Enable( true ); } - wxWindow* button = FindWindowByLabel( wxT( "OK" ) ); + m_sdbSizerOK->SetDefault(); - if( button ) - SetDefaultItem( button ); + FixOSXCancelButtonIssue(); - GetSizer()->SetSizeHints( this ); - Centre(); + // Now all widgets have the size fixed, call FinishDialogSettings + FinishDialogSettings(); } ~DIALOG_EXPORT_IDF3() diff --git a/pcbnew/dialogs/dialog_export_idf_base.cpp b/pcbnew/dialogs/dialog_export_idf_base.cpp index 491559227a..fbc8132c29 100644 --- a/pcbnew/dialogs/dialog_export_idf_base.cpp +++ b/pcbnew/dialogs/dialog_export_idf_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version May 6 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -60,7 +60,14 @@ DIALOG_EXPORT_IDF3_BASE::DIALOG_EXPORT_IDF3_BASE( wxWindow* parent, wxWindowID i bSizer4->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_IDF_Xref = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); - m_IDF_Xref->SetMaxLength( 8 ); + #ifdef __WXGTK__ + if ( !m_IDF_Xref->HasFlag( wxTE_MULTILINE ) ) + { + m_IDF_Xref->SetMaxLength( 8 ); + } + #else + m_IDF_Xref->SetMaxLength( 8 ); + #endif bSizer4->Add( m_IDF_Xref, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); @@ -74,7 +81,14 @@ DIALOG_EXPORT_IDF3_BASE::DIALOG_EXPORT_IDF3_BASE( wxWindow* parent, wxWindowID i bSizer5->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_IDF_Yref = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); - m_IDF_Yref->SetMaxLength( 8 ); + #ifdef __WXGTK__ + if ( !m_IDF_Yref->HasFlag( wxTE_MULTILINE ) ) + { + m_IDF_Yref->SetMaxLength( 8 ); + } + #else + m_IDF_Yref->SetMaxLength( 8 ); + #endif bSizer5->Add( m_IDF_Yref, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); @@ -98,14 +112,14 @@ DIALOG_EXPORT_IDF3_BASE::DIALOG_EXPORT_IDF3_BASE( wxWindow* parent, wxWindowID i m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bSizerIDFFile->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); - m_sdbSizer1 = new wxStdDialogButtonSizer(); - m_sdbSizer1OK = new wxButton( this, wxID_OK ); - m_sdbSizer1->AddButton( m_sdbSizer1OK ); - m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); - m_sdbSizer1->Realize(); + 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(); - bSizerIDFFile->Add( m_sdbSizer1, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bSizerIDFFile->Add( m_sdbSizer, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); this->SetSizer( bSizerIDFFile ); diff --git a/pcbnew/dialogs/dialog_export_idf_base.fbp b/pcbnew/dialogs/dialog_export_idf_base.fbp index 8967150e98..1dee900da1 100644 --- a/pcbnew/dialogs/dialog_export_idf_base.fbp +++ b/pcbnew/dialogs/dialog_export_idf_base.fbp @@ -1205,7 +1205,7 @@ 0 0 - m_sdbSizer1 + m_sdbSizer protected diff --git a/pcbnew/dialogs/dialog_export_idf_base.h b/pcbnew/dialogs/dialog_export_idf_base.h index 131479d2f7..d4401439d2 100644 --- a/pcbnew/dialogs/dialog_export_idf_base.h +++ b/pcbnew/dialogs/dialog_export_idf_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version May 6 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -53,9 +53,9 @@ class DIALOG_EXPORT_IDF3_BASE : public DIALOG_SHIM wxTextCtrl* m_IDF_Yref; wxRadioBox* m_rbUnitSelection; wxStaticLine* m_staticline1; - wxStdDialogButtonSizer* m_sdbSizer1; - wxButton* m_sdbSizer1OK; - wxButton* m_sdbSizer1Cancel; + wxStdDialogButtonSizer* m_sdbSizer; + wxButton* m_sdbSizerOK; + wxButton* m_sdbSizerCancel; public: diff --git a/pcbnew/dialogs/dialog_export_vrml.cpp b/pcbnew/dialogs/dialog_export_vrml.cpp index 697204e7b2..c2165b94bc 100644 --- a/pcbnew/dialogs/dialog_export_vrml.cpp +++ b/pcbnew/dialogs/dialog_export_vrml.cpp @@ -86,8 +86,11 @@ public: tmpStr << m_YRef; m_VRML_Yref->SetValue( tmpStr ); m_sdbSizer1OK->SetDefault(); - GetSizer()->SetSizeHints( this ); - Centre(); + + FixOSXCancelButtonIssue(); + + // Now all widgets have the size fixed, call FinishDialogSettings + FinishDialogSettings(); Connect( ID_USE_ABS_PATH, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_EXPORT_3DFILE::OnUpdateUseRelativePath ) ); From 01100a57e54538dbf14f7791fc5f17eee8e836c4 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 18 Jul 2016 18:28:02 +0200 Subject: [PATCH 2/2] refinements in dialogs and OSX Cancel button fix --- pcbnew/dialogs/dialog_graphic_item_properties.cpp | 14 ++++++++++---- .../dialog_graphic_item_properties_base.cpp | 4 +++- .../dialog_graphic_item_properties_base.fbp | 2 +- .../dialogs/dialog_graphic_item_properties_base.h | 3 ++- pcbnew/dialogs/dialog_pad_properties.cpp | 4 ++-- pcbnew/dialogs/dialog_pad_properties.h | 9 +++++++++ pcbnew/dialogs/dialog_pad_properties_base.cpp | 2 ++ pcbnew/dialogs/dialog_pad_properties_base.fbp | 2 +- pcbnew/dialogs/dialog_pad_properties_base.h | 1 + 9 files changed, 31 insertions(+), 10 deletions(-) diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp index 1d6136852c..d8c2098ae5 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp @@ -72,6 +72,16 @@ private: bool TransferDataToWindow(); bool TransferDataFromWindow(); void OnLayerChoice( wxCommandEvent& event ); + + void OnInitDlg( wxInitDialogEvent& event ) + { + // Call the default wxDialog handler of a wxInitDialogEvent + TransferDataToWindow(); + + // Now all widgets have the size fixed, call FinishDialogSettings + FinishDialogSettings(); + } + bool Validate(); }; @@ -92,11 +102,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES( PCB_EDIT_FRAME* m_StandardButtonsSizerOK->SetDefault(); - Layout(); FixOSXCancelButtonIssue(); - - // Now all widgets have the size fixed, call FinishDialogSettings - FinishDialogSettings(); } diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_base.cpp b/pcbnew/dialogs/dialog_graphic_item_properties_base.cpp index f9a58d31d5..9b61ba454a 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties_base.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 9 2016) +// C++ code generated with wxFormBuilder (version May 6 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -159,11 +159,13 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnClose ) ); + this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnInitDlg ) ); } DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::~DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnClose ) ); + this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnInitDlg ) ); } diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_base.fbp b/pcbnew/dialogs/dialog_graphic_item_properties_base.fbp index 5a8b547f1a..a237974ccf 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties_base.fbp +++ b/pcbnew/dialogs/dialog_graphic_item_properties_base.fbp @@ -67,7 +67,7 @@ - + OnInitDlg diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_base.h b/pcbnew/dialogs/dialog_graphic_item_properties_base.h index 0067846792..8404f59879 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties_base.h +++ b/pcbnew/dialogs/dialog_graphic_item_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 9 2016) +// C++ code generated with wxFormBuilder (version May 6 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -70,6 +70,7 @@ class DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } + virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); } public: diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 40450aa66f..b65785f4ff 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -148,10 +148,10 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP } initValues(); - TransferDataToWindow(); + + FixOSXCancelButtonIssue(); m_sdbSizerOK->SetDefault(); - GetSizer()->SetSizeHints( this ); m_PadNumCtrl->SetFocus(); m_canUpdate = true; diff --git a/pcbnew/dialogs/dialog_pad_properties.h b/pcbnew/dialogs/dialog_pad_properties.h index 6e8028e995..7b8d25d9d3 100644 --- a/pcbnew/dialogs/dialog_pad_properties.h +++ b/pcbnew/dialogs/dialog_pad_properties.h @@ -119,6 +119,15 @@ private: /// Update the graphical pad shown in the panel. void OnValuesChanged( wxCommandEvent& event ); + void OnInitDlg( wxInitDialogEvent& event ) + { + // Call the default wxDialog handler of a wxInitDialogEvent + TransferDataToWindow(); + + // Now all widgets have the size fixed, call FinishDialogSettings + FinishDialogSettings(); + } + /// Updates the different parameters for the component being edited. /// Automatically fired from the OK button click. bool TransferDataFromWindow(); diff --git a/pcbnew/dialogs/dialog_pad_properties_base.cpp b/pcbnew/dialogs/dialog_pad_properties_base.cpp index 6eff023509..63d18746a5 100644 --- a/pcbnew/dialogs/dialog_pad_properties_base.cpp +++ b/pcbnew/dialogs/dialog_pad_properties_base.cpp @@ -594,6 +594,7 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind this->Centre( wxBOTH ); // Connect Events + this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnInitDlg ) ); m_PadNumCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this ); m_PadNetNameCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this ); m_PadType->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::PadTypeSelected ), NULL, this ); @@ -629,6 +630,7 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind DIALOG_PAD_PROPERTIES_BASE::~DIALOG_PAD_PROPERTIES_BASE() { // Disconnect Events + this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnInitDlg ) ); m_PadNumCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this ); m_PadNetNameCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this ); m_PadType->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::PadTypeSelected ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_pad_properties_base.fbp b/pcbnew/dialogs/dialog_pad_properties_base.fbp index 71a69992dc..dcff38772a 100644 --- a/pcbnew/dialogs/dialog_pad_properties_base.fbp +++ b/pcbnew/dialogs/dialog_pad_properties_base.fbp @@ -67,7 +67,7 @@ - + OnInitDlg diff --git a/pcbnew/dialogs/dialog_pad_properties_base.h b/pcbnew/dialogs/dialog_pad_properties_base.h index 22c2f8f086..80878b632a 100644 --- a/pcbnew/dialogs/dialog_pad_properties_base.h +++ b/pcbnew/dialogs/dialog_pad_properties_base.h @@ -162,6 +162,7 @@ class DIALOG_PAD_PROPERTIES_BASE : public DIALOG_SHIM wxButton* m_sdbSizerCancel; // Virtual event handlers, overide them in your derived class + virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); } virtual void OnValuesChanged( wxCommandEvent& event ) { event.Skip(); } virtual void PadTypeSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnPadShapeSelection( wxCommandEvent& event ) { event.Skip(); }