Esempio n. 1
0
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() );
}
Esempio n. 2
0
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() );
}
Esempio n. 3
0
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() );
}
Esempio n. 4
0
void MyFrame::OnCalc(wxCommandEvent& event)
{
	std::string text	= invoice_list->GetValue().ToStdString();
	std::string target	= target_input->GetValue().ToStdString();
	Finder f = Finder();
	int n;
	Finder::readToInt(&n,target.c_str());
	f.setTarget(n);
	f.setValues(text);
	f.make();
	std::vector<int> result = f.getResult();

	if (result.size() == 0) {
		result_list->SetValue(L"拼凑失败!");
		return;
	}

	double sum = 0;
	std::stringstream result_str;
	for (std::vector<int>::size_type i = 0; i != result.size(); ++i) {
		double v = result[i] / 100.0;
		result_str << v;
		if (i != result.size() -1)
			result_str << " + ";
		sum += v;
	}
	result_str << " = ";
	result_str << sum;

	result_list->SetValue(result_str.str());
}
Esempio n. 5
0
void MyFrame::OnTestTextValue(wxCommandEvent& WXUNUSED(event))
{
    wxString value = m_textctrl->GetValue();
    m_textctrl->SetValue(value);
    if ( m_textctrl->GetValue() != value )
    {
        wxLogError(wxT("Text value changed after getting and setting it"));
    }
}
Esempio n. 6
0
void MyFrame::OnSolveButton(wxCommandEvent& evt) {
    Solver solver;
    
    if(!solver.set_goal(goalEntry->GetValue().ToStdString())) {
        wxMessageBox(wxT("Неверный формат целевой функции"), 
                     wxT("Ошибка"), wxOK|wxCENTER|wxICON_ERROR);
        return;
    }
    
    for(auto const& entry : restrEntries) {
        bool restrSet = solver.add_restriction(entry->GetValue().ToStdString());
        
        if(!restrSet) {
            wxMessageBox(wxT("Неверный формат ограничения"), 
                         wxT("Ошибка"), wxOK|wxCENTER|wxICON_ERROR);
            return;
        }
    }
    
    Solver invSolver = solver;
    invSolver.invert_to_dual();
    
    auto steps = solver.solve();
    auto invSteps = invSolver.solve();
    
    if(!steps.back().valid()) {
        wxMessageBox(wxT("Неразрешимая система"),
                     wxT("Ошибка"), wxOK|wxCENTER|wxICON_ERROR);
        return;
    }
    
    ClearNotebooks();
    FillNotebook(steps, directStepsBook);
    FillNotebook(invSteps, invertStepsBook);
}
void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent )
{
    wxString text;
    int      value;

    /* save old text in undo list if not already in edit */
    /* or the label to be edited is part of a block */
    if( m_CurrentText->GetFlags() == 0 ||
        m_Parent->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
        m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED );

    m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() );

    text = m_textLabel->GetValue();

    if( !text.IsEmpty() )
        m_CurrentText->m_Text = text;
    else if( !m_CurrentText->IsNew() )
    {
        DisplayError( this, _( "Empty Text!" ) );
        return;
    }

    m_CurrentText->SetOrientation( m_TextOrient->GetSelection() );
    text  = m_TextSize->GetValue();
    value = ReturnValueFromString( g_UserUnit, text );
    m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;

    if( m_TextShape )
        m_CurrentText->SetShape( m_TextShape->GetSelection() );

    int style = m_TextStyle->GetSelection();

    if( ( style & 1 ) )
        m_CurrentText->m_Italic = 1;
    else
        m_CurrentText->m_Italic = 0;

    if( ( style & 2 ) )
    {
        m_CurrentText->m_Bold  = true;
        m_CurrentText->m_Thickness = GetPenSizeForBold( m_CurrentText->m_Size.x );
    }
    else
    {
        m_CurrentText->m_Bold  = false;
        m_CurrentText->m_Thickness = 0;
    }

    m_Parent->OnModify();

    /* Make the text size as new default size if it is a new text */
    if( m_CurrentText->IsNew() )
        m_Parent->SetDefaultLabelSize( m_CurrentText->m_Size.x );

    m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() );
    m_Parent->GetCanvas()->MoveCursorToCrossHair();
    EndModal( wxID_OK );
}
Esempio n. 8
0
    MainFrame(const wxString& title) {
        wxXmlResource::Get()->LoadFrame(this, NULL, "Frame1");

        m_buttonFindAll = XRCCTRL(*this, "m_buttonFindAll", wxButton);
        m_textCtrlRegex = XRCCTRL(*this, "m_textCtrlRegex", wxTextCtrl);
        m_textCtrlString = XRCCTRL(*this, "m_textCtrlString", wxTextCtrl);
        m_textCtrlFindAll = XRCCTRL(*this, "m_textCtrlFindAll", wxTextCtrl);
        m_textCtrlRegex->Bind(wxEVT_TEXT, [=](wxCommandEvent &event){
            std::wstring a = m_textCtrlRegex->GetValue();
            auto R = re::compile(a);
            if (R){
                m_textCtrlRegex->SetBackgroundColour(wxColor(0,255,0));
                m_textCtrlRegex->Refresh();
                m_textCtrlFindAll->Clear();
                m_textCtrlFindAll->Refresh();
            }
            else{
                m_textCtrlRegex->SetBackgroundColour(wxColor(255, 0, 0));
                m_textCtrlRegex->Refresh();
                m_textCtrlFindAll->Clear();
                m_textCtrlFindAll->AppendText(std::to_string(re::getlasterror()));
                m_textCtrlFindAll->AppendText("\n");
                m_textCtrlFindAll->AppendText(re::getlasterrorstr());
                m_textCtrlFindAll->Refresh();
            }
        }
        );
        //------------------------------------------------------------------------------
        m_buttonFindAll->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [=](wxCommandEvent &event){
            m_textCtrlFindAll->Clear();
            std::wstring a = m_textCtrlRegex->GetValue();
            auto R = re::compile(a);
            if (R){
                std::wstring s = m_textCtrlString->GetValue();
                auto v = R->findall(s);
                for (auto i = v.begin(); i < v.end(); i++){
                    m_textCtrlFindAll->AppendText(*i);
                    m_textCtrlFindAll->AppendText("\n");
                }
            }
            m_textCtrlFindAll->Refresh();

        });
        //------------------------------------------------------------------------------

    }
int ValueFromTextCtrl( const wxTextCtrl& aTextCtr )
{
    int      value;
    wxString msg = aTextCtr.GetValue();

    value = ValueFromString( g_UserUnit, msg );

    return value;
}
void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent )
{
    wxString text;
    int      value;

    /* save old text in undo list if not already in edit */
    /* or the label to be edited is part of a block */
    if( m_CurrentText->GetFlags() == 0 ||
        m_Parent->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
        m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED );

    m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() );

    text = m_textLabel->GetValue();

    if( !text.IsEmpty() )
        m_CurrentText->SetText( text );
    else if( !m_CurrentText->IsNew() )
    {
        DisplayError( this, _( "Empty Text!" ) );
        return;
    }

    m_CurrentText->SetOrientation( m_TextOrient->GetSelection() );
    text  = m_TextSize->GetValue();
    value = ValueFromString( g_UserUnit, text );
    m_CurrentText->SetSize( wxSize( value, value ) );

    if( m_TextShape )
        /// @todo move cast to widget
        m_CurrentText->SetShape( static_cast<PINSHEETLABEL_SHAPE>( m_TextShape->GetSelection() ) );

    int style = m_TextStyle->GetSelection();

    m_CurrentText->SetItalic( ( style & 1 ) );

    if( ( style & 2 ) )
    {
        m_CurrentText->SetBold( true );
        m_CurrentText->SetThickness( GetPenSizeForBold( m_CurrentText->GetSize().x ) );
    }
    else
    {
        m_CurrentText->SetBold( false );
        m_CurrentText->SetThickness( 0 );
    }

    m_Parent->OnModify();

    // Make the text size the new default size ( if it is a new text ):
    if( m_CurrentText->IsNew() )
        SetDefaultTextSize( m_CurrentText->GetSize().x );

    m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() );
    m_Parent->GetCanvas()->MoveCursorToCrossHair();
    EndModal( wxID_OK );
}
Esempio n. 11
0
void NumValidatorTestCase::NoTrailingZeroes()
{
    // We need a locale with point as decimal separator.
    wxLocale loc(wxLANGUAGE_ENGLISH_UK, wxLOCALE_DONT_LOAD_DEFAULT);

    double value = 1.2;
    m_text->SetValidator(
        wxMakeFloatingPointValidator(3, &value, wxNUM_VAL_NO_TRAILING_ZEROES));

    wxValidator * const val = m_text->GetValidator();

    CPPUNIT_ASSERT( val->TransferToWindow() );
    CPPUNIT_ASSERT_EQUAL( "1.2", m_text->GetValue() );

    value = 1.234;
    CPPUNIT_ASSERT( val->TransferToWindow() );
    CPPUNIT_ASSERT_EQUAL( "1.234", m_text->GetValue() );
}
Esempio n. 12
0
void PrivateImportDailyFrame::OnOK(wxCommandEvent& ev)
{
	m_filename = file_path_input->GetValue().ToAscii();
	m_symbol = symbol_input->GetValue().ToAscii();
	//if (m_symbol.length() && m_filename.length())
	//	Show(false);
	//else
		Destroy();
	//Destroy();
}
void CDialogVolumeRename::OnOK(wxCommandEvent &e)
{
  wxString sValue = m_pText->GetValue();
  if(m_pVolumes->Rename(m_pThisVolume,sValue))
  {
    e.Skip(true);
  }
  else
  {
    mainApp::ShowError(m_pVolumes->GetLastError(),this);
  }
}
Esempio n. 14
0
	// Get the value of the argument from the textbox
	long getArgValue()
	{
		wxString val = text_control->GetValue();

		// Empty string means ignore it
		if (val == "")
			return -1;

		long ret;
		val.ToLong(&ret);
		return ret;
	}
Esempio n. 15
0
void NumValidatorTestCase::ZeroAsBlank()
{
    long value = 0;
    m_text->SetValidator(
        wxMakeIntegerValidator(&value, wxNUM_VAL_ZERO_AS_BLANK));

    wxValidator * const val = m_text->GetValidator();

    CPPUNIT_ASSERT( val->TransferToWindow() );
    CPPUNIT_ASSERT_EQUAL( "", m_text->GetValue() );

    value++;
    CPPUNIT_ASSERT( val->TransferFromWindow() );
    CPPUNIT_ASSERT_EQUAL( 0, value );
}
Esempio n. 16
0
void DataExportDlg::OnTextChanged(wxCommandEvent&)
{
    //if (!text->IsModified())
    //    return;
    string s = wx2s(text->GetValue());
    size_t colon = s.find(':');
    bool parsable = (ftk->check_syntax("print " + s) && colon != string::npos);
    FindWindow(wxID_OK)->Enable(parsable);
    if (parsable) {
        only_a_cb->SetValue(s.substr(0, colon) == "if a");
        vector<string> v = split_string(s.substr(colon + 1), ',');
        vm_foreach (string, i, v)
            *i = strip_string(*i);
        for (size_t i = 0; i < list->GetCount(); ++i)
            list->Check(i, contains_element(v, wx2s(cv[i])));
    }
}
Esempio n. 17
0
void WebFrame::OnFindText(wxCommandEvent& evt)
{
    int flags = 0;

    if(m_find_toolbar_wrap->IsChecked())
        flags |= wxWEBVIEW_FIND_WRAP;
    if(m_find_toolbar_wholeword->IsChecked())
        flags |= wxWEBVIEW_FIND_ENTIRE_WORD;
    if(m_find_toolbar_matchcase->IsChecked())
        flags |= wxWEBVIEW_FIND_MATCH_CASE;
    if(m_find_toolbar_highlight->IsChecked())
        flags |= wxWEBVIEW_FIND_HIGHLIGHT_RESULT;

    if(m_find_toolbar_previous->GetId() == evt.GetId())
        flags |= wxWEBVIEW_FIND_BACKWARDS;

    wxString find_text = m_find_ctrl->GetValue();
    long count = m_browser->Find(find_text, flags);

    if(m_findText != find_text)
    {
        m_findCount = count;
        m_findText = find_text;
    }

    if(count != wxNOT_FOUND || find_text.IsEmpty())
    {
        m_find_ctrl->SetBackgroundColour(*wxWHITE);
    }
    else
    {
        m_find_ctrl->SetBackgroundColour(wxColour(255, 101, 101));
    }

    m_find_ctrl->Refresh();

    //Log the result, note that count is zero indexed.
    if(count != m_findCount)
    {
        count++;
    }
    wxLogMessage("Searching for:%s  current match:%i/%i", m_findText.c_str(), count, m_findCount);
}
void CDialogVolumeAddNew::OnOK(wxCommandEvent &e)
{
  wxString sCopyFrom = m_pChoiceKit->GetStringSelection();
  m_sName = m_pText->GetValue();
  bool bError = true;
  {
    wxBusyCursor xxx;
    if(m_pVolumes->Create(sCopyFrom,m_sName))
    {
      bError = false;
      e.Skip();
    }
  }

  if(bError) // we want wxBusyCursor out of scope here
  {
    m_sName.Empty();
    mainApp::ShowError(m_pVolumes->GetLastError(),this);
  }
}
/**
 * Validates and saves (if valid) the type and offset of an array axis numbering
 *
 * @param offsetEntry the entry of the offset (text)
 * @param typeEntry the entry of the axis nmbering scheme (choice)
 * @param type the destination of the type if valid
 * @param offset the destination of the offset if valid
 * @param errors error string accumulator
 * @return if all valid
 */
static bool validateNumberingTypeAndOffset( const wxTextCtrl& offsetEntry,
                                            const wxChoice& typeEntry,
                                            DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T& type,
                                            int& offset,
                                            wxArrayString& errors )
{
    const int typeVal = typeEntry.GetSelection();
    // mind undefined casts to enums (should not be able to happen)
    bool ok = typeVal <= DIALOG_CREATE_ARRAY::NUMBERING_TYPE_MAX;

    if( ok )
    {
        type = (DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T) typeVal;
    }
    else
    {
        wxString err;
        err.Printf( _("Unrecognised numbering scheme: %d"), typeVal );
        errors.Add( err );
        // we can't proceed - we don't know the numbering type
        return false;
    }

    const wxString text = offsetEntry.GetValue();
    ok = getNumberingOffset( text, type, offset );

    if( !ok )
    {
        const wxString& alphabet = alphabetFromNumberingScheme( type );

        wxString err;
        err.Printf( _( "Could not determine numbering start from \"%s\": "
                       "expected value consistent with alphabet \"%s\"" ),
                    text, alphabet );
        errors.Add(err);
    }

    return ok;
}
Esempio n. 20
0
    void writeInfoPlistFile(wxTextFile& file)
    {
        if(not file.Exists()) {
            wxMessageBox(_("Cannot access or create file!"));
            return;
        }

        file.AddLine(wxT("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
        file.AddLine(wxT("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" "
                         "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"));
        file.AddLine(wxT("<plist version=\"1.0\">"));
        file.AddLine(wxT("<dict>\n"));
        file.AddLine(wxT("    <key>CFBundleExecutable</key>"));
        file.AddLine(wxT("    <string>") + m_project_name + wxT("</string>\n"));
        file.AddLine(wxT("    <key>CFBundleGetInfoString</key>"));
        file.AddLine(wxT("    <string>") + m_get_info_string->GetValue() + wxT("</string>\n"));
        file.AddLine(wxT("    <key>CFBundleIconFile</key>"));
        file.AddLine(wxT("    <string>") + m_icon_file->GetValue() + wxT("</string>\n"));
        file.AddLine(wxT("    <key>CFBundleIdentifier</key>"));
        file.AddLine(wxT("    <string>") + m_identifier->GetValue() + wxT("</string>\n"));
        file.AddLine(wxT("    <key>CFBundleSignature</key>"));
        file.AddLine(wxT("    <string>") + m_signature->GetValue() + wxT("</string>\n"));
        file.AddLine(wxT("    <key>CFBundleVersion</key>"));
        file.AddLine(wxT("    <string>") + m_version->GetValue() + wxT("</string>\n"));
        file.AddLine(wxT("    <key>CFBundleInfoDictionaryVersion</key>"));
        file.AddLine(wxT("    <string>6.0</string>\n"));
        file.AddLine(wxT("    <key>CFBundleDevelopmentRegion</key>"));
        file.AddLine(wxT("    <string>English</string>\n"));
        file.AddLine(wxT("    <key>CFBundlePackageType</key>"));
        file.AddLine(wxT("    <string>APPL</string>\n"));
        file.AddLine(wxT("    <key>CFBundleShortVersionString</key>"));
        file.AddLine(wxT("    <string>") + m_version->GetValue() + wxT("</string>\n"));
        file.AddLine(wxT("</dict>"));
        file.AddLine(wxT("</plist>"));

        if(not file.Write()) {
            wxMessageBox(_("Failed to write Info.plist file!"));
            return;
        }
    }
Esempio n. 21
0
 wxString getIconDestName() { return m_icon_file->GetValue(); }
Esempio n. 22
0
void FlashFrame::OnCallWithArg(wxCommandEvent& WXUNUSED(event))
{
    CallFlashFunc("string", m_funcname->GetValue(), m_funcarg->GetValue());
}
Esempio n. 23
0
void FlashFrame::OnCall(wxCommandEvent& WXUNUSED(event))
{
    CallFlashFunc("", m_funcname->GetValue());
}
Esempio n. 24
0
void MyFrame::OnURLEnter(wxCommandEvent& WXUNUSED(myEvent))
{
    mySafari->LoadURL(urlText->GetValue());
}
Esempio n. 25
0
void App::OnConvert(wxCommandEvent&)
{
    bool with_header = header->GetValue();
    int block_nr = browser->block_ch->GetSelection();
    int idx_x = browser->x_column->GetValue();
    int idx_y = browser->y_column->GetValue();
    bool has_err = browser->std_dev_cb->GetValue();
    int idx_err = browser->s_column->GetValue();
    bool dec_comma = browser->comma_cb->GetValue();

    wxArrayString paths;
    browser->filectrl->GetPaths(paths);
    string options;
    if (dec_comma)
        options = "decimal-comma";

    for (size_t i = 0; i < paths.GetCount(); ++i) {
        wxFileName old_filename(paths[i]);
        wxString fn = old_filename.GetName() + "." + ext_tc->GetValue();
        wxString new_filename = dirpicker->GetPath() + wxFILE_SEP_PATH + fn;
        if (!overwrite->GetValue() && wxFileExists(new_filename)) {
            int answer = wxMessageBox("File " + fn + " exists.\n"
                                      "Overwrite?",
                                      "Overwrite?",
                                      wxYES|wxNO|wxCANCEL|wxICON_QUESTION);
            if (answer == wxCANCEL)
                break;
            if (answer != wxYES)
                continue;

        }
        FILE *f = fopen(new_filename.mb_str(), "w");
        try {
            wxBusyCursor wait;
            xylib::DataSet const *ds = xylib::load_file(wx2s(paths[i]),
                                            browser->get_filetype(), options);
            xylib::Block const *block = ds->get_block(block_nr);
            xylib::Column const& xcol = block->get_column(idx_x);
            xylib::Column const& ycol = block->get_column(idx_y);
            xylib::Column const* ecol = (has_err ? &block->get_column(idx_err)
                                                 : NULL);
            const int np = block->get_point_count();

            if (with_header) {
                fprintf(f, "# converted by xyConvert %s from file:\n# %s\n",
                        xylib_get_version(),
                        wx2s(new_filename).c_str());
                if (ds->get_block_count() > 1)
                    fprintf(f, "# (block %d) %s\n", block_nr,
                                                    block->get_name().c_str());
                if (block->get_column_count() > 2) {
                    string xname = (xcol.get_name().empty() ? string("x")
                                                            : xcol.get_name());
                    string yname = (ycol.get_name().empty() ? string("y")
                                                            : ycol.get_name());
                    fprintf(f, "#%s\t%s", xname.c_str(), yname.c_str());
                    if (has_err) {
                        string ename = (ecol->get_name().empty() ? string("err")
                                                            : ecol->get_name());
                        fprintf(f, "\t%s", ename.c_str());
                    }
                    fprintf(f, "\n");
                }
            }

            for (int j = 0; j < np; ++j) {
                fprintf(f, "%.9g\t%.9g", xcol.get_value(j), ycol.get_value(j));
                if (has_err)
                    fprintf(f, "\t%.9g", ecol->get_value(j));
                fprintf(f, "\n");
            }
        } catch (runtime_error const& e) {
            wxMessageBox(e.what(), "Error", wxCANCEL|wxICON_ERROR);
        }
        fclose(f);
    }
}
Esempio n. 26
0
void NumValidatorTestCase::Interactive()
{
    // FIXME: This test fails on MSW buildbot slaves although works fine on
    //        development machine, no idea why. It seems to be a problem with
    //        wxUIActionSimulator rather the wxListCtrl control itself however.
    if ( wxGetUserId().Lower().Matches("buildslave*") )
        return;

    // Set a locale using comma as thousands separator character.
    wxLocale loc(wxLANGUAGE_ENGLISH_UK, wxLOCALE_DONT_LOAD_DEFAULT);

    m_text->SetValidator(
        wxIntegerValidator<unsigned>(NULL, wxNUM_VAL_THOUSANDS_SEPARATOR));

    // Create a sibling text control to be able to switch focus and thus
    // trigger the control validation/normalization.
    wxTextCtrl * const text2 = new wxTextCtrl(m_text->GetParent(), wxID_ANY);
    text2->Move(10, 80); // Just to see it better while debugging...
    wxFloatingPointValidator<float> valFloat(3);
    valFloat.SetRange(-10., 10.);
    text2->SetValidator(valFloat);

    wxUIActionSimulator sim;

    // Entering '-' in a control with positive range is not allowed.
    m_text->SetFocus();
    sim.Char('-');
    wxYield();
    CPPUNIT_ASSERT_EQUAL( "", m_text->GetValue() );

    // Neither is entering '.' or any non-digit character.
    sim.Text(".a+/");
    wxYield();
    CPPUNIT_ASSERT_EQUAL( "", m_text->GetValue() );

    // Entering digits should work though and after leaving the control the
    // contents should be normalized.
    sim.Text("1234567");
    wxYield();
    text2->SetFocus();
    wxYield();
    if ( loc.IsOk() )
        CPPUNIT_ASSERT_EQUAL( "1,234,567", m_text->GetValue() );
    else
        CPPUNIT_ASSERT_EQUAL( "1234567", m_text->GetValue() );


    // Entering both '-' and '.' in this control should work but only in the
    // correct order.
    sim.Char('-');
    wxYield();
    CPPUNIT_ASSERT_EQUAL( "-", text2->GetValue() );

    text2->SetInsertionPoint(0);
    sim.Char('.');
    wxYield();
    CPPUNIT_ASSERT_EQUAL( "-", text2->GetValue() );

    text2->SetInsertionPointEnd();
    sim.Char('.');
    wxYield();
    CPPUNIT_ASSERT_EQUAL( "-.", text2->GetValue() );

    // Adding up to three digits after the point should work.
    sim.Text("987");
    wxYield();
    CPPUNIT_ASSERT_EQUAL( "-.987", text2->GetValue() );

    // But no more.
    sim.Text("654");
    wxYield();
    CPPUNIT_ASSERT_EQUAL( "-.987", text2->GetValue() );

    // We can remove one digit and another one though.
    sim.Char(WXK_BACK);
    sim.Char(WXK_BACK);
    sim.Char('6');
    wxYield();
    CPPUNIT_ASSERT_EQUAL( "-.96", text2->GetValue() );


    // Also test the range constraint.
    text2->Clear();

    sim.Char('9');
    wxYield();
    CPPUNIT_ASSERT_EQUAL( "9", text2->GetValue() );

    sim.Char('9');
    wxYield();
    CPPUNIT_ASSERT_EQUAL( "9", text2->GetValue() );
}
Esempio n. 27
0
	string getParams()
	{
		return text_params->GetValue();
	}
Esempio n. 28
0
	string getName()
	{
		return text_name->GetValue();
	}
Esempio n. 29
0
/**
  * Callback invoked when user entered an URL and pressed enter
  */
void WebFrame::OnUrl(wxCommandEvent& WXUNUSED(evt))
{
    m_browser->LoadURL( m_url->GetValue() );
    m_browser->SetFocus();
    UpdateState();
}
Esempio n. 30
0
void DataExportDlg::OnOk(wxCommandEvent& event)
{
    wxConfig::Get()->Write(wxT("/exportPoints"), text->GetValue());
    event.Skip();
}