Commit b7b972d8 authored by jean-pierre charras's avatar jean-pierre charras

Rework on layer box selector, to use it in dialogs (currently the active layer...

Rework on layer box selector, to use it in dialogs (currently the active layer selector, the layer pair selector and the dimension editor dialog.
This rework solves Bug #1214545.
Work in progress: many dialogs do not yet use the layer box selector.
parents 93eeb75c 902e5cce
......@@ -7,53 +7,70 @@
#include <wx/wx.h>
#include <wx/ownerdrw.h>
#include <wx/menuitem.h>
#include <wx/aui/aui.h>
#include <class_layer_box_selector.h>
/* class to display a layer list.
*
*/
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
int n, const wxString choices[] ) :
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY )
LAYER_SELECTOR::LAYER_SELECTOR()
{
m_layerorder = true;
m_layerhotkeys = true;
m_hotkeys = NULL;
if( choices != NULL )
ResyncBitmapOnly();
}
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices ) :
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, choices, wxCB_READONLY )
bool LAYER_SELECTOR::SetLayersOrdered( bool value )
{
m_layerorder = true;
m_layerhotkeys = true;
m_hotkeys = NULL;
m_layerorder = value;
return m_layerorder;
}
if( !choices.IsEmpty() )
ResyncBitmapOnly();
bool LAYER_SELECTOR::SetLayersHotkeys( bool value )
{
m_layerhotkeys = value;
return m_layerhotkeys;
}
bool LAYER_BOX_SELECTOR::SetLayersOrdered( bool value )
void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer )
{
m_layerorder = value;
return m_layerorder;
wxMemoryDC bmpDC;
wxBrush brush;
// Prepare Bitmap
bmpDC.SelectObject( aLayerbmp );
brush.SetColour( MakeColour( GetLayerColor( aLayer ) ) );
brush.SetStyle( wxSOLID );
bmpDC.SetBrush( brush );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
bmpDC.SetPen( *wxBLACK_PEN );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
}
/* class to display a layer list in a wxBitmapComboBox.
*/
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
int n, const wxString choices[] ) :
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY ),
LAYER_SELECTOR()
{
if( choices != NULL )
ResyncBitmapOnly();
}
bool LAYER_BOX_SELECTOR::SetLayersHotkeys( bool value )
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices ) :
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, choices, wxCB_READONLY ),
LAYER_SELECTOR()
{
m_layerhotkeys = value;
return m_layerhotkeys;
if( !choices.IsEmpty() )
ResyncBitmapOnly();
}
......@@ -104,21 +121,3 @@ void LAYER_BOX_SELECTOR::ResyncBitmapOnly()
SetBitmapLayer( layerbmp, i );
}
}
void LAYER_BOX_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer )
{
wxMemoryDC bmpDC;
wxBrush brush;
// Prepare Bitmap
bmpDC.SelectObject( aLayerbmp );
brush.SetColour( MakeColour( GetLayerColor( aLayer ) ) );
brush.SetStyle( wxSOLID );
bmpDC.SetBrush( brush );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
bmpDC.SetPen( *wxBLACK_PEN );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
}
......@@ -32,14 +32,8 @@
#include <common.h>
#include <colors_selection.h>
#include <layers_id_colors_and_visibility.h>
#include <gerbview_frame.h>
#include <wx/ownerdrw.h>
#include <wx/menuitem.h>
#include <wx/bmpcbox.h>
#include <wx/wx.h>
#include <class_gbr_layer_box_selector.h>
void GBR_LAYER_BOX_SELECTOR::Resync()
......
......@@ -4,14 +4,11 @@
#include <class_layer_box_selector.h>
/* class to display a layer list in GerbView.
*
*/
// class to display a layer list in GerbView.
class GBR_LAYER_BOX_SELECTOR : public LAYER_BOX_SELECTOR
{
public:
GBR_LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
GBR_LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL )
......@@ -21,16 +18,6 @@ public:
m_layerorder = false;
}
GBR_LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices )
:LAYER_BOX_SELECTOR( parent, id, pos, size, choices )
{
m_layerhotkeys = false;
m_layerorder = false;
}
// Reload the Layers names and bitmaps
// Virtual function
void Resync();
......
#ifndef CLASS_LAYER_BOX_SELECTOR_H
#define CLASS_LAYER_BOX_SELECTOR_H 1
#include <hotkeys_basic.h>
#include <wx/bmpcbox.h>
#include <colors.h> // EDA_COLOR_T definition
#include <layers_id_colors_and_visibility.h>
class EDA_HOTKEY_CONFIG;
class wxAuiToolBar;
/* class to display a layer list.
*
/* Basic class to build a layer list.
* this is an basic abstract class to build a layer list selector.
* To display this list, you should therefore derive this class
*/
class LAYER_BOX_SELECTOR : public wxBitmapComboBox
class LAYER_SELECTOR
{
protected:
bool m_layerhotkeys;
......@@ -24,14 +22,7 @@ public:
struct EDA_HOTKEY_CONFIG* m_hotkeys;
public:
LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL );
LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices );
LAYER_SELECTOR();
// Returns a color index from the layer id
// Virtual function because GerbView uses its own functions in a derived class
......@@ -45,7 +36,33 @@ public:
// Virtual function pure because GerbView uses its own functions in a derived class
virtual bool IsLayerEnabled( LAYER_NUM aLayer ) const = 0;
// Get Current Item #
bool SetLayersOrdered(bool value);
bool SetLayersHotkeys(bool value);
protected:
// Fills the layer bitmap aLayerbmp with the layer color
void SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer );
};
/* class to display a layer list in a wxBitmapComboBox.
*/
class LAYER_BOX_SELECTOR :public wxBitmapComboBox, public LAYER_SELECTOR
{
public:
// Hotkey Info
struct EDA_HOTKEY_CONFIG* m_hotkeys;
public:
LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL );
LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices );
// Get Current Item #
int GetChoice();
// Get Current Layer
......@@ -60,13 +77,6 @@ public:
// Reload the Layers bitmaps colors
void ResyncBitmapOnly();
bool SetLayersOrdered(bool value);
bool SetLayersHotkeys(bool value);
protected:
// Fills the layer bitmap aLayerbmp with the layer color
void SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer );
};
#define DECLARE_LAYERS_HOTKEY(list) int list[NB_LAYERS] = \
......
......@@ -542,7 +542,15 @@ public:
void ReCreateMicrowaveVToolbar();
void ReCreateOptToolbar();
void ReCreateMenuBar();
PCB_LAYER_BOX_SELECTOR* ReCreateLayerBox( wxAuiToolBar* parent );
/**
* Re create the layer Box by clearing the old list, and building
* le new one, from the new layers names and cole layers
* @param aForceResizeToolbar = true to resize the parent toolbar
* false if not needed (mainly in parent toolbar creation,
* or when the layers names are not modified)
*/
void ReCreateLayerBox( bool aForceResizeToolbar = true );
/**
* Function OnModify
......
......@@ -186,9 +186,14 @@ void PL_EDITOR_FRAME::Files_io( wxCommandEvent& event )
filename = openFileDialog.GetPath();
// Ensure the file has the right extension:
// because a name like name.subname.subsubname is legal,
// add the right extension without replacing the wxFileName
// extension
wxFileName fn(filename);
fn.SetExt( PageLayoutDescrFileExtension );
filename = fn.GetFullPath();
if( fn.GetExt() != PageLayoutDescrFileExtension )
filename << wxT(".") << PageLayoutDescrFileExtension;
if( !SavePageLayoutDescrFile( filename ) )
{
wxString msg;
......
......@@ -76,6 +76,7 @@ set( PCBNEW_DIALOGS
dialogs/dialog_global_deletion_base.cpp
dialogs/dialog_keepout_area_properties.cpp
dialogs/dialog_keepout_area_properties_base.cpp
dialogs/dialog_layer_selection_base.cpp
dialogs/dialog_layers_setup.cpp
dialogs/dialog_layers_setup_base.cpp
dialogs/dialog_netlist.cpp
......
......@@ -38,17 +38,9 @@
#include <class_board.h>
#include <hotkeys.h>
#include <wx/ownerdrw.h>
#include <wx/menuitem.h>
#include <wx/bmpcbox.h>
#include <wx/wx.h>
#include <class_pcb_layer_box_selector.h>
/* class to display a layer list.
*
*/
// class to display a layer list in a wxBitmapComboBox.
// Reload the Layers
void PCB_LAYER_BOX_SELECTOR::Resync()
......@@ -58,9 +50,14 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
static DECLARE_LAYERS_ORDER_LIST( layertranscode );
static DECLARE_LAYERS_HOTKEY( layerhk );
// Tray to fix a minimum width fot the BitmapComboBox
int minwidth = 80, h;
wxClientDC dc( GetParent() ); // The DC for "this" is not always initialized
#define BM_SIZE 14
for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i )
{
wxBitmap layerbmp( 14, 14 );
wxBitmap layerbmp( BM_SIZE, BM_SIZE );
wxString layername;
LAYER_NUM layerid = i;
......@@ -70,23 +67,33 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
if( ! IsLayerEnabled( layerid ) )
continue;
if( ( m_layerMaskDisable & GetLayerMask( layerid ) ) )
continue;
SetBitmapLayer( layerbmp, layerid );
layername = GetLayerName( layerid );
if( m_layerhotkeys && m_hotkeys != NULL )
layername = AddHotkeyName( layername, m_hotkeys, layerhk[layerid], IS_COMMENT );
layername = AddHotkeyName( layername, m_hotkeys,
layerhk[layerid], IS_COMMENT );
Append( layername, layerbmp, (void*)(intptr_t) layerid );
int w;
dc.GetTextExtent ( layername, &w, &h );
minwidth = std::max( minwidth, w );
}
minwidth += BM_SIZE + 35; // Take in account the bitmap size and margins
SetMinClientSize( wxSize( minwidth, -1 ) );
}
// Returns true if the layer id is enabled (i.e. is it should be displayed)
bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled( LAYER_NUM aLayer ) const
{
PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent();
BOARD* board = pcbFrame->GetBoard();
wxASSERT( m_boardFrame != NULL );
BOARD* board = m_boardFrame->GetBoard();
wxASSERT( board != NULL );
return board->IsLayerEnabled( aLayer );
......@@ -96,8 +103,8 @@ bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled( LAYER_NUM aLayer ) const
// Returns a color index from the layer id
EDA_COLOR_T PCB_LAYER_BOX_SELECTOR::GetLayerColor( LAYER_NUM aLayer ) const
{
PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent();
BOARD* board = pcbFrame->GetBoard();
wxASSERT( m_boardFrame != NULL );
BOARD* board = m_boardFrame->GetBoard();
wxASSERT( board != NULL );
return board->GetLayerColor( aLayer );
......@@ -107,8 +114,8 @@ EDA_COLOR_T PCB_LAYER_BOX_SELECTOR::GetLayerColor( LAYER_NUM aLayer ) const
// Returns the name of the layer id
wxString PCB_LAYER_BOX_SELECTOR::GetLayerName( LAYER_NUM aLayer ) const
{
PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent();
BOARD* board = pcbFrame->GetBoard();
wxASSERT( m_boardFrame != NULL );
BOARD* board = m_boardFrame->GetBoard();
wxASSERT( board != NULL );
return board->GetLayerName( aLayer );
......
......@@ -3,41 +3,53 @@
#include <class_layer_box_selector.h>
class PCB_BASE_FRAME;
/* class to display a layer list in Pcbnew.
*
*/
/* class to display a layer list.
*
/* class to display a pcb layer list in a wxBitmapComboBox.
*/
class PCB_LAYER_BOX_SELECTOR : public LAYER_BOX_SELECTOR
{
PCB_BASE_FRAME * m_boardFrame;
LAYER_MSK m_layerMaskDisable; // A mask to remove some layers from layer list
public:
// Hotkey Info
struct EDA_HOTKEY_CONFIG* m_hotkeys;
public:
PCB_LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
// If you are thinking the constructor is a bit curious,
// just remember it is used by automaticallty generated by wxFormBuilder files,
// and it should mimic the wxBitmapComboBox constructor.
// Therefore, value, style are not yet used,
// but they are here for compatibility
PCB_LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL )
int n = 0, const wxString choices[] = NULL, int style = 0 )
:LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices )
{
}
{
m_boardFrame = NULL;
m_layerMaskDisable = 0;
}
// Accessors
// SetBoardFrame should be called after creating a PCB_LAYER_BOX_SELECTOR
// It is not passed through the constructor because when using wxFormBuilder
// we should use a constructor compatible with a wxBitmapComboBox
void SetBoardFrame( PCB_BASE_FRAME * aFrame ) { m_boardFrame = aFrame; };
PCB_LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices )
:LAYER_BOX_SELECTOR( parent, id, pos, size, choices )
{
}
// SetLayerMask allows disableing some layers, whiech are not
// shown in list;
void SetLayerMask( LAYER_MSK aMask ) { m_layerMaskDisable = aMask; }
// Reload the Layers names and bitmaps
// Virtual function
void Resync();
private:
// Returns a color index from the layer id
// Virtual function
EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const;
......
......@@ -341,7 +341,7 @@ void PCB_LAYER_WIDGET::ReFill()
void PCB_LAYER_WIDGET::OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor )
{
myframe->GetBoard()->SetLayerColor( aLayer, aColor );
myframe->ReCreateLayerBox( NULL );
myframe->ReCreateLayerBox( false );
myframe->GetCanvas()->Refresh();
}
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "class_pcb_layer_box_selector.h"
#include "dialog_dimension_editor_base.h"
///////////////////////////////////////////////////////////////////////////
......@@ -21,6 +23,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
bSizerMain->Add( m_staticTextDim, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_Name = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_Name->SetMaxLength( 0 );
m_Name->SetMinSize( wxSize( 400,-1 ) );
bSizerMain->Add( m_Name, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
......@@ -36,6 +39,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
bSizerLeft->Add( m_staticTextSizeX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TxtSizeXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_TxtSizeXCtrl->SetMaxLength( 0 );
bSizerLeft->Add( m_TxtSizeXCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextSizeY = new wxStaticText( this, wxID_ANY, _("Size Y"), wxDefaultPosition, wxDefaultSize, 0 );
......@@ -43,6 +47,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
bSizerLeft->Add( m_staticTextSizeY, 0, wxRIGHT|wxLEFT, 5 );
m_TxtSizeYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_TxtSizeYCtrl->SetMaxLength( 0 );
bSizerLeft->Add( m_TxtSizeYCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextWidth = new wxStaticText( this, wxID_ANY, _("Width"), wxDefaultPosition, wxDefaultSize, 0 );
......@@ -50,6 +55,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
bSizerLeft->Add( m_staticTextWidth, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TxtWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_TxtWidthCtrl->SetMaxLength( 0 );
bSizerLeft->Add( m_TxtWidthCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextPosX = new wxStaticText( this, wxID_ANY, _("Text position X"), wxDefaultPosition, wxDefaultSize, 0 );
......@@ -57,6 +63,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
bSizerLeft->Add( m_staticTextPosX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_textCtrlPosX = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrlPosX->SetMaxLength( 0 );
bSizerLeft->Add( m_textCtrlPosX, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextPosY = new wxStaticText( this, wxID_ANY, _("Text position Y"), wxDefaultPosition, wxDefaultSize, 0 );
......@@ -64,6 +71,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
bSizerLeft->Add( m_staticTextPosY, 0, wxRIGHT|wxLEFT, 5 );
m_textCtrlPosY = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrlPosY->SetMaxLength( 0 );
bSizerLeft->Add( m_textCtrlPosY, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
......@@ -82,7 +90,7 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
m_staticTextLayer->Wrap( -1 );
bSizerRight->Add( m_staticTextLayer, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_SelLayerBox = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
bSizerRight->Add( m_SelLayerBox, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
......
......@@ -1389,7 +1389,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="subclass">PCB_LAYER_BOX_SELECTOR; class_pcb_layer_box_selector.h</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -11,6 +11,9 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
class PCB_LAYER_BOX_SELECTOR;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
......@@ -51,7 +54,7 @@ class DIALOG_DIMENSION_EDITOR_BASE : public DIALOG_SHIM
wxTextCtrl* m_textCtrlPosY;
wxRadioBox* m_rbMirror;
wxStaticText* m_staticTextLayer;
wxComboBox* m_SelLayerBox;
PCB_LAYER_BOX_SELECTOR* m_SelLayerBox;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizerBts;
wxButton* m_sdbSizerBtsOK;
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_layer_selection_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_LAYER_SELECTION_BASE::DIALOG_LAYER_SELECTION_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerUpper;
bSizerUpper = new wxBoxSizer( wxHORIZONTAL );
m_leftGridLayers = new wxGrid( this, ID_LEFT_LIST, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_leftGridLayers->CreateGrid( 1, 4 );
m_leftGridLayers->EnableEditing( false );
m_leftGridLayers->EnableGridLines( true );
m_leftGridLayers->EnableDragGridSize( false );
m_leftGridLayers->SetMargins( 0, 3 );
// Columns
m_leftGridLayers->EnableDragColMove( false );
m_leftGridLayers->EnableDragColSize( false );
m_leftGridLayers->SetColLabelSize( 0 );
m_leftGridLayers->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_leftGridLayers->EnableDragRowSize( false );
m_leftGridLayers->SetRowLabelSize( 0 );
m_leftGridLayers->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
m_leftGridLayers->SetLabelBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
// Cell Defaults
m_leftGridLayers->SetDefaultCellBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );
m_leftGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
bSizerUpper->Add( m_leftGridLayers, 0, wxALL|wxEXPAND, 5 );
m_rightGridLayers = new wxGrid( this, ID_RIGHT_LIST, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_rightGridLayers->CreateGrid( 1, 4 );
m_rightGridLayers->EnableEditing( false );
m_rightGridLayers->EnableGridLines( true );
m_rightGridLayers->EnableDragGridSize( false );
m_rightGridLayers->SetMargins( 0, 3 );
// Columns
m_rightGridLayers->EnableDragColMove( false );
m_rightGridLayers->EnableDragColSize( false );
m_rightGridLayers->SetColLabelSize( 0 );
m_rightGridLayers->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_rightGridLayers->EnableDragRowSize( false );
m_rightGridLayers->SetRowLabelSize( 0 );
m_rightGridLayers->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_rightGridLayers->SetDefaultCellBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );
m_rightGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
bSizerUpper->Add( m_rightGridLayers, 0, wxALL|wxEXPAND, 5 );
bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 );
m_buttonClear = new wxButton( this, wxID_ANY, _("Clear Selection"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerMain->Add( m_buttonClear, 0, wxALL|wxALIGN_RIGHT, 5 );
this->SetSizer( bSizerMain );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
m_leftGridLayers->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_LAYER_SELECTION_BASE::OnLeftGridClick ), NULL, this );
m_rightGridLayers->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_LAYER_SELECTION_BASE::OnRightGridClick ), NULL, this );
m_buttonClear->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LAYER_SELECTION_BASE::OnClearSelection ), NULL, this );
}
DIALOG_LAYER_SELECTION_BASE::~DIALOG_LAYER_SELECTION_BASE()
{
// Disconnect Events
m_leftGridLayers->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_LAYER_SELECTION_BASE::OnLeftGridClick ), NULL, this );
m_rightGridLayers->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_LAYER_SELECTION_BASE::OnRightGridClick ), NULL, this );
m_buttonClear->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LAYER_SELECTION_BASE::OnClearSelection ), NULL, this );
}
DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerUpper;
bSizerUpper = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerLeft;
bSizerLeft = new wxBoxSizer( wxVERTICAL );
m_staticTextTopLayer = new wxStaticText( this, wxID_ANY, _("Top/Front Layer"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextTopLayer->Wrap( -1 );
bSizerLeft->Add( m_staticTextTopLayer, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_leftGridLayers = new wxGrid( this, ID_LEFT_LIST, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_leftGridLayers->CreateGrid( 1, 4 );
m_leftGridLayers->EnableEditing( false );
m_leftGridLayers->EnableGridLines( true );
m_leftGridLayers->EnableDragGridSize( false );
m_leftGridLayers->SetMargins( 0, 3 );
// Columns
m_leftGridLayers->EnableDragColMove( false );
m_leftGridLayers->EnableDragColSize( false );
m_leftGridLayers->SetColLabelSize( 0 );
m_leftGridLayers->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_leftGridLayers->EnableDragRowSize( false );
m_leftGridLayers->SetRowLabelSize( 0 );
m_leftGridLayers->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
m_leftGridLayers->SetLabelBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
// 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 );
bSizerUpper->Add( bSizerLeft, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerRight;
bSizerRight = new wxBoxSizer( wxVERTICAL );
m_staticTextBottomLayer = new wxStaticText( this, wxID_ANY, _("Bottom/Back Layer"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextBottomLayer->Wrap( -1 );
bSizerRight->Add( m_staticTextBottomLayer, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_rightGridLayers = new wxGrid( this, ID_RIGHT_LIST, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_rightGridLayers->CreateGrid( 1, 4 );
m_rightGridLayers->EnableEditing( false );
m_rightGridLayers->EnableGridLines( true );
m_rightGridLayers->EnableDragGridSize( false );
m_rightGridLayers->SetMargins( 0, 3 );
// Columns
m_rightGridLayers->EnableDragColMove( false );
m_rightGridLayers->EnableDragColSize( false );
m_rightGridLayers->SetColLabelSize( 0 );
m_rightGridLayers->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_rightGridLayers->EnableDragRowSize( false );
m_rightGridLayers->SetRowLabelSize( 0 );
m_rightGridLayers->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_rightGridLayers->SetDefaultCellBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );
m_rightGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
bSizerRight->Add( m_rightGridLayers, 1, wxALL|wxEXPAND, 5 );
bSizerUpper->Add( bSizerRight, 1, wxEXPAND, 5 );
bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bSizerMain->Add( m_sdbSizer, 0, wxEXPAND, 5 );
this->SetSizer( bSizerMain );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
m_leftGridLayers->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnLeftGridClick ), NULL, this );
m_rightGridLayers->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnRightGridClick ), 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()
{
// Disconnect Events
m_leftGridLayers->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnLeftGridClick ), NULL, this );
m_rightGridLayers->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnRightGridClick ), 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 );
}
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_LAYER_SELECTION_BASE_H__
#define __DIALOG_LAYER_SELECTION_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/font.h>
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
#include <wx/stattext.h>
#include <wx/statline.h>
///////////////////////////////////////////////////////////////////////////
#define ID_LEFT_LIST 1000
#define ID_RIGHT_LIST 1001
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_LAYER_SELECTION_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_LAYER_SELECTION_BASE : public wxDialog
{
private:
protected:
wxGrid* m_leftGridLayers;
wxGrid* m_rightGridLayers;
wxButton* m_buttonClear;
// Virtual event handlers, overide them in your derived class
virtual void OnLeftGridClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnRightGridClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnClearSelection( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_LAYER_SELECTION_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select Layer:"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 452,183 ), long style = wxCAPTION|wxCLOSE_BOX );
~DIALOG_LAYER_SELECTION_BASE();
};
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE : public wxDialog
{
private:
protected:
wxStaticText* m_staticTextTopLayer;
wxGrid* m_leftGridLayers;
wxStaticText* m_staticTextBottomLayer;
wxGrid* m_rightGridLayers;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnLeftGridClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnRightGridClick( 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 Cpper Layer Pair:"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 332,175 ), long style = wxDEFAULT_DIALOG_STYLE );
~DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE();
};
#endif //__DIALOG_LAYER_SELECTION_BASE_H__
......@@ -560,7 +560,7 @@ void DIALOG_LAYERS_SETUP::OnOkButtonClick( wxCommandEvent& event )
}
m_Parent->OnModify();
m_Parent->ReCreateLayerBox( NULL );
m_Parent->ReCreateLayerBox();
m_Parent->ReFillLayerWidget();
EndModal( wxID_OK );
......
......@@ -44,6 +44,7 @@
#include <pcbnew.h>
#include <dialog_dimension_editor_base.h>
#include <class_pcb_layer_box_selector.h>
/* Local functions */
static void BuildDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
......@@ -132,12 +133,12 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
PutValueInLocalUnits( *m_textCtrlPosY, aDimension->Text().GetTextPosition().y );
AddUnitSymbol( *m_staticTextPosY );
for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer < NB_PCB_LAYERS; ++layer )
{
m_SelLayerBox->Append( aParent->GetBoard()->GetLayerName( layer ) );
}
m_SelLayerBox->SetSelection( aDimension->GetLayer() - FIRST_NON_COPPER_LAYER );
// Configure the layers list selector
m_SelLayerBox->SetLayersHotkeys( false );
m_SelLayerBox->SetLayerMask( ALL_CU_LAYERS | EDGE_LAYER );
m_SelLayerBox->SetBoardFrame( m_Parent );
m_SelLayerBox->Resync();
m_SelLayerBox->SetLayerSelection( aDimension->GetLayer() );
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
......@@ -199,7 +200,7 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
CurrentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false );
CurrentDimension->SetLayer( FIRST_NON_COPPER_LAYER + m_SelLayerBox->GetCurrentSelection() );
CurrentDimension->SetLayer( m_SelLayerBox->GetLayerSelection() );
if( m_DC ) // Display new text
{
......
......@@ -925,7 +925,15 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
itmp = SelectLayer( getActiveLayer(), UNDEFINED_LAYER, UNDEFINED_LAYER );
if( itmp >= 0 )
{
// if user changed colors and we are in high contrast mode, then redraw
// because the PAD_SMD pads may change color.
if( DisplayOpt.ContrastModeDisplay && getActiveLayer() != itmp )
{
m_canvas->Refresh();
}
setActiveLayer( itmp );
}
m_canvas->MoveCursorToCrossHair();
break;
......
......@@ -141,7 +141,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
fn.SetExt( PcbFileExtension );
GetBoard()->SetFileName( fn.GetFullPath() );
UpdateTitle();
ReCreateLayerBox( NULL );
ReCreateLayerBox();
}
break;
......@@ -396,8 +396,7 @@ bool PCB_EDIT_FRAME::LoadOnePcbFile( const wxString& aFileName, bool aAppend,
// Update info shown by the horizontal toolbars
GetBoard()->SetCurrentNetClass( NETCLASS::Default );
ReFillLayerWidget();
ReCreateLayerBox( NULL );
ReCreateLayerBox();
// upate the layer widget to match board visibility states, both layers and render columns.
syncLayerVisibilities();
......
......@@ -589,7 +589,7 @@ void PCB_EDIT_FRAME::ShowDesignRulesEditor( wxCommandEvent& event )
if( returncode == wxID_OK ) // New rules, or others changes.
{
ReCreateLayerBox( NULL );
ReCreateLayerBox();
updateTraceWidthSelectBox();
updateViaSizeSelectBox();
OnModify();
......
......@@ -301,7 +301,7 @@ bool EDA_APP::OnInit()
frame->Clear_Pcb( false );
// update the layer names in the listbox
frame->ReCreateLayerBox( NULL );
frame->ReCreateLayerBox( false );
/* For an obscure reason the focus is lost after loading a board file
* when starting (i.e. only at this point)
......
This diff is collapsed.
......@@ -277,9 +277,11 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
m_mainToolBar->AddSeparator();
if( m_SelLayerBox == NULL )
{
m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( m_mainToolBar, ID_TOOLBARH_PCB_SELECT_LAYER );
ReCreateLayerBox( m_mainToolBar );
m_SelLayerBox->SetBoardFrame( this );
}
ReCreateLayerBox( false );
m_mainToolBar->AddControl( m_SelLayerBox );
PrepareLayerIndicator(); // Initialize the bitmap with current
......@@ -661,14 +663,19 @@ void PCB_EDIT_FRAME::updateViaSizeSelectBox()
}
PCB_LAYER_BOX_SELECTOR* PCB_EDIT_FRAME::ReCreateLayerBox( wxAuiToolBar* parent )
void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
{
if( m_SelLayerBox == NULL )
return NULL;
if( m_SelLayerBox == NULL || m_mainToolBar == NULL )
return;
m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
m_SelLayerBox->m_hotkeys = g_Board_Editor_Hokeys_Descr;
m_SelLayerBox->Resync();
m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
return m_SelLayerBox;
if( aForceResizeToolbar )
{
// the layer box can have its size changed
// Update the aui manager, to take in account the new size
m_auimgr.Update();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment