示例#1
0
void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) )
{
    const wxString choices[] =
    {
        _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"),
        _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"),
        _T("Eleven"), _T("Twelve"), _T("Seventeen"),
    };

    wxArrayInt selections;
    size_t count = wxGetMultipleChoices(selections,
                                        _T("This is a small sample\n")
                                        _T("A multi-choice convenience dialog"),
                                        _T("Please select a value"),
                                        WXSIZEOF(choices), choices,
                                        this);
    if ( count )
    {
        wxString msg;
        msg.Printf(wxT("You selected %u items:\n"), (unsigned)count);
        for ( size_t n = 0; n < count; n++ )
        {
            msg += wxString::Format(wxT("\t%u: %u (%s)\n"),
                                    (unsigned)n, (unsigned)selections[n],
                                    choices[selections[n]].c_str());
        }
        wxLogMessage(msg);
    }
    //else: cancelled or nothing selected
}
示例#2
0
/**
* @brief Construye y muestra una ventana para seleccionar multiples opciones de una lista de posibles
*
* Recibe una lista de posibles opciones y un cuadro de texto, arma una ventana 
* con una lista de checks para las opciones, marca las que estaban presentes
* en el cuadro de texto, y si el usuario presiona aceptar actualiza el contenido
* del cuadro de texto. La ventana se ejecuta directamente en este constructor.
*
* @param parent         ventana padre, para hacerlo modal
* @param title          titulo de la ventana 
* @param message        texto para mostrar sobre la lista de checks
* @param text           control de texto de donde tomar las opciones seleccionadas y donde guardar el resultado
* @param options_array  lista de opciones posibles
* @param comma_splits   indica si la coma separa opciones en el cuadro de texto, para pasar a mxUtils::Split
**/
mxMultipleChoiceEditor::mxMultipleChoiceEditor(wxWindow *parent, wxString title, wxString message, wxTextCtrl *text, wxArrayString &options_array, bool comma_splits) {
	if (last_multiple_choice_editor) delete last_multiple_choice_editor;
	last_multiple_choice_editor=this;
	
	wxArrayString splitted_array;
	wxArrayInt selection;
	mxUT::Split(text->GetValue(),splitted_array,comma_splits,true);
	options_array.Sort();
	int p=options_array.Index("all");
	if (p!=wxNOT_FOUND) {
		for (unsigned int i=0;i<splitted_array.GetCount();i++)
			selection.Add(p);
	} else {
		for (unsigned int i=0;i<splitted_array.GetCount();i++) {
			p=options_array.Index(splitted_array[i]);
			if (p!=wxNOT_FOUND) selection.Add(p);
		}
	}
	if (wxGetMultipleChoices(selection,message,title,options_array,parent)>=0) {
		wxString res;
		if (selection.GetCount()) {
			if (options_array[selection[0]].Contains(wxChar(' '))) 
				res=wxString("\"")<<options_array[selection[0]]<<"\"";
			else
				res=options_array[selection[0]];
			for (unsigned int i=1;i<selection.GetCount();i++) {
				if (options_array[selection[i]].Contains(wxChar(' '))) 
					res<<" \""<<options_array[selection[i]]<<"\"";
				else
					res<<" "<<options_array[selection[i]];
			}
		}
		text->SetValue(res);
	}
}
void preferences_dialog::on_showcase_details_button( wxCommandEvent &event )
{
#if ( setupUSE_SHOWCASE )

    // Make the array of listbox indexes to have selected
    wxArrayInt selected_index_numbers;
    wxString showcase_details_fields_string = the_configuration->Read( "/PLUCKER_DESKTOP/showcase_dialog_details_fields", "7" );

    // Converts the read string to an array of integers.
    utils_string::string_to_arrayint( showcase_details_fields_string, ';', &selected_index_numbers, true );

    //! \todo This should be shared somehow with the showcase dialog.
    const wxString showcase_field_names[] = { _( "Name" ),
                                              _( "URL" ),
                                              _( "Description" ),
                                              _( "Language" ),
                                              _( "Category" ),
                                              _( "Update Frequency" ),
                                              _( "Update Period" ),
                                              _( "Update Base" ),
                                              _( "Update Enabled" ),
                                              _( "Image Depth" ),
                                              _( "Maximum Depth" ),
                                              _( "Stay On Host" ),
                                              _( "Stay On Domain"),
                                              _( "URL Pattern" )
                                            };

    // Show the dialog
    size_t number_of_selected_items = wxGetMultipleChoices( selected_index_numbers,
                                      _( "Fields to display in details pane:" ),
                                      _( "Select desired fields" ),
                                      WXSIZEOF( showcase_field_names ), showcase_field_names,
                                      this );
    if ( number_of_selected_items != 0 )  {
        wxString details_pane_configuration_string;
        for ( size_t n = 0; n < number_of_selected_items; n++ ) {
            details_pane_configuration_string += wxString::Format( wxT( "%u;" ), selected_index_numbers[ n ] );
        }
        // Strips off the trailing ';'
        details_pane_configuration_string.RemoveLast();
        wxLogDebug( "Wrote out showcase_dialog_details_fields to config as=" + details_pane_configuration_string );
        the_configuration->Write( "/PLUCKER_DESKTOP/showcase_dialog_details_fields", details_pane_configuration_string );
        the_configuration->Flush();
    }

    selected_index_numbers.Clear();
#endif
}
示例#4
0
size_t wxGetMultipleChoices(wxArrayInt& selections,
                            const wxString& message,
                            const wxString& caption,
                            const wxArrayString& aChoices,
                            wxWindow *parent,
                            int x, int y,
                            bool centre,
                            int width, int height)
{
    wxString *choices;
    int n = ConvertWXArrayToC(aChoices, &choices);
    size_t res = wxGetMultipleChoices(selections, message, caption,
                                      n, choices, parent,
                                      x, y, centre, width, height);
    delete [] choices;

    return res;
}
void ProjectConfigurationPanel::OnButton2Click(wxCommandEvent& event)
{
    wxArrayString HeadersBase;
    if ( HeadersDetectorDlg(this,m_Project,HeadersBase).ShowModal() != wxID_OK )
    {
        cbMessageBox( _("Cancelled the search"), _("Cancelled"), wxOK | wxICON_WARNING, this );
        return;
    }

    if ( HeadersBase.IsEmpty() )
    {
        cbMessageBox( _("Didn't found any #include directive."), _("Error"), wxOK | wxICON_ERROR, this );
        return;
    }

    // Getting array of all known libraries
    ResultArray AllArray;
    for ( int i=0; i<rtCount; i++ )
    {
        m_KnownLibs[i].GetAllResults(AllArray);
    }
    wxArrayString NewLibs;

    // Sorting and removing duplicates and processing results
    HeadersBase.Sort();
    wxString Previous;
    for ( size_t i=0; i<HeadersBase.Count(); i++ )
    {
        if ( Previous != HeadersBase[i] )
        {
            Previous = HeadersBase[i];
            DetectNewLibs( Previous, AllArray, NewLibs );
        }
    }

    // Filtering detected results
    wxArrayString NewLibsFiltered;
    NewLibs.Sort();
    Previous.Clear();
    for ( size_t i=0; i<NewLibs.Count(); i++ )
    {
        if ( Previous != NewLibs[i] )
        {
            Previous = NewLibs[i];
            if ( m_ConfCopy.m_GlobalUsedLibs.Index(Previous) == wxNOT_FOUND )
            {
                NewLibsFiltered.Add( Previous );
            }
        }
    }

    if ( NewLibsFiltered.IsEmpty() )
    {
        cbMessageBox(
            _("Didn't found any missing library for your project.\n"
              "\n"
              "This may mean that you project is fully configured\n"
              "or that missing libraries are not yet recognized\n"
              "or fully supported in lib_finder plugin"),
            _("No libraries found"),
            wxOK | wxICON_ASTERISK,
            this );
        return;
    }

    wxArrayInt Choices;
    wxGetMultipleChoices(
        Choices,
        _("Select libraries to include in your project"),
        _("Adding new libraries"),
        NewLibsFiltered,
        this);

    if ( Choices.IsEmpty() )
    {
        return;
    }

    for ( size_t i=0; i<Choices.Count(); i++ )
    {
        wxString Library = NewLibsFiltered[ Choices[i] ];
        m_ConfCopy.m_GlobalUsedLibs.Add(Library);
        m_UsedLibraries->Append(GetUserListName(Library),new ListItemData(Library));
    }

    // Make sure that after the scan, used won't be able to manually
    // add currently selected "known" library (through '<' button)
    // which has just been added automatically
    wxTreeEvent ev;
    Onm_KnownLibrariesTreeSelectionChanged(ev);
}