KiCad PCB EDA Suite
KIDIALOG Class Reference

Helper class to create more flexible dialogs, including 'do not show again' checkbox handling. More...

#include <confirm.h>

Inheritance diagram for KIDIALOG:

Public Types

enum  KD_TYPE {
  KD_NONE , KD_INFO , KD_QUESTION , KD_WARNING ,
  KD_ERROR
}
 < Dialog type. Selects appropriate icon and default dialog title More...
 

Public Member Functions

 KIDIALOG (wxWindow *aParent, const wxString &aMessage, const wxString &aCaption, long aStyle=wxOK)
 
 KIDIALOG (wxWindow *aParent, const wxString &aMessage, KD_TYPE aType, const wxString &aCaption="")
 
bool SetOKCancelLabels (const ButtonLabel &ok, const ButtonLabel &cancel) override
 Shows the 'do not show again' checkbox. More...
 
void DoNotShowCheckbox (wxString file, int line)
 Checks the 'do not show again' setting for the dialog. More...
 
bool DoNotShowAgain () const
 
void ForceShowAgain ()
 
bool Show (bool aShow=true) override
 
int ShowModal () override
 

Static Protected Member Functions

static wxString getCaption (KD_TYPE aType, const wxString &aCaption)
 
static long getStyle (KD_TYPE aType)
 

Protected Attributes

unsigned long m_hash
 
bool m_cancelMeansCancel
 

Detailed Description

Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.

Definition at line 45 of file confirm.h.

Member Enumeration Documentation

◆ KD_TYPE

< Dialog type. Selects appropriate icon and default dialog title

Enumerator
KD_NONE 
KD_INFO 
KD_QUESTION 
KD_WARNING 
KD_ERROR 

Definition at line 49 of file confirm.h.

@ KD_INFO
Definition: confirm.h:49
@ KD_QUESTION
Definition: confirm.h:49
@ KD_ERROR
Definition: confirm.h:49
@ KD_NONE
Definition: confirm.h:49
@ KD_WARNING
Definition: confirm.h:49

Constructor & Destructor Documentation

◆ KIDIALOG() [1/2]

KIDIALOG::KIDIALOG ( wxWindow *  aParent,
const wxString &  aMessage,
const wxString &  aCaption,
long  aStyle = wxOK 
)

Definition at line 58 of file confirm.cpp.

60 : wxRichMessageDialog( aParent, aMessage, aCaption, aStyle | wxCENTRE | wxSTAY_ON_TOP ),
61 m_hash( 0 ),
63{
64}
bool m_cancelMeansCancel
Definition: confirm.h:79
unsigned long m_hash
Definition: confirm.h:78

◆ KIDIALOG() [2/2]

KIDIALOG::KIDIALOG ( wxWindow *  aParent,
const wxString &  aMessage,
KD_TYPE  aType,
const wxString &  aCaption = "" 
)

Definition at line 67 of file confirm.cpp.

69 : wxRichMessageDialog( aParent, aMessage, getCaption( aType, aCaption ), getStyle( aType ) ),
70 m_hash( 0 ),
72{
73}
static long getStyle(KD_TYPE aType)
Definition: confirm.cpp:158
static wxString getCaption(KD_TYPE aType, const wxString &aCaption)
Definition: confirm.cpp:140

Member Function Documentation

◆ DoNotShowAgain()

bool KIDIALOG::DoNotShowAgain ( ) const

Definition at line 84 of file confirm.cpp.

85{
86 return doNotShowAgainDlgs.count( m_hash ) > 0;
87}
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:37

References doNotShowAgainDlgs, and m_hash.

Referenced by DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP(), and DIALOG_CONFIGURE_PATHS::OnGridCellChanging().

◆ DoNotShowCheckbox()

◆ ForceShowAgain()

void KIDIALOG::ForceShowAgain ( )

Definition at line 90 of file confirm.cpp.

91{
93}

References doNotShowAgainDlgs, and m_hash.

◆ getCaption()

wxString KIDIALOG::getCaption ( KD_TYPE  aType,
const wxString &  aCaption 
)
staticprotected

Definition at line 140 of file confirm.cpp.

141{
142 if( !aCaption.IsEmpty() )
143 return aCaption;
144
145 switch( aType )
146 {
147 case KD_NONE: /* fall through */
148 case KD_INFO: return _( "Message" );
149 case KD_QUESTION: return _( "Question" );
150 case KD_WARNING: return _( "Warning" );
151 case KD_ERROR: return _( "Error" );
152 }
153
154 return wxEmptyString;
155}

References _, KD_ERROR, KD_INFO, KD_NONE, KD_QUESTION, and KD_WARNING.

◆ getStyle()

long KIDIALOG::getStyle ( KD_TYPE  aType)
staticprotected

Definition at line 158 of file confirm.cpp.

159{
160 long style = wxOK | wxCENTRE | wxSTAY_ON_TOP;
161
162 switch( aType )
163 {
164 case KD_NONE: break;
165 case KD_INFO: style |= wxICON_INFORMATION; break;
166 case KD_QUESTION: style |= wxICON_QUESTION; break;
167 case KD_WARNING: style |= wxICON_WARNING; break;
168 case KD_ERROR: style |= wxICON_ERROR; break;
169 }
170
171 return style;
172}

References KD_ERROR, KD_INFO, KD_NONE, KD_QUESTION, and KD_WARNING.

◆ SetOKCancelLabels()

bool KIDIALOG::SetOKCancelLabels ( const ButtonLabel &  ok,
const ButtonLabel &  cancel 
)
inlineoverride

Shows the 'do not show again' checkbox.

Definition at line 56 of file confirm.h.

References cancel, and m_cancelMeansCancel.

Referenced by DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange(), ZONE_FILLER::Fill(), and DIALOG_SIM_COMMAND::TransferDataFromWindow().

◆ Show()

bool KIDIALOG::Show ( bool  aShow = true)
override

Definition at line 96 of file confirm.cpp.

97{
98 // We should check the do-not-show-again setting only when the dialog is displayed
99 if( aShow )
100 {
101 // Check if this dialog should be shown to the user
102 auto it = doNotShowAgainDlgs.find( m_hash );
103
104 if( it != doNotShowAgainDlgs.end() )
105 return it->second;
106 }
107
108 int ret = wxRichMessageDialog::Show( aShow );
109
110 // Has the user asked not to show the dialog again?
111 // Note that we don't save a Cancel value unless the Cancel button is being used for some
112 // other function (which is actually more common than it being used for Cancel).
113 if( IsCheckBoxChecked() && (!m_cancelMeansCancel || ret != wxID_CANCEL ) )
115
116 return ret;
117}

References doNotShowAgainDlgs, m_cancelMeansCancel, and m_hash.

◆ ShowModal()

int KIDIALOG::ShowModal ( )
override

Definition at line 120 of file confirm.cpp.

121{
122 // Check if this dialog should be shown to the user
123 auto it = doNotShowAgainDlgs.find( m_hash );
124
125 if( it != doNotShowAgainDlgs.end() )
126 return it->second;
127
128 int ret = wxRichMessageDialog::ShowModal();
129
130 // Has the user asked not to show the dialog again?
131 // Note that we don't save a Cancel value unless the Cancel button is being used for some
132 // other function (which is actually more common than it being used for Cancel).
133 if( IsCheckBoxChecked() && (!m_cancelMeansCancel || ret != wxID_CANCEL ) )
135
136 return ret;
137}

References doNotShowAgainDlgs, m_cancelMeansCancel, and m_hash.

Referenced by PCB_CONTROL::AppendBoard(), DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange(), PCB_BASE_EDIT_FRAME::createNewLibrary(), SYMBOL_EDIT_FRAME::CreateNewSymbol(), DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP(), SYMBOL_EDIT_FRAME::ExportSymbol(), ZONE_FILLER::Fill(), KICAD_MANAGER_FRAME::ImportNonKiCadProject(), SYMBOL_EDIT_FRAME::ImportSymbol(), ROUTER_TOOL::InlineBreakTrack(), CLIPBOARD_IO::Load(), LEGACY_PLUGIN::loadZONE_CONTAINER(), KICAD_MANAGER_CONTROL::NewFromTemplate(), DIALOG_CONFIGURE_PATHS::OnGridCellChanging(), PCB_EDIT_FRAME::OpenProjectFiles(), PCB_PARSER::parseSetup(), ROUTER_TOOL::performDragging(), SYMBOL_EDITOR_PIN_TOOL::PlacePin(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), SYMBOL_EDIT_FRAME::saveSymbolAs(), PNS_KICAD_IFACE_BASE::syncZone(), DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(), DIALOG_SIM_COMMAND::TransferDataFromWindow(), DIALOG_EXPORT_IDF3::TransferDataFromWindow(), and DIALOG_GENCAD_EXPORT_OPTIONS::TransferDataFromWindow().

Member Data Documentation

◆ m_cancelMeansCancel

bool KIDIALOG::m_cancelMeansCancel
protected

Definition at line 79 of file confirm.h.

Referenced by SetOKCancelLabels(), Show(), and ShowModal().

◆ m_hash

unsigned long KIDIALOG::m_hash
protected

Definition at line 78 of file confirm.h.

Referenced by DoNotShowAgain(), DoNotShowCheckbox(), ForceShowAgain(), Show(), and ShowModal().


The documentation for this class was generated from the following files: