diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp b/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp index 3544f37c8f..312f0d795b 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp +++ b/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp @@ -42,12 +42,14 @@ #include -PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager, +PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, EDA_UNITS_T aUnits, S3D_CACHE* aCacheManager, MODULE* aModuleCopy, COLORS_DESIGN_SETTINGS *aColors, std::vector *aParentInfoList ) : PANEL_PREV_3D_BASE( aParent, wxID_ANY ) { + m_userUnits = aUnits; + initPanel(); // Initialize the color settings to draw the board and the footprint @@ -133,7 +135,7 @@ void PANEL_PREV_3D::initPanel() wxString units; - switch( g_UserUnit ) + switch( m_userUnits ) { case INCHES: units = _( "inches" ); @@ -243,7 +245,7 @@ void PANEL_PREV_3D::SetModelDataIdx( int idx, bool aReloadPreviewModule ) double scaler = 1; - switch( g_UserUnit ) + switch( m_userUnits ) { case MILLIMETRES: scaler = 1.0f; @@ -486,7 +488,7 @@ void PANEL_PREV_3D::onIncrementOffset( wxSpinEvent& event ) double step = OFFSET_INCREMENT_MM; - if( g_UserUnit == INCHES ) + if( m_userUnits == INCHES ) step = OFFSET_INCREMENT_MIL/1000.0; incrementTextCtrl( textCtrl, step, -MAX_OFFSET, MAX_OFFSET ); @@ -506,7 +508,7 @@ void PANEL_PREV_3D::onDecrementOffset( wxSpinEvent& event ) double step = OFFSET_INCREMENT_MM; - if( g_UserUnit == INCHES ) + if( m_userUnits == INCHES ) step = OFFSET_INCREMENT_MIL/1000.0; incrementTextCtrl( textCtrl, -step, -MAX_OFFSET, MAX_OFFSET ); @@ -556,7 +558,7 @@ void PANEL_PREV_3D::onMouseWheelOffset( wxMouseEvent& event ) if( event.ShiftDown( ) ) step = OFFSET_INCREMENT_MM_FINE; - if( g_UserUnit == INCHES ) + if( m_userUnits == INCHES ) { step = OFFSET_INCREMENT_MIL/1000.0; if( event.ShiftDown( ) ) @@ -599,7 +601,7 @@ void PANEL_PREV_3D::getOrientationVars( SGPOINT& aScale, SGPOINT& aRotation, SGP double scaler = 1.0f; - switch( g_UserUnit ) + switch( m_userUnits ) { case MILLIMETRES: scaler = 1.0f; diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_model.h b/3d-viewer/3d_cache/dialogs/panel_prev_model.h index afe8825147..264b36d65a 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_model.h +++ b/3d-viewer/3d_cache/dialogs/panel_prev_model.h @@ -72,7 +72,7 @@ class COLORS_DESIGN_SETTINGS; class PANEL_PREV_3D: public PANEL_PREV_3D_BASE { public: - PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager, + PANEL_PREV_3D( wxWindow* aParent, EDA_UNITS_T aUnits, S3D_CACHE* aCacheManager, MODULE* aModuleCopy, COLORS_DESIGN_SETTINGS *aColors, std::vector *aParentInfoList = NULL ); @@ -104,6 +104,8 @@ private: /// Current MODULE_3D_SETTINGS that is being edited MODULE_3D_SETTINGS m_modelInfo; + EDA_UNITS_T m_userUnits; + // Methods of the class private: void initPanel(); diff --git a/common/preview_items/ruler_item.cpp b/common/preview_items/ruler_item.cpp index 18f9ee1713..2442a17c16 100644 --- a/common/preview_items/ruler_item.cpp +++ b/common/preview_items/ruler_item.cpp @@ -40,12 +40,12 @@ static const double majorTickLengthFactor = 2.5; static void drawCursorStrings( KIGFX::VIEW* aView, const VECTOR2D& aCursor, - const VECTOR2D& aRulerVec ) + const VECTOR2D& aRulerVec, EDA_UNITS_T aUnits ) { // draw the cursor labels std::vector cursorStrings; - cursorStrings.push_back( DimensionLabel( "r", aRulerVec.EuclideanNorm(), g_UserUnit ) ); + cursorStrings.push_back( DimensionLabel( "r", aRulerVec.EuclideanNorm(), aUnits ) ); double degs = RAD2DECIDEG( -aRulerVec.Angle() ); cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), degs, DEGREES ) ); @@ -73,7 +73,7 @@ struct TICK_FORMAT }; -static TICK_FORMAT getTickFormatForScale( double aScale, double& aTickSpace ) +static TICK_FORMAT getTickFormatForScale( double aScale, double& aTickSpace, EDA_UNITS_T aUnits ) { // simple 1/2/5 scales per decade static std::vector tickFormats = @@ -87,7 +87,7 @@ static TICK_FORMAT getTickFormatForScale( double aScale, double& aTickSpace ) aTickSpace = 1; // convert to a round (mod-10) number of mils - if( g_UserUnit == INCHES ) + if( aUnits == INCHES ) { aTickSpace *= 2.54; } @@ -119,12 +119,12 @@ static TICK_FORMAT getTickFormatForScale( double aScale, double& aTickSpace ) * @param aMinorTickLen length of minor ticks in IU */ void drawTicksAlongLine( KIGFX::VIEW *aView, const VECTOR2D& aOrigin, - const VECTOR2D& aLine, double aMinorTickLen ) + const VECTOR2D& aLine, double aMinorTickLen, EDA_UNITS_T aUnits ) { VECTOR2D tickLine = aLine.Rotate( -M_PI_2 ); auto gal = aView->GetGAL(); double tickSpace; - TICK_FORMAT tickF = getTickFormatForScale( gal->GetWorldScale(), tickSpace ); + TICK_FORMAT tickF = getTickFormatForScale( gal->GetWorldScale(), tickSpace, aUnits ); auto rs = static_cast( aView->GetPainter()->GetSettings() ); // number of ticks in whole ruler @@ -170,7 +170,7 @@ void drawTicksAlongLine( KIGFX::VIEW *aView, const VECTOR2D& aOrigin, if( drawLabel ) { - wxString label = DimensionLabel( "", tickSpace * i, g_UserUnit ); + wxString label = DimensionLabel( "", tickSpace * i, aUnits ); // FIXME: spaces choke OpenGL lp:1668455 label.erase( std::remove( label.begin(), label.end(), ' ' ), label.end() ); @@ -205,9 +205,10 @@ void drawBacksideTicks( KIGFX::GAL& aGal, const VECTOR2D& aOrigin, } -RULER_ITEM::RULER_ITEM( const TWO_POINT_GEOMETRY_MANAGER& aGeomMgr ): +RULER_ITEM::RULER_ITEM( const TWO_POINT_GEOMETRY_MANAGER& aGeomMgr, EDA_UNITS_T userUnits ): EDA_ITEM( NOT_USED ), // Never added to anything - just a preview - m_geomMgr( aGeomMgr ) + m_geomMgr( aGeomMgr ), + m_userUnits( userUnits ) {} @@ -254,7 +255,7 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const // constant text size on screen SetConstantGlyphHeight( gal, 14.0 ); - drawCursorStrings( aView, end, rulerVec ); + drawCursorStrings( aView, end, rulerVec, m_userUnits ); // tick label size SetConstantGlyphHeight( gal, 12.0 ); @@ -262,7 +263,7 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const // basic tick size const double minorTickLen = 5.0 / gal.GetWorldScale(); - drawTicksAlongLine( aView, origin, rulerVec, minorTickLen ); + drawTicksAlongLine( aView, origin, rulerVec, minorTickLen, m_userUnits ); gal.SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ).WithAlpha( PreviewOverlayDeemphAlpha( true ) ) ); drawBacksideTicks( gal, origin, rulerVec, minorTickLen * majorTickLengthFactor, 2 ); diff --git a/common/tool/grid_menu.cpp b/common/tool/grid_menu.cpp index 24bde69014..5098ccc51e 100644 --- a/common/tool/grid_menu.cpp +++ b/common/tool/grid_menu.cpp @@ -35,13 +35,13 @@ using namespace std::placeholders; GRID_MENU::GRID_MENU( EDA_DRAW_FRAME* aParent ) : m_parent( aParent ) { - BASE_SCREEN* screen = aParent->GetScreen(); + BASE_SCREEN* screen = m_parent->GetScreen(); SetTitle( _( "Grid" ) ); SetIcon( grid_select_xpm ); wxArrayString gridsList; - screen->BuildGridsChoiceList( gridsList, g_UserUnit != INCHES ); + screen->BuildGridsChoiceList( gridsList, m_parent->GetUserUnits() != INCHES ); for( unsigned int i = 0; i < gridsList.GetCount(); ++i ) { @@ -67,7 +67,7 @@ void GRID_MENU::update() int currentId = screen->GetGridCmdId(); wxArrayString gridsList; - screen->BuildGridsChoiceList( gridsList, g_UserUnit != INCHES ); + screen->BuildGridsChoiceList( gridsList, m_parent->GetUserUnits() != INCHES ); for( unsigned int i = 0; i < GetMenuItemCount(); ++i ) { diff --git a/common/zoom.cpp b/common/zoom.cpp index 9e4629f37c..168893f1c8 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -315,7 +315,7 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu ) _( "Grid" ), KiBitmap( grid_select_xpm ) ); wxArrayString gridsList; - int icurr = screen->BuildGridsChoiceList( gridsList, g_UserUnit != INCHES ); + int icurr = screen->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES ); for( unsigned i = 0; i < gridsList.GetCount(); i++ ) { diff --git a/eeschema/dialogs/dialog_sch_edit_sheet_pin.cpp b/eeschema/dialogs/dialog_sch_edit_sheet_pin.cpp index a711dae961..c9f1bbdd87 100644 --- a/eeschema/dialogs/dialog_sch_edit_sheet_pin.cpp +++ b/eeschema/dialogs/dialog_sch_edit_sheet_pin.cpp @@ -22,6 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include @@ -35,14 +36,15 @@ static wxString sheetPinTypes[] = }; -#define SHEET_PIN_TYPE_CNT ( sizeof( sheetPinTypes ) / sizeof( wxString ) ) - - -DIALOG_SCH_EDIT_SHEET_PIN::DIALOG_SCH_EDIT_SHEET_PIN( wxWindow* parent ) : - DIALOG_SCH_EDIT_SHEET_PIN_BASE( parent ) +DIALOG_SCH_EDIT_SHEET_PIN::DIALOG_SCH_EDIT_SHEET_PIN( SCH_EDIT_FRAME* parent, SCH_SHEET_PIN* aPin ) : + DIALOG_SCH_EDIT_SHEET_PIN_BASE( parent ), + m_frame( parent ), + m_sheetPin( aPin ), + m_textWidth( parent, m_widthLabel, m_widthCtrl, m_widthUnits, true ), + m_textHeight( parent, m_heightLabel, m_heightCtrl, m_heightUnits, true ) { - for( size_t i = 0; i < SHEET_PIN_TYPE_CNT; i++ ) - m_choiceConnectionType->Append( sheetPinTypes[ i ] ); + for( const wxString& sheetPinType : sheetPinTypes ) + m_choiceConnectionType->Append( sheetPinType ); m_choiceConnectionType->SetSelection( 0 ); m_textName->SetFocus(); @@ -55,6 +57,15 @@ DIALOG_SCH_EDIT_SHEET_PIN::DIALOG_SCH_EDIT_SHEET_PIN( wxWindow* parent ) : // Now all widgets have the size fixed, call FinishDialogSettings FinishDialogSettings(); + /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier versions for + * the flex grid sizer in wxGTK that prevents the last column from being sized + * correctly. It doesn't cause any problems on win32 so it doesn't need to wrapped + * in ugly #ifdef __WXGTK__ #endif. + */ + Layout(); + Fit(); + SetMinSize( GetSize() ); + // On some windows manager (Unity, XFCE), this dialog is // not always raised, depending on this dialog is run. // Force it to be raised @@ -62,6 +73,36 @@ DIALOG_SCH_EDIT_SHEET_PIN::DIALOG_SCH_EDIT_SHEET_PIN( wxWindow* parent ) : } +bool DIALOG_SCH_EDIT_SHEET_PIN::TransferDataToWindow() +{ + m_textName->SetValue( m_sheetPin->GetText() ); + m_textWidth.SetValue( m_sheetPin->GetTextWidth() ); + m_textHeight.SetValue( m_sheetPin->GetTextHeight() ); + m_choiceConnectionType->SetSelection( m_sheetPin->GetShape() ); + + return true; +} + + +bool DIALOG_SCH_EDIT_SHEET_PIN::TransferDataFromWindow() +{ + if( !m_sheetPin->IsNew() ) + { + m_frame->SaveCopyInUndoList( (SCH_ITEM*) m_sheetPin->GetParent(), UR_CHANGED ); + m_frame->GetScreen()->SetCurItem( nullptr ); + } + + m_sheetPin->SetText( m_textName->GetValue() ); + m_sheetPin->SetTextSize( wxSize( m_textWidth.GetValue(), m_textHeight.GetValue() ) ); + + auto shape = static_cast( m_choiceConnectionType->GetCurrentSelection() ); + m_sheetPin->SetShape( shape ); + + m_frame->OnModify(); + + return true; +} + void DIALOG_SCH_EDIT_SHEET_PIN::onOKButton( wxCommandEvent& event ) { diff --git a/eeschema/dialogs/dialog_sch_edit_sheet_pin.h b/eeschema/dialogs/dialog_sch_edit_sheet_pin.h index 38b1b04ab1..e60a69cf50 100644 --- a/eeschema/dialogs/dialog_sch_edit_sheet_pin.h +++ b/eeschema/dialogs/dialog_sch_edit_sheet_pin.h @@ -34,31 +34,25 @@ #include #include // enum PINSHEETLABEL_SHAPE definition +#include + + +class SCH_SHEET_PIN; class DIALOG_SCH_EDIT_SHEET_PIN : public DIALOG_SCH_EDIT_SHEET_PIN_BASE { + SCH_EDIT_FRAME* m_frame; + SCH_SHEET_PIN* m_sheetPin; + + UNIT_BINDER m_textWidth; + UNIT_BINDER m_textHeight; + public: - DIALOG_SCH_EDIT_SHEET_PIN( wxWindow* parent ); + DIALOG_SCH_EDIT_SHEET_PIN( SCH_EDIT_FRAME* parent, SCH_SHEET_PIN* aPin ); - // Set the label text in m_textName. - // Because m_textName uses a wxTextValidator, the label text must be stored in the - // validator string - void SetLabelName( const wxString& aName ) { m_labelString = aName; } - wxString GetLabelName() const { return m_textName->GetValue(); } - - void SetTextHeight( const wxString& aHeight ) { m_textHeight->SetValue( aHeight ); } - wxString GetTextHeight() const { return m_textHeight->GetValue(); } - - void SetTextWidth( const wxString& aWidth ) { m_textWidth->SetValue( aWidth ); } - wxString GetTextWidth() const { return m_textWidth->GetValue(); } - - void SetConnectionType( PINSHEETLABEL_SHAPE aType ) { m_choiceConnectionType->SetSelection( aType ); } - /// @todo move cast to widget - PINSHEETLABEL_SHAPE GetConnectionType() const { return static_cast( m_choiceConnectionType->GetCurrentSelection() ); } - - void SetTextHeightUnits( const wxString& aUnit ) { m_staticHeightUnits->SetLabel( aUnit ); } - void SetTextWidthUnits( const wxString& aUnit ) { m_staticWidthUnits->SetLabel( aUnit ); } + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; private: void onOKButton( wxCommandEvent& event ) override; diff --git a/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.cpp b/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.cpp index 8413603c02..fbf0c13379 100644 --- a/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.cpp +++ b/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.cpp @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jul 2 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #include "dialog_sch_edit_sheet_pin_base.h" @@ -27,46 +27,48 @@ DIALOG_SCH_EDIT_SHEET_PIN_BASE::DIALOG_SCH_EDIT_SHEET_PIN_BASE( wxWindow* parent m_staticText1 = new wxStaticText( this, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1->Wrap( -1 ); - fgSizer1->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 6 ); + fgSizer1->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_textName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textName->SetMinSize( wxSize( 160,-1 ) ); + m_textName->SetValidator( wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, &m_labelString ) ); - fgSizer1->Add( m_textName, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 6 ); + fgSizer1->Add( m_textName, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); fgSizer1->Add( 0, 0, 1, wxEXPAND, 6 ); - m_staticText2 = new wxStaticText( this, wxID_ANY, _("Text height:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText2->Wrap( -1 ); - fgSizer1->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 6 ); + m_heightLabel = new wxStaticText( this, wxID_ANY, _("Text height:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_heightLabel->Wrap( -1 ); + fgSizer1->Add( m_heightLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - m_textHeight = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_textHeight, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 6 ); + m_heightCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer1->Add( m_heightCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - m_staticHeightUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticHeightUnits->Wrap( -1 ); - fgSizer1->Add( m_staticHeightUnits, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 6 ); + m_heightUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); + m_heightUnits->Wrap( -1 ); + fgSizer1->Add( m_heightUnits, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); - m_staticText5 = new wxStaticText( this, wxID_ANY, _("Text width:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText5->Wrap( -1 ); - fgSizer1->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 6 ); + m_widthLabel = new wxStaticText( this, wxID_ANY, _("Text width:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_widthLabel->Wrap( -1 ); + fgSizer1->Add( m_widthLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - m_textWidth = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_textWidth, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 6 ); + m_widthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer1->Add( m_widthCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - m_staticWidthUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticWidthUnits->Wrap( -1 ); - fgSizer1->Add( m_staticWidthUnits, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 6 ); + m_widthUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); + m_widthUnits->Wrap( -1 ); + fgSizer1->Add( m_widthUnits, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); m_staticText3 = new wxStaticText( this, wxID_ANY, _("Connection type:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText3->Wrap( -1 ); - fgSizer1->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 6 ); + fgSizer1->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 ); wxArrayString m_choiceConnectionTypeChoices; m_choiceConnectionType = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceConnectionTypeChoices, 0 ); m_choiceConnectionType->SetSelection( 0 ); - fgSizer1->Add( m_choiceConnectionType, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 6 ); + fgSizer1->Add( m_choiceConnectionType, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5 ); fgSizer1->Add( 0, 0, 1, wxEXPAND, 6 ); @@ -75,10 +77,10 @@ DIALOG_SCH_EDIT_SHEET_PIN_BASE::DIALOG_SCH_EDIT_SHEET_PIN_BASE( wxWindow* parent m_nameSizer->Add( fgSizer1, 1, wxEXPAND, 6 ); - m_mainSizer->Add( m_nameSizer, 1, wxALL|wxEXPAND, 6 ); + m_mainSizer->Add( m_nameSizer, 1, wxALL|wxEXPAND, 10 ); - - m_mainSizer->Add( 0, 0, 0, wxALL|wxEXPAND, 3 ); + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + m_mainSizer->Add( m_staticline1, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizerOK = new wxButton( this, wxID_OK ); diff --git a/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.fbp b/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.fbp index be04da0d57..88eb5a41be 100644 --- a/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.fbp +++ b/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.fbp @@ -94,7 +94,7 @@ wxVERTICAL none - 6 + 10 wxALL|wxEXPAND 1 @@ -119,8 +119,8 @@ 4 0 - 6 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -202,8 +202,8 @@ - 6 - wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -239,7 +239,7 @@ 0 0 - + 160,-1 1 m_textName 1 @@ -303,7 +303,7 @@ - 6 + 5 wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT 0 @@ -342,7 +342,7 @@ 0 1 - m_staticText2 + m_heightLabel 1 @@ -386,7 +386,7 @@ - 6 + 5 wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT 0 @@ -425,7 +425,7 @@ 0 1 - m_textHeight + m_heightCtrl 1 @@ -477,8 +477,8 @@ - 6 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 1 @@ -516,7 +516,7 @@ 0 1 - m_staticHeightUnits + m_heightUnits 1 @@ -560,7 +560,7 @@ - 6 + 5 wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT 0 @@ -599,7 +599,7 @@ 0 1 - m_staticText5 + m_widthLabel 1 @@ -643,7 +643,7 @@ - 6 + 5 wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT 0 @@ -682,7 +682,7 @@ 0 1 - m_textWidth + m_widthCtrl 1 @@ -734,8 +734,8 @@ - 6 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 1 @@ -773,7 +773,7 @@ 0 1 - m_staticWidthUnits + m_widthUnits 1 @@ -817,7 +817,7 @@ - 6 + 5 wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT 0 @@ -900,8 +900,8 @@ - 6 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND 0 1 @@ -1002,13 +1002,84 @@ - 3 - wxALL|wxEXPAND + 10 + wxEXPAND|wxRIGHT|wxLEFT 0 - - 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline1 + 1 + + protected - 0 + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; forward_declare + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.h b/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.h index db178edfcd..d4f138bb3e 100644 --- a/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.h +++ b/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.h @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jul 2 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #ifndef __DIALOG_SCH_EDIT_SHEET_PIN_BASE_H__ @@ -11,8 +11,6 @@ #include #include #include -class DIALOG_SHIM; - #include "dialog_shim.h" #include #include @@ -24,6 +22,7 @@ class DIALOG_SHIM; #include #include #include +#include #include #include @@ -40,14 +39,15 @@ class DIALOG_SCH_EDIT_SHEET_PIN_BASE : public DIALOG_SHIM protected: wxStaticText* m_staticText1; wxTextCtrl* m_textName; - wxStaticText* m_staticText2; - wxTextCtrl* m_textHeight; - wxStaticText* m_staticHeightUnits; - wxStaticText* m_staticText5; - wxTextCtrl* m_textWidth; - wxStaticText* m_staticWidthUnits; + wxStaticText* m_heightLabel; + wxTextCtrl* m_heightCtrl; + wxStaticText* m_heightUnits; + wxStaticText* m_widthLabel; + wxTextCtrl* m_widthCtrl; + wxStaticText* m_widthUnits; wxStaticText* m_staticText3; wxChoice* m_choiceConnectionType; + wxStaticLine* m_staticline1; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel; diff --git a/eeschema/dialogs/dialog_sch_sheet_props.cpp b/eeschema/dialogs/dialog_sch_sheet_props.cpp index 140ba45ba4..3d622c59be 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.cpp +++ b/eeschema/dialogs/dialog_sch_sheet_props.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2009 Wayne Stambaugh - * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2014-2018 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,12 +23,17 @@ */ #include +#include #include #include +#include +#include - -DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( wxWindow* parent ) : - DIALOG_SCH_SHEET_PROPS_BASE( parent ) +DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( SCH_EDIT_FRAME* parent, SCH_SHEET* aSheet ) : + DIALOG_SCH_SHEET_PROPS_BASE( parent ), + m_sheet( aSheet ), + m_filenameTextSize( parent, m_filenameSizeLabel, m_filenameSizeCtrl, m_filenameSizeUnits, true ), + m_sheetnameTextSize( parent, m_sheetnameSizeLabel, m_sheetnameSizeCtrl, m_sheetnameSizeUnits, true ) { m_textFileName->SetValidator( FILE_NAME_WITH_PATH_CHAR_VALIDATOR() ); m_textFileName->SetFocus(); @@ -36,17 +41,66 @@ DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( wxWindow* parent ) : // Now all widgets have the size fixed, call FinishDialogSettings FinishDialogSettings(); + + /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier + * versions for the flex grid sizer in wxGTK that prevents the last + * column from being sized correctly. It doesn't cause any problems + * on win32 so it doesn't need to wrapped in ugly #ifdef __WXGTK__ + * #endif. + * Still present in wxWidgets 3.0.2 + */ + Layout(); + Fit(); + SetMinSize( GetSize() ); + GetSizer()->Fit( this ); } -void DIALOG_SCH_SHEET_PROPS::SetFileName( const wxString& aFileName ) +bool DIALOG_SCH_SHEET_PROPS::TransferDataToWindow() { // Filenames are stored using unix notation - wxString fname = aFileName; + wxString fname = m_sheet->GetFileName(); + #ifdef __WINDOWS__ fname.Replace( wxT("/"), wxT("\\") ); #endif m_textFileName->SetValue( fname ); + + m_textSheetName->SetValue( m_sheet->GetName() ); + + m_filenameTextSize.SetValue( m_sheet->GetFileNameSize() ); + m_sheetnameTextSize.SetValue( m_sheet->GetSheetNameSize() ); + + auto tstamp = wxString::Format( wxT( "%8.8lX" ), (unsigned long) m_sheet->GetTimeStamp() ); + m_textCtrlTimeStamp->SetValue( tstamp ); + + return true; +} + + +bool DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow() +{ + wxFileName fileName = GetFileName(); + fileName.SetExt( SchematicFileExtension ); + + if( !fileName.IsOk() ) + { + DisplayError( this, _( "File name is not valid!" ) ); + return false; + } + + // Duplicate sheet names are not valid. + SCH_SHEET_LIST hierarchy( g_RootSheet ); + const SCH_SHEET* sheet = hierarchy.FindSheetByName( GetSheetName() ); + + if( sheet && (sheet != m_sheet) ) + { + DisplayError( this, wxString::Format( _( "A sheet named \"%s\" already exists." ), + GetSheetName() ) ); + return false; + } + + return true; } diff --git a/eeschema/dialogs/dialog_sch_sheet_props.h b/eeschema/dialogs/dialog_sch_sheet_props.h index e4aa3a6e6a..87c65a29e1 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.h +++ b/eeschema/dialogs/dialog_sch_sheet_props.h @@ -25,56 +25,33 @@ #ifndef __dialog_sch_sheet_props__ #define __dialog_sch_sheet_props__ -/** - * @file - * Subclass of DIALOG_SCH_SHEET_PROPS_BASE, which is generated by wxFormBuilder. - */ - #include +#include + + +class SCH_SHEET; +class SCH_EDIT_FRAME; + /** Implementing DIALOG_SCH_SHEET_PROPS_BASE */ class DIALOG_SCH_SHEET_PROPS : public DIALOG_SCH_SHEET_PROPS_BASE { + SCH_SHEET* m_sheet; + + UNIT_BINDER m_filenameTextSize; + UNIT_BINDER m_sheetnameTextSize; + public: /** Constructor */ - DIALOG_SCH_SHEET_PROPS( wxWindow* parent ); + DIALOG_SCH_SHEET_PROPS( SCH_EDIT_FRAME* parent, SCH_SHEET* aSheet ); + + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; - void SetFileName( const wxString& aFileName ); const wxString GetFileName(); - - void SetSheetName( const wxString& aSheetName ) - { - m_textSheetName->SetValue( aSheetName ); - } wxString GetSheetName() { return m_textSheetName->GetValue(); } - - void SetFileNameTextSize( const wxString& aTextSize ) - { - m_textFileNameSize->SetValue( aTextSize ); - } - wxString GetFileNameTextSize() { return m_textFileNameSize->GetValue(); } - - void SetSheetNameTextSize( const wxString& aTextSize ) - { - m_textSheetNameSize->SetValue( aTextSize ); - } - wxString GetSheetNameTextSize() { return m_textSheetNameSize->GetValue(); } - - void SetFileNameTextSizeUnits(const wxString& aUnits) - { - m_staticFileNameSizeUnits->SetLabel( aUnits ); - } - - void SetSheetNameTextSizeUnits(const wxString& aUnits) - { - m_staticSheetNameSizeUnits->SetLabel( aUnits ); - } - - void SetSheetTimeStamp(const wxString& aTimeStamp) - { - m_textCtrlTimeStamp->SetValue( aTimeStamp ); - } - + int GetFileNameTextSize() { return m_filenameTextSize.GetValue(); } + int GetSheetNameTextSize() { return m_sheetnameTextSize.GetValue(); } }; #endif // __dialog_sch_sheet_props__ diff --git a/eeschema/dialogs/dialog_sch_sheet_props_base.cpp b/eeschema/dialogs/dialog_sch_sheet_props_base.cpp index b8846a400c..f400fb465f 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props_base.cpp +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.cpp @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 4 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #include "dialog_sch_sheet_props_base.h" @@ -25,55 +25,55 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi fgSizer1->SetFlexibleDirection( wxBOTH ); fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_staticText1 = new wxStaticText( this, wxID_ANY, _("&File name:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText1->Wrap( -1 ); - fgSizer1->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + m_filenameLabel = new wxStaticText( this, wxID_ANY, _("&File name:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_filenameLabel->Wrap( -1 ); + fgSizer1->Add( m_filenameLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); m_textFileName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_textFileName->SetMinSize( wxSize( 200,-1 ) ); - fgSizer1->Add( m_textFileName, 5, wxEXPAND|wxTOP|wxBOTTOM, 3 ); + fgSizer1->Add( m_textFileName, 5, wxEXPAND|wxTOP, 5 ); - fgSizer1->Add( 0, 0, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 3 ); + fgSizer1->Add( 0, 0, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT, 10 ); - m_staticText2 = new wxStaticText( this, wxID_ANY, _("Si&ze:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText2->Wrap( -1 ); - fgSizer1->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + m_filenameSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_filenameSizeLabel->Wrap( -1 ); + fgSizer1->Add( m_filenameSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_textFileNameSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_textFileNameSize, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 3 ); + m_filenameSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer1->Add( m_filenameSizeCtrl, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 ); - m_staticFileNameSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticFileNameSizeUnits->Wrap( -1 ); - fgSizer1->Add( m_staticFileNameSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + m_filenameSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); + m_filenameSizeUnits->Wrap( -1 ); + fgSizer1->Add( m_filenameSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_staticText4 = new wxStaticText( this, wxID_ANY, _("&Sheet name:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText4->Wrap( -1 ); - fgSizer1->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + m_sheetnameLabel = new wxStaticText( this, wxID_ANY, _("&Sheet name:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_sheetnameLabel->Wrap( -1 ); + fgSizer1->Add( m_sheetnameLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); m_textSheetName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_textSheetName, 5, wxEXPAND|wxTOP|wxBOTTOM, 3 ); + fgSizer1->Add( m_textSheetName, 5, wxEXPAND|wxTOP, 5 ); - fgSizer1->Add( 0, 0, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + fgSizer1->Add( 0, 0, 0, wxALIGN_CENTER_VERTICAL|wxALL, 10 ); - m_staticText5 = new wxStaticText( this, wxID_ANY, _("&Size:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText5->Wrap( -1 ); - fgSizer1->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + m_sheetnameSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_sheetnameSizeLabel->Wrap( -1 ); + fgSizer1->Add( m_sheetnameSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_textSheetNameSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_textSheetNameSize, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 3 ); + m_sheetnameSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer1->Add( m_sheetnameSizeCtrl, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 ); - m_staticSheetNameSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticSheetNameSizeUnits->Wrap( -1 ); - fgSizer1->Add( m_staticSheetNameSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + m_sheetnameSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); + m_sheetnameSizeUnits->Wrap( -1 ); + fgSizer1->Add( m_sheetnameSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - fgSizer1->Add( m_staticline2, 0, wxEXPAND|wxALL, 5 ); - m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - fgSizer1->Add( m_staticline3, 0, wxEXPAND | wxALL, 5 ); + fgSizer1->Add( 0, 0, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 ); + + + fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); @@ -98,13 +98,10 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi bupperSizer->Add( fgSizer1, 1, wxALL|wxEXPAND, 5 ); - mainSizer->Add( bupperSizer, 0, wxEXPAND, 5 ); - - - mainSizer->Add( 0, 0, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + mainSizer->Add( bupperSizer, 0, wxEXPAND|wxTOP, 5 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - mainSizer->Add( m_staticline1, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + mainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( this, wxID_OK ); @@ -118,6 +115,7 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi this->SetSizer( mainSizer ); this->Layout(); + mainSizer->Fit( this ); this->Centre( wxBOTH ); } diff --git a/eeschema/dialogs/dialog_sch_sheet_props.fbp b/eeschema/dialogs/dialog_sch_sheet_props_base.fbp similarity index 87% rename from eeschema/dialogs/dialog_sch_sheet_props.fbp rename to eeschema/dialogs/dialog_sch_sheet_props_base.fbp index f81bb957e2..f7d195c9a4 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.fbp +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.fbp @@ -44,7 +44,7 @@ 500,150 DIALOG_SCH_SHEET_PROPS_BASE - 519,185 + -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Schematic Sheet Properties @@ -95,7 +95,7 @@ none 5 - wxEXPAND + wxEXPAND|wxTOP 0 @@ -119,8 +119,8 @@ 0 0 - 3 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -158,7 +158,7 @@ 0 1 - m_staticText1 + m_filenameLabel 1 @@ -202,8 +202,8 @@ - 3 - wxEXPAND|wxTOP|wxBOTTOM + 5 + wxEXPAND|wxTOP 5 1 @@ -293,9 +293,9 @@ - 3 - wxALIGN_CENTER_HORIZONTAL|wxALL - 1 + 10 + wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT + 0 0 protected @@ -303,8 +303,8 @@ - 3 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -334,7 +334,7 @@ 0 0 wxID_ANY - Si&ze: + Text size: 0 @@ -342,7 +342,7 @@ 0 1 - m_staticText2 + m_filenameSizeLabel 1 @@ -386,8 +386,8 @@ - 3 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + 5 + wxALIGN_CENTER_VERTICAL|wxTOP 0 1 @@ -425,7 +425,7 @@ 0 1 - m_textFileNameSize + m_filenameSizeCtrl 1 @@ -477,8 +477,8 @@ - 3 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -516,7 +516,7 @@ 0 1 - m_staticFileNameSizeUnits + m_filenameSizeUnits 1 @@ -560,8 +560,8 @@ - 3 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -599,7 +599,7 @@ 0 1 - m_staticText4 + m_sheetnameLabel 1 @@ -643,8 +643,8 @@ - 3 - wxEXPAND|wxTOP|wxBOTTOM + 5 + wxEXPAND|wxTOP 5 1 @@ -734,9 +734,9 @@ - 3 + 10 wxALIGN_CENTER_VERTICAL|wxALL - 1 + 0 0 protected @@ -744,8 +744,8 @@ - 3 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -775,7 +775,7 @@ 0 0 wxID_ANY - &Size: + Text size: 0 @@ -783,7 +783,7 @@ 0 1 - m_staticText5 + m_sheetnameSizeLabel 1 @@ -827,8 +827,8 @@ - 3 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + 5 + wxALIGN_CENTER_VERTICAL|wxTOP 0 1 @@ -866,7 +866,7 @@ 0 1 - m_textSheetNameSize + m_sheetnameSizeCtrl 1 @@ -918,8 +918,8 @@ - 3 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -957,7 +957,7 @@ 0 1 - m_staticSheetNameSizeUnits + m_sheetnameSizeUnits 1 @@ -1002,164 +1002,22 @@ 5 - wxEXPAND|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline2 - 1 - - + wxEXPAND|wxTOP|wxBOTTOM + 1 + + 0 protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - + 0 5 - wxEXPAND | wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline3 - 1 - - + wxEXPAND + 1 + + 0 protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - + 0 @@ -1382,17 +1240,7 @@ 5 - wxBOTTOM|wxRIGHT|wxLEFT - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND|wxRIGHT|wxLEFT + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 1 diff --git a/eeschema/dialogs/dialog_sch_sheet_props_base.h b/eeschema/dialogs/dialog_sch_sheet_props_base.h index 2bdc81f1c9..ddff1bcafb 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props_base.h +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.h @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 4 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #ifndef __DIALOG_SCH_SHEET_PROPS_BASE_H__ @@ -11,8 +11,6 @@ #include #include #include -class DIALOG_SHIM; - #include "dialog_shim.h" #include #include @@ -21,8 +19,8 @@ class DIALOG_SHIM; #include #include #include -#include #include +#include #include #include @@ -36,18 +34,16 @@ class DIALOG_SCH_SHEET_PROPS_BASE : public DIALOG_SHIM private: protected: - wxStaticText* m_staticText1; + wxStaticText* m_filenameLabel; wxTextCtrl* m_textFileName; - wxStaticText* m_staticText2; - wxTextCtrl* m_textFileNameSize; - wxStaticText* m_staticFileNameSizeUnits; - wxStaticText* m_staticText4; + wxStaticText* m_filenameSizeLabel; + wxTextCtrl* m_filenameSizeCtrl; + wxStaticText* m_filenameSizeUnits; + wxStaticText* m_sheetnameLabel; wxTextCtrl* m_textSheetName; - wxStaticText* m_staticText5; - wxTextCtrl* m_textSheetNameSize; - wxStaticText* m_staticSheetNameSizeUnits; - wxStaticLine* m_staticline2; - wxStaticLine* m_staticline3; + wxStaticText* m_sheetnameSizeLabel; + wxTextCtrl* m_sheetnameSizeCtrl; + wxStaticText* m_sheetnameSizeUnits; wxStaticText* m_staticTextTimeStamp; wxTextCtrl* m_textCtrlTimeStamp; wxStaticLine* m_staticline1; @@ -57,7 +53,7 @@ class DIALOG_SCH_SHEET_PROPS_BASE : public DIALOG_SHIM public: - DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Schematic Sheet Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 519,185 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Schematic Sheet Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_SCH_SHEET_PROPS_BASE(); }; diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 848ac58d01..e91eb576a5 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -202,10 +202,10 @@ void SCH_BASE_FRAME::UpdateStatusBar() EDA_DRAW_FRAME::UpdateStatusBar(); // Display absolute coordinates: - double dXpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().x ); - double dYpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().y ); + double dXpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().x ); + double dYpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().y ); - if ( g_UserUnit == MILLIMETRES ) + if ( GetUserUnits() == MILLIMETRES ) { dXpos = RoundTo0( dXpos, 100.0 ); dYpos = RoundTo0( dYpos, 100.0 ); @@ -214,7 +214,7 @@ void SCH_BASE_FRAME::UpdateStatusBar() wxString absformatter; wxString locformatter; - switch( g_UserUnit ) + switch( GetUserUnits() ) { case INCHES: absformatter = wxT( "X %.3f Y %.3f" ); @@ -243,10 +243,10 @@ void SCH_BASE_FRAME::UpdateStatusBar() dx = GetCrossHairPosition().x - screen->m_O_Curseur.x; dy = GetCrossHairPosition().y - screen->m_O_Curseur.y; - dXpos = To_User_Unit( g_UserUnit, dx ); - dYpos = To_User_Unit( g_UserUnit, dy ); + dXpos = To_User_Unit( GetUserUnits(), dx ); + dYpos = To_User_Unit( GetUserUnits(), dy ); - if( g_UserUnit == MILLIMETRES ) + if( GetUserUnits() == MILLIMETRES ) { dXpos = RoundTo0( dXpos, 100.0 ); dYpos = RoundTo0( dYpos, 100.0 ); diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 8212561591..bea2fdde64 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -50,29 +49,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy ) SCH_SHEET_LIST hierarchy( g_RootSheet ); // This is the schematic sheet hierarchy. // Get the new texts - DIALOG_SCH_SHEET_PROPS dlg( this ); - - wxString units = GetUnitsLabel( g_UserUnit ); - dlg.SetFileName( aSheet->GetFileName() ); - dlg.SetFileNameTextSize( StringFromValue( g_UserUnit, aSheet->GetFileNameSize() ) ); - dlg.SetFileNameTextSizeUnits( units ); - dlg.SetSheetName( aSheet->GetName() ); - dlg.SetSheetNameTextSize( StringFromValue( g_UserUnit, aSheet->GetSheetNameSize() ) ); - dlg.SetSheetNameTextSizeUnits( units ); - dlg.SetSheetTimeStamp( wxString::Format( wxT( "%8.8lX" ), - (unsigned long) aSheet->GetTimeStamp() ) ); - - /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier - * versions for the flex grid sizer in wxGTK that prevents the last - * column from being sized correctly. It doesn't cause any problems - * on win32 so it doesn't need to wrapped in ugly #ifdef __WXGTK__ - * #endif. - * Still present in wxWidgets 3.0.2 - */ - dlg.Layout(); - dlg.Fit(); - dlg.SetMinSize( dlg.GetSize() ); - dlg.GetSizer()->Fit( &dlg ); + DIALOG_SCH_SHEET_PROPS dlg( this, aSheet ); if( dlg.ShowModal() == wxID_CANCEL ) return false; @@ -80,22 +57,6 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy ) wxFileName fileName = dlg.GetFileName(); fileName.SetExt( SchematicFileExtension ); - if( !fileName.IsOk() ) - { - DisplayError( this, _( "File name is not valid!" ) ); - return false; - } - - // Duplicate sheet names are not valid. - const SCH_SHEET* sheet = hierarchy.FindSheetByName( dlg.GetSheetName() ); - - if( sheet && (sheet != aSheet) ) - { - DisplayError( this, wxString::Format( _( "A sheet named \"%s\" already exists." ), - dlg.GetSheetName() ) ); - return false; - } - wxString msg; bool loadFromFile = false; bool clearAnnotation = false; @@ -122,8 +83,9 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy ) if( !g_RootSheet->SearchHierarchy( newFilename, &useScreen ) ) { loadFromFile = wxFileExists( newFilename ); - wxLogDebug( "Sheet requested file \"%s\", %s", newFilename, - ( loadFromFile ) ? "found" : "not found" ); + wxLogDebug( "Sheet requested file \"%s\", %s", + newFilename, + ( loadFromFile ) ? "found" : "not found" ); } // Inside Eeschema, filenames are stored using unix notation @@ -273,9 +235,8 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy ) if( !pi->GetError().IsEmpty() ) { DisplayErrorMessage( this, - _( "The entire schematic could not be load. Errors " - "occurred attempting to load hierarchical sheet " - "schematics." ), + _( "The entire schematic could not be loaded.\n" + "Errors occurred loading hierarchical sheets." ), pi->GetError() ); } } @@ -291,9 +252,9 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy ) } } - aSheet->SetFileNameSize( ValueFromString( g_UserUnit, dlg.GetFileNameTextSize() ) ); + aSheet->SetFileNameSize( dlg.GetFileNameTextSize() ); aSheet->SetName( dlg.GetSheetName() ); - aSheet->SetSheetNameSize( ValueFromString( g_UserUnit, dlg.GetSheetNameTextSize() ) ); + aSheet->SetSheetNameSize( dlg.GetSheetNameTextSize() ); if( aSheet->GetName().IsEmpty() ) aSheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ), diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index 7387755b08..dd9c9d009c 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -34,9 +34,7 @@ #include #include #include -#include -#include #include #include @@ -63,43 +61,11 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw ) if( aSheetPin == NULL ) return wxID_CANCEL; - DIALOG_SCH_EDIT_SHEET_PIN dlg( this ); - - dlg.SetLabelName( aSheetPin->GetText() ); - dlg.SetTextHeight( StringFromValue( g_UserUnit, aSheetPin->GetTextHeight() ) ); - dlg.SetTextHeightUnits( GetUnitsLabel( g_UserUnit ) ); - dlg.SetTextWidth( StringFromValue( g_UserUnit, aSheetPin->GetTextWidth() ) ); - dlg.SetTextWidthUnits( GetUnitsLabel( g_UserUnit ) ); - dlg.SetConnectionType( aSheetPin->GetShape() ); - - /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier versions for - * the flex grid sizer in wxGTK that prevents the last column from being sized - * correctly. It doesn't cause any problems on win32 so it doesn't need to wrapped - * in ugly #ifdef __WXGTK__ #endif. - */ - dlg.Layout(); - dlg.Fit(); - dlg.SetMinSize( dlg.GetSize() ); + DIALOG_SCH_EDIT_SHEET_PIN dlg( this, aSheetPin ); if( dlg.ShowModal() == wxID_CANCEL ) return wxID_CANCEL; - if( !aSheetPin->IsNew() ) - { - SaveCopyInUndoList( (SCH_ITEM*) aSheetPin->GetParent(), UR_CHANGED ); - GetScreen()->SetCurItem( NULL ); - } - - aSheetPin->SetText( dlg.GetLabelName() ); - - aSheetPin->SetTextSize( wxSize( - ValueFromString( g_UserUnit, dlg.GetTextWidth() ), - ValueFromString( g_UserUnit, dlg.GetTextHeight() ) ) ); - - aSheetPin->SetShape( dlg.GetConnectionType() ); - - OnModify(); - if( aRedraw ) m_canvas->Refresh(); diff --git a/gerbview/gerber_file_image.cpp b/gerbview/gerber_file_image.cpp index 15543bded4..df4783169a 100644 --- a/gerbview/gerber_file_image.cpp +++ b/gerbview/gerber_file_image.cpp @@ -360,7 +360,7 @@ void GERBER_FILE_IMAGE::DisplayImageInfo( GERBVIEW_FRAME* aMainFrame ) msg = m_ImageJustifyYCenter ? _("Center") : _("Normal"); aMainFrame->AppendMsgPanel( _( "Y Justify" ), msg, DARKRED ); - if( g_UserUnit == INCHES ) + if( aMainFrame->GetUserUnits() == INCHES ) msg.Printf( wxT( "X=%f Y=%f" ), Iu2Mils( m_ImageJustifyOffset.x ) / 1000.0, Iu2Mils( m_ImageJustifyOffset.y ) / 1000.0 ); else diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 0d86a3fcc1..74b3dc6085 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -344,8 +344,8 @@ void GERBVIEW_FRAME::updateDCodeSelectBox() // Build the aperture list of the current layer, and add it to the combo box: wxArrayString dcode_list; wxString msg; - const char* units = g_UserUnit == INCHES ? "mils" : "mm"; - double scale = g_UserUnit == INCHES ? IU_PER_MILS : IU_PER_MM; + const char* units = GetUserUnits() == INCHES ? "mils" : "mm"; + double scale = GetUserUnits() == INCHES ? IU_PER_MILS : IU_PER_MM; for( int ii = 0; ii < TOOLS_MAX_COUNT; ii++ ) { diff --git a/gerbview/tools/selection_tool.cpp b/gerbview/tools/selection_tool.cpp index f1499cc811..c961a6df13 100644 --- a/gerbview/tools/selection_tool.cpp +++ b/gerbview/tools/selection_tool.cpp @@ -832,7 +832,7 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) _( "Measure distance" ) ); KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr; - KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr ); + KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, m_frame->GetUserUnits() ); view.Add( &ruler ); view.SetVisible( &ruler, false ); diff --git a/include/preview_items/ruler_item.h b/include/preview_items/ruler_item.h index c651ca4c0b..d616478ef7 100644 --- a/include/preview_items/ruler_item.h +++ b/include/preview_items/ruler_item.h @@ -44,7 +44,7 @@ class RULER_ITEM : public EDA_ITEM { public: - RULER_ITEM( const TWO_POINT_GEOMETRY_MANAGER& m_geomMgr ); + RULER_ITEM( const TWO_POINT_GEOMETRY_MANAGER& m_geomMgr, EDA_UNITS_T userUnits ); ///> @copydoc EDA_ITEM::ViewBBox() const BOX2I ViewBBox() const override; @@ -74,6 +74,7 @@ public: private: const TWO_POINT_GEOMETRY_MANAGER& m_geomMgr; + const EDA_UNITS_T m_userUnits; }; } // PREVIEW diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp index 8600f0d12a..15fbc3f563 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp @@ -88,7 +88,7 @@ DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR( PCB_EDIT_FRAME* a aParent->Prj().Get3DCacheManager()->GetResolver()->SetProgramBase( &Pgm() ); - m_PreviewPane = new PANEL_PREV_3D( m_Panel3D, + m_PreviewPane = new PANEL_PREV_3D( m_Panel3D, aParent->GetUserUnits(), aParent->Prj().Get3DCacheManager(), m_currentModuleCopy, &aParent->Settings().Colors(), diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp index 3569cc4c5a..1031a96497 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp @@ -80,7 +80,7 @@ DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR( FOOTPRINT_EDIT_FRAME* aP m_currentModuleCopy = new MODULE( *aModule ); - m_PreviewPane = new PANEL_PREV_3D( m_Panel3D, + m_PreviewPane = new PANEL_PREV_3D( m_Panel3D, aParent->GetUserUnits(), aParent->Prj().Get3DCacheManager(), m_currentModuleCopy, &aParent->Settings().Colors(), diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index 54f99ed7b9..86e4fa3f06 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -251,14 +251,14 @@ void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge ) { wxString buffer; - buffer = StringFromValue( g_UserUnit, GetDesignSettings().m_ModuleSegmentWidth ); + buffer = StringFromValue( GetUserUnits(), GetDesignSettings().m_ModuleSegmentWidth ); WX_TEXT_ENTRY_DIALOG dlg( this, _( "New Width:" ), _( "Edge Width" ), buffer ); if( dlg.ShowModal() != wxID_OK ) return; // canceled by user buffer = dlg.GetValue( ); - GetDesignSettings().m_ModuleSegmentWidth = ValueFromString( g_UserUnit, buffer ); + GetDesignSettings().m_ModuleSegmentWidth = ValueFromString( GetUserUnits(), buffer ); if( aEdge ) { diff --git a/pcbnew/exporters/gen_footprints_placefile.cpp b/pcbnew/exporters/gen_footprints_placefile.cpp index acab0791f4..4984c26858 100644 --- a/pcbnew/exporters/gen_footprints_placefile.cpp +++ b/pcbnew/exporters/gen_footprints_placefile.cpp @@ -634,7 +634,7 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event ) fn.SetPath( dirDialog.GetPath() ); fn.SetExt( wxT( "rpt" ) ); - bool unitMM = g_UserUnit != INCHES; + bool unitMM = GetUserUnits() != INCHES; bool success = DoGenFootprintsReport( fn.GetFullPath(), unitMM ); wxString msg; diff --git a/pcbnew/microwave.cpp b/pcbnew/microwave.cpp index fe39ff40fa..94c475c19c 100644 --- a/pcbnew/microwave.cpp +++ b/pcbnew/microwave.cpp @@ -266,7 +266,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) break; } - wxString value = StringFromValue( g_UserUnit, gap_size ); + wxString value = StringFromValue( GetUserUnits(), gap_size ); WX_TEXT_ENTRY_DIALOG dlg( this, msg, _( "Create microwave module" ), value ); if( dlg.ShowModal() != wxID_OK ) @@ -276,7 +276,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) } value = dlg.GetValue(); - gap_size = ValueFromString( g_UserUnit, value ); + gap_size = ValueFromString( GetUserUnits(), value ); bool abort = false; @@ -472,7 +472,8 @@ MWAVE_POLYGONAL_SHAPE_DLG::MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, wxRA_SPECIFY_COLS ); LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 ); - m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize, g_UserUnit, LeftBoxSizer ); + m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize, parent->GetUserUnits(), + LeftBoxSizer ); GetSizer()->SetSizeHints( this ); } @@ -721,14 +722,14 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* aModule ) gap_size = next_pad->GetPos0().x - pad->GetPos0().x - pad->GetSize().x; // Entrer the desired length of the gap. - msg = StringFromValue( g_UserUnit, gap_size ); + msg = StringFromValue( GetUserUnits(), gap_size ); WX_TEXT_ENTRY_DIALOG dlg( this, _( "Gap:" ), _( "Create Microwave Gap" ), msg ); if( dlg.ShowModal() != wxID_OK ) return; // cancelled by user msg = dlg.GetValue(); - gap_size = ValueFromString( g_UserUnit, msg ); + gap_size = ValueFromString( GetUserUnits(), msg ); // Updating sizes of pads forming the gap. int tw = GetDesignSettings().GetCurrentTrackWidth(); diff --git a/pcbnew/tool_pcb_editor.cpp b/pcbnew/tool_pcb_editor.cpp index be222bbeca..502ac3bbd8 100644 --- a/pcbnew/tool_pcb_editor.cpp +++ b/pcbnew/tool_pcb_editor.cpp @@ -639,7 +639,7 @@ void PCB_EDIT_FRAME::updateTraceWidthSelectBox() return; wxString msg; - bool mmFirst = g_UserUnit != INCHES; + bool mmFirst = GetUserUnits() != INCHES; m_SelTrackWidthBox->Clear(); @@ -679,7 +679,7 @@ void PCB_EDIT_FRAME::updateViaSizeSelectBox() wxString msg; m_SelViaSizeBox->Clear(); - bool mmFirst = g_UserUnit != INCHES; + bool mmFirst = GetUserUnits() != INCHES; for( unsigned ii = 0; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ ) { diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 79d3c2c47f..54af031137 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -1175,7 +1175,7 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr; - KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr ); + KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, frame()->GetUserUnits() ); view.Add( &ruler ); view.SetVisible( &ruler, false );