From 924accfdc8f3e2349208c956c4fc667376ff17b7 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 1 Mar 2021 23:10:03 -0500 Subject: [PATCH] Consolidate wxAui art providers --- common/CMakeLists.txt | 3 +- common/eda_base_frame.cpp | 2 +- common/tool/action_toolbar.cpp | 4 +- ..._provider.cpp => wx_aui_art_providers.cpp} | 24 ++++++++++-- common/widgets/wx_aui_dock_art.cpp | 38 ------------------- ..._art_provider.h => wx_aui_art_providers.h} | 21 +++++++--- include/widgets/wx_aui_dock_art.h | 31 --------------- 7 files changed, 40 insertions(+), 83 deletions(-) rename common/widgets/{aui_art_provider.cpp => wx_aui_art_providers.cpp} (86%) delete mode 100644 common/widgets/wx_aui_dock_art.cpp rename include/widgets/{aui_art_provider.h => wx_aui_art_providers.h} (76%) delete mode 100644 include/widgets/wx_aui_dock_art.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 110804cc62..b0ca7b9e0c 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -210,7 +210,6 @@ set( COMMON_DLG_SRCS set( COMMON_WIDGET_SRCS widgets/app_progress_dialog.cpp - widgets/aui_art_provider.cpp widgets/bitmap_button.cpp widgets/bitmap_toggle.cpp widgets/button_row_panel.cpp @@ -242,9 +241,9 @@ set( COMMON_WIDGET_SRCS widgets/unit_binder.cpp widgets/widget_save_restore.cpp widgets/widget_hotkey_list.cpp + widgets/wx_aui_art_providers.cpp widgets/wx_busy_indicator.cpp widgets/wx_grid.cpp - widgets/wx_aui_dock_art.cpp ) set( COMMON_DRAWING_SHEET_SRCS diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index d2d40e512f..2cecc9ebcb 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/common/tool/action_toolbar.cpp b/common/tool/action_toolbar.cpp index 29c5e67f88..cd6bcecd6a 100644 --- a/common/tool/action_toolbar.cpp +++ b/common/tool/action_toolbar.cpp @@ -35,8 +35,8 @@ #include #include #include -#include #include +#include #include #include @@ -175,7 +175,7 @@ ACTION_TOOLBAR::ACTION_TOOLBAR( EDA_BASE_FRAME* parent, wxWindowID id, const wxP #ifdef NOTYET #if !wxCHECK_VERSION( 3, 1, 0 ) // Custom art provider makes dark mode work on wx < 3.1 - AUI_ART_PROVIDER* newArt = new AUI_ART_PROVIDER(); + WX_AUI_TOOLBAR_ART* newArt = new WX_AUI_TOOLBAR_ART(); SetArtProvider( newArt ); #endif #endif diff --git a/common/widgets/aui_art_provider.cpp b/common/widgets/wx_aui_art_providers.cpp similarity index 86% rename from common/widgets/aui_art_provider.cpp rename to common/widgets/wx_aui_art_providers.cpp index ac395b957b..060ff34a3a 100644 --- a/common/widgets/aui_art_provider.cpp +++ b/common/widgets/wx_aui_art_providers.cpp @@ -18,20 +18,21 @@ */ #include +#include #include #include #include #include -#include +#include /** * wxAuiDefaultToolBarArt::DrawButton except with dark-mode awareness based on BITMAP_BUTTON * Unfortunately, wx 3.0 does not provide any hooks that would make it possible to do this in a way * other than just copy/pasting the upstream implementation and modifying it... */ -void AUI_ART_PROVIDER::DrawButton( wxDC& aDc, wxWindow* aWindow, const wxAuiToolBarItem& aItem, - const wxRect& aRect ) +void WX_AUI_TOOLBAR_ART::DrawButton( wxDC& aDc, wxWindow* aWindow, const wxAuiToolBarItem& aItem, + const wxRect& aRect ) { bool darkMode = KIPLATFORM::UI::IsDarkTheme(); int textWidth = 0; @@ -121,3 +122,20 @@ void AUI_ART_PROVIDER::DrawButton( wxDC& aDc, wxWindow* aWindow, const wxAuiTool aDc.DrawText( aItem.GetLabel(), textX, textY ); } } + + +WX_AUI_DOCK_ART::WX_AUI_DOCK_ART() : wxAuiDefaultDockArt() +{ +#if defined( _WIN32 ) + #if wxCHECK_VERSION( 3, 1, 0 ) + // Use normal control font, wx likes to use "small" + m_captionFont = *wxNORMAL_FONT; + + // Increase the box the caption rests in size a bit + m_captionSize = wxWindow::FromDIP( 20, NULL ); +#endif +#endif + + // Turn off the ridiculous looking gradient + m_gradientType = wxAUI_GRADIENT_NONE; +} diff --git a/common/widgets/wx_aui_dock_art.cpp b/common/widgets/wx_aui_dock_art.cpp deleted file mode 100644 index 315b8d7701..0000000000 --- a/common/widgets/wx_aui_dock_art.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 - - -WX_AUI_DOCK_ART::WX_AUI_DOCK_ART() : wxAuiDefaultDockArt() -{ -#if defined( _WIN32 ) -#if wxCHECK_VERSION( 3, 1, 0 ) - // Use normal control font, wx likes to use "small" - m_captionFont = *wxNORMAL_FONT; - - // Increase the box the caption rests in size a bit - m_captionSize = wxWindow::FromDIP( 20, NULL ); -#endif -#endif - - // Turn off the ridiculous looking gradient - m_gradientType = wxAUI_GRADIENT_NONE; -} \ No newline at end of file diff --git a/include/widgets/aui_art_provider.h b/include/widgets/wx_aui_art_providers.h similarity index 76% rename from include/widgets/aui_art_provider.h rename to include/widgets/wx_aui_art_providers.h index 045f14845f..b0cd97888b 100644 --- a/include/widgets/aui_art_provider.h +++ b/include/widgets/wx_aui_art_providers.h @@ -17,25 +17,34 @@ * with this program. If not, see . */ -#ifndef KICAD_AUI_ART_PROVIDER_H -#define KICAD_AUI_ART_PROVIDER_H +#ifndef KICAD_WX_AUI_ART_PROVIDERS_H +#define KICAD_WX_AUI_ART_PROVIDERS_H #include +#include /** * wxWidgets 3.1 has support for dark mode detection, but 3.0 doesn't. * The main purpose of this replacement art provider is to backport that functionality * so that it is available in Linux systems that will likely be stuck on 3.0 for a while. */ -class AUI_ART_PROVIDER : public wxAuiDefaultToolBarArt +class WX_AUI_TOOLBAR_ART : public wxAuiDefaultToolBarArt { public: - AUI_ART_PROVIDER() : wxAuiDefaultToolBarArt() {} + WX_AUI_TOOLBAR_ART() : wxAuiDefaultToolBarArt() {} - virtual ~AUI_ART_PROVIDER() = default; + virtual ~WX_AUI_TOOLBAR_ART() = default; void DrawButton( wxDC& aDc, wxWindow* aWindow, const wxAuiToolBarItem& aItem, const wxRect& aRect ) override; }; -#endif // KICAD_AUI_ART_PROVIDER_H + +class WX_AUI_DOCK_ART : public wxAuiDefaultDockArt +{ +public: + WX_AUI_DOCK_ART(); +}; + + +#endif // KICAD_WX_AUI_ART_PROVIDERS_H diff --git a/include/widgets/wx_aui_dock_art.h b/include/widgets/wx_aui_dock_art.h deleted file mode 100644 index 4de7673f40..0000000000 --- a/include/widgets/wx_aui_dock_art.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 WX_AUI_DOCK_ART_H -#define WX_AUI_DOCK_ART_H - -#include - -class WX_AUI_DOCK_ART : public wxAuiDefaultDockArt -{ -public: - WX_AUI_DOCK_ART(); -}; - -#endif \ No newline at end of file