Commit a7b25145 authored by Dick Hollenbeck's avatar Dick Hollenbeck

portrait setting was being overwritten in dialog_page_settings.cpp, add...

portrait setting was being overwritten in dialog_page_settings.cpp, add updatePortrait(), improve comments
parent 6d39b53e
...@@ -85,10 +85,17 @@ wxArrayString PAGE_INFO::GetStandardSizes() ...@@ -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 ) : PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) :
m_type( aType ), m_type( aType ),
m_size( aSizeMils ), m_size( aSizeMils )
m_portrait( false )
{ {
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
m_left_margin = GOST_LEFTMARGIN; m_left_margin = GOST_LEFTMARGIN;
...@@ -98,6 +105,8 @@ PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) : ...@@ -98,6 +105,8 @@ PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) :
#else #else
m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400; m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400;
#endif #endif
updatePortrait();
} }
...@@ -106,6 +115,7 @@ PAGE_INFO::PAGE_INFO( const wxString& aType ) ...@@ -106,6 +115,7 @@ PAGE_INFO::PAGE_INFO( const wxString& aType )
SetType( aType ); SetType( aType );
} }
bool PAGE_INFO::SetType( const wxString& aType ) bool PAGE_INFO::SetType( const wxString& aType )
{ {
bool rc = true; bool rc = true;
...@@ -147,6 +157,8 @@ bool PAGE_INFO::SetType( const wxString& aType ) ...@@ -147,6 +157,8 @@ bool PAGE_INFO::SetType( const wxString& aType )
// customize: // customize:
m_size.x = s_user_width; m_size.x = s_user_width;
m_size.y = s_user_height; m_size.y = s_user_height;
updatePortrait();
} }
else else
rc = false; rc = false;
...@@ -170,7 +182,7 @@ void PAGE_INFO::SetPortrait( bool isPortrait ) ...@@ -170,7 +182,7 @@ void PAGE_INFO::SetPortrait( bool isPortrait )
m_portrait = 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 ) ...@@ -210,10 +222,13 @@ void PAGE_INFO::SetUserHeightMils( int aHeightInMils )
void PAGE_INFO::SetWidthMils( int aWidthInMils ) void PAGE_INFO::SetWidthMils( int aWidthInMils )
{ {
m_size.x = clampWidth( aWidthInMils ); m_size.x = clampWidth( aWidthInMils );
updatePortrait();
} }
void PAGE_INFO::SetHeightMils( int aHeightInMils ) void PAGE_INFO::SetHeightMils( int aHeightInMils )
{ {
m_size.y = clampHeight( aHeightInMils ); m_size.y = clampHeight( aHeightInMils );
updatePortrait();
} }
...@@ -79,10 +79,9 @@ void DIALOG_PAGES_SETTINGS::initDialog() ...@@ -79,10 +79,9 @@ void DIALOG_PAGES_SETTINGS::initDialog()
setCurrentPageSizeSelection( pageInfo.GetType() ); setCurrentPageSizeSelection( pageInfo.GetType() );
// only a click fires the selection changed event, so have to fabricate this check // only a click fires the "selection changed" event, so have to fabricate this check
wxCommandEvent junk; wxCommandEvent dummy;
onPaperSizeChoice( dummy );
onPaperSizeChoice( junk );
switch( g_UserUnit ) switch( g_UserUnit )
{ {
...@@ -247,13 +246,15 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) ...@@ -247,13 +246,15 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
} }
else else
{ {
pageInfo.SetPortrait( m_orientationComboBox->GetSelection() );
// here we assume translators will keep original paper size spellings // here we assume translators will keep original paper size spellings
if( !pageInfo.SetType( paperType ) ) if( !pageInfo.SetType( paperType ) )
{ {
wxASSERT_MSG( FALSE, wxT( "the translation for paper size must preserve original spellings" ) ); 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 ); m_Parent->SetPageSettings( pageInfo );
......
...@@ -148,9 +148,10 @@ public: ...@@ -148,9 +148,10 @@ public:
* commonly associated with that type name. * commonly associated with that type name.
* *
* @param aStandardPageDescriptionName is a wxString constant giving one of: * @param aStandardPageDescriptionName is a wxString constant giving one of:
* "A4" "A3" "A2" "A1" "A0" "A" "B" "C" "D" "E" "GERBER", or "User". If "User" * "A4" "A3" "A2" "A1" "A0" "A" "B" "C" "D" "E" "GERBER", "USLetter", "USLegal",
* then the width and height are custom, and will be set according to previous calls * "USLedger", or "User". If "User" then the width and height are custom,
* to static PAGE_INFO::SetUserWidthMils() and * and will be set according to <b>previous</b> calls to
* static PAGE_INFO::SetUserWidthMils() and
* static PAGE_INFO::SetUserHeightMils(); * static PAGE_INFO::SetUserHeightMils();
* *
* @return bool - true iff @a aStandarePageDescription was a recognized type. * @return bool - true iff @a aStandarePageDescription was a recognized type.
...@@ -268,6 +269,8 @@ private: ...@@ -268,6 +269,8 @@ private:
static int s_user_height; static int s_user_height;
static int s_user_width; static int s_user_width;
void updatePortrait();
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment