diff --git a/common/class_page_info.cpp b/common/class_page_info.cpp index c8d5bd83d1..917eb954af 100644 --- a/common/class_page_info.cpp +++ b/common/class_page_info.cpp @@ -85,10 +85,17 @@ wxArrayString PAGE_INFO::GetStandardSizes() } */ + +inline void PAGE_INFO::updatePortrait() +{ + // update m_portrait based on orientation of m_size.x and m_size.y + m_portrait = ( m_size.y > m_size.x ); +} + + PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) : m_type( aType ), - m_size( aSizeMils ), - m_portrait( false ) + m_size( aSizeMils ) { #if defined(KICAD_GOST) m_left_margin = GOST_LEFTMARGIN; @@ -98,6 +105,8 @@ PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) : #else m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400; #endif + + updatePortrait(); } @@ -106,6 +115,7 @@ PAGE_INFO::PAGE_INFO( const wxString& aType ) SetType( aType ); } + bool PAGE_INFO::SetType( const wxString& aType ) { bool rc = true; @@ -147,6 +157,8 @@ bool PAGE_INFO::SetType( const wxString& aType ) // customize: m_size.x = s_user_width; m_size.y = s_user_height; + + updatePortrait(); } else rc = false; @@ -170,7 +182,7 @@ void PAGE_INFO::SetPortrait( bool isPortrait ) m_portrait = isPortrait; - // margins are not touched. + // margins are not touched, do that if you want } } @@ -210,10 +222,13 @@ void PAGE_INFO::SetUserHeightMils( int aHeightInMils ) void PAGE_INFO::SetWidthMils( int aWidthInMils ) { m_size.x = clampWidth( aWidthInMils ); + updatePortrait(); } void PAGE_INFO::SetHeightMils( int aHeightInMils ) { m_size.y = clampHeight( aHeightInMils ); + updatePortrait(); } + diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index 9e02f7800d..b554b5d969 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -79,10 +79,9 @@ void DIALOG_PAGES_SETTINGS::initDialog() setCurrentPageSizeSelection( pageInfo.GetType() ); - // only a click fires the selection changed event, so have to fabricate this check - wxCommandEvent junk; - - onPaperSizeChoice( junk ); + // only a click fires the "selection changed" event, so have to fabricate this check + wxCommandEvent dummy; + onPaperSizeChoice( dummy ); switch( g_UserUnit ) { @@ -247,13 +246,15 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) } else { - pageInfo.SetPortrait( m_orientationComboBox->GetSelection() ); - // here we assume translators will keep original paper size spellings if( !pageInfo.SetType( paperType ) ) { wxASSERT_MSG( FALSE, wxT( "the translation for paper size must preserve original spellings" ) ); } + + // set portrait _after_ setting size/type above + int choice = m_orientationComboBox->GetSelection(); + pageInfo.SetPortrait( choice ); } m_Parent->SetPageSettings( pageInfo ); diff --git a/include/common.h b/include/common.h index a862eea6dc..1094808035 100644 --- a/include/common.h +++ b/include/common.h @@ -148,9 +148,10 @@ public: * commonly associated with that type name. * * @param aStandardPageDescriptionName is a wxString constant giving one of: - * "A4" "A3" "A2" "A1" "A0" "A" "B" "C" "D" "E" "GERBER", or "User". If "User" - * then the width and height are custom, and will be set according to previous calls - * to static PAGE_INFO::SetUserWidthMils() and + * "A4" "A3" "A2" "A1" "A0" "A" "B" "C" "D" "E" "GERBER", "USLetter", "USLegal", + * "USLedger", or "User". If "User" then the width and height are custom, + * and will be set according to previous calls to + * static PAGE_INFO::SetUserWidthMils() and * static PAGE_INFO::SetUserHeightMils(); * * @return bool - true iff @a aStandarePageDescription was a recognized type. @@ -268,6 +269,8 @@ private: static int s_user_height; static int s_user_width; + + void updatePortrait(); };