Example #1
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);
	}
}
Example #2
0
void CMP_LIBRARY::SearchEntryNames( wxArrayString& aNames, const wxRegEx& aRe, bool aSort )
{
    if( !aRe.IsValid() )
        return;

    LIB_ALIAS_MAP::iterator it;

    for( it=aliases.begin();  it!=aliases.end();  it++ )
    {
        if( aRe.Matches( (*it).second->GetKeyWords() ) )
            aNames.Add( (*it).first );
    }

    if( aSort )
        aNames.Sort();
}
Example #3
0
/* static */
const wxArrayString& PicType::getSupportedPicNames()
{
    static wxArrayString picNames;

    if (picNames.size() == 0)
    {
        // cache the array with the names of supported PICs
        picNames.Alloc(s_arrSupported.size());
        for(unsigned int i=0;i<s_arrSupported.size();i++)
            picNames.Add(s_arrSupported[i].name);

        picNames.Sort();
    }

    return picNames;
}
Example #4
0
void AutoCompData::BuildString( wxArrayString& strings, wxString* output )
{
   wxASSERT( output );

   strings.Sort( CmpStringNoCase );
   output->Alloc( strings.GetCount() * 10 ); // Take a guess at the size.

   for ( int i=0; i < strings.GetCount(); i++ ) 
   {
      output->Append( strings[i] );
      output->Append( ' ' );
   }

   output->RemoveLast();
   output->Shrink();
}
Example #5
0
/* TextEntryPanel::TextEntryPanel
 * TextEntryPanel class constructor
 *******************************************************************/
TextEntryPanel::TextEntryPanel(wxWindow* parent)
	: EntryPanel(parent, "text")
{
	// Create the text area
	text_area = new TextEditor(this, -1);
	sizer_main->Add(text_area, 1, wxEXPAND, 0);

	// Add 'Text Language' choice to toolbar
	SToolBarGroup* group_language = new SToolBarGroup(toolbar, "Text Language", true);
	languages = TextLanguage::getLanguageNames();
	languages.Sort();
	languages.Insert("None", 0, 1);
	choice_text_language = new wxChoice(group_language, -1, wxDefaultPosition, wxDefaultSize, languages);
	choice_text_language->Select(0);
	group_language->addCustomControl(choice_text_language);
	toolbar->addGroup(group_language);

	// Add 'Word Wrap' checkbox to top sizer
	sizer_bottom->AddStretchSpacer();
	cb_wordwrap = new wxCheckBox(this, -1, "Word Wrapping");
	sizer_bottom->Add(cb_wordwrap, 0, wxEXPAND, 0);

	// Add 'Jump To' button to top sizer
	btn_jump_to = new wxButton(this, -1, "Jump To");
	sizer_bottom->Add(btn_jump_to, 0, wxEXPAND|wxRIGHT, 4);

	// Add 'Find/Replace' button to top sizer
	btn_find_replace = new wxButton(this, -1, "Find + Replace");
	sizer_bottom->Add(btn_find_replace, 0, wxEXPAND, 0);

	// Bind events
	choice_text_language->Bind(wxEVT_CHOICE, &TextEntryPanel::onChoiceLanguageChanged, this);
	text_area->Bind(wxEVT_STC_CHANGE, &TextEntryPanel::onTextModified, this);
	btn_find_replace->Bind(wxEVT_BUTTON, &TextEntryPanel::onBtnFindReplace, this);
	text_area->Bind(wxEVT_STC_UPDATEUI, &TextEntryPanel::onUpdateUI, this);
	cb_wordwrap->Bind(wxEVT_CHECKBOX, &TextEntryPanel::onWordWrapChanged, this);
	btn_jump_to->Bind(wxEVT_BUTTON, &TextEntryPanel::onBtnJumpTo, this);

	// Custom toolbar
	custom_toolbar_actions = "arch_scripts_compileacs;arch_scripts_compilehacs";
	toolbar->addActionGroup("Scripts", wxSplit(custom_toolbar_actions, ';'));

	Layout();
}
Example #6
0
/* TextEntryPanel::TextEntryPanel
 * TextEntryPanel class constructor
 *******************************************************************/
TextEntryPanel::TextEntryPanel(wxWindow* parent)
	: EntryPanel(parent, "text")
{
	// Create the text area
	text_area = new TextEditor(this, -1);
	sizer_main->Add(text_area, 1, wxEXPAND, 0);

	// Add 'Text Language' choice
	languages = TextLanguage::getLanguageNames();
	languages.Sort();
	languages.Insert("None", 0, 1);
	choice_text_language = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, languages);
	choice_text_language->Select(0);
	sizer_bottom->Add(new wxStaticText(this, -1, "Text Language:"), 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 4);
	sizer_bottom->Add(choice_text_language, 0, wxEXPAND);

	// Add 'Word Wrap' checkbox to top sizer
	sizer_top->AddStretchSpacer();
	cb_wordwrap = new wxCheckBox(this, -1, "Word Wrapping");
	sizer_top->Add(cb_wordwrap, 0, wxEXPAND, 0);

	// Add 'Jump To' button to top sizer
	btn_jump_to = new wxButton(this, -1, "Jump To");
	sizer_top->Add(btn_jump_to, 0, wxEXPAND|wxRIGHT, 4);

	// Add 'Find/Replace' button to top sizer
	btn_find_replace = new wxButton(this, -1, "Find + Replace");
	sizer_top->Add(btn_find_replace, 0, wxEXPAND, 0);

	// Bind events
	choice_text_language->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &TextEntryPanel::onChoiceLanguageChanged, this);
	text_area->Bind(wxEVT_STC_CHANGE, &TextEntryPanel::onTextModified, this);
	btn_find_replace->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &TextEntryPanel::onBtnFindReplace, this);
	text_area->Bind(wxEVT_STC_UPDATEUI, &TextEntryPanel::onUpdateUI, this);
	cb_wordwrap->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &TextEntryPanel::onWordWrapChanged, this);
	btn_jump_to->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &TextEntryPanel::onBtnJumpTo, this);

	// Custom toolbar
	custom_toolbar_actions = "arch_scripts_compileacs;arch_scripts_compilehacs";

	Layout();
}
Example #7
0
void CMP_LIBRARY::SearchEntryNames( wxArrayString& aNames,
                                    const wxString& aNameSearch,
                                    const wxString& aKeySearch,
                                    bool aSort )
{
    LIB_ALIAS_MAP::iterator it;

    for( it=aliases.begin();  it!=aliases.end();  it++ )
    {
        if( !aKeySearch.IsEmpty() && KeyWordOk( aKeySearch, (*it).second->GetKeyWords() ) )
            aNames.Add( (*it).first );

        if( !aNameSearch.IsEmpty() && WildCompareString( aNameSearch,
                                                         (*it).second->GetName(), false ) )
            aNames.Add( (*it).first );
    }

    if( aSort )
        aNames.Sort();
}
Example #8
0
void CMP_LIBRARY::GetEntryNames( wxArrayString& aNames, bool aSort, bool aMakeUpperCase )
{
    LIB_ALIAS_MAP::iterator it;

    for( it=aliases.begin();  it!=aliases.end();  it++ )
    {
        if( aMakeUpperCase )
        {
            wxString tmp = (*it).first;
            tmp.MakeUpper();
            aNames.Add( tmp );
        }
        else
        {
            aNames.Add( (*it).first );
        }
    }

    if( aSort )
        aNames.Sort();
}
Example #9
0
//=============================================================================
// Function: BuildRemoteList
// Purpose: Append Network Neighborhood items to the list.
// Notes: - Mounted gets transalated into Connected.  FilteredAdd is told
//          to ignore the Mounted flag since we need to handle it in a weird
//          way manually.
//        - The resulting list is sorted alphabetically.
//=============================================================================
static bool BuildRemoteList(wxArrayString& list, NETRESOURCE* pResSrc,
                            unsigned flagsSet, unsigned flagsUnset)
{
    // NN query depends on dynamically loaded library.
    if (!s_pWNetOpenEnum || !s_pWNetEnumResource || !s_pWNetCloseEnum)
    {
        wxLogError(_("Failed to load mpr.dll."));
        return false;
    }

    // Don't waste time doing the work if the flags conflict.
    if (flagsSet & wxFS_VOL_MOUNTED && flagsUnset & wxFS_VOL_MOUNTED)
        return false;

    //----------------------------------------------
    // Generate the list according to the flags set.
    //----------------------------------------------
    BuildListFromNN(list, pResSrc, flagsSet, flagsUnset);
    list.Sort(CompareFcn);

    //-------------------------------------------------------------------------
    // If mounted only is requested, then we only need one simple pass.
    // Otherwise, we need to build a list of all NN volumes and then apply the
    // list of mounted drives to it.
    //-------------------------------------------------------------------------
    if (!(flagsSet & wxFS_VOL_MOUNTED))
    {
        // generate.
        wxArrayString mounted;
        BuildListFromNN(mounted, pResSrc, flagsSet | wxFS_VOL_MOUNTED, flagsUnset & ~wxFS_VOL_MOUNTED);
        mounted.Sort(CompareFcn);

        // apply list from bottom to top to preserve indexes if removing items.
        ssize_t iList = list.GetCount()-1;
        for (ssize_t iMounted = mounted.GetCount()-1; iMounted >= 0 && iList >= 0; iMounted--)
        {
            int compare;
            wxString all(list[iList]);
            wxString mount(mounted[iMounted]);

            while (compare =
                     wxStricmp(list[iList].c_str(), mounted[iMounted].c_str()),
                   compare > 0 && iList >= 0)
            {
                iList--;
                all = list[iList];
            }


            if (compare == 0)
            {
                // Found the element.  Remove it or mark it mounted.
                if (flagsUnset & wxFS_VOL_MOUNTED)
                    list.RemoveAt(iList);
                else
                    s_fileInfo[list[iList]].m_flags |= wxFS_VOL_MOUNTED;

            }

            iList--;
        }
    }

    return true;
} // BuildRemoteList
bool GITHUB_GETLIBLIST::GetFootprintLibraryList( wxArrayString& aList )
{
    std::string fullURLCommand;
    int page = 1;
    int itemCountMax = 99;              // Do not use a valu > 100, it does not work
    strcpy( m_option_string, "application/json" );

    // Github max items returned is 100 per page

    if( !repoURL2listURL( m_repoURL, &fullURLCommand, itemCountMax, page ) )
    {
        wxString msg = wxString::Format( _( "malformed URL:\n'%s'" ), GetChars( m_repoURL ) );
        wxMessageBox( msg );
        return false;
    }

    // The URL lib names are relative to the server name.
    // so add the server name to them.
    wxURI repo( m_repoURL );
    wxString urlPrefix = repo.GetScheme() + wxT( "://" ) + repo.GetServer() + wxT( "/" );

    wxString errorMsg;
    const char  sep = ',';      // Separator fields, in json returned file
    wxString    tmp;
    int items_count_per_page = 0;
    std::string& json_image = GetBuffer();

    while( 1 )
    {
        bool success = remoteGetJSON( fullURLCommand, &errorMsg );

        if( !success )
        {
            wxMessageBox( errorMsg );
            return false;
        }


        for( unsigned ii = 0; ii < json_image.size(); ii++ )
        {
            if( json_image[ii] == sep || ii == json_image.size() - 1 )
            {
                if( tmp.StartsWith( wxT( "\"full_name\"" ) ) )
                {
                    #define QUOTE '\"'
                    // Remove useless quotes:
                    if( tmp[tmp.Length() - 1] == QUOTE )
                        tmp.RemoveLast();

                    if( tmp.EndsWith( m_libs_ext ) )
                    {
                        aList.Add( tmp.AfterLast( ':' ) );
                        int idx = aList.GetCount() - 1;

                        if( aList[idx][0] == QUOTE )
                            aList[idx].Remove( 0, 1 );

                        aList[idx].Prepend( urlPrefix );
                    }

                    items_count_per_page++;
                }

                tmp.Clear();
            }
            else
                tmp << json_image[ii];
        }

        if( items_count_per_page >= itemCountMax )
        {
            page++;
            repoURL2listURL( m_repoURL, &fullURLCommand, itemCountMax, page );
            items_count_per_page = 0;
            ClearBuffer();
        }
        else
            break;
    }

    aList.Sort();
    return true;
}
Example #11
0
/* TextEntryPanel::TextEntryPanel
 * TextEntryPanel class constructor
 *******************************************************************/
TextEntryPanel::TextEntryPanel(wxWindow* parent)
	: EntryPanel(parent, "text")
{
	// Create the text area
	text_area = new TextEditor(this, -1);
	sizer_main->Add(text_area, 1, wxEXPAND, 0);

	// Create the find+replace panel
	panel_fr = new FindReplacePanel(this, text_area);
	text_area->setFindReplacePanel(panel_fr);
	panel_fr->Hide();
	sizer_main->Add(panel_fr, 0, wxEXPAND|wxTOP, 8);
	sizer_main->AddSpacer(4);

	// Add 'Text Language' choice to toolbar
	SToolBarGroup* group_language = new SToolBarGroup(toolbar, "Text Language", true);
	languages = TextLanguage::getLanguageNames();
	languages.Sort();
	languages.Insert("None", 0, 1);
	choice_text_language = new wxChoice(group_language, -1, wxDefaultPosition, wxDefaultSize, languages);
	choice_text_language->Select(0);
	group_language->addCustomControl(choice_text_language);
	toolbar->addGroup(group_language);

	// Add 'Jump To' choice to toolbar
	SToolBarGroup* group_jump_to = new SToolBarGroup(toolbar, "Jump To", true);
	choice_jump_to = new wxChoice(group_jump_to, -1, wxDefaultPosition, wxSize(200, -1));
	group_jump_to->addCustomControl(choice_jump_to);
	toolbar->addGroup(group_jump_to);
	text_area->setJumpToControl(choice_jump_to);

	// Bind events
	choice_text_language->Bind(wxEVT_CHOICE, &TextEntryPanel::onChoiceLanguageChanged, this);
	text_area->Bind(wxEVT_STC_CHANGE, &TextEntryPanel::onTextModified, this);
	text_area->Bind(wxEVT_STC_UPDATEUI, &TextEntryPanel::onUpdateUI, this);

	// Custom toolbar
	custom_toolbar_actions = "arch_scripts_compileacs;arch_scripts_compilehacs";
	toolbar->addActionGroup("Scripts", wxSplit(custom_toolbar_actions, ';'));


	// --- Custom menu ---
	menu_custom = new wxMenu();
	theApp->getAction("ptxt_find_replace")->addToMenu(menu_custom);
	theApp->getAction("ptxt_jump_to_line")->addToMenu(menu_custom);

	// 'Code Folding' submenu
	wxMenu* menu_fold = new wxMenu();
	menu_custom->AppendSubMenu(menu_fold, "Code Folding");
	theApp->getAction("ptxt_fold_foldall")->addToMenu(menu_fold);
	theApp->getAction("ptxt_fold_unfoldall")->addToMenu(menu_fold);

	// 'Compile' submenu
	wxMenu* menu_scripts = new wxMenu();
	menu_custom->AppendSubMenu(menu_scripts, "Compile");
	theApp->getAction("arch_scripts_compileacs")->addToMenu(menu_scripts);
	theApp->getAction("arch_scripts_compilehacs")->addToMenu(menu_scripts);

	menu_custom->AppendSeparator();

	theApp->getAction("ptxt_wrap")->addToMenu(menu_custom);
	custom_menu_name = "Text";


	Layout();
}