From e9ed3e3e55d9b9feea969422e49632a33fe3be89 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sat, 1 Aug 2015 17:30:38 -0400 Subject: [PATCH] Pcbnew: make OK button default item in dimension properties dialog. --- .../dialogs/dialog_dimension_editor_base.cpp | 21 ++++++------- .../dialogs/dialog_dimension_editor_base.fbp | 24 ++++++++------- pcbnew/dialogs/dialog_dimension_editor_base.h | 4 +-- pcbnew/dimension.cpp | 30 +++++++++++-------- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/pcbnew/dialogs/dialog_dimension_editor_base.cpp b/pcbnew/dialogs/dialog_dimension_editor_base.cpp index 0190bf6d6b..96205bb8ca 100644 --- a/pcbnew/dialogs/dialog_dimension_editor_base.cpp +++ b/pcbnew/dialogs/dialog_dimension_editor_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Jun 5 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -18,7 +18,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx wxBoxSizer* bSizerMain; bSizerMain = new wxBoxSizer( wxVERTICAL ); - m_staticTextDim = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextDim = new wxStaticText( this, wxID_ANY, _("Text"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextDim->Wrap( -1 ); bSizerMain->Add( m_staticTextDim, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -34,7 +34,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx wxBoxSizer* bSizerLeft; bSizerLeft = new wxBoxSizer( wxVERTICAL ); - m_staticTextSizeX = new wxStaticText( this, wxID_ANY, _("Size X"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextSizeX = new wxStaticText( this, wxID_ANY, _("Text Width"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextSizeX->Wrap( -1 ); bSizerLeft->Add( m_staticTextSizeX, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -42,7 +42,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx m_TxtSizeXCtrl->SetMaxLength( 0 ); bSizerLeft->Add( m_TxtSizeXCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - m_staticTextSizeY = new wxStaticText( this, wxID_ANY, _("Size Y"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextSizeY = new wxStaticText( this, wxID_ANY, _("Text Height"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextSizeY->Wrap( -1 ); bSizerLeft->Add( m_staticTextSizeY, 0, wxRIGHT|wxLEFT, 5 ); @@ -50,7 +50,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx m_TxtSizeYCtrl->SetMaxLength( 0 ); bSizerLeft->Add( m_TxtSizeYCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - m_staticTextWidth = new wxStaticText( this, wxID_ANY, _("Width"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextWidth = new wxStaticText( this, wxID_ANY, _("Text Thickness"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextWidth->Wrap( -1 ); bSizerLeft->Add( m_staticTextWidth, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -58,7 +58,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx m_TxtWidthCtrl->SetMaxLength( 0 ); bSizerLeft->Add( m_TxtWidthCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - m_staticTextPosX = new wxStaticText( this, wxID_ANY, _("Text position X"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextPosX = new wxStaticText( this, wxID_ANY, _("Text Position X"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextPosX->Wrap( -1 ); bSizerLeft->Add( m_staticTextPosX, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -66,7 +66,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx m_textCtrlPosX->SetMaxLength( 0 ); bSizerLeft->Add( m_textCtrlPosX, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - m_staticTextPosY = new wxStaticText( this, wxID_ANY, _("Text position Y"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextPosY = new wxStaticText( this, wxID_ANY, _("Text Position Y"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextPosY->Wrap( -1 ); bSizerLeft->Add( m_staticTextPosY, 0, wxRIGHT|wxLEFT, 5 ); @@ -86,7 +86,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx m_rbMirror->SetSelection( 0 ); bSizerRight->Add( m_rbMirror, 0, wxALL|wxEXPAND, 5 ); - m_staticTextLayer = new wxStaticText( this, wxID_ANY, _("Layer:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextLayer = new wxStaticText( this, wxID_ANY, _("Layer"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextLayer->Wrap( -1 ); bSizerRight->Add( m_staticTextLayer, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -100,7 +100,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); + bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); m_sdbSizerBts = new wxStdDialogButtonSizer(); m_sdbSizerBtsOK = new wxButton( this, wxID_OK ); @@ -109,11 +109,12 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx m_sdbSizerBts->AddButton( m_sdbSizerBtsCancel ); m_sdbSizerBts->Realize(); - bSizerMain->Add( m_sdbSizerBts, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSizerMain->Add( m_sdbSizerBts, 0, wxALL|wxEXPAND, 5 ); this->SetSizer( bSizerMain ); this->Layout(); + bSizerMain->Fit( this ); this->Centre( wxBOTH ); diff --git a/pcbnew/dialogs/dialog_dimension_editor_base.fbp b/pcbnew/dialogs/dialog_dimension_editor_base.fbp index 4373b4f5cf..96e453c125 100644 --- a/pcbnew/dialogs/dialog_dimension_editor_base.fbp +++ b/pcbnew/dialogs/dialog_dimension_editor_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -20,8 +20,10 @@ . 1 + 1 1 1 + UI 0 0 @@ -42,7 +44,7 @@ DIALOG_DIMENSION_EDITOR_BASE - 417,328 + -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Dimension Properties @@ -123,7 +125,7 @@ 0 0 wxID_ANY - Text: + Text 0 @@ -315,7 +317,7 @@ 0 0 wxID_ANY - Size X + Text Width 0 @@ -489,7 +491,7 @@ 0 0 wxID_ANY - Size Y + Text Height 0 @@ -663,7 +665,7 @@ 0 0 wxID_ANY - Width + Text Thickness 0 @@ -837,7 +839,7 @@ 0 0 wxID_ANY - Text position X + Text Position X 0 @@ -1011,7 +1013,7 @@ 0 0 wxID_ANY - Text position Y + Text Position Y 0 @@ -1286,7 +1288,7 @@ 0 0 wxID_ANY - Layer: + Layer 0 @@ -1434,7 +1436,7 @@ 5 - wxEXPAND | wxALL + wxEXPAND|wxLEFT|wxRIGHT|wxTOP 0 1 @@ -1515,7 +1517,7 @@ 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + wxALL|wxEXPAND 0 0 diff --git a/pcbnew/dialogs/dialog_dimension_editor_base.h b/pcbnew/dialogs/dialog_dimension_editor_base.h index 62291b9a22..6b03a0bb80 100644 --- a/pcbnew/dialogs/dialog_dimension_editor_base.h +++ b/pcbnew/dialogs/dialog_dimension_editor_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Jun 5 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -67,7 +67,7 @@ class DIALOG_DIMENSION_EDITOR_BASE : public DIALOG_SHIM public: - DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Dimension Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 417,328 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Dimension Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_DIMENSION_EDITOR_BASE(); }; diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index 618807a7b7..c59afa9a1c 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -48,7 +48,7 @@ /* Local functions */ static void BuildDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aPosition, bool aErase ); + const wxPoint& aPosition, bool aErase ); static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ); @@ -135,7 +135,7 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent, // Configure the layers list selector if( !m_Parent->GetBoard()->IsLayerEnabled( aDimension->GetLayer() ) ) - // Should not happens, because one acnnot select a board item on a + // Should not happens, because one cannot select a board item on a // not activated layer, but ... m_SelLayerBox->ShowNonActivatedLayers( true ); @@ -146,11 +146,12 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent, if( m_SelLayerBox->SetLayerSelection( aDimension->GetLayer() ) < 0 ) { - wxMessageBox( _("This item has an illegal layer id.\n" - "Now, forced on the drawings layer. Please, fix it") ); + wxMessageBox( _( "This item has an illegal layer id.\n" + "Now, forced on the drawings layer. Please, fix it" ) ); m_SelLayerBox->SetLayerSelection( Dwgs_User ); } + SetDefaultItem( m_sdbSizerBtsOK ); GetSizer()->Fit( this ); GetSizer()->SetSizeHints( this ); Centre(); @@ -169,8 +170,8 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event ) if( !m_Parent->GetBoard()->IsLayerEnabled( newlayer ) ) { - wxMessageBox( _( "the layer currently selected is not enabled for this board\n" - "You cannot use it" ) ); + wxMessageBox( _( "The layer currently selected is not enabled for this board\n" + "You cannot use it" ) ); return; } @@ -213,16 +214,16 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event ) if( width > maxthickness ) { DisplayError( NULL, - _( "The text thickness is too large for the text size. It will be clamped") ); + _( "The text thickness is too large for the text size. " + "It will be clamped" ) ); width = maxthickness; } CurrentDimension->SetWidth( width ); CurrentDimension->Text().SetThickness( width ); - CurrentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false ); - CurrentDimension->SetLayer( newlayer ); + #ifndef USE_WX_OVERLAY if( m_DC ) // Display new text { @@ -231,6 +232,7 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event ) #else m_Parent->Refresh(); #endif + m_Parent->OnModify(); EndModal( 1 ); } @@ -285,7 +287,6 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC ) aDimension->Text().SetThickness( width ); aDimension->SetWidth( width ); aDimension->AdjustDimensionDetails(); - aDimension->Draw( m_canvas, aDC, GR_XOR ); m_canvas->SetMouseCapture( BuildDimension, AbortBuildDimension ); @@ -316,7 +317,7 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC ) static void BuildDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aPosition, bool aErase ) + const wxPoint& aPosition, bool aErase ) { PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen(); DIMENSION* Dimension = (DIMENSION*) screen->GetCurItem(); @@ -377,9 +378,11 @@ void PCB_EDIT_FRAME::DeleteDimension( DIMENSION* aDimension, wxDC* aDC ) OnModify(); } + /* Initialize parameters to move a pcb text */ static wxPoint initialTextPosition; + void PCB_EDIT_FRAME::BeginMoveDimensionText( DIMENSION* aItem, wxDC* DC ) { if( aItem == NULL ) @@ -403,7 +406,7 @@ void PCB_EDIT_FRAME::BeginMoveDimensionText( DIMENSION* aItem, wxDC* DC ) /* Move dimension text following the cursor. */ static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, - bool aErase ) + bool aErase ) { DIMENSION* dimension = (DIMENSION*) aPanel->GetScreen()->GetCurItem(); @@ -418,6 +421,7 @@ static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& dimension->Draw( aPanel, aDC, GR_XOR ); } + /* * Abort current text edit progress. * @@ -439,6 +443,7 @@ void AbortMoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) dimension->Draw( aPanel, aDC, GR_OR ); } + /* * Place the current dimension text being moving */ @@ -457,6 +462,5 @@ void PCB_EDIT_FRAME::PlaceDimensionText( DIMENSION* aItem, wxDC* DC ) aItem->Text().SetTextPosition( initialTextPosition ); SaveCopyInUndoList( aItem, UR_CHANGED ); aItem->Text().SetTextPosition( tmp ); - aItem->ClearFlags(); }