2012-03-26 21:45:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
2018-04-14 14:51:15 +00:00
|
|
|
* Copyright (C) 1992-2018 Kicad Developers, see AUTHORS.txt for contributors.
|
2012-03-26 21:45:05 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2011-09-30 18:15:37 +00:00
|
|
|
*/
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
/**
|
|
|
|
* @file dialog_page_settings.cpp
|
2010-03-14 10:34:40 +00:00
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2019-01-06 16:43:12 +00:00
|
|
|
#include <macros.h> // arrayDim()
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <common.h>
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
#include <project.h>
|
2013-07-19 18:27:22 +00:00
|
|
|
#include <confirm.h>
|
2012-03-26 21:45:05 +00:00
|
|
|
#include <gr_basic.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <base_struct.h>
|
|
|
|
#include <class_drawpanel.h>
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <title_block.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <draw_frame.h>
|
2013-07-19 18:27:22 +00:00
|
|
|
#include <worksheet_shape_builder.h>
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <base_screen.h>
|
2013-08-09 16:19:52 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <wx/valgen.h>
|
2011-12-31 05:44:00 +00:00
|
|
|
#include <wx/tokenzr.h>
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
#ifdef EESCHEMA
|
2018-01-30 08:56:43 +00:00
|
|
|
#include <sch_screen.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
2010-03-14 10:34:40 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
#include <worksheet.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_page_settings.h>
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2018-08-04 11:18:15 +00:00
|
|
|
#define MAX_PAGE_EXAMPLE_SIZE 200
|
|
|
|
|
2013-01-18 06:04:25 +00:00
|
|
|
|
2012-03-27 16:41:13 +00:00
|
|
|
// List of page formats.
|
2016-01-21 10:15:13 +00:00
|
|
|
// they are prefixed by "_HKI" (already in use for hotkeys) instead of "_",
|
|
|
|
// because we need both the translated and the not translated version.
|
2018-04-14 14:51:15 +00:00
|
|
|
// when displayed in dialog we should explicitly call wxGetTranslation()
|
2012-03-27 16:41:13 +00:00
|
|
|
// to show the translated version.
|
2016-01-21 10:15:13 +00:00
|
|
|
// See hotkeys_basic.h for more info
|
|
|
|
#define _HKI( x ) wxT( x )
|
2013-04-18 18:54:03 +00:00
|
|
|
static const wxString pageFmts[] =
|
2012-03-27 16:41:13 +00:00
|
|
|
{
|
2016-01-21 10:15:13 +00:00
|
|
|
_HKI("A4 210x297mm"),
|
|
|
|
_HKI("A3 297x420mm"),
|
|
|
|
_HKI("A2 420x594mm"),
|
|
|
|
_HKI("A1 594x841mm"),
|
|
|
|
_HKI("A0 841x1189mm"),
|
|
|
|
_HKI("A 8.5x11in"),
|
|
|
|
_HKI("B 11x17in"),
|
|
|
|
_HKI("C 17x22in"),
|
|
|
|
_HKI("D 22x34in"),
|
|
|
|
_HKI("E 34x44in"),
|
|
|
|
_HKI("USLetter 8.5x11in"), // USLetter without space is correct
|
|
|
|
_HKI("USLegal 8.5x14in"), // USLegal without space is correct
|
|
|
|
_HKI("USLedger 11x17in"), // USLedger without space is correct
|
|
|
|
_HKI("User (Custom)"), // size defined by user. The string must contain "Custom"
|
2018-04-14 14:51:15 +00:00
|
|
|
// to be recognized in code
|
2012-03-27 16:41:13 +00:00
|
|
|
};
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event )
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2018-08-04 11:18:15 +00:00
|
|
|
FRAME_T smallSizeFrames[] =
|
|
|
|
{
|
|
|
|
FRAME_PCB, FRAME_PCB_MODULE_EDITOR, FRAME_PCB_MODULE_VIEWER,
|
2018-08-11 16:04:46 +00:00
|
|
|
FRAME_PCB_MODULE_VIEWER_MODAL, FRAME_PCB_FOOTPRINT_WIZARD,
|
2018-08-04 11:18:15 +00:00
|
|
|
FRAME_PCB_FOOTPRINT_PREVIEW,
|
|
|
|
FRAME_CVPCB_DISPLAY
|
|
|
|
};
|
|
|
|
|
|
|
|
// Fix the max page size: it is MAX_PAGE_SIZE_EDITORS
|
|
|
|
// or MAX_PAGE_SIZE_PCBNEW for Pcbnew draw frames, due to the small internal
|
|
|
|
// units that do not allow too large draw areas
|
|
|
|
wxSize maxPageSize( MAX_PAGE_SIZE_EDITORS_MILS, MAX_PAGE_SIZE_EDITORS_MILS );
|
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
for( unsigned ii = 0; ii < arrayDim( smallSizeFrames ); ii++ )
|
2018-08-04 11:18:15 +00:00
|
|
|
{
|
|
|
|
if( IsType( smallSizeFrames[ii] ) )
|
|
|
|
{
|
|
|
|
maxPageSize.x = maxPageSize.y = MAX_PAGE_SIZE_PCBNEW_MILS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DIALOG_PAGES_SETTINGS dlg( this, maxPageSize );
|
2013-07-19 18:27:22 +00:00
|
|
|
dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName );
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2015-06-14 17:58:57 +00:00
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
|
|
|
{
|
2018-10-16 12:20:09 +00:00
|
|
|
#ifdef EESCHEMA
|
|
|
|
RedrawScreen( wxPoint( 0, 0 ), false );
|
|
|
|
#else
|
|
|
|
GetCanvas()->Refresh();
|
|
|
|
#endif
|
2015-06-14 17:58:57 +00:00
|
|
|
}
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-04 11:18:15 +00:00
|
|
|
DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent, wxSize aMaxUserSizeMils ) :
|
2011-12-22 21:57:50 +00:00
|
|
|
DIALOG_PAGES_SETTINGS_BASE( parent ),
|
2018-06-14 08:26:11 +00:00
|
|
|
m_initialized( false ),
|
2018-11-29 18:59:38 +00:00
|
|
|
m_customSizeX( parent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits, false ),
|
|
|
|
m_customSizeY( parent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits, false )
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2013-07-19 18:27:22 +00:00
|
|
|
m_parent = parent;
|
|
|
|
m_screen = m_parent->GetScreen();
|
2014-12-31 12:31:19 +00:00
|
|
|
m_projectPath = Prj().GetProjectPath();
|
2012-03-26 21:45:05 +00:00
|
|
|
m_page_bitmap = NULL;
|
2018-08-04 11:18:15 +00:00
|
|
|
m_maxPageSizeMils = aMaxUserSizeMils;
|
2013-07-19 18:27:22 +00:00
|
|
|
m_tb = m_parent->GetTitleBlock();
|
2013-01-19 09:58:25 +00:00
|
|
|
m_customFmt = false;
|
2013-07-19 18:27:22 +00:00
|
|
|
m_localPrjConfigChanged = false;
|
2014-12-31 12:31:19 +00:00
|
|
|
m_pagelayout = NULL;
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2016-01-01 08:39:12 +00:00
|
|
|
m_PickDate->SetValue( wxDateTime::Now() );
|
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
initDialog();
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2010-03-14 10:34:40 +00:00
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2010-03-14 10:34:40 +00:00
|
|
|
DIALOG_PAGES_SETTINGS::~DIALOG_PAGES_SETTINGS()
|
|
|
|
{
|
2014-12-31 12:31:19 +00:00
|
|
|
delete m_page_bitmap;
|
|
|
|
delete m_pagelayout;
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2010-03-14 10:34:40 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::initDialog()
|
|
|
|
{
|
2011-12-22 21:57:50 +00:00
|
|
|
wxString msg;
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2018-04-14 14:51:15 +00:00
|
|
|
// initialize page format choice box and page format list.
|
2013-01-19 09:58:25 +00:00
|
|
|
// The first shows translated strings, the second contains not translated strings
|
2012-03-27 16:41:13 +00:00
|
|
|
m_paperSizeComboBox->Clear();
|
2012-04-16 23:31:29 +00:00
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
for( unsigned ii = 0; ii < arrayDim(pageFmts); ii++ )
|
2012-03-27 16:41:13 +00:00
|
|
|
{
|
|
|
|
m_pageFmt.Add( pageFmts[ii] );
|
|
|
|
m_paperSizeComboBox->Append( wxGetTranslation( pageFmts[ii] ) );
|
|
|
|
}
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// initialize the page layout descr filename
|
2013-08-09 16:19:52 +00:00
|
|
|
SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#ifdef EESCHEMA
|
2012-10-04 06:57:15 +00:00
|
|
|
// Init display value for schematic sub-sheet number
|
2010-03-14 10:34:40 +00:00
|
|
|
wxString format = m_TextSheetCount->GetLabel();
|
2013-07-19 18:27:22 +00:00
|
|
|
msg.Printf( format, m_screen->m_NumberOfScreens );
|
2011-03-14 15:17:18 +00:00
|
|
|
m_TextSheetCount->SetLabel( msg );
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2010-03-14 10:34:40 +00:00
|
|
|
format = m_TextSheetNumber->GetLabel();
|
2013-07-19 18:27:22 +00:00
|
|
|
msg.Printf( format, m_screen->m_ScreenNumber );
|
2011-03-14 15:17:18 +00:00
|
|
|
m_TextSheetNumber->SetLabel( msg );
|
2012-01-23 04:33:36 +00:00
|
|
|
#else
|
2012-04-16 23:31:29 +00:00
|
|
|
m_TextSheetCount->Show( false );
|
|
|
|
m_TextSheetNumber->Show( false );
|
2012-01-23 04:33:36 +00:00
|
|
|
#endif
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
m_pageInfo = m_parent->GetPageSettings();
|
2012-03-26 21:45:05 +00:00
|
|
|
SetCurrentPageSizeSelection( m_pageInfo.GetType() );
|
|
|
|
m_orientationComboBox->SetSelection( m_pageInfo.IsPortrait() );
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-01-17 14:58:58 +00:00
|
|
|
// only a click fires the "selection changed" event, so have to fabricate this check
|
|
|
|
wxCommandEvent dummy;
|
2012-03-26 21:45:05 +00:00
|
|
|
OnPaperSizeChoice( dummy );
|
2012-01-16 04:11:43 +00:00
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
if( m_customFmt )
|
2013-01-19 09:58:25 +00:00
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
m_customSizeX.SetValue( m_pageInfo.GetWidthMils() * IU_PER_MILS );
|
|
|
|
m_customSizeY.SetValue( m_pageInfo.GetHeightMils() * IU_PER_MILS );
|
2013-01-19 09:58:25 +00:00
|
|
|
}
|
2018-06-14 08:26:11 +00:00
|
|
|
else
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
m_customSizeX.SetValue( m_pageInfo.GetCustomWidthMils() * IU_PER_MILS );
|
|
|
|
m_customSizeY.SetValue( m_pageInfo.GetCustomHeightMils() * IU_PER_MILS );
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
2010-07-12 14:07:09 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
m_TextRevision->SetValue( m_tb.GetRevision() );
|
2013-05-23 18:45:23 +00:00
|
|
|
m_TextDate->SetValue( m_tb.GetDate() );
|
2012-03-26 21:45:05 +00:00
|
|
|
m_TextTitle->SetValue( m_tb.GetTitle() );
|
|
|
|
m_TextCompany->SetValue( m_tb.GetCompany() );
|
|
|
|
m_TextComment1->SetValue( m_tb.GetComment1() );
|
|
|
|
m_TextComment2->SetValue( m_tb.GetComment2() );
|
|
|
|
m_TextComment3->SetValue( m_tb.GetComment3() );
|
|
|
|
m_TextComment4->SetValue( m_tb.GetComment4() );
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
#ifndef EESCHEMA
|
2015-06-14 17:58:57 +00:00
|
|
|
// these options have meaning only for Eeschema.
|
|
|
|
// disable them for other apps
|
2011-03-14 15:17:18 +00:00
|
|
|
m_RevisionExport->Show( false );
|
2013-05-23 18:45:23 +00:00
|
|
|
m_DateExport->Show( false );
|
2011-03-14 15:17:18 +00:00
|
|
|
m_TitleExport->Show( false );
|
|
|
|
m_CompanyExport->Show( false );
|
|
|
|
m_Comment1Export->Show( false );
|
|
|
|
m_Comment2Export->Show( false );
|
|
|
|
m_Comment3Export->Show( false );
|
|
|
|
m_Comment4Export->Show( false );
|
2010-03-14 10:34:40 +00:00
|
|
|
#endif
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
UpdatePageLayoutExample();
|
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
// Make the OK button the default.
|
2015-06-14 17:58:57 +00:00
|
|
|
m_sdbSizerOK->SetDefault();
|
2012-03-26 21:45:05 +00:00
|
|
|
m_initialized = true;
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event )
|
|
|
|
{
|
2018-11-29 18:59:38 +00:00
|
|
|
if( !m_customSizeX.Validate( Mils2iu( MIN_PAGE_SIZE ), Mils2iu( m_maxPageSizeMils.x ) ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( !m_customSizeY.Validate( Mils2iu( MIN_PAGE_SIZE ), Mils2iu( m_maxPageSizeMils.y ) ) )
|
|
|
|
return;
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
if( SavePageSettings() )
|
2012-03-26 21:45:05 +00:00
|
|
|
{
|
2013-07-19 18:27:22 +00:00
|
|
|
m_screen->SetModify();
|
|
|
|
|
2014-12-31 12:31:19 +00:00
|
|
|
if( LocalPrjConfigChanged() )
|
2018-10-09 09:29:48 +00:00
|
|
|
m_parent->SaveProjectSettings( false );
|
2018-11-20 14:11:22 +00:00
|
|
|
|
|
|
|
// Call the post processing (if any) after changes
|
|
|
|
m_parent->OnPageSettingsChange();
|
2012-03-26 21:45:05 +00:00
|
|
|
}
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2015-06-14 17:58:57 +00:00
|
|
|
event.Skip();
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
|
2012-01-16 04:11:43 +00:00
|
|
|
{
|
2012-03-27 16:41:13 +00:00
|
|
|
int idx = m_paperSizeComboBox->GetSelection();
|
2012-04-16 23:31:29 +00:00
|
|
|
|
2012-03-27 16:41:13 +00:00
|
|
|
if( idx < 0 )
|
|
|
|
idx = 0;
|
2012-04-16 23:31:29 +00:00
|
|
|
|
2012-03-27 16:41:13 +00:00
|
|
|
const wxString paperType = m_pageFmt[idx];
|
2012-04-16 23:31:29 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
if( paperType.Contains( PAGE_INFO::Custom ) )
|
2012-01-16 04:11:43 +00:00
|
|
|
{
|
2012-01-16 20:48:32 +00:00
|
|
|
m_orientationComboBox->Enable( false );
|
2018-06-14 08:26:11 +00:00
|
|
|
m_customSizeX.Enable( true );
|
|
|
|
m_customSizeY.Enable( true );
|
2013-01-19 09:58:25 +00:00
|
|
|
m_customFmt = true;
|
2012-01-16 04:11:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-16 20:48:32 +00:00
|
|
|
m_orientationComboBox->Enable( true );
|
2012-04-16 23:31:29 +00:00
|
|
|
|
2013-10-11 16:24:43 +00:00
|
|
|
#if 0
|
|
|
|
// ForcePortrait() does not exist, but could be useful.
|
|
|
|
// so I leave these lines, which could be seen as a todo feature
|
|
|
|
if( paperType.ForcePortrait() )
|
2012-03-26 21:45:05 +00:00
|
|
|
{
|
|
|
|
m_orientationComboBox->SetStringSelection( _( "Portrait" ) );
|
|
|
|
m_orientationComboBox->Enable( false );
|
2012-04-16 23:31:29 +00:00
|
|
|
}
|
2013-10-11 16:24:43 +00:00
|
|
|
#endif
|
2018-06-14 08:26:11 +00:00
|
|
|
m_customSizeX.Enable( false );
|
|
|
|
m_customSizeY.Enable( false );
|
2013-01-19 09:58:25 +00:00
|
|
|
m_customFmt = false;
|
2012-01-16 04:11:43 +00:00
|
|
|
}
|
2012-04-16 23:31:29 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
UpdatePageLayoutExample();
|
2012-01-16 04:11:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::OnUserPageSizeXTextUpdated( wxCommandEvent& event )
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
if( m_initialized )
|
2012-03-26 21:45:05 +00:00
|
|
|
{
|
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
UpdatePageLayoutExample();
|
|
|
|
}
|
|
|
|
}
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::OnUserPageSizeYTextUpdated( wxCommandEvent& event )
|
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
if( m_initialized )
|
2012-03-26 21:45:05 +00:00
|
|
|
{
|
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
UpdatePageLayoutExample();
|
|
|
|
}
|
|
|
|
}
|
2012-01-15 21:07:01 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::OnPageOrientationChoice( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_initialized )
|
|
|
|
{
|
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
UpdatePageLayoutExample();
|
|
|
|
}
|
|
|
|
}
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
|
|
|
|
void DIALOG_PAGES_SETTINGS::OnRevisionTextUpdated( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_initialized && m_TextRevision->IsModified() )
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2012-03-26 21:45:05 +00:00
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
m_tb.SetRevision( m_TextRevision->GetValue() );
|
|
|
|
UpdatePageLayoutExample();
|
|
|
|
}
|
|
|
|
}
|
2010-07-12 14:07:09 +00:00
|
|
|
|
|
|
|
|
2013-05-23 18:45:23 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::OnDateTextUpdated( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_initialized && m_TextDate->IsModified() )
|
|
|
|
{
|
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
m_tb.SetDate( m_TextDate->GetValue() );
|
|
|
|
UpdatePageLayoutExample();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::OnTitleTextUpdated( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_initialized && m_TextTitle->IsModified() )
|
|
|
|
{
|
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
m_tb.SetTitle( m_TextTitle->GetValue() );
|
|
|
|
UpdatePageLayoutExample();
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
2012-03-26 21:45:05 +00:00
|
|
|
}
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2012-01-15 21:07:01 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::OnCompanyTextUpdated( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_initialized && m_TextCompany->IsModified() )
|
|
|
|
{
|
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
m_tb.SetCompany( m_TextCompany->GetValue() );
|
|
|
|
UpdatePageLayoutExample();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PAGES_SETTINGS::OnComment1TextUpdated( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_initialized && m_TextComment1->IsModified() )
|
|
|
|
{
|
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
m_tb.SetComment1( m_TextComment1->GetValue() );
|
|
|
|
UpdatePageLayoutExample();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PAGES_SETTINGS::OnComment2TextUpdated( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_initialized && m_TextComment2->IsModified() )
|
|
|
|
{
|
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
m_tb.SetComment2( m_TextComment2->GetValue() );
|
|
|
|
UpdatePageLayoutExample();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PAGES_SETTINGS::OnComment3TextUpdated( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_initialized && m_TextComment3->IsModified() )
|
|
|
|
{
|
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
m_tb.SetComment3( m_TextComment3->GetValue() );
|
|
|
|
UpdatePageLayoutExample();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PAGES_SETTINGS::OnComment4TextUpdated( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_initialized && m_TextComment4->IsModified() )
|
|
|
|
{
|
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
m_tb.SetComment4( m_TextComment4->GetValue() );
|
|
|
|
UpdatePageLayoutExample();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-14 17:58:57 +00:00
|
|
|
|
2013-05-23 18:45:23 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::OnDateApplyClick( wxCommandEvent& event )
|
|
|
|
{
|
2015-06-14 17:58:57 +00:00
|
|
|
wxDateTime datetime = m_PickDate->GetValue();
|
|
|
|
wxString date =
|
|
|
|
// We can choose different formats. Only one must be uncommented
|
|
|
|
//
|
|
|
|
// datetime.Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
|
|
|
|
// datetime.Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
|
|
|
|
// datetime.Format( wxT("%Y-%b-%d") );
|
|
|
|
datetime.FormatISODate();
|
|
|
|
|
|
|
|
m_TextDate->SetValue( date );
|
2013-05-23 18:45:23 +00:00
|
|
|
}
|
2012-01-16 20:48:32 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
bool DIALOG_PAGES_SETTINGS::SavePageSettings()
|
2012-03-26 21:45:05 +00:00
|
|
|
{
|
2018-11-29 18:59:38 +00:00
|
|
|
bool success = false;
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2013-08-09 16:19:52 +00:00
|
|
|
wxString fileName = GetWksFileName();
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-08-09 16:19:52 +00:00
|
|
|
if( fileName != BASE_SCREEN::m_PageLayoutDescrFileName )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
wxString fullFileName = WORKSHEET_LAYOUT::MakeFullFileName( fileName, m_projectPath );
|
2014-12-31 12:31:19 +00:00
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Page layout description file \"%s\" not found." ),
|
|
|
|
GetChars( fullFileName ) );
|
|
|
|
wxMessageBox( msg );
|
|
|
|
return false;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2013-08-09 16:19:52 +00:00
|
|
|
BASE_SCREEN::m_PageLayoutDescrFileName = fileName;
|
2013-07-19 18:27:22 +00:00
|
|
|
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
|
2014-12-31 12:31:19 +00:00
|
|
|
pglayout.SetPageLayout( fullFileName );
|
2013-07-19 18:27:22 +00:00
|
|
|
m_localPrjConfigChanged = true;
|
|
|
|
}
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
|
2012-03-27 16:41:13 +00:00
|
|
|
const wxString paperType = m_pageFmt[idx];
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2012-01-16 20:48:32 +00:00
|
|
|
if( paperType.Contains( PAGE_INFO::Custom ) )
|
|
|
|
{
|
2012-03-26 21:45:05 +00:00
|
|
|
GetCustomSizeMilsFromDialog();
|
|
|
|
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::Custom );
|
2012-04-16 23:31:29 +00:00
|
|
|
|
2018-11-29 18:59:38 +00:00
|
|
|
if( success )
|
2012-03-26 21:45:05 +00:00
|
|
|
{
|
|
|
|
PAGE_INFO::SetCustomWidthMils( m_layout_size.x );
|
|
|
|
PAGE_INFO::SetCustomHeightMils( m_layout_size.y );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2012-04-02 18:11:00 +00:00
|
|
|
m_pageInfo.SetWidthMils( m_layout_size.x );
|
|
|
|
m_pageInfo.SetHeightMils( m_layout_size.y );
|
2012-03-26 21:45:05 +00:00
|
|
|
}
|
2012-01-16 20:48:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-26 21:45:05 +00:00
|
|
|
// search for longest common string first, e.g. A4 before A
|
|
|
|
if( paperType.Contains( PAGE_INFO::USLetter ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::USLetter );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::USLegal ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::USLegal );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::USLedger ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::USLedger );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::GERBER ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::GERBER );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::A4 ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::A4 );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::A3 ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::A3 );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::A2 ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::A2 );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::A1 ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::A1 );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::A0 ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::A0 );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::A ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::A );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::B ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::B );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::C ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::C );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::D ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::D );
|
2012-03-26 21:45:05 +00:00
|
|
|
else if( paperType.Contains( PAGE_INFO::E ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
success = m_pageInfo.SetType( PAGE_INFO::E );
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2018-11-29 18:59:38 +00:00
|
|
|
if( success )
|
2012-01-16 20:48:32 +00:00
|
|
|
{
|
2012-03-26 21:45:05 +00:00
|
|
|
int choice = m_orientationComboBox->GetSelection();
|
|
|
|
m_pageInfo.SetPortrait( choice != 0 );
|
2012-01-16 20:48:32 +00:00
|
|
|
}
|
2012-03-26 21:45:05 +00:00
|
|
|
}
|
2012-01-17 14:58:58 +00:00
|
|
|
|
2018-11-29 18:59:38 +00:00
|
|
|
if( !success )
|
2012-03-26 21:45:05 +00:00
|
|
|
{
|
2018-06-13 00:05:25 +00:00
|
|
|
wxASSERT_MSG( false, _( "the translation for paper size must preserve original spellings" ) );
|
2012-03-26 21:45:05 +00:00
|
|
|
m_pageInfo.SetType( PAGE_INFO::A4 );
|
2012-01-16 20:48:32 +00:00
|
|
|
}
|
2012-01-16 04:11:43 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
m_parent->SetPageSettings( m_pageInfo );
|
2012-03-26 21:45:05 +00:00
|
|
|
|
|
|
|
m_tb.SetRevision( m_TextRevision->GetValue() );
|
2013-05-23 18:45:23 +00:00
|
|
|
m_tb.SetDate( m_TextDate->GetValue() );
|
2012-03-26 21:45:05 +00:00
|
|
|
m_tb.SetCompany( m_TextCompany->GetValue() );
|
|
|
|
m_tb.SetTitle( m_TextTitle->GetValue() );
|
|
|
|
m_tb.SetComment1( m_TextComment1->GetValue() );
|
|
|
|
m_tb.SetComment2( m_TextComment2->GetValue() );
|
|
|
|
m_tb.SetComment3( m_TextComment3->GetValue() );
|
|
|
|
m_tb.SetComment4( m_TextComment4->GetValue() );
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
m_parent->SetTitleBlock( m_tb );
|
|
|
|
|
2012-01-15 21:07:01 +00:00
|
|
|
|
2010-03-14 10:34:40 +00:00
|
|
|
#ifdef EESCHEMA
|
2011-12-31 05:44:00 +00:00
|
|
|
// Exports settings to other sheets if requested:
|
2011-03-14 15:17:18 +00:00
|
|
|
SCH_SCREEN* screen;
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
// Build the screen list
|
2010-10-26 20:25:48 +00:00
|
|
|
SCH_SCREENS ScreenList;
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
// Update title blocks for all screens
|
2010-03-14 10:34:40 +00:00
|
|
|
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
|
|
|
|
{
|
2013-07-19 18:27:22 +00:00
|
|
|
if( screen == m_screen )
|
2010-03-14 10:34:40 +00:00
|
|
|
continue;
|
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
TITLE_BLOCK tb2 = screen->GetTitleBlock();
|
|
|
|
|
2010-03-14 10:34:40 +00:00
|
|
|
if( m_RevisionExport->IsChecked() )
|
2012-03-26 21:45:05 +00:00
|
|
|
tb2.SetRevision( m_tb.GetRevision() );
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2013-05-23 18:45:23 +00:00
|
|
|
if( m_DateExport->IsChecked() )
|
|
|
|
tb2.SetDate( m_tb.GetDate() );
|
|
|
|
|
2010-03-14 10:34:40 +00:00
|
|
|
if( m_TitleExport->IsChecked() )
|
2012-03-26 21:45:05 +00:00
|
|
|
tb2.SetTitle( m_tb.GetTitle() );
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
if( m_CompanyExport->IsChecked() )
|
2012-03-26 21:45:05 +00:00
|
|
|
tb2.SetCompany( m_tb.GetCompany() );
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
if( m_Comment1Export->IsChecked() )
|
2012-03-26 21:45:05 +00:00
|
|
|
tb2.SetComment1( m_tb.GetComment1() );
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
if( m_Comment2Export->IsChecked() )
|
2012-03-26 21:45:05 +00:00
|
|
|
tb2.SetComment2( m_tb.GetComment2() );
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
if( m_Comment3Export->IsChecked() )
|
2012-03-26 21:45:05 +00:00
|
|
|
tb2.SetComment3( m_tb.GetComment3() );
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
if( m_Comment4Export->IsChecked() )
|
2012-03-26 21:45:05 +00:00
|
|
|
tb2.SetComment4( m_tb.GetComment4() );
|
2012-01-09 08:35:06 +00:00
|
|
|
|
|
|
|
screen->SetTitleBlock( tb2 );
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2010-03-14 10:34:40 +00:00
|
|
|
#endif
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
return true;
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::SetCurrentPageSizeSelection( const wxString& aPaperSize )
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2012-03-27 16:41:13 +00:00
|
|
|
// search all the not translated label list containing our paper type
|
|
|
|
for( unsigned i = 0; i < m_pageFmt.GetCount(); ++i )
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2012-01-09 08:35:06 +00:00
|
|
|
// parse each label looking for aPaperSize within it
|
2012-03-27 16:41:13 +00:00
|
|
|
wxStringTokenizer st( m_pageFmt[i] );
|
2011-12-31 05:44:00 +00:00
|
|
|
|
|
|
|
while( st.HasMoreTokens() )
|
2011-12-22 21:57:50 +00:00
|
|
|
{
|
2012-01-09 08:35:06 +00:00
|
|
|
if( st.GetNextToken() == aPaperSize )
|
2011-12-31 05:44:00 +00:00
|
|
|
{
|
2012-01-16 20:48:32 +00:00
|
|
|
m_paperSizeComboBox->SetSelection( i );
|
2011-12-31 05:44:00 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-12-22 21:57:50 +00:00
|
|
|
}
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
|
|
|
|
void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
|
|
|
|
{
|
|
|
|
int lyWidth, lyHeight;
|
|
|
|
|
2018-08-04 11:18:15 +00:00
|
|
|
wxSize clamped_layout_size( Clamp( MIN_PAGE_SIZE, m_layout_size.x, m_maxPageSizeMils.x ),
|
|
|
|
Clamp( MIN_PAGE_SIZE, m_layout_size.y, m_maxPageSizeMils.y ) );
|
2012-03-26 21:45:05 +00:00
|
|
|
|
|
|
|
double lyRatio = clamped_layout_size.x < clamped_layout_size.y ?
|
|
|
|
(double) clamped_layout_size.y / clamped_layout_size.x :
|
|
|
|
(double) clamped_layout_size.x / clamped_layout_size.y;
|
|
|
|
|
|
|
|
if( clamped_layout_size.x < clamped_layout_size.y )
|
|
|
|
{
|
|
|
|
lyHeight = MAX_PAGE_EXAMPLE_SIZE;
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
lyWidth = KiROUND( (double) lyHeight / lyRatio );
|
2012-03-26 21:45:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lyWidth = MAX_PAGE_EXAMPLE_SIZE;
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
lyHeight = KiROUND( (double) lyWidth / lyRatio );
|
2012-03-26 21:45:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_page_bitmap )
|
|
|
|
{
|
|
|
|
m_PageLayoutExampleBitmap->SetBitmap( wxNullBitmap );
|
|
|
|
delete m_page_bitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_page_bitmap = new wxBitmap( lyWidth + 1, lyHeight + 1 );
|
2012-04-16 23:31:29 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
if( m_page_bitmap->IsOk() )
|
|
|
|
{
|
2019-02-23 14:22:27 +00:00
|
|
|
double scaleW = (double) lyWidth / clamped_layout_size.x;
|
|
|
|
double scaleH = (double) lyHeight / clamped_layout_size.y;
|
2012-03-26 21:45:05 +00:00
|
|
|
|
|
|
|
// Prepare DC.
|
2013-05-28 09:49:53 +00:00
|
|
|
wxSize example_size( lyWidth + 1, lyHeight + 1 );
|
2012-03-26 21:45:05 +00:00
|
|
|
wxMemoryDC memDC;
|
|
|
|
memDC.SelectObject( *m_page_bitmap );
|
2012-07-11 08:02:47 +00:00
|
|
|
memDC.SetClippingRegion( wxPoint( 0, 0 ), example_size );
|
2012-03-26 21:45:05 +00:00
|
|
|
memDC.Clear();
|
|
|
|
memDC.SetUserScale( scaleW, scaleH );
|
|
|
|
|
|
|
|
// Get logical page size and margins.
|
|
|
|
PAGE_INFO pageDUMMY;
|
|
|
|
|
2013-03-27 20:38:20 +00:00
|
|
|
// Get page type
|
|
|
|
int idx = m_paperSizeComboBox->GetSelection();
|
|
|
|
|
|
|
|
if( idx < 0 )
|
|
|
|
idx = 0;
|
|
|
|
|
2013-05-25 09:01:44 +00:00
|
|
|
wxString pageFmtName = m_pageFmt[idx].BeforeFirst( ' ' );
|
|
|
|
bool portrait = clamped_layout_size.x < clamped_layout_size.y;
|
|
|
|
pageDUMMY.SetType( pageFmtName, portrait );
|
|
|
|
if( m_customFmt )
|
|
|
|
{
|
|
|
|
pageDUMMY.SetWidthMils( clamped_layout_size.x );
|
|
|
|
pageDUMMY.SetHeightMils( clamped_layout_size.y );
|
|
|
|
}
|
2013-03-27 20:38:20 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
// Draw layout preview.
|
|
|
|
wxString emptyString;
|
2013-05-22 08:45:25 +00:00
|
|
|
GRResetPenAndBrush( &memDC );
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2014-12-31 12:31:19 +00:00
|
|
|
WORKSHEET_LAYOUT::SetAltInstance( m_pagelayout );
|
2019-02-23 14:22:27 +00:00
|
|
|
GRFilledRect( NULL, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, WHITE, WHITE );
|
2013-05-22 08:45:25 +00:00
|
|
|
DrawPageLayout( &memDC, NULL, pageDUMMY,
|
2013-05-25 09:01:44 +00:00
|
|
|
emptyString, emptyString,
|
2013-07-19 18:27:22 +00:00
|
|
|
m_tb, m_screen->m_NumberOfScreens,
|
2019-02-23 14:22:27 +00:00
|
|
|
m_screen->m_ScreenNumber, 1, 1, DARKGRAY, RED );
|
2012-03-26 21:45:05 +00:00
|
|
|
|
|
|
|
memDC.SelectObject( wxNullBitmap );
|
|
|
|
m_PageLayoutExampleBitmap->SetBitmap( *m_page_bitmap );
|
2014-12-31 12:31:19 +00:00
|
|
|
WORKSHEET_LAYOUT::SetAltInstance( NULL );
|
2012-03-26 21:45:05 +00:00
|
|
|
|
|
|
|
// Refresh the dialog.
|
|
|
|
Layout();
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog()
|
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
|
2012-03-27 16:41:13 +00:00
|
|
|
const wxString paperType = m_pageFmt[idx];
|
2012-03-26 21:45:05 +00:00
|
|
|
|
|
|
|
// here we assume translators will keep original paper size spellings
|
|
|
|
if( paperType.Contains( PAGE_INFO::Custom ) )
|
|
|
|
{
|
|
|
|
GetCustomSizeMilsFromDialog();
|
2012-04-16 23:31:29 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
if( m_layout_size.x && m_layout_size.y )
|
|
|
|
{
|
|
|
|
if( m_layout_size.x < m_layout_size.y )
|
|
|
|
m_orientationComboBox->SetStringSelection( _( "Portrait" ) );
|
|
|
|
else
|
|
|
|
m_orientationComboBox->SetStringSelection( _( "Landscape" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PAGE_INFO pageInfo; // SetType() later to lookup size
|
|
|
|
|
2014-06-11 05:00:30 +00:00
|
|
|
static const wxChar* papers[] = {
|
2012-03-26 21:45:05 +00:00
|
|
|
// longest common string first, since sequential search below
|
2014-06-11 05:00:30 +00:00
|
|
|
PAGE_INFO::A4,
|
|
|
|
PAGE_INFO::A3,
|
|
|
|
PAGE_INFO::A2,
|
|
|
|
PAGE_INFO::A1,
|
|
|
|
PAGE_INFO::A0,
|
|
|
|
PAGE_INFO::A,
|
|
|
|
PAGE_INFO::B,
|
|
|
|
PAGE_INFO::C,
|
|
|
|
PAGE_INFO::D,
|
|
|
|
PAGE_INFO::E,
|
|
|
|
PAGE_INFO::USLetter,
|
|
|
|
PAGE_INFO::USLegal,
|
|
|
|
PAGE_INFO::USLedger,
|
2012-03-26 21:45:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned i;
|
2012-04-16 23:31:29 +00:00
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
for( i=0; i < arrayDim( papers ); ++i )
|
2012-03-26 21:45:05 +00:00
|
|
|
{
|
2014-10-17 08:14:30 +00:00
|
|
|
if( paperType.Contains( papers[i] ) )
|
2012-03-26 21:45:05 +00:00
|
|
|
{
|
2014-10-17 08:14:30 +00:00
|
|
|
pageInfo.SetType( papers[i] );
|
2012-03-26 21:45:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
wxASSERT( i != arrayDim(papers) ); // dialog UI match the above list?
|
2012-03-26 21:45:05 +00:00
|
|
|
|
|
|
|
m_layout_size = pageInfo.GetSizeMils();
|
|
|
|
|
|
|
|
// swap sizes to match orientation
|
|
|
|
bool isPortrait = (bool) m_orientationComboBox->GetSelection();
|
|
|
|
|
|
|
|
if( ( isPortrait && m_layout_size.x >= m_layout_size.y ) ||
|
|
|
|
( !isPortrait && m_layout_size.x < m_layout_size.y ) )
|
|
|
|
{
|
|
|
|
m_layout_size.Set( m_layout_size.y, m_layout_size.x );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PAGES_SETTINGS::GetCustomSizeMilsFromDialog()
|
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
double customSizeX = (double) m_customSizeX.GetValue() / IU_PER_MILS;
|
|
|
|
double customSizeY = (double) m_customSizeY.GetValue() / IU_PER_MILS;
|
2012-03-26 21:45:05 +00:00
|
|
|
|
|
|
|
// Prepare to painless double -> int conversion.
|
|
|
|
customSizeX = Clamp( double( INT_MIN ), customSizeX, double( INT_MAX ) );
|
|
|
|
customSizeY = Clamp( double( INT_MIN ), customSizeY, double( INT_MAX ) );
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
m_layout_size = wxSize( KiROUND( customSizeX ), KiROUND( customSizeY ) );
|
2012-03-26 21:45:05 +00:00
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2018-04-14 14:51:15 +00:00
|
|
|
|
2013-08-09 16:19:52 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2018-04-14 14:51:15 +00:00
|
|
|
wxFileName fn = GetWksFileName();
|
|
|
|
wxString name = GetWksFileName();
|
|
|
|
wxString path;
|
|
|
|
|
|
|
|
if( fn.IsAbsolute() )
|
|
|
|
{
|
|
|
|
path = fn.GetPath();
|
|
|
|
name = fn.GetFullName();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
path = m_projectPath;
|
|
|
|
}
|
|
|
|
|
2013-08-09 16:19:52 +00:00
|
|
|
// Display a file picker dialog
|
2017-11-12 00:31:38 +00:00
|
|
|
wxFileDialog fileDialog( this, _( "Select Page Layout Description File" ),
|
2018-04-14 14:51:15 +00:00
|
|
|
path, name, PageLayoutDescrFileWildcard(),
|
2013-08-09 16:19:52 +00:00
|
|
|
wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
|
|
|
|
|
|
|
|
if( fileDialog.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString fileName = fileDialog.GetPath();
|
|
|
|
|
|
|
|
// Try to remove the path, if the path is the current working dir,
|
2014-12-31 12:31:19 +00:00
|
|
|
// or the dir of kicad.pro (template), and use a relative path
|
|
|
|
wxString shortFileName = WORKSHEET_LAYOUT::MakeShortFileName( fileName, m_projectPath );
|
2013-08-09 16:19:52 +00:00
|
|
|
|
|
|
|
// For Win/Linux/macOS compatibility, a relative path is a good idea
|
2014-12-31 12:31:19 +00:00
|
|
|
if( shortFileName != GetWksFileName() && shortFileName != fileName )
|
2013-08-09 16:19:52 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString msg = wxString::Format( _(
|
2018-04-14 14:51:15 +00:00
|
|
|
"The page layout description file name has changed.\n"
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
"Do you want to use the relative path:\n"
|
2017-12-15 11:37:46 +00:00
|
|
|
"\"%s\"\n"
|
2014-12-31 12:31:19 +00:00
|
|
|
"instead of\n"
|
2018-04-14 14:51:15 +00:00
|
|
|
"\"%s\"?" ), GetChars( shortFileName ), GetChars( fileName ) );
|
2014-12-31 12:31:19 +00:00
|
|
|
|
|
|
|
if( !IsOK( this, msg ) )
|
|
|
|
shortFileName = fileName;
|
2013-08-09 16:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetWksFileName( shortFileName );
|
2014-12-31 12:31:19 +00:00
|
|
|
|
|
|
|
if( m_pagelayout == NULL )
|
|
|
|
m_pagelayout = new WORKSHEET_LAYOUT;
|
|
|
|
|
|
|
|
m_pagelayout->SetPageLayout( fileName );
|
|
|
|
|
|
|
|
GetPageLayoutInfoFromDialog();
|
|
|
|
UpdatePageLayoutExample();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|