diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt index b4ea9e52d5..ee0219f64b 100644 --- a/pagelayout_editor/CMakeLists.txt +++ b/pagelayout_editor/CMakeLists.txt @@ -19,6 +19,8 @@ set( PL_EDITOR_SRCS dialogs/dialog_new_dataitem_base.cpp dialogs/dialog_new_dataitem.cpp dialogs/dialog_design_inspector_base.cpp + dialogs/panel_pl_editor_color_settings.cpp + dialogs/panel_pl_editor_color_settings_base.cpp design_inspector.cpp pl_editor_screen.cpp pl_editor_layout.cpp diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp new file mode 100644 index 0000000000..218f51f0f6 --- /dev/null +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp @@ -0,0 +1,84 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2020 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 3 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, see . + */ + +#include +#include +#include +#include +#include +#include + +#include "panel_pl_editor_color_settings.h" + + +PANEL_PL_EDITOR_COLOR_SETTINGS::PANEL_PL_EDITOR_COLOR_SETTINGS( PL_EDITOR_FRAME* aFrame, + wxWindow* aWindow ) + : PANEL_PL_EDITOR_COLOR_SETTINGS_BASE( aWindow ), + m_frame( aFrame ) +{ +} + + +bool PANEL_PL_EDITOR_COLOR_SETTINGS::TransferDataToWindow() +{ + PL_EDITOR_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); + + COLOR_SETTINGS* current = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme ); + + int width = 0; + int height = 0; + int minwidth = width; + + m_themeSelection->Clear(); + + for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() ) + { + int pos = m_themeSelection->Append( settings->GetName(), static_cast( settings ) ); + + if( settings == current ) + m_themeSelection->SetSelection( pos ); + + m_themeSelection->GetTextExtent( settings->GetName(), &width, &height ); + minwidth = std::max( minwidth, width ); + } + + m_themeSelection->SetMinSize( wxSize( minwidth + 50, -1 ) ); + + Fit(); + + return true; +} + + +bool PANEL_PL_EDITOR_COLOR_SETTINGS::TransferDataFromWindow() +{ + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + + auto selected = static_cast( + m_themeSelection->GetClientData( m_themeSelection->GetSelection() ) ); + + PL_EDITOR_SETTINGS* cfg = mgr.GetAppSettings(); + + cfg->m_ColorTheme = selected->GetFilename(); + + auto settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings(); + settings->LoadColors( selected ); + + return true; +} \ No newline at end of file diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings.h b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.h new file mode 100644 index 0000000000..3a9d50e93a --- /dev/null +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.h @@ -0,0 +1,41 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2020 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 3 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, see . + */ + +#ifndef KICAD_PANEL_PL_EDITOR_COLOR_SETTINGS_H +#define KICAD_PANEL_PL_EDITOR_COLOR_SETTINGS_H + +#include "panel_pl_editor_color_settings_base.h" + +class PL_EDITOR_FRAME; + +class PANEL_PL_EDITOR_COLOR_SETTINGS : public PANEL_PL_EDITOR_COLOR_SETTINGS_BASE +{ +public: + PANEL_PL_EDITOR_COLOR_SETTINGS( PL_EDITOR_FRAME* aFrame, wxWindow* aWindow ); + +private: + bool TransferDataToWindow() override; + + bool TransferDataFromWindow() override; + + PL_EDITOR_FRAME* m_frame; +}; + + +#endif //KICAD_PANEL_PL_EDITOR_COLOR_SETTINGS_H diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.cpp b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.cpp new file mode 100644 index 0000000000..36bd754ccf --- /dev/null +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.cpp @@ -0,0 +1,44 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "panel_pl_editor_color_settings_base.h" + +/////////////////////////////////////////////////////////////////////////// + +PANEL_PL_EDITOR_COLOR_SETTINGS_BASE::PANEL_PL_EDITOR_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +{ + wxBoxSizer* p1mainSizer; + p1mainSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxStaticBoxSizer* sbSizer1; + sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Color Theme") ), wxHORIZONTAL ); + + sbSizer1->SetMinSize( wxSize( 250,-1 ) ); + m_txtTheme = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Theme:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_txtTheme->Wrap( -1 ); + sbSizer1->Add( m_txtTheme, 0, wxALIGN_CENTER_VERTICAL|wxALL, 10 ); + + wxArrayString m_themeSelectionChoices; + m_themeSelection = new wxChoice( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_themeSelectionChoices, 0 ); + m_themeSelection->SetSelection( 0 ); + sbSizer1->Add( m_themeSelection, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 10 ); + + + p1mainSizer->Add( sbSizer1, 0, wxALL, 10 ); + + + p1mainSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + + this->SetSizer( p1mainSizer ); + this->Layout(); + p1mainSizer->Fit( this ); +} + +PANEL_PL_EDITOR_COLOR_SETTINGS_BASE::~PANEL_PL_EDITOR_COLOR_SETTINGS_BASE() +{ +} diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.fbp b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.fbp new file mode 100644 index 0000000000..b79b9bd908 --- /dev/null +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.fbp @@ -0,0 +1,209 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + table + panel_pl_editor_color_settings_base + 1000 + none + + 1 + PanelPagelayoutEditorColorSettingsBase + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + PANEL_PL_EDITOR_COLOR_SETTINGS_BASE + + -1,-1 + ; forward_declare + + + + wxTAB_TRAVERSAL + + + p1mainSizer + wxHORIZONTAL + none + + 10 + wxALL + 0 + + wxID_ANY + Color Theme + 250,-1 + sbSizer1 + wxHORIZONTAL + 1 + none + + 10 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Theme: + 0 + + 0 + + + 0 + + 1 + m_txtTheme + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 10 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_themeSelection + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + + + diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.h b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.h new file mode 100644 index 0000000000..19596c6df4 --- /dev/null +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.h @@ -0,0 +1,44 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class PANEL_PL_EDITOR_COLOR_SETTINGS_BASE +/////////////////////////////////////////////////////////////////////////////// +class PANEL_PL_EDITOR_COLOR_SETTINGS_BASE : public wxPanel +{ + private: + + protected: + wxStaticText* m_txtTheme; + wxChoice* m_themeSelection; + + public: + + PANEL_PL_EDITOR_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + ~PANEL_PL_EDITOR_COLOR_SETTINGS_BASE(); + +}; + diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 0b605fee31..49a4ff9cd3 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -91,7 +92,6 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_showBorderAndTitleBlock = true; // true for reference drawings. m_originSelectChoice = 0; - SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK) WS_DATA_MODEL::GetTheInstance().m_EditMode = true; SetShowPageLimits( true ); m_AboutTitle = "PlEditor"; @@ -418,6 +418,7 @@ void PL_EDITOR_FRAME::InstallPreferences( PAGED_DIALOG* aParent, wxTreebook* book = aParent->GetTreebook(); book->AddPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); + book->AddPage( new PANEL_PL_EDITOR_COLOR_SETTINGS( this, aParent ), _( "Colors" ) ); aHotkeysPanel->AddHotKeys( GetToolManager() ); }