Commit 87aa22f1 authored by Dick Hollenbeck's avatar Dick Hollenbeck

quiet warnings, add Clamp()

parent b5cac30a
/********************/
/* System includes. */
/********************/
#ifndef FCTSYS_H
#define FCTSYS_H
#ifndef FCTSYS_H_
#define FCTSYS_H_
// For compilers that support precompilation, includes "wx.h".
#include <wx/wxprec.h>
......@@ -46,6 +46,25 @@
#define D(x) // nothing
#endif
/**
* Function Clamp
* limits @a value within the range @a lower <= @a value <= @a upper. It will work
* on temporary expressions, since they are evaluated only once, and it should work
* on most if not all numeric types. The arguments are accepted in this order so you
* can remember the expression as a memory aid:
* <p>
* result is: lower <= value <= upper
*/
template <typename T> inline const T& Clamp( const T& lower, const T& value, const T& upper )
{
wxASSERT( lower <= upper );
if( value < lower )
return lower;
else if( value > upper )
return upper;
return value;
}
#define UNIX_STRING_DIR_SEP wxT( "/" )
#define WIN_STRING_DIR_SEP wxT( "\\" )
......@@ -64,4 +83,4 @@
#include <config.h>
#endif /* FCTSYS_H */
#endif // FCTSYS_H__
......@@ -171,7 +171,7 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event )
infile->GetStream()->GetSize(), zippedsize );
PrintMsg( msg );
delete infile;
}
}
else
{
PrintMsg( _(" >>Error\n") );
......
......@@ -438,7 +438,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
// Type of pad selection
m_PadType->SetSelection( 0 );
for( int ii = 0; ii < NBTYPES; ii++ )
for( unsigned ii = 0; ii < NBTYPES; ii++ )
{
if( CodeType[ii] == m_dummyPad->GetAttribute() )
{
......@@ -573,11 +573,10 @@ void DIALOG_PAD_PROPERTIES::PadOrientEvent( wxCommandEvent& event )
void DIALOG_PAD_PROPERTIES::PadTypeSelected( wxCommandEvent& event )
{
long layer_mask;
int ii;
long layer_mask;
unsigned ii = m_PadType->GetSelection();
ii = m_PadType->GetSelection();
if( ii < 0 || ii >= NBTYPES )
if( ii >= NBTYPES ) // catches < 0 also
ii = 0;
layer_mask = Std_Pad_Layers[ii];
......@@ -603,11 +602,11 @@ void DIALOG_PAD_PROPERTIES::PadTypeSelected( wxCommandEvent& event )
void DIALOG_PAD_PROPERTIES::SetPadLayersList( long layer_mask )
{
if( ( layer_mask & ALL_CU_LAYERS ) == LAYER_FRONT )
if( ( layer_mask & ALL_CU_LAYERS ) == LAYER_FRONT )
m_rbCopperLayersSel->SetSelection(0);
else if( ( layer_mask & ALL_CU_LAYERS ) == LAYER_BACK)
m_rbCopperLayersSel->SetSelection(1);
else if( ( layer_mask & ALL_CU_LAYERS ) != 0 )
else if( ( layer_mask & ALL_CU_LAYERS ) != 0 )
m_rbCopperLayersSel->SetSelection(2);
else
m_rbCopperLayersSel->SetSelection(3);
......
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