void NumValidatorTestCase::TransferInt() { int value = 0; wxIntegerValidator<int> valInt(&value); valInt.SetWindow(m_text); CPPUNIT_ASSERT( valInt.TransferToWindow() ); CPPUNIT_ASSERT_EQUAL( "0", m_text->GetValue() ); value = 17; CPPUNIT_ASSERT( valInt.TransferToWindow() ); CPPUNIT_ASSERT_EQUAL( "17", m_text->GetValue() ); m_text->ChangeValue("foobar"); CPPUNIT_ASSERT( !valInt.TransferFromWindow() ); m_text->ChangeValue("-234"); CPPUNIT_ASSERT( valInt.TransferFromWindow() ); CPPUNIT_ASSERT_EQUAL( -234, value ); m_text->ChangeValue("9223372036854775808"); // == LLONG_MAX + 1 CPPUNIT_ASSERT( !valInt.TransferFromWindow() ); m_text->Clear(); CPPUNIT_ASSERT( !valInt.TransferFromWindow() ); }
void NumValidatorTestCase::TransferUnsigned() { unsigned value = 0; wxIntegerValidator<unsigned> valUnsigned(&value); valUnsigned.SetWindow(m_text); CPPUNIT_ASSERT( valUnsigned.TransferToWindow() ); CPPUNIT_ASSERT_EQUAL( "0", m_text->GetValue() ); value = 17; CPPUNIT_ASSERT( valUnsigned.TransferToWindow() ); CPPUNIT_ASSERT_EQUAL( "17", m_text->GetValue() ); m_text->ChangeValue("foobar"); CPPUNIT_ASSERT( !valUnsigned.TransferFromWindow() ); m_text->ChangeValue("-234"); CPPUNIT_ASSERT( !valUnsigned.TransferFromWindow() ); m_text->ChangeValue("234"); CPPUNIT_ASSERT( valUnsigned.TransferFromWindow() ); CPPUNIT_ASSERT_EQUAL( 234, value ); m_text->ChangeValue("18446744073709551616"); // == ULLONG_MAX + 1 CPPUNIT_ASSERT( !valUnsigned.TransferFromWindow() ); m_text->Clear(); CPPUNIT_ASSERT( !valUnsigned.TransferFromWindow() ); }
void NumValidatorTestCase::TransferFloat() { // We need a locale with point as decimal separator. wxLocale loc(wxLANGUAGE_ENGLISH_UK, wxLOCALE_DONT_LOAD_DEFAULT); float value = 0; wxFloatingPointValidator<float> valFloat(3, &value); valFloat.SetWindow(m_text); CPPUNIT_ASSERT( valFloat.TransferToWindow() ); CPPUNIT_ASSERT_EQUAL( "0.000", m_text->GetValue() ); value = 1.234f; CPPUNIT_ASSERT( valFloat.TransferToWindow() ); CPPUNIT_ASSERT_EQUAL( "1.234", m_text->GetValue() ); value = 1.2345678f; CPPUNIT_ASSERT( valFloat.TransferToWindow() ); CPPUNIT_ASSERT_EQUAL( "1.235", m_text->GetValue() ); m_text->ChangeValue("foobar"); CPPUNIT_ASSERT( !valFloat.TransferFromWindow() ); m_text->ChangeValue("-234.567"); CPPUNIT_ASSERT( valFloat.TransferFromWindow() ); CPPUNIT_ASSERT_EQUAL( -234.567f, value ); m_text->Clear(); CPPUNIT_ASSERT( !valFloat.TransferFromWindow() ); }
// Set the value in the textbox void setArgValue(long val) { if (val < 0) text_control->ChangeValue(""); else text_control->ChangeValue(S_FMT("%ld", val)); }
void DataExportDlg::on_widget_change() { wxString s = (only_a_cb->GetValue() ? wxT("if a: ") : wxT("all: ")); for (size_t i = 0; i < list->GetCount(); ++i) { if (list->IsChecked(i)) { if (!s.EndsWith(wxT(": ")) && !cv[i].empty()) s += wxT(", "); s += cv[i]; } } text->ChangeValue(s); FindWindow(wxID_OK)->Enable(true); }