2020-07-15 23:08:16 +00:00
|
|
|
/*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RESETTABLE_PANEL_H_
|
|
|
|
#define RESETTABLE_PANEL_H_
|
|
|
|
|
2021-06-03 01:19:20 +00:00
|
|
|
#include <wx/panel.h>
|
2021-11-01 11:20:13 +00:00
|
|
|
#include <id.h>
|
2020-07-15 23:08:16 +00:00
|
|
|
|
|
|
|
class PAGED_DIALOG;
|
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
#define wxRESETTABLE 0x00008000
|
|
|
|
#define ID_RESET_PANEL ID_PREFERENCES_RESET_PANEL
|
|
|
|
|
2020-07-15 23:08:16 +00:00
|
|
|
/**
|
2021-02-12 03:19:46 +00:00
|
|
|
* A wxPanel that is designed to be reset in a standard manner.
|
2020-07-15 23:08:16 +00:00
|
|
|
*/
|
|
|
|
class RESETTABLE_PANEL : public wxPanel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
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 )
|
2021-11-01 11:20:13 +00:00
|
|
|
: wxPanel( aParent, aId, aPos, aSize, aStyle | wxRESETTABLE, aName )
|
2020-07-15 23:08:16 +00:00
|
|
|
{
|
2021-11-01 11:20:13 +00:00
|
|
|
Bind( wxEVT_COMMAND_BUTTON_CLICKED,
|
|
|
|
[&]( wxCommandEvent& aCmd )
|
|
|
|
{
|
|
|
|
if( aCmd.GetId() == ID_RESET_PANEL )
|
|
|
|
ResetPanel();
|
|
|
|
else
|
|
|
|
aCmd.Skip();
|
|
|
|
} );
|
2020-07-15 23:08:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset the contents of this panel.
|
|
|
|
*/
|
|
|
|
virtual void ResetPanel() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the tooltip the reset button should display when showing this panel.
|
|
|
|
*
|
|
|
|
* @return the tooltip
|
|
|
|
*/
|
2021-11-01 11:20:13 +00:00
|
|
|
virtual wxString GetResetTooltip() const
|
2020-07-15 23:08:16 +00:00
|
|
|
{
|
|
|
|
return _( "Reset all settings on this page to their default" );
|
|
|
|
}
|
2021-11-01 11:20:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Overridden to supply the reset button tooltip when queried with { -INT_MAX, INT_MAX }.
|
|
|
|
*/
|
|
|
|
wxString GetHelpTextAtPoint( const wxPoint& aPt, wxHelpEvent::Origin aOrigin ) const override
|
|
|
|
{
|
|
|
|
if( aPt == wxPoint( -INT_MAX, INT_MAX ) )
|
|
|
|
return GetResetTooltip();
|
|
|
|
else
|
|
|
|
return wxPanel::GetHelpTextAtPoint( aPt, aOrigin );
|
|
|
|
}
|
2020-07-15 23:08:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|