KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kidialog.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) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <kicommon.h>
24#include <wx/richmsgdlg.h>
25
26
27#if defined( _WIN32 ) && wxCHECK_VERSION( 3, 3, 0 )
28#define KIDIALOG_BASE wxGenericRichMessageDialog
29#else
30#define KIDIALOG_BASE wxRichMessageDialog
31#endif
32
33
38{
39public:
40 static void ClearDoNotShowAgainDialogs();
41
44
45 KIDIALOG( wxWindow* aParent, const wxString& aMessage, const wxString& aCaption, long aStyle = wxOK );
46 KIDIALOG( wxWindow* aParent, const wxString& aMessage, KD_TYPE aType, const wxString& aCaption = "" );
47
48 bool SetOKCancelLabels( const ButtonLabel& ok, const ButtonLabel& cancel ) override
49 {
50 m_cancelMeansCancel = false;
51 return KIDIALOG_BASE::SetOKCancelLabels( ok, cancel );
52 }
53
55 void DoNotShowCheckbox( wxString file, int line );
56
58 bool DoNotShowAgain() const;
59
60 bool Show( bool aShow = true ) override;
61 int ShowModal() override;
62
63protected:
64 // Helper functions for wxRichMessageDialog constructor
65 static wxString getCaption( KD_TYPE aType, const wxString& aCaption );
66 static long getStyle( KD_TYPE aType );
67
68protected:
69 unsigned long m_hash; // Unique id
70 bool m_cancelMeansCancel; // If the Cancel button is renamed then it should be saved by the
71 // DoNotShowAgain checkbox. If it's really a cancel then it should not.
72};
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition kidialog.h:38
@ KD_INFO
Definition kidialog.h:43
@ KD_QUESTION
Definition kidialog.h:43
@ KD_ERROR
Definition kidialog.h:43
@ KD_NONE
Definition kidialog.h:43
@ KD_WARNING
Definition kidialog.h:43
bool m_cancelMeansCancel
Definition kidialog.h:70
unsigned long m_hash
Definition kidialog.h:69
KIDIALOG(wxWindow *aParent, const wxString &aMessage, const wxString &aCaption, long aStyle=wxOK)
Definition kidialog.cpp:29
bool SetOKCancelLabels(const ButtonLabel &ok, const ButtonLabel &cancel) override
Definition kidialog.h:48
static void ClearDoNotShowAgainDialogs()
Dialog type. Selects appropriate icon and default dialog title.
Definition kidialog.cpp:45
#define KICOMMON_API
Definition kicommon.h:27
#define KIDIALOG_BASE
Definition kidialog.h:30