void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) { bool retSuccess = false; m_save_flag = true; int idx = m_paperSizeComboBox->GetSelection(); if( idx < 0 ) idx = 0; const wxString paperType = m_pageFmt[idx]; if( paperType.Contains( PAGE_INFO::Custom ) ) { GetCustomSizeMilsFromDialog(); retSuccess = m_pageInfo.SetType( PAGE_INFO::Custom ); if( retSuccess ) { if( m_layout_size.x < MIN_PAGE_SIZE || m_layout_size.y < MIN_PAGE_SIZE || m_layout_size.x > MAX_PAGE_SIZE || m_layout_size.y > MAX_PAGE_SIZE ) { wxString msg = wxString::Format( _( "Selected custom paper size\nis out of the permissible \ limits\n%.1f - %.1f %s!\nSelect another custom paper size?" ), g_UserUnit == INCHES ? MIN_PAGE_SIZE / 1000. : MIN_PAGE_SIZE * 25.4 / 1000, g_UserUnit == INCHES ? MAX_PAGE_SIZE / 1000. : MAX_PAGE_SIZE * 25.4 / 1000, g_UserUnit == INCHES ? _( "inches" ) : _( "mm" ) ); if( wxMessageBox( msg, _( "Warning!" ), wxYES_NO | wxICON_EXCLAMATION, this ) == wxYES ) { m_save_flag = false; return; } m_layout_size.x = Clamp( MIN_PAGE_SIZE, m_layout_size.x, MAX_PAGE_SIZE ); m_layout_size.y = Clamp( MIN_PAGE_SIZE, m_layout_size.y, MAX_PAGE_SIZE ); } PAGE_INFO::SetCustomWidthMils( m_layout_size.x ); PAGE_INFO::SetCustomHeightMils( m_layout_size.y ); m_pageInfo.SetWidthMils( m_layout_size.x ); m_pageInfo.SetHeightMils( m_layout_size.y ); }
void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog() { int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 ); const wxString paperType = m_pageFmt[idx]; // here we assume translators will keep original paper size spellings if( paperType.Contains( PAGE_INFO::Custom ) ) { GetCustomSizeMilsFromDialog(); if( m_layout_size.x && m_layout_size.y ) { if( m_layout_size.x < m_layout_size.y ) m_orientationComboBox->SetStringSelection( _( "Portrait" ) ); else m_orientationComboBox->SetStringSelection( _( "Landscape" ) ); } } else { PAGE_INFO pageInfo; // SetType() later to lookup size static const wxChar* papers[] = { // longest common string first, since sequential search below PAGE_INFO::A4, PAGE_INFO::A3, PAGE_INFO::A2, PAGE_INFO::A1, PAGE_INFO::A0, PAGE_INFO::A, PAGE_INFO::B, PAGE_INFO::C, PAGE_INFO::D, PAGE_INFO::E, PAGE_INFO::USLetter, PAGE_INFO::USLegal, PAGE_INFO::USLedger, }; unsigned i; for( i=0; i < arrayDim( papers ); ++i ) { if( paperType.Contains( papers[i] ) ) { pageInfo.SetType( papers[i] ); break; } } wxASSERT( i != arrayDim(papers) ); // dialog UI match the above list? m_layout_size = pageInfo.GetSizeMils(); // swap sizes to match orientation bool isPortrait = (bool) m_orientationComboBox->GetSelection(); if( ( isPortrait && m_layout_size.x >= m_layout_size.y ) || ( !isPortrait && m_layout_size.x < m_layout_size.y ) ) { m_layout_size.Set( m_layout_size.y, m_layout_size.x ); } } }
bool DIALOG_PAGES_SETTINGS::SavePageSettings() { bool success = false; wxString fileName = GetWksFileName(); if( fileName != BASE_SCREEN::m_PageLayoutDescrFileName ) { wxString fullFileName = WORKSHEET_LAYOUT::MakeFullFileName( fileName, m_projectPath ); if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) ) { wxString msg; msg.Printf( _( "Page layout description file \"%s\" not found." ), GetChars( fullFileName ) ); wxMessageBox( msg ); return false; } BASE_SCREEN::m_PageLayoutDescrFileName = fileName; WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); pglayout.SetPageLayout( fullFileName ); m_localPrjConfigChanged = true; } int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 ); const wxString paperType = m_pageFmt[idx]; if( paperType.Contains( PAGE_INFO::Custom ) ) { GetCustomSizeMilsFromDialog(); success = m_pageInfo.SetType( PAGE_INFO::Custom ); if( success ) { PAGE_INFO::SetCustomWidthMils( m_layout_size.x ); PAGE_INFO::SetCustomHeightMils( m_layout_size.y ); m_pageInfo.SetWidthMils( m_layout_size.x ); m_pageInfo.SetHeightMils( m_layout_size.y ); } } else { // search for longest common string first, e.g. A4 before A if( paperType.Contains( PAGE_INFO::USLetter ) ) success = m_pageInfo.SetType( PAGE_INFO::USLetter ); else if( paperType.Contains( PAGE_INFO::USLegal ) ) success = m_pageInfo.SetType( PAGE_INFO::USLegal ); else if( paperType.Contains( PAGE_INFO::USLedger ) ) success = m_pageInfo.SetType( PAGE_INFO::USLedger ); else if( paperType.Contains( PAGE_INFO::GERBER ) ) success = m_pageInfo.SetType( PAGE_INFO::GERBER ); else if( paperType.Contains( PAGE_INFO::A4 ) ) success = m_pageInfo.SetType( PAGE_INFO::A4 ); else if( paperType.Contains( PAGE_INFO::A3 ) ) success = m_pageInfo.SetType( PAGE_INFO::A3 ); else if( paperType.Contains( PAGE_INFO::A2 ) ) success = m_pageInfo.SetType( PAGE_INFO::A2 ); else if( paperType.Contains( PAGE_INFO::A1 ) ) success = m_pageInfo.SetType( PAGE_INFO::A1 ); else if( paperType.Contains( PAGE_INFO::A0 ) ) success = m_pageInfo.SetType( PAGE_INFO::A0 ); else if( paperType.Contains( PAGE_INFO::A ) ) success = m_pageInfo.SetType( PAGE_INFO::A ); else if( paperType.Contains( PAGE_INFO::B ) ) success = m_pageInfo.SetType( PAGE_INFO::B ); else if( paperType.Contains( PAGE_INFO::C ) ) success = m_pageInfo.SetType( PAGE_INFO::C ); else if( paperType.Contains( PAGE_INFO::D ) ) success = m_pageInfo.SetType( PAGE_INFO::D ); else if( paperType.Contains( PAGE_INFO::E ) ) success = m_pageInfo.SetType( PAGE_INFO::E ); if( success ) { int choice = m_orientationComboBox->GetSelection(); m_pageInfo.SetPortrait( choice != 0 ); } } if( !success ) { wxASSERT_MSG( false, _( "the translation for paper size must preserve original spellings" ) ); m_pageInfo.SetType( PAGE_INFO::A4 ); } m_parent->SetPageSettings( m_pageInfo ); m_tb.SetRevision( m_TextRevision->GetValue() ); m_tb.SetDate( m_TextDate->GetValue() ); m_tb.SetCompany( m_TextCompany->GetValue() ); m_tb.SetTitle( m_TextTitle->GetValue() ); m_tb.SetComment1( m_TextComment1->GetValue() ); m_tb.SetComment2( m_TextComment2->GetValue() ); m_tb.SetComment3( m_TextComment3->GetValue() ); m_tb.SetComment4( m_TextComment4->GetValue() ); m_parent->SetTitleBlock( m_tb ); #ifdef EESCHEMA // Exports settings to other sheets if requested: SCH_SCREEN* screen; // Build the screen list SCH_SCREENS ScreenList; // Update title blocks for all screens for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) { if( screen == m_screen ) continue; TITLE_BLOCK tb2 = screen->GetTitleBlock(); if( m_RevisionExport->IsChecked() ) tb2.SetRevision( m_tb.GetRevision() ); if( m_DateExport->IsChecked() ) tb2.SetDate( m_tb.GetDate() ); if( m_TitleExport->IsChecked() ) tb2.SetTitle( m_tb.GetTitle() ); if( m_CompanyExport->IsChecked() ) tb2.SetCompany( m_tb.GetCompany() ); if( m_Comment1Export->IsChecked() ) tb2.SetComment1( m_tb.GetComment1() ); if( m_Comment2Export->IsChecked() ) tb2.SetComment2( m_tb.GetComment2() ); if( m_Comment3Export->IsChecked() ) tb2.SetComment3( m_tb.GetComment3() ); if( m_Comment4Export->IsChecked() ) tb2.SetComment4( m_tb.GetComment4() ); screen->SetTitleBlock( tb2 ); } #endif return true; }
bool DIALOG_PAGES_SETTINGS::SavePageSettings() { bool retSuccess = false; wxString fileName = GetWksFileName(); if( fileName != BASE_SCREEN::m_PageLayoutDescrFileName ) { if( !fileName.IsEmpty() ) { wxString fullFileName = WORKSHEET_LAYOUT::MakeFullFileName( fileName ); if( !wxFileExists( fullFileName ) ) { wxString msg; msg.Printf( _("Page layout description file <%s> not found. Abort"), GetChars( fullFileName ) ); wxMessageBox( msg ); return false; } } BASE_SCREEN::m_PageLayoutDescrFileName = fileName; WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); pglayout.SetPageLayout( fileName ); m_localPrjConfigChanged = true; } int idx = m_paperSizeComboBox->GetSelection(); if( idx < 0 ) idx = 0; const wxString paperType = m_pageFmt[idx]; if( paperType.Contains( PAGE_INFO::Custom ) ) { GetCustomSizeMilsFromDialog(); retSuccess = m_pageInfo.SetType( PAGE_INFO::Custom ); if( retSuccess ) { if( m_layout_size.x < MIN_PAGE_SIZE || m_layout_size.y < MIN_PAGE_SIZE || m_layout_size.x > MAX_PAGE_SIZE || m_layout_size.y > MAX_PAGE_SIZE ) { wxString msg = wxString::Format( _( "Selected custom paper size\nis out of the permissible \ limits\n%.1f - %.1f %s!\nSelect another custom paper size?" ), g_UserUnit == INCHES ? MIN_PAGE_SIZE / 1000. : MIN_PAGE_SIZE * 25.4 / 1000, g_UserUnit == INCHES ? MAX_PAGE_SIZE / 1000. : MAX_PAGE_SIZE * 25.4 / 1000, g_UserUnit == INCHES ? _( "inches" ) : _( "mm" ) ); if( wxMessageBox( msg, _( "Warning!" ), wxYES_NO | wxICON_EXCLAMATION, this ) == wxYES ) { return false; } m_layout_size.x = Clamp( MIN_PAGE_SIZE, m_layout_size.x, MAX_PAGE_SIZE ); m_layout_size.y = Clamp( MIN_PAGE_SIZE, m_layout_size.y, MAX_PAGE_SIZE ); } PAGE_INFO::SetCustomWidthMils( m_layout_size.x ); PAGE_INFO::SetCustomHeightMils( m_layout_size.y ); m_pageInfo.SetWidthMils( m_layout_size.x ); m_pageInfo.SetHeightMils( m_layout_size.y ); }