Commit 0025ac7d authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

Add "portrait" support to the page size settings for all standard paper

    sizes.  Tested with postscript output only.  Required minor file format changes
    to reflect the "portrait" setting.  common/dialogs/dialog_page_settings.cpp
    uses a checkbox but its name is "Landscape", which is inverted from portrait,
    but since it is the more common choice, I used that rather than portrait.
    The tooltip for that checkbox makes it clear.  No portrait mode is supported
    for "User" paper size.
parent 9147e66d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -4,6 +4,17 @@ KiCad ChangeLog 2012
Please add newer entries at the top, list the date and your name with
email address.

2012-Jan-15 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++all
    Add "portrait" support to the page size settings for all standard paper
    sizes.  Tested with postscript output only.  Required minor file format changes
    to reflect the "portrait" setting.  common/dialogs/dialog_page_settings.cpp
    uses a checkbox but its name is "Landscape", which is inverted from portrait,
    but since it is the more common choice, I used that rather than portrait.
    The tooltip for that checkbox makes it clear.  No portrait mode is supported
    for "User" paper size.


2012-Jan-9 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+78 −25
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString )

//-----<PAGE_INFO>-------------------------------------------------------------

// Standard page sizes in mils
// Standard page sizes in mils, all constants
#if defined(KICAD_GOST)
const PAGE_INFO  PAGE_INFO::pageA4(    wxSize(  8283, 11700 ),  wxT( "A4" ) );
#else
@@ -224,6 +224,27 @@ wxArrayString PAGE_INFO::GetStandardSizes()
}
*/

PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) :
    m_type( aType ),
    m_size( aSizeMils ),
    m_portrait( false )
{
#if defined(KICAD_GOST)
    m_left_margin   = GOST_LEFTMARGIN;
    m_right_margin  = GOST_RIGHTMARGIN;
    m_top_margin    = GOST_TOPMARGIN;
    m_bottom_margin = GOST_BOTTOMMARGIN;
#else
    m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400;
#endif
}


PAGE_INFO::PAGE_INFO( const wxString& aType )
{
    SetType( aType );
}

bool PAGE_INFO::SetType( const wxString& aType )
{
    bool rc = true;
@@ -267,47 +288,79 @@ bool PAGE_INFO::SetType( const wxString& aType )
}


PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) :
    m_size( aSizeMils )
void PAGE_INFO::SetPortrait( bool isPortrait )
{
    m_type   = aType;

#if defined(KICAD_GOST)
    m_left_margin   = GOST_LEFTMARGIN;
    m_right_margin  = GOST_RIGHTMARGIN;
    m_top_margin    = GOST_TOPMARGIN;
    m_bottom_margin = GOST_BOTTOMMARGIN;
#else
    m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400;
#endif
}
    if( m_portrait != isPortrait )
    {
        // swap x and y in m_size
        m_size = wxSize( m_size.y, m_size.x );

        m_portrait = isPortrait;

PAGE_INFO::PAGE_INFO( const wxString& aType )
{
    SetType( aType );
        // margins are not touched.
    }
}


void PAGE_INFO::SetUserWidthMils( int aWidthInMils )
static int clampWidth( int aWidthInMils )
{
    if( aWidthInMils < 6000 )
        aWidthInMils = 6000;
    else if( aWidthInMils > 44000 )
    if( aWidthInMils < 4000 )       // 4" is about a baseball card
        aWidthInMils = 4000;
    else if( aWidthInMils > 44000 ) //44" is plotter size
        aWidthInMils = 44000;

    s_user_width = aWidthInMils;
    return aWidthInMils;
}


void PAGE_INFO::SetUserHeightMils( int aHeightInMils )
static int clampHeight( int aHeightInMils )
{
    if( aHeightInMils < 4000 )
        aHeightInMils = 4000;
    else if( aHeightInMils > 44000 )
        aHeightInMils = 44000;
    return aHeightInMils;
}

    s_user_height = aHeightInMils;

void PAGE_INFO::SetUserWidthMils( int aWidthInMils )
{
    s_user_width = clampWidth( aWidthInMils );
}


void PAGE_INFO::SetUserHeightMils( int aHeightInMils )
{
    s_user_height = clampHeight( aHeightInMils );
}


void PAGE_INFO::SetWidthMils(  int aWidthInMils )
{
    m_size.x = clampWidth( aWidthInMils );
}


int PAGE_INFO::GetWidthMils() const
{
    return m_size.x;
}


void PAGE_INFO::SetHeightMils( int aHeightInMils )
{
    m_size.y = clampHeight( aHeightInMils );
}


int PAGE_INFO::GetHeightMils() const
{
    return m_size.y;
}


const wxSize& PAGE_INFO::GetSizeMils() const
{
    return m_size;
}

//-----</PAGE_INFO>------------------------------------------------------------
+29 −15
Original line number Diff line number Diff line
@@ -72,10 +72,16 @@ void DIALOG_PAGES_SETTINGS::initDialog()
    msg.Printf( format, m_Screen->m_ScreenNumber );
    m_TextSheetNumber->SetLabel( msg );

    PAGE_INFO   pageInfo = m_Parent->GetPageSettings();
    const PAGE_INFO& pageInfo = m_Parent->GetPageSettings();

    if( wxT( "User" ) != pageInfo.GetType() )
        m_landscapeCheckbox->SetValue( !pageInfo.IsPortrait() );

    setCurrentPageSizeSelection( pageInfo.GetType() );

    // only a click fires the radiobutton selected event, so have to fabricate this check
    onRadioButtonSelected();

    switch( g_UserUnit )
    {
    case MILLIMETRES:
@@ -149,20 +155,12 @@ void DIALOG_PAGES_SETTINGS::initDialog()
}


/*!
 * 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 );
@@ -171,16 +169,31 @@ void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event )
}


/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
 */

void DIALOG_PAGES_SETTINGS::OnCancelClick( wxCommandEvent& event )
{
    Close( true );
}


void DIALOG_PAGES_SETTINGS::onRadioButtonSelected()
{
    if( wxT( "User" ) == m_PageSizeBox->GetStringSelection() )
    {
        m_landscapeCheckbox->Enable( false );
    }
    else
    {
        m_landscapeCheckbox->Enable( true );
    }
}


void DIALOG_PAGES_SETTINGS::onRadioButtonSelected( wxCommandEvent& event )
{
    onRadioButtonSelected();    // no event arg
}


void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
{
    wxString    msg;
@@ -236,6 +249,9 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
    // paperType is "User", otherwise User with and height will not go into effect right away.
    PAGE_INFO   pageInfo( paperType );

    if( wxT( "User" ) != paperType )
        pageInfo.SetPortrait( !m_landscapeCheckbox->IsChecked() );

    m_Parent->SetPageSettings( pageInfo );

#ifdef EESCHEMA
@@ -306,7 +322,5 @@ void DIALOG_PAGES_SETTINGS::setCurrentPageSizeSelection( const wxString& aPaperS
            }
        }
    }

    // m_PageSizeBox->SetSelection( 1 );        // wxFormBuilder does this, control there
}
+4 −0
Original line number Diff line number Diff line
@@ -36,10 +36,14 @@ private:
    /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
    void OnCancelClick( wxCommandEvent& event );

    /// wxEVT_COMMAND_RADIOBOX_SELECTED
    void onRadioButtonSelected( wxCommandEvent& event );

    void setCurrentPageSizeSelection( const wxString& aPaperSize );
    void SavePageSettings(wxCommandEvent& event);
    void ReturnSizeSelected(wxCommandEvent& event);

    void onRadioButtonSelected();
};

#endif  // _DIALOG_PAGES_SETTINGS_H_
+15 −1
Original line number Diff line number Diff line
@@ -31,12 +31,23 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind
	wxString m_PageSizeBoxChoices[] = { _("A4"), _("A3"), _("A2"), _("A1"), _("A0"), _("A"), _("B"), _("C"), _("D"), _("E"), _("User") };
	int m_PageSizeBoxNChoices = sizeof( m_PageSizeBoxChoices ) / sizeof( wxString );
	m_PageSizeBox = new wxRadioBox( this, wxID_ANY, _("Page Size:"), wxDefaultPosition, wxDefaultSize, m_PageSizeBoxNChoices, m_PageSizeBoxChoices, 1, wxRA_SPECIFY_COLS );
	m_PageSizeBox->SetSelection( 1 );
	m_PageSizeBox->SetSelection( 9 );
	LeftColumnSizer->Add( m_PageSizeBox, 0, wxALL|wxEXPAND, 5 );
	
	
	LeftColumnSizer->Add( 5, 0, 1, wxEXPAND, 5 );
	
	wxStaticBoxSizer* sbSizer8;
	sbSizer8 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Orientation:") ), wxVERTICAL );
	
	m_landscapeCheckbox = new wxCheckBox( this, wxID_ANY, _("Landscape"), wxDefaultPosition, wxDefaultSize, 0 );
	m_landscapeCheckbox->SetValue(true); 
	m_landscapeCheckbox->SetToolTip( _("Check for landscape, uncheck for portrait") );
	
	sbSizer8->Add( m_landscapeCheckbox, 0, wxALL|wxEXPAND, 5 );
	
	LeftColumnSizer->Add( sbSizer8, 1, wxALL|wxEXPAND, 5 );
	
	wxBoxSizer* bSizerXsize;
	bSizerXsize = new wxBoxSizer( wxVERTICAL );
	
@@ -204,9 +215,11 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind
	
	this->SetSizer( bMainSizer );
	this->Layout();
	bMainSizer->Fit( this );
	
	// Connect Events
	this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCloseWindow ) );
	m_PageSizeBox->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::onRadioButtonSelected ), NULL, this );
	m_TextUserSizeX->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnTextctrlUserPageSizeXTextUpdated ), NULL, this );
	m_TextUserSizeY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnTextctrlUserPageSizeYTextUpdated ), NULL, this );
	m_TitleExport->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCheckboxTitleClick ), NULL, this );
@@ -218,6 +231,7 @@ DIALOG_PAGES_SETTINGS_BASE::~DIALOG_PAGES_SETTINGS_BASE()
{
	// Disconnect Events
	this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCloseWindow ) );
	m_PageSizeBox->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::onRadioButtonSelected ), NULL, this );
	m_TextUserSizeX->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnTextctrlUserPageSizeXTextUpdated ), NULL, this );
	m_TextUserSizeY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnTextctrlUserPageSizeYTextUpdated ), NULL, this );
	m_TitleExport->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCheckboxTitleClick ), NULL, this );
Loading