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 
24 #include <fctsys.h>
25 #include <common.h>
26 #include <project.h>
27 #include <confirm.h>
28 #include <gr_basic.h>
29 #include <base_struct.h>
30 #include <title_block.h>
31 #include <eda_draw_frame.h>
32 #include <ws_data_model.h>
33 #include <base_screen.h>
35 #include <tool/tool_manager.h>
36 #include <wx/valgen.h>
37 #include <wx/tokenzr.h>
38 
39 #ifdef EESCHEMA
40 #include <sch_screen.h>
41 #include <general.h>
42 #endif
43 
44 #include <ws_painter.h>
45 #include <dialog_page_settings.h>
46 #include <tool/actions.h>
47 
48 #define MAX_PAGE_EXAMPLE_SIZE 200
49 
50 
51 // List of page formats.
52 // they are prefixed by "_HKI" (already in use for hotkeys) instead of "_",
53 // because we need both the translated and the not translated version.
54 // when displayed in dialog we should explicitly call wxGetTranslation()
55 // to show the translated version.
56 // See hotkeys_basic.h for more info
57 #define _HKI( x ) wxT( x )
58 static const wxString pageFmts[] =
59 {
60  _HKI("A4 210x297mm"),
61  _HKI("A3 297x420mm"),
62  _HKI("A2 420x594mm"),
63  _HKI("A1 594x841mm"),
64  _HKI("A0 841x1189mm"),
65  _HKI("A 8.5x11in"),
66  _HKI("B 11x17in"),
67  _HKI("C 17x22in"),
68  _HKI("D 22x34in"),
69  _HKI("E 34x44in"),
70  _HKI("USLetter 8.5x11in"), // USLetter without space is correct
71  _HKI("USLegal 8.5x14in"), // USLegal without space is correct
72  _HKI("USLedger 11x17in"), // USLedger without space is correct
73  _HKI("User (Custom)"), // size defined by user. The string must contain "Custom"
74  // to be recognized in code
75 };
76 
77 DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent, wxSize aMaxUserSizeMils ) :
79  m_initialized( false ),
80  m_customSizeX( parent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits, false ),
81  m_customSizeY( parent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits, false )
82 {
83  m_parent = parent;
86  m_page_bitmap = NULL;
87  m_maxPageSizeMils = aMaxUserSizeMils;
89  m_customFmt = false;
91 
93  wxString serialization;
95  m_pagelayout->SetPageLayout( TO_UTF8( serialization ) );
96 
97  m_PickDate->SetValue( wxDateTime::Now() );
98 
99  if( parent->GetName() == PL_EDITOR_FRAME_NAME )
100  {
101  SetTitle( _( "Preview Settings" ) );
102  m_staticTextPaper->SetLabel( _( "Preview Paper" ) );
103  m_staticTextTitleBlock->SetLabel( _( "Preview Title Block Data" ) );
104  }
105  else
106  {
107  SetTitle( _( "Page Settings" ) );
108  m_staticTextPaper->SetLabel( _( "Paper" ) );
109  m_staticTextTitleBlock->SetLabel( _( "Title Block" ) );
110  }
111 
112  initDialog();
113 
114  GetSizer()->SetSizeHints( this );
115  Centre();
116 }
117 
118 
120 {
121  delete m_page_bitmap;
122  delete m_pagelayout;
123 }
124 
125 
127 {
128  wxString msg;
129 
130  // initialize page format choice box and page format list.
131  // The first shows translated strings, the second contains not translated strings
132  m_paperSizeComboBox->Clear();
133 
134  for( const wxString& pageFmt : pageFmts )
135  {
136  m_pageFmt.Add( pageFmt );
137  m_paperSizeComboBox->Append( wxGetTranslation( pageFmt ) );
138  }
139 
140  // initialize the page layout descr filename
142 
143 #ifdef EESCHEMA
144  // Init display value for schematic sub-sheet number
145  wxString format = m_TextSheetCount->GetLabel();
146  msg.Printf( format, m_screen->m_NumberOfScreens );
147  m_TextSheetCount->SetLabel( msg );
148 
149  format = m_TextSheetNumber->GetLabel();
150  msg.Printf( format, m_screen->m_ScreenNumber );
151  m_TextSheetNumber->SetLabel( msg );
152 #else
153  m_TextSheetCount->Show( false );
154  m_TextSheetNumber->Show( false );
155 #endif
156 
159  m_orientationComboBox->SetSelection( m_pageInfo.IsPortrait() );
160 
161  // only a click fires the "selection changed" event, so have to fabricate this check
162  wxCommandEvent dummy;
164 
165  if( m_customFmt )
166  {
169  }
170  else
171  {
174  }
175 
176  m_TextRevision->SetValue( m_tb.GetRevision() );
177  m_TextDate->SetValue( m_tb.GetDate() );
178  m_TextTitle->SetValue( m_tb.GetTitle() );
179  m_TextCompany->SetValue( m_tb.GetCompany() );
180  m_TextComment1->SetValue( m_tb.GetComment1() );
181  m_TextComment2->SetValue( m_tb.GetComment2() );
182  m_TextComment3->SetValue( m_tb.GetComment3() );
183  m_TextComment4->SetValue( m_tb.GetComment4() );
184 
185 #ifndef EESCHEMA
186  // these options have meaning only for Eeschema.
187  // disable them for other apps
188  m_RevisionExport->Show( false );
189  m_DateExport->Show( false );
190  m_TitleExport->Show( false );
191  m_CompanyExport->Show( false );
192  m_Comment1Export->Show( false );
193  m_Comment2Export->Show( false );
194  m_Comment3Export->Show( false );
195  m_Comment4Export->Show( false );
196 #endif
197 
200 
201  // Make the OK button the default.
202  m_sdbSizerOK->SetDefault();
203  m_initialized = true;
204 }
205 
206 
207 void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event )
208 {
209  if( !m_customSizeX.Validate( Mils2iu( MIN_PAGE_SIZE ), Mils2iu( m_maxPageSizeMils.x ) ) )
210  return;
211 
212  if( !m_customSizeY.Validate( Mils2iu( MIN_PAGE_SIZE ), Mils2iu( m_maxPageSizeMils.y ) ) )
213  return;
214 
215  if( SavePageSettings() )
216  {
217  m_screen->SetModify();
218 
219  if( LocalPrjConfigChanged() )
220  m_parent->SaveProjectSettings( false );
221 
222  // Call the post processing (if any) after changes
224  }
225 
226  event.Skip();
227 }
228 
229 
230 void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
231 {
232  int idx = m_paperSizeComboBox->GetSelection();
233 
234  if( idx < 0 )
235  idx = 0;
236 
237  const wxString paperType = m_pageFmt[idx];
238 
239  if( paperType.Contains( PAGE_INFO::Custom ) )
240  {
241  m_orientationComboBox->Enable( false );
242  m_customSizeX.Enable( true );
243  m_customSizeY.Enable( true );
244  m_customFmt = true;
245  }
246  else
247  {
248  m_orientationComboBox->Enable( true );
249 
250 #if 0
251  // ForcePortrait() does not exist, but could be useful.
252  // so I leave these lines, which could be seen as a todo feature
253  if( paperType.ForcePortrait() )
254  {
255  m_orientationComboBox->SetStringSelection( _( "Portrait" ) );
256  m_orientationComboBox->Enable( false );
257  }
258 #endif
259  m_customSizeX.Enable( false );
260  m_customSizeY.Enable( false );
261  m_customFmt = false;
262  }
263 
266 }
267 
268 
270 {
271  if( m_initialized )
272  {
275  }
276 }
277 
278 
280 {
281  if( m_initialized )
282  {
285  }
286 }
287 
288 
290 {
291  if( m_initialized )
292  {
295  }
296 }
297 
298 
299 void DIALOG_PAGES_SETTINGS::OnRevisionTextUpdated( wxCommandEvent& event )
300 {
301  if( m_initialized && m_TextRevision->IsModified() )
302  {
304  m_tb.SetRevision( m_TextRevision->GetValue() );
306  }
307 }
308 
309 
310 void DIALOG_PAGES_SETTINGS::OnDateTextUpdated( wxCommandEvent& event )
311 {
312  if( m_initialized && m_TextDate->IsModified() )
313  {
315  m_tb.SetDate( m_TextDate->GetValue() );
317  }
318 }
319 
320 
321 void DIALOG_PAGES_SETTINGS::OnTitleTextUpdated( wxCommandEvent& event )
322 {
323  if( m_initialized && m_TextTitle->IsModified() )
324  {
326  m_tb.SetTitle( m_TextTitle->GetValue() );
328  }
329 }
330 
331 
332 void DIALOG_PAGES_SETTINGS::OnCompanyTextUpdated( wxCommandEvent& event )
333 {
334  if( m_initialized && m_TextCompany->IsModified() )
335  {
337  m_tb.SetCompany( m_TextCompany->GetValue() );
339  }
340 }
341 
342 
343 void DIALOG_PAGES_SETTINGS::OnComment1TextUpdated( wxCommandEvent& event )
344 {
345  if( m_initialized && m_TextComment1->IsModified() )
346  {
348  m_tb.SetComment1( m_TextComment1->GetValue() );
350  }
351 }
352 
353 
354 void DIALOG_PAGES_SETTINGS::OnComment2TextUpdated( wxCommandEvent& event )
355 {
356  if( m_initialized && m_TextComment2->IsModified() )
357  {
359  m_tb.SetComment2( m_TextComment2->GetValue() );
361  }
362 }
363 
364 
365 void DIALOG_PAGES_SETTINGS::OnComment3TextUpdated( wxCommandEvent& event )
366 {
367  if( m_initialized && m_TextComment3->IsModified() )
368  {
370  m_tb.SetComment3( m_TextComment3->GetValue() );
372  }
373 }
374 
375 
376 void DIALOG_PAGES_SETTINGS::OnComment4TextUpdated( wxCommandEvent& event )
377 {
378  if( m_initialized && m_TextComment4->IsModified() )
379  {
381  m_tb.SetComment4( m_TextComment4->GetValue() );
383  }
384 }
385 
386 
387 void DIALOG_PAGES_SETTINGS::OnDateApplyClick( wxCommandEvent& event )
388 {
389  wxDateTime datetime = m_PickDate->GetValue();
390  wxString date =
391  // We can choose different formats. Only one must be uncommented
392  //
393  // datetime.Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
394  // datetime.Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
395  // datetime.Format( wxT("%Y-%b-%d") );
396  datetime.FormatISODate();
397 
398  m_TextDate->SetValue( date );
399 }
400 
401 
403 {
404  bool success = false;
405 
406  wxString fileName = GetWksFileName();
407 
409  {
410  wxString fullFileName = WS_DATA_MODEL::MakeFullFileName( fileName, m_projectPath );
411 
412  if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) )
413  {
414  wxString msg;
415  msg.Printf( _( "Page layout description file \"%s\" not found." ),
416  GetChars( fullFileName ) );
417  wxMessageBox( msg );
418  return false;
419  }
420 
423  pglayout.SetPageLayout( fullFileName );
425  }
426 
427  int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
428  const wxString paperType = m_pageFmt[idx];
429 
430  if( paperType.Contains( PAGE_INFO::Custom ) )
431  {
433 
434  success = m_pageInfo.SetType( PAGE_INFO::Custom );
435 
436  if( success )
437  {
440 
443  }
444  }
445  else
446  {
447  // search for longest common string first, e.g. A4 before A
448  if( paperType.Contains( PAGE_INFO::USLetter ) )
450  else if( paperType.Contains( PAGE_INFO::USLegal ) )
452  else if( paperType.Contains( PAGE_INFO::USLedger ) )
454  else if( paperType.Contains( PAGE_INFO::GERBER ) )
455  success = m_pageInfo.SetType( PAGE_INFO::GERBER );
456  else if( paperType.Contains( PAGE_INFO::A4 ) )
457  success = m_pageInfo.SetType( PAGE_INFO::A4 );
458  else if( paperType.Contains( PAGE_INFO::A3 ) )
459  success = m_pageInfo.SetType( PAGE_INFO::A3 );
460  else if( paperType.Contains( PAGE_INFO::A2 ) )
461  success = m_pageInfo.SetType( PAGE_INFO::A2 );
462  else if( paperType.Contains( PAGE_INFO::A1 ) )
463  success = m_pageInfo.SetType( PAGE_INFO::A1 );
464  else if( paperType.Contains( PAGE_INFO::A0 ) )
465  success = m_pageInfo.SetType( PAGE_INFO::A0 );
466  else if( paperType.Contains( PAGE_INFO::A ) )
467  success = m_pageInfo.SetType( PAGE_INFO::A );
468  else if( paperType.Contains( PAGE_INFO::B ) )
469  success = m_pageInfo.SetType( PAGE_INFO::B );
470  else if( paperType.Contains( PAGE_INFO::C ) )
471  success = m_pageInfo.SetType( PAGE_INFO::C );
472  else if( paperType.Contains( PAGE_INFO::D ) )
473  success = m_pageInfo.SetType( PAGE_INFO::D );
474  else if( paperType.Contains( PAGE_INFO::E ) )
475  success = m_pageInfo.SetType( PAGE_INFO::E );
476 
477  if( success )
478  {
479  int choice = m_orientationComboBox->GetSelection();
480  m_pageInfo.SetPortrait( choice != 0 );
481  }
482  }
483 
484  if( !success )
485  {
486  wxASSERT_MSG( false, _( "the translation for paper size must preserve original spellings" ) );
488  }
489 
491 
492  m_tb.SetRevision( m_TextRevision->GetValue() );
493  m_tb.SetDate( m_TextDate->GetValue() );
494  m_tb.SetCompany( m_TextCompany->GetValue() );
495  m_tb.SetTitle( m_TextTitle->GetValue() );
496  m_tb.SetComment1( m_TextComment1->GetValue() );
497  m_tb.SetComment2( m_TextComment2->GetValue() );
498  m_tb.SetComment3( m_TextComment3->GetValue() );
499  m_tb.SetComment4( m_TextComment4->GetValue() );
500 
502 
503 
504 #ifdef EESCHEMA
505  // Exports settings to other sheets if requested:
506  SCH_SCREEN* screen;
507 
508  // Build the screen list
509  SCH_SCREENS ScreenList;
510 
511  // Update title blocks for all screens
512  for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
513  {
514  if( screen == m_screen )
515  continue;
516 
517  TITLE_BLOCK tb2 = screen->GetTitleBlock();
518 
519  if( m_RevisionExport->IsChecked() )
520  tb2.SetRevision( m_tb.GetRevision() );
521 
522  if( m_DateExport->IsChecked() )
523  tb2.SetDate( m_tb.GetDate() );
524 
525  if( m_TitleExport->IsChecked() )
526  tb2.SetTitle( m_tb.GetTitle() );
527 
528  if( m_CompanyExport->IsChecked() )
529  tb2.SetCompany( m_tb.GetCompany() );
530 
531  if( m_Comment1Export->IsChecked() )
532  tb2.SetComment1( m_tb.GetComment1() );
533 
534  if( m_Comment2Export->IsChecked() )
535  tb2.SetComment2( m_tb.GetComment2() );
536 
537  if( m_Comment3Export->IsChecked() )
538  tb2.SetComment3( m_tb.GetComment3() );
539 
540  if( m_Comment4Export->IsChecked() )
541  tb2.SetComment4( m_tb.GetComment4() );
542 
543  screen->SetTitleBlock( tb2 );
544  }
545 
546 #endif
547 
548  return true;
549 }
550 
551 
552 void DIALOG_PAGES_SETTINGS::SetCurrentPageSizeSelection( const wxString& aPaperSize )
553 {
554  // search all the not translated label list containing our paper type
555  for( unsigned i = 0; i < m_pageFmt.GetCount(); ++i )
556  {
557  // parse each label looking for aPaperSize within it
558  wxStringTokenizer st( m_pageFmt[i] );
559 
560  while( st.HasMoreTokens() )
561  {
562  if( st.GetNextToken() == aPaperSize )
563  {
564  m_paperSizeComboBox->SetSelection( i );
565  return;
566  }
567  }
568  }
569 }
570 
571 
573 {
574  int lyWidth, lyHeight;
575 
576  wxSize clamped_layout_size( Clamp( MIN_PAGE_SIZE, m_layout_size.x, m_maxPageSizeMils.x ),
578 
579  double lyRatio = clamped_layout_size.x < clamped_layout_size.y ?
580  (double) clamped_layout_size.y / clamped_layout_size.x :
581  (double) clamped_layout_size.x / clamped_layout_size.y;
582 
583  if( clamped_layout_size.x < clamped_layout_size.y )
584  {
585  lyHeight = MAX_PAGE_EXAMPLE_SIZE;
586  lyWidth = KiROUND( (double) lyHeight / lyRatio );
587  }
588  else
589  {
590  lyWidth = MAX_PAGE_EXAMPLE_SIZE;
591  lyHeight = KiROUND( (double) lyWidth / lyRatio );
592  }
593 
594  if( m_page_bitmap )
595  {
596  m_PageLayoutExampleBitmap->SetBitmap( wxNullBitmap );
597  delete m_page_bitmap;
598  }
599 
600  m_page_bitmap = new wxBitmap( lyWidth + 1, lyHeight + 1 );
601 
602  if( m_page_bitmap->IsOk() )
603  {
604  double scaleW = (double) lyWidth / clamped_layout_size.x;
605  double scaleH = (double) lyHeight / clamped_layout_size.y;
606 
607  // Prepare DC.
608  wxSize example_size( lyWidth + 1, lyHeight + 1 );
609  wxMemoryDC memDC;
610  memDC.SelectObject( *m_page_bitmap );
611  memDC.SetClippingRegion( wxPoint( 0, 0 ), example_size );
612  memDC.Clear();
613  memDC.SetUserScale( scaleW, scaleH );
614 
615  // Get logical page size and margins.
616  PAGE_INFO pageDUMMY;
617 
618  // Get page type
619  int idx = m_paperSizeComboBox->GetSelection();
620 
621  if( idx < 0 )
622  idx = 0;
623 
624  wxString pageFmtName = m_pageFmt[idx].BeforeFirst( ' ' );
625  bool portrait = clamped_layout_size.x < clamped_layout_size.y;
626  pageDUMMY.SetType( pageFmtName, portrait );
627  if( m_customFmt )
628  {
629  pageDUMMY.SetWidthMils( clamped_layout_size.x );
630  pageDUMMY.SetHeightMils( clamped_layout_size.y );
631  }
632 
633  // Draw layout preview.
634  wxString emptyString;
635  GRResetPenAndBrush( &memDC );
636 
638  GRFilledRect( NULL, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, WHITE, WHITE );
639  PrintPageLayout( &memDC, pageDUMMY, emptyString, emptyString, m_tb,
641 
642  memDC.SelectObject( wxNullBitmap );
645 
646  // Refresh the dialog.
647  Layout();
648  Refresh();
649  }
650 }
651 
652 
654 {
655  int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
656  const wxString paperType = m_pageFmt[idx];
657 
658  // here we assume translators will keep original paper size spellings
659  if( paperType.Contains( PAGE_INFO::Custom ) )
660  {
662 
663  if( m_layout_size.x && m_layout_size.y )
664  {
665  if( m_layout_size.x < m_layout_size.y )
666  m_orientationComboBox->SetStringSelection( _( "Portrait" ) );
667  else
668  m_orientationComboBox->SetStringSelection( _( "Landscape" ) );
669  }
670  }
671  else
672  {
673  PAGE_INFO pageInfo; // SetType() later to lookup size
674 
675  static const wxChar* papers[] = {
676  // longest common string first, since sequential search below
682  PAGE_INFO::A,
683  PAGE_INFO::B,
684  PAGE_INFO::C,
685  PAGE_INFO::D,
686  PAGE_INFO::E,
690  };
691 
692  unsigned i;
693 
694  for( i=0; i < arrayDim( papers ); ++i )
695  {
696  if( paperType.Contains( papers[i] ) )
697  {
698  pageInfo.SetType( papers[i] );
699  break;
700  }
701  }
702 
703  wxASSERT( i != arrayDim(papers) ); // dialog UI match the above list?
704 
705  m_layout_size = pageInfo.GetSizeMils();
706 
707  // swap sizes to match orientation
708  bool isPortrait = (bool) m_orientationComboBox->GetSelection();
709 
710  if( ( isPortrait && m_layout_size.x >= m_layout_size.y ) ||
711  ( !isPortrait && m_layout_size.x < m_layout_size.y ) )
712  {
714  }
715  }
716 }
717 
718 
720 {
721  double customSizeX = (double) m_customSizeX.GetValue() / IU_PER_MILS;
722  double customSizeY = (double) m_customSizeY.GetValue() / IU_PER_MILS;
723 
724  // Prepare to painless double -> int conversion.
725  customSizeX = Clamp( double( INT_MIN ), customSizeX, double( INT_MAX ) );
726  customSizeY = Clamp( double( INT_MIN ), customSizeY, double( INT_MAX ) );
727  m_layout_size = wxSize( KiROUND( customSizeX ), KiROUND( customSizeY ) );
728 }
729 
730 
731 void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
732 {
733  wxFileName fn = GetWksFileName();
734  wxString name = GetWksFileName();
735  wxString path;
736 
737  if( fn.IsAbsolute() )
738  {
739  path = fn.GetPath();
740  name = fn.GetFullName();
741  }
742  else
743  {
744  path = m_projectPath;
745  }
746 
747  // Display a file picker dialog
748  wxFileDialog fileDialog( this, _( "Select Page Layout Description File" ),
750  wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
751 
752  if( fileDialog.ShowModal() != wxID_OK )
753  return;
754 
755  wxString fileName = fileDialog.GetPath();
756 
757  // Try to remove the path, if the path is the current working dir,
758  // or the dir of kicad.pro (template), and use a relative path
759  wxString shortFileName = WS_DATA_MODEL::MakeShortFileName( fileName, m_projectPath );
760 
761  // For Win/Linux/macOS compatibility, a relative path is a good idea
762  if( shortFileName != GetWksFileName() && shortFileName != fileName )
763  {
764  wxString msg = wxString::Format( _(
765  "The page layout description file name has changed.\n"
766  "Do you want to use the relative path:\n"
767  "\"%s\"\n"
768  "instead of\n"
769  "\"%s\"?" ), GetChars( shortFileName ), GetChars( fileName ) );
770 
771  if( !IsOK( this, msg ) )
772  shortFileName = fileName;
773  }
774 
775  SetWksFileName( shortFileName );
776 
777  if( m_pagelayout == NULL )
779 
780  m_pagelayout->SetPageLayout( fileName );
781 
784 }
void SetComment1(const wxString &aComment)
Definition: title_block.h:117
void OnDateApplyClick(wxCommandEvent &event) override
WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block.
Definition: ws_data_model.h:39
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)=0
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:120
static const wxChar A[]
Definition: page_info.h:69
wxString PageLayoutDescrFileWildcard()
SCH_SCREEN * GetNext()
int m_ScreenNumber
Definition: base_screen.h:135
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:139
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:115
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:84
int GetHeightMils() const
Definition: page_info.h:140
static const wxChar E[]
Definition: page_info.h:73
void OnComment3TextUpdated(wxCommandEvent &event) override
static const wxChar GERBER[]
Definition: page_info.h:74
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:888
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 TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:123
#define PL_EDITOR_FRAME_NAME
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.
void OnUserPageSizeXTextUpdated(wxCommandEvent &event) override
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:78
const wxString & GetType() const
Definition: page_info.h:97
#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.
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot,...
Definition: title_block.h:40
wxSize m_layout_size
Temporary bitmap for the page layout example.
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
void SetComment4(const wxString &aComment)
Definition: title_block.h:120
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
static void SetAltInstance(WS_DATA_MODEL *aLayout=NULL)
static function: Set an alternate instance of WS_DATA_MODEL mainly used in page setting dialog
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:109
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
virtual const PAGE_INFO & GetPageSettings() const =0
void OnComment1TextUpdated(wxCommandEvent &event) override
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
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
static const wxString MakeShortFileName(const wxString &aFullFileName, const wxString &aProjectPath)
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
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
const wxString & GetCompany() const
Definition: title_block.h:99
const wxString & GetComment3() const
Definition: title_block.h:123
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 wxSize & GetSizeMils() const
Definition: page_info.h:142
void OnDateTextUpdated(wxCommandEvent &event) override
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: sch_screen.h:125
void SetCurrentPageSizeSelection(const wxString &aPaperSize)
void SetTitle(const wxString &aTitle)
Definition: title_block.h:60
#define _(s)
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:253
static const wxChar USLedger[]
Definition: page_info.h:77
DIALOG_PAGES_SETTINGS(EDA_DRAW_FRAME *parent, wxSize aMaxUserSizeMils)
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
void OnWksFileSelection(wxCommandEvent &event) override
Class DIALOG_PAGES_SETTINGS_BASE.
virtual void SaveProjectSettings(bool aAskForSave)
Save changes to the project settings to the project (.pro) file.
static const wxChar A1[]
Definition: page_info.h:67
const wxString & GetDate() const
Definition: title_block.h:79
const wxString & GetComment2() const
Definition: title_block.h:122
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.
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:101
void OnUserPageSizeYTextUpdated(wxCommandEvent &event) override
static const wxString MakeFullFileName(const wxString &aShortFileName, const wxString &aProjectPath)
Static function.
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 to draw a dummy shape when a LIB_PART is not found in library.
#define max(a, b)
Definition: auxiliary.h:86
bool IsPortrait() const
Definition: page_info.h:121
const wxString & GetComment1() const
Definition: title_block.h:121
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...
size_t i
Definition: json11.cpp:597
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:239
#define IU_PER_MILS
Definition: plotter.cpp:134
The common library.
static int GetCustomWidthMils()
Function GetCustomWidthMils.
Definition: page_info.h:170
WS_DATA_MODEL * m_pagelayout
Temporary title block (basic inscriptions).
Definition: colors.h:49
bool m_customFmt
Temporary page info.
int m_NumberOfScreens
Definition: base_screen.h:136
static const wxChar A2[]
Definition: page_info.h:66
const wxString & GetTitle() const
Definition: title_block.h:65
SCH_SCREEN * GetFirst()
void OnComment2TextUpdated(wxCommandEvent &event) override
void OnPaperSizeChoice(wxCommandEvent &event) override
void SetComment3(const wxString &aComment)
Definition: title_block.h:119
void OnTitleTextUpdated(wxCommandEvent &event) override
void OnCompanyTextUpdated(wxCommandEvent &event) override
void SetModify()
Definition: base_screen.h:224
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)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:294
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SaveInString(wxString &aOutputString)
Save the description in a buffer.
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:486
int GetWidthMils() const
Definition: page_info.h:137
static const wxChar A0[]
Definition: page_info.h:68
void PrintPageLayout(wxDC *aDC, const PAGE_INFO &aPageInfo, const wxString &aFullSheetName, const wxString &aFileName, const TITLE_BLOCK &aTitleBlock, int aSheetCount, int aSheetNumber, int aPenWidth, double aScalar, COLOR4D aColor, const wxString &aSheetLayer)
Function PrintPageLayout is a core function to print the page layout with the frame and the basic ins...