2011-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file dialog_page_settings.cpp
|
|
|
|
*/
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
/* The "Page Settings" dialog box created by this file (and setpage.h)
|
|
|
|
* contains seven checkboxes which *are* shown when that dialog box is
|
2011-09-30 18:15:37 +00:00
|
|
|
* invoked in Eeschema, but which are *not* shown when that dialog box is
|
2010-03-14 10:34:40 +00:00
|
|
|
* invoked in Pcbnew instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "base_struct.h"
|
|
|
|
#include "class_drawpanel.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "class_sch_screen.h"
|
2010-03-14 10:34:40 +00:00
|
|
|
#include "wxstruct.h"
|
|
|
|
|
|
|
|
#include "wx/valgen.h"
|
|
|
|
|
|
|
|
#ifdef EESCHEMA
|
|
|
|
#include "general.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "dialog_page_settings.h"
|
|
|
|
|
|
|
|
#define NB_ITEMS 11
|
2011-03-14 15:17:18 +00:00
|
|
|
Ki_PageDescr* SheetList[NB_ITEMS + 1] =
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2011-03-14 15:17:18 +00:00
|
|
|
&g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0,
|
|
|
|
&g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E,
|
2010-03-14 10:34:40 +00:00
|
|
|
&g_Sheet_user, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event )
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2011-03-14 15:17:18 +00:00
|
|
|
DIALOG_PAGES_SETTINGS frame( this );
|
2010-03-14 10:34:40 +00:00
|
|
|
int diag = frame.ShowModal();
|
2011-03-14 15:17:18 +00:00
|
|
|
|
|
|
|
if( DrawPanel && diag )
|
2010-03-14 10:34:40 +00:00
|
|
|
DrawPanel->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ) :
|
2010-03-14 10:34:40 +00:00
|
|
|
DIALOG_PAGES_SETTINGS_BASE( parent )
|
|
|
|
{
|
2011-03-14 15:17:18 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
m_Screen = m_Parent->GetScreen();
|
2010-03-14 10:34:40 +00:00
|
|
|
m_Modified = 0;
|
2011-03-14 15:17:18 +00:00
|
|
|
m_SelectedSheet = NULL;
|
2010-03-14 10:34:40 +00:00
|
|
|
m_CurrentSelection = 0;
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2010-03-14 10:34:40 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::initDialog()
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
SetFocus();
|
|
|
|
SearchPageSizeSelection();
|
|
|
|
|
|
|
|
// Init display value for sheet User size
|
|
|
|
wxString format = m_TextSheetCount->GetLabel();
|
2011-03-14 15:17:18 +00:00
|
|
|
msg.Printf( format, m_Screen->m_NumberOfScreen );
|
|
|
|
m_TextSheetCount->SetLabel( msg );
|
2010-03-14 10:34:40 +00:00
|
|
|
format = m_TextSheetNumber->GetLabel();
|
2011-03-14 15:17:18 +00:00
|
|
|
msg.Printf( format, m_Screen->m_ScreenNumber );
|
|
|
|
m_TextSheetNumber->SetLabel( msg );
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
switch( g_UserUnit )
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2010-07-12 14:07:09 +00:00
|
|
|
case MILLIMETRES:
|
2011-03-14 15:17:18 +00:00
|
|
|
UserSizeX = (double) g_Sheet_user.m_Size.x * 25.4 / 1000;
|
|
|
|
UserSizeY = (double) g_Sheet_user.m_Size.y * 25.4 / 1000;
|
2010-07-12 14:07:09 +00:00
|
|
|
msg.Printf( wxT( "%.2f" ), UserSizeX );
|
|
|
|
m_TextUserSizeX->SetValue( msg );
|
|
|
|
msg.Printf( wxT( "%.2f" ), UserSizeY );
|
|
|
|
m_TextUserSizeY->SetValue( msg );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INCHES:
|
2011-03-14 15:17:18 +00:00
|
|
|
UserSizeX = (double) g_Sheet_user.m_Size.x / 1000;
|
|
|
|
UserSizeY = (double) g_Sheet_user.m_Size.y / 1000;
|
2010-07-12 14:07:09 +00:00
|
|
|
msg.Printf( wxT( "%.3f" ), UserSizeX );
|
|
|
|
m_TextUserSizeX->SetValue( msg );
|
|
|
|
msg.Printf( wxT( "%.3f" ), UserSizeY );
|
|
|
|
m_TextUserSizeY->SetValue( msg );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNSCALED_UNITS:
|
2011-03-14 15:17:18 +00:00
|
|
|
UserSizeX = g_Sheet_user.m_Size.x;
|
|
|
|
UserSizeY = g_Sheet_user.m_Size.y;
|
2010-07-12 14:07:09 +00:00
|
|
|
msg.Printf( wxT( "%f" ), UserSizeX );
|
|
|
|
m_TextUserSizeX->SetValue( msg );
|
|
|
|
msg.Printf( wxT( "%f" ), UserSizeY );
|
|
|
|
m_TextUserSizeY->SetValue( msg );
|
|
|
|
break;
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
2010-07-12 14:07:09 +00:00
|
|
|
|
2010-03-14 10:34:40 +00:00
|
|
|
// Set validators
|
2011-03-14 15:17:18 +00:00
|
|
|
m_PageSizeBox->SetValidator( wxGenericValidator( &m_CurrentSelection ) );
|
|
|
|
m_TextRevision->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Revision ) );
|
|
|
|
m_TextTitle->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Title ) );
|
|
|
|
m_TextCompany->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Company ) );
|
|
|
|
m_TextComment1->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Commentaire1 ) );
|
|
|
|
m_TextComment2->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Commentaire2 ) );
|
|
|
|
m_TextComment3->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Commentaire3 ) );
|
|
|
|
m_TextComment4->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Screen->m_Commentaire4 ) );
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
#ifndef EESCHEMA
|
2011-03-14 15:17:18 +00:00
|
|
|
m_RevisionExport->Show( false );
|
|
|
|
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
|
|
|
|
|
|
|
// Make the OK button the default.
|
|
|
|
m_sdbSizer1OK->SetDefault();
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_CLOSE_WINDOW event handler for ID_DIALOG
|
|
|
|
*/
|
|
|
|
|
|
|
|
void DIALOG_PAGES_SETTINGS::OnCloseWindow( wxCloseEvent& event )
|
|
|
|
{
|
|
|
|
EndModal( m_Modified );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
|
|
|
*/
|
|
|
|
|
|
|
|
void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
SavePageSettings( event );
|
|
|
|
m_Modified = 1;
|
2011-03-14 15:17:18 +00:00
|
|
|
Close( true );
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
|
|
|
|
*/
|
|
|
|
|
|
|
|
void DIALOG_PAGES_SETTINGS::OnCancelClick( wxCommandEvent& event )
|
|
|
|
{
|
2011-03-14 15:17:18 +00:00
|
|
|
Close( true );
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2011-03-14 15:17:18 +00:00
|
|
|
double dtmp;
|
|
|
|
wxString msg;
|
2010-03-14 10:34:40 +00:00
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
m_Screen->m_Revision = m_TextRevision->GetValue();
|
|
|
|
m_Screen->m_Company = m_TextCompany->GetValue();
|
|
|
|
m_Screen->m_Title = m_TextTitle->GetValue();
|
|
|
|
m_Screen->m_Commentaire1 = m_TextComment1->GetValue();
|
|
|
|
m_Screen->m_Commentaire2 = m_TextComment2->GetValue();
|
|
|
|
m_Screen->m_Commentaire3 = m_TextComment3->GetValue();
|
|
|
|
m_Screen->m_Commentaire4 = m_TextComment4->GetValue();
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
msg = m_TextUserSizeX->GetValue();
|
2011-03-14 15:17:18 +00:00
|
|
|
msg.ToDouble( &dtmp );
|
2010-03-14 10:34:40 +00:00
|
|
|
UserSizeX = dtmp;
|
|
|
|
msg = m_TextUserSizeY->GetValue();
|
2011-03-14 15:17:18 +00:00
|
|
|
msg.ToDouble( &dtmp );
|
2010-03-14 10:34:40 +00:00
|
|
|
UserSizeY = dtmp;
|
|
|
|
|
|
|
|
int ii = m_PageSizeBox->GetSelection();
|
|
|
|
|
|
|
|
if( ii < 0 )
|
|
|
|
ii = 0;
|
|
|
|
|
|
|
|
m_SelectedSheet = SheetList[ii];
|
|
|
|
m_Screen->m_CurrentSheetDesc = m_SelectedSheet;
|
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
switch( g_UserUnit )
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2010-07-12 14:07:09 +00:00
|
|
|
case MILLIMETRES:
|
2011-03-14 15:17:18 +00:00
|
|
|
g_Sheet_user.m_Size.x = (int) ( UserSizeX * 1000 / 25.4 );
|
|
|
|
g_Sheet_user.m_Size.y = (int) ( UserSizeY * 1000 / 25.4 );
|
2010-07-12 14:07:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case INCHES:
|
2011-03-14 15:17:18 +00:00
|
|
|
g_Sheet_user.m_Size.x = (int) ( UserSizeX * 1000 );
|
|
|
|
g_Sheet_user.m_Size.y = (int) ( UserSizeY * 1000 );
|
2010-07-12 14:07:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UNSCALED_UNITS:
|
2011-03-14 15:17:18 +00:00
|
|
|
g_Sheet_user.m_Size.x = (int) ( UserSizeX );
|
|
|
|
g_Sheet_user.m_Size.y = (int) ( UserSizeY );
|
2010-07-12 14:07:09 +00:00
|
|
|
break;
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( g_Sheet_user.m_Size.x < 6000 )
|
|
|
|
g_Sheet_user.m_Size.x = 6000;
|
|
|
|
|
|
|
|
if( g_Sheet_user.m_Size.x > 44000 )
|
|
|
|
g_Sheet_user.m_Size.x = 44000;
|
|
|
|
|
|
|
|
if( g_Sheet_user.m_Size.y < 4000 )
|
|
|
|
g_Sheet_user.m_Size.y = 4000;
|
|
|
|
|
|
|
|
if( g_Sheet_user.m_Size.y > 44000 )
|
|
|
|
g_Sheet_user.m_Size.y = 44000;
|
|
|
|
|
|
|
|
#ifdef EESCHEMA
|
|
|
|
/* Exports settings to other sheets if requested: */
|
2011-03-14 15:17:18 +00:00
|
|
|
SCH_SCREEN* screen;
|
|
|
|
|
2010-03-14 10:34:40 +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
|
|
|
|
2010-03-14 10:34:40 +00:00
|
|
|
/* Update the datas */
|
|
|
|
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
|
|
|
|
{
|
|
|
|
if( screen == m_Screen )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( m_RevisionExport->IsChecked() )
|
|
|
|
screen->m_Revision = m_Screen->m_Revision;
|
|
|
|
|
|
|
|
if( m_TitleExport->IsChecked() )
|
2011-03-14 15:17:18 +00:00
|
|
|
screen->m_Title = m_Screen->m_Title;
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
if( m_CompanyExport->IsChecked() )
|
|
|
|
screen->m_Company = m_Screen->m_Company;
|
|
|
|
|
|
|
|
if( m_Comment1Export->IsChecked() )
|
|
|
|
screen->m_Commentaire1 = m_Screen->m_Commentaire1;
|
|
|
|
|
|
|
|
if( m_Comment2Export->IsChecked() )
|
|
|
|
screen->m_Commentaire2 = m_Screen->m_Commentaire2;
|
|
|
|
|
|
|
|
if( m_Comment3Export->IsChecked() )
|
|
|
|
screen->m_Commentaire3 = m_Screen->m_Commentaire3;
|
|
|
|
|
|
|
|
if( m_Comment4Export->IsChecked() )
|
|
|
|
screen->m_Commentaire4 = m_Screen->m_Commentaire4;
|
|
|
|
}
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2010-03-14 10:34:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
m_Screen->SetModify();
|
2011-02-21 21:07:00 +00:00
|
|
|
m_Parent->DrawPanel->Refresh();
|
2010-03-14 10:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Search the correct index to activate the radiobox list size selection
|
|
|
|
* according to the current page size
|
|
|
|
*/
|
2011-03-14 15:17:18 +00:00
|
|
|
void DIALOG_PAGES_SETTINGS::SearchPageSizeSelection()
|
2010-03-14 10:34:40 +00:00
|
|
|
{
|
2011-03-14 15:17:18 +00:00
|
|
|
Ki_PageDescr* sheet;
|
|
|
|
int ii;
|
2010-03-14 10:34:40 +00:00
|
|
|
|
|
|
|
m_CurrentSelection = NB_ITEMS - 1;
|
2011-02-05 02:21:11 +00:00
|
|
|
|
2010-03-14 10:34:40 +00:00
|
|
|
for( ii = 0; ii < NB_ITEMS; ii++ )
|
|
|
|
{
|
|
|
|
sheet = SheetList[ii];
|
2011-02-05 02:21:11 +00:00
|
|
|
|
|
|
|
if( m_Parent->GetScreen()->m_CurrentSheetDesc == sheet )
|
2010-03-14 10:34:40 +00:00
|
|
|
m_CurrentSelection = ii;
|
|
|
|
}
|
|
|
|
}
|