KiCad PCB EDA Suite
dialog_page_settings.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include <base_screen.h>
21 #include <confirm.h>
22 #include <core/arraydim.h>
24 #include <eda_draw_frame.h>
25 #include <eda_item.h>
26 #include <gr_basic.h>
27 #include <kiface_i.h>
28 #include <math/util.h> // for KiROUND, Clamp
29 #include <project.h>
30 #include <title_block.h>
31 #include <tool/actions.h>
32 #include <tool/tool_manager.h>
36 #include <wx/valgen.h>
37 #include <wx/tokenzr.h>
38 
39 #define MAX_PAGE_EXAMPLE_SIZE 200
40 
41 
42 // List of page formats.
43 // they are prefixed by "_HKI" (already in use for hotkeys) instead of "_",
44 // because we need both the translated and the not translated version.
45 // when displayed in dialog we should explicitly call wxGetTranslation()
46 // to show the translated version.
47 // See hotkeys_basic.h for more info
48 #define _HKI( x ) wxT( x )
49 static const wxString pageFmts[] =
50 {
51  _HKI("A5 148x210mm"),
52  _HKI("A4 210x297mm"),
53  _HKI("A3 297x420mm"),
54  _HKI("A2 420x594mm"),
55  _HKI("A1 594x841mm"),
56  _HKI("A0 841x1189mm"),
57  _HKI("A 8.5x11in"),
58  _HKI("B 11x17in"),
59  _HKI("C 17x22in"),
60  _HKI("D 22x34in"),
61  _HKI("E 34x44in"),
62  _HKI("USLetter 8.5x11in"), // USLetter without space is correct
63  _HKI("USLegal 8.5x14in"), // USLegal without space is correct
64  _HKI("USLedger 11x17in"), // USLedger without space is correct
65  _HKI("User (Custom)"), // size defined by user. The string must contain "Custom"
66  // to be recognized in code
67 };
68 
70  wxSize aMaxUserSizeMils ) :
71  DIALOG_PAGES_SETTINGS_BASE( aParent ),
72  m_parent( aParent ),
73  m_screen( m_parent->GetScreen() ),
74  m_initialized( false ),
75  m_pageBitmap( nullptr ),
76  m_iuPerMils( aIuPerMils ),
77  m_customSizeX( aParent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits, false ),
78  m_customSizeY( aParent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits, false )
79 {
81  m_maxPageSizeMils = aMaxUserSizeMils;
83  m_customFmt = false;
85 
87  wxString serialization;
89  m_drawingSheet->SetPageLayout(TO_UTF8( serialization ) );
90 
91  m_PickDate->SetValue( wxDateTime::Now() );
92 
93  if( m_parent->GetName() == PL_EDITOR_FRAME_NAME )
94  {
95  SetTitle( _( "Preview Settings" ) );
96  m_staticTextPaper->SetLabel( _( "Preview Paper" ) );
97  m_staticTextTitleBlock->SetLabel( _( "Preview Title Block Data" ) );
98  }
99  else
100  {
101  SetTitle( _( "Page Settings" ) );
102  m_staticTextPaper->SetLabel( _( "Paper" ) );
103  m_staticTextTitleBlock->SetLabel( _( "Title Block" ) );
104  }
105 
106  Centre();
107 }
108 
109 
111 {
112  delete m_pageBitmap;
113  delete m_drawingSheet;
114 }
115 
116 
118 {
119  wxString msg;
120 
121  // initialize page format choice box and page format list.
122  // The first shows translated strings, the second contains not translated strings
123  m_paperSizeComboBox->Clear();
124 
125  for( const wxString& pageFmt : pageFmts )
126  {
127  m_pageFmt.Add( pageFmt );
128  m_paperSizeComboBox->Append( wxGetTranslation( pageFmt ) );
129  }
130 
131  // initialize the page layout descr filename
133 
136  m_orientationComboBox->SetSelection( m_pageInfo.IsPortrait() );
137 
138  // only a click fires the "selection changed" event, so have to fabricate this check
139  wxCommandEvent dummy;
141 
142  if( m_customFmt )
143  {
146  }
147  else
148  {
151  }
152 
153  m_TextRevision->SetValue( m_tb.GetRevision() );
154  m_TextDate->SetValue( m_tb.GetDate() );
155  m_TextTitle->SetValue( m_tb.GetTitle() );
156  m_TextCompany->SetValue( m_tb.GetCompany() );
157  m_TextComment1->SetValue( m_tb.GetComment( 0 ) );
158  m_TextComment2->SetValue( m_tb.GetComment( 1 ) );
159  m_TextComment3->SetValue( m_tb.GetComment( 2 ) );
160  m_TextComment4->SetValue( m_tb.GetComment( 3 ) );
161  m_TextComment5->SetValue( m_tb.GetComment( 4 ) );
162  m_TextComment6->SetValue( m_tb.GetComment( 5 ) );
163  m_TextComment7->SetValue( m_tb.GetComment( 6 ) );
164  m_TextComment8->SetValue( m_tb.GetComment( 7 ) );
165  m_TextComment9->SetValue( m_tb.GetComment( 8 ) );
166 
167  // The default is to disable aall these fields for the "generic" dialog
168  m_TextSheetCount->Show( false );
169  m_TextSheetNumber->Show( false );
170  m_PaperExport->Show( false );
171  m_RevisionExport->Show( false );
172  m_DateExport->Show( false );
173  m_TitleExport->Show( false );
174  m_CompanyExport->Show( false );
175  m_Comment1Export->Show( false );
176  m_Comment2Export->Show( false );
177  m_Comment3Export->Show( false );
178  m_Comment4Export->Show( false );
179  m_Comment5Export->Show( false );
180  m_Comment6Export->Show( false );
181  m_Comment7Export->Show( false );
182  m_Comment8Export->Show( false );
183  m_Comment9Export->Show( false );
184 
186 
189 
190  GetSizer()->SetSizeHints( this );
191 
192  // Make the OK button the default.
193  m_sdbSizerOK->SetDefault();
194  m_initialized = true;
195 
196  return true;
197 }
198 
199 
201 {
203  return false;
204 
206  return false;
207 
208  if( SavePageSettings() )
209  {
210  m_screen->SetModify();
211 
212  if( LocalPrjConfigChanged() )
214 
215  // Call the post processing (if any) after changes
217  }
218 
219  return true;
220 }
221 
222 
223 void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
224 {
225  int idx = m_paperSizeComboBox->GetSelection();
226 
227  if( idx < 0 )
228  idx = 0;
229 
230  const wxString paperType = m_pageFmt[idx];
231 
232  if( paperType.Contains( PAGE_INFO::Custom ) )
233  {
234  m_orientationComboBox->Enable( false );
235  m_customSizeX.Enable( true );
236  m_customSizeY.Enable( true );
237  m_customFmt = true;
238  }
239  else
240  {
241  m_orientationComboBox->Enable( true );
242 
243 #if 0
244  // ForcePortrait() does not exist, but could be useful.
245  // so I leave these lines, which could be seen as a todo feature
246  if( paperType.ForcePortrait() )
247  {
248  m_orientationComboBox->SetStringSelection( _( "Portrait" ) );
249  m_orientationComboBox->Enable( false );
250  }
251 #endif
252  m_customSizeX.Enable( false );
253  m_customSizeY.Enable( false );
254  m_customFmt = false;
255  }
256 
259 }
260 
261 
263 {
264  if( m_initialized )
265  {
268  }
269 }
270 
271 
273 {
274  if( m_initialized )
275  {
278  }
279 }
280 
281 
283 {
284  if( m_initialized )
285  {
288  }
289 }
290 
291 
292 void DIALOG_PAGES_SETTINGS::OnRevisionTextUpdated( wxCommandEvent& event )
293 {
294  if( m_initialized && m_TextRevision->IsModified() )
295  {
297  m_tb.SetRevision( m_TextRevision->GetValue() );
299  }
300 }
301 
302 
303 void DIALOG_PAGES_SETTINGS::OnDateTextUpdated( wxCommandEvent& event )
304 {
305  if( m_initialized && m_TextDate->IsModified() )
306  {
308  m_tb.SetDate( m_TextDate->GetValue() );
310  }
311 }
312 
313 
314 void DIALOG_PAGES_SETTINGS::OnTitleTextUpdated( wxCommandEvent& event )
315 {
316  if( m_initialized && m_TextTitle->IsModified() )
317  {
319  m_tb.SetTitle( m_TextTitle->GetValue() );
321  }
322 }
323 
324 
325 void DIALOG_PAGES_SETTINGS::OnCompanyTextUpdated( wxCommandEvent& event )
326 {
327  if( m_initialized && m_TextCompany->IsModified() )
328  {
330  m_tb.SetCompany( m_TextCompany->GetValue() );
332  }
333 }
334 
335 
336 void DIALOG_PAGES_SETTINGS::OnComment1TextUpdated( wxCommandEvent& event )
337 {
338  if( m_initialized && m_TextComment1->IsModified() )
339  {
341  m_tb.SetComment( 0, m_TextComment1->GetValue() );
343  }
344 }
345 
346 
347 void DIALOG_PAGES_SETTINGS::OnComment2TextUpdated( wxCommandEvent& event )
348 {
349  if( m_initialized && m_TextComment2->IsModified() )
350  {
352  m_tb.SetComment( 1, m_TextComment2->GetValue() );
354  }
355 }
356 
357 
358 void DIALOG_PAGES_SETTINGS::OnComment3TextUpdated( wxCommandEvent& event )
359 {
360  if( m_initialized && m_TextComment3->IsModified() )
361  {
363  m_tb.SetComment( 2, m_TextComment3->GetValue() );
365  }
366 }
367 
368 
369 void DIALOG_PAGES_SETTINGS::OnComment4TextUpdated( wxCommandEvent& event )
370 {
371  if( m_initialized && m_TextComment4->IsModified() )
372  {
374  m_tb.SetComment( 3, m_TextComment4->GetValue() );
376  }
377 }
378 
379 
380 void DIALOG_PAGES_SETTINGS::OnComment5TextUpdated( wxCommandEvent& event )
381 {
382  if( m_initialized && m_TextComment5->IsModified() )
383  {
385  m_tb.SetComment( 4, m_TextComment5->GetValue() );
387  }
388 }
389 
390 
391 void DIALOG_PAGES_SETTINGS::OnComment6TextUpdated( wxCommandEvent& event )
392 {
393  if( m_initialized && m_TextComment6->IsModified() )
394  {
396  m_tb.SetComment( 5, m_TextComment6->GetValue() );
398  }
399 }
400 
401 
402 void DIALOG_PAGES_SETTINGS::OnComment7TextUpdated( wxCommandEvent& event )
403 {
404  if( m_initialized && m_TextComment7->IsModified() )
405  {
407  m_tb.SetComment( 6, m_TextComment7->GetValue() );
409  }
410 }
411 
412 
413 void DIALOG_PAGES_SETTINGS::OnComment8TextUpdated( wxCommandEvent& event )
414 {
415  if( m_initialized && m_TextComment8->IsModified() )
416  {
418  m_tb.SetComment( 7, m_TextComment8->GetValue() );
420  }
421 }
422 
423 
424 void DIALOG_PAGES_SETTINGS::OnComment9TextUpdated( wxCommandEvent& event )
425 {
426  if( m_initialized && m_TextComment9->IsModified() )
427  {
429  m_tb.SetComment( 8, m_TextComment9->GetValue() );
431  }
432 }
433 
434 
435 void DIALOG_PAGES_SETTINGS::OnDateApplyClick( wxCommandEvent& event )
436 {
437  wxDateTime datetime = m_PickDate->GetValue();
438  wxString date =
439  // We can choose different formats. Only one must be uncommented
440  //
441  // datetime.Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
442  // datetime.Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
443  // datetime.Format( wxT("%Y-%b-%d") );
444  datetime.FormatISODate();
445 
446  m_TextDate->SetValue( date );
447 }
448 
449 
451 {
452  bool success = false;
453 
454  wxString fileName = GetWksFileName();
455 
457  {
458  wxString fullFileName = DS_DATA_MODEL::MakeFullFileName( fileName, m_projectPath );
459 
460  if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) )
461  {
462  wxString msg;
463  msg.Printf( _( "Page layout description file \"%s\" not found." ), fullFileName );
464  wxMessageBox( msg );
465  return false;
466  }
467 
471  }
472 
473  int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
474  const wxString paperType = m_pageFmt[idx];
475 
476  if( paperType.Contains( PAGE_INFO::Custom ) )
477  {
479 
480  success = m_pageInfo.SetType( PAGE_INFO::Custom );
481 
482  if( success )
483  {
486 
489  }
490  }
491  else
492  {
493  // search for longest common string first, e.g. A4 before A
494  if( paperType.Contains( PAGE_INFO::USLetter ) )
496  else if( paperType.Contains( PAGE_INFO::USLegal ) )
498  else if( paperType.Contains( PAGE_INFO::USLedger ) )
500  else if( paperType.Contains( PAGE_INFO::GERBER ) )
501  success = m_pageInfo.SetType( PAGE_INFO::GERBER );
502  else if( paperType.Contains( PAGE_INFO::A5 ) )
503  success = m_pageInfo.SetType( PAGE_INFO::A5 );
504  else if( paperType.Contains( PAGE_INFO::A4 ) )
505  success = m_pageInfo.SetType( PAGE_INFO::A4 );
506  else if( paperType.Contains( PAGE_INFO::A3 ) )
507  success = m_pageInfo.SetType( PAGE_INFO::A3 );
508  else if( paperType.Contains( PAGE_INFO::A2 ) )
509  success = m_pageInfo.SetType( PAGE_INFO::A2 );
510  else if( paperType.Contains( PAGE_INFO::A1 ) )
511  success = m_pageInfo.SetType( PAGE_INFO::A1 );
512  else if( paperType.Contains( PAGE_INFO::A0 ) )
513  success = m_pageInfo.SetType( PAGE_INFO::A0 );
514  else if( paperType.Contains( PAGE_INFO::A ) )
515  success = m_pageInfo.SetType( PAGE_INFO::A );
516  else if( paperType.Contains( PAGE_INFO::B ) )
517  success = m_pageInfo.SetType( PAGE_INFO::B );
518  else if( paperType.Contains( PAGE_INFO::C ) )
519  success = m_pageInfo.SetType( PAGE_INFO::C );
520  else if( paperType.Contains( PAGE_INFO::D ) )
521  success = m_pageInfo.SetType( PAGE_INFO::D );
522  else if( paperType.Contains( PAGE_INFO::E ) )
523  success = m_pageInfo.SetType( PAGE_INFO::E );
524 
525  if( success )
526  {
527  int choice = m_orientationComboBox->GetSelection();
528  m_pageInfo.SetPortrait( choice != 0 );
529  }
530  }
531 
532  if( !success )
533  {
534  wxASSERT_MSG( false, _( "the translation for paper size must preserve original spellings" ) );
536  }
537 
539 
540  m_tb.SetRevision( m_TextRevision->GetValue() );
541  m_tb.SetDate( m_TextDate->GetValue() );
542  m_tb.SetCompany( m_TextCompany->GetValue() );
543  m_tb.SetTitle( m_TextTitle->GetValue() );
544  m_tb.SetComment( 0, m_TextComment1->GetValue() );
545  m_tb.SetComment( 1, m_TextComment2->GetValue() );
546  m_tb.SetComment( 2, m_TextComment3->GetValue() );
547  m_tb.SetComment( 3, m_TextComment4->GetValue() );
548  m_tb.SetComment( 4, m_TextComment5->GetValue() );
549  m_tb.SetComment( 5, m_TextComment6->GetValue() );
550  m_tb.SetComment( 6, m_TextComment7->GetValue() );
551  m_tb.SetComment( 7, m_TextComment8->GetValue() );
552  m_tb.SetComment( 8, m_TextComment9->GetValue() );
553 
555 
556  return onSavePageSettings();
557 }
558 
559 
560 void DIALOG_PAGES_SETTINGS::SetCurrentPageSizeSelection( const wxString& aPaperSize )
561 {
562  // search all the not translated label list containing our paper type
563  for( unsigned i = 0; i < m_pageFmt.GetCount(); ++i )
564  {
565  // parse each label looking for aPaperSize within it
566  wxStringTokenizer st( m_pageFmt[i] );
567 
568  while( st.HasMoreTokens() )
569  {
570  if( st.GetNextToken() == aPaperSize )
571  {
572  m_paperSizeComboBox->SetSelection( i );
573  return;
574  }
575  }
576  }
577 }
578 
579 
581 {
582  int lyWidth, lyHeight;
583 
584  wxSize clamped_layout_size( Clamp( MIN_PAGE_SIZE_MILS, m_layout_size.x, m_maxPageSizeMils.x ),
586 
587  double lyRatio = clamped_layout_size.x < clamped_layout_size.y ?
588  (double) clamped_layout_size.y / clamped_layout_size.x :
589  (double) clamped_layout_size.x / clamped_layout_size.y;
590 
591  if( clamped_layout_size.x < clamped_layout_size.y )
592  {
593  lyHeight = MAX_PAGE_EXAMPLE_SIZE;
594  lyWidth = KiROUND( (double) lyHeight / lyRatio );
595  }
596  else
597  {
598  lyWidth = MAX_PAGE_EXAMPLE_SIZE;
599  lyHeight = KiROUND( (double) lyWidth / lyRatio );
600  }
601 
602  if( m_pageBitmap )
603  {
604  m_PageLayoutExampleBitmap->SetBitmap( wxNullBitmap );
605  delete m_pageBitmap;
606  }
607 
608  m_pageBitmap = new wxBitmap( lyWidth + 1, lyHeight + 1 );
609 
610  if( m_pageBitmap->IsOk() )
611  {
612  double scaleW = (double) lyWidth / clamped_layout_size.x;
613  double scaleH = (double) lyHeight / clamped_layout_size.y;
614  double scale = std::min( scaleW, scaleH );
615 
616  // Prepare DC.
617  wxSize example_size( lyWidth + 1, lyHeight + 1 );
618  wxMemoryDC memDC;
619  memDC.SelectObject( *m_pageBitmap );
620  memDC.SetClippingRegion( wxPoint( 0, 0 ), example_size );
621  memDC.Clear();
622  memDC.SetUserScale( scale, scale );
623 
624  // Get logical page size and margins.
625  PAGE_INFO pageDUMMY;
626 
627  // Get page type
628  int idx = m_paperSizeComboBox->GetSelection();
629 
630  if( idx < 0 )
631  idx = 0;
632 
633  wxString pageFmtName = m_pageFmt[idx].BeforeFirst( ' ' );
634  bool portrait = clamped_layout_size.x < clamped_layout_size.y;
635  pageDUMMY.SetType( pageFmtName, portrait );
636  if( m_customFmt )
637  {
638  pageDUMMY.SetWidthMils( clamped_layout_size.x );
639  pageDUMMY.SetHeightMils( clamped_layout_size.y );
640  }
641 
642  // Draw layout preview.
643  KIGFX::DS_RENDER_SETTINGS renderSettings;
644  COLOR_SETTINGS* colorSettings = m_parent->GetColorSettings();
645  COLOR4D bgColor = m_parent->GetDrawBgColor();
646  wxString emptyString;
647 
649  {
650  GRResetPenAndBrush( &memDC );
651  renderSettings.SetDefaultPenWidth( 1 );
652  renderSettings.LoadColors( colorSettings );
653  renderSettings.SetPrintDC( &memDC );
654 
655  if( m_parent->IsType( FRAME_SCH )
659  {
660  COLOR4D worksheetColor = renderSettings.GetLayerColor( LAYER_SCHEMATIC_DRAWINGSHEET );
661  renderSettings.SetLayerColor( LAYER_DRAWINGSHEET, worksheetColor );
662  }
663 
664  GRFilledRect( NULL, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, bgColor, bgColor );
665 
666  PrintDrawingSheet( &renderSettings, pageDUMMY, emptyString, emptyString, m_tb,
668  wxEmptyString, m_screen->GetVirtualPageNumber() == 1 );
669 
670  memDC.SelectObject( wxNullBitmap );
672  }
674 
675  // Refresh the dialog.
676  Layout();
677  Refresh();
678  }
679 }
680 
681 
683 {
684  int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
685  const wxString paperType = m_pageFmt[idx];
686 
687  // here we assume translators will keep original paper size spellings
688  if( paperType.Contains( PAGE_INFO::Custom ) )
689  {
691 
692  if( m_layout_size.x && m_layout_size.y )
693  {
694  if( m_layout_size.x < m_layout_size.y )
695  m_orientationComboBox->SetStringSelection( _( "Portrait" ) );
696  else
697  m_orientationComboBox->SetStringSelection( _( "Landscape" ) );
698  }
699  }
700  else
701  {
702  PAGE_INFO pageInfo; // SetType() later to lookup size
703 
704  static const wxChar* papers[] = {
705  // longest common string first, since sequential search below
712  PAGE_INFO::A,
713  PAGE_INFO::B,
714  PAGE_INFO::C,
715  PAGE_INFO::D,
716  PAGE_INFO::E,
720  };
721 
722  unsigned i;
723 
724  for( i=0; i < arrayDim( papers ); ++i )
725  {
726  if( paperType.Contains( papers[i] ) )
727  {
728  pageInfo.SetType( papers[i] );
729  break;
730  }
731  }
732 
733  wxASSERT( i != arrayDim(papers) ); // dialog UI match the above list?
734 
735  m_layout_size = pageInfo.GetSizeMils();
736 
737  // swap sizes to match orientation
738  bool isPortrait = (bool) m_orientationComboBox->GetSelection();
739 
740  if( ( isPortrait && m_layout_size.x >= m_layout_size.y ) ||
741  ( !isPortrait && m_layout_size.x < m_layout_size.y ) )
742  {
744  }
745  }
746 }
747 
748 
750 {
751  double customSizeX = (double) m_customSizeX.GetValue() / m_iuPerMils;
752  double customSizeY = (double) m_customSizeY.GetValue() / m_iuPerMils;
753 
754  // Prepare to painless double -> int conversion.
755  customSizeX = Clamp( double( INT_MIN ), customSizeX, double( INT_MAX ) );
756  customSizeY = Clamp( double( INT_MIN ), customSizeY, double( INT_MAX ) );
757  m_layout_size = wxSize( KiROUND( customSizeX ), KiROUND( customSizeY ) );
758 }
759 
760 
761 void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
762 {
763  wxFileName fn = GetWksFileName();
764  wxString name = GetWksFileName();
765  wxString path;
766 
767  if( fn.IsAbsolute() )
768  {
769  path = fn.GetPath();
770  name = fn.GetFullName();
771  }
772  else
773  {
774  path = m_projectPath;
775  }
776 
777  // Display a file picker dialog
778  wxFileDialog fileDialog( this, _( "Select Page Layout Description File" ),
780  wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
781 
782  if( fileDialog.ShowModal() != wxID_OK )
783  return;
784 
785  wxString fileName = fileDialog.GetPath();
786 
787  // Try to remove the path, if the path is the current working dir,
788  // or the dir of kicad.pro (template), and use a relative path
789  wxString shortFileName = DS_DATA_MODEL::MakeShortFileName( fileName, m_projectPath );
790 
791  // For Win/Linux/macOS compatibility, a relative path is a good idea
792  if( shortFileName != GetWksFileName() && shortFileName != fileName )
793  {
794  wxString msg = wxString::Format( _( "The page layout description file name has changed.\n"
795  "Do you want to use the relative path:\n"
796  "\"%s\"\n"
797  "instead of\n"
798  "\"%s\"?" ),
799  shortFileName,
800  fileName );
801 
802  if( !IsOK( this, msg ) )
803  shortFileName = fileName;
804  }
805 
806  SetWksFileName( shortFileName );
807 
808  if( m_drawingSheet == NULL )
810 
811  m_drawingSheet->LoadDrawingSheet( fileName );
812 
815 }
void OnDateApplyClick(wxCommandEvent &event) override
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)=0
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:118
virtual void onTransferDataToWindow()
static const wxChar A[]
Definition: page_info.h:68
wxString PageLayoutDescrFileWildcard()
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
void OnComment5TextUpdated(wxCommandEvent &event) override
wxSize m_maxPageSizeMils
Logical page layout size.
void LoadDrawingSheet(const wxString &aFullFileName=wxEmptyString, bool Append=false)
Populates the list with a custom layout or the default layout if no custom layout is available.
virtual const TITLE_BLOCK & GetTitleBlock() const =0
static int GetCustomHeightMils()
Definition: page_info.h:165
static void SetAltInstance(DS_DATA_MODEL *aLayout=NULL)
Set an alternate instance of DS_DATA_MODEL.
void OnPageOrientationChoice(wxCommandEvent &event) override
This file is part of the common library.
virtual void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)=0
void SetRevision(const wxString &aRevision)
Definition: title_block.h:81
const wxString & GetComment(int aIdx) const
Definition: title_block.h:107
int GetHeightMils() const
Definition: page_info.h:133
static const wxChar E[]
Definition: page_info.h:72
void OnComment3TextUpdated(wxCommandEvent &event) override
static const wxChar GERBER[]
Definition: page_info.h:73
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:882
TITLE_BLOCK m_tb
true if the page selection is custom
static const wxChar A3[]
Definition: page_info.h:64
void OnComment7TextUpdated(wxCommandEvent &event) override
int GetVirtualPageNumber() const
Definition: base_screen.h:79
void SetWksFileName(const wxString &aFilename)
static void SetCustomWidthMils(int aWidthInMils)
Set the width of Custom page in mils for any custom page constructed or made via SetType() after maki...
Definition: page_info.cpp:231
virtual bool TransferDataFromWindow() override
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
Definition: page_info.cpp:119
virtual void SaveProjectSettings()
Save changes to the project settings to the project (.pro) file.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
int GetPageCount() const
Definition: base_screen.h:76
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
void SetDate(const wxString &aDate)
Set the date field, and defaults to the current time and date.
Definition: title_block.h:71
virtual bool TransferDataToWindow() override
static const char * emptyString
#define PL_EDITOR_FRAME_NAME
void OnUserPageSizeXTextUpdated(wxCommandEvent &event) override
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:77
const wxString & GetType() const
Definition: page_info.h:94
#define MAX_PAGE_EXAMPLE_SIZE
static const wxChar D[]
Definition: page_info.h:71
const wxString GetWksFileName()
bool m_initialized
list of page sizes (not translated)
The base class for create windows for drawing purpose.
#define MIN_PAGE_SIZE_MILS
Min and max page sizes for clamping, in mils.
Definition: page_info.h:39
wxSize m_layout_size
Temporary bitmap for the page layout example.
virtual const wxString GetProjectPath() const
Return the full path of the project.
DIALOG_PAGES_SETTINGS(EDA_DRAW_FRAME *aParent, double aIuPerMils, wxSize aMaxUserSizeMils)
const wxString & GetPageNumber() const
Definition: base_screen.cpp:78
Store page-layout-specific render settings.
Definition: ds_painter.h:46
DS_DATA_MODEL * m_drawingSheet
Temporary title block (basic inscriptions).
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:89
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
virtual const PAGE_INFO & GetPageSettings() const =0
void OnComment8TextUpdated(wxCommandEvent &event) override
void OnComment1TextUpdated(wxCommandEvent &event) override
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
static const wxChar USLegal[]
Definition: page_info.h:75
virtual bool onSavePageSettings()
void OnComment9TextUpdated(wxCommandEvent &event) override
static const wxChar B[]
Definition: page_info.h:69
void SetComment(int aIdx, const wxString &aComment)
Definition: title_block.h:101
#define NULL
static const wxChar C[]
Definition: page_info.h:70
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
const wxString & GetRevision() const
Definition: title_block.h:86
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
const wxString & GetCompany() const
Definition: title_block.h:96
static const wxString MakeShortFileName(const wxString &aFullFileName, const wxString &aProjectPath)
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, const PAGE_INFO &aPageInfo, const wxString &aFullSheetName, const wxString &aFileName, const TITLE_BLOCK &aTitleBlock, int aSheetCount, const wxString &aPageNumber, double aMils2Iu, const PROJECT *aProject, const wxString &aSheetLayer, bool aIsFirstPage)
Print the border and title block.
void SetCompany(const wxString &aCompany)
Definition: title_block.h:91
Definition of file extensions used in Kicad.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
static const wxChar A4[]
Definition: page_info.h:63
const wxSize & GetSizeMils() const
Definition: page_info.h:135
void OnDateTextUpdated(wxCommandEvent &event) override
void SetCurrentPageSizeSelection(const wxString &aPaperSize)
void SetTitle(const wxString &aTitle)
Definition: title_block.h:58
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:257
void SaveInString(wxString &aOutputString)
Save the description in a buffer.
wxBitmap * m_pageBitmap
the page layuout filename was changed
static const wxChar USLedger[]
Definition: page_info.h:76
void OnWksFileSelection(wxCommandEvent &event) override
Class DIALOG_PAGES_SETTINGS_BASE.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static const wxChar A1[]
Definition: page_info.h:66
const wxString & GetDate() const
Definition: title_block.h:76
void OnComment6TextUpdated(wxCommandEvent &event) override
void SetPageLayout(const char *aPageLayout, bool aAppend=false, const wxString &aSource=wxT("Sexpr_string"))
Populate the list from a S expr description stored in a string.
static const wxChar USLetter[]
Definition: page_info.h:74
virtual void OnPageSettingsChange()
Called when modifying the page settings.
PAGE_INFO m_pageInfo
The max page size allowed by the caller frame.
const int scale
virtual bool Validate(double aMin, double aMax, EDA_UNITS aUnits=EDA_UNITS::UNSCALED)
Validate the control against the given range, informing the user of any errors found.
void OnComment4TextUpdated(wxCommandEvent &event) override
void OnUserPageSizeYTextUpdated(wxCommandEvent &event) override
bool IsType(FRAME_T aType) const
const char * name
Definition: DXF_plotter.cpp:59
bool IsPortrait() const
Definition: page_info.h:117
#define _(s)
Definition: 3d_actions.cpp:33
static const wxString pageFmts[]
virtual void SetValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
static const wxString MakeFullFileName(const wxString &aShortFileName, const wxString &aProjectPath)
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:243
static const wxChar A5[]
Definition: page_info.h:62
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
const T & Clamp(const T &lower, const T &value, const T &upper)
Function Clamp limits value within the range lower <= value <= upper.
Definition: util.h:46
static int GetCustomWidthMils()
Definition: page_info.h:160
virtual long long int GetValue()
Return the current value in Internal Units.
bool m_customFmt
Temporary page info.
Color settings are a bit different than most of the settings objects in that there can be more than o...
static const wxChar A2[]
Definition: page_info.h:65
const wxString & GetTitle() const
Definition: title_block.h:63
virtual COLOR4D GetDrawBgColor() const
void OnComment2TextUpdated(wxCommandEvent &event) override
void OnPaperSizeChoice(wxCommandEvent &event) override
drawingsheet frame and titleblock
virtual COLOR_SETTINGS * GetColorSettings() const
Returns a pointer to the active color theme settings.
void OnTitleTextUpdated(wxCommandEvent &event) override
void OnCompanyTextUpdated(wxCommandEvent &event) override
void SetModify()
Definition: base_screen.h:59
void OnRevisionTextUpdated(wxCommandEvent &event) override
void SetDefaultPenWidth(int aWidth)
BASE_SCREEN class implementation.
#define _HKI(x)
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
Definition: page_info.cpp:186
void LoadColors(const COLOR_SETTINGS *aSettings) override
Definition: ds_painter.cpp:56
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:297
void SetPrintDC(wxDC *aDC)
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
static void SetCustomHeightMils(int aHeightInMils)
Set the height of Custom page in mils for any custom page constructed or made via SetType() after mak...
Definition: page_info.cpp:237
int GetWidthMils() const
Definition: page_info.h:130
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
static const wxChar A0[]
Definition: page_info.h:67