Skip to content

Commit

Permalink
Enum refactoring and shiny icons in dialog_lib_edit_pin_table
Browse files Browse the repository at this point in the history
  • Loading branch information
GyrosGeier authored and jp-charras committed Feb 28, 2016
1 parent a0fd827 commit 4b103ba
Show file tree
Hide file tree
Showing 29 changed files with 836 additions and 388 deletions.
5 changes: 5 additions & 0 deletions eeschema/CMakeLists.txt
Expand Up @@ -13,6 +13,7 @@ include_directories( BEFORE ${INC_BEFORE} )
include_directories(
./dialogs
./netlist_exporters
./widgets
../common
../common/dialogs
${INC_AFTER}
Expand Down Expand Up @@ -72,6 +73,8 @@ set( EESCHEMA_DLGS

set( EESCHEMA_WIDGETS
widgets/widget_eeschema_color_config.cpp
widgets/pin_shape_combobox.cpp
widgets/pin_type_combobox.cpp
)


Expand Down Expand Up @@ -137,6 +140,8 @@ set( EESCHEMA_SRCS
operations_on_items_lists.cpp
pinedit.cpp
pin_number.cpp
pin_shape.cpp
pin_type.cpp
plot_schematic_DXF.cpp
plot_schematic_HPGL.cpp
plot_schematic_PS.cpp
Expand Down
3 changes: 2 additions & 1 deletion eeschema/dialogs/dialog_edit_label.cpp
Expand Up @@ -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();

Expand Down
18 changes: 9 additions & 9 deletions eeschema/dialogs/dialog_erc.cpp
Expand Up @@ -49,8 +49,8 @@
#include <erc.h>
#include <id.h>

extern int DiagErc[PIN_NMAX][PIN_NMAX];
extern int DefaultDiagErc[PIN_NMAX][PIN_NMAX];
extern int DiagErc[PINTYPE_COUNT][PINTYPE_COUNT];
extern int DefaultDiagErc[PINTYPE_COUNT][PINTYPE_COUNT];



Expand All @@ -63,7 +63,7 @@ bool DIALOG_ERC::m_tstUniqueGlobalLabels = true; // saved only for the curren
#define ID_MATRIX_0 1800

BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE )
EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PIN_NMAX * PIN_NMAX ) - 1,
EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PINTYPE_COUNT * PINTYPE_COUNT ) - 1,
wxEVT_COMMAND_BUTTON_CLICKED, DIALOG_ERC::ChangeErrorLevel )
END_EVENT_TABLE()

Expand Down Expand Up @@ -91,9 +91,9 @@ void DIALOG_ERC::Init()
{
m_initialized = false;

for( int ii = 0; ii < PIN_NMAX; ii++ )
for( int ii = 0; ii < PINTYPE_COUNT; ii++ )
{
for( int jj = 0; jj < PIN_NMAX; jj++ )
for( int jj = 0; jj < PINTYPE_COUNT; jj++ )
m_buttonList[ii][jj] = NULL;
}

Expand Down Expand Up @@ -290,7 +290,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
if( m_initialized == false )
{
// Print row labels
for( int ii = 0; ii < PIN_NMAX; ii++ )
for( int ii = 0; ii < PINTYPE_COUNT; ii++ )
{
int y = pos.y + (ii * bitmap_size.y);
text = new wxStaticText( m_matrixPanel, -1, CommentERC_H[ii],
Expand All @@ -305,7 +305,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
else
pos = m_buttonList[0][0]->GetPosition();

for( int ii = 0; ii < PIN_NMAX; ii++ )
for( int ii = 0; ii < PINTYPE_COUNT; ii++ )
{
int y = pos.y + (ii * bitmap_size.y);

Expand All @@ -323,7 +323,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
text = new wxStaticText( m_matrixPanel, -1, CommentERC_V[ii], txtpos );
}

int event_id = ID_MATRIX_0 + ii + ( jj * PIN_NMAX );
int event_id = ID_MATRIX_0 + ii + ( jj * PINTYPE_COUNT );
BITMAP_DEF bitmap_butt = erc_green_xpm;

delete m_buttonList[ii][jj];
Expand Down Expand Up @@ -420,7 +420,7 @@ void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event )
wxBitmapButton* butt = (wxBitmapButton*) event.GetEventObject();
pos = butt->GetPosition();

x = ii / PIN_NMAX; y = ii % PIN_NMAX;
x = ii / PINTYPE_COUNT; y = ii % PINTYPE_COUNT;

level = DiagErc[y][x];

Expand Down
4 changes: 2 additions & 2 deletions eeschema/dialogs/dialog_erc.h
Expand Up @@ -27,7 +27,7 @@

#include <wx/htmllbox.h>
#include <vector>
#include <lib_pin.h> // For PIN_NMAX definition
#include <lib_pin.h> // For PINTYPE_COUNT definition

#include <dialog_erc_base.h>
#include "dialog_erc_listbox.h"
Expand All @@ -40,7 +40,7 @@ class DIALOG_ERC : public DIALOG_ERC_BASE

private:
SCH_EDIT_FRAME* m_parent;
wxBitmapButton* m_buttonList[PIN_NMAX][PIN_NMAX];
wxBitmapButton* m_buttonList[PINTYPE_COUNT][PINTYPE_COUNT];
bool m_initialized;
const SCH_MARKER* m_lastMarkerFound;
static bool m_writeErcFile;
Expand Down
27 changes: 1 addition & 26 deletions eeschema/dialogs/dialog_lib_edit_pin.cpp
Expand Up @@ -133,7 +133,7 @@ void DIALOG_LIB_EDIT_PIN::OnPropertiesChange( wxCommandEvent& event )
int pinNumSize = ValueFromString( g_UserUnit, GetPadNameTextSize());
int pinOrient = LIB_PIN::GetOrientationCode( GetOrientation() );
int pinLength = ValueFromString( g_UserUnit, GetLength() );
int pinShape = LIB_PIN::GetStyleCode( GetStyle() );
GRAPHIC_PINSHAPE pinShape = GetStyle();
ELECTRICAL_PINTYPE pinType = GetElectricalType();

m_dummyPin->SetName( GetPinName() );
Expand Down Expand Up @@ -161,28 +161,3 @@ void DIALOG_LIB_EDIT_PIN::SetOrientationList( const wxArrayString& list,
m_choiceOrientation->Insert( list[ii], KiBitmap( aBitmaps[ii] ), ii );
}
}


void DIALOG_LIB_EDIT_PIN::SetElectricalTypeList( const wxArrayString& list,
const BITMAP_DEF* aBitmaps )
{
for ( unsigned ii = 0; ii < list.GetCount(); ii++ )
{
if( aBitmaps == NULL )
m_choiceElectricalType->Append( list[ii] );
else
m_choiceElectricalType->Insert( list[ii], KiBitmap( aBitmaps[ii] ), ii );
}
}


void DIALOG_LIB_EDIT_PIN::SetStyleList( const wxArrayString& list, const BITMAP_DEF* aBitmaps )
{
for ( unsigned ii = 0; ii < list.GetCount(); ii++ )
{
if( aBitmaps == NULL )
m_choiceStyle->Append( list[ii] );
else
m_choiceStyle->Insert( list[ii], KiBitmap( aBitmaps[ii] ), ii );
}
}
14 changes: 6 additions & 8 deletions eeschema/dialogs/dialog_lib_edit_pin.h
Expand Up @@ -31,6 +31,8 @@
*/

#include <wx/bmpcbox.h>
#include <pin_shape_combobox.h>
#include <pin_type_combobox.h>

#include <dialog_lib_edit_pin_base.h>

Expand Down Expand Up @@ -59,22 +61,18 @@ class DIALOG_LIB_EDIT_PIN : public DIALOG_LIB_EDIT_PIN_BASE
}
int GetOrientation( void ) { return m_choiceOrientation->GetSelection(); }

void SetElectricalTypeList( const wxArrayString& list, const BITMAP_DEF* aBitmaps );
void SetElectricalType( int type )
void SetElectricalType( ELECTRICAL_PINTYPE type )
{
m_choiceElectricalType->SetSelection( type );
}

ELECTRICAL_PINTYPE GetElectricalType( void )
{
// m_choiceElectricalType is expected having the eletrical type names
// order indentical to the ELECTRICAL_PINTYPE enum
return (ELECTRICAL_PINTYPE)m_choiceElectricalType->GetSelection();
return m_choiceElectricalType->GetSelection();
}

void SetStyleList( const wxArrayString& list, const BITMAP_DEF* aBitmaps );
void SetStyle( int style ) { m_choiceStyle->SetSelection( style ); }
int GetStyle( void ) { return m_choiceStyle->GetSelection(); }
void SetStyle( GRAPHIC_PINSHAPE style ) { m_choiceStyle->SetSelection( style ); }
GRAPHIC_PINSHAPE GetStyle( void ) { return m_choiceStyle->GetSelection(); }

void SetPinName( const wxString& name ) { m_textPinName->SetValue( name ); }
wxString GetPinName( void ) { return m_textPinName->GetValue(); }
Expand Down
6 changes: 4 additions & 2 deletions eeschema/dialogs/dialog_lib_edit_pin_base.cpp
Expand Up @@ -5,6 +5,8 @@
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#include "pin_shape_combobox.h"
#include "pin_type_combobox.h"
#include "wx/bmpcbox.h"

#include "dialog_lib_edit_pin_base.h"
Expand Down Expand Up @@ -61,14 +63,14 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID

fgSizerPins->Add( m_staticTextEType, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );

m_choiceElectricalType = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
m_choiceElectricalType = new PinTypeComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
fgSizerPins->Add( m_choiceElectricalType, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );

m_staticTextGstyle = new wxStaticText( this, wxID_ANY, _("Graphic &Style:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextGstyle->Wrap( -1 );
fgSizerPins->Add( m_staticTextGstyle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );

m_choiceStyle = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
m_choiceStyle = new PinShapeComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
fgSizerPins->Add( m_choiceStyle, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );


Expand Down
4 changes: 2 additions & 2 deletions eeschema/dialogs/dialog_lib_edit_pin_base.fbp
Expand Up @@ -784,7 +784,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxCB_READONLY</property>
<property name="subclass">wxBitmapComboBox; wx/bmpcbox.h</property>
<property name="subclass">PinTypeComboBox; pin_type_combobox.h</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
Expand Down Expand Up @@ -958,7 +958,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxCB_READONLY</property>
<property name="subclass">wxBitmapComboBox; wx/bmpcbox.h</property>
<property name="subclass">PinShapeComboBox; pin_shape_combobox.h</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
Expand Down
6 changes: 4 additions & 2 deletions eeschema/dialogs/dialog_lib_edit_pin_base.h
Expand Up @@ -12,6 +12,8 @@
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
class PinShapeComboBox;
class PinTypeComboBox;
class wxBitmapComboBox;

#include "dialog_shim.h"
Expand Down Expand Up @@ -64,9 +66,9 @@ class DIALOG_LIB_EDIT_PIN_BASE : public DIALOG_SHIM
wxStaticText* m_staticTextOrient;
wxBitmapComboBox* m_choiceOrientation;
wxStaticText* m_staticTextEType;
wxBitmapComboBox* m_choiceElectricalType;
PinTypeComboBox* m_choiceElectricalType;
wxStaticText* m_staticTextGstyle;
wxBitmapComboBox* m_choiceStyle;
PinShapeComboBox* m_choiceStyle;
wxCheckBox* m_checkApplyToAllParts;
wxCheckBox* m_checkApplyToAllConversions;
wxCheckBox* m_checkShow;
Expand Down
51 changes: 47 additions & 4 deletions eeschema/dialogs/dialog_lib_edit_pin_table.cpp
Expand Up @@ -183,7 +183,7 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent,
100,
wxAlignment( wxALIGN_LEFT | wxALIGN_TOP ),
wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE );
wxDataViewTextRenderer* rend2 = new wxDataViewTextRenderer( wxT( "string" ), wxDATAVIEW_CELL_INERT );
wxDataViewIconTextRenderer* rend2 = new wxDataViewIconTextRenderer( wxT( "wxDataViewIconText" ), wxDATAVIEW_CELL_INERT );
wxDataViewColumn* col2 = new wxDataViewColumn( _( "Type" ),
rend2,
DataViewModel::PIN_TYPE,
Expand Down Expand Up @@ -255,7 +255,23 @@ unsigned int DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::GetColumnCount() const

wxString DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::GetColumnType( unsigned int aCol ) const
{
return wxT( "string" );
switch( aCol )
{
case PIN_NUMBER:
return wxT( "string" );

case PIN_NAME:
return wxT( "string" );

case PIN_TYPE:
return wxT( "wxDataViewIconText" );

case PIN_POSITION:
return wxT( "string" );
}

assert( ! "Unhandled column" );
return wxT( "" );
}


Expand Down Expand Up @@ -431,8 +447,20 @@ void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Group::GetValue( wxVariant& aValu
if( aCol == m_GroupingColumn )
// shortcut
m_Members.front()->GetValue( aValue, aCol );
else
else if( aCol != PIN_TYPE )
aValue = GetString( aCol );
else
{
PinNumbers values;

for( std::list<Pin*>::const_iterator i = m_Members.begin(); i != m_Members.end(); ++i )
values.insert( (*i)->GetString( aCol ) );

if( values.size() > 1 )
aValue << wxDataViewIconText( boost::algorithm::join( values, "," ), wxNullIcon );
else
m_Members.front()->GetValue( aValue, aCol );
}
}


Expand Down Expand Up @@ -476,7 +504,22 @@ void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Group::Add( Pin* aPin )
void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Pin::GetValue( wxVariant& aValue,
unsigned int aCol ) const
{
aValue = GetString( aCol );
switch( aCol )
{
case PIN_NUMBER:
case PIN_NAME:
case PIN_POSITION:
aValue = GetString( aCol );
break;

case PIN_TYPE:
{
wxIcon icon;
icon.CopyFromBitmap( KiBitmap ( GetBitmap( m_Backing->GetType() ) ) );
aValue << wxDataViewIconText( m_Backing->GetElectricalTypeName(), icon );
}
break;
}
}


Expand Down
8 changes: 6 additions & 2 deletions eeschema/dialogs/dialog_sch_edit_sheet_pin.h
Expand Up @@ -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
{
Expand All @@ -49,8 +52,9 @@ class DIALOG_SCH_EDIT_SHEET_PIN : public DIALOG_SCH_EDIT_SHEET_PIN_BASE
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 ); }
Expand Down
8 changes: 4 additions & 4 deletions eeschema/edit_label.cpp
Expand Up @@ -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 )
Expand Down

0 comments on commit 4b103ba

Please sign in to comment.