void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event ) { LAYER_ID newlayer = ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ); if( !m_Parent->GetBoard()->IsLayerEnabled( newlayer ) ) { wxMessageBox( _( "The layer currently selected is not enabled for this board\n" "You cannot use it" ) ); return; } #ifndef USE_WX_OVERLAY if( m_DC ) // Delete old text. { CurrentDimension->Draw( m_Parent->GetCanvas(), m_DC, GR_XOR ); } #endif m_Parent->SaveCopyInUndoList(CurrentDimension, UR_CHANGED); if( m_Name->GetValue() != wxEmptyString ) { CurrentDimension->SetText( m_Name->GetValue() ); } wxString msg; // Get new size value: msg = m_TxtSizeXCtrl->GetValue(); CurrentDimension->Text().SetWidth( ValueFromString( g_UserUnit, msg ) ); msg = m_TxtSizeYCtrl->GetValue(); CurrentDimension->Text().SetHeight( ValueFromString( g_UserUnit, msg ) ); // Get new position value: // It will be copied later in dimension, because msg = m_textCtrlPosX->GetValue(); wxPoint pos; pos.x = ValueFromString( g_UserUnit, msg ); msg = m_textCtrlPosY->GetValue(); pos.y = ValueFromString( g_UserUnit, msg ); CurrentDimension->Text().SetTextPosition( pos ); // Get new line thickness value: msg = m_TxtWidthCtrl->GetValue(); int width = ValueFromString( g_UserUnit, msg ); int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->Text().GetSize() ); if( width > maxthickness ) { DisplayError( NULL, _( "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 { CurrentDimension->Draw( m_Parent->GetCanvas(), m_DC, GR_OR ); } #else m_Parent->Refresh(); #endif m_Parent->OnModify(); EndModal( 1 ); }
void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event ) { BOARD_COMMIT commit( m_parent ); PCB_LAYER_ID newlayer = ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ); if( !m_parent->GetBoard()->IsLayerEnabled( newlayer ) ) { wxMessageBox( _( "The layer currently selected is not enabled for this board\n" "You cannot use it" ) ); return; } #ifndef USE_WX_OVERLAY if( m_DC ) // Delete old text. { m_currentDimension->Draw( m_parent->GetCanvas(), m_DC, GR_XOR ); } #endif commit.Modify( m_currentDimension ); if( m_Name->GetValue() != wxEmptyString ) { m_currentDimension->SetText( m_Name->GetValue() ); } wxString msg; // Get new size value: msg = m_TxtSizeXCtrl->GetValue(); m_currentDimension->Text().SetTextWidth( ValueFromString( g_UserUnit, msg ) ); msg = m_TxtSizeYCtrl->GetValue(); m_currentDimension->Text().SetTextHeight( ValueFromString( g_UserUnit, msg ) ); // Get new position value: // It will be copied later in dimension, because msg = m_textCtrlPosX->GetValue(); wxPoint pos; pos.x = ValueFromString( g_UserUnit, msg ); msg = m_textCtrlPosY->GetValue(); pos.y = ValueFromString( g_UserUnit, msg ); m_currentDimension->Text().SetTextPos( pos ); // Get new line thickness value: msg = m_TxtWidthCtrl->GetValue(); int width = ValueFromString( g_UserUnit, msg ); int maxthickness = Clamp_Text_PenSize( width, m_currentDimension->Text().GetTextSize() ); if( width > maxthickness ) { DisplayError( NULL, _( "The text thickness is too large for the text size. " "It will be clamped" ) ); width = maxthickness; } m_currentDimension->SetWidth( width ); m_currentDimension->Text().SetThickness( width ); m_currentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false ); m_currentDimension->SetLayer( newlayer ); #ifndef USE_WX_OVERLAY if( m_DC ) // Display new text { m_currentDimension->Draw( m_parent->GetCanvas(), m_DC, GR_OR ); } #else m_parent->Refresh(); #endif commit.Push( _( "Modifed dimensions properties" ) ); event.Skip(); // ends returning wxID_OK (default behavior) }