From 48573712e832fbc98fadb3c7268caa98f3ddb32a Mon Sep 17 00:00:00 2001 From: Chris Pavlina Date: Tue, 12 Apr 2016 19:18:33 -0400 Subject: [PATCH] Exterminate another 0.1deg field --- pcbnew/dialogs/dialog_pcb_text_properties.cpp | 59 +++++++++---------- .../dialog_pcb_text_properties_base.cpp | 24 ++------ .../dialog_pcb_text_properties_base.fbp | 12 ++-- .../dialogs/dialog_pcb_text_properties_base.h | 10 +--- 4 files changed, 39 insertions(+), 66 deletions(-) diff --git a/pcbnew/dialogs/dialog_pcb_text_properties.cpp b/pcbnew/dialogs/dialog_pcb_text_properties.cpp index 748557d7f3..4d78c42bfa 100644 --- a/pcbnew/dialogs/dialog_pcb_text_properties.cpp +++ b/pcbnew/dialogs/dialog_pcb_text_properties.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004-2010 Jean-Pierre Charras - * Copyright (C) 2010-2015 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2010-2016 KiCad Developers, see change_log.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 @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -58,12 +59,11 @@ private: wxDC* m_DC; TEXTE_PCB* m_SelectedPCBText; - void MyInit(); + wxFloatingPointValidator m_OrientValidator; + double m_OrientValue; - // Handlers for DIALOG_PCB_TEXT_PROPERTIES_BASE events. - void OnClose( wxCloseEvent& event ); - void OnCancelClick( wxCommandEvent& event ); - void OnOkClick( wxCommandEvent& event ); + bool TransferDataToWindow(); + bool TransferDataFromWindow(); }; @@ -75,14 +75,19 @@ private: */ DIALOG_PCB_TEXT_PROPERTIES::DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent, - TEXTE_PCB* passedTextPCB, wxDC* DC ) - : DIALOG_PCB_TEXT_PROPERTIES_BASE( parent ) + TEXTE_PCB* passedTextPCB, wxDC* DC ) : + DIALOG_PCB_TEXT_PROPERTIES_BASE( parent ), + m_OrientValidator( 1, &m_OrientValue ) { m_Parent = parent; m_DC = DC; m_SelectedPCBText = passedTextPCB; - MyInit(); + m_OrientValue = 0.0; + m_OrientValidator.SetRange( -360.0, 360.0 ); + m_OrientCtrl->SetValidator( m_OrientValidator ); + m_OrientValidator.SetWindow( m_OrientCtrl ); + m_StandardSizerOK->SetDefault(); GetSizer()->SetSizeHints( this ); Centre(); @@ -108,7 +113,7 @@ void PCB_EDIT_FRAME::InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC ) } -void DIALOG_PCB_TEXT_PROPERTIES::MyInit() +bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow() { // Put units symbols to text labels where appropriate AddUnitSymbol( *m_SizeXLabel ); @@ -135,9 +140,7 @@ void DIALOG_PCB_TEXT_PROPERTIES::MyInit() m_LayerSelectionCtrl->Resync(); m_LayerSelectionCtrl->SetLayerSelection( m_SelectedPCBText->GetLayer() ); - wxString orientationStr; - orientationStr << m_SelectedPCBText->GetOrientation(); - m_OrientationCtrl->SetValue( orientationStr ); + m_OrientValue = m_SelectedPCBText->GetOrientation() / 10.0; if( m_SelectedPCBText->IsMirrored() ) m_DisplayCtrl->SetSelection( 1 ); @@ -159,8 +162,8 @@ void DIALOG_PCB_TEXT_PROPERTIES::MyInit() m_ThicknessCtrl->MoveAfterInTabOrder( m_SizeYCtrl ); m_PositionXCtrl->MoveAfterInTabOrder( m_ThicknessCtrl ); m_PositionYCtrl->MoveAfterInTabOrder( m_PositionXCtrl ); - m_OrientationCtrl->MoveAfterInTabOrder( m_PositionYCtrl ); - m_LayerSelectionCtrl->MoveAfterInTabOrder( m_OrientationCtrl ); + m_OrientCtrl->MoveAfterInTabOrder( m_PositionYCtrl ); + m_LayerSelectionCtrl->MoveAfterInTabOrder( m_OrientCtrl ); m_StyleCtrl->MoveAfterInTabOrder( m_LayerSelectionCtrl ); m_DisplayCtrl->MoveAfterInTabOrder( m_StyleCtrl ); m_justifyChoice->MoveAfterInTabOrder( m_DisplayCtrl ); @@ -168,30 +171,24 @@ void DIALOG_PCB_TEXT_PROPERTIES::MyInit() // Set focus on most important control m_TextContentCtrl->SetFocus(); m_TextContentCtrl->SetSelection( -1, -1 ); + + return DIALOG_PCB_TEXT_PROPERTIES_BASE::TransferDataToWindow(); } -void DIALOG_PCB_TEXT_PROPERTIES::OnClose( wxCloseEvent& event ) +bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow() { - EndModal( 0 ); -} + if( !DIALOG_PCB_TEXT_PROPERTIES_BASE::TransferDataFromWindow() ) + return false; -void DIALOG_PCB_TEXT_PROPERTIES::OnCancelClick( wxCommandEvent& event ) -{ - EndModal( wxID_CANCEL ); -} - - -void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) -{ // Test for acceptable layer. // Incorrect layer can happen for old boards, // having texts on edge cut layer for instance if( m_LayerSelectionCtrl->GetLayerSelection() < 0 ) { wxMessageBox( _( "No layer selected, Please select the text layer" ) ); - return; + return false; } wxPoint newPosition; @@ -268,10 +265,7 @@ void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) m_SelectedPCBText->SetMirrored( m_DisplayCtrl->GetSelection() == 1 ); // Set the text orientation - long orientation; - m_OrientationCtrl->GetValue().ToLong( &orientation ); - orientation = orientation % 3600; - m_SelectedPCBText->SetOrientation( orientation ); + m_SelectedPCBText->SetOrientation( m_OrientValue * 10.0 ); // Set whether the PCB text is slanted (it is not italics, as italics has additional curves in style) m_SelectedPCBText->SetItalic( m_StyleCtrl->GetSelection() ); @@ -302,5 +296,6 @@ void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) m_parent->Refresh(); #endif m_Parent->OnModify(); - EndModal( 1 ); + + return true; } diff --git a/pcbnew/dialogs/dialog_pcb_text_properties_base.cpp b/pcbnew/dialogs/dialog_pcb_text_properties_base.cpp index 65c8b2af57..95f7b15cc5 100644 --- a/pcbnew/dialogs/dialog_pcb_text_properties_base.cpp +++ b/pcbnew/dialogs/dialog_pcb_text_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Apr 9 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -57,11 +57,9 @@ DIALOG_PCB_TEXT_PROPERTIES_BASE::DIALOG_PCB_TEXT_PROPERTIES_BASE( wxWindow* pare fgSizer1->Add( m_staticText10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_SizeXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_SizeXCtrl->SetMaxLength( 0 ); fgSizer1->Add( m_SizeXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_PositionXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_PositionXCtrl->SetMaxLength( 0 ); fgSizer1->Add( m_PositionXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_LayerSelectionCtrl = new PCB_LAYER_BOX_SELECTOR( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); @@ -90,11 +88,9 @@ DIALOG_PCB_TEXT_PROPERTIES_BASE::DIALOG_PCB_TEXT_PROPERTIES_BASE( wxWindow* pare fgSizer1->Add( m_staticText11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_SizeYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_SizeYCtrl->SetMaxLength( 0 ); fgSizer1->Add( m_SizeYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_PositionYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_PositionYCtrl->SetMaxLength( 0 ); fgSizer1->Add( m_PositionYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); wxString m_StyleCtrlChoices[] = { _("Normal"), _("Italic") }; @@ -113,7 +109,7 @@ DIALOG_PCB_TEXT_PROPERTIES_BASE::DIALOG_PCB_TEXT_PROPERTIES_BASE( wxWindow* pare m_ThicknessLabel->Wrap( -1 ); fgSizer1->Add( m_ThicknessLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - m_orientationLabel = new wxStaticText( this, wxID_ANY, _("Orientation (0.1 deg):"), wxDefaultPosition, wxDefaultSize, 0 ); + m_orientationLabel = new wxStaticText( this, wxID_ANY, _("Orientation (deg):"), wxDefaultPosition, wxDefaultSize, 0 ); m_orientationLabel->Wrap( -1 ); fgSizer1->Add( m_orientationLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); @@ -124,12 +120,10 @@ DIALOG_PCB_TEXT_PROPERTIES_BASE::DIALOG_PCB_TEXT_PROPERTIES_BASE( wxWindow* pare fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); m_ThicknessCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_ThicknessCtrl->SetMaxLength( 0 ); fgSizer1->Add( m_ThicknessCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - m_OrientationCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_OrientationCtrl->SetMaxLength( 0 ); - fgSizer1->Add( m_OrientationCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + m_OrientCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer1->Add( m_OrientCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); bSizer9->Add( fgSizer1, 1, wxALL|wxEXPAND, 5 ); @@ -152,18 +146,8 @@ DIALOG_PCB_TEXT_PROPERTIES_BASE::DIALOG_PCB_TEXT_PROPERTIES_BASE( wxWindow* pare bMainSizer->Fit( this ); this->Centre( wxBOTH ); - - // Connect Events - this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PCB_TEXT_PROPERTIES_BASE::OnClose ) ); - m_StandardSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCB_TEXT_PROPERTIES_BASE::OnCancelClick ), NULL, this ); - m_StandardSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCB_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this ); } DIALOG_PCB_TEXT_PROPERTIES_BASE::~DIALOG_PCB_TEXT_PROPERTIES_BASE() { - // Disconnect Events - this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PCB_TEXT_PROPERTIES_BASE::OnClose ) ); - m_StandardSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCB_TEXT_PROPERTIES_BASE::OnCancelClick ), NULL, this ); - m_StandardSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCB_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this ); - } diff --git a/pcbnew/dialogs/dialog_pcb_text_properties_base.fbp b/pcbnew/dialogs/dialog_pcb_text_properties_base.fbp index 103fea24f0..1e88fb5a71 100644 --- a/pcbnew/dialogs/dialog_pcb_text_properties_base.fbp +++ b/pcbnew/dialogs/dialog_pcb_text_properties_base.fbp @@ -61,7 +61,7 @@ - OnClose + @@ -220,7 +220,7 @@ 0 - + 0 0 400,60 @@ -1790,7 +1790,7 @@ 0 0 wxID_ANY - Orientation (0.1 deg): + Orientation (deg): 0 @@ -1992,7 +1992,7 @@ 0 1 - m_OrientationCtrl + m_OrientCtrl 1 @@ -2062,11 +2062,11 @@ m_StandardSizer protected - OnCancelClick + - OnOkClick + diff --git a/pcbnew/dialogs/dialog_pcb_text_properties_base.h b/pcbnew/dialogs/dialog_pcb_text_properties_base.h index ddadfbe75c..771522286e 100644 --- a/pcbnew/dialogs/dialog_pcb_text_properties_base.h +++ b/pcbnew/dialogs/dialog_pcb_text_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Apr 9 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -60,16 +60,10 @@ class DIALOG_PCB_TEXT_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_ThicknessLabel; wxStaticText* m_orientationLabel; wxTextCtrl* m_ThicknessCtrl; - wxTextCtrl* m_OrientationCtrl; + wxTextCtrl* m_OrientCtrl; wxStdDialogButtonSizer* m_StandardSizer; wxButton* m_StandardSizerOK; wxButton* m_StandardSizerCancel; - - // Virtual event handlers, overide them in your derived class - virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } - public: