Commit 9bcdef85 authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: canvas background color: all frame are now using the same parameter.

fix recent bug which prevent eeschema to save color preferences.
fix few other minor issues.
parent ea06ad14
...@@ -119,8 +119,8 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, ...@@ -119,8 +119,8 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
m_showOriginAxis = false; // true to draw the grid origin m_showOriginAxis = false; // true to draw the grid origin
m_cursorShape = 0; m_cursorShape = 0;
m_LastGridSizeId = 0; m_LastGridSizeId = 0;
m_DrawGrid = true; // hide/Show grid. default = show m_drawGrid = true; // hide/Show grid. default = show
m_GridColor = DARKGRAY; // Grid color m_gridColor = DARKGRAY; // Default grid color
m_showPageLimits = false; m_showPageLimits = false;
m_drawBgColor = BLACK; // the background color of the draw canvas: m_drawBgColor = BLACK; // the background color of the draw canvas:
// BLACK for Pcbnew, BLACK or WHITE for eeschema // BLACK for Pcbnew, BLACK or WHITE for eeschema
......
...@@ -425,13 +425,13 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER&, int ) ...@@ -425,13 +425,13 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER&, int )
bool DISPLAY_FOOTPRINTS_FRAME::IsGridVisible() const bool DISPLAY_FOOTPRINTS_FRAME::IsGridVisible() const
{ {
return m_DrawGrid; return m_drawGrid;
} }
void DISPLAY_FOOTPRINTS_FRAME::SetGridVisibility(bool aVisible) void DISPLAY_FOOTPRINTS_FRAME::SetGridVisibility(bool aVisible)
{ {
m_DrawGrid = aVisible; m_drawGrid = aVisible;
} }
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
static wxTreeItemId GetPrevItem( const wxTreeCtrl& tree, const wxTreeItemId& item ); static wxTreeItemId GetPrevItem( const wxTreeCtrl& tree, const wxTreeItemId& item );
static wxTreeItemId GetNextItem( const wxTreeCtrl& tree, const wxTreeItemId& item ); static wxTreeItemId GetNextItem( const wxTreeCtrl& tree, const wxTreeItemId& item );
DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( wxWindow* aParent, const wxString& aTitle, DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle,
COMPONENT_TREE_SEARCH_CONTAINER* aContainer, COMPONENT_TREE_SEARCH_CONTAINER* aContainer,
int aDeMorganConvert ) int aDeMorganConvert )
: DIALOG_CHOOSE_COMPONENT_BASE( aParent, wxID_ANY, aTitle ), : DIALOG_CHOOSE_COMPONENT_BASE( aParent, wxID_ANY, aTitle ),
...@@ -44,6 +44,7 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( wxWindow* aParent, const wxStr ...@@ -44,6 +44,7 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( wxWindow* aParent, const wxStr
m_external_browser_requested( false ), m_external_browser_requested( false ),
m_received_doubleclick_in_tree( false ) m_received_doubleclick_in_tree( false )
{ {
m_parent = aParent;
m_search_container->SetTree( m_libraryComponentTree ); m_search_container->SetTree( m_libraryComponentTree );
m_searchBox->SetFocus(); m_searchBox->SetFocus();
m_componentDetails->SetEditable( false ); m_componentDetails->SetEditable( false );
...@@ -260,7 +261,8 @@ void DIALOG_CHOOSE_COMPONENT::OnHandlePreviewRepaint( wxPaintEvent& aRepaintEven ...@@ -260,7 +261,8 @@ void DIALOG_CHOOSE_COMPONENT::OnHandlePreviewRepaint( wxPaintEvent& aRepaintEven
void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_PART* aComponent, int aUnit ) void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_PART* aComponent, int aUnit )
{ {
wxPaintDC dc( m_componentView ); wxPaintDC dc( m_componentView );
dc.SetBackground( *wxWHITE_BRUSH ); EDA_COLOR_T bgcolor = m_parent->GetDrawBgColor();
dc.SetBackground( bgcolor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
dc.Clear(); dc.Clear();
if( aComponent == NULL ) if( aComponent == NULL )
......
...@@ -30,20 +30,27 @@ class COMPONENT_TREE_SEARCH_CONTAINER; ...@@ -30,20 +30,27 @@ class COMPONENT_TREE_SEARCH_CONTAINER;
class LIB_ALIAS; class LIB_ALIAS;
class LIB_PART; class LIB_PART;
class wxTreeItemId; class wxTreeItemId;
class SCH_BASE_FRAME;
class DIALOG_CHOOSE_COMPONENT : public DIALOG_CHOOSE_COMPONENT_BASE class DIALOG_CHOOSE_COMPONENT : public DIALOG_CHOOSE_COMPONENT_BASE
{ {
SCH_BASE_FRAME* m_parent;
COMPONENT_TREE_SEARCH_CONTAINER* const m_search_container;
const int m_deMorganConvert;
bool m_external_browser_requested;
bool m_received_doubleclick_in_tree;
public: public:
/** /**
* Create dialog to choose component. * Create dialog to choose component.
* *
* @param aParent Parent window. * @param aParent a SCH_BASE_FRAME parent window.
* @param aTitle Dialog title. * @param aTitle Dialog title.
* @param aSearchContainer The tree selection search container. Needs to be pre-populated * @param aSearchContainer The tree selection search container. Needs to be pre-populated
* This dialog does not take over ownership of this object. * This dialog does not take over ownership of this object.
* @param aDeMorganConvert preferred deMorgan conversion (TODO: should happen in dialog) * @param aDeMorganConvert preferred deMorgan conversion (TODO: should happen in dialog)
*/ */
DIALOG_CHOOSE_COMPONENT( wxWindow* aParent, const wxString& aTitle, DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle,
COMPONENT_TREE_SEARCH_CONTAINER* aSearchContainer, COMPONENT_TREE_SEARCH_CONTAINER* aSearchContainer,
int aDeMorganConvert ); int aDeMorganConvert );
virtual ~DIALOG_CHOOSE_COMPONENT(); virtual ~DIALOG_CHOOSE_COMPONENT();
...@@ -80,11 +87,6 @@ private: ...@@ -80,11 +87,6 @@ private:
bool updateSelection(); bool updateSelection();
void selectIfValid( const wxTreeItemId& aTreeId ); void selectIfValid( const wxTreeItemId& aTreeId );
void renderPreview( LIB_PART* aComponent, int aUnit ); void renderPreview( LIB_PART* aComponent, int aUnit );
COMPONENT_TREE_SEARCH_CONTAINER* const m_search_container;
const int m_deMorganConvert;
bool m_external_browser_requested;
bool m_received_doubleclick_in_tree;
}; };
#endif /* DIALOG_CHOOSE_COMPONENT_H */ #endif /* DIALOG_CHOOSE_COMPONENT_H */
...@@ -3,14 +3,12 @@ ...@@ -3,14 +3,12 @@
*/ */
#include <fctsys.h> #include <fctsys.h>
#include <gr_basic.h>
#include <draw_frame.h> #include <draw_frame.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <general.h> #include <general.h>
#include <dialog_color_config.h> #include <dialog_color_config.h>
#include <layers_id_colors_and_visibility.h>
#define ID_COLOR_SETUP 1800 #define ID_COLOR_SETUP 1800
...@@ -86,7 +84,7 @@ static BUTTONINDEX buttonGroups[] = { ...@@ -86,7 +84,7 @@ static BUTTONINDEX buttonGroups[] = {
}; };
static EDA_COLOR_T currentColors[ NB_SCH_LAYERS ]; static EDA_COLOR_T currentColors[ LAYERSCH_ID_COUNT ];
IMPLEMENT_DYNAMIC_CLASS( DIALOG_COLOR_CONFIG, wxDialog ) IMPLEMENT_DYNAMIC_CLASS( DIALOG_COLOR_CONFIG, wxDialog )
...@@ -188,7 +186,7 @@ void DIALOG_COLOR_CONFIG::CreateControls() ...@@ -188,7 +186,7 @@ void DIALOG_COLOR_CONFIG::CreateControls()
iconDC.SelectObject( bitmap ); iconDC.SelectObject( bitmap );
EDA_COLOR_T color = GetLayerColor( LayerNumber( buttons->m_Layer ) ); EDA_COLOR_T color = GetLayerColor( LAYERSCH_ID( buttons->m_Layer ) );
currentColors[ buttons->m_Layer ] = color; currentColors[ buttons->m_Layer ] = color;
iconDC.SetPen( *wxBLACK_PEN ); iconDC.SetPen( *wxBLACK_PEN );
...@@ -235,6 +233,9 @@ void DIALOG_COLOR_CONFIG::CreateControls() ...@@ -235,6 +233,9 @@ void DIALOG_COLOR_CONFIG::CreateControls()
m_SelBgColor->SetSelection( ( m_parent->GetDrawBgColor() == BLACK ) ? 1 : 0 ); m_SelBgColor->SetSelection( ( m_parent->GetDrawBgColor() == BLACK ) ? 1 : 0 );
m_columnBoxSizer->Add( m_SelBgColor, 1, wxGROW | wxRIGHT | wxTOP | wxBOTTOM, 5 ); m_columnBoxSizer->Add( m_SelBgColor, 1, wxGROW | wxRIGHT | wxTOP | wxBOTTOM, 5 );
currentColors[ LAYER_BACKGROUND ] = m_parent->GetDrawBgColor();
// Provide a line to separate all of the controls added so far from the // Provide a line to separate all of the controls added so far from the
// "OK", "Cancel", and "Apply" buttons (which will be added after that // "OK", "Cancel", and "Apply" buttons (which will be added after that
// line). // line).
...@@ -317,24 +318,27 @@ void DIALOG_COLOR_CONFIG::SetColor( wxCommandEvent& event ) ...@@ -317,24 +318,27 @@ void DIALOG_COLOR_CONFIG::SetColor( wxCommandEvent& event )
bool DIALOG_COLOR_CONFIG::UpdateColorsSettings() bool DIALOG_COLOR_CONFIG::UpdateColorsSettings()
{ {
// Update color of background // Update color of background
if( m_SelBgColor->GetSelection() == 0 ) EDA_COLOR_T bgcolor = WHITE;
m_parent->SetDrawBgColor( WHITE );
else if( m_SelBgColor->GetSelection() > 0 )
m_parent->SetDrawBgColor( BLACK ); bgcolor = BLACK;
m_parent->SetDrawBgColor( bgcolor );
currentColors[ LAYER_BACKGROUND ] = bgcolor;
bool warning = false; bool warning = false;
for( LayerNumber ii = LAYER_WIRE; ii < NB_SCH_LAYERS; ++ii ) for( LAYERSCH_ID clyr = LAYER_WIRE; clyr < LAYERSCH_ID_COUNT; ++clyr )
{ {
SetLayerColor( currentColors[ ii ], ii ); SetLayerColor( currentColors[ clyr ], clyr );
if( m_parent->GetDrawBgColor() == GetLayerColor( ii ) ) if( bgcolor == GetLayerColor( clyr ) && clyr != LAYER_BACKGROUND )
warning = true; warning = true;
} }
m_parent->SetGridColor( GetLayerColor( LAYER_GRID ) ); m_parent->SetGridColor( GetLayerColor( LAYER_GRID ) );
if( m_parent->GetDrawBgColor() == GetLayerColor( LAYER_GRID ) ) if( bgcolor == GetLayerColor( LAYER_GRID ) )
warning = true; warning = true;
return warning; return warning;
...@@ -348,7 +352,8 @@ void DIALOG_COLOR_CONFIG::OnOkClick( wxCommandEvent& event ) ...@@ -348,7 +352,8 @@ void DIALOG_COLOR_CONFIG::OnOkClick( wxCommandEvent& event )
// Prompt the user if an item has the same color as the background // Prompt the user if an item has the same color as the background
// because this item cannot be seen: // because this item cannot be seen:
if( warning ) if( warning )
wxMessageBox( _("Warning:\nSome items have the same color as the background\nand they will not be seen on screen") ); wxMessageBox( _("Warning:\nSome items have the same color as the background\n"
"and they will not be seen on screen") );
m_parent->GetCanvas()->Refresh(); m_parent->GetCanvas()->Refresh();
......
...@@ -70,7 +70,7 @@ static struct IFACE : public KIFACE_I ...@@ -70,7 +70,7 @@ static struct IFACE : public KIFACE_I
bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ); bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits );
void OnKifaceEnd( PGM_BASE* aProgram ); void OnKifaceEnd();
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 )
{ {
...@@ -154,15 +154,15 @@ PGM_BASE& Pgm() ...@@ -154,15 +154,15 @@ PGM_BASE& Pgm()
} }
static EDA_COLOR_T s_layerColor[NB_SCH_LAYERS]; static EDA_COLOR_T s_layerColor[LAYERSCH_ID_COUNT];
EDA_COLOR_T GetLayerColor( LayerNumber aLayer ) EDA_COLOR_T GetLayerColor( LAYERSCH_ID aLayer )
{ {
wxASSERT( unsigned( aLayer ) < DIM( s_layerColor ) ); wxASSERT( unsigned( aLayer ) < DIM( s_layerColor ) );
return s_layerColor[aLayer]; return s_layerColor[aLayer];
} }
void SetLayerColor( EDA_COLOR_T aColor, int aLayer ) void SetLayerColor( EDA_COLOR_T aColor, LAYERSCH_ID aLayer )
{ {
wxASSERT( unsigned( aLayer ) < DIM( s_layerColor ) ); wxASSERT( unsigned( aLayer ) < DIM( s_layerColor ) );
s_layerColor[aLayer] = aColor; s_layerColor[aLayer] = aColor;
...@@ -178,7 +178,8 @@ static PARAM_CFG_ARRAY& cfg_params() ...@@ -178,7 +178,8 @@ static PARAM_CFG_ARRAY& cfg_params()
// These are KIFACE specific, they need to be loaded once when the // These are KIFACE specific, they need to be loaded once when the
// eeschema KIFACE comes in. // eeschema KIFACE comes in.
#define CLR(x, y, z) ca.push_back( new PARAM_CFG_SETCOLOR( true, wxT( x ), &s_layerColor[y], z )); #define CLR(x, y, z)\
ca.push_back( new PARAM_CFG_SETCOLOR( true, wxT( x ), &s_layerColor[y], z ) );
CLR( "ColorWireEx", LAYER_WIRE, GREEN ) CLR( "ColorWireEx", LAYER_WIRE, GREEN )
CLR( "ColorBusEx", LAYER_BUS, BLUE ) CLR( "ColorBusEx", LAYER_BUS, BLUE )
...@@ -204,6 +205,7 @@ static PARAM_CFG_ARRAY& cfg_params() ...@@ -204,6 +205,7 @@ static PARAM_CFG_ARRAY& cfg_params()
CLR( "ColorErcWEx", LAYER_ERC_WARN, GREEN ) CLR( "ColorErcWEx", LAYER_ERC_WARN, GREEN )
CLR( "ColorErcEEx", LAYER_ERC_ERR, RED ) CLR( "ColorErcEEx", LAYER_ERC_ERR, RED )
CLR( "ColorGridEx", LAYER_GRID, DARKGRAY ) CLR( "ColorGridEx", LAYER_GRID, DARKGRAY )
CLR( "ColorBgCanvasEx", LAYER_BACKGROUND, WHITE )
} }
return ca; return ca;
...@@ -220,9 +222,11 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) ...@@ -220,9 +222,11 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
// Give a default colour for all layers // Give a default colour for all layers
// (actual color will be initialized by config) // (actual color will be initialized by config)
for( int ii = 0; ii < NB_SCH_LAYERS; ii++ ) for( LAYERSCH_ID ii = LAYER_FIRST; ii < LAYERSCH_ID_COUNT; ++ii )
SetLayerColor( DARKGRAY, ii ); SetLayerColor( DARKGRAY, ii );
SetLayerColor( WHITE, LAYER_BACKGROUND );
// Must be called before creating the main frame in order to // Must be called before creating the main frame in order to
// display the real hotkeys in menus or tool tips // display the real hotkeys in menus or tool tips
ReadHotkeyConfig( wxT("SchematicFrame"), s_Eeschema_Hokeys_Descr ); ReadHotkeyConfig( wxT("SchematicFrame"), s_Eeschema_Hokeys_Descr );
...@@ -233,10 +237,9 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) ...@@ -233,10 +237,9 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
} }
void IFACE::OnKifaceEnd( PGM_BASE* aProgram ) void IFACE::OnKifaceEnd()
{ {
wxConfigSaveSetups( KifaceSettings(), cfg_params() ); wxConfigSaveSetups( KifaceSettings(), cfg_params() );
end_common(); end_common();
} }
...@@ -307,6 +307,7 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event ) ...@@ -307,6 +307,7 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
{ {
wxArrayString units; wxArrayString units;
GRIDS grid_list = GetScreen()->GetGrids(); GRIDS grid_list = GetScreen()->GetGrids();
bool saveProjectConfig = false;
DIALOG_EESCHEMA_OPTIONS dlg( this ); DIALOG_EESCHEMA_OPTIONS dlg( this );
...@@ -356,19 +357,33 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event ) ...@@ -356,19 +357,33 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
int sep, firstId; int sep, firstId;
dlg.GetRefIdSeparator( sep, firstId); dlg.GetRefIdSeparator( sep, firstId);
if( sep != (int)LIB_PART::GetSubpartIdSeparator() || if( sep != (int)LIB_PART::GetSubpartIdSeparator() ||
firstId != (int)LIB_PART::GetSubpartFirstId() ) firstId != (int)LIB_PART::GetSubpartFirstId() )
{ {
LIB_PART::SetSubpartIdNotation( sep, firstId ); LIB_PART::SetSubpartIdNotation( sep, firstId );
SaveProjectSettings( true ); saveProjectConfig = true;
} }
SetDefaultBusThickness( dlg.GetBusWidth() ); SetDefaultBusThickness( dlg.GetBusWidth() );
SetDefaultLineThickness( dlg.GetLineWidth() ); SetDefaultLineThickness( dlg.GetLineWidth() );
if( dlg.GetTextSize() != GetDefaultTextSize() )
{
SetDefaultTextSize( dlg.GetTextSize() ); SetDefaultTextSize( dlg.GetTextSize() );
saveProjectConfig = true;
}
if( g_RepeatStep.x != dlg.GetRepeatHorizontal() ||
g_RepeatStep.y != dlg.GetRepeatVertical() ||
g_RepeatDeltaLabel != dlg.GetRepeatLabel() )
{
g_RepeatStep.x = dlg.GetRepeatHorizontal(); g_RepeatStep.x = dlg.GetRepeatHorizontal();
g_RepeatStep.y = dlg.GetRepeatVertical(); g_RepeatStep.y = dlg.GetRepeatVertical();
g_RepeatDeltaLabel = dlg.GetRepeatLabel(); g_RepeatDeltaLabel = dlg.GetRepeatLabel();
saveProjectConfig = true;
}
SetAutoSaveInterval( dlg.GetAutoSaveInterval() * 60 ); SetAutoSaveInterval( dlg.GetAutoSaveInterval() * 60 );
SetGridVisibility( dlg.GetShowGrid() ); SetGridVisibility( dlg.GetShowGrid() );
m_showAllPins = dlg.GetShowHiddenPins(); m_showAllPins = dlg.GetShowHiddenPins();
...@@ -402,6 +417,9 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event ) ...@@ -402,6 +417,9 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
SaveSettings( config() ); // save values shared by eeschema applications. SaveSettings( config() ); // save values shared by eeschema applications.
if( saveProjectConfig )
SaveProjectSettings( true );
m_canvas->Refresh( true ); m_canvas->Refresh( true );
} }
...@@ -534,7 +552,6 @@ static const wxChar SimulatorCommandEntry[] = wxT( "SimCmdLine" ); ...@@ -534,7 +552,6 @@ static const wxChar SimulatorCommandEntry[] = wxT( "SimCmdLine" );
// Library editor wxConfig entry names. // Library editor wxConfig entry names.
static const wxChar lastLibExportPathEntry[] = wxT( "LastLibraryExportPath" ); static const wxChar lastLibExportPathEntry[] = wxT( "LastLibraryExportPath" );
static const wxChar lastLibImportPathEntry[] = wxT( "LastLibraryImportPath" ); static const wxChar lastLibImportPathEntry[] = wxT( "LastLibraryImportPath" );
static const wxChar libeditdrawBgColorEntry[] = wxT( "LibeditBgColor" );
static const wxChar defaultPinNumSizeEntry[] = wxT( "LibeditPinNumSize" ); static const wxChar defaultPinNumSizeEntry[] = wxT( "LibeditPinNumSize" );
static const wxChar defaultPinNameSizeEntry[] = wxT( "LibeditPinNameSize" ); static const wxChar defaultPinNameSizeEntry[] = wxT( "LibeditPinNameSize" );
static const wxChar DefaultPinLengthEntry[] = wxT( "DefaultPinLength" ); static const wxChar DefaultPinLengthEntry[] = wxT( "DefaultPinLength" );
...@@ -549,9 +566,6 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings() ...@@ -549,9 +566,6 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings()
&m_showPageLimits, true ) ); &m_showPageLimits, true ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Units" ), m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Units" ),
(int*)&g_UserUnit, MILLIMETRES ) ); (int*)&g_UserUnit, MILLIMETRES ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "SchEditorBgColor" ),
&m_drawBgColor,
WHITE ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PrintMonochrome" ), m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PrintMonochrome" ),
&m_printMonochrome, true ) ); &m_printMonochrome, true ) );
...@@ -570,7 +584,8 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) ...@@ -570,7 +584,8 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
wxConfigLoadSetups( aCfg, GetConfigurationSettings() ); wxConfigLoadSetups( aCfg, GetConfigurationSettings() );
m_GridColor = GetLayerColor( LAYER_GRID ); SetGridColor( GetLayerColor( LAYER_GRID ) );
SetDrawBgColor( GetLayerColor( LAYER_BACKGROUND ) );
SetDefaultBusThickness( aCfg->Read( DefaultBusWidthEntry, DEFAULTBUSTHICKNESS ) ); SetDefaultBusThickness( aCfg->Read( DefaultBusWidthEntry, DEFAULTBUSTHICKNESS ) );
SetDefaultLineThickness( aCfg->Read( DefaultDrawLineWidthEntry, DEFAULTDRAWLINETHICKNESS ) ); SetDefaultLineThickness( aCfg->Read( DefaultDrawLineWidthEntry, DEFAULTDRAWLINETHICKNESS ) );
...@@ -732,8 +747,8 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) ...@@ -732,8 +747,8 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
wxConfigPathChanger cpc( aCfg, m_configPath ); wxConfigPathChanger cpc( aCfg, m_configPath );
EDA_COLOR_T itmp = ColorByName( aCfg->Read( libeditdrawBgColorEntry, wxT("WHITE") ) ); SetGridColor( GetLayerColor( LAYER_GRID ) );
SetDrawBgColor( itmp ); SetDrawBgColor( GetLayerColor( LAYER_BACKGROUND ) );
wxString pro_dir = Prj().GetProjectFullName(); wxString pro_dir = Prj().GetProjectFullName();
...@@ -753,7 +768,6 @@ void LIB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg ) ...@@ -753,7 +768,6 @@ void LIB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
wxConfigPathChanger cpc( aCfg, m_configPath ); wxConfigPathChanger cpc( aCfg, m_configPath );
aCfg->Write( libeditdrawBgColorEntry, ColorGetName( GetDrawBgColor() ) );
aCfg->Write( lastLibExportPathEntry, m_lastLibExportPath ); aCfg->Write( lastLibExportPathEntry, m_lastLibExportPath );
aCfg->Write( lastLibImportPathEntry, m_lastLibImportPath ); aCfg->Write( lastLibImportPathEntry, m_lastLibImportPath );
aCfg->Write( DefaultPinLengthEntry, (long) GetDefaultPinLength() ); aCfg->Write( DefaultPinLengthEntry, (long) GetDefaultPinLength() );
......
...@@ -36,8 +36,12 @@ class SCH_SHEET; ...@@ -36,8 +36,12 @@ class SCH_SHEET;
#define GR_DEFAULT_DRAWMODE GR_COPY #define GR_DEFAULT_DRAWMODE GR_COPY
// this enum is for color management // this enum is for color management
// Using here "LAYER" in name is due to historical reasons.
// Eeschema does not actually use layers. It just uses "LAYER_XX" as identifier
// mainly for item color
typedef enum { typedef enum {
LAYER_WIRE, LAYER_FIRST,
LAYER_WIRE = LAYER_FIRST,
LAYER_BUS, LAYER_BUS,
LAYER_JUNCTION, LAYER_JUNCTION,
LAYER_LOCLABEL, LAYER_LOCLABEL,
...@@ -61,12 +65,13 @@ typedef enum { ...@@ -61,12 +65,13 @@ typedef enum {
LAYER_ERC_ERR, LAYER_ERC_ERR,
LAYER_DEVICE_BACKGROUND, LAYER_DEVICE_BACKGROUND,
LAYER_GRID, LAYER_GRID,
NB_SCH_LAYERS LAYER_BACKGROUND,
} LayerNumber; LAYERSCH_ID_COUNT
} LAYERSCH_ID;
inline LayerNumber operator++( LayerNumber& a ) inline LAYERSCH_ID operator++( LAYERSCH_ID& a )
{ {
a = LayerNumber( int( a ) + 1 ); a = LAYERSCH_ID( int( a ) + 1 );
return a; return a;
} }
...@@ -104,7 +109,8 @@ void SetDefaultTextSize( int aSize ); ...@@ -104,7 +109,8 @@ void SetDefaultTextSize( int aSize );
int GetDefaultBusThickness(); int GetDefaultBusThickness();
void SetDefaultBusThickness( int aThickness ); void SetDefaultBusThickness( int aThickness );
EDA_COLOR_T GetLayerColor( LayerNumber aLayer ); EDA_COLOR_T GetLayerColor( LAYERSCH_ID aLayer );
void SetLayerColor( EDA_COLOR_T aColor, LAYERSCH_ID aLayer );
// Color to draw selected items // Color to draw selected items
EDA_COLOR_T GetItemSelectedColor(); EDA_COLOR_T GetItemSelectedColor();
...@@ -112,6 +118,4 @@ EDA_COLOR_T GetItemSelectedColor(); ...@@ -112,6 +118,4 @@ EDA_COLOR_T GetItemSelectedColor();
// Color to draw items flagged invisible, in libedit (they are invisible in Eeschema // Color to draw items flagged invisible, in libedit (they are invisible in Eeschema
EDA_COLOR_T GetInvisibleItemColor(); EDA_COLOR_T GetInvisibleItemColor();
void SetLayerColor( EDA_COLOR_T aColor, int aLayer );
#endif // _GENERAL_H_ #endif // _GENERAL_H_
...@@ -35,7 +35,6 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, ...@@ -35,7 +35,6 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition,
aSize, aStyle, aFrameName ) aSize, aStyle, aFrameName )
{ {
SetDrawBgColor( WHITE ); // the background color of the draw canvas, BLACK or WHITE
} }
...@@ -47,6 +46,18 @@ void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event ) ...@@ -47,6 +46,18 @@ void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
viewlibFrame->Raise(); viewlibFrame->Raise();
} }
// Virtual from EDA_DRAW_FRAME
EDA_COLOR_T SCH_BASE_FRAME::GetDrawBgColor() const
{
return GetLayerColor( LAYER_BACKGROUND );
}
void SCH_BASE_FRAME::SetDrawBgColor( EDA_COLOR_T aColor)
{
m_drawBgColor= aColor;
SetLayerColor( aColor, LAYER_BACKGROUND );
}
SCH_SCREEN* SCH_BASE_FRAME::GetScreen() const SCH_SCREEN* SCH_BASE_FRAME::GetScreen() const
{ {
......
...@@ -504,7 +504,7 @@ bool SCH_SCREEN::Save( FILE* aFile ) const ...@@ -504,7 +504,7 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
} }
// This section is not used, but written for file compatibility // This section is not used, but written for file compatibility
if( fprintf( aFile, "EELAYER %d %d\n", NB_SCH_LAYERS, 0 ) < 0 if( fprintf( aFile, "EELAYER %d %d\n", LAYERSCH_ID_COUNT, 0 ) < 0
|| fprintf( aFile, "EELAYER END\n" ) < 0 ) || fprintf( aFile, "EELAYER END\n" ) < 0 )
return false; return false;
......
...@@ -507,13 +507,13 @@ void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg ) ...@@ -507,13 +507,13 @@ void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
{ {
EDA_DRAW_FRAME::LoadSettings( aCfg ); EDA_DRAW_FRAME::LoadSettings( aCfg );
wxConfigPathChanger cpc( aCfg, m_configPath ); SetGridColor( GetLayerColor( LAYER_GRID ) );
SetDrawBgColor( GetLayerColor( LAYER_BACKGROUND ) );
EDA_COLOR_T itmp = ColorByName( aCfg->Read( LIBVIEW_BGCOLOR, wxT( "WHITE" ) ) ); wxConfigPathChanger cpc( aCfg, m_configPath );
SetDrawBgColor( itmp );
aCfg->Read( LIBLIST_WIDTH_KEY, &m_libListWidth, 100 ); aCfg->Read( LIBLIST_WIDTH_KEY, &m_libListWidth, 150 );
aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 100 ); aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 150 );
// Set parameters to a reasonable value. // Set parameters to a reasonable value.
if( m_libListWidth > m_FrameSize.x/2 ) if( m_libListWidth > m_FrameSize.x/2 )
...@@ -538,7 +538,6 @@ void LIB_VIEW_FRAME::SaveSettings( wxConfigBase* aCfg ) ...@@ -538,7 +538,6 @@ void LIB_VIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
m_cmpListWidth = m_cmpList->GetSize().x; m_cmpListWidth = m_cmpList->GetSize().x;
aCfg->Write( CMPLIST_WIDTH_KEY, m_cmpListWidth ); aCfg->Write( CMPLIST_WIDTH_KEY, m_cmpListWidth );
aCfg->Write( LIBVIEW_BGCOLOR, ColorGetName( GetDrawBgColor() ) );
} }
......
...@@ -60,9 +60,9 @@ protected: ...@@ -60,9 +60,9 @@ protected:
int m_LastGridSizeId; // the command id offset (>= 0) of the last selected grid int m_LastGridSizeId; // the command id offset (>= 0) of the last selected grid
// 0 is for the grid corresponding to // 0 is for the grid corresponding to
// a wxCommand ID = ID_POPUP_GRID_LEVEL_1000. // a wxCommand ID = ID_POPUP_GRID_LEVEL_1000.
bool m_DrawGrid; // hide/Show grid bool m_drawGrid; // hide/Show grid
bool m_showPageLimits; ///< true to display the page limits bool m_showPageLimits; ///< true to display the page limits
EDA_COLOR_T m_GridColor; // Grid color EDA_COLOR_T m_gridColor; // Grid color
EDA_COLOR_T m_drawBgColor; ///< the background color of the draw canvas EDA_COLOR_T m_drawBgColor; ///< the background color of the draw canvas
///< BLACK for Pcbnew, BLACK or WHITE for eeschema ///< BLACK for Pcbnew, BLACK or WHITE for eeschema
...@@ -258,8 +258,16 @@ public: ...@@ -258,8 +258,16 @@ public:
virtual void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) = 0; virtual void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) = 0;
// the background color of the draw canvas: // the background color of the draw canvas:
EDA_COLOR_T GetDrawBgColor() const { return m_drawBgColor; } // Virtual because some frames can have a specific way to get/set the bg color
void SetDrawBgColor( EDA_COLOR_T aColor) { m_drawBgColor= aColor ; } /**
* @return the EDA_COLOR_T for the canvas background
*/
virtual EDA_COLOR_T GetDrawBgColor() const { return m_drawBgColor; }
/**
* @param aColor: the EDA_COLOR_T for the canvas background
*/
virtual void SetDrawBgColor( EDA_COLOR_T aColor) { m_drawBgColor= aColor ; }
int GetCursorShape() const { return m_cursorShape; } int GetCursorShape() const { return m_cursorShape; }
...@@ -355,7 +363,7 @@ public: ...@@ -355,7 +363,7 @@ public:
*/ */
virtual bool IsGridVisible() const virtual bool IsGridVisible() const
{ {
return m_DrawGrid; return m_drawGrid;
} }
/** /**
...@@ -365,7 +373,7 @@ public: ...@@ -365,7 +373,7 @@ public:
*/ */
virtual void SetGridVisibility( bool aVisible ) virtual void SetGridVisibility( bool aVisible )
{ {
m_DrawGrid = aVisible; m_drawGrid = aVisible;
} }
/** /**
...@@ -374,7 +382,7 @@ public: ...@@ -374,7 +382,7 @@ public:
*/ */
virtual EDA_COLOR_T GetGridColor() const virtual EDA_COLOR_T GetGridColor() const
{ {
return m_GridColor; return m_gridColor;
} }
/** /**
...@@ -383,7 +391,7 @@ public: ...@@ -383,7 +391,7 @@ public:
*/ */
virtual void SetGridColor( EDA_COLOR_T aColor ) virtual void SetGridColor( EDA_COLOR_T aColor )
{ {
m_GridColor = aColor; m_gridColor = aColor;
} }
/** /**
......
...@@ -68,6 +68,11 @@ public: ...@@ -68,6 +68,11 @@ public:
} }
void SetGridOrigin( const wxPoint& aPoint ) {} // overload EDA_DRAW_FRAME void SetGridOrigin( const wxPoint& aPoint ) {} // overload EDA_DRAW_FRAME
// Virtual from EDA_DRAW_FRAME
// the background color of the draw canvas:
EDA_COLOR_T GetDrawBgColor() const;
void SetDrawBgColor( EDA_COLOR_T aColor);
const TITLE_BLOCK& GetTitleBlock() const; // overload EDA_DRAW_FRAME const TITLE_BLOCK& GetTitleBlock() const; // overload EDA_DRAW_FRAME
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload EDA_DRAW_FRAME void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload EDA_DRAW_FRAME
......
...@@ -115,7 +115,7 @@ public: ...@@ -115,7 +115,7 @@ public:
class SCH_ITEM : public EDA_ITEM class SCH_ITEM : public EDA_ITEM
{ {
protected: protected:
LayerNumber m_Layer; LAYERSCH_ID m_Layer;
EDA_ITEMS m_connections; ///< List of items connected to this item. EDA_ITEMS m_connections; ///< List of items connected to this item.
public: public:
...@@ -145,14 +145,14 @@ public: ...@@ -145,14 +145,14 @@ public:
* Function GetLayer * Function GetLayer
* returns the layer this item is on. * returns the layer this item is on.
*/ */
LayerNumber GetLayer() const { return m_Layer; } LAYERSCH_ID GetLayer() const { return m_Layer; }
/** /**
* Function SetLayer * Function SetLayer
* sets the layer this item is on. * sets the layer this item is on.
* @param aLayer The layer number. * @param aLayer The layer number.
*/ */
void SetLayer( LayerNumber aLayer ) { m_Layer = aLayer; } void SetLayer( LAYERSCH_ID aLayer ) { m_Layer = aLayer; }
/** /**
* Function GetPenSize virtual pure * Function GetPenSize virtual pure
......
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