KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kicad_tab_art.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef KICAD_TAB_ART_H
21#define KICAD_TAB_ART_H
22
23#include <functional>
24
25#include <wx/version.h>
26#include <wx/aui/auibook.h>
27#include <wx/aui/tabart.h>
28
29
33{
34 bool italic = false;
35 bool bold = false;
36 bool showAsterisk = false;
37};
38
39
43TAB_VISUAL_STATE ResolveTabVisualState( bool aPreview, bool aModified );
44
45
48class KICAD_TAB_ART : public wxAuiDefaultTabArt
49{
50public:
52 using STATE_FN = std::function<TAB_VISUAL_STATE( wxWindow* )>;
53
54 explicit KICAD_TAB_ART( STATE_FN aProvider );
55
56 wxAuiTabArt* Clone() override;
57
58#if wxCHECK_VERSION( 3, 3, 0 )
59 // wxWidgets 3.3 rewrote wxAUI to a page-based art interface and the tab strip now renders through
60 // DrawPageTab/GetPageTabSize. The legacy DrawTab/GetTabSize are no longer on the draw path for the
61 // default (flat) art, so the decorations must hook the page-based methods instead.
62 int DrawPageTab( wxDC& aDc, wxWindow* aWnd, wxAuiNotebookPage& aPage,
63 const wxRect& aRect ) override;
64
65 wxSize GetPageTabSize( wxReadOnlyDC& aDc, wxWindow* aWnd, const wxAuiNotebookPage& aPage,
66 int* aXExtent = nullptr ) override;
67#else
68 void DrawTab( wxDC& aDc, wxWindow* aWnd, const wxAuiNotebookPage& aPage, const wxRect& aInRect,
69 int aCloseButtonState, wxRect* aOutTabRect, wxRect* aOutButtonRect,
70 int* aXExtent ) override;
71
72 wxSize GetTabSize( wxDC& aDc, wxWindow* aWnd, const wxString& aCaption,
73 const wxBitmapBundle& aBitmap, bool aActive, int aCloseButtonState,
74 int* aXExtent ) override;
75#endif
76
77private:
81 TAB_VISUAL_STATE stateFor( wxWindow* aPageWindow ) const;
82
86 wxFont decoratedFont( const TAB_VISUAL_STATE& aState, bool aActive ) const;
87
89};
90
91#endif // KICAD_TAB_ART_H
wxSize GetTabSize(wxDC &aDc, wxWindow *aWnd, const wxString &aCaption, const wxBitmapBundle &aBitmap, bool aActive, int aCloseButtonState, int *aXExtent) override
KICAD_TAB_ART(STATE_FN aProvider)
wxAuiTabArt * Clone() override
STATE_FN m_stateFn
std::function< TAB_VISUAL_STATE(wxWindow *)> STATE_FN
Returns the current visual state for a page window.
void DrawTab(wxDC &aDc, wxWindow *aWnd, const wxAuiNotebookPage &aPage, const wxRect &aInRect, int aCloseButtonState, wxRect *aOutTabRect, wxRect *aOutButtonRect, int *aXExtent) override
wxFont decoratedFont(const TAB_VISUAL_STATE &aState, bool aActive) const
The base caption font for a tab, styled italic for preview and bold for modified.
TAB_VISUAL_STATE stateFor(wxWindow *aPageWindow) const
Visual state for a page, or a default if no provider is set.
TAB_VISUAL_STATE ResolveTabVisualState(bool aPreview, bool aModified)
Resolve a tab's decorations from its document state flags.
Visual decorations derived from document state: preview is italic, modified is bold with a leading as...