Loading common/base_struct.cpp +7 −4 Original line number Original line Diff line number Diff line Loading @@ -230,7 +230,7 @@ EDA_TEXT::~EDA_TEXT() int EDA_TEXT::LenSize( const wxString& aLine ) const int EDA_TEXT::LenSize( const wxString& aLine ) const { { return ReturnGraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold ) + m_Thickness; return ReturnGraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold ); } } Loading Loading @@ -286,7 +286,6 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const delete list; delete list; rect.SetSize( textsize ); rect.SetSize( textsize ); rect.Inflate( thickness / 2 ); // ensure a small margin /* Now, calculate the rect origin, according to text justification /* Now, calculate the rect origin, according to text justification * At this point the rectangle origin is the text origin (m_Pos). * At this point the rectangle origin is the text origin (m_Pos). Loading @@ -297,6 +296,8 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const switch( m_HJustify ) switch( m_HJustify ) { { case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_HJUSTIFY_LEFT: if( m_Mirror ) rect.SetX( rect.GetX() - rect.GetWidth() ); break; break; case GR_TEXT_HJUSTIFY_CENTER: case GR_TEXT_HJUSTIFY_CENTER: Loading @@ -304,6 +305,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const break; break; case GR_TEXT_HJUSTIFY_RIGHT: case GR_TEXT_HJUSTIFY_RIGHT: if( !m_Mirror ) rect.SetX( rect.GetX() - rect.GetWidth() ); rect.SetX( rect.GetX() - rect.GetWidth() ); break; break; } } Loading @@ -324,6 +326,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const break; break; } } rect.Inflate( thickness / 2 ); rect.Normalize(); // Make h and v sizes always >= 0 rect.Normalize(); // Make h and v sizes always >= 0 return rect; return rect; Loading Loading @@ -378,7 +381,7 @@ void EDA_TEXT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, aColor, aColor, aDrawMode, aDrawMode, aFillMode, aFillMode, aAnchor_color, i ? UNSPECIFIED_COLOR : aAnchor_color, txt, txt, pos ); pos ); pos += offset; pos += offset; Loading include/base_struct.h +5 −0 Original line number Original line Diff line number Diff line Loading @@ -845,6 +845,11 @@ public: void SetText( const wxString& aText ) { m_Text = aText; } void SetText( const wxString& aText ) { m_Text = aText; } wxString GetText() const { return m_Text; } wxString GetText() const { return m_Text; } GRTextHorizJustifyType GetHorizJustify() const { return m_HJustify; }; GRTextVertJustifyType GetVertJustify() const { return m_VJustify; }; void SetHorizJustify( GRTextHorizJustifyType aType ) { m_HJustify = aType; }; void SetVertJustify( GRTextVertJustifyType aType ) { m_VJustify = aType; }; }; }; #endif /* BASE_STRUCT_H */ #endif /* BASE_STRUCT_H */ pcbnew/class_pcb_text.cpp +50 −13 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,7 @@ #include "trigo.h" #include "trigo.h" #include "protos.h" #include "protos.h" #include "richio.h" #include "richio.h" #include "class_drawpanel.h" /*******************/ /*******************/ /* class TEXTE_PCB */ /* class TEXTE_PCB */ Loading Loading @@ -119,8 +119,9 @@ int TEXTE_PCB::ReadTextePcbDescr( LINE_READER* aReader ) { { style[0] = 0; style[0] = 0; int normal_display = 1; int normal_display = 1; sscanf( line + 2, " %d %d %lX %s\n", &m_Layer, &normal_display, char hJustify = 'l'; &m_TimeStamp, style ); sscanf( line + 2, " %d %d %lX %s %c\n", &m_Layer, &normal_display, &m_TimeStamp, style, &hJustify ); m_Mirror = normal_display ? false : true; m_Mirror = normal_display ? false : true; Loading @@ -133,6 +134,25 @@ int TEXTE_PCB::ReadTextePcbDescr( LINE_READER* aReader ) m_Italic = 1; m_Italic = 1; else else m_Italic = 0; m_Italic = 0; switch( hJustify ) { case 'l': case 'L': m_HJustify = GR_TEXT_HJUSTIFY_LEFT; break; case 'c': case 'C': m_HJustify = GR_TEXT_HJUSTIFY_CENTER; break; case 'r': case 'R': m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; break; default: m_HJustify = GR_TEXT_HJUSTIFY_CENTER; break; } continue; continue; } } } } Loading Loading @@ -173,9 +193,26 @@ bool TEXTE_PCB::Save( FILE* aFile ) const fprintf( aFile, "Po %d %d %d %d %d %d\n", fprintf( aFile, "Po %d %d %d %d %d %d\n", m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Thickness, m_Orient ); m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Thickness, m_Orient ); fprintf( aFile, "De %d %d %lX %s\n", m_Layer, char hJustify = 'L'; switch( m_HJustify ) { case GR_TEXT_HJUSTIFY_LEFT: hJustify = 'L'; break; case GR_TEXT_HJUSTIFY_CENTER: hJustify = 'C'; break; case GR_TEXT_HJUSTIFY_RIGHT: hJustify = 'R'; break; default: hJustify = 'C'; break; } fprintf( aFile, "De %d %d %lX %s %c\n", m_Layer, m_Mirror ? 0 : 1, m_Mirror ? 0 : 1, m_TimeStamp, style ); m_TimeStamp, style, hJustify ); if( fprintf( aFile, "$EndTEXTPCB\n" ) != sizeof("$EndTEXTPCB\n") - 1 ) if( fprintf( aFile, "$EndTEXTPCB\n" ) != sizeof("$EndTEXTPCB\n") - 1 ) return false; return false; Loading Loading @@ -245,16 +282,16 @@ void TEXTE_PCB::DisplayInfo( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( _( "Mirror" ), _( "Yes" ), DARKGREEN ); frame->AppendMsgPanel( _( "Mirror" ), _( "Yes" ), DARKGREEN ); msg.Printf( wxT( "%.1f" ), (float) m_Orient / 10 ); msg.Printf( wxT( "%.1f" ), (float) m_Orient / 10 ); frame->AppendMsgPanel( _( "Orient" ), msg, DARKGREEN ); frame->AppendMsgPanel( _( "Orientation" ), msg, DARKGREEN ); valeur_param( m_Thickness, msg ); valeur_param( m_Thickness, msg ); frame->AppendMsgPanel( _( "Thickness" ), msg, MAGENTA ); frame->AppendMsgPanel( _( "Thickness" ), msg, MAGENTA ); valeur_param( m_Size.x, msg ); valeur_param( m_Size.x, msg ); frame->AppendMsgPanel( _( "H Size" ), msg, RED ); frame->AppendMsgPanel( _( "Size X" ), msg, RED ); valeur_param( m_Size.y, msg ); valeur_param( m_Size.y, msg ); frame->AppendMsgPanel( _( "V Size" ), msg, RED ); frame->AppendMsgPanel( _( "Size Y" ), msg, RED ); } } Loading pcbnew/dialogs/dialog_pcb_text_properties.cpp +41 −3 Original line number Original line Diff line number Diff line Loading @@ -58,6 +58,7 @@ DIALOG_PCB_TEXT_PROPERTIES::DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent, Centre(); Centre(); } } /** /** * Routine for main window class to launch text properties dialog. * Routine for main window class to launch text properties dialog. */ */ Loading @@ -70,6 +71,7 @@ void PCB_EDIT_FRAME::InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC ) DrawPanel->m_IgnoreMouseEvents = FALSE; DrawPanel->m_IgnoreMouseEvents = FALSE; } } void DIALOG_PCB_TEXT_PROPERTIES::MyInit() void DIALOG_PCB_TEXT_PROPERTIES::MyInit() { { SetFocus(); SetFocus(); Loading @@ -95,11 +97,18 @@ void DIALOG_PCB_TEXT_PROPERTIES::MyInit() PutValueInLocalUnits( *m_PositionYCtrl, m_SelectedPCBText->m_Pos.y, PutValueInLocalUnits( *m_PositionYCtrl, m_SelectedPCBText->m_Pos.y, m_Parent->m_InternalUnits ); m_Parent->m_InternalUnits ); int enabledLayers = m_Parent->GetBoard()->GetEnabledLayers(); for( int layer = 0; layer < NB_LAYERS; ++layer ) for( int layer = 0; layer < NB_LAYERS; ++layer ) { { if( enabledLayers & (1 << layer) ) { layerList.push_back( layer ); int itemIndex = m_LayerSelectionCtrl->Append( m_Parent->GetBoard()->GetLayerName( layer ) ); m_LayerSelectionCtrl->Append( m_Parent->GetBoard()->GetLayerName( layer ) ); if( m_SelectedPCBText->GetLayer() == layer ) m_LayerSelectionCtrl->SetSelection( itemIndex ); } } } m_LayerSelectionCtrl->SetSelection( m_SelectedPCBText->GetLayer() ); switch( m_SelectedPCBText->m_Orient ) switch( m_SelectedPCBText->m_Orient ) { { Loading Loading @@ -127,16 +136,28 @@ void DIALOG_PCB_TEXT_PROPERTIES::MyInit() else else m_StyleCtrl->SetSelection( 0 ); m_StyleCtrl->SetSelection( 0 ); // Set justification GRTextHorizJustifyType hJustify = m_SelectedPCBText->GetHorizJustify(); m_justifyChoice->SetSelection( (int) hJustify + 1 ); // Set focus on most important control // Set focus on most important control m_TextContentCtrl->SetFocus(); m_TextContentCtrl->SetFocus(); m_TextContentCtrl->SetSelection( -1, -1 ); m_TextContentCtrl->SetSelection( -1, -1 ); } } void DIALOG_PCB_TEXT_PROPERTIES::OnClose( wxCloseEvent& event ) { EndModal( 0 ); } void DIALOG_PCB_TEXT_PROPERTIES::OnCancelClick( wxCommandEvent& event ) void DIALOG_PCB_TEXT_PROPERTIES::OnCancelClick( wxCommandEvent& event ) { { EndModal( wxID_CANCEL ); EndModal( wxID_CANCEL ); } } void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) { { wxPoint newPosition; wxPoint newPosition; Loading Loading @@ -174,6 +195,7 @@ void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) // Check constraints and set PCB Text size // Check constraints and set PCB Text size newSize.x = ReturnValueFromString( g_UserUnit, m_SizeXCtrl->GetValue(), m_Parent->m_InternalUnits ); newSize.x = ReturnValueFromString( g_UserUnit, m_SizeXCtrl->GetValue(), m_Parent->m_InternalUnits ); newSize.y = ReturnValueFromString( g_UserUnit, m_SizeYCtrl->GetValue(), m_Parent->m_InternalUnits ); newSize.y = ReturnValueFromString( g_UserUnit, m_SizeYCtrl->GetValue(), m_Parent->m_InternalUnits ); if( newSize.x < TEXTS_MIN_SIZE ) if( newSize.x < TEXTS_MIN_SIZE ) newSize.x = TEXTS_MIN_SIZE; newSize.x = TEXTS_MIN_SIZE; if( newSize.y < TEXTS_MIN_SIZE ) if( newSize.y < TEXTS_MIN_SIZE ) Loading @@ -196,7 +218,7 @@ void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) } } // Set the layer on which the PCB text is laying // Set the layer on which the PCB text is laying m_SelectedPCBText->SetLayer( m_LayerSelectionCtrl->GetSelection() ); m_SelectedPCBText->SetLayer( layerList[m_LayerSelectionCtrl->GetSelection()] ); // Set whether the PCB text is mirrored (faced down from layer face perspective) // Set whether the PCB text is mirrored (faced down from layer face perspective) m_SelectedPCBText->m_Mirror = (m_DisplayCtrl->GetSelection() == 1) ? true : false; m_SelectedPCBText->m_Mirror = (m_DisplayCtrl->GetSelection() == 1) ? true : false; Loading @@ -207,6 +229,22 @@ void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) // Set whether the PCB text is slanted (it is not italics, as italics has additional curves in style) // Set whether the PCB text is slanted (it is not italics, as italics has additional curves in style) m_SelectedPCBText->m_Italic = m_StyleCtrl->GetSelection() ? 1 : 0; m_SelectedPCBText->m_Italic = m_StyleCtrl->GetSelection() ? 1 : 0; // Set justification switch( m_justifyChoice->GetSelection() ) { case 0: m_SelectedPCBText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break; case 1: m_SelectedPCBText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); break; case 2: m_SelectedPCBText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break; default: break; } // Finally, display new text if there is a context to do so // Finally, display new text if there is a context to do so if( m_DC ) if( m_DC ) { { Loading pcbnew/dialogs/dialog_pcb_text_properties.h +7 −13 Original line number Original line Diff line number Diff line #ifndef __dialog_pcb_text_properties__ #ifndef DIALOG_PCB_TEXT_PROPERTIES_H #define __dialog_pcb_text_properties__ #define DIALOG_PCB_TEXT_PROPERTIES_H /** @file Subclass of DIALOG_PCB_TEXT_PROPERTIES_BASE, which is generated by wxFormBuilder. */ #include <vector> #include <wx/wx.h> #include "dialog_pcb_text_properties_base.h" #include "dialog_pcb_text_properties_base.h" //// end generated include class PCB_EDIT_FRAME; class PCB_EDIT_FRAME; class wxDC; class TEXTE_PCB; class TEXTE_PCB; /** Implementing DIALOG_PCB_TEXT_PROPERTIES_BASE */ /** Implementing DIALOG_PCB_TEXT_PROPERTIES_BASE */ Loading @@ -21,18 +15,18 @@ private: PCB_EDIT_FRAME* m_Parent; PCB_EDIT_FRAME* m_Parent; wxDC* m_DC; wxDC* m_DC; TEXTE_PCB* m_SelectedPCBText; TEXTE_PCB* m_SelectedPCBText; std::vector<int> layerList; void MyInit(); void MyInit(); protected: protected: // Handlers for DIALOG_PCB_TEXT_PROPERTIES_BASE events. // Handlers for DIALOG_PCB_TEXT_PROPERTIES_BASE events. void OnClose( wxCloseEvent& event ); void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event ); public: public: DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent, TEXTE_PCB* passedTextPCB, wxDC* DC ); DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent, TEXTE_PCB* passedTextPCB, wxDC* DC ); //// end generated class members }; }; #endif // __dialog_pcb_text_properties__ #endif // DIALOG_PCB_TEXT_PROPERTIES_H Loading
common/base_struct.cpp +7 −4 Original line number Original line Diff line number Diff line Loading @@ -230,7 +230,7 @@ EDA_TEXT::~EDA_TEXT() int EDA_TEXT::LenSize( const wxString& aLine ) const int EDA_TEXT::LenSize( const wxString& aLine ) const { { return ReturnGraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold ) + m_Thickness; return ReturnGraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold ); } } Loading Loading @@ -286,7 +286,6 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const delete list; delete list; rect.SetSize( textsize ); rect.SetSize( textsize ); rect.Inflate( thickness / 2 ); // ensure a small margin /* Now, calculate the rect origin, according to text justification /* Now, calculate the rect origin, according to text justification * At this point the rectangle origin is the text origin (m_Pos). * At this point the rectangle origin is the text origin (m_Pos). Loading @@ -297,6 +296,8 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const switch( m_HJustify ) switch( m_HJustify ) { { case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_HJUSTIFY_LEFT: if( m_Mirror ) rect.SetX( rect.GetX() - rect.GetWidth() ); break; break; case GR_TEXT_HJUSTIFY_CENTER: case GR_TEXT_HJUSTIFY_CENTER: Loading @@ -304,6 +305,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const break; break; case GR_TEXT_HJUSTIFY_RIGHT: case GR_TEXT_HJUSTIFY_RIGHT: if( !m_Mirror ) rect.SetX( rect.GetX() - rect.GetWidth() ); rect.SetX( rect.GetX() - rect.GetWidth() ); break; break; } } Loading @@ -324,6 +326,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const break; break; } } rect.Inflate( thickness / 2 ); rect.Normalize(); // Make h and v sizes always >= 0 rect.Normalize(); // Make h and v sizes always >= 0 return rect; return rect; Loading Loading @@ -378,7 +381,7 @@ void EDA_TEXT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, aColor, aColor, aDrawMode, aDrawMode, aFillMode, aFillMode, aAnchor_color, i ? UNSPECIFIED_COLOR : aAnchor_color, txt, txt, pos ); pos ); pos += offset; pos += offset; Loading
include/base_struct.h +5 −0 Original line number Original line Diff line number Diff line Loading @@ -845,6 +845,11 @@ public: void SetText( const wxString& aText ) { m_Text = aText; } void SetText( const wxString& aText ) { m_Text = aText; } wxString GetText() const { return m_Text; } wxString GetText() const { return m_Text; } GRTextHorizJustifyType GetHorizJustify() const { return m_HJustify; }; GRTextVertJustifyType GetVertJustify() const { return m_VJustify; }; void SetHorizJustify( GRTextHorizJustifyType aType ) { m_HJustify = aType; }; void SetVertJustify( GRTextVertJustifyType aType ) { m_VJustify = aType; }; }; }; #endif /* BASE_STRUCT_H */ #endif /* BASE_STRUCT_H */
pcbnew/class_pcb_text.cpp +50 −13 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,7 @@ #include "trigo.h" #include "trigo.h" #include "protos.h" #include "protos.h" #include "richio.h" #include "richio.h" #include "class_drawpanel.h" /*******************/ /*******************/ /* class TEXTE_PCB */ /* class TEXTE_PCB */ Loading Loading @@ -119,8 +119,9 @@ int TEXTE_PCB::ReadTextePcbDescr( LINE_READER* aReader ) { { style[0] = 0; style[0] = 0; int normal_display = 1; int normal_display = 1; sscanf( line + 2, " %d %d %lX %s\n", &m_Layer, &normal_display, char hJustify = 'l'; &m_TimeStamp, style ); sscanf( line + 2, " %d %d %lX %s %c\n", &m_Layer, &normal_display, &m_TimeStamp, style, &hJustify ); m_Mirror = normal_display ? false : true; m_Mirror = normal_display ? false : true; Loading @@ -133,6 +134,25 @@ int TEXTE_PCB::ReadTextePcbDescr( LINE_READER* aReader ) m_Italic = 1; m_Italic = 1; else else m_Italic = 0; m_Italic = 0; switch( hJustify ) { case 'l': case 'L': m_HJustify = GR_TEXT_HJUSTIFY_LEFT; break; case 'c': case 'C': m_HJustify = GR_TEXT_HJUSTIFY_CENTER; break; case 'r': case 'R': m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; break; default: m_HJustify = GR_TEXT_HJUSTIFY_CENTER; break; } continue; continue; } } } } Loading Loading @@ -173,9 +193,26 @@ bool TEXTE_PCB::Save( FILE* aFile ) const fprintf( aFile, "Po %d %d %d %d %d %d\n", fprintf( aFile, "Po %d %d %d %d %d %d\n", m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Thickness, m_Orient ); m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Thickness, m_Orient ); fprintf( aFile, "De %d %d %lX %s\n", m_Layer, char hJustify = 'L'; switch( m_HJustify ) { case GR_TEXT_HJUSTIFY_LEFT: hJustify = 'L'; break; case GR_TEXT_HJUSTIFY_CENTER: hJustify = 'C'; break; case GR_TEXT_HJUSTIFY_RIGHT: hJustify = 'R'; break; default: hJustify = 'C'; break; } fprintf( aFile, "De %d %d %lX %s %c\n", m_Layer, m_Mirror ? 0 : 1, m_Mirror ? 0 : 1, m_TimeStamp, style ); m_TimeStamp, style, hJustify ); if( fprintf( aFile, "$EndTEXTPCB\n" ) != sizeof("$EndTEXTPCB\n") - 1 ) if( fprintf( aFile, "$EndTEXTPCB\n" ) != sizeof("$EndTEXTPCB\n") - 1 ) return false; return false; Loading Loading @@ -245,16 +282,16 @@ void TEXTE_PCB::DisplayInfo( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( _( "Mirror" ), _( "Yes" ), DARKGREEN ); frame->AppendMsgPanel( _( "Mirror" ), _( "Yes" ), DARKGREEN ); msg.Printf( wxT( "%.1f" ), (float) m_Orient / 10 ); msg.Printf( wxT( "%.1f" ), (float) m_Orient / 10 ); frame->AppendMsgPanel( _( "Orient" ), msg, DARKGREEN ); frame->AppendMsgPanel( _( "Orientation" ), msg, DARKGREEN ); valeur_param( m_Thickness, msg ); valeur_param( m_Thickness, msg ); frame->AppendMsgPanel( _( "Thickness" ), msg, MAGENTA ); frame->AppendMsgPanel( _( "Thickness" ), msg, MAGENTA ); valeur_param( m_Size.x, msg ); valeur_param( m_Size.x, msg ); frame->AppendMsgPanel( _( "H Size" ), msg, RED ); frame->AppendMsgPanel( _( "Size X" ), msg, RED ); valeur_param( m_Size.y, msg ); valeur_param( m_Size.y, msg ); frame->AppendMsgPanel( _( "V Size" ), msg, RED ); frame->AppendMsgPanel( _( "Size Y" ), msg, RED ); } } Loading
pcbnew/dialogs/dialog_pcb_text_properties.cpp +41 −3 Original line number Original line Diff line number Diff line Loading @@ -58,6 +58,7 @@ DIALOG_PCB_TEXT_PROPERTIES::DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent, Centre(); Centre(); } } /** /** * Routine for main window class to launch text properties dialog. * Routine for main window class to launch text properties dialog. */ */ Loading @@ -70,6 +71,7 @@ void PCB_EDIT_FRAME::InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC ) DrawPanel->m_IgnoreMouseEvents = FALSE; DrawPanel->m_IgnoreMouseEvents = FALSE; } } void DIALOG_PCB_TEXT_PROPERTIES::MyInit() void DIALOG_PCB_TEXT_PROPERTIES::MyInit() { { SetFocus(); SetFocus(); Loading @@ -95,11 +97,18 @@ void DIALOG_PCB_TEXT_PROPERTIES::MyInit() PutValueInLocalUnits( *m_PositionYCtrl, m_SelectedPCBText->m_Pos.y, PutValueInLocalUnits( *m_PositionYCtrl, m_SelectedPCBText->m_Pos.y, m_Parent->m_InternalUnits ); m_Parent->m_InternalUnits ); int enabledLayers = m_Parent->GetBoard()->GetEnabledLayers(); for( int layer = 0; layer < NB_LAYERS; ++layer ) for( int layer = 0; layer < NB_LAYERS; ++layer ) { { if( enabledLayers & (1 << layer) ) { layerList.push_back( layer ); int itemIndex = m_LayerSelectionCtrl->Append( m_Parent->GetBoard()->GetLayerName( layer ) ); m_LayerSelectionCtrl->Append( m_Parent->GetBoard()->GetLayerName( layer ) ); if( m_SelectedPCBText->GetLayer() == layer ) m_LayerSelectionCtrl->SetSelection( itemIndex ); } } } m_LayerSelectionCtrl->SetSelection( m_SelectedPCBText->GetLayer() ); switch( m_SelectedPCBText->m_Orient ) switch( m_SelectedPCBText->m_Orient ) { { Loading Loading @@ -127,16 +136,28 @@ void DIALOG_PCB_TEXT_PROPERTIES::MyInit() else else m_StyleCtrl->SetSelection( 0 ); m_StyleCtrl->SetSelection( 0 ); // Set justification GRTextHorizJustifyType hJustify = m_SelectedPCBText->GetHorizJustify(); m_justifyChoice->SetSelection( (int) hJustify + 1 ); // Set focus on most important control // Set focus on most important control m_TextContentCtrl->SetFocus(); m_TextContentCtrl->SetFocus(); m_TextContentCtrl->SetSelection( -1, -1 ); m_TextContentCtrl->SetSelection( -1, -1 ); } } void DIALOG_PCB_TEXT_PROPERTIES::OnClose( wxCloseEvent& event ) { EndModal( 0 ); } void DIALOG_PCB_TEXT_PROPERTIES::OnCancelClick( wxCommandEvent& event ) void DIALOG_PCB_TEXT_PROPERTIES::OnCancelClick( wxCommandEvent& event ) { { EndModal( wxID_CANCEL ); EndModal( wxID_CANCEL ); } } void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) { { wxPoint newPosition; wxPoint newPosition; Loading Loading @@ -174,6 +195,7 @@ void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) // Check constraints and set PCB Text size // Check constraints and set PCB Text size newSize.x = ReturnValueFromString( g_UserUnit, m_SizeXCtrl->GetValue(), m_Parent->m_InternalUnits ); newSize.x = ReturnValueFromString( g_UserUnit, m_SizeXCtrl->GetValue(), m_Parent->m_InternalUnits ); newSize.y = ReturnValueFromString( g_UserUnit, m_SizeYCtrl->GetValue(), m_Parent->m_InternalUnits ); newSize.y = ReturnValueFromString( g_UserUnit, m_SizeYCtrl->GetValue(), m_Parent->m_InternalUnits ); if( newSize.x < TEXTS_MIN_SIZE ) if( newSize.x < TEXTS_MIN_SIZE ) newSize.x = TEXTS_MIN_SIZE; newSize.x = TEXTS_MIN_SIZE; if( newSize.y < TEXTS_MIN_SIZE ) if( newSize.y < TEXTS_MIN_SIZE ) Loading @@ -196,7 +218,7 @@ void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) } } // Set the layer on which the PCB text is laying // Set the layer on which the PCB text is laying m_SelectedPCBText->SetLayer( m_LayerSelectionCtrl->GetSelection() ); m_SelectedPCBText->SetLayer( layerList[m_LayerSelectionCtrl->GetSelection()] ); // Set whether the PCB text is mirrored (faced down from layer face perspective) // Set whether the PCB text is mirrored (faced down from layer face perspective) m_SelectedPCBText->m_Mirror = (m_DisplayCtrl->GetSelection() == 1) ? true : false; m_SelectedPCBText->m_Mirror = (m_DisplayCtrl->GetSelection() == 1) ? true : false; Loading @@ -207,6 +229,22 @@ void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event ) // Set whether the PCB text is slanted (it is not italics, as italics has additional curves in style) // Set whether the PCB text is slanted (it is not italics, as italics has additional curves in style) m_SelectedPCBText->m_Italic = m_StyleCtrl->GetSelection() ? 1 : 0; m_SelectedPCBText->m_Italic = m_StyleCtrl->GetSelection() ? 1 : 0; // Set justification switch( m_justifyChoice->GetSelection() ) { case 0: m_SelectedPCBText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break; case 1: m_SelectedPCBText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); break; case 2: m_SelectedPCBText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break; default: break; } // Finally, display new text if there is a context to do so // Finally, display new text if there is a context to do so if( m_DC ) if( m_DC ) { { Loading
pcbnew/dialogs/dialog_pcb_text_properties.h +7 −13 Original line number Original line Diff line number Diff line #ifndef __dialog_pcb_text_properties__ #ifndef DIALOG_PCB_TEXT_PROPERTIES_H #define __dialog_pcb_text_properties__ #define DIALOG_PCB_TEXT_PROPERTIES_H /** @file Subclass of DIALOG_PCB_TEXT_PROPERTIES_BASE, which is generated by wxFormBuilder. */ #include <vector> #include <wx/wx.h> #include "dialog_pcb_text_properties_base.h" #include "dialog_pcb_text_properties_base.h" //// end generated include class PCB_EDIT_FRAME; class PCB_EDIT_FRAME; class wxDC; class TEXTE_PCB; class TEXTE_PCB; /** Implementing DIALOG_PCB_TEXT_PROPERTIES_BASE */ /** Implementing DIALOG_PCB_TEXT_PROPERTIES_BASE */ Loading @@ -21,18 +15,18 @@ private: PCB_EDIT_FRAME* m_Parent; PCB_EDIT_FRAME* m_Parent; wxDC* m_DC; wxDC* m_DC; TEXTE_PCB* m_SelectedPCBText; TEXTE_PCB* m_SelectedPCBText; std::vector<int> layerList; void MyInit(); void MyInit(); protected: protected: // Handlers for DIALOG_PCB_TEXT_PROPERTIES_BASE events. // Handlers for DIALOG_PCB_TEXT_PROPERTIES_BASE events. void OnClose( wxCloseEvent& event ); void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event ); public: public: DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent, TEXTE_PCB* passedTextPCB, wxDC* DC ); DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent, TEXTE_PCB* passedTextPCB, wxDC* DC ); //// end generated class members }; }; #endif // __dialog_pcb_text_properties__ #endif // DIALOG_PCB_TEXT_PROPERTIES_H