From 7c99a242cf9054d56d218a8be962650bb37ccb25 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 20 Jun 2014 13:13:04 +0200 Subject: [PATCH] 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. --- common/draw_frame.cpp | 3 ++ common/draw_panel.cpp | 16 +++++--- common/kiface_i.cpp | 31 -------------- common/worksheet.cpp | 4 +- cvpcb/cvpcb.cpp | 2 - eeschema/dialogs/dialog_color_config.cpp | 10 ++--- eeschema/dialogs/dialog_lib_edit_pin.cpp | 4 +- eeschema/dialogs/dialog_lib_edit_pin.h | 2 +- .../dialogs/dialog_print_using_printer.cpp | 6 +-- eeschema/eeschema_config.cpp | 20 +++++---- eeschema/libeditframe.cpp | 5 +++ eeschema/sch_base_frame.cpp | 2 +- eeschema/schframe.cpp | 1 + eeschema/viewlib_frame.cpp | 9 ++++ gerbview/draw_gerber_screen.cpp | 8 ++-- gerbview/gerbview.cpp | 3 -- gerbview/gerbview_frame.cpp | 2 +- include/common.h | 2 - include/draw_frame.h | 9 ++++ include/gr_basic.h | 3 +- include/wxstruct.h | 7 ++-- .../dialogs/dialogs_for_printing.cpp | 6 +-- pagelayout_editor/menubar.cpp | 2 +- pagelayout_editor/pl_editor.cpp | 7 ---- pagelayout_editor/pl_editor_config.cpp | 8 ++-- pagelayout_editor/pl_editor_frame.cpp | 31 ++++++++------ pcbnew/class_pad_draw_functions.cpp | 2 +- pcbnew/class_track.cpp | 2 +- pcbnew/dialogs/dialog_display_options.cpp | 41 +++++++++++++++---- pcbnew/pcbnew.cpp | 2 - pcbnew/pcbnew_config.cpp | 21 +--------- pcbnew/print_board_functions.cpp | 2 +- pcbnew/printout_controler.cpp | 8 ++-- 33 files changed, 143 insertions(+), 138 deletions(-) diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp index 1300ff9718..b94c2c67b5 100644 --- a/common/draw_frame.cpp +++ b/common/draw_frame.cpp @@ -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; diff --git a/common/draw_panel.cpp b/common/draw_panel.cpp index dedd4f6059..73864ad2db 100644 --- a/common/draw_panel.cpp +++ b/common/draw_panel.cpp @@ -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( g_DrawBgColor == WHITE ) + if( ( bgColor != WHITE ) && ( bgColor != BLACK ) ) + bgColor = BLACK; + + 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 ) diff --git a/common/kiface_i.cpp b/common/kiface_i.cpp index f7772a1e35..53d5f3233e 100644 --- a/common/kiface_i.cpp +++ b/common/kiface_i.cpp @@ -31,12 +31,6 @@ #include #include -#include - - -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(); } diff --git a/common/worksheet.cpp b/common/worksheet.cpp index 215b2dd4b7..eb1ab917d4 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -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(); diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index 78fbebf619..317ef82631 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -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 diff --git a/eeschema/dialogs/dialog_color_config.cpp b/eeschema/dialogs/dialog_color_config.cpp index 1ed7ae72dc..d256a6a7cd 100644 --- a/eeschema/dialogs/dialog_color_config.cpp +++ b/eeschema/dialogs/dialog_color_config.cpp @@ -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; diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp index 7f3307ad83..f23ea1bc3b 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp @@ -9,7 +9,7 @@ #include -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); diff --git a/eeschema/dialogs/dialog_lib_edit_pin.h b/eeschema/dialogs/dialog_lib_edit_pin.h index 6c6e15e894..b9169fcacb 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin.h +++ b/eeschema/dialogs/dialog_lib_edit_pin.h @@ -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 ); diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index 15fbdc8055..198289d50c 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -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 ); diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 8ece081b1b..7f1506328b 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -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 ) ); diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 379c5bb0cd..fd3597d3ac 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -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 ); } diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index ca6ac2f9ed..411697ad4c 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -28,7 +28,6 @@ #include #include - 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 } diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 4a46f3047a..abc89e3cf8 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -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 ); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index e8b368c118..0cfbc55a17 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -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() ) ); } diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp index 86add4d293..e8efa84f68 100644 --- a/gerbview/draw_gerber_screen.cpp +++ b/gerbview/draw_gerber_screen.cpp @@ -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 ) { diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index fbdc0288bc..f7147d20bb 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -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; } diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 0674be6c1e..09abe01df2 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -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(); } diff --git a/include/common.h b/include/common.h index a647f80d47..fcf7c94177 100644 --- a/include/common.h +++ b/include/common.h @@ -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. diff --git a/include/draw_frame.h b/include/draw_frame.h index 44023def51..a7ee30cd0b 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -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; } diff --git a/include/gr_basic.h b/include/gr_basic.h index 18cf7692da..d994548e76 100644 --- a/include/gr_basic.h +++ b/include/gr_basic.h @@ -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& 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 */ diff --git a/include/wxstruct.h b/include/wxstruct.h index daffa56d67..5b6215838a 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -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 ); diff --git a/pagelayout_editor/dialogs/dialogs_for_printing.cpp b/pagelayout_editor/dialogs/dialogs_for_printing.cpp index 707b43a2ca..5ed93f4917 100644 --- a/pagelayout_editor/dialogs/dialogs_for_printing.cpp +++ b/pagelayout_editor/dialogs/dialogs_for_printing.cpp @@ -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 ); diff --git a/pagelayout_editor/menubar.cpp b/pagelayout_editor/menubar.cpp index 7544f66dd8..3276af3eb7 100644 --- a/pagelayout_editor/menubar.cpp +++ b/pagelayout_editor/menubar.cpp @@ -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 ) ); diff --git a/pagelayout_editor/pl_editor.cpp b/pagelayout_editor/pl_editor.cpp index 012720abc9..2b341364d5 100644 --- a/pagelayout_editor/pl_editor.cpp +++ b/pagelayout_editor/pl_editor.cpp @@ -28,7 +28,6 @@ */ #include -//#include #include #include #include @@ -41,8 +40,6 @@ #include #include -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 diff --git a/pagelayout_editor/pl_editor_config.cpp b/pagelayout_editor/pl_editor_config.cpp index 1586a5ca2b..98140d10ab 100644 --- a/pagelayout_editor/pl_editor_config.cpp +++ b/pagelayout_editor/pl_editor_config.cpp @@ -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(); diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 85f52b428d..2c0099f76d 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -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; diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index 24113ea52a..ef1ab7f409 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -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 ) diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 183cad4241..821277a0a2 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -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 { diff --git a/pcbnew/dialogs/dialog_display_options.cpp b/pcbnew/dialogs/dialog_display_options.cpp index 5ad1e752f4..18800c09e0 100644 --- a/pcbnew/dialogs/dialog_display_options.cpp +++ b/pcbnew/dialogs/dialog_display_options.cpp @@ -1,10 +1,35 @@ -///////////////////////////////////////////////////////////////////////////// -// 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 #include #include @@ -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; diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 793a537885..e0ae55575f 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -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 diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 45ee46192e..94f8d72d95 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -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 ) ); diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index 2683e268b5..7162c93618 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -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 ); diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index c553cd83ed..a21dd3bfb0 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -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 );