@ -30,7 +30,9 @@ static constexpr double MAX_SCALE = 100.0;
DIALOG_PRINT_GENERIC : : DIALOG_PRINT_GENERIC ( EDA_DRAW_FRAME * aParent , PRINTOUT_SETTINGS * aSettings )
DIALOG_PRINT_GENERIC : : DIALOG_PRINT_GENERIC ( EDA_DRAW_FRAME * aParent , PRINTOUT_SETTINGS * aSettings )
: DIALOG_PRINT_GENERIC_BASE ( aParent ) , m_config ( nullptr ) , m_settings ( aSettings )
: DIALOG_PRINT_GENERIC_BASE ( aParent ) , m_config ( nullptr ) , m_settings ( aSettings )
{
{
m_scaleValidator . SetRange ( MIN_SCALE , MAX_SCALE ) ;
// Note: for the validator, min value is 0.0, to allow typing values like 0.5
// that start by 0
m_scaleValidator . SetRange ( 0.0 , MAX_SCALE ) ;
m_scaleCustomText - > SetValidator ( m_scaleValidator ) ;
m_scaleCustomText - > SetValidator ( m_scaleValidator ) ;
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
@ -84,7 +86,7 @@ void DIALOG_PRINT_GENERIC::saveSettings()
}
}
double DIALOG_PRINT_GENERIC : : getScaleValue ( ) const
double DIALOG_PRINT_GENERIC : : getScaleValue ( )
{
{
if ( m_scale1 - > GetValue ( ) )
if ( m_scale1 - > GetValue ( ) )
return 1.0 ;
return 1.0 ;
@ -94,9 +96,30 @@ double DIALOG_PRINT_GENERIC::getScaleValue() const
if ( m_scaleCustom - > GetValue ( ) )
if ( m_scaleCustom - > GetValue ( ) )
{
{
double scale ;
double scale = 1.0 ; ;
wxCHECK ( m_scaleCustomText - > GetValue ( ) . ToDouble ( & scale ) , 1.0 ) ;
if ( ! m_scaleCustomText - > GetValue ( ) . ToDouble ( & scale ) )
{
DisplayInfoMessage ( nullptr , _ ( " Warning: Bad scale number " ) ) ;
scale = 1.0 ;
}
if ( scale > MAX_SCALE )
{
scale = MAX_SCALE ;
setScaleValue ( scale ) ;
DisplayInfoMessage ( nullptr ,
wxString : : Format ( _ ( " Warning: Scale option set to a very large value. \n "
" Clamped to %f " ) , scale ) ) ;
}
else if ( scale < MIN_SCALE )
{
scale = MIN_SCALE ;
setScaleValue ( scale ) ;
DisplayInfoMessage ( nullptr ,
wxString : : Format ( _ ( " Warning: Scale option set to a very small value. \n "
" Clamped to %f " ) , scale ) ) ;
}
return scale ;
return scale ;
}
}
@ -118,14 +141,11 @@ void DIALOG_PRINT_GENERIC::setScaleValue( double aValue )
}
}
else
else
{
{
// Silently clamp the value (it comes from the config file).
if ( aValue > MAX_SCALE )
if ( aValue > MAX_SCALE )
{
DisplayInfoMessage ( nullptr , _ ( " Warning: Scale option set to a very large value " ) ) ;
}
aValue = MAX_SCALE ;
else if ( aValue < MIN_SCALE )
else if ( aValue < MIN_SCALE )
{
DisplayInfoMessage ( nullptr , _ ( " Warning: Scale option set to a very small value " ) ) ;
}
aValue = MIN_SCALE ;
m_scaleCustom - > SetValue ( true ) ;
m_scaleCustom - > SetValue ( true ) ;
m_scaleCustomText - > SetValue ( wxString : : Format ( wxT ( " %f " ) , aValue ) ) ;
m_scaleCustomText - > SetValue ( wxString : : Format ( wxT ( " %f " ) , aValue ) ) ;