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 38 of file confirm.cpp.

40 : wxRichMessageDialog( aParent, aMessage, aCaption, aStyle | wxCENTRE | wxSTAY_ON_TOP ),
41 m_hash( 0 ),
43{
44}
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 47 of file confirm.cpp.

49 : wxRichMessageDialog( aParent, aMessage, getCaption( aType, aCaption ), getStyle( aType ) ),
50 m_hash( 0 ),
52{
53}
static long getStyle(KD_TYPE aType)
Definition: confirm.cpp:138
static wxString getCaption(KD_TYPE aType, const wxString &aCaption)
Definition: confirm.cpp:120

Member Function Documentation

◆ DoNotShowAgain()

bool KIDIALOG::DoNotShowAgain ( ) const

Definition at line 64 of file confirm.cpp.

65{
66 return doNotShowAgainDlgs.count( m_hash ) > 0;
67}
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:35

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 70 of file confirm.cpp.

71{
73}

References doNotShowAgainDlgs, and m_hash.

◆ getCaption()

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

Definition at line 120 of file confirm.cpp.

121{
122 if( !aCaption.IsEmpty() )
123 return aCaption;
124
125 switch( aType )
126 {
127 case KD_NONE: /* fall through */
128 case KD_INFO: return _( "Message" );
129 case KD_QUESTION: return _( "Question" );
130 case KD_WARNING: return _( "Warning" );
131 case KD_ERROR: return _( "Error" );
132 }
133
134 return wxEmptyString;
135}

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

◆ getStyle()

long KIDIALOG::getStyle ( KD_TYPE  aType)
staticprotected

Definition at line 138 of file confirm.cpp.

139{
140 long style = wxOK | wxCENTRE | wxSTAY_ON_TOP;
141
142 switch( aType )
143 {
144 case KD_NONE: break;
145 case KD_INFO: style |= wxICON_INFORMATION; break;
146 case KD_QUESTION: style |= wxICON_QUESTION; break;
147 case KD_WARNING: style |= wxICON_WARNING; break;
148 case KD_ERROR: style |= wxICON_ERROR; break;
149 }
150
151 return style;
152}

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_SETTINGS::TransferDataFromWindow().

◆ Show()

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

Definition at line 76 of file confirm.cpp.

77{
78 // We should check the do-not-show-again setting only when the dialog is displayed
79 if( aShow )
80 {
81 // Check if this dialog should be shown to the user
82 auto it = doNotShowAgainDlgs.find( m_hash );
83
84 if( it != doNotShowAgainDlgs.end() )
85 return it->second;
86 }
87
88 int ret = wxRichMessageDialog::Show( aShow );
89
90 // Has the user asked not to show the dialog again?
91 // Note that we don't save a Cancel value unless the Cancel button is being used for some
92 // other function (which is actually more common than it being used for Cancel).
93 if( IsCheckBoxChecked() && (!m_cancelMeansCancel || ret != wxID_CANCEL ) )
95
96 return ret;
97}

References doNotShowAgainDlgs, m_cancelMeansCancel, and m_hash.

◆ ShowModal()

int KIDIALOG::ShowModal ( )
override

Definition at line 100 of file confirm.cpp.

101{
102 // Check if this dialog should be shown to the user
103 auto it = doNotShowAgainDlgs.find( m_hash );
104
105 if( it != doNotShowAgainDlgs.end() )
106 return it->second;
107
108 int ret = wxRichMessageDialog::ShowModal();
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.

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_SETTINGS::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: