static void sig_dialog(void) { const char *label = pdf_field_label(ctx, sig_widget->obj); ui_dialog_begin(400, (ui.gridsize+4)*3 + ui.lineheight*10); { ui_layout(T, X, NW, 2, 2); ui_label("%s", label); ui_spacer(); if (sig_result) ui_label("Signature is valid.\n%s", sig_status); else ui_label("Could not verify signature:\n%s", sig_status); ui_layout(B, X, NW, 2, 2); ui_panel_begin(0, ui.gridsize, 0, 0, 0); { ui_layout(R, NONE, S, 0, 0); if (ui_button("Cancel") || (!ui.focus && ui.key == KEY_ESCAPE)) ui.dialog = NULL; ui_spacer(); if (ui_button("Sign")) { fz_strlcpy(cert_filename, filename, sizeof cert_filename); ui_init_open_file(".", cert_file_filter); ui.dialog = cert_file_dialog; } } ui_panel_end(); } ui_dialog_end(); }
static void cert_password_dialog(void) { int is; ui_dialog_begin(400, (ui.gridsize+4)*3); { ui_layout(T, X, NW, 2, 2); ui_label("Password:"******"Cancel")) ui.dialog = NULL; ui_spacer(); if (ui_button("Okay") || is == UI_INPUT_ACCEPT) { ui.dialog = NULL; do_sign(); } } ui_panel_end(); } ui_dialog_end(); }
static void tx_dialog(void) { int ff = pdf_field_flags(ctx, tx_widget->obj); const char *label = pdf_field_label(ctx, tx_widget->obj); int tx_h = (ff & PDF_TX_FIELD_IS_MULTILINE) ? 10 : 1; int lbl_h = ui_break_lines((char*)label, NULL, 20, 394, NULL); int is; ui_dialog_begin(400, (ui.gridsize+4)*3 + ui.lineheight*(tx_h+lbl_h-2)); { ui_layout(T, X, NW, 2, 2); ui_label("%s", label); is = ui_input(&tx_input, 200, tx_h); ui_layout(B, X, NW, 2, 2); ui_panel_begin(0, ui.gridsize, 0, 0, 0); { ui_layout(R, NONE, S, 0, 0); if (ui_button("Cancel") || (!ui.focus && ui.key == KEY_ESCAPE)) ui.dialog = NULL; ui_spacer(); if (ui_button("Okay") || is == UI_INPUT_ACCEPT) { pdf_set_text_field_value(ctx, tx_widget, tx_input.text); if (pdf_update_page(ctx, tx_widget->page)) render_page(); ui.dialog = NULL; } } ui_panel_end(); } ui_dialog_end(); }
static void ch_dialog(void) { const char *label; const char *value; const char **options; int n, choice; int label_h; label = pdf_field_label(ctx, ch_widget->obj); label_h = ui_break_lines((char*)label, NULL, 20, 394, NULL); n = pdf_choice_widget_options(ctx, ch_widget->page->doc, ch_widget, 0, NULL); options = fz_malloc_array(ctx, n, sizeof(char*)); pdf_choice_widget_options(ctx, ch_widget->page->doc, ch_widget, 0, options); value = pdf_field_value(ctx, ch_widget->obj); ui_dialog_begin(400, (ui.gridsize+4)*3 + ui.lineheight*(label_h-1)); { ui_layout(T, X, NW, 2, 2); ui_label("%s", label); choice = ui_select("Widget/Ch", value, options, n); if (choice >= 0) pdf_set_choice_field_value(ctx, ch_widget, options[choice]); ui_layout(B, X, NW, 2, 2); ui_panel_begin(0, ui.gridsize, 0, 0, 0); { ui_layout(R, NONE, S, 0, 0); if (ui_button("Cancel") || (!ui.focus && ui.key == KEY_ESCAPE)) ui.dialog = NULL; ui_spacer(); if (ui_button("Okay")) { if (pdf_update_page(ctx, ch_widget->page)) render_page(); ui.dialog = NULL; } } ui_panel_end(); } ui_dialog_end(); fz_free(ctx, options); }
int ui_save_file(char filename[PATH_MAX], void (*extra_panel)(void)) { int i, rv = 0; ui_panel_begin(0, 0, 4, 4, 1); { ui_layout(L, Y, NW, 0, 0); ui_panel_begin(150, 0, 0, 0, 0); { ui_layout(T, X, NW, 2, 2); list_drives(); if (extra_panel) { ui_spacer(); extra_panel(); } ui_layout(B, X, NW, 2, 2); if (ui_button("Cancel") || (!ui.focus && ui.key == KEY_ESCAPE)) { filename[0] = 0; rv = 1; } } ui_panel_end(); ui_layout(T, X, NW, 2, 2); if (ui_input(&fc.input_dir, 0, 1) == UI_INPUT_ACCEPT) load_dir(fc.input_dir.text); ui_layout(T, X, NW, 2, 2); ui_panel_begin(0, ui.gridsize, 0, 0, 0); { ui_layout(R, NONE, CENTER, 0, 0); if (ui_button("Save")) { fz_snprintf(filename, PATH_MAX, "%s/%s", fc.curdir, fc.input_file.text); rv = 1; } ui_spacer(); if (ui_button("\xe2\x9e\x95")) /* U+2795 HEAVY PLUS */ bump_file_version(1); if (ui_button("\xe2\x9e\x96")) /* U+2796 HEAVY MINUS */ bump_file_version(-1); ui_spacer(); ui_layout(ALL, X, CENTER, 0, 0); ui_input(&fc.input_file, 0, 1); } ui_panel_end(); ui_layout(ALL, BOTH, NW, 2, 2); ui_list_begin(&fc.list_dir, fc.count, 0, 0); for (i = 0; i < fc.count; ++i) { const char *name = fc.files[i].name; char buf[PATH_MAX]; if (fc.files[i].is_dir) fz_snprintf(buf, sizeof buf, "\xf0\x9f\x93\x81 %s", name); else fz_snprintf(buf, sizeof buf, "\xf0\x9f\x93\x84 %s", name); if (ui_list_item(&fc.list_dir, &fc.files[i], buf, i==fc.selected)) { fc.selected = i; if (fc.files[i].is_dir) { fz_snprintf(buf, sizeof buf, "%s/%s", fc.curdir, name); load_dir(buf); ui.active = NULL; } else { ui_input_init(&fc.input_file, name); } } } ui_list_end(&fc.list_dir); } ui_panel_end(); return rv; }
int ui_open_file(char filename[PATH_MAX]) { static int last_click_time = 0; static int last_click_sel = -1; int i, rv = 0; ui_panel_begin(0, 0, 4, 4, 1); { ui_layout(L, Y, NW, 0, 0); ui_panel_begin(150, 0, 0, 0, 0); { ui_layout(T, X, NW, 2, 2); list_drives(); ui_layout(B, X, NW, 2, 2); if (ui_button("Cancel") || (!ui.focus && ui.key == KEY_ESCAPE)) { filename[0] = 0; rv = 1; } } ui_panel_end(); ui_layout(T, X, NW, 2, 2); ui_panel_begin(0, ui.gridsize, 0, 0, 0); { if (fc.selected >= 0) { ui_layout(R, NONE, CENTER, 0, 0); if (ui_button("Open") || (!ui.focus && ui.key == KEY_ENTER)) { fz_snprintf(filename, PATH_MAX, "%s/%s", fc.curdir, fc.files[fc.selected].name); rv = 1; } ui_spacer(); } ui_layout(ALL, X, CENTER, 0, 0); if (ui_input(&fc.input_dir, 0, 1) == UI_INPUT_ACCEPT) load_dir(fc.input_dir.text); } ui_panel_end(); ui_layout(ALL, BOTH, NW, 2, 2); ui_list_begin(&fc.list_dir, fc.count, 0, 0); for (i = 0; i < fc.count; ++i) { const char *name = fc.files[i].name; char buf[PATH_MAX]; if (fc.files[i].is_dir) fz_snprintf(buf, sizeof buf, "%C %s", ICON_FOLDER, name); else fz_snprintf(buf, sizeof buf, "%C %s", ICON_DOCUMENT, name); if (ui_list_item(&fc.list_dir, &fc.files[i], buf, i==fc.selected)) { fc.selected = i; if (fc.files[i].is_dir) { fz_snprintf(buf, sizeof buf, "%s/%s", fc.curdir, name); load_dir(buf); ui.active = NULL; last_click_sel = -1; } else { int click_time = glutGet(GLUT_ELAPSED_TIME); if (i == last_click_sel && click_time < last_click_time + 250) { fz_snprintf(filename, PATH_MAX, "%s/%s", fc.curdir, name); rv = 1; } last_click_time = click_time; last_click_sel = i; } } } ui_list_end(&fc.list_dir); } ui_panel_end(); return rv; }