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="")
 
void DoNotShowCheckbox (wxString file, int line)
 

Shows the 'do not show again' checkbox

More...
 
bool DoNotShowAgain () const
 

Checks the 'do not show again' setting for the dialog

More...
 
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
 

Unique identifier of the dialog

More...
 

Detailed Description

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

Definition at line 44 of file confirm.h.

Member Enumeration Documentation

Dialog type. Selects appropriate icon and default dialog title

Enumerator
KD_NONE 
KD_INFO 
KD_QUESTION 
KD_WARNING 
KD_ERROR 

Definition at line 48 of file confirm.h.

Constructor & Destructor Documentation

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

Definition at line 45 of file confirm.cpp.

47  : wxRichMessageDialog( aParent, aMessage, aCaption, aStyle | wxCENTRE | wxSTAY_ON_TOP ),
48  m_hash( 0 )
49 {
50 }
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:65
KIDIALOG::KIDIALOG ( wxWindow *  aParent,
const wxString &  aMessage,
KD_TYPE  aType,
const wxString &  aCaption = "" 
)

Definition at line 53 of file confirm.cpp.

55  : wxRichMessageDialog( aParent, aMessage, getCaption( aType, aCaption ), getStyle( aType ) )
56 {
57 }
static wxString getCaption(KD_TYPE aType, const wxString &aCaption)
Definition: confirm.cpp:120
static long getStyle(KD_TYPE aType)
Definition: confirm.cpp:138

Member Function Documentation

bool KIDIALOG::DoNotShowAgain ( ) const

Checks the 'do not show again' setting for the dialog

Definition at line 68 of file confirm.cpp.

References doNotShowAgainDlgs, and m_hash.

69 {
70  return doNotShowAgainDlgs.count( m_hash ) > 0;
71 }
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:42
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:65
void KIDIALOG::ForceShowAgain ( )

Definition at line 74 of file confirm.cpp.

References doNotShowAgainDlgs, and m_hash.

75 {
76  doNotShowAgainDlgs.erase( m_hash );
77 }
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:42
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:65
wxString KIDIALOG::getCaption ( KD_TYPE  aType,
const wxString &  aCaption 
)
staticprotected

Definition at line 120 of file confirm.cpp.

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

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 }
long KIDIALOG::getStyle ( KD_TYPE  aType)
staticprotected

Definition at line 138 of file confirm.cpp.

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

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 }
bool KIDIALOG::Show ( bool  aShow = true)
override

Definition at line 80 of file confirm.cpp.

References doNotShowAgainDlgs, and m_hash.

81 {
82  // We should check the do-not-show-again setting only when the dialog is displayed
83  if( aShow )
84  {
85  // Check if this dialog should be shown to the user
86  auto it = doNotShowAgainDlgs.find( m_hash );
87 
88  if( it != doNotShowAgainDlgs.end() )
89  return it->second;
90  }
91 
92  bool ret = wxRichMessageDialog::Show( aShow );
93 
94  // Has the user asked not to show the dialog again
95  if( IsCheckBoxChecked() )
97 
98  return ret;
99 }
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:42
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:65
int KIDIALOG::ShowModal ( )
override

Definition at line 102 of file confirm.cpp.

References doNotShowAgainDlgs, and m_hash.

Referenced by DIALOG_COPPER_ZONE::AcceptOptions(), DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), ROUTER_TOOL::InlineDrag(), DIALOG_ANNOTATE::OnApplyClick(), DIALOG_ANNOTATE::OnClearAnnotationCmpClick(), KICAD_MANAGER_FRAME::OnCreateProjectFromTemplate(), LIB_EDIT_FRAME::OnExportPart(), DIALOG_CONFIGURE_PATHS::OnGridCellChanging(), KICAD_MANAGER_FRAME::OnImportEagleFiles(), ROUTER_TOOL::performDragging(), LIB_EDIT_FRAME::PlacePin(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), PNS_KICAD_IFACE::syncZone(), and DIALOG_GENCAD_EXPORT_OPTIONS::TransferDataFromWindow().

103 {
104  // Check if this dialog should be shown to the user
105  auto it = doNotShowAgainDlgs.find( m_hash );
106 
107  if( it != doNotShowAgainDlgs.end() )
108  return it->second;
109 
110  int ret = wxRichMessageDialog::ShowModal();
111 
112  // Has the user asked not to show the dialog again
113  if( IsCheckBoxChecked() )
114  doNotShowAgainDlgs[m_hash] = ret;
115 
116  return ret;
117 }
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:42
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:65

Member Data Documentation

unsigned long KIDIALOG::m_hash
protected

Unique identifier of the dialog

Definition at line 65 of file confirm.h.

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


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