Commit 7c99a242 authored by jean-pierre charras's avatar jean-pierre charras

Remove 2 global variables: g_DrawBgColor and g_ShowPageLimits.

They are now member of EDA_DRAW_FRAME.
This change could fix Bug #1330781 (Background color change in Eeschema affects background color in Pcbnew)
Show page limits has meaning only for the schematic editor,  the board editor and the page layout editor.
Draw background color selection exists only in eeschema and  page layout editor.
In pcbnew, only a black background is allowed.
A side effect is now the user should set the background color in schematic editor, and the library editor (2 different options).
The default is still the white color.
parent 94d78047
......@@ -117,6 +117,9 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
m_LastGridSizeId = 0;
m_DrawGrid = true; // hide/Show grid. default = show
m_GridColor = DARKGRAY; // Grid color
m_showPageLimits = false;
m_drawBgColor = BLACK; // the background color of the draw canvas:
// BLACK for Pcbnew, BLACK or WHITeEfor eeschema
m_snapToGrid = true;
m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight();
m_movingCursorWithKeyboard = false;
......
......@@ -103,7 +103,7 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
m_scrollIncrementX = std::min( size.x / 8, 10 );
m_scrollIncrementY = std::min( size.y / 8, 10 );
SetBackgroundColour( MakeColour( g_DrawBgColor ) );
SetBackgroundColour( MakeColour( parent->GetDrawBgColor() ) );
#if KICAD_USE_BUFFERED_DC || KICAD_USE_BUFFERED_PAINTDC
SetBackgroundStyle( wxBG_STYLE_CUSTOM );
......@@ -528,9 +528,11 @@ void EDA_DRAW_PANEL::EraseScreen( wxDC* DC )
{
GRSetDrawMode( DC, GR_COPY );
EDA_COLOR_T bgColor = GetParent()->GetDrawBgColor();
GRSFilledRect( NULL, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
0, g_DrawBgColor, g_DrawBgColor );
0, bgColor, bgColor );
// Set to one (1) to draw bounding box validate bounding box calculation.
#if DEBUG_SHOW_CLIP_RECT
......@@ -583,10 +585,12 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )
if( Screen == NULL )
return;
if( ( g_DrawBgColor != WHITE ) && ( g_DrawBgColor != BLACK ) )
g_DrawBgColor = BLACK;
EDA_COLOR_T bgColor = GetParent()->GetDrawBgColor();
if( ( bgColor != WHITE ) && ( bgColor != BLACK ) )
bgColor = BLACK;
if( g_DrawBgColor == WHITE )
if( bgColor == WHITE )
{
g_XorMode = GR_NXOR;
g_GhostColor = BLACK;
......@@ -599,7 +603,7 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )
GRResetPenAndBrush( DC );
DC->SetBackground( g_DrawBgColor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
DC->SetBackground( bgColor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
DC->SetBackgroundMode( wxSOLID );
if( erasebg )
......
......@@ -31,12 +31,6 @@
#include <pgm_base.h>
#include <common.h>
#include <gr_basic.h>
static const wxChar showPageLimitsKey[] = wxT( "ShowPageLimits" );
static const wxChar backgroundColorKey[] = wxT( "BackgroundColor" );
/// Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings.
/// A non-member function so it an be moved easily, plus it's nobody's business.
......@@ -97,24 +91,7 @@ static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
bool KIFACE_I::start_common( int aCtlBits )
{
m_start_flags = aCtlBits;
m_bm.Init();
m_bm.m_config->Read( showPageLimitsKey, &g_ShowPageLimits );
// FIXME OSX Mountain Lion (10.8)
// Seems that Read doesn't found anything and ColorFromInt
// Asserts - I'm unable to reproduce on 10.7
int draw_bg_color = BLACK; // Default for all apps but Eeschema
if( m_id == KIWAY::FACE_SCH )
draw_bg_color = WHITE; // Default for Eeschema
m_bm.m_config->Read( backgroundColorKey, &draw_bg_color );
g_DrawBgColor = ColorFromInt( draw_bg_color );
setSearchPaths( &m_bm.m_search, m_id );
return true;
......@@ -123,14 +100,6 @@ bool KIFACE_I::start_common( int aCtlBits )
void KIFACE_I::end_common()
{
if( m_bm.m_config )
{
// Save common preferences; the background still uses the old legacy
// color numbers, not the new names
m_bm.m_config->Write( showPageLimitsKey, g_ShowPageLimits );
m_bm.m_config->Write( backgroundColorKey, int( g_DrawBgColor ) );
}
m_bm.End();
}
......@@ -83,12 +83,12 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi
wxSize pageSize = pageInfo.GetSizeMils();
// if not printing, draw the page limits:
if( !aScreen->m_IsPrinting && g_ShowPageLimits )
if( !aScreen->m_IsPrinting && m_showPageLimits )
{
GRSetDrawMode( aDC, GR_COPY );
GRRect( m_canvas->GetClipBox(), aDC, 0, 0,
pageSize.x * aScalar, pageSize.y * aScalar, aLineWidth,
g_DrawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY );
m_drawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY );
}
TITLE_BLOCK t_block = GetTitleBlock();
......
......@@ -294,8 +294,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
// SetFootprintLibTablePath();
*/
g_DrawBgColor = BLACK;
try
{
// The global table is not related to a specific project. All projects
......
......@@ -232,7 +232,7 @@ void DIALOG_COLOR_CONFIG::CreateControls()
m_SelBgColor = new wxRadioBox( this, wxID_ANY, _( "Background Color" ),
wxDefaultPosition, wxDefaultSize,
m_SelBgColorStrings, 1, wxRA_SPECIFY_COLS );
m_SelBgColor->SetSelection( ( g_DrawBgColor == BLACK ) ? 1 : 0 );
m_SelBgColor->SetSelection( ( m_parent->GetDrawBgColor() == BLACK ) ? 1 : 0 );
m_columnBoxSizer->Add( m_SelBgColor, 1, wxGROW | wxRIGHT | wxTOP | wxBOTTOM, 5 );
// Provide a line to separate all of the controls added so far from the
......@@ -318,9 +318,9 @@ bool DIALOG_COLOR_CONFIG::UpdateColorsSettings()
{
// Update color of background
if( m_SelBgColor->GetSelection() == 0 )
g_DrawBgColor = WHITE;
m_parent->SetDrawBgColor( WHITE );
else
g_DrawBgColor = BLACK;
m_parent->SetDrawBgColor( BLACK );
bool warning = false;
......@@ -328,13 +328,13 @@ bool DIALOG_COLOR_CONFIG::UpdateColorsSettings()
{
SetLayerColor( currentColors[ ii ], ii );
if( g_DrawBgColor == GetLayerColor( ii ) )
if( m_parent->GetDrawBgColor() == GetLayerColor( ii ) )
warning = true;
}
m_parent->SetGridColor( GetLayerColor( LAYER_GRID ) );
if( g_DrawBgColor == GetLayerColor( LAYER_GRID ) )
if( m_parent->GetDrawBgColor() == GetLayerColor( LAYER_GRID ) )
warning = true;
return warning;
......
......@@ -9,7 +9,7 @@
#include <dialog_lib_edit_pin.h>
DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( wxWindow* parent, LIB_PIN* aPin ) :
DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( EDA_DRAW_FRAME* parent, LIB_PIN* aPin ) :
DIALOG_LIB_EDIT_PIN_BASE( parent )
{
// Creates a dummy pin to show on a panel, inside this dialog:
......@@ -20,7 +20,7 @@ DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( wxWindow* parent, LIB_PIN* aPin ) :
m_dummyPin->SetParent( NULL );
m_dummyPin->ClearFlags();
m_panelShowPin->SetBackgroundColour( MakeColour( g_DrawBgColor ) );
m_panelShowPin->SetBackgroundColour( MakeColour( parent->GetDrawBgColor() ) );
// Set tab order
m_textPadName->MoveAfterInTabOrder(m_textPinName);
......
......@@ -17,7 +17,7 @@ class DIALOG_LIB_EDIT_PIN : public DIALOG_LIB_EDIT_PIN_BASE
public:
/** Constructor */
DIALOG_LIB_EDIT_PIN( wxWindow* parent, LIB_PIN* aPin );
DIALOG_LIB_EDIT_PIN( EDA_DRAW_FRAME* parent, LIB_PIN* aPin );
~DIALOG_LIB_EDIT_PIN();
void OnCloseDialog( wxCloseEvent& event );
......
......@@ -63,7 +63,7 @@ public:
m_Parent = aParent;
}
SCH_EDIT_FRAME* GetSchFrameParent() { return m_Parent->GetParent(); }
bool OnPrintPage( int page );
bool HasPage( int page );
bool OnBeginDocument( int startPage, int endPage );
......@@ -425,7 +425,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
aScreen->m_IsPrinting = true;
EDA_COLOR_T bg_color = g_DrawBgColor;
EDA_COLOR_T bg_color = GetSchFrameParent()->GetDrawBgColor();
aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE );
......@@ -433,7 +433,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(),
IU_PER_MILS, aScreen->GetFileName() );
g_DrawBgColor = bg_color;
GetSchFrameParent()->SetDrawBgColor( bg_color );
aScreen->m_IsPrinting = false;
panel->SetClipBox( oldClipBox );
......
......@@ -76,14 +76,14 @@ void SetDefaultBusThickness( int aThickness)
/// Default size for text (not only labels)
static int s_defaultTextSize;
int GetDefaultTextSize()
{
int GetDefaultTextSize()
{
return s_defaultTextSize;
}
void SetDefaultTextSize( int aTextSize )
{
s_defaultTextSize = aTextSize;
void SetDefaultTextSize( int aTextSize )
{
s_defaultTextSize = aTextSize;
}
/*
......@@ -311,7 +311,7 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
dlg.SetMiddleButtonPanLimited( m_canvas->GetMiddleButtonPanLimited() );
dlg.SetEnableAutoPan( m_canvas->GetEnableAutoPan() );
dlg.SetEnableHVBusOrientation( GetForceHVLines() );
dlg.SetShowPageLimits( g_ShowPageLimits );
dlg.SetShowPageLimits( m_showPageLimits );
dlg.Layout();
dlg.Fit();
dlg.SetMinSize( dlg.GetSize() );
......@@ -357,7 +357,7 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
m_canvas->SetMiddleButtonPanLimited( dlg.GetMiddleButtonPanLimited() );
m_canvas->SetEnableAutoPan( dlg.GetEnableAutoPan() );
SetForceHVLines( dlg.GetEnableHVBusOrientation() );
g_ShowPageLimits = dlg.GetShowPageLimits();
m_showPageLimits = dlg.GetShowPageLimits();
wxString templateFieldName;
......@@ -534,8 +534,14 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings( void )
if( !m_configSettings.empty() )
return m_configSettings;
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowPageLimits" ),
&m_showPageLimits, true ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Units" ),
(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_SETCOLOR( true, wxT( "ColorWireEx" ),
&s_layerColor[LAYER_WIRE],
GREEN ) );
......
......@@ -295,6 +295,7 @@ const wxChar* LIB_EDIT_FRAME::GetLibEditFrameName()
return LIB_EDIT_FRAME_NAME;
}
static const wxChar drawBgColorKey[] = wxT( "LibeditBgColor" );
void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
{
......@@ -312,6 +313,9 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
wxConfigPathChanger cpc( aCfg, m_configPath );
EDA_COLOR_T itmp = ColorByName( aCfg->Read( drawBgColorKey, wxT("WHITE") ) );
SetDrawBgColor( itmp );
m_lastLibExportPath = aCfg->Read( lastLibExportPathEntry, ::wxGetCwd() );
m_lastLibImportPath = aCfg->Read( lastLibImportPathEntry, ::wxGetCwd() );
......@@ -335,6 +339,7 @@ void LIB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
wxConfigPathChanger cpc( aCfg, m_configPath );
aCfg->Write( drawBgColorKey, ColorGetName( GetDrawBgColor() ) );
aCfg->Write( lastLibExportPathEntry, m_lastLibExportPath );
aCfg->Write( lastLibImportPathEntry, m_lastLibImportPath );
}
......
......@@ -28,7 +28,6 @@
#include <base_units.h>
#include <kiway.h>
SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
FRAME_T aWindowType, const wxString& aTitle,
const wxPoint& aPosition, const wxSize& aSize, long aStyle,
......@@ -36,6 +35,7 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition,
aSize, aStyle, aFrameName )
{
SetDrawBgColor( WHITE ); // the background color of the draw canvas, BLACK or WHITE
}
......
......@@ -191,6 +191,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_previewSize = wxDefaultSize;
m_printMonochrome = true;
m_printSheetReference = true;
SetShowPageLimits( true );
m_HotkeysZoomAndGridList = s_Schematic_Hokeys_Descr;
m_dlgFindReplace = NULL;
m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
......
......@@ -496,6 +496,11 @@ void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event )
#define LIBLIST_WIDTH_KEY wxT( "ViewLiblistWidth" )
#define CMPLIST_WIDTH_KEY wxT( "ViewCmplistWidth" )
// Currently, the library viewer has no dialog to change the background color
// of the draw canvas. Therefore the background color is here just
// in case of this option is added to some library viewer config dialog
#define LIBVIEW_BGCOLOR wxT( "LibviewBgColor" )
void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
{
......@@ -503,6 +508,9 @@ void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
wxConfigPathChanger cpc( aCfg, m_configPath );
EDA_COLOR_T itmp = ColorByName( aCfg->Read( LIBVIEW_BGCOLOR, wxT( "WHITE" ) ) );
SetDrawBgColor( itmp );
aCfg->Read( LIBLIST_WIDTH_KEY, &m_libListWidth, 100 );
aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 100 );
......@@ -529,6 +537,7 @@ void LIB_VIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
m_cmpListWidth = m_cmpList->GetSize().x;
aCfg->Write( CMPLIST_WIDTH_KEY, m_cmpListWidth );
aCfg->Write( LIBVIEW_BGCOLOR, ColorGetName( GetDrawBgColor() ) );
}
......
......@@ -138,6 +138,8 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
const wxPoint& aOffset, bool aPrintBlackAndWhite )
{
GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent();
// Because Images can be negative (i.e with background filled in color) items are drawn
// graphic layer per graphic layer, after the background is filled
// to a temporary bitmap
......@@ -145,7 +147,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
// If aDrawMode = UNSPECIFIED_DRAWMODE, items are drawn to the main screen, and therefore
// artifacts can happen with negative items or negative images
wxColour bgColor = MakeColour( g_DrawBgColor );
wxColour bgColor = MakeColour( gerbFrame->GetDrawBgColor() );
#if wxCHECK_VERSION( 3, 0, 0 )
wxBrush bgBrush( bgColor, wxBRUSHSTYLE_SOLID );
......@@ -153,8 +155,6 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
wxBrush bgBrush( bgColor, wxSOLID );
#endif
GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent();
int bitmapWidth, bitmapHeight;
wxDC* plotDC = aDC;
......@@ -236,7 +236,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
// Force black and white draw mode on request:
if( aPrintBlackAndWhite )
gerbFrame->SetLayerColor( layer, g_DrawBgColor == BLACK ? WHITE : BLACK );
gerbFrame->SetLayerColor( layer, gerbFrame->GetDrawBgColor() == BLACK ? WHITE : BLACK );
if( useBufferBitmap )
{
......
......@@ -44,7 +44,6 @@
// Colors for layers and items
COLORS_DESIGN_SETTINGS g_ColorsSettings;
extern EDA_COLOR_T g_DrawBgColor;
int g_Default_GERBER_Format;
......@@ -146,8 +145,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
// display the real hotkeys in menus or tool tips
ReadHotkeyConfig( wxT("GerberFrame"), s_Gerbview_Hokeys_Descr );
g_DrawBgColor = BLACK;
return true;
}
......
......@@ -656,7 +656,7 @@ EDA_COLOR_T GERBVIEW_FRAME::GetNegativeItemsColor() const
if( IsElementVisible( NEGATIVE_OBJECTS_VISIBLE ) )
return GetVisibleElementColor( NEGATIVE_OBJECTS_VISIBLE );
else
return g_DrawBgColor;
return GetDrawBgColor();
}
......
......@@ -385,8 +385,6 @@ private:
void setMargins();
};
extern bool g_ShowPageLimits; ///< true to display the page limits
extern EDA_UNITS_T g_UserUnit; ///< display units
/// Draw color for moving objects.
......
......@@ -56,7 +56,10 @@ protected:
// 0 is for the grid corresponding to
// a wxCommand ID = ID_POPUP_GRID_LEVEL_1000.
bool m_DrawGrid; // hide/Show grid
bool m_showPageLimits; ///< true to display the page limits
EDA_COLOR_T m_GridColor; // Grid color
EDA_COLOR_T m_drawBgColor; ///< the background color of the draw canvas
///< BLACK for Pcbnew, BLACK or WHITE for eeschema
/// The area to draw on.
EDA_DRAW_PANEL* m_canvas;
......@@ -235,6 +238,10 @@ public:
virtual const TITLE_BLOCK& GetTitleBlock() const = 0;
virtual void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) = 0;
// the background color of the draw canvas:
EDA_COLOR_T GetDrawBgColor() const { return m_drawBgColor; }
void SetDrawBgColor( EDA_COLOR_T aColor) { m_drawBgColor= aColor ; }
int GetCursorShape() const { return m_cursorShape; }
void SetCursorShape( int aCursorShape ) { m_cursorShape = aCursorShape; }
......@@ -242,6 +249,8 @@ public:
bool GetShowBorderAndTitleBlock() const { return m_showBorderAndTitleBlock; }
void SetShowBorderAndTitleBlock( bool aShow ) { m_showBorderAndTitleBlock = aShow; }
bool ShowPageLimits() const { return m_showPageLimits; }
void SetShowPageLimits( bool aShow ) { m_showPageLimits = aShow; }
EDA_DRAW_PANEL* GetCanvas() { return m_canvas; }
......
......@@ -88,7 +88,6 @@ typedef int wxPenStyle;
extern GR_DRAWMODE g_XorMode;
extern EDA_COLOR_T g_DrawBgColor;
typedef enum {
......@@ -260,7 +259,7 @@ void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC,std::vector<wxPoint>& aLines,
int aWidth, EDA_COLOR_T aColor );
void GRDrawAnchor( EDA_RECT* aClipBox, wxDC *aDC, int x, int y, int aSize,
void GRDrawAnchor( EDA_RECT* aClipBox, wxDC *aDC, int x, int y, int aSize,
EDA_COLOR_T aColor );
#endif /* define GR_BASIC */
......@@ -486,10 +486,11 @@ public:
}
/**
* Function ScriptingToolbarPane
* Change *this to a scripting toolbar for KiCad.
* Function ScriptingConsolePane
* Change *this to a python scripting console pane for KiCad.
* Used in Pcbnew
*/
EDA_PANEINFO& ScriptingToolbarPane()
EDA_PANEINFO& ScriptingConsolePane()
{
CloseButton( false );
Floatable( true );
......
......@@ -186,13 +186,13 @@ void PLEDITOR_PRINTOUT::DrawPage( int aPageNum )
GRForceBlackPen( true );
screen->m_IsPrinting = true;
EDA_COLOR_T bg_color = g_DrawBgColor;
g_DrawBgColor = WHITE;
EDA_COLOR_T bg_color = m_parent->GetDrawBgColor();
m_parent->SetDrawBgColor( WHITE );
screen->m_ScreenNumber = aPageNum;
m_parent->DrawWorkSheet( dc, screen, 0, IU_PER_MILS, wxEmptyString );
g_DrawBgColor = bg_color;
m_parent->SetDrawBgColor( bg_color );
screen->m_IsPrinting = false;
panel->SetClipBox( oldClipBox );
......
......@@ -117,7 +117,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
AddMenuItem( preferencesMenu,
ID_MENU_SWITCH_BGCOLOR,
g_DrawBgColor == WHITE ?
GetDrawBgColor() == WHITE ?
_( "&BackGround Black" ) : _( "&BackGround White" ),
wxEmptyString, KiBitmap( palette_xpm ) );
......
......@@ -28,7 +28,6 @@
*/
#include <fctsys.h>
//#include <pgm_base.h>
#include <kiface_i.h>
#include <confirm.h>
#include <gestfich.h>
......@@ -41,8 +40,6 @@
#include <wx/file.h>
#include <wx/snglinst.h>
extern EDA_COLOR_T g_DrawBgColor;
namespace PGE {
......@@ -128,8 +125,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
ReadHotkeyConfig( wxT("PlEditorFrame"), s_PlEditor_Hokeys_Descr );
g_UserUnit = MILLIMETRES;
g_DrawBgColor = WHITE;
g_ShowPageLimits = true;
return true;
}
......@@ -156,8 +151,6 @@ bool MYFACE::OnKifaceStart( PGM_BASE* aProgram )
}
g_UserUnit = MILLIMETRES;
g_DrawBgColor = WHITE;
g_ShowPageLimits = true;
// read current setup and reopen last directory if no filename to open in
// command line
......
......@@ -51,13 +51,13 @@ void PL_EDITOR_FRAME::Process_Config( wxCommandEvent& event )
switch( id )
{
case ID_MENU_SWITCH_BGCOLOR:
if( g_DrawBgColor == WHITE )
g_DrawBgColor = BLACK;
if( GetDrawBgColor() == WHITE )
SetDrawBgColor( BLACK );
else
g_DrawBgColor = WHITE;
SetDrawBgColor( WHITE );
GetMenuBar()->SetLabel( ID_MENU_SWITCH_BGCOLOR,
g_DrawBgColor == WHITE ?
GetDrawBgColor() == WHITE ?
_( "&BackGround Black" ) :
_( "&BackGround White" ) );
m_canvas->Refresh();
......
......@@ -59,11 +59,13 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
{
m_FrameName = PL_EDITOR_FRAME_NAME;
m_showAxis = false; // true to show X and Y axis on screen
m_showAxis = false; // true to show X and Y axis on screen
m_showGridAxis = true;
m_showBorderAndTitleBlock = true; // true for reference drawings.
m_showBorderAndTitleBlock = true; // true for reference drawings.
m_HotkeysZoomAndGridList = s_PlEditor_Hokeys_Descr;
m_originSelectChoice = 0;
SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK)
SetShowPageLimits( true );
m_designTreeWidth = 150;
m_propertiesFrameWidth = 200;
......@@ -295,17 +297,21 @@ double PL_EDITOR_FRAME::BestZoom()
return bestzoom;
}
#define DESIGN_TREE_WIDTH_KEY wxT("DesignTreeWidth")
#define PROPERTIES_FRAME_WIDTH_KEY wxT("PropertiesFrameWidth")
#define CORNER_ORIGIN_CHOICE_KEY wxT("CornerOriginChoice")
static const wxChar designTreeWidthKey[] = wxT("DesignTreeWidth");
static const wxChar propertiesFrameWidthKey[] = wxT("PropertiesFrameWidth");
static const wxChar cornerOriginChoiceKey[] = wxT("CornerOriginChoice");
static const wxChar blackBgColorKey[] = wxT( "BlackBgColor" );
void PL_EDITOR_FRAME::LoadSettings( wxConfigBase* aCfg )
{
EDA_DRAW_FRAME::LoadSettings( aCfg );
aCfg->Read( DESIGN_TREE_WIDTH_KEY, &m_designTreeWidth, 100);
aCfg->Read( PROPERTIES_FRAME_WIDTH_KEY, &m_propertiesFrameWidth, 150);
aCfg->Read( CORNER_ORIGIN_CHOICE_KEY, &m_originSelectChoice );
aCfg->Read( designTreeWidthKey, &m_designTreeWidth, 100);
aCfg->Read( propertiesFrameWidthKey, &m_propertiesFrameWidth, 150);
aCfg->Read( cornerOriginChoiceKey, &m_originSelectChoice );
bool tmp;
aCfg->Read( blackBgColorKey, &tmp, false );
SetDrawBgColor( tmp ? BLACK : WHITE );
}
......@@ -316,9 +322,10 @@ void PL_EDITOR_FRAME::SaveSettings( wxConfigBase* aCfg )
m_designTreeWidth = m_treePagelayout->GetSize().x;
m_propertiesFrameWidth = m_propertiesPagelayout->GetSize().x;
aCfg->Write( DESIGN_TREE_WIDTH_KEY, m_designTreeWidth);
aCfg->Write( PROPERTIES_FRAME_WIDTH_KEY, m_propertiesFrameWidth);
aCfg->Write( CORNER_ORIGIN_CHOICE_KEY, m_originSelectChoice );
aCfg->Write( designTreeWidthKey, m_designTreeWidth);
aCfg->Write( propertiesFrameWidthKey, m_propertiesFrameWidth);
aCfg->Write( cornerOriginChoiceKey, m_originSelectChoice );
aCfg->Write( blackBgColorKey, GetDrawBgColor() == BLACK );
// was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
wxConfigSaveSetups( aCfg, GetConfigurationSettings() );
......@@ -517,7 +524,7 @@ void PL_EDITOR_FRAME::RedrawActiveWindow( wxDC* aDC, bool aEraseBg )
WORKSHEET_DATAITEM* selecteditem = GetSelectedItem();
// the color to draw selected items
if( g_DrawBgColor == WHITE )
if( GetDrawBgColor() == WHITE )
WORKSHEET_DATAITEM::m_SelectedColor = DARKCYAN;
else
WORKSHEET_DATAITEM::m_SelectedColor = YELLOW;
......
......@@ -416,7 +416,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
{
blackpenstate = GetGRForceBlackPenState();
GRForceBlackPen( false );
aDrawInfo.m_HoleColor = g_DrawBgColor;
aDrawInfo.m_HoleColor = WHITE;
}
if( aDrawInfo.m_DrawMode != GR_XOR )
......
......@@ -840,7 +840,7 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
{
blackpenstate = GetGRForceBlackPenState();
GRForceBlackPen( false );
color = g_DrawBgColor;
color = WHITE;
}
else
{
......
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_general_options.cpp
// Author: jean-pierre Charras
/////////////////////////////////////////////////////////////////////////////
/**
* @file pcbnew/dialogs/dialog_general_options.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* functions relatives to the dialog opened from the main menu :
Prefernces/display
Preferences/display
*/
#include <fctsys.h>
#include <class_drawpanel.h>
#include <confirm.h>
......@@ -84,7 +109,7 @@ void DIALOG_DISPLAY_OPTIONS::init()
else
m_OptDisplayVias->SetSelection( 0 );
m_Show_Page_Limits->SetSelection( g_ShowPageLimits ? 0 : 1 );
m_Show_Page_Limits->SetSelection( m_Parent->ShowPageLimits() ? 0 : 1 );
m_OptDisplayViaHole->SetSelection( DisplayOpt.m_DisplayViaMode );
m_OptDisplayModTexts->SetSelection( DisplayOpt.DisplayModText );
......@@ -108,9 +133,9 @@ void DIALOG_DISPLAY_OPTIONS::OnCancelClick( wxCommandEvent& event )
void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event)
{
if ( m_Show_Page_Limits->GetSelection() == 0 )
g_ShowPageLimits = true;
m_Parent->SetShowPageLimits( true );
else
g_ShowPageLimits = false;
m_Parent->SetShowPageLimits( false );
if ( m_OptDisplayTracks->GetSelection() == 1 )
DisplayOpt.DisplayPcbTrackFill = true;
......
......@@ -436,8 +436,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
SetFootprintLibTablePath();
*/
g_DrawBgColor = BLACK;
try
{
// The global table is not related to a specific project. All projects
......
......@@ -240,25 +240,6 @@ bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName )
// was: wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
Prj().ConfigLoad( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP_PCB, GetProjectFileParameters(), false );
// Dick 5-Feb-2012: I don't agree with this, the BOARD contents should dictate
// what is visible or not, even initially. And since PCB_EDIT_FRAME projects settings
// have no control over what is visible (see PCB_EDIT_FRAME::GetProjectFileParameters())
// this is recklessly turning on things the user may not want to see.
#if 0
/* Reset the items visibility flag when loading a new configuration because it could
* create SERIOUS mistakes for the user if board items are not visible after loading
* a board. Grid and ratsnest can be left to their previous state.
*/
bool showGrid = IsElementVisible( GRID_VISIBLE );
bool showRats = IsElementVisible( RATSNEST_VISIBLE );
SetVisibleAlls();
SetElementVisibility( GRID_VISIBLE, showGrid );
SetElementVisibility( RATSNEST_VISIBLE, showRats );
#endif
Prj().ElemClear( PROJECT::ELEM_FPTBL ); // Force it to be reloaded on demand.
// Load the page layout decr file, from the filename stored in
......@@ -315,6 +296,8 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
if( !m_configSettings.empty() )
return m_configSettings;
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowPageLimits" ),
&m_showPageLimits, true ) );
// Units used in dialogs and toolbars
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Units" ),
(int*)&g_UserUnit, MILLIMETRES ) );
......
......@@ -302,7 +302,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
if( drillShapeOpt != PRINT_PARAMETERS::NO_DRILL_SHAPE )
{
TRACK * track = Pcb->m_Track;
EDA_COLOR_T color = g_DrawBgColor;
EDA_COLOR_T color = GetDrawBgColor();
bool blackpenstate = GetGRForceBlackPenState();
GRForceBlackPen( false );
GRSetDrawMode( aDC, GR_COPY );
......
......@@ -299,9 +299,9 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) );
screen->m_IsPrinting = true;
EDA_COLOR_T bg_color = g_DrawBgColor;
EDA_COLOR_T bg_color = m_Parent->GetDrawBgColor();
// Print frame reference, if reqquested, before
// Print frame reference, if requested, before
if( m_PrintParams.m_Print_Black_and_White )
GRForceBlackPen( true );
......@@ -351,7 +351,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
devLeft, devTop, devRight, devBottom );
#endif
g_DrawBgColor = WHITE;
m_Parent->SetDrawBgColor( WHITE );
/* when printing in color mode, we use the graphic OR mode that gives the same look as
* the screen but because the background is white when printing, we must use a trick:
......@@ -380,7 +380,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror,
&m_PrintParams );
g_DrawBgColor = bg_color;
m_Parent->SetDrawBgColor( bg_color );
screen->m_IsPrinting = false;
panel->SetClipBox( tmp );
GRForceBlackPen( false );
......
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