diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index 215471a415..e31e85822f 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -641,23 +641,27 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() } // Draw layout preview. - wxString emptyString; - GRResetPenAndBrush( &memDC ); + KIGFX::WS_RENDER_SETTINGS renderSettings; + COLOR_SETTINGS* colorSettings = m_parent->GetColorSettings(); + COLOR4D bgColor = m_parent->GetDrawBgColor(); + wxString emptyString; WS_DATA_MODEL::SetAltInstance( m_pagelayout ); - KIGFX::WS_RENDER_SETTINGS renderSettings; - renderSettings.SetDefaultPenWidth( 1 ); - renderSettings.SetLayerColor( LAYER_WORKSHEET, COLOR4D( RED ) ); - renderSettings.SetPrintDC( &memDC ); + { + GRResetPenAndBrush( &memDC ); + renderSettings.SetDefaultPenWidth( 1 ); + renderSettings.LoadColors( colorSettings ); + renderSettings.SetPrintDC( &memDC ); - GRFilledRect( NULL, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, WHITE, WHITE ); + GRFilledRect( NULL, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, bgColor, bgColor ); - PrintPageLayout( &renderSettings, pageDUMMY, emptyString, emptyString, m_tb, - m_screen->GetPageCount(), m_screen->GetPageNumber(), 1, &Prj(), - wxEmptyString, m_screen->GetVirtualPageNumber() == 1 ); + PrintPageLayout( &renderSettings, pageDUMMY, emptyString, emptyString, m_tb, + m_screen->GetPageCount(), m_screen->GetPageNumber(), 1, &Prj(), + wxEmptyString, m_screen->GetVirtualPageNumber() == 1 ); - memDC.SelectObject( wxNullBitmap ); - m_PageLayoutExampleBitmap->SetBitmap( *m_pageBitmap ); + memDC.SelectObject( wxNullBitmap ); + m_PageLayoutExampleBitmap->SetBitmap( *m_pageBitmap ); + } WS_DATA_MODEL::SetAltInstance( NULL ); // Refresh the dialog. diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index b8821c76ca..b0b3c8f8d3 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -943,10 +943,14 @@ void EDA_DRAW_FRAME::RecreateToolbars() } -COLOR_SETTINGS* EDA_DRAW_FRAME::GetColorSettings() +COLOR_SETTINGS* EDA_DRAW_FRAME::GetColorSettings() const { if( !m_colorSettings ) - m_colorSettings = Pgm().GetSettingsManager().GetColorSettings(); + { + COLOR_SETTINGS* colorSettings = Pgm().GetSettingsManager().GetColorSettings(); + + const_cast( this )->m_colorSettings = colorSettings; + } return m_colorSettings; } diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index de5c061e05..08a526c5f4 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -505,7 +505,7 @@ void DISPLAY_FOOTPRINTS_FRAME::UpdateMsgPanel() } -COLOR_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetColorSettings() +COLOR_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetColorSettings() const { auto* settings = Pgm().GetSettingsManager().GetAppSettings(); diff --git a/cvpcb/display_footprints_frame.h b/cvpcb/display_footprints_frame.h index cef9b01c8b..7b589c70fd 100644 --- a/cvpcb/display_footprints_frame.h +++ b/cvpcb/display_footprints_frame.h @@ -79,7 +79,7 @@ public: ///> @copydoc EDA_DRAW_FRAME::UpdateMsgPanel() void UpdateMsgPanel() override; - COLOR_SETTINGS* GetColorSettings() override; + COLOR_SETTINGS* GetColorSettings() const override; /** * Function GetGridColor() , virtual diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index c4be430464..b279b07d79 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -417,13 +417,23 @@ void SCH_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars } -COLOR_SETTINGS* SCH_BASE_FRAME::GetColorSettings() +COLOR_SETTINGS* SCH_BASE_FRAME::GetColorSettings() const { if( !m_colorSettings ) { - EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); - m_colorSettings = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme ); + SETTINGS_MANAGER& settingsManager = Pgm().GetSettingsManager(); + EESCHEMA_SETTINGS* cfg = settingsManager.GetAppSettings(); + COLOR_SETTINGS* colorSettings = settingsManager.GetColorSettings( cfg->m_ColorTheme ); + + const_cast( this )->m_colorSettings = colorSettings; } return m_colorSettings; } + + +COLOR4D SCH_BASE_FRAME::GetDrawBgColor() const +{ + return GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ); +} + diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index 04e6ead472..0078c40935 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -123,6 +123,8 @@ public: return *m_defaults; } + COLOR4D GetDrawBgColor() const override; + /** * Allow some frames to show/hide hidden pins. The default impl shows all pins. */ @@ -255,7 +257,7 @@ public: */ COLOR4D GetLayerColor( SCH_LAYER_ID aLayer ); - COLOR_SETTINGS* GetColorSettings() override; + COLOR_SETTINGS* GetColorSettings() const override; protected: /** diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 9b82cf9f80..31223e2904 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -273,7 +273,7 @@ void SYMBOL_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) } -COLOR_SETTINGS* SYMBOL_EDIT_FRAME::GetColorSettings() +COLOR_SETTINGS* SYMBOL_EDIT_FRAME::GetColorSettings() const { SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); diff --git a/eeschema/symbol_editor/symbol_edit_frame.h b/eeschema/symbol_editor/symbol_edit_frame.h index 19987f55e6..73a33b30a0 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.h +++ b/eeschema/symbol_editor/symbol_edit_frame.h @@ -233,12 +233,12 @@ public: void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; - SYMBOL_EDITOR_SETTINGS* GetSettings() + SYMBOL_EDITOR_SETTINGS* GetSettings() const { return m_settings; } - COLOR_SETTINGS* GetColorSettings() override; + COLOR_SETTINGS* GetColorSettings() const override; /** * Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro: diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 229acb2466..664fefbc28 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -151,7 +151,7 @@ public: virtual void SetDrawBgColor( COLOR4D aColor) { m_drawBgColor= aColor ; } /// Returns a pointer to the active color theme settings - virtual COLOR_SETTINGS* GetColorSettings(); + virtual COLOR_SETTINGS* GetColorSettings() const; bool ShowPageLimits() const { return m_showPageLimits; } void SetShowPageLimits( bool aShow ) { m_showPageLimits = aShow; } diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h index ce84688ce0..cfa8f33b36 100644 --- a/include/pcb_base_frame.h +++ b/include/pcb_base_frame.h @@ -160,7 +160,7 @@ public: * * @return a pointer to the active COLOR_SETTINGS. */ - virtual COLOR_SETTINGS* GetColorSettings() override + virtual COLOR_SETTINGS* GetColorSettings() const override { wxFAIL_MSG( "Color settings requested for a PCB_BASE_FRAME that does not override!" ); return nullptr; @@ -365,9 +365,9 @@ public: void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; - PCBNEW_SETTINGS* GetPcbNewSettings(); + PCBNEW_SETTINGS* GetPcbNewSettings() const; - FOOTPRINT_EDITOR_SETTINGS* GetFootprintEditorSettings(); + FOOTPRINT_EDITOR_SETTINGS* GetFootprintEditorSettings() const; virtual MAGNETIC_SETTINGS* GetMagneticItemsSettings(); diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 44ac852a8c..cf916bc2b7 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -548,7 +548,7 @@ void FOOTPRINT_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) } -COLOR_SETTINGS* FOOTPRINT_EDIT_FRAME::GetColorSettings() +COLOR_SETTINGS* FOOTPRINT_EDIT_FRAME::GetColorSettings() const { wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme; return Pgm().GetSettingsManager().GetColorSettings( currentTheme ); diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index f615daff53..bb043ca28f 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -86,7 +86,7 @@ public: void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; - COLOR_SETTINGS* GetColorSettings() override; + COLOR_SETTINGS* GetColorSettings() const override; const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override; diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 55ec550626..13b0b7a471 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -793,7 +793,7 @@ WINDOW_SETTINGS* FOOTPRINT_VIEWER_FRAME::GetWindowSettings( APP_SETTINGS_BASE* a } -COLOR_SETTINGS* FOOTPRINT_VIEWER_FRAME::GetColorSettings() +COLOR_SETTINGS* FOOTPRINT_VIEWER_FRAME::GetColorSettings() const { auto* settings = Pgm().GetSettingsManager().GetAppSettings(); diff --git a/pcbnew/footprint_viewer_frame.h b/pcbnew/footprint_viewer_frame.h index bda14e697d..aa825ee204 100644 --- a/pcbnew/footprint_viewer_frame.h +++ b/pcbnew/footprint_viewer_frame.h @@ -93,7 +93,7 @@ public: */ bool ShowModal( wxString* aFootprint, wxWindow* aParent ) override; - COLOR_SETTINGS* GetColorSettings() override; + COLOR_SETTINGS* GetColorSettings() const override; private: wxTextCtrl* m_libFilter; diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 50f26cadea..599366540d 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -282,10 +282,11 @@ void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv ) } -COLOR_SETTINGS* FOOTPRINT_WIZARD_FRAME::GetColorSettings() +COLOR_SETTINGS* FOOTPRINT_WIZARD_FRAME::GetColorSettings() const { - return Pgm().GetSettingsManager().GetColorSettings( - GetFootprintEditorSettings()->m_ColorTheme ); + wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme; + + return Pgm().GetSettingsManager().GetColorSettings( currentTheme ); } diff --git a/pcbnew/footprint_wizard_frame.h b/pcbnew/footprint_wizard_frame.h index 198206d1b7..8a0148d3d1 100644 --- a/pcbnew/footprint_wizard_frame.h +++ b/pcbnew/footprint_wizard_frame.h @@ -89,7 +89,7 @@ public: */ void PythonPluginsReload(); - COLOR_SETTINGS* GetColorSettings() override; + COLOR_SETTINGS* GetColorSettings() const override; private: diff --git a/pcbnew/pcb_base_edit_frame.cpp b/pcbnew/pcb_base_edit_frame.cpp index a7688ff364..add950feb8 100644 --- a/pcbnew/pcb_base_edit_frame.cpp +++ b/pcbnew/pcb_base_edit_frame.cpp @@ -205,7 +205,7 @@ void PCB_BASE_EDIT_FRAME::SetObjectVisible( GAL_LAYER_ID aLayer, bool aVisible ) } -COLOR_SETTINGS* PCB_BASE_EDIT_FRAME::GetColorSettings() +COLOR_SETTINGS* PCB_BASE_EDIT_FRAME::GetColorSettings() const { return Pgm().GetSettingsManager().GetColorSettings( GetPcbNewSettings()->m_ColorTheme ); } diff --git a/pcbnew/pcb_base_edit_frame.h b/pcbnew/pcb_base_edit_frame.h index 4475c7243b..b2cc890ca4 100644 --- a/pcbnew/pcb_base_edit_frame.h +++ b/pcbnew/pcb_base_edit_frame.h @@ -191,7 +191,7 @@ public: ///> @copydoc PCB_BASE_FRAME::SetBoard() virtual void SetBoard( BOARD* aBoard ) override; - COLOR_SETTINGS* GetColorSettings() override; + COLOR_SETTINGS* GetColorSettings() const override; /* full undo redo management : */ diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 2045a94a1b..2c271a2e0e 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -676,13 +676,13 @@ void PCB_BASE_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) } -PCBNEW_SETTINGS* PCB_BASE_FRAME::GetPcbNewSettings() +PCBNEW_SETTINGS* PCB_BASE_FRAME::GetPcbNewSettings() const { return Pgm().GetSettingsManager().GetAppSettings(); } -FOOTPRINT_EDITOR_SETTINGS* PCB_BASE_FRAME::GetFootprintEditorSettings() +FOOTPRINT_EDITOR_SETTINGS* PCB_BASE_FRAME::GetFootprintEditorSettings() const { return Pgm().GetSettingsManager().GetAppSettings(); }