diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 91fcc91cda..a8c96451bb 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -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(); diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index c3d8797471..c620571f4b 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -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 ); diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index ed548ef958..8ece081b1b 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -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 ) ); diff --git a/eeschema/general.h b/eeschema/general.h index 83d50569b3..828f286d24 100644 --- a/eeschema/general.h +++ b/eeschema/general.h @@ -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 */ diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 36f43f8c0d..83e89a98cd 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -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; diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index d0fa09b677..1313e5a010 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -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" ); } diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 5edc5badb4..379c5bb0cd 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -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; diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 287f9c5233..3755109ccd 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -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 ); diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 90903a582a..0ee3715fd2 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -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 ); diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 95c268dcaa..4d51daa852 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -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 ) { diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index 3b3809c2e3..8f6f415052 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -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; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 7893abfa5f..3f80135351 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -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" ); diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index fad9539da9..4a46f3047a 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -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(); diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index f9043a226d..9069c1fed9 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -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() ); diff --git a/include/eda_text.h b/include/eda_text.h index a114e56f1a..aa1b6aa7f2 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -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 diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 852b65c3fc..34d8dc8555 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -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; }