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) 1992-2018 Kicad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
28 #include <fctsys.h>
29 #include <macros.h> // arrayDim()
30 #include <common.h>
31 #include <project.h>
32 #include <confirm.h>
33 #include <gr_basic.h>
34 #include <base_struct.h>
35 #include <class_drawpanel.h>
36 #include <title_block.h>
37 #include <draw_frame.h>
39 #include <base_screen.h>
41 
42 #include <wx/valgen.h>
43 #include <wx/tokenzr.h>
44 
45 #ifdef EESCHEMA
46 #include <sch_screen.h>
47 #include <general.h>
48 #endif
49 
50 #include <worksheet.h>
51 #include <dialog_page_settings.h>
52 
53 #define MAX_PAGE_EXAMPLE_SIZE 200
54 
55 
56 // List of page formats.
57 // they are prefixed by "_HKI" (already in use for hotkeys) instead of "_",
58 // because we need both the translated and the not translated version.
59 // when displayed in dialog we should explicitly call wxGetTranslation()
60 // to show the translated version.
61 // See hotkeys_basic.h for more info
62 #define _HKI( x ) wxT( x )
63 static const wxString pageFmts[] =
64 {
65  _HKI("A4 210x297mm"),
66  _HKI("A3 297x420mm"),
67  _HKI("A2 420x594mm"),
68  _HKI("A1 594x841mm"),
69  _HKI("A0 841x1189mm"),
70  _HKI("A 8.5x11in"),
71  _HKI("B 11x17in"),
72  _HKI("C 17x22in"),
73  _HKI("D 22x34in"),
74  _HKI("E 34x44in"),
75  _HKI("USLetter 8.5x11in"), // USLetter without space is correct
76  _HKI("USLegal 8.5x14in"), // USLegal without space is correct
77  _HKI("USLedger 11x17in"), // USLedger without space is correct
78  _HKI("User (Custom)"), // size defined by user. The string must contain "Custom"
79  // to be recognized in code
80 };
81 
82 void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event )
83 {
84  FRAME_T smallSizeFrames[] =
85  {
90  };
91 
92  // Fix the max page size: it is MAX_PAGE_SIZE_EDITORS
93  // or MAX_PAGE_SIZE_PCBNEW for Pcbnew draw frames, due to the small internal
94  // units that do not allow too large draw areas
96 
97  for( unsigned ii = 0; ii < arrayDim( smallSizeFrames ); ii++ )
98  {
99  if( IsType( smallSizeFrames[ii] ) )
100  {
101  maxPageSize.x = maxPageSize.y = MAX_PAGE_SIZE_PCBNEW_MILS;
102  break;
103  }
104  }
105 
106  DIALOG_PAGES_SETTINGS dlg( this, maxPageSize );
108 
109  if( dlg.ShowModal() == wxID_OK )
110  {
111 #ifdef EESCHEMA
112  RedrawScreen( wxPoint( 0, 0 ), false );
113 #else
114  GetCanvas()->Refresh();
115 #endif
116  }
117 }
118 
119 
121  DIALOG_PAGES_SETTINGS_BASE( parent ),
122  m_initialized( false ),
123  m_customSizeX( parent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits, false ),
124  m_customSizeY( parent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits, false )
125 {
126  m_parent = parent;
129  m_page_bitmap = NULL;
130  m_maxPageSizeMils = aMaxUserSizeMils;
132  m_customFmt = false;
133  m_localPrjConfigChanged = false;
134  m_pagelayout = NULL;
135 
136  m_PickDate->SetValue( wxDateTime::Now() );
137 
138  initDialog();
139 
140  GetSizer()->SetSizeHints( this );
141  Centre();
142 }
143 
144 
146 {
147  delete m_page_bitmap;
148  delete m_pagelayout;
149 }
150 
151 
153 {
154  wxString msg;
155 
156  // initialize page format choice box and page format list.
157  // The first shows translated strings, the second contains not translated strings
158  m_paperSizeComboBox->Clear();
159 
160  for( unsigned ii = 0; ii < arrayDim(pageFmts); ii++ )
161  {
162  m_pageFmt.Add( pageFmts[ii] );
163  m_paperSizeComboBox->Append( wxGetTranslation( pageFmts[ii] ) );
164  }
165 
166  // initialize the page layout descr filename
168 
169 #ifdef EESCHEMA
170  // Init display value for schematic sub-sheet number
171  wxString format = m_TextSheetCount->GetLabel();
172  msg.Printf( format, m_screen->m_NumberOfScreens );
173  m_TextSheetCount->SetLabel( msg );
174 
175  format = m_TextSheetNumber->GetLabel();
176  msg.Printf( format, m_screen->m_ScreenNumber );
177  m_TextSheetNumber->SetLabel( msg );
178 #else
179  m_TextSheetCount->Show( false );
180  m_TextSheetNumber->Show( false );
181 #endif
182 
185  m_orientationComboBox->SetSelection( m_pageInfo.IsPortrait() );
186 
187  // only a click fires the "selection changed" event, so have to fabricate this check
188  wxCommandEvent dummy;
189  OnPaperSizeChoice( dummy );
190 
191  if( m_customFmt )
192  {
195  }
196  else
197  {
200  }
201 
202  m_TextRevision->SetValue( m_tb.GetRevision() );
203  m_TextDate->SetValue( m_tb.GetDate() );
204  m_TextTitle->SetValue( m_tb.GetTitle() );
205  m_TextCompany->SetValue( m_tb.GetCompany() );
206  m_TextComment1->SetValue( m_tb.GetComment1() );
207  m_TextComment2->SetValue( m_tb.GetComment2() );
208  m_TextComment3->SetValue( m_tb.GetComment3() );
209  m_TextComment4->SetValue( m_tb.GetComment4() );
210 
211 #ifndef EESCHEMA
212  // these options have meaning only for Eeschema.
213  // disable them for other apps
214  m_RevisionExport->Show( false );
215  m_DateExport->Show( false );
216  m_TitleExport->Show( false );
217  m_CompanyExport->Show( false );
218  m_Comment1Export->Show( false );
219  m_Comment2Export->Show( false );
220  m_Comment3Export->Show( false );
221  m_Comment4Export->Show( false );
222 #endif
223 
226 
227  // Make the OK button the default.
228  m_sdbSizerOK->SetDefault();
229  m_initialized = true;
230 }
231 
232 
233 void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event )
234 {
235  if( !m_customSizeX.Validate( Mils2iu( MIN_PAGE_SIZE ), Mils2iu( m_maxPageSizeMils.x ) ) )
236  return;
237 
238  if( !m_customSizeY.Validate( Mils2iu( MIN_PAGE_SIZE ), Mils2iu( m_maxPageSizeMils.y ) ) )
239  return;
240 
241  if( SavePageSettings() )
242  {
243  m_screen->SetModify();
244 
245  if( LocalPrjConfigChanged() )
246  m_parent->SaveProjectSettings( false );
247 
248  // Call the post processing (if any) after changes
250  }
251 
252  event.Skip();
253 }
254 
255 
256 void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
257 {
258  int idx = m_paperSizeComboBox->GetSelection();
259 
260  if( idx < 0 )
261  idx = 0;
262 
263  const wxString paperType = m_pageFmt[idx];
264 
265  if( paperType.Contains( PAGE_INFO::Custom ) )
266  {
267  m_orientationComboBox->Enable( false );
268  m_customSizeX.Enable( true );
269  m_customSizeY.Enable( true );
270  m_customFmt = true;
271  }
272  else
273  {
274  m_orientationComboBox->Enable( true );
275 
276 #if 0
277  // ForcePortrait() does not exist, but could be useful.
278  // so I leave these lines, which could be seen as a todo feature
279  if( paperType.ForcePortrait() )
280  {
281  m_orientationComboBox->SetStringSelection( _( "Portrait" ) );
282  m_orientationComboBox->Enable( false );
283  }
284 #endif
285  m_customSizeX.Enable( false );
286  m_customSizeY.Enable( false );
287  m_customFmt = false;
288  }
289 
292 }
293 
294 
296 {
297  if( m_initialized )
298  {
301  }
302 }
303 
304 
306 {
307  if( m_initialized )
308  {
311  }
312 }
313 
314 
316 {
317  if( m_initialized )
318  {
321  }
322 }
323 
324 
325 void DIALOG_PAGES_SETTINGS::OnRevisionTextUpdated( wxCommandEvent& event )
326 {
327  if( m_initialized && m_TextRevision->IsModified() )
328  {
330  m_tb.SetRevision( m_TextRevision->GetValue() );
332  }
333 }
334 
335 
336 void DIALOG_PAGES_SETTINGS::OnDateTextUpdated( wxCommandEvent& event )
337 {
338  if( m_initialized && m_TextDate->IsModified() )
339  {
341  m_tb.SetDate( m_TextDate->GetValue() );
343  }
344 }
345 
346 
347 void DIALOG_PAGES_SETTINGS::OnTitleTextUpdated( wxCommandEvent& event )
348 {
349  if( m_initialized && m_TextTitle->IsModified() )
350  {
352  m_tb.SetTitle( m_TextTitle->GetValue() );
354  }
355 }
356 
357 
358 void DIALOG_PAGES_SETTINGS::OnCompanyTextUpdated( wxCommandEvent& event )
359 {
360  if( m_initialized && m_TextCompany->IsModified() )
361  {
363  m_tb.SetCompany( m_TextCompany->GetValue() );
365  }
366 }
367 
368 
369 void DIALOG_PAGES_SETTINGS::OnComment1TextUpdated( wxCommandEvent& event )
370 {
371  if( m_initialized && m_TextComment1->IsModified() )
372  {
374  m_tb.SetComment1( m_TextComment1->GetValue() );
376  }
377 }
378 
379 
380 void DIALOG_PAGES_SETTINGS::OnComment2TextUpdated( wxCommandEvent& event )
381 {
382  if( m_initialized && m_TextComment2->IsModified() )
383  {
385  m_tb.SetComment2( m_TextComment2->GetValue() );
387  }
388 }
389 
390 
391 void DIALOG_PAGES_SETTINGS::OnComment3TextUpdated( wxCommandEvent& event )
392 {
393  if( m_initialized && m_TextComment3->IsModified() )
394  {
396  m_tb.SetComment3( m_TextComment3->GetValue() );
398  }
399 }
400 
401 
402 void DIALOG_PAGES_SETTINGS::OnComment4TextUpdated( wxCommandEvent& event )
403 {
404  if( m_initialized && m_TextComment4->IsModified() )
405  {
407  m_tb.SetComment4( m_TextComment4->GetValue() );
409  }
410 }
411 
412 
413 void DIALOG_PAGES_SETTINGS::OnDateApplyClick( wxCommandEvent& event )
414 {
415  wxDateTime datetime = m_PickDate->GetValue();
416  wxString date =
417  // We can choose different formats. Only one must be uncommented
418  //
419  // datetime.Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
420  // datetime.Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
421  // datetime.Format( wxT("%Y-%b-%d") );
422  datetime.FormatISODate();
423 
424  m_TextDate->SetValue( date );
425 }
426 
427 
429 {
430  bool success = false;
431 
432  wxString fileName = GetWksFileName();
433 
435  {
436  wxString fullFileName = WORKSHEET_LAYOUT::MakeFullFileName( fileName, m_projectPath );
437 
438  if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) )
439  {
440  wxString msg;
441  msg.Printf( _( "Page layout description file \"%s\" not found." ),
442  GetChars( fullFileName ) );
443  wxMessageBox( msg );
444  return false;
445  }
446 
449  pglayout.SetPageLayout( fullFileName );
451  }
452 
453  int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
454  const wxString paperType = m_pageFmt[idx];
455 
456  if( paperType.Contains( PAGE_INFO::Custom ) )
457  {
459 
460  success = m_pageInfo.SetType( PAGE_INFO::Custom );
461 
462  if( success )
463  {
466 
469  }
470  }
471  else
472  {
473  // search for longest common string first, e.g. A4 before A
474  if( paperType.Contains( PAGE_INFO::USLetter ) )
476  else if( paperType.Contains( PAGE_INFO::USLegal ) )
478  else if( paperType.Contains( PAGE_INFO::USLedger ) )
480  else if( paperType.Contains( PAGE_INFO::GERBER ) )
481  success = m_pageInfo.SetType( PAGE_INFO::GERBER );
482  else if( paperType.Contains( PAGE_INFO::A4 ) )
483  success = m_pageInfo.SetType( PAGE_INFO::A4 );
484  else if( paperType.Contains( PAGE_INFO::A3 ) )
485  success = m_pageInfo.SetType( PAGE_INFO::A3 );
486  else if( paperType.Contains( PAGE_INFO::A2 ) )
487  success = m_pageInfo.SetType( PAGE_INFO::A2 );
488  else if( paperType.Contains( PAGE_INFO::A1 ) )
489  success = m_pageInfo.SetType( PAGE_INFO::A1 );
490  else if( paperType.Contains( PAGE_INFO::A0 ) )
491  success = m_pageInfo.SetType( PAGE_INFO::A0 );
492  else if( paperType.Contains( PAGE_INFO::A ) )
493  success = m_pageInfo.SetType( PAGE_INFO::A );
494  else if( paperType.Contains( PAGE_INFO::B ) )
495  success = m_pageInfo.SetType( PAGE_INFO::B );
496  else if( paperType.Contains( PAGE_INFO::C ) )
497  success = m_pageInfo.SetType( PAGE_INFO::C );
498  else if( paperType.Contains( PAGE_INFO::D ) )
499  success = m_pageInfo.SetType( PAGE_INFO::D );
500  else if( paperType.Contains( PAGE_INFO::E ) )
501  success = m_pageInfo.SetType( PAGE_INFO::E );
502 
503  if( success )
504  {
505  int choice = m_orientationComboBox->GetSelection();
506  m_pageInfo.SetPortrait( choice != 0 );
507  }
508  }
509 
510  if( !success )
511  {
512  wxASSERT_MSG( false, _( "the translation for paper size must preserve original spellings" ) );
514  }
515 
517 
518  m_tb.SetRevision( m_TextRevision->GetValue() );
519  m_tb.SetDate( m_TextDate->GetValue() );
520  m_tb.SetCompany( m_TextCompany->GetValue() );
521  m_tb.SetTitle( m_TextTitle->GetValue() );
522  m_tb.SetComment1( m_TextComment1->GetValue() );
523  m_tb.SetComment2( m_TextComment2->GetValue() );
524  m_tb.SetComment3( m_TextComment3->GetValue() );
525  m_tb.SetComment4( m_TextComment4->GetValue() );
526 
528 
529 
530 #ifdef EESCHEMA
531  // Exports settings to other sheets if requested:
532  SCH_SCREEN* screen;
533 
534  // Build the screen list
535  SCH_SCREENS ScreenList;
536 
537  // Update title blocks for all screens
538  for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
539  {
540  if( screen == m_screen )
541  continue;
542 
543  TITLE_BLOCK tb2 = screen->GetTitleBlock();
544 
545  if( m_RevisionExport->IsChecked() )
546  tb2.SetRevision( m_tb.GetRevision() );
547 
548  if( m_DateExport->IsChecked() )
549  tb2.SetDate( m_tb.GetDate() );
550 
551  if( m_TitleExport->IsChecked() )
552  tb2.SetTitle( m_tb.GetTitle() );
553 
554  if( m_CompanyExport->IsChecked() )
555  tb2.SetCompany( m_tb.GetCompany() );
556 
557  if( m_Comment1Export->IsChecked() )
558  tb2.SetComment1( m_tb.GetComment1() );
559 
560  if( m_Comment2Export->IsChecked() )
561  tb2.SetComment2( m_tb.GetComment2() );
562 
563  if( m_Comment3Export->IsChecked() )
564  tb2.SetComment3( m_tb.GetComment3() );
565 
566  if( m_Comment4Export->IsChecked() )
567  tb2.SetComment4( m_tb.GetComment4() );
568 
569  screen->SetTitleBlock( tb2 );
570  }
571 
572 #endif
573 
574  return true;
575 }
576 
577 
578 void DIALOG_PAGES_SETTINGS::SetCurrentPageSizeSelection( const wxString& aPaperSize )
579 {
580  // search all the not translated label list containing our paper type
581  for( unsigned i = 0; i < m_pageFmt.GetCount(); ++i )
582  {
583  // parse each label looking for aPaperSize within it
584  wxStringTokenizer st( m_pageFmt[i] );
585 
586  while( st.HasMoreTokens() )
587  {
588  if( st.GetNextToken() == aPaperSize )
589  {
590  m_paperSizeComboBox->SetSelection( i );
591  return;
592  }
593  }
594  }
595 }
596 
597 
599 {
600  int lyWidth, lyHeight;
601 
602  wxSize clamped_layout_size( Clamp( MIN_PAGE_SIZE, m_layout_size.x, m_maxPageSizeMils.x ),
604 
605  double lyRatio = clamped_layout_size.x < clamped_layout_size.y ?
606  (double) clamped_layout_size.y / clamped_layout_size.x :
607  (double) clamped_layout_size.x / clamped_layout_size.y;
608 
609  if( clamped_layout_size.x < clamped_layout_size.y )
610  {
611  lyHeight = MAX_PAGE_EXAMPLE_SIZE;
612  lyWidth = KiROUND( (double) lyHeight / lyRatio );
613  }
614  else
615  {
616  lyWidth = MAX_PAGE_EXAMPLE_SIZE;
617  lyHeight = KiROUND( (double) lyWidth / lyRatio );
618  }
619 
620  if( m_page_bitmap )
621  {
622  m_PageLayoutExampleBitmap->SetBitmap( wxNullBitmap );
623  delete m_page_bitmap;
624  }
625 
626  m_page_bitmap = new wxBitmap( lyWidth + 1, lyHeight + 1 );
627 
628  if( m_page_bitmap->IsOk() )
629  {
630  // Calculate layout preview scale.
631  int appScale = m_screen->MilsToIuScalar();
632 
633  double scaleW = (double) lyWidth / clamped_layout_size.x / appScale;
634  double scaleH = (double) lyHeight / clamped_layout_size.y / appScale;
635 
636  // Prepare DC.
637  wxSize example_size( lyWidth + 1, lyHeight + 1 );
638  wxMemoryDC memDC;
639  memDC.SelectObject( *m_page_bitmap );
640  memDC.SetClippingRegion( wxPoint( 0, 0 ), example_size );
641  memDC.Clear();
642  memDC.SetUserScale( scaleW, scaleH );
643 
644  // Get logical page size and margins.
645  PAGE_INFO pageDUMMY;
646 
647  // Get page type
648  int idx = m_paperSizeComboBox->GetSelection();
649 
650  if( idx < 0 )
651  idx = 0;
652 
653  wxString pageFmtName = m_pageFmt[idx].BeforeFirst( ' ' );
654  bool portrait = clamped_layout_size.x < clamped_layout_size.y;
655  pageDUMMY.SetType( pageFmtName, portrait );
656  if( m_customFmt )
657  {
658  pageDUMMY.SetWidthMils( clamped_layout_size.x );
659  pageDUMMY.SetHeightMils( clamped_layout_size.y );
660  }
661 
662  // Draw layout preview.
663  wxString emptyString;
664  GRResetPenAndBrush( &memDC );
665 
667  DrawPageLayout( &memDC, NULL, pageDUMMY,
668  emptyString, emptyString,
670  m_screen->m_ScreenNumber, 1, appScale, DARKGRAY, RED );
671 
672  memDC.SelectObject( wxNullBitmap );
675 
676  // Refresh the dialog.
677  Layout();
678  Refresh();
679  }
680 }
681 
682 
684 {
685  int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
686  const wxString paperType = m_pageFmt[idx];
687 
688  // here we assume translators will keep original paper size spellings
689  if( paperType.Contains( PAGE_INFO::Custom ) )
690  {
692 
693  if( m_layout_size.x && m_layout_size.y )
694  {
695  if( m_layout_size.x < m_layout_size.y )
696  m_orientationComboBox->SetStringSelection( _( "Portrait" ) );
697  else
698  m_orientationComboBox->SetStringSelection( _( "Landscape" ) );
699  }
700  }
701  else
702  {
703  PAGE_INFO pageInfo; // SetType() later to lookup size
704 
705  static const wxChar* papers[] = {
706  // 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() / IU_PER_MILS;
752  double customSizeY = (double) m_customSizeY.GetValue() / IU_PER_MILS;
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" ),
779  path, name, PageLayoutDescrFileWildcard(),
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 = WORKSHEET_LAYOUT::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( _(
795  "The page layout description file name has changed.\n"
796  "Do you want to use the relative path:\n"
797  "\"%s\"\n"
798  "instead of\n"
799  "\"%s\"?" ), GetChars( shortFileName ), GetChars( fileName ) );
800 
801  if( !IsOK( this, msg ) )
802  shortFileName = fileName;
803  }
804 
805  SetWksFileName( shortFileName );
806 
807  if( m_pagelayout == NULL )
809 
810  m_pagelayout->SetPageLayout( fileName );
811 
814 }
void SetComment1(const wxString &aComment)
Definition: title_block.h:117
void OnDateApplyClick(wxCommandEvent &event) override
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)=0
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:123
static const wxChar A[]
Definition: page_info.h:69
wxString PageLayoutDescrFileWildcard()
SCH_SCREEN * GetNext()
int m_ScreenNumber
Definition: base_screen.h:216
wxSize m_maxPageSizeMils
Logical page layout size.
const T & Clamp(const T &lower, const T &value, const T &upper)
Function Clamp limits value within the range lower <= value <= upper.
Definition: macros.h:130
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:385
virtual const TITLE_BLOCK & GetTitleBlock() const =0
static int GetCustomHeightMils()
Function GetCustomHeightMils.
Definition: page_info.h:176
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:121
void OnPageOrientationChoice(wxCommandEvent &event) override
const wxString & GetCompany() const
Definition: title_block.h:99
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:84
static const wxChar E[]
Definition: page_info.h:73
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
void OnComment3TextUpdated(wxCommandEvent &event) override
static const wxChar GERBER[]
Definition: page_info.h:74
TITLE_BLOCK m_tb
true if the page selection is custom
virtual bool Validate(int aMin, int aMax, bool setFocusOnError=true)
Function Validate Validates the control against the given range, informing the user of any errors fou...
static const wxChar A3[]
Definition: page_info.h:65
void SetWksFileName(const wxString &aFilename)
static void SetCustomWidthMils(int aWidthInMils)
Function SetCustomWidthMils sets the width of Custom page in mils, for any custom page constructed or...
Definition: page_info.cpp:227
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Function SetType sets the name of the page type and also the sizes and margins commonly associated wi...
Definition: page_info.cpp:117
const wxString & GetComment4() const
Definition: title_block.h:124
void SetDate(const wxString &aDate)
Function SetDate sets the date field, and defaults to the current time and date.
Definition: title_block.h:74
const wxString & GetDate() const
Definition: title_block.h:79
void OnUserPageSizeXTextUpdated(wxCommandEvent &event) override
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:78
#define MAX_PAGE_EXAMPLE_SIZE
static const wxChar D[]
Definition: page_info.h:72
const wxString GetWksFileName()
bool m_initialized
list of page sizes (not translated)
The base class for create windows for drawing purpose.
Definition: draw_frame.h:78
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
wxSize m_layout_size
Temporary bitmap for the page layout example.
void SetComment4(const wxString &aComment)
Definition: title_block.h:120
static WORKSHEET_LAYOUT & GetTheInstance()
static function: returns the instance of WORKSHEET_LAYOUT used in the application ...
This file contains miscellaneous commonly used macros and functions.
const wxSize & GetSizeMils() const
Definition: page_info.h:142
virtual int GetValue()
Function GetValue Returns the current value in Internal Units.
wxBitmap * m_page_bitmap
the page layuout filename was changed
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:180
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
virtual const PAGE_INFO & GetPageSettings() const =0
const wxString & GetTitle() const
Definition: title_block.h:65
void DrawPageLayout(wxDC *aDC, EDA_RECT *aClipBox, const PAGE_INFO &aPageInfo, const wxString &aFullSheetName, const wxString &aFileName, TITLE_BLOCK &aTitleBlock, int aSheetCount, int aSheetNumber, int aPenWidth, double aScalar, COLOR4D aColor, COLOR4D aAltColor, const wxString &aSheetLayer)
Function DrawPageLayout is a core function to draw the page layout with the frame and the basic inscr...
void OnComment1TextUpdated(wxCommandEvent &event) override
bool IsPortrait() const
Definition: page_info.h:121
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:394
static const wxChar USLegal[]
Definition: page_info.h:76
static const wxChar B[]
Definition: page_info.h:70
static const wxChar C[]
Definition: page_info.h:71
#define MAX_PAGE_SIZE_PCBNEW_MILS
Definition: page_info.h:40
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:89
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
void SetCompany(const wxString &aCompany)
Definition: title_block.h:94
Definition of file extensions used in Kicad.
static const wxChar A4[]
Definition: page_info.h:64
Definition: colors.h:60
const wxString & GetComment3() const
Definition: title_block.h:123
virtual int MilsToIuScalar()
Function MilsToIuScalar returns the scalar required to convert mils to internal units.
Definition: base_screen.h:245
void OnDateTextUpdated(wxCommandEvent &event) override
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: sch_screen.h:138
void SetCurrentPageSizeSelection(const wxString &aPaperSize)
void SetTitle(const wxString &aTitle)
Definition: title_block.h:60
int GetWidthMils() const
Definition: page_info.h:137
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:253
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:136
static const wxChar USLedger[]
Definition: page_info.h:77
const wxString & GetComment2() const
Definition: title_block.h:122
DIALOG_PAGES_SETTINGS(EDA_DRAW_FRAME *parent, wxSize aMaxUserSizeMils)
#define MAX_PAGE_SIZE_EDITORS_MILS
Definition: page_info.h:41
WORKSHEET_LAYOUT handles the graphic items list to draw/plot the title block and other items (page re...
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
of elements in an array. This implements type-safe compile time checking
Definition: macros.h:99
void OnWksFileSelection(wxCommandEvent &event) override
Class DIALOG_PAGES_SETTINGS_BASE.
virtual void SaveProjectSettings(bool aAskForSave)
Function SaveProjectSettings saves changes to the project settings to the project (...
static const wxChar A1[]
Definition: page_info.h:67
Definitions for the Eeschema program SCH_SCREEN class.
virtual void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
Redraw the entire screen area by updating the scroll bars and mouse pointer in order to have aCenterP...
static const wxChar USLetter[]
Definition: page_info.h:75
void OnOkClick(wxCommandEvent &event) override
void SetComment2(const wxString &aComment)
Definition: title_block.h:118
virtual void OnPageSettingsChange()
Called when modifying the page settings.
Definition: draw_frame.h:754
const wxString & GetComment1() const
Definition: title_block.h:121
PAGE_INFO m_pageInfo
The max page size allowed by the caller frame.
void OnComment4TextUpdated(wxCommandEvent &event) override
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void OnUserPageSizeYTextUpdated(wxCommandEvent &event) override
const char * name
Definition: DXF_plotter.cpp:61
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
#define max(a, b)
Definition: auxiliary.h:86
static const wxString MakeShortFileName(const wxString &aFullFileName, const wxString &aProjectPath)
WORKSHEET_LAYOUT * m_pagelayout
Temporary title block (basic inscriptions).
static const wxString pageFmts[]
virtual void SetValue(int aValue)
Function SetValue Sets new value (in Internal Units) for the text field, taking care of units convers...
static const wxString MakeFullFileName(const wxString &aShortFileName, const wxString &aProjectPath)
Static function.
size_t i
Definition: json11.cpp:597
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:239
#define IU_PER_MILS
Definition: plotter.cpp:134
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
The common library.
static int GetCustomWidthMils()
Function GetCustomWidthMils.
Definition: page_info.h:170
void Process_PageSettings(wxCommandEvent &event)
bool m_customFmt
Temporary page info.
int m_NumberOfScreens
Definition: base_screen.h:217
static const wxChar A2[]
Definition: page_info.h:66
classes and function to generate graphics to plt or draw titles blocks and frame references ...
SCH_SCREEN * GetFirst()
void OnComment2TextUpdated(wxCommandEvent &event) override
bool IsType(FRAME_T aType) const
void OnPaperSizeChoice(wxCommandEvent &event) override
void SetComment3(const wxString &aComment)
Definition: title_block.h:119
const wxString & GetType() const
Definition: page_info.h:97
Basic classes for most KiCad items.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
void OnTitleTextUpdated(wxCommandEvent &event) override
void OnCompanyTextUpdated(wxCommandEvent &event) override
void SetModify()
Definition: base_screen.h:324
void OnRevisionTextUpdated(wxCommandEvent &event) override
#define MIN_PAGE_SIZE
Min and max page sizes for clamping, in mils.
Definition: page_info.h:39
BASE_SCREEN class implementation.
#define _HKI(x)
void SetPortrait(bool aIsPortrait)
Function SetPortrait will rotate the paper page 90 degrees.
Definition: page_info.cpp:182
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:295
static void SetAltInstance(WORKSHEET_LAYOUT *aLayout=NULL)
static function: Set an alternate instance of WORKSHEET_LAYOUT mainly used in page setting dialog ...
int GetHeightMils() const
Definition: page_info.h:140
void Enable(bool aEnable)
Function Enable Enables/diasables the label, widget and units label.
static void SetCustomHeightMils(int aHeightInMils)
Function SetCustomHeightMils sets the height of Custom page in mils, for any custom page constructed ...
Definition: page_info.cpp:233
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
void SetPageLayout(const wxString &aFullFileName=wxEmptyString, bool Append=false)
Populates the list with a custom layout, or the default layout, if no custom layout available...
static const wxChar A0[]
Definition: page_info.h:68