40 #include <wx/msgdlg.h>
41 #include <wx/textctrl.h>
42 #include <wx/radiobox.h>
43 #include <wx/choice.h>
44 #include <wx/msgdlg.h>
52 wxCHECK_MSG( 0,
false,
wxT(
"Invalid member name") );
58 false,
wxT(
"Invalid member name") );
76 wxTextCtrl *control = (wxTextCtrl*)m_validatorWindow;
99 wxTextCtrl *control = (wxTextCtrl*)m_validatorWindow;
105 if (optional &&
value.empty()) {
126 wxCHECK_MSG( m_validatorWindow,
false,
127 wxT(
"No window associated with validator") );
128 wxCHECK_MSG( m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)),
false,
129 wxT(
"CSerialTextValidator is only for wxTextCtrl's") );
143 wxTextCtrl *control = (wxTextCtrl*)m_validatorWindow;
154 if (optional &&
value.empty()) {
194 wxControlWithItems *control = (wxControlWithItems*)m_validatorWindow;
202 int index =
value ? 0 : 1;
203 if (control->GetCount() == 3)
205 control->SetSelection(index);
208 control->SetSelection(control->GetCount() == 3 ? 0 : 1);
219 wxControlWithItems *control = (wxControlWithItems*)m_validatorWindow;
220 int index = control->GetSelection();
226 if (control->GetCount() == 3) {
251 wxCHECK_MSG( m_validatorWindow,
false,
252 wxT(
"No window associated with validator") );
253 wxCHECK_MSG( m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)),
false,
254 wxT(
"CSerialBoolValidator is only for wxRadioBox's") );
256 wxControlWithItems *control = (wxControlWithItems*)m_validatorWindow;
257 int count = control->GetCount();
258 wxCHECK_MSG( (optional ?
count == 3 :
count == 2),
false,
259 wxT(
"CSerialBoolValidator assosiated with invalid control") );
286 bool valueSet =
false;
305 CEnumeratedTypeValues::TValues::const_iterator it;
307 for (it = values.begin();it != values.end();++it, ++index) {
308 if (
value == it->second)
312 if (it == values.end())
315 if (optional && !defaultPtr)
321 wxRadioBox* radioBox = wxDynamicCast(m_validatorWindow, wxRadioBox);
323 radioBox->SetSelection(newValue);
327 wxChoice* choice = wxDynamicCast(m_validatorWindow, wxChoice);
329 choice->SetSelection(newValue);
342 wxRadioBox* radioBox = wxDynamicCast(m_validatorWindow, wxRadioBox);
344 index = radioBox->GetSelection();
346 wxChoice* choice = wxDynamicCast(m_validatorWindow, wxChoice);
348 index = choice->GetSelection();
361 if (index == 0 && !defaultPtr)
368 CEnumeratedTypeValues::TValues::const_iterator it;
369 for (it = values.begin(); it != values.end() && index > 0;++it, --index);
371 if (it == values.end())
397 wxCHECK_MSG( m_validatorWindow,
false,
398 wxT(
"No window associated with validator") );
400 wxRadioBox* radioBox = wxDynamicCast(m_validatorWindow, wxRadioBox);
401 wxChoice* choice = wxDynamicCast(m_validatorWindow, wxChoice);
403 wxCHECK_MSG( radioBox || choice,
405 wxT(
"CSerialEnumValidator is only for wxRadioBox or wxChoice") );
415 values.size() + 1 : values.size();
417 int ctrlCount = radioBox ? radioBox->GetCount() : choice->GetCount();
419 wxCHECK_MSG(
count == ctrlCount,
false,
420 wxT(
"CSerialEnumValidator assosiated with invalid control") );
431 : wxValidator(), m_Object(
val.m_Object), m_TitleChoice(
val.m_TitleChoice), m_Label(
val.m_Label), m_ShowErr(
val.m_ShowErr)
438 wxValidator::Copy(
val);
452 wxTextCtrl *control = (wxTextCtrl*)m_validatorWindow;
454 objects::CTitle& title =
dynamic_cast<objects::CTitle&
>(
m_Object);
458 if (title.IsSet() && !title.Set().empty()) {
459 switch (title.Set().front()->Which()) {
460 case objects::CTitle::C_E::e_Name:
461 value = title.Set().front()->GetName();
463 case objects::CTitle::C_E::e_Tsub:
464 value = title.Set().front()->GetTsub();
466 case objects::CTitle::C_E::e_Trans:
467 value = title.Set().front()->GetTrans();
469 case objects::CTitle::C_E::e_Jta:
470 value = title.Set().front()->GetJta();
472 case objects::CTitle::C_E::e_Iso_jta:
473 value = title.Set().front()->GetIso_jta();
475 case objects::CTitle::C_E::e_Ml_jta:
476 value = title.Set().front()->GetMl_jta();
478 case objects::CTitle::C_E::e_Coden:
479 value = title.Set().front()->GetCoden();
481 case objects::CTitle::C_E::e_Issn:
482 value = title.Set().front()->GetIssn();
484 case objects::CTitle::C_E::e_Abr:
485 value = title.Set().front()->GetAbr();
487 case objects::CTitle::C_E::e_Isbn:
488 value = title.Set().front()->GetIsbn();
505 wxTextCtrl *control = (wxTextCtrl*)m_validatorWindow;
509 objects::CTitle& title =
dynamic_cast<objects::CTitle&
>(
m_Object);
513 if (title.Set().empty()) {
514 item =
new objects::CTitle::C_E();
515 title.Set().push_back(item);
517 item = title.Set().front();
524 wxT(
"Error"), wxOK | wxICON_ERROR, (wxWindow*)(control));
529 case objects::CTitle::C_E::e_Name:
530 item->SetName(
value);
532 case objects::CTitle::C_E::e_Tsub:
533 item->SetTsub(
value);
535 case objects::CTitle::C_E::e_Trans:
536 item->SetTrans(
value);
538 case objects::CTitle::C_E::e_Jta:
541 case objects::CTitle::C_E::e_Iso_jta:
542 item->SetIso_jta(
value);
544 case objects::CTitle::C_E::e_Ml_jta:
545 item->SetMl_jta(
value);
547 case objects::CTitle::C_E::e_Coden:
548 item->SetCoden(
value);
550 case objects::CTitle::C_E::e_Issn:
551 item->SetIssn(
value);
553 case objects::CTitle::C_E::e_Abr:
556 case objects::CTitle::C_E::e_Isbn:
557 item->SetIsbn(
value);
569 wxCHECK_MSG( m_validatorWindow,
false,
570 wxT(
"No window associated with validator") );
571 wxCHECK_MSG( m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)),
false,
572 wxT(
"CSerialTitleValidator is only for wxTextCtrl's") );
virtual bool TransferFromWindow()
virtual bool TransferToWindow()
virtual bool TransferFromWindow()
bool CheckValidator() const
CSerialBoolValidator(CSerialObject &object, const string &memberName)
virtual bool TransferToWindow()
CSerialEnumValidator(CSerialObject &object, const string &memberName)
bool CheckValidator() const
virtual bool TransferFromWindow()
const CMemberInfo * m_MemberInfo
virtual bool TransferFromWindow()
virtual bool TransferToWindow()
bool CheckValidator() const
CSerialTextValidator(CSerialObject &object, const string &memberName)
virtual bool TransferFromWindow()
CSerialTitleValidator(CSerialObject &object, objects::CTitle::C_E::E_Choice title_choice, const string &label, bool show_err=true)
bool Copy(const CSerialTitleValidator &val)
bool CheckValidator() const
objects::CTitle::C_E::E_Choice m_TitleChoice
virtual bool TransferToWindow()
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
list< pair< string, TEnumValueType > > TValues
bool Optional(void) const
bool UpdateSetFlagNo(TObjectPtr object) const
set 'setFlag' to eSetNo and return true if previous value wasn't eSetNo
TConstObjectPtr GetDefault(void) const
TObjectPtr GetItemPtr(TObjectPtr object) const
void UpdateSetFlagYes(TObjectPtr object) const
set 'setFlag' to eSetYes
const TValues & GetValues(void) const
Get the list of name-value pairs.
TTypeInfo GetTypeInfo(void) const
bool GetSetFlagYes(TConstObjectPtr object) const
true if 'setFlag' is not eSetNo
const void * TConstObjectPtr
EPrimitiveValueType
Primitive value type.
static const TObjectType * SafeCast(TTypeInfo type)
@ ePrimitiveValueString
string|char*|const char*
@ ePrimitiveValueBool
bool
@ ePrimitiveValueEnum
enum
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
EPrimitiveValueType GetPrimitiveValueType(void) const
virtual void GetValueString(TConstObjectPtr objectPtr, string &value) const
ETypeFamily GetTypeFamily(void) const
virtual void SetValueBool(TObjectPtr objectPtr, bool value) const
virtual Int4 GetValueInt4(TConstObjectPtr objectPtr) const override
virtual bool GetValueBool(TConstObjectPtr objectPtr) const
virtual void SetValueInt4(TObjectPtr objectPtr, Int4 value) const override
virtual bool IsDefault(TConstObjectPtr object) const override
Check, whether the object contains default value.
virtual void SetValueString(TObjectPtr objectPtr, const string &value) const
const CEnumeratedTypeValues & Values(void) const
const GenericPointer< typename T::ValueType > T2 value
static bool CheckValueType(const CMemberInfo *memberInfo, EPrimitiveValueType type)
wxString ToWxString(const string &s)
string ToStdString(const wxString &s)
string ToAsciiStdString(const wxString &input)