void mxExportPreview::UpdatePrev ( ) {
    if (state!=mxEP_NONE && pid>0) {
        state=mxEP_UPDATE;
        the_process->Kill(pid,wxSIGKILL);
        return;
    }
    the_process = new wxProcess(this->GetEventHandler());

    mxSource * src = main_window->GetCurrentSource();
    if (!src) {
        SetMessage(_Z("No hay pseudocódigo para exportar"));
        state=mxEP_NONE;
        return;
    }

    wxString command;
    command<<config->pseint_command<<_T(" --nouser --norun \"")<<src->SaveTemp()<<_T("\" ");
    command<<mxProcess::GetProfileArgs();
    command<<" --draw \""<<temp_filename<<".psd"<<"\"";

    _LOG("mxExportPreview, command="<<command);
    pid = wxExecute(command,wxEXEC_ASYNC,the_process);
    if (pid<=0) {
        SetMessage(_Z("Error al intentar exportar"));
        return;
    }
    SetMessage("Actualizando...");
    state=mxEP_CHECK;
}
mxTestPanel::mxTestPanel(wxWindow *parent) : wxPanel(parent,wxID_ANY) {
	src = NULL;
	sizer = new wxBoxSizer(wxHORIZONTAL);
	eval_button = new wxButton(this,mxID_TESTPACK_RUN,_Z("Evaluar..."));
	label = new wxStaticText(this,wxID_ANY,_Z("Cargando ejercicio..."),wxDefaultPosition,wxDefaultSize);
	sizer->Add(eval_button,wxSizerFlags().Border(wxALL,5));
	sizer->Add(label,wxSizerFlags().Center().Centre().Border(wxALL,5));
	sizer->AddStretchSpacer();
	help_button = new wxButton(this,wxID_HELP,_Z(" ? "),wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT);
	sizer->Add(help_button,wxSizerFlags().Border(wxALL,5));
	SetSizerAndFit(sizer);
}
Exemple #3
0
mpz_class silvia_rng::get_random(size_t n)
{
	// If n is a multiple of 8, use the simple way
	if (n % 8 == 0)
	{
		std::vector<unsigned char> rand_val;
		rand_val.resize(n/8);

		// FIXME: we should really check the return value of
		//        RAND_bytes as failure indicates a lack of proper
		//        entropy
		RAND_bytes(&rand_val[0], n / 8);

		// Now convert it to MPZ
		mpz_class rand;

		mpz_import(_Z(rand), n / 8, 1, sizeof(unsigned char), 0, 0, &rand_val[0]);

		return rand;
	}
	else
	{
		size_t num_bytes = (n / 8) + 1;

		// Compute the mask
		size_t mask_bits = n % 8;
		unsigned char mask = 0;

		while (mask_bits--)
		{
			mask = mask << 1;
			mask = mask + 0x01;
		}

		std::vector<unsigned char> rand_val;
		rand_val.resize(num_bytes);

		// FIXME: we should really check the return value of
		//        RAND_bytes as failure indicates a lack of proper
		//        entropy
		RAND_bytes(&rand_val[0], num_bytes);

		rand_val[0] &= mask;

		// Now convert it to MPZ
		mpz_class rand;

		mpz_import(_Z(rand), num_bytes, 1, sizeof(unsigned char), 0, 0, &rand_val[0]);

		return rand;
	}
}
mxVarWindow::mxVarWindow(wxWindow *parent):wxPanel(parent,wxID_ANY,wxDefaultPosition,wxSize(150,100)) {
	wxSizer *sizer=new wxBoxSizer(wxVERTICAL);
	tree = new wxTreeCtrl(this,wxID_ANY,wxDefaultPosition,wxSize(150,50),wxTR_FULL_ROW_HIGHLIGHT|wxTR_NO_LINES|wxTR_HIDE_ROOT|wxTR_SINGLE|wxTR_NO_BUTTONS/*|wxTR_ROW_LINES*/);
	
	wxArrayString img_files(LV_MAX+2,""); // +2 por proc y sub
	img_files[LV_DEFINIDA                                   ] = img_files[0                                ] = "vt_desc.png";
	img_files[LV_DEFINIDA| LV_LOGICA                        ] = img_files[LV_LOGICA                        ] = "vt_log.png";
	img_files[LV_DEFINIDA|           LV_NUMERICA            ] = img_files[          LV_NUMERICA            ] = "vt_num.png";
	img_files[LV_DEFINIDA| LV_LOGICA|LV_NUMERICA            ] = img_files[LV_LOGICA|LV_NUMERICA            ] = "vt_log_num.png";
	img_files[LV_DEFINIDA|                       LV_CARACTER] = img_files[                      LV_CARACTER] = "vt_car.png";
	img_files[LV_DEFINIDA| LV_LOGICA            |LV_CARACTER] = img_files[LV_LOGICA|            LV_CARACTER] = "vt_log_car.png";
	img_files[LV_DEFINIDA|           LV_NUMERICA|LV_CARACTER] = img_files[          LV_NUMERICA|LV_CARACTER] = "vt_car_num.png";
	img_files[LV_DEFINIDA| LV_LOGICA|LV_NUMERICA|LV_CARACTER] = img_files[LV_LOGICA|LV_NUMERICA|LV_CARACTER] = "vt_desc.png";
	img_files[LV_MAX] = "vt_proc.png";
	img_files[LV_MAX+1] = "vt_sub.png";
	
	wxImageList* imglist = new wxImageList(16, 16,true,img_files.GetCount());
	for(unsigned int i=0;i<img_files.GetCount();i++)
		imglist->Add(wxBitmap(utils->JoinDirAndFile(config->images_path,img_files[i]),wxBITMAP_TYPE_PNG));
	tree->AssignImageList(imglist);
	tree_root=tree_current=tree->AddRoot("");
	tree->SetToolTip(tooltip=utils->FixTooltip(_Z("En esta sección se listan las variables que utiliza un algoritmo. El ícono a la izquierda del nombre indica los potenciales tipos de datos que determina el intérprete en caso de que el tipo de variable pueda deducirse antes de ejecutar el algoritmo. Puede seleccionar una para resaltarla en el pseudocódigo.")));
	sizer->Add(tree,wxSizerFlags().Proportion(1).Expand());
	SetSizer(sizer);
}
bool mxTestPanel::Load (const wxString & path, const wxString &key, mxSource *src) {
	this->path=path; this->key=key; this->src=src;
	if (!pack.Load(path,key)) return false;
	if (pack.GetConfigInt("version requerida")>PACKAGE_VERSION) {
		wxMessageBox(_Z("Debe actualizar PSeInt para poder abrir este ejercicio"),_Z("Error"),wxID_OK|wxICON_ERROR,this);
		return false;
	}
	if (pack.GetConfigBool("creator")) {
		Run("--create_new_test_package=1");
		return false;
	}
	label->SetLabel(_Z(" <- click aquí para evaluar su respuesta"));
	sizer->Layout();
	src->SetText(pack.GetBaseSrc());
	return true;
}
void mxVarWindow::OnTreeClick2 (wxTreeEvent & evt) {
	if (debug->debugging) { // cuando se depura, sirve para inspeccionar
		if (!debug->paused) return;
		wxTreeItemId it=evt.GetItem();
		if (it.IsOk() && tree->GetItemParent(it)!=tree_root) {
			tree->SelectItem(it);
			debug_panel->ShowInEvaluateDialog(tree->GetItemText(it).BeforeFirst('['));
		}
	} else { // cuando no se depura muestra un menu contextual
		if (tree->GetItemParent(evt.GetItem())==tree_root) return;
		wxMenu menu;
		menu.Append(mxID_VARS_DEFINIR,_Z("Definir variable...")); // para mostrar en el dialogo
		menu.Append(mxID_VARS_ADD_TO_DESKTOP_TEST,_Z("Agregar la variable a la Prueba de Escritorio...")); // para mostrar en el dialogo
		PopupMenu(&menu);
	}
}
wxString ConfigManager::LoadProfile(wxString pname) {
	profile=pname;
	if (lang.Load(DIR_PLUS_FILE(profiles_dir,profile))) {
		return lang.descripcion.c_str();
	} else {
		return _Z("Esta opcion le permite definir su propia configuracion. Utilice el boton \"Personalizar...\" para definirla.");
	}
}
Exemple #8
0
DM_Z DIV_ZZ_Z (DM_Z X1, DM_Z X2)
{
    DM_N t;  //Объявляем переменную счётчик
    DM_N natX1 = TRANS_Z_N (X1); //Объявляем натуральные аналоги целым числам
    DM_N natX2 = TRANS_Z_N (X2);
    if (!NZER_N_B(natX2))    //Если делитель равен нулю. выдаем ошибку
        printf("Делитель равен нулю.");
    else if (COM_NN_D(natX1, natX2)==2)  //Если Первое число больше второго:
    {
        do
        {
            natX1=SUB_NN_N(natX1, natX2); //Вычитаем из большего числа меньшее
            t=ADD_1N_N(t);      //Наращиваем t
        }
        while (COM_NN_D(natX1, natX2)==2); //Цикл пока делимое больше делителя
        t = TRANS_N_Z(t);  //Переводим результат в целое
        if (POZ_Z_D(X1)==1 && POZ_Z_D(X2)==2 || POZ_Z_D(X1)==2 && POZ_Z_D(X2)==1)
           t= MUL_Z-_Z(t); //Если исходные числа имеют разные знаки,
                           //Поменять знак у результата
        return t;
    }

    else if (COM_NN_D(natX1, natX2)==1) //Если второе число больше первого:
    {                                   //Выполняем аналогичные действия.
        do
        {
            natX1=SUB_NN_N(natX1,natX1);
            t=ADD_1N_N(t);
        }
        while (COM_NN_D(natX1, natX1)==2);
        t = TRANS_N_Z(t);
        if (POZ_Z_D(X1)==1 && POZ_Z_D(X2)==2 || POZ_Z_D(X1)==2 && POZ_Z_D(X2)==1)
           t= MUL_Z-_Z(t);
        return t;
    }
    else if (COM_N_D(natX1, natX2)==0)  // Если числа равны:
    {
        t = TRANS_N_Z(t);  // Переводим t в целое
        t.a[0]=1;  //Присваиваем результату значение 1
        t.n=1;
        if ((POZ_Z_D(X2)==2 && POZ_Z_D(X1)==1) || (POZ_Z_D(X2)==1 && POZ_Z_D(X1)==2))
        t.b=!t.b; //Если исходные числа имели разные знаки, меняем знак результата.
    }
    return t;
}
Exemple #9
0
std::string silvia_attribute::int_rep()
{
	char* int_rep_str = mpz_get_str(NULL, 10, _Z(attr_rep));
	
	std::string rv = std::string(int_rep_str);
	
	free(int_rep_str);
	
	return rv;
}
Exemple #10
0
void silvia_string_attribute::from_rep(const mpz_class& rep)
{
	this->attr_rep = rep;
	
	size_t count;
	
	char* rep_data = (char*) mpz_export(NULL, &count, 1, sizeof(char), 1, 0, _Z(this->attr_rep));
	
	value = std::string(rep_data, count);
	
	free(rep_data);
}
Exemple #11
0
silvia_string_attribute& silvia_string_attribute::operator=(const std::string value)
{
	this->value = value;

	if (this->value.size() > (SYSPAR(l_m) / 8))
	{
		// Truncate!
		this->value = this->value.substr(0, SYSPAR(l_m) / 8);
	}

	mpz_import(_Z(this->attr_rep), this->value.size(), 1, sizeof(char), 1, 0, this->value.c_str());
}
void mxProfile::LoadProfile() {
	if (!text) return;
	wxString pname=GetListSelection();
	if (pname==_PERSONALIZADO) { 
		text->SetValue(_Z("Puede utilizar el botón \"Personalizar\" para definir su propia configuración.")); 
		return;
	}
	int p=perfiles.Index(pname);
	if (p==wxNOT_FOUND) return; // no deberia ocurrir nunca
	config->LoadProfile(pname);
	text->SetValue(descripciones[p]);
}
Exemple #13
0
    Parser::Parser(const vector<Production>& productions, const string& parserTablePath) : BasicParser(productions), parserTablePath(parserTablePath)
    {
#ifdef _DEBUG
        stream.open("ParserResult.txt", fstream::out | fstream::binary);
#endif
        // String Begin
        Rule quotationMarks = Rule('\"', &context);
        Rule ruleString = quotationMarks + *!quotationMarks + quotationMarks;
        ruleString.buildDFA();
        ruleString.setShowName("\"{String}\"");
        Production::Item itemString(ruleString);
        // String End

        // Digit Start
        Rule _0('0', &context);
        Rule _9('9', &context);
        Rule _0_9  = _0 - _9;
        Rule ruleDigit = +_0_9;
        ruleDigit.buildDFA();
        ruleDigit.setShowName("\"{Digit}\"");
        Production::Item itemDigit(ruleDigit);
        // Digit End

        // Real Start
        Rule _point('.', &context);
        Rule ruleReal = *_0_9 + _point + +_0_9;
        ruleReal.buildDFA();
        ruleReal.setShowName("\"{Real}\"");
        Production::Item itemReal(ruleReal);
        // Real End

        // Letter Start
        Rule _('_', &context);
        Rule _a('a', &context);
        Rule _z('z', &context);
        Rule _A('A', &context);
        Rule _Z('Z', &context);
        Rule _a_z = _a - _z;
        Rule _A_Z = _A - _Z;
        Rule ruleLetter = ((+_ + ruleDigit) |
            (+(_ | _a_z | _A_Z))) +
            *(_ | ruleDigit | _a_z | _A_Z);
        ruleLetter.buildDFA();
        ruleLetter.setShowName("\"{Letter}\"");
        Production::Item itemLetter(ruleLetter);
        // Letter End

        vts.push_back(pair<string, Production::Item>("{String}", itemString));
        vts.push_back(pair<string, Production::Item>("{Digit}",  itemDigit));
        vts.push_back(pair<string, Production::Item>("{Real}",   itemReal));
        vts.push_back(pair<string, Production::Item>("{Letter}", itemLetter));
    }
wxString ConfigManager::GetTTYCommand ( ) {
	if (use_psterm) return psterm_command+(config->use_dark_psterm?" --darktheme":"");
	if (tty_command==_no_tty) { // tratar de detectar automaticamente un terminal adecuado
		if (utils->GetOutput("xterm -version").Len()) {
			tty_command = "xterm -T \"$name\" -e";
		} else if (utils->GetOutput("lxterminal -version").Len()) {
			tty_command = "lxterminal -T \"$name\" -e";
		} else if (utils->GetOutput("gnome-terminal --version").Len()) {
			tty_command = "gnome-terminal --hide-menubar --disable-factory -t \"$name\" -x";
		} else if (utils->GetOutput("konsole --version").Len()) {
			if (utils->GetOutput("konsole --version").Find("KDE: 3")==wxNOT_FOUND) {
				tty_command = "konsole -e";
				wxMessageBox(_Z("PSeInt requiere de una terminal para ejecutar los algoritmos. La unica terminal conocida encontrada en sus sistema es konosole, de KDE4. Esta genera problemas para ejecutar los algoritmos paso a paso y para obtener correctamente los errores en tiempo de ejecucion. Se recomienda instalar xterm."),_Z("Terminal de ejecucion"));
			} else {
				tty_command = "konsole --nomenubar --notoolbar -T \"$name\" -e";
			}
		} else {
			wxMessageBox(_Z("No se ha encontrado una terminal conocida.\nInstale xterm,konsole o gnome-terminal; o\nconfigure el parametro \"Comando del\nTerminal\" en el cuadro de Preferencias.\""),_Z("Terminal de ejecucion"));
		}
	}
	return tty_command;
}
void mxExportPreview::OnProcTerminate (wxProcessEvent & event) {
    _LOG("mxExportPreview::OnProcessTerminate");
    if (pid<=0||!the_process||event.GetPid()!=pid) return;
    int exit_code = event.GetExitCode();
    delete the_process;
    the_process=NULL;
    if (exit_code!=0) {
        SetMessage(_Z("Error al intentar exportar"));
        state=mxEP_NONE;
        return;
    }

    switch(state) {

    case mxEP_NONE: { // no deberia pasar nunca
        return;
    }
    break;

    case mxEP_CHECK: { // estaba armando el psd, ahora exportar
        wxString command;
        command<<config->psexport_command<<_T(" \"")<<temp_filename<<".psd"<<_T("\" \"")<<temp_filename<<".exp"<<_T("\"");
        if (config->lang[LS_BASE_ZERO_ARRAYS]) command<<_T(" --base_zero_arrays=1");
        int lang_id = mxID_FILE_EXPORT_LANG_FIRST+1+combo_lang->GetCurrentSelection();
        command<<" --lang="<<utils->GetExportLangCode(lang_id);

        the_process = new wxProcess(this->GetEventHandler());
        _LOG("mxExportPreview, command="<<command);
        pid = wxExecute(command,wxEXEC_ASYNC,the_process);
        state = mxEP_EXP;

    }
    break;

    case mxEP_EXP: { // estaba exportando, mostrar
        state = mxEP_NONE;
        code_ctrl->LoadFile(temp_filename+".exp");
    }
    break;

    case mxEP_UPDATE: {  // se interrumpio lo que estaba haciendo para empezar otra vez
        pid = 0;
        state = mxEP_NONE;
        UpdatePrev();
    }
    break;

    default:
        break;
    }
}
mxExportPreview::mxExportPreview():wxFrame(main_window,wxID_ANY,_Z("Exportar - Vista previa"),wxDefaultPosition,wxDefaultSize) {

    pid=0;
    state=mxEP_NONE;

    static int tid=0;
    temp_filename = DIR_PLUS_FILE(config->temp_dir,wxString("temp_ep_")<<tid++);

    wxBoxSizer *top_sizer = new wxBoxSizer(wxHORIZONTAL);
    wxSizerFlags sz;
    sz.Center();
    top_sizer->Add( new wxStaticText(this,wxID_ANY,_Z(" Lenguaje: ")),sz );
    wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);

    wxArrayString langs_list;
    for (int id = mxID_FILE_EXPORT_LANG_FIRST+1; id < int(mxID_FILE_EXPORT_LANG_LAST); id++)
        langs_list.Add(utils->GetExportLangName(id).AfterFirst(' '));
    combo_lang = new wxComboBox(this,mxID_EXPPREV_LANG,"",wxDefaultPosition,wxDefaultSize,langs_list,wxCB_READONLY);
    combo_lang->Select(mxID_FILE_EXPORT_LANG_CPP03-mxID_FILE_EXPORT_LANG_FIRST-1);

    top_sizer->Add(combo_lang,sz);
    top_sizer->Add(new wxButton(this,mxID_EXPPREV_UPDATE,_Z("Actualizar")),sz);
    top_sizer->AddStretchSpacer();
    top_sizer->Add(	new wxBitmapButton(this,mxID_EXPPREV_COPY,wxBitmap(DIR_PLUS_FILE(config->images_path,"tools/copiar.png"),wxBITMAP_TYPE_PNG)), sz);
    top_sizer->Add(	new wxBitmapButton(this,mxID_EXPPREV_SAVE,wxBitmap(DIR_PLUS_FILE(config->images_path,"tools/guardar.png"),wxBITMAP_TYPE_PNG)), sz);
    main_sizer->Add(top_sizer,wxSizerFlags().Proportion(0).Expand());

    code_ctrl = new wxStyledTextCtrl(this,wxID_ANY);
    code_ctrl->SetMarginType (0, wxSTC_MARGIN_NUMBER);
    code_ctrl->SetMarginWidth (0, code_ctrl->TextWidth (wxSTC_STYLE_LINENUMBER, " XXXXX"));
    main_sizer->Add(code_ctrl,wxSizerFlags().Proportion(1).Expand());

    SetSizer(main_sizer);
    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
    Show();
    UpdatePrev();
}
void mxProfile::Search ( ) {
	list->DeleteAllItems();
	int sel=-1, cont=0;
	wxString pat=search->GetValue().Lower();
	for(unsigned int i=0;i<perfiles.GetCount();i++) {
		if (pat.Len()==0 || perfiles[i].Lower().Contains(pat) || descripciones[i].Lower().Contains(pat)) {
			list->InsertItem(cont,perfiles[i],i);
			if (perfiles[i].Lower()==config->profile.Lower()) sel=cont;
			cont++;
		}
		
	}
	if (!pat) {
		list->InsertItem(cont,_PERSONALIZADO,perfiles.GetCount());
		if (sel==-1) sel=cont;
		cont++;
	}
	if (sel!=-1) SetListSelection(sel); 
	else text->SetValue(wxString()<<_Z("El perfil seleccionado actualmente (")<<config->profile<<_Z(") no aparece en esta búsqueda."));
}
Exemple #18
0
bool silvia_boolean_attribute::get_value()
{
	return (mpz_get_ui(_Z(attr_rep)) == 1);
}
Exemple #19
0
 _OPC("svt"  , 0x24, F_RR , 0        , _X(TSREG)),
 _OPC("sex"  , 0x25, F_RR , 0        , _X(TSREG)),
 _OPC("svx"  , 0x26, F_RR , 0        , _X(TSREG)),
 _OPC("sve"  , 0x27, F_RR , 0        , _X(TSREG)),
 _OPC("sic"  , 0x28, F_RR , 0        , _X(TSREG)),
 _OPC("sfr"  , 0x29, F_RR , 0        , _X(TSREG)),
 _OPC("spm"  , 0x2a, F_RR , 0        , _X(TSREG)),
 _OPC("ssm"  , 0x2b, F_RR , 0        , _X(TSREG)),
 _OPC("spsw" , 0x2c, F_RR , 0        , _X(TSREG)),
 _OPC("rpn"  , 0x2d, F_RR , 0        , _X(TSREG)),
 _OPC("smvl" , 0x2e, F_RR , 0        , _X(TSREG)),
 _OPC("svl"  , 0x2f, F_RR , 0        , _X(TSREG)),
 _OPC("scr"  , 0x30, F_RR , FS_EXTOP , _XYZ(TSREG, TSREG|TLI127, TSREG|TLM0M1)),
 _OPC("sas"  , 0x31, F_RR , 0        , _XZ(TSREG, TSREG|TLM0M1)),
 //_OPC("lmir" , 0x32, F_RR , 0      , _Z(TLM0M1)), //------offset------
 _OPC("ldvecc",  0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),         //0x00
 _OPC("ldfpec",  0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x01
 _OPC("ldocmcc", 0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x02
 _OPC("ldbccc",  0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x03
 _OPC("lddidr",  0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x04
 _OPC("ldsar",   0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x05
 _OPC("ldicmcc", 0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x06
 _OPC("ldsidr",  0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x07
 _OPC("ldbpfc",  0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x08
 _OPC("ldusrcc", 0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x09
 _OPC("ldiphcc", 0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x0a
 _OPC("ldspec",  0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x0b
 _OPC("ldvarec", 0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x0c
 _OPC("ldvldec", 0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x0d
 _OPC("ldmnubc", 0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x0e
 _OPC("ldsracc", 0x32, F_RR , FS_EXTOP  , _Z(TSREG|TLM0M1)),	  //0x0f
mxProfile::mxProfile(wxWindow *parent):wxDialog(parent,wxID_ANY,_Z("Opciones del Lenguaje"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER),old_config(LS_INIT) {
	
	text=NULL; // para que no procese el evento de seleccion al crear la lista
	
	old_config=config->lang;
	old_profile=config->profile;
	
	wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
	
	wxBoxSizer *search_sizer = new wxBoxSizer(wxHORIZONTAL);
	search=new wxTextCtrl(this,wxID_FIND,"");
	search_sizer->Add(new wxStaticText(this,wxID_ANY,_Z("Buscar: ")),wxSizerFlags().Center());
	search_sizer->Add(search,wxSizerFlags().Proportion(1).Expand());
	
	sizer->Add(search_sizer,wxSizerFlags().Proportion(0).Expand().Border(wxALL,5));
	
	wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL);

	wxDir dir(config->profiles_dir);
	if ( dir.IsOpened() ) {
		wxString filename;
		wxString spec;
		bool cont = dir.GetFirst(&filename, spec , wxDIR_FILES);
		while ( cont ) {
			perfiles.Add(filename);
			cont = dir.GetNext(&filename);
		}
	}
	perfiles.Sort(comp_nocase);
	for(unsigned int i=0;i<perfiles.GetCount();i++) { 
		LangSettings l(LS_INIT); l.Load(DIR_PLUS_FILE(config->profiles_dir,perfiles[i]));
		descripciones.Add(l.descripcion.c_str());
	}
	
	list = new wxListCtrl(this,wxID_ANY,wxDefaultPosition,wxSize(200,200),wxLC_REPORT|wxLC_NO_HEADER|wxLC_SINGLE_SEL);
	list->InsertColumn(0,_Z("Perfil"));
	wxImageList *iml = new wxImageList(24,24,true);
	wxBitmap noimage(DIR_PLUS_FILE(DIR_PLUS_FILE(config->profiles_dir,"icons"),"null.png"),wxBITMAP_TYPE_PNG);
	for(unsigned int i=0;i<perfiles.GetCount();i++) {
		wxString ficon=DIR_PLUS_FILE(DIR_PLUS_FILE(config->profiles_dir,"icons"),perfiles[i]+".png");
		if (wxFileName::FileExists(ficon))
			iml->Add(wxBitmap(ficon,wxBITMAP_TYPE_PNG));
		else
			iml->Add(noimage);
	}
	iml->Add(wxBitmap(DIR_PLUS_FILE(DIR_PLUS_FILE(config->profiles_dir,"icons"),"personalizado.png"),wxBITMAP_TYPE_PNG));
	list->AssignImageList(iml,wxIMAGE_LIST_SMALL);
	
	Search();
	
	text = new wxTextCtrl(this,wxID_ANY,_T(""),wxDefaultPosition,wxDefaultSize,wxTE_MULTILINE|wxTE_READONLY);
	LoadProfile();
	
	wxButton *options_button = new mxBitmapButton (this, wxID_ABOUT, bitmaps->buttons.next, _Z("Personalizar..."));
	wxButton *ok_button = new mxBitmapButton (this, wxID_OK, bitmaps->buttons.ok, _Z("Aceptar"));
	wxButton *cancel_button = new mxBitmapButton (this, wxID_CANCEL, bitmaps->buttons.cancel, _Z("Cancelar"));
	button_sizer->Add(options_button,wxSizerFlags().Border(wxALL,5).Proportion(0).Expand());
	button_sizer->AddStretchSpacer(1);
	button_sizer->Add(cancel_button,wxSizerFlags().Border(wxALL,5).Proportion(0).Expand());
	button_sizer->Add(ok_button,wxSizerFlags().Border(wxALL,5).Proportion(0).Expand());
	
	sizer->Add(new wxStaticText(this,wxID_ANY,_Z(" Seleccione un perfil para configurar las reglas del lenguaje: ")),wxSizerFlags().Expand().Proportion(0).Border(wxTOP,5));
	sizer->Add(list,wxSizerFlags().Expand().Proportion(3).FixedMinSize());
	sizer->Add(new wxStaticText(this,wxID_ANY,_Z("")),wxSizerFlags().Expand().Proportion(0));
	sizer->Add(new wxStaticText(this,wxID_ANY,_Z(" Descripción del perfil seleccionado:")),wxSizerFlags().Expand().Proportion(0));
	sizer->Add(text,wxSizerFlags().Expand().Proportion(1).FixedMinSize());
	sizer->Add(new wxStaticText(this,wxID_ANY,""),wxSizerFlags().Expand().Proportion(0));
	sizer->Add(button_sizer,wxSizerFlags().Expand().Proportion(0));
	
	ok_button->SetDefault();
	SetEscapeId(wxID_CANCEL);
	
	SetSizerAndFit(sizer);
	
	this->Layout(); // para ajustar el tamaño de la columna de la lista
	list->SetColumnWidth(0,list->GetSize().GetWidth()-32);
	
	search->SetFocus();
	
	ShowModal();
}
Exemple #21
0
int main(int argc, char *argv[])
{
	atexit(finish);
	_Z(); _P(); _P(); _P(); _P(); p();
	return 0;
}