diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp index 7d90d8635b..82abae93a9 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2010 Jean-Pierre Charras - * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2016 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 @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -60,27 +61,37 @@ private: DRAWSEGMENT* m_item; BOARD_DESIGN_SETTINGS m_brdSettings; + wxFloatingPointValidator m_AngleValidator; + double m_AngleValue; + public: DIALOG_GRAPHIC_ITEM_PROPERTIES( PCB_EDIT_FRAME* aParent, DRAWSEGMENT* aItem, wxDC* aDC ); ~DIALOG_GRAPHIC_ITEM_PROPERTIES() {}; private: - void initDlg(); - void OnOkClick( wxCommandEvent& event ); - void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } + bool TransferDataToWindow(); + bool TransferDataFromWindow(); void OnLayerChoice( wxCommandEvent& event ); - bool itemValuesOK(); + bool Validate(); }; DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES( PCB_EDIT_FRAME* aParent, DRAWSEGMENT* aItem, wxDC* aDC ): - DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( aParent ) + DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( aParent ), + m_AngleValidator( 1, &m_AngleValue ), + m_AngleValue( 0.0 ) { m_parent = aParent; m_DC = aDC; m_item = aItem; m_brdSettings = m_parent->GetDesignSettings(); - initDlg(); + + m_AngleValidator.SetRange( -360.0, 360.0 ); + m_AngleCtrl->SetValidator( m_AngleValidator ); + m_AngleValidator.SetWindow( m_AngleCtrl ); + + m_StandardButtonsSizerOK->SetDefault(); + Layout(); GetSizer()->SetSizeHints( this ); Centre(); @@ -99,10 +110,8 @@ void PCB_EDIT_FRAME::InstallGraphicItemPropertiesDialog( DRAWSEGMENT* aItem, wxD } -void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg() +bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow() { - m_StandardButtonsSizerOK->SetDefault(); - // Set unit symbol wxStaticText* texts_unit[] = { @@ -112,14 +121,10 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg() m_EndPointYUnit, m_ThicknessTextUnit, m_DefaulThicknessTextUnit, - NULL }; - for( int ii = 0; ; ii++ ) + for( int ii = 0; ii < DIM( texts_unit ); ii++ ) { - if( texts_unit[ii] == NULL ) - break; - texts_unit[ii]->SetLabel( GetAbbreviatedUnitsLabel() ); } @@ -134,8 +139,8 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg() m_StartPointYLabel->SetLabel( _( "Center Y:" ) ); m_EndPointXLabel->SetLabel( _( "Point X:" ) ); m_EndPointYLabel->SetLabel( _( "Point Y:" ) ); - m_Angle_Text->Show( false ); - m_Angle_Ctrl->Show( false ); + m_AngleText->Show( false ); + m_AngleCtrl->Show( false ); m_AngleUnit->Show( false ); break; @@ -146,9 +151,7 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg() m_EndPointXLabel->SetLabel( _( "Start Point X:" ) ); m_EndPointYLabel->SetLabel( _( "Start Point Y:" ) ); - // Here the angle is a double, but the UI is still working with integers. - msg << int( m_item->GetAngle() ); - m_Angle_Ctrl->SetValue( msg ); + m_AngleValue = m_item->GetAngle() / 10.0; break; case S_SEGMENT: @@ -156,8 +159,8 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg() // Fall through. default: - m_Angle_Text->Show( false ); - m_Angle_Ctrl->Show( false ); + m_AngleText->Show( false ); + m_AngleCtrl->Show( false ); m_AngleUnit->Show( false ); break; } @@ -193,6 +196,8 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg() "It has been moved to the drawings layer. Please fix it." ) ); m_LayerSelectionCtrl->SetLayerSelection( Dwgs_User ); } + + return DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::TransferDataToWindow(); } @@ -209,10 +214,10 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnLayerChoice( wxCommandEvent& event ) } -void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event ) +bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow() { - if( !itemValuesOK() ) - return; + if( !DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::TransferDataFromWindow() ) + return false; m_parent->SaveCopyInUndoList( m_item, UR_CHANGED ); @@ -248,10 +253,7 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event ) if( m_item->GetShape() == S_ARC ) { - double angle; - m_Angle_Ctrl->GetValue().ToDouble( &angle ); - NORMALIZE_ANGLE_360( angle ); - m_item->SetAngle( angle ); + m_item->SetAngle( m_AngleValue * 10.0 ); } m_parent->OnModify(); @@ -263,14 +265,17 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event ) m_parent->SetDesignSettings( m_brdSettings ); - Close( true ); + return true; } -bool DIALOG_GRAPHIC_ITEM_PROPERTIES::itemValuesOK() +bool DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate() { wxArrayString error_msgs; + if( !DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::Validate() ) + return false; + // Load the start and end points -- all types use these in the checks. int startx = ValueFromString( g_UserUnit, m_Center_StartXCtrl->GetValue() ); int starty = ValueFromString( g_UserUnit, m_Center_StartYCtrl->GetValue() ); @@ -282,11 +287,7 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::itemValuesOK() { case S_ARC: // Check angle of arc. - double angle; - m_Angle_Ctrl->GetValue().ToDouble( &angle ); - NORMALIZE_ANGLE_360( angle ); - - if( angle == 0 ) + if( m_AngleValue == 0.0 ) { error_msgs.Add( _( "The arc angle must be greater than zero." ) ); } diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_base.cpp b/pcbnew/dialogs/dialog_graphic_item_properties_base.cpp index 4590d47071..f9a58d31d5 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 Jun 5 2014) +// C++ code generated with wxFormBuilder (version Apr 9 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -32,7 +32,6 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind fgUpperLeftGridSizer->Add( m_StartPointXLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 ); m_Center_StartXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_Center_StartXCtrl->SetMaxLength( 0 ); fgUpperLeftGridSizer->Add( m_Center_StartXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); m_StartPointXUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -44,7 +43,6 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind fgUpperLeftGridSizer->Add( m_StartPointYLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 ); m_Center_StartYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_Center_StartYCtrl->SetMaxLength( 0 ); fgUpperLeftGridSizer->Add( m_Center_StartYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); m_StartPointYUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -56,7 +54,6 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind fgUpperLeftGridSizer->Add( m_EndPointXLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 ); m_EndX_Radius_Ctrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_EndX_Radius_Ctrl->SetMaxLength( 0 ); fgUpperLeftGridSizer->Add( m_EndX_Radius_Ctrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); m_EndPointXUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -68,7 +65,6 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind fgUpperLeftGridSizer->Add( m_EndPointYLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 ); m_EndY_Ctrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_EndY_Ctrl->SetMaxLength( 0 ); fgUpperLeftGridSizer->Add( m_EndY_Ctrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); m_EndPointYUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -90,15 +86,14 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind fgUpperRightGridSizer->SetFlexibleDirection( wxBOTH ); fgUpperRightGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_Angle_Text = new wxStaticText( this, wxID_ANY, _("Arc angle:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Angle_Text->Wrap( -1 ); - fgUpperRightGridSizer->Add( m_Angle_Text, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 ); + m_AngleText = new wxStaticText( this, wxID_ANY, _("Arc angle:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_AngleText->Wrap( -1 ); + fgUpperRightGridSizer->Add( m_AngleText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 ); - m_Angle_Ctrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_Angle_Ctrl->SetMaxLength( 0 ); - fgUpperRightGridSizer->Add( m_Angle_Ctrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); + m_AngleCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgUpperRightGridSizer->Add( m_AngleCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); - m_AngleUnit = new wxStaticText( this, wxID_ANY, _("0.1 degree"), wxDefaultPosition, wxDefaultSize, 0 ); + m_AngleUnit = new wxStaticText( this, wxID_ANY, _("degrees"), wxDefaultPosition, wxDefaultSize, 0 ); m_AngleUnit->Wrap( -1 ); fgUpperRightGridSizer->Add( m_AngleUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); @@ -107,7 +102,6 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind fgUpperRightGridSizer->Add( m_ThicknessLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 ); m_ThicknessCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_ThicknessCtrl->SetMaxLength( 0 ); fgUpperRightGridSizer->Add( m_ThicknessCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); m_ThicknessTextUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -119,7 +113,6 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind fgUpperRightGridSizer->Add( m_DefaultThicknessLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxTOP, 5 ); m_DefaultThicknessCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_DefaultThicknessCtrl->SetMaxLength( 0 ); fgUpperRightGridSizer->Add( m_DefaultThicknessCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); m_DefaulThicknessTextUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -166,15 +159,11 @@ 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 ) ); - m_StandardButtonsSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnCancelClick ), NULL, this ); - m_StandardButtonsSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnOkClick ), NULL, this ); } DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::~DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnClose ) ); - m_StandardButtonsSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnCancelClick ), NULL, this ); - m_StandardButtonsSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnOkClick ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_base.fbp b/pcbnew/dialogs/dialog_graphic_item_properties_base.fbp index 1fcb7cd99b..5a8b547f1a 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties_base.fbp +++ b/pcbnew/dialogs/dialog_graphic_item_properties_base.fbp @@ -1294,7 +1294,7 @@ 0 1 - m_Angle_Text + m_AngleText 1 @@ -1377,7 +1377,7 @@ 0 1 - m_Angle_Ctrl + m_AngleCtrl 1 @@ -1460,7 +1460,7 @@ 0 0 wxID_ANY - 0.1 degree + degrees 0 @@ -2313,11 +2313,11 @@ m_StandardButtonsSizer protected - OnCancelClick + - OnOkClick + diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_base.h b/pcbnew/dialogs/dialog_graphic_item_properties_base.h index 84a8bb8e8f..0067846792 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 Jun 5 2014) +// C++ code generated with wxFormBuilder (version Apr 9 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -52,8 +52,8 @@ class DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE : public DIALOG_SHIM wxTextCtrl* m_EndY_Ctrl; wxStaticText* m_EndPointYUnit; wxStaticLine* m_staticline2; - wxStaticText* m_Angle_Text; - wxTextCtrl* m_Angle_Ctrl; + wxStaticText* m_AngleText; + wxTextCtrl* m_AngleCtrl; wxStaticText* m_AngleUnit; wxStaticText* m_ThicknessLabel; wxTextCtrl* m_ThicknessCtrl; @@ -70,8 +70,6 @@ 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 OnCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp b/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp index 92c8d7caa4..18f5e7dba2 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp @@ -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, jean-pierre.charras at wanadoo.fr - * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2016 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 @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -59,29 +60,40 @@ private: BOARD_DESIGN_SETTINGS m_brdSettings; MODULE* m_module; + wxFloatingPointValidator m_AngleValidator; + double m_AngleValue; + public: DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES( FOOTPRINT_EDIT_FRAME* aParent, EDGE_MODULE* aItem ); ~DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES() {}; private: - void initDlg(); - void OnOkClick( wxCommandEvent& event ); - void OnCancelClick( wxCommandEvent& event ){ event.Skip(); } + bool TransferDataToWindow(); + bool TransferDataFromWindow(); void OnLayerChoice( wxCommandEvent& event ); - bool itemValuesOK(); + bool Validate(); }; DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES( FOOTPRINT_EDIT_FRAME* aParent, EDGE_MODULE * aItem ): - DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( aParent ) + DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( aParent ), + m_AngleValidator( 1, &m_AngleValue ), + m_AngleValue( 0.0 ) { m_parent = aParent; m_item = aItem; m_brdSettings = m_parent->GetDesignSettings(); m_module = m_parent->GetBoard()->m_Modules; - initDlg(); + + m_AngleValidator.SetRange( -360.0, 360.0 ); + m_AngleCtrl->SetValidator( m_AngleValidator ); + m_AngleValidator.SetWindow( m_AngleCtrl ); + + SetFocus(); + m_StandardButtonsSizerOK->SetDefault(); + Layout(); GetSizer()->SetSizeHints( this ); Centre(); @@ -109,11 +121,8 @@ void FOOTPRINT_EDIT_FRAME::InstallFootprintBodyItemPropertiesDlg( EDGE_MODULE* a } -void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::initDlg() +bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataToWindow() { - SetFocus(); - m_StandardButtonsSizerOK->SetDefault(); - // Set unit symbol wxStaticText* texts_unit[] = { @@ -123,14 +132,10 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::initDlg() m_EndPointYUnit, m_ThicknessTextUnit, m_DefaulThicknessTextUnit, - NULL }; - for( int ii = 0; ; ii++ ) + for( int ii = 0; ii < DIM( texts_unit ); ii++ ) { - if( texts_unit[ii] == NULL ) - break; - texts_unit[ii]->SetLabel( GetAbbreviatedUnitsLabel() ); } @@ -145,8 +150,8 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::initDlg() m_StartPointYLabel->SetLabel( _( "Center Y" ) ); m_EndPointXLabel->SetLabel( _( "Point X" ) ); m_EndPointYLabel->SetLabel( _( "Point Y" ) ); - m_Angle_Text->Show( false ); - m_Angle_Ctrl->Show( false ); + m_AngleText->Show( false ); + m_AngleCtrl->Show( false ); m_AngleUnit->Show( false ); break; @@ -157,10 +162,7 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::initDlg() m_EndPointXLabel->SetLabel( _( "Start Point X" ) ); m_EndPointYLabel->SetLabel( _( "Start Point Y" ) ); - // Here the angle is a double, but the UI is still working - // with integers - msg << int( m_item->GetAngle() ); - m_Angle_Ctrl->SetValue( msg ); + m_AngleValue = m_item->GetAngle() / 10.0; break; case S_SEGMENT: @@ -168,8 +170,8 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::initDlg() // Fall through. default: - m_Angle_Text->Show( false ); - m_Angle_Ctrl->Show( false ); + m_AngleText->Show( false ); + m_AngleCtrl->Show( false ); m_AngleUnit->Show( false ); break; } @@ -198,24 +200,20 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::initDlg() "It has been moved to the front silk screen layer. Please fix it." ) ); m_LayerSelectionCtrl->SetLayerSelection( F_SilkS ); } + + return DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::TransferDataToWindow(); } -/*******************************************************************/ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::OnLayerChoice( wxCommandEvent& event ) -/*******************************************************************/ { } -/*******************************************************************/ -void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event ) -/*******************************************************************/ -/* Copy values in text control to the item parameters - */ +bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataFromWindow() { - if( !itemValuesOK() ) - return; + if( !DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::TransferDataFromWindow() ) + return false; LAYER_NUM layer = m_LayerSelectionCtrl->GetLayerSelection(); @@ -225,7 +223,7 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event ) * confirmation is requested */ if( !IsOK( NULL, _( "The graphic item will be on a copper layer. This is very dangerous. Are you sure?" ) ) ) - return; + return false;; } m_parent->SaveCopyInUndoList( m_module, UR_MODEDIT ); @@ -261,23 +259,23 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event ) if( m_item->GetShape() == S_ARC ) { - double angle; - m_Angle_Ctrl->GetValue().ToDouble( &angle ); - NORMALIZE_ANGLE_360( angle ); - m_item->SetAngle( angle ); + m_item->SetAngle( m_AngleValue * 10.0 ); } m_parent->OnModify(); m_parent->SetMsgPanel( m_item ); - Close( true ); + return true; } -bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::itemValuesOK() +bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::Validate() { wxArrayString error_msgs; + if( !DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::Validate() ) + return false; + // Load the start and end points -- all types use these in the checks. int startx = ValueFromString( g_UserUnit, m_Center_StartXCtrl->GetValue() ); int starty = ValueFromString( g_UserUnit, m_Center_StartYCtrl->GetValue() ); @@ -290,7 +288,7 @@ bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::itemValuesOK() case S_ARC: // Check angle of arc. double angle; - m_Angle_Ctrl->GetValue().ToDouble( &angle ); + m_AngleCtrl->GetValue().ToDouble( &angle ); NORMALIZE_ANGLE_360( angle ); if( angle == 0 )