Refresh layer selection dialogs.

Use platform-native widgets to show selection and draw layer
colours over the PCB background colour.

(cherry picked from commit 4f95f7f)
This commit is contained in:
Jeff Young 2018-06-30 21:22:01 +01:00
parent 7c3a67191b
commit fb21069c5a
4 changed files with 127 additions and 174 deletions

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 19 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -24,11 +24,14 @@ DIALOG_LAYER_SELECTION_BASE::DIALOG_LAYER_SELECTION_BASE( wxWindow* parent, wxWi
// Grid
m_leftGridLayers->CreateGrid( 1, 3 );
m_leftGridLayers->EnableEditing( false );
m_leftGridLayers->EnableGridLines( true );
m_leftGridLayers->EnableGridLines( false );
m_leftGridLayers->EnableDragGridSize( false );
m_leftGridLayers->SetMargins( 5, 3 );
// Columns
m_leftGridLayers->SetColSize( 0, 24 );
m_leftGridLayers->SetColSize( 1, 20 );
m_leftGridLayers->SetColSize( 2, 72 );
m_leftGridLayers->EnableDragColMove( false );
m_leftGridLayers->EnableDragColSize( false );
m_leftGridLayers->SetColLabelSize( 0 );
@ -45,8 +48,6 @@ DIALOG_LAYER_SELECTION_BASE::DIALOG_LAYER_SELECTION_BASE( wxWindow* parent, wxWi
// Cell Defaults
m_leftGridLayers->SetDefaultCellBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );
m_leftGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
m_leftGridLayers->SetMinSize( wxSize( -1,100 ) );
bSizerUpper->Add( m_leftGridLayers, 1, wxALL|wxEXPAND, 5 );
m_rightGridLayers = new wxGrid( this, ID_RIGHT_LIST, wxDefaultPosition, wxDefaultSize, 0 );
@ -54,11 +55,14 @@ DIALOG_LAYER_SELECTION_BASE::DIALOG_LAYER_SELECTION_BASE( wxWindow* parent, wxWi
// Grid
m_rightGridLayers->CreateGrid( 1, 3 );
m_rightGridLayers->EnableEditing( false );
m_rightGridLayers->EnableGridLines( true );
m_rightGridLayers->EnableGridLines( false );
m_rightGridLayers->EnableDragGridSize( false );
m_rightGridLayers->SetMargins( 5, 3 );
// Columns
m_rightGridLayers->SetColSize( 0, 24 );
m_rightGridLayers->SetColSize( 1, 20 );
m_rightGridLayers->SetColSize( 2, 72 );
m_rightGridLayers->EnableDragColMove( false );
m_rightGridLayers->EnableDragColSize( false );
m_rightGridLayers->SetColLabelSize( 0 );
@ -77,7 +81,7 @@ DIALOG_LAYER_SELECTION_BASE::DIALOG_LAYER_SELECTION_BASE( wxWindow* parent, wxWi
bSizerUpper->Add( m_rightGridLayers, 1, wxALL|wxEXPAND, 5 );
bSizerMain->Add( bSizerUpper, 1, wxEXPAND|wxALL, 5 );
bSizerMain->Add( bSizerUpper, 1, wxEXPAND|wxALL, 10 );
this->SetSizer( bSizerMain );
@ -125,11 +129,14 @@ DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE
// Grid
m_leftGridLayers->CreateGrid( 1, 3 );
m_leftGridLayers->EnableEditing( false );
m_leftGridLayers->EnableGridLines( true );
m_leftGridLayers->EnableGridLines( false );
m_leftGridLayers->EnableDragGridSize( false );
m_leftGridLayers->SetMargins( 0, 3 );
m_leftGridLayers->SetMargins( 3, 3 );
// Columns
m_leftGridLayers->SetColSize( 0, 24 );
m_leftGridLayers->SetColSize( 1, 20 );
m_leftGridLayers->SetColSize( 2, 72 );
m_leftGridLayers->EnableDragColMove( false );
m_leftGridLayers->EnableDragColSize( false );
m_leftGridLayers->SetColLabelSize( 0 );
@ -145,11 +152,11 @@ DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE
// Cell Defaults
m_leftGridLayers->SetDefaultCellBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );
m_leftGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
bSizerLeft->Add( m_leftGridLayers, 1, wxALL|wxEXPAND, 5 );
m_leftGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
bSizerLeft->Add( m_leftGridLayers, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
bSizerUpper->Add( bSizerLeft, 1, wxEXPAND, 5 );
bSizerUpper->Add( bSizerLeft, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerRight;
bSizerRight = new wxBoxSizer( wxVERTICAL );
@ -163,11 +170,14 @@ DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE
// Grid
m_rightGridLayers->CreateGrid( 1, 3 );
m_rightGridLayers->EnableEditing( false );
m_rightGridLayers->EnableGridLines( true );
m_rightGridLayers->EnableGridLines( false );
m_rightGridLayers->EnableDragGridSize( false );
m_rightGridLayers->SetMargins( 0, 3 );
m_rightGridLayers->SetMargins( 3, 3 );
// Columns
m_rightGridLayers->SetColSize( 0, 24 );
m_rightGridLayers->SetColSize( 1, 20 );
m_rightGridLayers->SetColSize( 2, 72 );
m_rightGridLayers->EnableDragColMove( false );
m_rightGridLayers->EnableDragColSize( false );
m_rightGridLayers->SetColLabelSize( 0 );
@ -182,16 +192,14 @@ DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE
// Cell Defaults
m_rightGridLayers->SetDefaultCellBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );
m_rightGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
m_rightGridLayers->SetMinSize( wxSize( -1,100 ) );
bSizerRight->Add( m_rightGridLayers, 1, wxALL|wxEXPAND, 5 );
m_rightGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
bSizerRight->Add( m_rightGridLayers, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
bSizerUpper->Add( bSizerRight, 1, wxEXPAND, 5 );
bSizerUpper->Add( bSizerRight, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 );
bSizerMain->Add( bSizerUpper, 0, wxALL|wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
@ -215,8 +223,6 @@ DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE
// Connect Events
m_leftGridLayers->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnLeftGridCellClick ), NULL, this );
m_rightGridLayers->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnRightGridCellClick ), NULL, this );
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnOKClick ), NULL, this );
}
DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::~DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE()
@ -224,7 +230,5 @@ DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::~DIALOG_COPPER_LAYER_PAIR_SELECTION_BAS
// Disconnect Events
m_leftGridLayers->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnLeftGridCellClick ), NULL, this );
m_rightGridLayers->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnRightGridCellClick ), NULL, this );
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnOKClick ), NULL, this );
}

View File

@ -14,7 +14,6 @@
<property name="file">dialog_layer_selection_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_layer_selection_base</property>
<property name="namespace"></property>
@ -95,7 +94,7 @@
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="border">10</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
@ -134,7 +133,7 @@
<property name="col_label_values"></property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="cols">3</property>
<property name="column_sizes"></property>
<property name="column_sizes">24,20,72</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
@ -151,7 +150,7 @@
<property name="floatable">1</property>
<property name="font"></property>
<property name="grid_line_color"></property>
<property name="grid_lines">1</property>
<property name="grid_lines">0</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">ID_LEFT_LIST</property>
@ -165,7 +164,7 @@
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">-1,100</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_leftGridLayers</property>
<property name="pane_border">1</property>
@ -277,7 +276,7 @@
<property name="col_label_values"></property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="cols">3</property>
<property name="column_sizes"></property>
<property name="column_sizes">24,20,72</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
@ -294,7 +293,7 @@
<property name="floatable">1</property>
<property name="font"></property>
<property name="grid_line_color"></property>
<property name="grid_lines">1</property>
<property name="grid_lines">0</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">ID_RIGHT_LIST</property>
@ -414,7 +413,7 @@
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="title">Select Copper Layer Pair:</property>
<property name="title">Select Copper Layer Pair</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
@ -462,8 +461,8 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerUpper</property>
@ -471,8 +470,8 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerLeft</property>
@ -563,8 +562,8 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL</property>
<property name="proportion">0</property>
<object class="wxGrid" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
@ -584,7 +583,7 @@
<property name="cell_font"></property>
<property name="cell_horiz_alignment">wxALIGN_LEFT</property>
<property name="cell_text"></property>
<property name="cell_vert_alignment">wxALIGN_TOP</property>
<property name="cell_vert_alignment">wxALIGN_CENTRE</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTRE</property>
@ -592,7 +591,7 @@
<property name="col_label_values"></property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="cols">3</property>
<property name="column_sizes"></property>
<property name="column_sizes">24,20,72</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
@ -609,7 +608,7 @@
<property name="floatable">1</property>
<property name="font"></property>
<property name="grid_line_color"></property>
<property name="grid_lines">1</property>
<property name="grid_lines">0</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">ID_LEFT_LIST</property>
@ -617,7 +616,7 @@
<property name="label_font"></property>
<property name="label_text"></property>
<property name="margin_height">3</property>
<property name="margin_width">0</property>
<property name="margin_width">3</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -708,8 +707,8 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerRight</property>
@ -800,8 +799,8 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL</property>
<property name="proportion">0</property>
<object class="wxGrid" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
@ -821,7 +820,7 @@
<property name="cell_font"></property>
<property name="cell_horiz_alignment">wxALIGN_LEFT</property>
<property name="cell_text"></property>
<property name="cell_vert_alignment">wxALIGN_TOP</property>
<property name="cell_vert_alignment">wxALIGN_CENTRE</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTRE</property>
@ -829,7 +828,7 @@
<property name="col_label_values"></property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="cols">3</property>
<property name="column_sizes"></property>
<property name="column_sizes">24,20,72</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
@ -846,7 +845,7 @@
<property name="floatable">1</property>
<property name="font"></property>
<property name="grid_line_color"></property>
<property name="grid_lines">1</property>
<property name="grid_lines">0</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">ID_RIGHT_LIST</property>
@ -854,13 +853,13 @@
<property name="label_font"></property>
<property name="label_text"></property>
<property name="margin_height">3</property>
<property name="margin_width">0</property>
<property name="margin_width">3</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">-1,100</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_rightGridLayers</property>
<property name="pane_border">1</property>
@ -1043,11 +1042,11 @@
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick">OnCancelClick</event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick">OnOKClick</event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 19 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -72,13 +72,11 @@ class DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE : public wxDialog
// Virtual event handlers, overide them in your derived class
virtual void OnLeftGridCellClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnRightGridCellClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select Copper Layer Pair:"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select Copper Layer Pair"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE();
};

View File

@ -37,6 +37,12 @@
#include <dialogs/dialog_layer_selection_base.h>
// Column position by function:
#define SELECT_COLNUM 0
#define COLOR_COLNUM 1
#define LAYERNAME_COLNUM 2
/* classes to display a layer list using a wxGrid.
*/
class PCB_LAYER_SELECTOR: public LAYER_SELECTOR
@ -79,16 +85,15 @@ protected:
class PCB_ONE_LAYER_SELECTOR : public PCB_LAYER_SELECTOR,
public DIALOG_LAYER_SELECTION_BASE
{
PCB_LAYER_ID m_layerSelected;
LSET m_notAllowedLayersMask;
BOARD* m_brd;
PCB_LAYER_ID m_layerSelected;
LSET m_notAllowedLayersMask;
BOARD* m_brd;
std::vector<PCB_LAYER_ID> m_layersIdLeftColumn;
std::vector<PCB_LAYER_ID> m_layersIdRightColumn;
public:
PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD * aBrd,
PCB_LAYER_ID aDefaultLayer,
LSET aNotAllowedLayersMask );
PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD * aBrd, PCB_LAYER_ID aDefaultLayer,
LSET aNotAllowedLayersMask );
LAYER_NUM GetLayerSelection() { return m_layerSelected; }
@ -101,65 +106,59 @@ private:
};
PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent,
BOARD* aBrd, PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask )
: PCB_LAYER_SELECTOR( aParent ), DIALOG_LAYER_SELECTION_BASE( aParent )
PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD* aBrd,
PCB_LAYER_ID aDefaultLayer,
LSET aNotAllowedLayersMask ) :
PCB_LAYER_SELECTOR( aParent ),
DIALOG_LAYER_SELECTION_BASE( aParent )
{
m_layerSelected = aDefaultLayer;
m_notAllowedLayersMask = aNotAllowedLayersMask;
m_brd = aBrd;
m_leftGridLayers->SetCellHighlightPenWidth( 0 );
m_rightGridLayers->SetCellHighlightPenWidth( 0 );
m_leftGridLayers->SetColFormatBool( SELECT_COLNUM );
m_rightGridLayers->SetColFormatBool( SELECT_COLNUM );
buildList();
Layout();
GetSizer()->SetSizeHints( this );
SetFocus();
}
// Build the layers list
// Column position by function:
#define SELECT_COLNUM 0
#define COLOR_COLNUM 1
#define LAYERNAME_COLNUM 2
void PCB_ONE_LAYER_SELECTOR::buildList()
{
// Hide layerid column which is used only to know the layer id
// not to be shown in dialogs
m_leftGridLayers->SetColSize( COLOR_COLNUM, 20 );
m_rightGridLayers->SetColSize( COLOR_COLNUM, 20 );
wxColour bg = GetLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
int left_row = 0;
int right_row = 0;
wxString layername;
int left_row = 0;
int right_row = 0;
wxString layername;
for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq )
for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq )
{
PCB_LAYER_ID layerid = *ui_seq;
if( m_notAllowedLayersMask[layerid] )
continue;
COLOR4D color = GetLayerColor( layerid );
layername = GetLayerName( layerid );
wxColour fg = GetLayerColor( layerid ).ToColour();
wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
layername = wxT( " " ) + GetLayerName( layerid );
if( IsCopperLayer( layerid ) )
{
if( left_row )
m_leftGridLayers->AppendRows( 1 );
m_leftGridLayers->SetCellBackgroundColour ( left_row, COLOR_COLNUM,
color.ToColour() );
m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM,
layername );
m_leftGridLayers->SetCellBackgroundColour ( left_row, COLOR_COLNUM, color );
m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM, layername );
if( m_layerSelected == layerid )
{
m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM,
wxT("X") );
m_leftGridLayers->SetCellBackgroundColour ( left_row, SELECT_COLNUM,
color.ToColour() );
m_leftGridLayers->SetGridCursor( left_row, LAYERNAME_COLNUM );
}
m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM, "1" );
m_layersIdLeftColumn.push_back( layerid );
left_row++;
@ -169,19 +168,11 @@ void PCB_ONE_LAYER_SELECTOR::buildList()
if( right_row )
m_rightGridLayers->AppendRows( 1 );
m_rightGridLayers->SetCellBackgroundColour ( right_row, COLOR_COLNUM,
color.ToColour() );
m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM,
layername );
m_rightGridLayers->SetCellBackgroundColour( right_row, COLOR_COLNUM, color );
m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM, layername );
if( m_layerSelected == layerid )
{
m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM,
wxT("X") );
m_rightGridLayers->SetCellBackgroundColour ( right_row, SELECT_COLNUM,
color.ToColour() );
m_rightGridLayers->SetGridCursor( right_row, LAYERNAME_COLNUM );
}
m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM, "1" );
m_layersIdRightColumn.push_back( layerid );
right_row++;
@ -194,18 +185,12 @@ void PCB_ONE_LAYER_SELECTOR::buildList()
if( right_row <= 0 )
m_rightGridLayers->Show( false );
m_leftGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
m_rightGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
m_leftGridLayers->AutoSizeColumn(SELECT_COLNUM);
m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM);
}
void PCB_ONE_LAYER_SELECTOR::OnLeftGridCellClick( wxGridEvent& event )
{
m_layerSelected = m_layersIdLeftColumn[ event.GetRow() ];
m_leftGridLayers->SetGridCursor( event.GetRow(), LAYERNAME_COLNUM );
EndModal( 1 );
}
@ -213,13 +198,12 @@ void PCB_ONE_LAYER_SELECTOR::OnLeftGridCellClick( wxGridEvent& event )
void PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick( wxGridEvent& event )
{
m_layerSelected = m_layersIdRightColumn[ event.GetRow() ];
m_rightGridLayers->SetGridCursor( event.GetRow(), LAYERNAME_COLNUM );
EndModal( 2 );
}
PCB_LAYER_ID PCB_BASE_FRAME::SelectLayer( PCB_LAYER_ID aDefaultLayer,
LSET aNotAllowedLayersMask, wxPoint aDlgPosition )
PCB_LAYER_ID PCB_BASE_FRAME::SelectLayer( PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask,
wxPoint aDlgPosition )
{
PCB_ONE_LAYER_SELECTOR dlg( this, GetBoard(), aDefaultLayer, aNotAllowedLayersMask );
@ -269,18 +253,7 @@ private:
void OnLeftGridCellClick( wxGridEvent& event ) override;
void OnRightGridCellClick( wxGridEvent& event ) override;
void OnOkClick( wxCommandEvent& event )
{
EndModal( wxID_OK );
}
void OnCancelClick( wxCommandEvent& event ) override
{
EndModal( wxID_CANCEL );
}
void buildList();
void SetGridCursor( wxGrid* aGrid, int aRow, bool aEnable );
};
@ -299,8 +272,7 @@ void PCB_BASE_FRAME::SelectCopperLayerPair()
// select the same layer for both layers is allowed (normal in some boards)
// but could be a mistake. So display an info message
if( screen->m_Route_Layer_TOP == screen->m_Route_Layer_BOTTOM )
DisplayInfoMessage( this,
_( "Warning: The Top Layer and Bottom Layer are same." ) );
DisplayInfoMessage( this, _( "Warning: top and bottom layers are same." ) );
}
m_canvas->MoveCursorToCrossHair();
@ -317,8 +289,15 @@ SELECT_COPPER_LAYERS_PAIR_DIALOG::SELECT_COPPER_LAYERS_PAIR_DIALOG(
m_leftRowSelected = 0;
m_rightRowSelected = 0;
m_brd = aPcb;
m_leftGridLayers->SetCellHighlightPenWidth( 0 );
m_rightGridLayers->SetCellHighlightPenWidth( 0 );
m_leftGridLayers->SetColFormatBool( SELECT_COLNUM );
m_rightGridLayers->SetColFormatBool( SELECT_COLNUM );
buildList();
SetFocus();
GetSizer()->SetSizeHints( this );
Center();
}
@ -326,79 +305,52 @@ SELECT_COPPER_LAYERS_PAIR_DIALOG::SELECT_COPPER_LAYERS_PAIR_DIALOG(
void SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList()
{
m_leftGridLayers->SetColSize( COLOR_COLNUM, 20 );
m_rightGridLayers->SetColSize( COLOR_COLNUM, 20 );
wxColour bg = GetLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
int row = 0;
wxString layername;
// Select a not show cell, to avoid a wrong cell selection for user
int row = 0;
wxString layername;
for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq )
for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq )
{
PCB_LAYER_ID layerid = *ui_seq;
if( !IsCopperLayer( layerid ) )
break;
continue;
COLOR4D color = GetLayerColor( layerid );
wxColour fg = GetLayerColor( layerid ).ToColour();
wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
layername = GetLayerName( layerid );
layername = wxT( " " ) + GetLayerName( layerid );
if( row )
m_leftGridLayers->AppendRows( 1 );
m_leftGridLayers->SetCellBackgroundColour( row, COLOR_COLNUM, color.ToColour() );
m_leftGridLayers->SetCellBackgroundColour( row, COLOR_COLNUM, color );
m_leftGridLayers->SetCellValue( row, LAYERNAME_COLNUM, layername );
m_layersId.push_back( layerid );
if( m_frontLayer == layerid )
{
SetGridCursor( m_leftGridLayers, row, true );
m_leftGridLayers->SetCellValue( row, SELECT_COLNUM, "1" );
m_leftGridLayers->SetGridCursor( row, COLOR_COLNUM );
m_leftRowSelected = row;
}
if( row )
m_rightGridLayers->AppendRows( 1 );
m_rightGridLayers->SetCellBackgroundColour ( row, COLOR_COLNUM,
color.ToColour() );
m_rightGridLayers->SetCellValue( row, LAYERNAME_COLNUM,
layername );
m_rightGridLayers->SetCellBackgroundColour( row, COLOR_COLNUM, color );
m_rightGridLayers->SetCellValue( row, LAYERNAME_COLNUM, layername );
if( m_backLayer == layerid )
{
SetGridCursor( m_rightGridLayers, row, true );
m_rightGridLayers->SetCellValue( row, SELECT_COLNUM, "1" );
m_rightRowSelected = row;
}
row++;
}
m_leftGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
m_rightGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
m_leftGridLayers->AutoSizeColumn(SELECT_COLNUM);
m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM);
}
void SELECT_COPPER_LAYERS_PAIR_DIALOG::SetGridCursor( wxGrid* aGrid, int aRow,
bool aEnable )
{
if( aEnable )
{
PCB_LAYER_ID layerid = m_layersId[aRow];
COLOR4D color = GetLayerColor( layerid );
aGrid->SetCellValue( aRow, SELECT_COLNUM, wxT("X") );
aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM, color.ToColour() );
aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM );
}
else
{
aGrid->SetCellValue( aRow, SELECT_COLNUM, wxEmptyString );
aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM,
aGrid->GetDefaultCellBackgroundColour() );
aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM );
}
}
@ -410,10 +362,10 @@ void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnLeftGridCellClick( wxGridEvent& event )
if( m_frontLayer == layer )
return;
SetGridCursor( m_leftGridLayers, m_leftRowSelected, false );
m_leftGridLayers->SetCellValue( m_leftRowSelected, SELECT_COLNUM, wxEmptyString );
m_frontLayer = layer;
m_leftRowSelected = row;
SetGridCursor( m_leftGridLayers, m_leftRowSelected, true );
m_leftGridLayers->SetCellValue( m_leftRowSelected, SELECT_COLNUM, "1" );
}
@ -425,8 +377,8 @@ void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnRightGridCellClick( wxGridEvent& event
if( m_backLayer == layer )
return;
SetGridCursor( m_rightGridLayers, m_rightRowSelected, false );
m_rightGridLayers->SetCellValue( m_rightRowSelected, SELECT_COLNUM, wxEmptyString );
m_backLayer = layer;
m_rightRowSelected = row;
SetGridCursor( m_rightGridLayers, m_rightRowSelected, true );
m_rightGridLayers->SetCellValue( m_rightRowSelected, SELECT_COLNUM, "1" );
}