Made the project default text size apply to all text things in eeschema, instead of the hardcoded value

This commit is contained in:
Lorenzo Marcantonio 2014-05-16 15:57:53 +02:00
parent bb0804ec29
commit 6d17ad712c
16 changed files with 90 additions and 37 deletions

View File

@ -297,7 +297,7 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent )
// Make the text size the new default size ( if it is a new text ):
if( m_CurrentText->IsNew() )
m_Parent->SetDefaultLabelSize( m_CurrentText->GetSize().x );
SetDefaultTextSize( m_CurrentText->GetSize().x );
m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() );
m_Parent->GetCanvas()->MoveCursorToCrossHair();

View File

@ -101,7 +101,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
textItem->SetBold( lastTextBold );
textItem->SetItalic( lastTextItalic );
textItem->SetOrientation( lastTextOrientation );
textItem->SetSize( wxSize( GetDefaultLabelSize(), GetDefaultLabelSize() ) );
textItem->SetSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) );
textItem->SetFlags( IS_NEW | IS_MOVED );
EditSchematicText( textItem );

View File

@ -57,7 +57,7 @@
static EDA_COLOR_T s_layerColor[NB_SCH_LAYERS];
// The width to draw busses that do not have a specific width
/// The width to draw busses that do not have a specific width
static int s_defaultBusThickness;
int GetDefaultBusThickness()
@ -73,6 +73,19 @@ void SetDefaultBusThickness( int aThickness)
s_defaultBusThickness = 1;
}
/// Default size for text (not only labels)
static int s_defaultTextSize;
int GetDefaultTextSize()
{
return s_defaultTextSize;
}
void SetDefaultTextSize( int aTextSize )
{
s_defaultTextSize = aTextSize;
}
/*
* Default line (in Eeschema units) thickness used to draw/plot items having a
* default thickness line value (i.e. = 0 ).
@ -283,7 +296,7 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
dlg.SetBusWidth( GetDefaultBusThickness() );
dlg.SetLineWidth( GetDefaultLineThickness() );
dlg.SetPinLength( GetDefaultPinLength() );
dlg.SetTextSize( GetDefaultLabelSize() );
dlg.SetTextSize( GetDefaultTextSize() );
dlg.SetRepeatHorizontal( g_RepeatStep.x );
dlg.SetRepeatVertical( g_RepeatStep.y );
dlg.SetRepeatLabel( g_RepeatDeltaLabel );
@ -332,7 +345,7 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
SetDefaultBusThickness( dlg.GetBusWidth() );
SetDefaultLineThickness( dlg.GetLineWidth() );
SetDefaultPinLength( dlg.GetPinLength() );
SetDefaultLabelSize( dlg.GetTextSize() );
SetDefaultTextSize( dlg.GetTextSize() );
g_RepeatStep.x = dlg.GetRepeatHorizontal();
g_RepeatStep.y = dlg.GetRepeatVertical();
g_RepeatDeltaLabel = dlg.GetRepeatLabel();
@ -404,7 +417,7 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParametersList()
&g_RepeatDeltaLabel,
1, -10, +10 ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "LabSize" ),
&m_defaultLabelSize,
&s_defaultTextSize,
DEFAULT_SIZE_TEXT, 5,
1000 ) );

View File

@ -14,7 +14,6 @@ class SCH_SHEET;
#define SCHEMATIC_HEAD_STRING "Schematic File Version"
#define TXTMARGE 10 // Offset in mils for placement of labels and pin numbers
#define DEFAULT_TEXT_SIZE 50 // Default size for field texts
#define DANGLING_SYMBOL_SIZE 12
#define GR_DEFAULT_DRAWMODE GR_COPY
@ -76,6 +75,12 @@ extern SCH_SHEET* g_RootSheet;
int GetDefaultLineThickness();
void SetDefaultLineThickness( int aThickness );
/**
* Default size for text in general
*/
int GetDefaultTextSize();
void SetDefaultTextSize( int aSize );
/**
* Default length for new pins in module editor
*/

View File

@ -67,7 +67,8 @@ LIB_FIELD::~LIB_FIELD()
void LIB_FIELD::Init( int id )
{
m_id = id;
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
m_Size.x = GetDefaultTextSize();
m_Size.y = GetDefaultTextSize();
m_typeName = _( "Field" );
m_Orient = TEXT_ORIENT_HORIZ;
m_rotate = false;

View File

@ -208,8 +208,8 @@ LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) :
m_type = PIN_UNSPECIFIED; // electrical type of pin
m_attributes = 0; // bit 0 != 0: pin invisible
m_number = 0; // pin number (i.e. 4 ASCII chars)
m_numTextSize = DEFAULT_TEXT_SIZE;
m_nameTextSize = DEFAULT_TEXT_SIZE; // Default size for pin name and num
m_numTextSize = GetDefaultTextSize(); // Default size for pin name and num
m_nameTextSize = GetDefaultTextSize();
m_width = 0;
m_typeName = _( "Pin" );
}

View File

@ -88,7 +88,7 @@ LIB_ITEM* LIB_EDIT_FRAME::m_lastDrawItem = NULL;
LIB_ITEM* LIB_EDIT_FRAME::m_drawItem = NULL;
bool LIB_EDIT_FRAME:: m_showDeMorgan = false;
wxSize LIB_EDIT_FRAME:: m_clientSize = wxSize( -1, -1 );
int LIB_EDIT_FRAME:: m_textSize = DEFAULT_SIZE_TEXT;
int LIB_EDIT_FRAME:: m_textSize = -1;
int LIB_EDIT_FRAME:: m_textOrientation = TEXT_ORIENT_HORIZ;
int LIB_EDIT_FRAME:: m_drawLineWidth = 0;
FILL_T LIB_EDIT_FRAME:: m_drawFillStyle = NO_FILL;
@ -203,6 +203,10 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr;
m_editPinsPerPartOrConvert = false;
// Delayed initialization
if( m_textSize == -1 )
m_textSize = GetDefaultTextSize();
// Initialize grid id to the default value 50 mils:
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;

View File

@ -59,14 +59,14 @@ static wxPoint PinPreviousPos;
static int LastPinType = PIN_INPUT;
static int LastPinOrient = PIN_RIGHT;
static int LastPinShape = NONE;
static int LastPinNameSize = DEFAULT_TEXT_SIZE;
static int LastPinNumSize = DEFAULT_TEXT_SIZE;
static bool LastPinCommonConvert = false;
static bool LastPinCommonUnit = false;
static bool LastPinVisible = true;
// The -1 is a non-valid value to trigger delayed initialization
static int LastPinLength = -1;
static int LastPinNameSize = -1;
static int LastPinNumSize = -1;
static int GetLastPinLength()
{
@ -76,6 +76,22 @@ static int GetLastPinLength()
return LastPinLength;
}
static int GetLastPinNameSize()
{
if( LastPinNameSize == -1 )
LastPinNameSize = GetDefaultTextSize();
return LastPinNameSize;
}
static int GetLastPinNumSize()
{
if( LastPinNumSize == -1 )
LastPinNumSize = GetDefaultTextSize();
return LastPinNumSize;
}
void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
{
if( m_drawItem == NULL || m_drawItem->Type() != LIB_PIN_T )
@ -141,9 +157,9 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
pin->EnableEditMode( true, m_editPinsPerPartOrConvert );
pin->SetName( dlg.GetName() );
pin->SetNameTextSize( LastPinNameSize );
pin->SetNameTextSize( GetLastPinNameSize() );
pin->SetNumber( dlg.GetPadName() );
pin->SetNumberTextSize( LastPinNumSize );
pin->SetNumberTextSize( GetLastPinNumSize() );
pin->SetOrientation( LastPinOrient );
pin->SetLength( GetLastPinLength() );
pin->SetType( LastPinType );
@ -402,8 +418,8 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
pin->SetOrientation( LastPinOrient );
pin->SetType( LastPinType );
pin->SetShape( LastPinShape );
pin->SetNameTextSize( LastPinNameSize );
pin->SetNumberTextSize( LastPinNumSize );
pin->SetNameTextSize( GetLastPinNameSize() );
pin->SetNumberTextSize( GetLastPinNumSize() );
pin->SetConvert( LastPinCommonConvert ? 0 : m_convert );
pin->SetUnit( LastPinCommonUnit ? 0 : m_unit );
pin->SetVisible( LastPinVisible );

View File

@ -1311,7 +1311,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
GetField( fieldNdx )->SetAttributes( attr );
if( (w == 0 ) || (ii == 4) )
w = DEFAULT_SIZE_TEXT;
w = GetDefaultTextSize();
GetField( fieldNdx )->SetSize( wxSize( w, w ) );
GetField( fieldNdx )->SetOrientation( TEXT_ORIENT_HORIZ );

View File

@ -50,7 +50,8 @@ SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
m_pos = pos;
m_size = wxSize( MIN_SHEET_WIDTH, MIN_SHEET_HEIGHT );
SetTimeStamp( GetNewTimeStamp() );
m_sheetNameSize = m_fileNameSize = DEFAULT_TEXT_SIZE;
m_sheetNameSize = GetDefaultTextSize();
m_fileNameSize = GetDefaultTextSize();
m_screen = NULL;
m_name.Printf( wxT( "Sheet%8.8lX" ), m_TimeStamp );
m_fileName.Printf( wxT( "file%8.8lX.sch" ), m_TimeStamp );
@ -269,7 +270,7 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
if( size == 0 )
size = DEFAULT_SIZE_TEXT;
size = GetDefaultTextSize();
if( fieldNdx == 0 )
{

View File

@ -307,7 +307,7 @@ bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg )
m_Text = FROM_UTF8( name );
if( size == 0 )
size = DEFAULT_SIZE_TEXT;
size = GetDefaultTextSize();
m_Size.x = m_Size.y = size;

View File

@ -445,7 +445,7 @@ bool SCH_TEXT::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
if( size == 0 )
size = DEFAULT_SIZE_TEXT;
size = GetDefaultTextSize();
char* text = strtok( (char*) aLine, "\n\r" );
@ -930,7 +930,7 @@ bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
if( size == 0 )
size = DEFAULT_SIZE_TEXT;
size = GetDefaultTextSize();
char* text = strtok( (char*) aLine, "\n\r" );
@ -1093,7 +1093,7 @@ bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
if( size == 0 )
size = DEFAULT_SIZE_TEXT;
size = GetDefaultTextSize();
char* text = strtok( (char*) aLine, "\n\r" );
@ -1524,7 +1524,7 @@ bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
if( size == 0 )
size = DEFAULT_SIZE_TEXT;
size = GetDefaultTextSize();
char* text = strtok( (char*) aLine, "\n\r" );

View File

@ -184,7 +184,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_showAxis = false; // true to show axis
m_showBorderAndTitleBlock = true; // true to show sheet references
m_CurrentSheet = new SCH_SHEET_PATH();
m_TextFieldSize = DEFAULT_SIZE_TEXT;
m_DefaultSchematicFileName = NAMELESS_PROJECT;
m_DefaultSchematicFileName += wxT( ".sch" );
m_showAllPins = false;
@ -199,7 +198,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_hasAutoSave = true;
SetForceHVLines( true );
SetDefaultLabelSize( DEFAULT_SIZE_TEXT );
CreateScreens();

View File

@ -44,9 +44,19 @@
int SCH_EDIT_FRAME::m_lastSheetPinType = NET_INPUT;
wxSize SCH_EDIT_FRAME::m_lastSheetPinTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT );
wxSize SCH_EDIT_FRAME::m_lastSheetPinTextSize( -1, -1 );
wxPoint SCH_EDIT_FRAME::m_lastSheetPinPosition;
const wxSize &SCH_EDIT_FRAME::GetLastSheetPinTextSize()
{
// Delayed initialization (need the preferences to be loaded)
if( m_lastSheetPinTextSize.x == -1 )
{
m_lastSheetPinTextSize.x = GetDefaultTextSize();
m_lastSheetPinTextSize.y = GetDefaultTextSize();
}
return m_lastSheetPinTextSize;
}
int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC )
{
@ -102,7 +112,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), line );
sheetPin->SetFlags( IS_NEW );
sheetPin->SetSize( m_lastSheetPinTextSize );
sheetPin->SetSize( GetLastSheetPinTextSize() );
sheetPin->SetShape( m_lastSheetPinType );
int response = EditSheetPin( sheetPin, NULL );
@ -158,7 +168,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), label->GetText() );
sheetPin->SetFlags( IS_NEW );
sheetPin->SetSize( m_lastSheetPinTextSize );
sheetPin->SetSize( GetLastSheetPinTextSize() );
m_lastSheetPinType = label->GetShape();
sheetPin->SetShape( label->GetShape() );
sheetPin->SetPosition( GetCrossHairPosition() );

View File

@ -60,7 +60,13 @@ enum EDA_DRAW_MODE_T {
};
#define DEFAULT_SIZE_TEXT 60 /* default text height (in mils or 1/1000") */
/** This is the "default-of-the-default" hardcoded text size; individual
* application define their own default policy starting with this
* (usually with a user option or project). DO NOT change this value if
* you do not fully realize the effect it has on sexp serialization
* (text size equal to this is not explicitly wrote, so it would change
* subsequent reads) */
#define DEFAULT_SIZE_TEXT 60 // default text height (in mils, i.e. 1/1000")
#define TEXT_NO_VISIBLE 1 //< EDA_TEXT::m_Attribut(e?) visibility flag.
#define DIM_ANCRE_TEXTE 2 // Anchor size for text

View File

@ -118,7 +118,6 @@ private:
SCH_SHEET_PATH* m_CurrentSheet; ///< which sheet we are presently working on.
wxString m_DefaultSchematicFileName;
int m_TextFieldSize;
PARAM_CFG_ARRAY m_projectFileParams;
PARAM_CFG_ARRAY m_configSettings;
wxPageSetupDialogData m_pageSetupData;
@ -146,8 +145,6 @@ private:
///< generator.
bool m_forceHVLines; ///< force H or V directions for wires, bus, line
int m_defaultLabelSize; ///< size of a new label
/// An index to the last find item in the found items list #m_foundItems.
int m_foundItemIndex;
@ -172,6 +169,11 @@ private:
protected:
TEMPLATES m_TemplateFieldNames;
/**
* Initializing accessor for the pin text size
*/
const wxSize &GetLastSheetPinTextSize();
/**
* Function doAutoSave
* saves the schematic files that have been modified and not yet saved.
@ -205,9 +207,6 @@ public:
void OnCloseWindow( wxCloseEvent& Event );
int GetDefaultLabelSize() const { return m_defaultLabelSize; }
void SetDefaultLabelSize( int aLabelSize ) { m_defaultLabelSize = aLabelSize; }
bool GetForceHVLines() const { return m_forceHVLines; }
void SetForceHVLines( bool aForceHVdirection ) { m_forceHVLines = aForceHVdirection; }