Beispiel #1
0
int GetKeyCode(char * text)
{
	UI_DIALOG * dlg;
	window *wind;
	key_dialog k;

	text = text;

	dlg = ui_create_dialog( 200, 200, 400, 200, DF_DIALOG | DF_MODAL, (int (*)(UI_DIALOG *, d_event *, void *))key_dialog_handler, &k );

	k.DoneButton = ui_add_gadget_button( dlg, 170, 165, 60, 25, "Ok", NULL );
	strcpy(k.text, "");

	ui_gadget_calc_keys(dlg);

	//key_flush();

	dlg->keyboard_focus_gadget = (UI_GADGET *)k.DoneButton;
	wind = ui_dialog_get_window(dlg);

	while (window_exists(wind))
		event_process();

	return 0;
}
Beispiel #2
0
int ui_get_filename( char * filename, const char * filespec, const char * message  )
{
    char			InputText[PATH_MAX];
    char			*p;
    int				i;
    file_browser	*b;
    UI_DIALOG		*dlg;
    window			*wind;
    int				rval = 0;

    MALLOC(b, file_browser, 1);
    if (!b)
        return 0;

    if ((p = strrchr(filename, '/')))
    {
        *p++ = 0;
        strcpy(b->view_dir, filename);
        strcpy(InputText, p);
    }
    else
    {
        strcpy(b->view_dir, "");
        strcpy(InputText, filename);
    }

    b->filename_list = file_getfilelist(&b->num_files, filespec, b->view_dir);
    if (!b->filename_list)
    {
        d_free(b);
        return 0;
    }

    b->directory_list = file_getdirlist(&b->num_dirs, b->view_dir);
    if (!b->directory_list)
    {
        PHYSFS_freeList(b->filename_list);
        d_free(b);
        return 0;
    }

    //ui_messagebox( -2,-2, 1,"DEBUG:0", "Ok" );
    for (i=0; i<35; i++)
        b->spaces[i] = ' ';
    b->spaces[34] = 0;

    dlg = ui_create_dialog( 200, 100, 400, 370, static_cast<dialog_flags>(DF_DIALOG | DF_MODAL), (int (*)(UI_DIALOG *, d_event *, void *))browser_handler, b );

    b->user_file  = ui_add_gadget_inputbox( dlg, 60, 30, PATH_MAX, 40, InputText );

    b->listbox1 = ui_add_gadget_listbox(dlg,  20, 110, 125, 200, b->num_files, b->filename_list);
    b->listbox2 = ui_add_gadget_listbox(dlg, 210, 110, 100, 200, b->num_dirs, b->directory_list);

    b->button1 = ui_add_gadget_button( dlg,     20, 330, 60, 25, "Ok", NULL );
    b->button2 = ui_add_gadget_button( dlg,    100, 330, 60, 25, "Cancel", NULL );
    b->help_button = ui_add_gadget_button( dlg, 180, 330, 60, 25, "Help", NULL );

    dlg->keyboard_focus_gadget = (UI_GADGET *)b->user_file;

    b->button1->hotkey = KEY_CTRLED + KEY_ENTER;
    b->button2->hotkey = KEY_ESC;
    b->help_button->hotkey = KEY_F1;
    b->listbox1->hotkey = KEY_ALTED + KEY_F;
    b->listbox2->hotkey = KEY_ALTED + KEY_D;
    b->user_file->hotkey = KEY_ALTED + KEY_A;

    ui_gadget_calc_keys(dlg);

    b->filename = filename;
    b->filespec = filespec;
    b->message = message;

    wind = ui_dialog_get_window(dlg);

    while (window_exists(wind))
        event_process();

    //key_flush();

    if (b->filename_list)
        PHYSFS_freeList(b->filename_list);
    if (b->directory_list)
        PHYSFS_freeList(b->directory_list);

    rval = b->filename_list != NULL;
    d_free(b);

    return rval;
}