kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #23462
[PATCH 4/5] Use TypeSheetLabel enum where appropriate
---
eeschema/dialogs/dialog_edit_label.cpp | 3 ++-
eeschema/dialogs/dialog_sch_edit_sheet_pin.h | 8 ++++++--
eeschema/edit_label.cpp | 8 ++++----
eeschema/sch_sheet_pin.cpp | 2 +-
eeschema/sch_text.cpp | 4 ++--
eeschema/sch_text.h | 6 +++---
eeschema/schframe.h | 4 +++-
eeschema/sheetlab.cpp | 2 +-
8 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp
index e861a39..2bdb167 100644
--- a/eeschema/dialogs/dialog_edit_label.cpp
+++ b/eeschema/dialogs/dialog_edit_label.cpp
@@ -301,7 +301,8 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent )
m_CurrentText->SetSize( wxSize( value, value ) );
if( m_TextShape )
- m_CurrentText->SetShape( m_TextShape->GetSelection() );
+ /// @todo move cast to widget
+ m_CurrentText->SetShape( static_cast<TypeSheetLabel>( m_TextShape->GetSelection() ) );
int style = m_TextStyle->GetSelection();
diff --git a/eeschema/dialogs/dialog_sch_edit_sheet_pin.h b/eeschema/dialogs/dialog_sch_edit_sheet_pin.h
index fc35864..4d02b01 100644
--- a/eeschema/dialogs/dialog_sch_edit_sheet_pin.h
+++ b/eeschema/dialogs/dialog_sch_edit_sheet_pin.h
@@ -34,6 +34,9 @@
#include <dialog_sch_edit_sheet_pin_base.h>
+// enum TypeSheetLabel
+#include <sch_text.h>
+
class DIALOG_SCH_EDIT_SHEET_PIN : public DIALOG_SCH_EDIT_SHEET_PIN_BASE
{
@@ -49,8 +52,9 @@ public:
void SetTextWidth( const wxString& aWidth ) { m_textWidth->SetValue( aWidth ); }
wxString GetTextWidth() const { return m_textWidth->GetValue(); }
- void SetConnectionType( int aType ) { m_choiceConnectionType->SetSelection( aType ); }
- int GetConnectionType() const { return m_choiceConnectionType->GetCurrentSelection(); }
+ void SetConnectionType( TypeSheetLabel aType ) { m_choiceConnectionType->SetSelection( aType ); }
+ /// @todo move cast to widget
+ TypeSheetLabel GetConnectionType() const { return static_cast<TypeSheetLabel>( m_choiceConnectionType->GetCurrentSelection() ); }
void SetTextHeightUnits( const wxString& aUnit ) { m_staticHeightUnits->SetLabel( aUnit ); }
void SetTextWidthUnits( const wxString& aUnit ) { m_staticWidthUnits->SetLabel( aUnit ); }
diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp
index 2be1d87..2d8b243 100644
--- a/eeschema/edit_label.cpp
+++ b/eeschema/edit_label.cpp
@@ -41,10 +41,10 @@
#include <eeschema_id.h>
-static int lastGlobalLabelShape = (int) NET_INPUT;
-static int lastTextOrientation = 0;
-static bool lastTextBold = false;
-static bool lastTextItalic = false;
+static TypeSheetLabel lastGlobalLabelShape = NET_INPUT;
+static int lastTextOrientation = 0;
+static bool lastTextBold = false;
+static bool lastTextItalic = false;
void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* aTextItem, wxDC* aDC )
diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp
index 048ffb1..52cdd5d 100644
--- a/eeschema/sch_sheet_pin.cpp
+++ b/eeschema/sch_sheet_pin.cpp
@@ -466,7 +466,7 @@ void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wx
* for INPUT type the icon is the OUTPUT shape of SCH_HIERLABEL
* for OUTPUT type the icon is the INPUT shape of SCH_HIERLABEL
*/
- int tmp = m_shape;
+ TypeSheetLabel tmp = m_shape;
switch( m_shape )
{
diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp
index c84852c..964409a 100644
--- a/eeschema/sch_text.cpp
+++ b/eeschema/sch_text.cpp
@@ -102,11 +102,11 @@ static int* TemplateShape[5][4] =
SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
SCH_ITEM( NULL, aType ),
- EDA_TEXT( text )
+ EDA_TEXT( text ),
+ m_shape( NET_INPUT )
{
m_Layer = LAYER_NOTES;
m_Pos = pos;
- m_shape = 0;
m_isDangling = false;
m_MultilineAllowed = true;
m_schematicOrientation = 0;
diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h
index a570bfc..e80448d 100644
--- a/eeschema/sch_text.h
+++ b/eeschema/sch_text.h
@@ -58,7 +58,7 @@ extern const char* SheetLabelType[]; /* names of types of labels */
class SCH_TEXT : public SCH_ITEM, public EDA_TEXT
{
protected:
- int m_shape;
+ TypeSheetLabel m_shape;
/// True if not connected to another object if the object derive from SCH_TEXT
/// supports connections.
@@ -120,9 +120,9 @@ public:
int GetOrientation() { return m_schematicOrientation; }
- int GetShape() const { return m_shape; }
+ TypeSheetLabel GetShape() const { return m_shape; }
- void SetShape( int aShape ) { m_shape = aShape; }
+ void SetShape( TypeSheetLabel aShape ) { m_shape = aShape; }
/**
* Function GetSchematicTextOffset (virtual)
diff --git a/eeschema/schframe.h b/eeschema/schframe.h
index 95840f5..743eb29 100644
--- a/eeschema/schframe.h
+++ b/eeschema/schframe.h
@@ -38,6 +38,8 @@
#include <class_sch_screen.h>
#include <sch_collectors.h>
+// enum TypeSheetLabel
+#include <sch_text.h>
class LIB_EDIT_FRAME;
class LIB_VIEW_FRAME;
@@ -173,7 +175,7 @@ private:
wxArrayString m_componentLibFiles;
*/
- static int m_lastSheetPinType; ///< Last sheet pin type.
+ static TypeSheetLabel m_lastSheetPinType; ///< Last sheet pin type.
static wxSize m_lastSheetPinTextSize; ///< Last sheet pin text size.
static wxPoint m_lastSheetPinPosition; ///< Last sheet pin position.
diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp
index aeca483..a2f4faa 100644
--- a/eeschema/sheetlab.cpp
+++ b/eeschema/sheetlab.cpp
@@ -43,7 +43,7 @@
#include <dialogs/dialog_sch_edit_sheet_pin.h>
-int SCH_EDIT_FRAME::m_lastSheetPinType = NET_INPUT;
+TypeSheetLabel SCH_EDIT_FRAME::m_lastSheetPinType = NET_INPUT;
wxSize SCH_EDIT_FRAME::m_lastSheetPinTextSize( -1, -1 );
wxPoint SCH_EDIT_FRAME::m_lastSheetPinPosition;
Follow ups
References