KiCad PCB EDA Suite
CONFIG_SAVE_RESTORE_WINDOW Class Reference

#include <dialog_create_array.h>

Inheritance diagram for CONFIG_SAVE_RESTORE_WINDOW:
DIALOG_CREATE_ARRAY

Classes

struct  CONFIG_CTRL_T
 

Protected Member Functions

 CONFIG_SAVE_RESTORE_WINDOW (bool &validFlag)
 
void Add (wxRadioBox *ctrl, int &dest)
 
void Add (wxCheckBox *ctrl, bool &dest)
 
void Add (wxTextCtrl *ctrl, wxString &dest)
 
void Add (wxChoice *ctrl, int &dest)
 
void Add (wxNotebook *ctrl, int &dest)
 
void ReadConfigFromControls ()
 
void RestoreConfigToControls ()
 

Private Types

enum  CONFIG_CTRL_TYPE_T {
  CFG_CTRL_TEXT, CFG_CTRL_CHECKBOX, CFG_CTRL_RADIOBOX, CFG_CTRL_CHOICE,
  CFG_CTRL_TAB
}
 

Private Attributes

std::vector< CONFIG_CTRL_Tctrls
 
bool & valid
 

Detailed Description

Definition at line 36 of file dialog_create_array.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

CONFIG_SAVE_RESTORE_WINDOW::CONFIG_SAVE_RESTORE_WINDOW ( bool &  validFlag)
inlineprotected

Definition at line 60 of file dialog_create_array.h.

60  :
61  valid( validFlag )
62  {}

Member Function Documentation

void CONFIG_SAVE_RESTORE_WINDOW::Add ( wxRadioBox *  ctrl,
int &  dest 
)
inlineprotected

Definition at line 64 of file dialog_create_array.h.

References CFG_CTRL_RADIOBOX.

Referenced by DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY().

65  {
66  CONFIG_CTRL_T ctrlInfo = { ctrl, CFG_CTRL_RADIOBOX, (void*) &dest };
67 
68  ctrls.push_back( ctrlInfo );
69  }
std::vector< CONFIG_CTRL_T > ctrls
void CONFIG_SAVE_RESTORE_WINDOW::Add ( wxCheckBox *  ctrl,
bool &  dest 
)
inlineprotected

Definition at line 71 of file dialog_create_array.h.

References CFG_CTRL_CHECKBOX.

72  {
73  CONFIG_CTRL_T ctrlInfo = { ctrl, CFG_CTRL_CHECKBOX, (void*) &dest };
74 
75  ctrls.push_back( ctrlInfo );
76  }
std::vector< CONFIG_CTRL_T > ctrls
void CONFIG_SAVE_RESTORE_WINDOW::Add ( wxTextCtrl *  ctrl,
wxString &  dest 
)
inlineprotected

Definition at line 78 of file dialog_create_array.h.

References CFG_CTRL_TEXT.

79  {
80  CONFIG_CTRL_T ctrlInfo = { ctrl, CFG_CTRL_TEXT, (void*) &dest };
81 
82  ctrls.push_back( ctrlInfo );
83  }
std::vector< CONFIG_CTRL_T > ctrls
void CONFIG_SAVE_RESTORE_WINDOW::Add ( wxChoice *  ctrl,
int &  dest 
)
inlineprotected

Definition at line 85 of file dialog_create_array.h.

References CFG_CTRL_CHOICE.

86  {
87  CONFIG_CTRL_T ctrlInfo = { ctrl, CFG_CTRL_CHOICE, (void*) &dest };
88 
89  ctrls.push_back( ctrlInfo );
90  }
std::vector< CONFIG_CTRL_T > ctrls
void CONFIG_SAVE_RESTORE_WINDOW::Add ( wxNotebook *  ctrl,
int &  dest 
)
inlineprotected

Definition at line 92 of file dialog_create_array.h.

References CFG_CTRL_TAB.

93  {
94  CONFIG_CTRL_T ctrlInfo = { ctrl, CFG_CTRL_TAB, (void*) &dest };
95 
96  ctrls.push_back( ctrlInfo );
97  }
std::vector< CONFIG_CTRL_T > ctrls
void CONFIG_SAVE_RESTORE_WINDOW::ReadConfigFromControls ( )
inlineprotected

Definition at line 99 of file dialog_create_array.h.

References CFG_CTRL_CHECKBOX, CFG_CTRL_CHOICE, CFG_CTRL_RADIOBOX, CFG_CTRL_TAB, and CFG_CTRL_TEXT.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

100  {
101  for( std::vector<CONFIG_CTRL_T>::const_iterator iter = ctrls.begin(), iend = ctrls.end();
102  iter != iend; ++iter )
103  {
104  switch( iter->type )
105  {
106  case CFG_CTRL_CHECKBOX:
107  *(bool*) iter->dest = static_cast<wxCheckBox*>( iter->control )->GetValue();
108  break;
109 
110  case CFG_CTRL_TEXT:
111  *(wxString*) iter->dest = static_cast<wxTextCtrl*>( iter->control )->GetValue();
112  break;
113 
114  case CFG_CTRL_CHOICE:
115  *(int*) iter->dest = static_cast<wxChoice*>( iter->control )->GetSelection();
116  break;
117 
118  case CFG_CTRL_RADIOBOX:
119  *(int*) iter->dest = static_cast<wxRadioBox*>( iter->control )->GetSelection();
120  break;
121 
122  case CFG_CTRL_TAB:
123  *(int*) iter->dest = static_cast<wxNotebook*>( iter->control )->GetSelection();
124  break;
125 
126  default:
127  wxASSERT_MSG( false, wxString(
128  "Unhandled control type for config store: " ) << iter->type );
129  }
130  }
131 
132  valid = true;
133  }
std::vector< CONFIG_CTRL_T > ctrls
void CONFIG_SAVE_RESTORE_WINDOW::RestoreConfigToControls ( )
inlineprotected

Definition at line 135 of file dialog_create_array.h.

References CFG_CTRL_CHECKBOX, CFG_CTRL_CHOICE, CFG_CTRL_RADIOBOX, CFG_CTRL_TAB, and CFG_CTRL_TEXT.

Referenced by DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY().

136  {
137  if( !valid )
138  return;
139 
140  for( std::vector<CONFIG_CTRL_T>::const_iterator iter = ctrls.begin(), iend = ctrls.end();
141  iter != iend; ++iter )
142  {
143  switch( iter->type )
144  {
145  case CFG_CTRL_CHECKBOX:
146  static_cast<wxCheckBox*>( iter->control )->SetValue( *(bool*) iter->dest );
147  break;
148 
149  case CFG_CTRL_TEXT:
150  static_cast<wxTextCtrl*>( iter->control )->SetValue( *(wxString*) iter->dest );
151  break;
152 
153  case CFG_CTRL_CHOICE:
154  static_cast<wxChoice*>( iter->control )->SetSelection( *(int*) iter->dest );
155  break;
156 
157  case CFG_CTRL_RADIOBOX:
158  static_cast<wxRadioBox*>( iter->control )->SetSelection( *(int*) iter->dest );
159  break;
160 
161  case CFG_CTRL_TAB:
162  static_cast<wxNotebook*>( iter->control )->SetSelection( *(int*) iter->dest );
163  break;
164 
165  default:
166  wxASSERT_MSG( false, wxString(
167  "Unhandled control type for config restore: " ) << iter->type );
168  }
169  }
170  }
std::vector< CONFIG_CTRL_T > ctrls

Member Data Documentation

std::vector<CONFIG_CTRL_T> CONFIG_SAVE_RESTORE_WINDOW::ctrls
private

Definition at line 56 of file dialog_create_array.h.

bool& CONFIG_SAVE_RESTORE_WINDOW::valid
private

Definition at line 57 of file dialog_create_array.h.


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