KiCad PCB EDA Suite
Loading...
Searching...
No Matches
resettable_panel.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 (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef RESETTABLE_PANEL_H_
21#define RESETTABLE_PANEL_H_
22
23#include <wx/panel.h>
24#include <id.h>
25
26class PAGED_DIALOG;
27
28#define wxRESETTABLE 0x00008000
29#define ID_RESET_PANEL ID_PREFERENCES_RESET_PANEL
30
34class RESETTABLE_PANEL : public wxPanel
35{
36public:
37 RESETTABLE_PANEL( wxWindow* aParent, wxWindowID aId = wxID_ANY,
38 const wxPoint& aPos = wxDefaultPosition,
39 const wxSize& aSize = wxSize( -1,-1 ),
40 long aStyle = wxTAB_TRAVERSAL,
41 const wxString& aName = wxEmptyString )
42 : wxPanel( aParent, aId, aPos, aSize, aStyle | wxRESETTABLE, aName )
43 {
44 Bind( wxEVT_COMMAND_BUTTON_CLICKED,
45 [&]( wxCommandEvent& aCmd )
46 {
47 if( aCmd.GetId() == ID_RESET_PANEL )
48 ResetPanel();
49 else
50 aCmd.Skip();
51 } );
52 }
53
57 virtual void ResetPanel() = 0;
58
64 virtual wxString GetResetTooltip() const
65 {
66 return _( "Reset all settings on this page to their default" );
67 }
68
72 wxString GetHelpTextAtPoint( const wxPoint& aPt, wxHelpEvent::Origin aOrigin ) const override
73 {
74 if( aPt == wxPoint( -INT_MAX, INT_MAX ) )
75 return GetResetTooltip();
76 else
77 return wxPanel::GetHelpTextAtPoint( aPt, aOrigin );
78 }
79};
80
81#endif
A wxPanel that is designed to be reset in a standard manner.
RESETTABLE_PANEL(wxWindow *aParent, wxWindowID aId=wxID_ANY, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxSize(-1,-1), long aStyle=wxTAB_TRAVERSAL, const wxString &aName=wxEmptyString)
virtual void ResetPanel()=0
Reset the contents of this panel.
virtual wxString GetResetTooltip() const
Get the tooltip the reset button should display when showing this panel.
wxString GetHelpTextAtPoint(const wxPoint &aPt, wxHelpEvent::Origin aOrigin) const override
Overridden to supply the reset button tooltip when queried with { -INT_MAX, INT_MAX }.
#define _(s)
#define wxRESETTABLE
#define ID_RESET_PANEL