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 fz_choice_widget_options(fz_interactive *idoc, fz_widget *tw, char *opts[]) { return pdf_choice_widget_options((pdf_document *)idoc, tw, opts); }