Commit 6518139b authored by dickelbeck's avatar dickelbeck

more layer widget work

parent 84d82cf2
......@@ -4,6 +4,26 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.
2010-Jan-23 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++pcbnew's PCB_LAYER_WIDGET
Removed wxformbuilder dependency from LAYER_WIDGET, thus killing off
layer_widget_base.* and panel_layer_select.fbp.
Added aPointSize to LAYER_WIDGET constructor so it uses that font size.
Removed layer_widget.h from wxPcbStruct.h for faster compiles with less
dependencies, and this meant moving the class LYRS out of
class WinEDA_PcbFrame. While doing that I renamed it to PCB_LAYER_WIDGET.
Integration of PCB_LAYER_WIDGET into WinEDA_PcbFrame to fully support
the layer change logic. Added syncLayerWidget(),
* WinEDA_PcbFrame:
Added syncLayerWidget(), syncLayerBox() (via a rename), setActiveLayer(),
and getActiveLayer().
Use a font size in PCB_LAYER_WIDGET 80% of the system font size for systems
with screen resolution height <= 900, or 100% if not. See WinEDA_PcbFrame
constructor.
* See TODO.txt for more things that need to be done.
2010-Jan-23 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++ Pcbnew:
......
......@@ -72,19 +72,24 @@ PCBNew
* Need to add polygon aperture type.
Then example 2 in RS274xrevd_e.pdf will draw properly.
Dick:
* Get the nested quote support for DSNLEXER fixed up and committed.
LAYER_WIDGET for PCBNEW
-----------------------
L2) Hook in bool WinEDA_PcbFrame::LYRS::OnLayerSelect( int aLayer )
L4) Move popup menu code from class LAYER_WIDGET into WinEDA_PcbFrame::LYRS so as
to keep LAYER_WIDGET fully usage agnostic. Remove #include "pcbstruct.h" // IsValidCopperLayerIndex()
from layer_widget.cpp.
L5) Add to moved popu menu code the ability to save the current layer widget
color and enable settings with an additional menu item.
L6) Test, and fix up any remaining issues with the PCB_VISIBLE support, several
items which are stored on globals could and should be stored in
EDA_Settings.m_VisibleElements using enum PCB_VISIBLE.
EDA_Settings.m_VisibleElements using enum PCB_VISIBLE. Initial Render
checkbox settings are probably not correct, for example grid.
L7) make the bitmapbutton a staticbitmap, and make its size dependent on
the point size.
L8) LAYER_WIDGET::GetBestSize() needs platform independence.
Dick:
L9) still thinking about background colors, easier now without wxformbuilder.
......@@ -8,7 +8,6 @@
#include "wxstruct.h"
#include "base_struct.h"
#include "layer_widget.h"
#ifndef PCB_INTERNAL_UNIT
#define PCB_INTERNAL_UNIT 10000
......@@ -36,6 +35,7 @@ class ZONE_CONTAINER;
class DRAWSEGMENT;
class GENERAL_COLLECTOR;
class GENERAL_COLLECTORS_GUIDE;
class PCB_LAYER_WIDGET;
/**
......@@ -49,34 +49,64 @@ class GENERAL_COLLECTORS_GUIDE;
/*****************************************************/
class WinEDA_PcbFrame : public WinEDA_BasePcbFrame
{
friend class PCB_LAYER_WIDGET;
protected:
PCB_LAYER_WIDGET* m_Layers;
DRC* m_drc; ///< the DRC controller, see drc.cpp
// we'll use lower case function names for private member functions.
void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu );
void createPopUpMenuForFootprints( MODULE* aModule, wxMenu* aPopMenu );
void createPopUpMenuForFpTexts( TEXTE_MODULE* aText, wxMenu* aPopMenu );
void createPopUpMenuForFpPads( D_PAD* aPad, wxMenu* aPopMenu );
void createPopupMenuForTracks( TRACK* aTrack, wxMenu* aPopMenu );
void createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu );
void createPopUpBlockMenu( wxMenu* menu );
void createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu );
/**
* Class LYRS
* is here to implement the abtract functions of LAYER_WIDGET so they
* may be tied into this frame's data.
* Function setActiveLayer
* will change the currently active layer to \a aLayer and also
* update the PCB_LAYER_WIDGET.
*/
class LYRS : public LAYER_WIDGET
void setActiveLayer( int aLayer, bool doLayerWidgetUpdate = true )
{
WinEDA_PcbFrame* myframe;
public:
LYRS( WinEDA_PcbFrame* aParent, wxWindow* aFocusOwner ) :
LAYER_WIDGET( aParent, aFocusOwner ),
myframe( aParent )
{
}
//-----<implement LAYER_WIDGET abstract callback functions>-----------
void OnLayerColorChange( int aLayer, int aColor );
bool OnLayerSelect( int aLayer );
void OnLayerVisible( int aLayer, bool isVisible, bool isFinal );
void OnRenderColorChange( int aId, int aColor );
void OnRenderEnable( int aId, bool isEnabled );
//-----</implement LAYER_WIDGET abstract callback functions>----------
};
LYRS* m_Layers; // established in constructor
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
if( doLayerWidgetUpdate )
syncLayerWidget();
}
/**
* Function getActiveLayer
* returns the active layer
*/
int getActiveLayer()
{
return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
}
/**
* Function syncLayerWidget
* updates the currently "selected" layer within the PCB_LAYER_WIDGET.
* The currently active layer is defined by the return value of getActiveLayer().
* <p>
* This function cannot be inline without including layer_widget.h in
* here and we do not want to do that.
*/
void syncLayerWidget();
/**
* Function syncLayerBox
* updates the currently "selected" layer within m_SelLayerBox
* The currently active layer, as defined by the return value of
* getActiveLayer(). And updates the colored icon in the toolbar.
*/
void syncLayerBox();
public:
WinEDAChoiceBox* m_SelLayerBox; // a combo box to display and
......@@ -95,19 +125,6 @@ public:
bool m_show_microwave_tools;
bool m_show_layer_manager_tools;
private:
DRC* m_drc; ///< the DRC controller, see drc.cpp
// we'll use lower case function names for private member functions.
void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu );
void createPopUpMenuForFootprints( MODULE* aModule, wxMenu* aPopMenu );
void createPopUpMenuForFpTexts( TEXTE_MODULE* aText, wxMenu* aPopMenu );
void createPopUpMenuForFpPads( D_PAD* aPad, wxMenu* aPopMenu );
void createPopupMenuForTracks( TRACK* aTrack, wxMenu* aPopMenu );
void createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu );
void createPopUpBlockMenu( wxMenu* menu );
void createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu );
public:
WinEDA_PcbFrame( wxWindow* father, const wxString& title,
......@@ -183,13 +200,6 @@ public:
/* toolbars update UI functions: */
/**
* Function UpdateToolbarLayerInfo
* updates the currently selected layer in the layer listbox and
* the colored icon in the toolbar.
*/
void UpdateToolbarLayerInfo();
void PrepareLayerIndicator();
/**
......@@ -206,14 +216,6 @@ public:
*/
void AuxiliaryToolBar_DesignRules_Update_UI();
/** Function SynchronizeLayersManager( )
* Must be called when info displayed in the layer manager Toolbar
* as been changed in the main window ( by hotkey or a tool option.
* Mainly when the active layer as changed.
* @param aFlag = flag giving the type of data (layers, checkboxes...)
*/
void SynchronizeLayersManager( int aFlag );
/* mouse functions events: */
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
......
......@@ -111,7 +111,6 @@ set(PCBNEW_SRCS
ioascii.cpp
print_board_functions.cpp
printout_controler.cpp
layer_panel_base.cpp
layer_widget.cpp
librairi.cpp
loadcmp.cpp
......@@ -243,7 +242,6 @@ endif(NOT MSVC)
# This one gets made only when testing.
add_executable(layer_widget_test WIN32 EXCLUDE_FROM_ALL
layer_panel_base.cpp
layer_widget.cpp
)
target_link_libraries(layer_widget_test common ${wxWidgets_LIBRARIES})
......@@ -36,7 +36,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
{
if( g_CurrentTrackList.GetCount() > 0 )
{
int previous_layer = ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
int previous_layer = getActiveLayer();
D( g_CurrentTrackList.VerifyListIntegrity(); )
......@@ -71,7 +71,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
// Correct active layer which could change if a via
// has been erased
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = previous_layer;
setActiveLayer( previous_layer );
UpdateStatusBar();
if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more,
......
......@@ -738,12 +738,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_SELECT_LAYER:
itmp = SelectLayer(
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer, -1, -1 );
itmp = SelectLayer( getActiveLayer(), -1, -1 );
if( itmp >= 0 )
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = itmp;
setActiveLayer( itmp );
DrawPanel->MouseToCursorSchema();
SynchronizeLayersManager( 1 );
break;
case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR:
......@@ -751,24 +749,17 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_SELECT_NO_CU_LAYER:
itmp = SelectLayer(
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer,
FIRST_NO_COPPER_LAYER,
-1 );
itmp = SelectLayer( getActiveLayer(), FIRST_NO_COPPER_LAYER, -1 );
if( itmp >= 0 )
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = itmp;
setActiveLayer( itmp );
DrawPanel->MouseToCursorSchema();
SynchronizeLayersManager( 1 );
break;
break;
case ID_POPUP_PCB_SELECT_CU_LAYER:
itmp = SelectLayer(
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer, -1,
LAST_COPPER_LAYER );
itmp = SelectLayer( getActiveLayer(), -1, LAST_COPPER_LAYER );
if( itmp >= 0 )
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = itmp;
SynchronizeLayersManager( 1 );
break;
setActiveLayer( itmp );
break;
case ID_POPUP_PCB_SELECT_LAYER_PAIR:
SelectLayerPair();
......@@ -777,9 +768,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_TOOLBARH_PCB_SELECT_LAYER:
itmp = m_SelLayerBox->GetChoice();
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer =
(int) ( (size_t) m_SelLayerBox->GetClientData( itmp ) );
SynchronizeLayersManager( 1 ); // Ensure Layer manager synchronization
setActiveLayer( (size_t) m_SelLayerBox->GetClientData( itmp ) );
if( DisplayOpt.ContrastModeDisplay )
DrawPanel->Refresh( true );
break;
......@@ -1076,10 +1065,10 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
{
int preslayer = GetScreen()->m_Active_Layer;
int curLayer = getActiveLayer();
// Check if the specified layer matches the present layer
if( layer == preslayer )
if( layer == curLayer )
return;
// Copper layers cannot be selected unconditionally; how many
......@@ -1087,7 +1076,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
if( IsValidCopperLayerIndex( layer ) )
{
// If only one copper layer is enabled, the only such layer
// that can be selected to is the "Copper" layer (so the
// that can be selected to is the "Back" layer (so the
// selection of any other copper layer is disregarded).
if( GetBoard()->m_BoardSettings->GetCopperLayerCount() < 2 )
{
......@@ -1129,9 +1118,10 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
// Want to set the routing layers so that it switches properly -
// see the implementation of Other_Layer_Route - the working
// layer is used to 'start' the via and set the layer masks appropriately.
GetScreen()->m_Route_Layer_TOP = preslayer;
GetScreen()->m_Route_Layer_TOP = curLayer;
GetScreen()->m_Route_Layer_BOTTOM = layer;
GetScreen()->m_Active_Layer = preslayer;
setActiveLayer( curLayer );
if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
{
......@@ -1140,7 +1130,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
}
// if the via was allowed by DRC, then the layer swap has already
// been done by Other_Layer_Route(). if via not allowed, then
// return now so assignment to m_Active_Layer below doesn't happen.
// return now so assignment to setActiveLayer() below doesn't happen.
return;
}
}
......@@ -1151,8 +1141,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
// and a non-copper layer, or vice-versa?
// ...
GetScreen()->m_Active_Layer = layer;
SynchronizeLayersManager( 1 ); // Ensure Layer manager synchronization
setActiveLayer( layer );
if( DisplayOpt.ContrastModeDisplay )
GetScreen()->SetRefreshReq();
......
......@@ -128,17 +128,14 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
if( aTrack == NULL )
{
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer !=
if( getActiveLayer() !=
((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP )
((PCB_SCREEN*)GetScreen())->m_Active_Layer =
((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP;
setActiveLayer( ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP );
else
((PCB_SCREEN*)GetScreen())->m_Active_Layer =
((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM;
setActiveLayer(((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM );
UpdateStatusBar();
SetToolbars();
SynchronizeLayersManager( 1 );
return true;
}
......@@ -185,39 +182,34 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
via->m_Width = GetBoard()->GetCurrentViaSize();
via->SetNet( g_HightLigth_NetCode );
via->m_Start = via->m_End = g_CurrentTrackSegment->m_End;
int old_layer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;
int old_layer = getActiveLayer();
// swap the layers.
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer !=
if( getActiveLayer() !=
((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP )
((PCB_SCREEN*)GetScreen())->m_Active_Layer =
((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP;
setActiveLayer(((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP );
else
((PCB_SCREEN*)GetScreen())->m_Active_Layer =
((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM;
setActiveLayer( ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM );
/* Adjust the via layer pair */
switch ( via->Shape() )
{
case VIA_BLIND_BURIED:
via->SetLayerPair( old_layer,
((PCB_SCREEN*)GetScreen())->m_Active_Layer );
via->SetLayerPair( old_layer, getActiveLayer() );
via->SetDrillValue( GetBoard()->GetCurrentViaDrill() );
break;
case VIA_MICROVIA: // from external to the near neighbor inner layer
if ( old_layer == LAYER_N_BACK )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_N_2;
setActiveLayer( LAYER_N_2 );
else if ( old_layer == LAYER_N_FRONT )
((PCB_SCREEN*)GetScreen())->m_Active_Layer =
GetBoard()->m_BoardSettings->GetCopperLayerCount() - 2;
setActiveLayer( GetBoard()->m_BoardSettings->GetCopperLayerCount() - 2 );
else if ( old_layer == LAYER_N_2 )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_N_BACK;
else if ( old_layer == GetBoard()->m_BoardSettings->GetCopperLayerCount() - 2 )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_N_FRONT;
setActiveLayer( LAYER_N_BACK );
else if ( old_layer == GetBoard()->m_BoardSettings->GetCopperLayerCount() - 2 );
setActiveLayer( LAYER_N_FRONT );
// else error
via->SetLayerPair( old_layer,
((PCB_SCREEN*)GetScreen())->m_Active_Layer );
via->SetLayerPair( old_layer, getActiveLayer() );
{
NETINFO_ITEM* net = GetBoard()->FindNet( via->GetNet() );
via->m_Width = net->GetMicroViaSize();
......@@ -236,7 +228,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
/* DRC fault: the Via cannot be placed here ... */
delete via;
((PCB_SCREEN*)GetScreen())->m_Active_Layer = old_layer;
setActiveLayer( old_layer );
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
......@@ -274,7 +266,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
*/
// set the layer to the new value
track->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer );
track->SetLayer( getActiveLayer() );
/* the start point is the via position and the end point is the cursor
* which also is on the via (will change when moving mouse)
......@@ -294,7 +286,6 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
UpdateStatusBar();
SetToolbars();
SynchronizeLayersManager( 1 );
return true;
}
......@@ -307,8 +298,7 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC )
{
TRACK* pt_segm;
int masquelayer =
g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer];
int masquelayer = (1 << getActiveLayer());
pt_segm = Locate_Pistes( GetBoard()->m_Track, masquelayer,
CURSEUR_OFF_GRILLE );
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 29 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "layer_panel_base.h"
#include <wx/settings.h>
///////////////////////////////////////////////////////////////////////////
LAYER_PANEL_BASE::LAYER_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style )
{
wxBoxSizer* boxSizer;
boxSizer = new wxBoxSizer( wxVERTICAL );
// m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_notebook = new wxAuiNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TOP );
// wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
wxFont font = m_notebook->GetFont();
font.SetPointSize( (font.GetPointSize() * 8) / 10 );
m_notebook->SetFont( font );
m_notebook->SetNormalFont( font );
m_notebook->SetSelectedFont( font );
m_notebook->SetMeasuringFont( font );
m_LayerPanel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxVERTICAL );
m_LayerScrolledWindow = new wxScrolledWindow( m_LayerPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
m_LayerScrolledWindow->SetScrollRate( 5, 5 );
m_LayersFlexGridSizer = new wxFlexGridSizer( 0, 4, 0, 1 );
m_LayersFlexGridSizer->SetFlexibleDirection( wxHORIZONTAL );
m_LayersFlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_LayerScrolledWindow->SetSizer( m_LayersFlexGridSizer );
m_LayerScrolledWindow->Layout();
m_LayersFlexGridSizer->Fit( m_LayerScrolledWindow );
bSizer3->Add( m_LayerScrolledWindow, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 2 );
m_LayerPanel->SetSizer( bSizer3 );
m_LayerPanel->Layout();
bSizer3->Fit( m_LayerPanel );
m_notebook->AddPage( m_LayerPanel, _("Layer"), true );
m_RenderingPanel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );
m_RenderScrolledWindow = new wxScrolledWindow( m_RenderingPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
m_RenderScrolledWindow->SetScrollRate( 5, 5 );
m_RenderFlexGridSizer = new wxFlexGridSizer( 0, 2, 0, 1 );
m_RenderFlexGridSizer->SetFlexibleDirection( wxHORIZONTAL );
m_RenderFlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_NONE );
m_RenderScrolledWindow->SetSizer( m_RenderFlexGridSizer );
m_RenderScrolledWindow->Layout();
m_RenderFlexGridSizer->Fit( m_RenderScrolledWindow );
bSizer4->Add( m_RenderScrolledWindow, 1, wxALL|wxEXPAND, 5 );
m_RenderingPanel->SetSizer( bSizer4 );
m_RenderingPanel->Layout();
bSizer4->Fit( m_RenderingPanel );
m_notebook->AddPage( m_RenderingPanel, _("Render"), false );
boxSizer->Add( m_notebook, 1, wxEXPAND | wxALL, 5 );
this->SetSizer( boxSizer );
this->Layout();
// Connect Events
m_LayerScrolledWindow->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL_BASE::OnLeftDownLayers ), NULL, this );
m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL_BASE::OnRightDownLayers ), NULL, this );
}
LAYER_PANEL_BASE::~LAYER_PANEL_BASE()
{
// Disconnect Events
m_LayerScrolledWindow->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL_BASE::OnLeftDownLayers ), NULL, this );
m_LayerScrolledWindow->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL_BASE::OnRightDownLayers ), NULL, this );
}
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 29 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __layer_panel_base__
#define __layer_panel_base__
#include <wx/intl.h>
#include <wx/sizer.h>
#include <wx/gdicmn.h>
#include <wx/scrolwin.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/panel.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
//#include <wx/notebook.h>
#include <wx/aui/auibook.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class LAYER_PANEL_BASE
///////////////////////////////////////////////////////////////////////////////
class LAYER_PANEL_BASE : public wxPanel
{
private:
protected:
// wxNotebook* m_notebook;
wxAuiNotebook* m_notebook;
wxPanel* m_LayerPanel;
wxScrolledWindow* m_LayerScrolledWindow;
wxFlexGridSizer* m_LayersFlexGridSizer;
wxPanel* m_RenderingPanel;
wxScrolledWindow* m_RenderScrolledWindow;
wxFlexGridSizer* m_RenderFlexGridSizer;
// Virtual event handlers, overide them in your derived class
virtual void OnLeftDownLayers( wxMouseEvent& event ){ event.Skip(); }
virtual void OnRightDownLayers( wxMouseEvent& event ){ event.Skip(); }
public:
LAYER_PANEL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 200,200 ), long style = wxTAB_TRAVERSAL );
~LAYER_PANEL_BASE();
};
#endif //__layer_panel_base__
This diff is collapsed.
......@@ -25,7 +25,26 @@
#ifndef LAYERWIDGET_H_
#define LAYERWIDGET_H_
#include "layer_panel_base.h"
#include <wx/intl.h>
#include <wx/wx.h>
#include <wx/statbmp.h>
#include <wx/string.h>
#include <wx/aui/auibook.h>
#include <wx/notebook.h>
#include <wx/sizer.h>
#include <wx/gdicmn.h>
#include <wx/scrolwin.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/panel.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#define LYR_COLUMN_COUNT 4 ///< Layer tab column count
#define RND_COLUMN_COUNT 2 ///< Rendering tab column count
/**
......@@ -44,7 +63,7 @@
* <p> void OnRenderColorChange( int id, int aColor );
* <p> void OnRenderEnable( int id, bool isEnabled );
*/
class LAYER_WIDGET : public LAYER_PANEL_BASE
class LAYER_WIDGET : public wxPanel
{
public:
/**
......@@ -74,14 +93,37 @@ public:
protected:
wxWindow* m_FocusOwner;
wxBitmap* m_BlankBitmap;
wxBitmap* m_RightArrowBitmap;
wxSize m_BitmapSize;
int m_CurrentRow; ///< selected row of layer list
wxAuiNotebook* m_notebook;
wxPanel* m_LayerPanel;
wxScrolledWindow* m_LayerScrolledWindow;
wxFlexGridSizer* m_LayersFlexGridSizer;
wxPanel* m_RenderingPanel;
wxScrolledWindow* m_RenderScrolledWindow;
wxFlexGridSizer* m_RenderFlexGridSizer;
wxWindow* m_FocusOwner;
wxBitmap* m_BlankBitmap;
wxBitmap* m_RightArrowBitmap;
wxSize m_BitmapSize;
int m_CurrentRow; ///< selected row of layer list
int m_PointSize;
static wxBitmap makeBitmap( int aColor );
/**
* Function encodeId
* is here to allow saving a layer index within a control as its wxControl id,
* but to do so in a way that all child wxControl ids within a wxWindow are unique,
* since this is required by Windows.
* @see getDecodedId()
*/
static int encodeId( int aColumn, int aId );
/**
* Function getDecodedId
* decodes \a aControlId to original un-encoded value.
*/
static int getDecodedId( int aControlId );
/**
* Function makeColorButton
......@@ -97,14 +139,6 @@ protected:
*/
void OnMiddleDownLayerColor( wxMouseEvent& event );
/**
* Function OnRightDownLayers
* puts up a popup menu for the layer panel.
*/
void OnRightDownLayers( wxMouseEvent& event );
void OnPopupSelection( wxCommandEvent& event );
/**
* Function OnLayerCheckBox
* handles the "is layer visible" checkbox and propogates the
......@@ -155,7 +189,9 @@ public:
* @param aFocusOwner is the window that should be sent the focus after
* every operation.
*/
LAYER_WIDGET( wxWindow* aParent, wxWindow* aFocusOwner );
LAYER_WIDGET( wxWindow* aParent, wxWindow* aFocusOwner, int aPointSize,
wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
/**
* Function GetBestSize
......
......@@ -196,7 +196,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( m_ID_current_state == ID_PCB_ARC_BUTT )
shape = S_ARC;
if( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer <= LAST_COPPER_LAYER )
if( getActiveLayer() <= LAST_COPPER_LAYER )
{
DisplayError( this, _( "Graphic not authorized on Copper layers" ) );
break;
......@@ -219,7 +219,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
}
case ID_TRACK_BUTT:
if( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer > LAST_COPPER_LAYER )
if( getActiveLayer() > LAST_COPPER_LAYER )
{
DisplayError( this, _( "Tracks on Copper layers only " ) );
break;
......@@ -328,7 +328,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break;
case ID_PCB_COTATION_BUTT:
if( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer <= LAST_COPPER_LAYER )
if( getActiveLayer() <= LAST_COPPER_LAYER )
{
DisplayError( this, _( "Cotation not authorized on Copper layers" ) );
break;
......
This diff is collapsed.
This diff is collapsed.
......@@ -68,7 +68,7 @@ void WinEDA_PcbFrame::PrepareLayerIndicator()
previous_Route_Layer_BOTTOM_color, previous_via_color;
/* get colors, and redraw bitmap button only on changes */
active_layer_color = g_DesignSettings.m_LayerColor[((PCB_SCREEN*)GetScreen())->m_Active_Layer];
active_layer_color = g_DesignSettings.m_LayerColor[ getActiveLayer() ];
if( previous_active_layer_color != active_layer_color )
{
previous_active_layer_color = active_layer_color;
......@@ -386,13 +386,13 @@ void WinEDA_PcbFrame::ReCreateOptToolbar()
g_DesignSettings.IsElementVisible( MOD_TEXT_INVISIBLE ));
m_OptionsToolBar->AddSeparator();
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR,
wxEmptyString,
wxBitmap( layers_manager_xpm ),
_(
"Show/hide the layers manager toolbar" ),
wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1,
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR,
wxEmptyString,
wxBitmap( layers_manager_xpm ),
_(
"Show/hide the layers manager toolbar" ),
wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1,
wxEmptyString,
wxBitmap( mw_toolbar_xpm ),
_( "Show/hide the toolbar for microwaves tools\n This is a experimental feature (under development)" ),
......@@ -664,20 +664,22 @@ an existing track use its width\notherwise, use current width setting" ),
}
void WinEDA_PcbFrame::UpdateToolbarLayerInfo()
void WinEDA_PcbFrame::syncLayerBox()
{
wxASSERT( m_SelLayerBox );
// Enable the display on the correct layer
// To avoid reentrancy ( Bug wxGTK Linux version? ), the selection is
// made where it is bad ( corrected on wxGTK 2.6.0 )
int count = m_SelLayerBox->GetCount();
// made only if it needs changing ( corrected on wxGTK 2.6.0 )
int count = m_SelLayerBox->GetCount();
int choice = m_SelLayerBox->GetChoice();
int layer = GetScreen()->m_Active_Layer;
int layer = getActiveLayer();
for( int listNdx=0; listNdx<count; ++listNdx )
{
if( (int) (size_t) m_SelLayerBox->GetClientData( listNdx ) == layer )
int clientData = (int) (size_t) m_SelLayerBox->GetClientData( listNdx );
if( clientData == layer )
{
if( listNdx != choice )
m_SelLayerBox->SetSelection( listNdx );
......@@ -748,11 +750,11 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
wxString msg = GetBoard()->GetLayerName( layer );
msg = AddHotkeyName( msg, s_Board_Editor_Hokeys_Descr,
HK_SwitchLayer[layer] );
/* we are using tabs in AddHotkeyName message.
* this is not handled by m_SelLayerBox.
* so we replace them by 3 spaces
*/
/* we are using tabs in AddHotkeyName message.
* this is not handled by m_SelLayerBox.
* so we replace them by 3 spaces
*/
msg.Replace( wxT( "\t"), wxT( " " ) );
m_SelLayerBox->Append( msg );
......@@ -766,7 +768,7 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
UpdateToolbarLayerInfo();
syncLayerBox();
return m_SelLayerBox;
}
......@@ -285,7 +285,8 @@ void WinEDA_PcbFrame::SetToolbars()
if( m_AuxiliaryToolBar )
AuxiliaryToolBar_Update_UI();
UpdateToolbarLayerInfo();
syncLayerBox();
PrepareLayerIndicator();
DisplayUnitsMsg();
#if defined(KICAD_AUIMANAGER)
......
......@@ -500,7 +500,7 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
{
int diag;
// Init zone params to reasonnable values
zone->SetLayer( GetScreen()->m_Active_Layer );
zone->SetLayer( getActiveLayer() );
// Prompt user for parameters:
DrawPanel->m_IgnoreMouseEvents = TRUE;
......@@ -535,12 +535,12 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
return 0;
// Switch active layer to the selectec zonz layer
GetScreen()->m_Active_Layer = g_Zone_Default_Setting.m_CurrentZone_Layer;
setActiveLayer( g_Zone_Default_Setting.m_CurrentZone_Layer );
}
else // Start a new contour: init zone params (net and layer) from an existing zone (add cutout or similar zone)
{
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = g_Zone_Default_Setting.m_CurrentZone_Layer =
s_CurrentZone->GetLayer();
g_Zone_Default_Setting.m_CurrentZone_Layer = s_CurrentZone->GetLayer();
setActiveLayer( s_CurrentZone->GetLayer() );
g_Zone_Default_Setting.ImportSetting( * s_CurrentZone);
}
......
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