From 698bd331c421e2a0f1043dce7cf530f905ffe974 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 10 Feb 2015 11:38:22 +0100 Subject: [PATCH] Dialog enum pads: fix incorrect use of sizers. --- pcbnew/dialogs/dialog_enum_pads.cpp | 4 + pcbnew/dialogs/dialog_enum_pads_base.cpp | 41 +++--- pcbnew/dialogs/dialog_enum_pads_base.fbp | 158 ++++++++++++++++++----- pcbnew/dialogs/dialog_enum_pads_base.h | 15 ++- pcbnew/modedit.cpp | 8 +- 5 files changed, 163 insertions(+), 63 deletions(-) diff --git a/pcbnew/dialogs/dialog_enum_pads.cpp b/pcbnew/dialogs/dialog_enum_pads.cpp index 51f822047e..d222258726 100644 --- a/pcbnew/dialogs/dialog_enum_pads.cpp +++ b/pcbnew/dialogs/dialog_enum_pads.cpp @@ -27,6 +27,10 @@ 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(); } diff --git a/pcbnew/dialogs/dialog_enum_pads_base.cpp b/pcbnew/dialogs/dialog_enum_pads_base.cpp index af1ac745f3..58a724210c 100644 --- a/pcbnew/dialogs/dialog_enum_pads_base.cpp +++ b/pcbnew/dialogs/dialog_enum_pads_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 30 2013) +// C++ code generated with wxFormBuilder (version Jun 5 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -9,43 +9,46 @@ /////////////////////////////////////////////////////////////////////////// -DIALOG_ENUM_PADS_BASE::DIALOG_ENUM_PADS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +DIALOG_ENUM_PADS_BASE::DIALOG_ENUM_PADS_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* bPrefixSizer; - bPrefixSizer = new wxBoxSizer( wxHORIZONTAL ); + m_lblInfo = new wxStaticText( this, wxID_ANY, _("Pad names are restricted to 4 characters (including number)."), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblInfo->Wrap( -1 ); + bMainSizer->Add( m_lblInfo, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + + bMainSizer->Add( 0, 0, 0, wxTOP|wxBOTTOM, 5 ); + + wxFlexGridSizer* fgSizer; + fgSizer = new wxFlexGridSizer( 0, 2, 0, 0 ); + fgSizer->AddGrowableCol( 1 ); + fgSizer->SetFlexibleDirection( wxBOTH ); + fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_lblPadPrefix = new wxStaticText( this, wxID_ANY, _("Pad name prefix:"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblPadPrefix->Wrap( -1 ); - bPrefixSizer->Add( m_lblPadPrefix, 1, wxALL, 5 ); + fgSizer->Add( m_lblPadPrefix, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_padPrefix = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_padPrefix->SetMaxLength( 4 ); - bPrefixSizer->Add( m_padPrefix, 0, wxALL, 5 ); - - - bMainSizer->Add( bPrefixSizer, 1, wxEXPAND, 5 ); - - wxBoxSizer* bPadNumSizer; - bPadNumSizer = new wxBoxSizer( wxHORIZONTAL ); + fgSizer->Add( m_padPrefix, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); m_lblPadStartNum = new wxStaticText( this, wxID_ANY, _("First pad number:"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblPadStartNum->Wrap( -1 ); - bPadNumSizer->Add( m_lblPadStartNum, 1, wxALL, 5 ); + fgSizer->Add( m_lblPadStartNum, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_padStartNum = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 999, 1 ); - bPadNumSizer->Add( m_padStartNum, 0, wxALL, 5 ); + fgSizer->Add( m_padStartNum, 0, wxALL|wxEXPAND, 5 ); - bMainSizer->Add( bPadNumSizer, 1, wxEXPAND, 5 ); + bMainSizer->Add( fgSizer, 1, wxEXPAND|wxALL, 5 ); - m_lblInfo = new wxStaticText( this, wxID_ANY, _("Pad names are restricted to 4 characters (including number)."), wxDefaultPosition, wxDefaultSize, 0 ); - m_lblInfo->Wrap( 320 ); - bMainSizer->Add( m_lblInfo, 0, wxALL, 5 ); + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); m_stdButtons = new wxStdDialogButtonSizer(); m_stdButtonsOK = new wxButton( this, wxID_OK ); @@ -54,7 +57,7 @@ DIALOG_ENUM_PADS_BASE::DIALOG_ENUM_PADS_BASE( wxWindow* parent, wxWindowID id, c m_stdButtons->AddButton( m_stdButtonsCancel ); m_stdButtons->Realize(); - bMainSizer->Add( m_stdButtons, 2, wxEXPAND, 5 ); + bMainSizer->Add( m_stdButtons, 0, wxEXPAND|wxALL, 5 ); this->SetSizer( bMainSizer ); diff --git a/pcbnew/dialogs/dialog_enum_pads_base.fbp b/pcbnew/dialogs/dialog_enum_pads_base.fbp index f17006d1f9..3c5c7515f6 100644 --- a/pcbnew/dialogs/dialog_enum_pads_base.fbp +++ b/pcbnew/dialogs/dialog_enum_pads_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -20,8 +20,10 @@ . 1 + 1 1 1 + UI 0 0 @@ -42,9 +44,9 @@ DIALOG_ENUM_PADS_BASE - 340,240 - wxDEFAULT_DIALOG_STYLE - + 340,187 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h Pad enumeration settings @@ -93,17 +95,117 @@ none 5 - wxEXPAND - 1 - + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Pad names are restricted to 4 characters (including number). + + 0 + + + 0 - bPrefixSizer - wxHORIZONTAL + 1 + m_lblInfo + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxBOTTOM + 0 + + 0 + protected + 0 + + + + 5 + wxEXPAND|wxALL + 1 + + 2 + wxBOTH + 1 + + 0 + + fgSizer + wxFLEX_GROWMODE_SPECIFIED none + 0 + 0 5 - wxALL - 1 + wxALL|wxALIGN_CENTER_VERTICAL + 0 1 1 @@ -185,7 +287,7 @@ 5 - wxALL + wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL 0 1 @@ -274,21 +376,10 @@ - - - - 5 - wxEXPAND - 1 - - - bPadNumSizer - wxHORIZONTAL - none 5 - wxALL - 1 + wxALL|wxALIGN_CENTER_VERTICAL + 0 1 1 @@ -370,7 +461,7 @@ 5 - wxALL + wxALL|wxEXPAND 0 1 @@ -452,6 +543,7 @@ + @@ -459,9 +551,9 @@ 5 - wxALL + wxEXPAND | wxALL 0 - + 1 1 1 @@ -489,7 +581,6 @@ 0 0 wxID_ANY - Pad names are restricted to 4 characters (including number). 0 @@ -497,7 +588,7 @@ 0 1 - m_lblInfo + m_staticline1 1 @@ -507,14 +598,13 @@ Resizable 1 - + wxLI_HORIZONTAL 0 - 320 @@ -542,8 +632,8 @@ 5 - wxEXPAND - 2 + wxEXPAND|wxALL + 0 0 1 diff --git a/pcbnew/dialogs/dialog_enum_pads_base.h b/pcbnew/dialogs/dialog_enum_pads_base.h index caed966dcd..1e60111b9b 100644 --- a/pcbnew/dialogs/dialog_enum_pads_base.h +++ b/pcbnew/dialogs/dialog_enum_pads_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 30 2013) +// C++ code generated with wxFormBuilder (version Jun 5 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -11,6 +11,9 @@ #include #include #include +class DIALOG_SHIM; + +#include "dialog_shim.h" #include #include #include @@ -18,8 +21,9 @@ #include #include #include -#include #include +#include +#include #include #include @@ -29,23 +33,24 @@ /////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_ENUM_PADS_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_ENUM_PADS_BASE : public wxDialog +class DIALOG_ENUM_PADS_BASE : public DIALOG_SHIM { private: protected: + wxStaticText* m_lblInfo; wxStaticText* m_lblPadPrefix; wxTextCtrl* m_padPrefix; wxStaticText* m_lblPadStartNum; wxSpinCtrl* m_padStartNum; - wxStaticText* m_lblInfo; + wxStaticLine* m_staticline1; wxStdDialogButtonSizer* m_stdButtons; wxButton* m_stdButtonsOK; wxButton* m_stdButtonsCancel; public: - DIALOG_ENUM_PADS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pad enumeration settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 340,240 ), long style = wxDEFAULT_DIALOG_STYLE ); + DIALOG_ENUM_PADS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pad enumeration settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 340,187 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_ENUM_PADS_BASE(); }; diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 3f54a60907..61951c2795 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -315,9 +315,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) Zoom_Automatique( false ); } - if( IsGalCanvasActive() ) - updateView(); - + updateView(); m_canvas->Refresh(); GetScreen()->ClrModify(); @@ -562,10 +560,10 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( m_Draw3DFrame ) m_Draw3DFrame->NewDisplay(); - m_canvas->Refresh(); - GetScreen()->ClrModify(); + updateView(); + m_canvas->Refresh(); break;