diff --git a/common/tool/tool_action.cpp b/common/tool/tool_action.cpp index 61c917985f..985714702a 100644 --- a/common/tool/tool_action.cpp +++ b/common/tool/tool_action.cpp @@ -80,11 +80,11 @@ wxString TOOL_ACTION::GetMenuItem() const } -wxString TOOL_ACTION::GetDescription() const +wxString TOOL_ACTION::GetDescription( bool aIncludeHotkey ) const { wxString tooltip = wxGetTranslation( m_tooltip ); - if( GetHotKey() ) + if( aIncludeHotkey && GetHotKey() ) tooltip += wxString::Format( wxT( " (%s)" ), KeyNameFromKeyCode( GetHotKey() ) ); return tooltip; diff --git a/common/widgets/widget_hotkey_list.cpp b/common/widgets/widget_hotkey_list.cpp index 99c0dee9fa..5a64f01585 100644 --- a/common/widgets/widget_hotkey_list.cpp +++ b/common/widgets/widget_hotkey_list.cpp @@ -291,7 +291,7 @@ void WIDGET_HOTKEY_LIST::UpdateFromClientData() const HOTKEY& changed_hk = hkdata->GetChangedHotkey(); wxString label = changed_hk.m_Actions[ 0 ]->GetLabel(); wxString key_text = KeyNameFromKeyCode( changed_hk.m_EditKeycode ); - wxString description = changed_hk.m_Actions[ 0 ]->GetDescription(); + wxString description = changed_hk.m_Actions[ 0 ]->GetDescription( false ); if( label.IsEmpty() ) label = changed_hk.m_Actions[ 0 ]->GetName(); diff --git a/common/widgets/wx_grid.cpp b/common/widgets/wx_grid.cpp index 2226a17923..fbadd72db9 100644 --- a/common/widgets/wx_grid.cpp +++ b/common/widgets/wx_grid.cpp @@ -48,6 +48,12 @@ WX_GRID::~WX_GRID() void WX_GRID::SetColLabelSize( int aHeight ) { + if( aHeight == 0 ) + { + wxGrid::SetColLabelSize( 0 ); + return; + } + // correct wxFormBuilder height for large fonts wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); int minHeight = guiFont.GetPixelSize().y + 2 * MIN_GRIDCELL_MARGIN; diff --git a/include/tool/tool_action.h b/include/tool/tool_action.h index 3389ef8893..38a8b38862 100644 --- a/include/tool/tool_action.h +++ b/include/tool/tool_action.h @@ -122,7 +122,7 @@ public: wxString GetLabel() const; wxString GetMenuItem() const; - wxString GetDescription() const; + wxString GetDescription( bool aIncludeHotkey = true ) const; TOOL_ACTION_SCOPE GetScope() const { return m_scope; } diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index d7caea15c0..1b782795e6 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -33,12 +33,56 @@ #include #include #include +#include #include #include #include #include +NET_GRID_TABLE::NET_GRID_TABLE( PCB_BASE_FRAME* aFrame, wxColor aBackgroundColor ) : + wxGridTableBase(), + m_frame( aFrame ) +{ + m_defaultAttr = new wxGridCellAttr; + m_defaultAttr->SetBackgroundColour( aBackgroundColor ); + + m_labelAttr = new wxGridCellAttr; + m_labelAttr->SetRenderer( new GRID_CELL_ESCAPED_TEXT_RENDERER ); + m_labelAttr->SetBackgroundColour( aBackgroundColor ); +} + + +NET_GRID_TABLE::~NET_GRID_TABLE() +{ + m_defaultAttr->DecRef(); + m_labelAttr->DecRef(); +} + + +wxGridCellAttr* NET_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind ) +{ + switch( aCol ) + { + case COL_COLOR: + m_defaultAttr->IncRef(); + return m_defaultAttr; + + case COL_VISIBILITY: + m_defaultAttr->IncRef(); + return m_defaultAttr; + + case COL_LABEL: + m_labelAttr->IncRef(); + return m_labelAttr; + + default: + wxFAIL; + return nullptr; + } +} + + wxString NET_GRID_TABLE::GetValue( int aRow, int aCol ) { wxASSERT( static_cast( aRow ) < m_nets.size() ); @@ -219,8 +263,6 @@ void NET_GRID_TABLE::Rebuild() { wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_nets.size() ); GetView()->ProcessTableMessage( msg ); - - GetView()->AutoSizeColumn( NET_GRID_TABLE::COL_LABEL ); } } @@ -346,6 +388,8 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo int pointSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize(); int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); + m_layerPanelColour = m_panelLayers->GetBackgroundColour().ChangeLightness( 110 ); + m_layersOuterSizer = new wxBoxSizer( wxVERTICAL ); m_windowLayers->SetSizer( m_layersOuterSizer ); m_windowLayers->SetScrollRate( 0, 5 ); @@ -438,18 +482,20 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo new GRID_CELL_COLOR_RENDERER( m_frame, SWATCH_SMALL ), new GRID_CELL_COLOR_SELECTOR( m_frame, m_netsGrid ) ); - wxGridCellAttr* attr = new wxGridCellAttr; - attr->SetRenderer( new GRID_CELL_ESCAPED_TEXT_RENDERER ); - m_netsGrid->SetColAttr( NET_GRID_TABLE::COL_LABEL, attr ); - - m_netsTable = new NET_GRID_TABLE( m_frame ); - m_netsGrid->SetTable( m_netsTable, true, wxGrid::wxGridSelectRows ); + m_netsTable = new NET_GRID_TABLE( m_frame, m_panelNets->GetBackgroundColour() ); + m_netsGrid->SetTable( m_netsTable, true ); + m_netsGrid->SetColLabelSize( 0 ); + m_netsGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); m_netsGrid->SetSelectionForeground( m_netsGrid->GetDefaultCellTextColour() ); - m_netsGrid->SetSelectionBackground( m_netsGrid->GetBackgroundColour() ); + m_netsGrid->SetSelectionBackground( m_panelNets->GetBackgroundColour() ); const int cellPadding = 6; - const int rowHeightPadding = 4; +#ifdef __WXMAC__ + const int rowHeightPadding = 5; +#else + const int rowHeightPadding = 3; +#endif wxSize size = ConvertDialogToPixels( SWATCH_SIZE_SMALL_DU ); m_netsGrid->SetColSize( NET_GRID_TABLE::COL_COLOR, size.x + cellPadding ); @@ -1001,7 +1047,6 @@ void APPEARANCE_CONTROLS::rebuildLayers() wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL ); panel->SetSizer( sizer ); - m_layerPanelColour = panel->GetBackgroundColour().ChangeLightness( 110 ); panel->SetBackgroundColour( m_layerPanelColour ); aSetting->visible = visible[layer]; diff --git a/pcbnew/widgets/appearance_controls.h b/pcbnew/widgets/appearance_controls.h index 9765a2f072..a78aef465a 100644 --- a/pcbnew/widgets/appearance_controls.h +++ b/pcbnew/widgets/appearance_controls.h @@ -79,10 +79,8 @@ public: } public: - NET_GRID_TABLE( PCB_BASE_FRAME* aFrame ) : - wxGridTableBase(), - m_frame( aFrame ) - {} + NET_GRID_TABLE( PCB_BASE_FRAME* aFrame, wxColor aBackgroundColor ); + ~NET_GRID_TABLE(); int GetNumberRows() override { @@ -94,6 +92,8 @@ public: return COL_SIZE; } + wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind ) override; + wxString GetValue( int aRow, int aCol ) override; void SetValue( int aRow, int aCol, const wxString& aValue ) override; @@ -127,6 +127,9 @@ private: PCB_BASE_FRAME* m_frame; std::vector m_nets; + + wxGridCellAttr* m_defaultAttr; + wxGridCellAttr* m_labelAttr; }; diff --git a/pcbnew/widgets/appearance_controls_base.cpp b/pcbnew/widgets/appearance_controls_base.cpp index 0d940f4677..4fcab32635 100644 --- a/pcbnew/widgets/appearance_controls_base.cpp +++ b/pcbnew/widgets/appearance_controls_base.cpp @@ -5,6 +5,8 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "widgets/wx_grid.h" + #include "appearance_controls_base.h" /////////////////////////////////////////////////////////////////////////// @@ -12,7 +14,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) { this->SetFont( wxFont( 10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); - this->SetMinSize( wxSize( 160,360 ) ); + this->SetMinSize( wxSize( 200,360 ) ); m_sizerOuter = new wxBoxSizer( wxVERTICAL ); @@ -120,7 +122,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID bSizer192->Add( bSizer17, 0, wxEXPAND, 5 ); - m_netsGrid = new wxGrid( m_panelNets, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_netsGrid = new WX_GRID( m_panelNets, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid m_netsGrid->CreateGrid( 5, 3 ); @@ -130,7 +132,9 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID m_netsGrid->SetMargins( 0, 0 ); // Columns - m_netsGrid->AutoSizeColumns(); + m_netsGrid->SetColSize( 0, 40 ); + m_netsGrid->SetColSize( 1, 40 ); + m_netsGrid->SetColSize( 2, 400 ); m_netsGrid->EnableDragColMove( false ); m_netsGrid->EnableDragColSize( false ); m_netsGrid->SetColLabelSize( 0 ); @@ -145,7 +149,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID // Cell Defaults m_netsGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - bSizer192->Add( m_netsGrid, 1, wxALL|wxEXPAND, 5 ); + bSizer192->Add( m_netsGrid, 0, wxALL|wxEXPAND, 5 ); m_panelNets->SetSizer( bSizer192 ); @@ -274,7 +278,6 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID this->SetSizer( m_sizerOuter ); this->Layout(); - m_sizerOuter->Fit( this ); // Connect Events this->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( APPEARANCE_CONTROLS_BASE::OnSetFocus ) ); diff --git a/pcbnew/widgets/appearance_controls_base.fbp b/pcbnew/widgets/appearance_controls_base.fbp index e27e98639b..c26545d03c 100644 --- a/pcbnew/widgets/appearance_controls_base.fbp +++ b/pcbnew/widgets/appearance_controls_base.fbp @@ -40,10 +40,10 @@ 0 wxID_ANY - 160,360 + 200,360 APPEARANCE_CONTROLS_BASE - -1,-1 + 215,400 ; ; forward_declare @@ -1217,7 +1217,7 @@ 5 wxALL|wxEXPAND - 1 + 0 1 1 @@ -1227,7 +1227,7 @@ - 1 + 0 0 @@ -1245,7 +1245,7 @@ wxALIGN_CENTER 3 - + 40,40,400 1 0 @@ -1294,7 +1294,7 @@ 5 1 - ; ; forward_declare + WX_GRID; widgets/wx_grid.h; forward_declare 0 diff --git a/pcbnew/widgets/appearance_controls_base.h b/pcbnew/widgets/appearance_controls_base.h index 7271e328ed..502202477b 100644 --- a/pcbnew/widgets/appearance_controls_base.h +++ b/pcbnew/widgets/appearance_controls_base.h @@ -9,6 +9,8 @@ #include #include +class WX_GRID; + #include #include #include @@ -65,7 +67,7 @@ class APPEARANCE_CONTROLS_BASE : public wxPanel wxStaticText* m_staticTextNets; wxTextCtrl* m_txtNetFilter; wxBitmapButton* m_btnNetInspector; - wxGrid* m_netsGrid; + WX_GRID* m_netsGrid; wxPanel* m_panelNetclasses; wxStaticText* m_staticText14; wxBitmapButton* m_btnConfigureNetClasses; @@ -95,7 +97,7 @@ class APPEARANCE_CONTROLS_BASE : public wxPanel public: - APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 215,400 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); ~APPEARANCE_CONTROLS_BASE(); void m_netsTabSplitterOnIdle( wxIdleEvent& )