widget.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #ifndef MUPDF_PDF_WIDGET_H
  2. #define MUPDF_PDF_WIDGET_H
  3. /* Types of widget */
  4. enum
  5. {
  6. PDF_WIDGET_TYPE_NOT_WIDGET = -1,
  7. PDF_WIDGET_TYPE_PUSHBUTTON,
  8. PDF_WIDGET_TYPE_CHECKBOX,
  9. PDF_WIDGET_TYPE_RADIOBUTTON,
  10. PDF_WIDGET_TYPE_TEXT,
  11. PDF_WIDGET_TYPE_LISTBOX,
  12. PDF_WIDGET_TYPE_COMBOBOX,
  13. PDF_WIDGET_TYPE_SIGNATURE
  14. };
  15. /* Types of text widget content */
  16. enum
  17. {
  18. PDF_WIDGET_CONTENT_UNRESTRAINED,
  19. PDF_WIDGET_CONTENT_NUMBER,
  20. PDF_WIDGET_CONTENT_SPECIAL,
  21. PDF_WIDGET_CONTENT_DATE,
  22. PDF_WIDGET_CONTENT_TIME
  23. };
  24. /*
  25. Widgets that may appear in PDF forms
  26. */
  27. /*
  28. pdf_focused_widget: returns the currently focused widget
  29. Widgets can become focused as a result of passing in ui events.
  30. NULL is returned if there is no currently focused widget. An
  31. app may wish to create a native representative of the focused
  32. widget, e.g., to collect the text for a text widget, rather than
  33. routing key strokes through pdf_pass_event.
  34. */
  35. pdf_widget *pdf_focused_widget(fz_context *ctx, pdf_document *doc);
  36. /*
  37. pdf_first_widget: get first widget when enumerating
  38. */
  39. pdf_widget *pdf_first_widget(fz_context *ctx, pdf_document *doc, pdf_page *page);
  40. /*
  41. pdf_next_widget: get next widget when enumerating
  42. */
  43. pdf_widget *pdf_next_widget(fz_context *ctx, pdf_widget *previous);
  44. /*
  45. pdf_create_widget: create a new widget of a specific type
  46. */
  47. pdf_widget *pdf_create_widget(fz_context *ctx, pdf_document *doc, pdf_page *page, int type, char *fieldname);
  48. /*
  49. pdf_widget_type: find out the type of a widget.
  50. The type determines what widget subclass the widget
  51. can safely be cast to.
  52. */
  53. int pdf_widget_type(fz_context *ctx, pdf_widget *widget);
  54. /*
  55. pdf_bound_widget: get the bounding box of a widget.
  56. */
  57. fz_rect *pdf_bound_widget(fz_context *ctx, pdf_widget *widget, fz_rect *);
  58. /*
  59. pdf_text_widget_text: Get the text currently displayed in
  60. a text widget.
  61. */
  62. char *pdf_text_widget_text(fz_context *ctx, pdf_document *doc, pdf_widget *tw);
  63. /*
  64. pdf_widget_text_max_len: get the maximum number of
  65. characters permitted in a text widget
  66. */
  67. int pdf_text_widget_max_len(fz_context *ctx, pdf_document *doc, pdf_widget *tw);
  68. /*
  69. pdf_text_widget_content_type: get the type of content
  70. required by a text widget
  71. */
  72. int pdf_text_widget_content_type(fz_context *ctx, pdf_document *doc, pdf_widget *tw);
  73. /*
  74. pdf_text_widget_set_text: Update the text of a text widget.
  75. The text is first validated and accepted only if it passes. The
  76. function returns whether validation passed.
  77. */
  78. int pdf_text_widget_set_text(fz_context *ctx, pdf_document *doc, pdf_widget *tw, char *text);
  79. /*
  80. pdf_choice_widget_options: get the list of options for a list
  81. box or combo box. Returns the number of options and fills in their
  82. names within the supplied array. Should first be called with a
  83. NULL array to find out how big the array should be. If exportval
  84. is true, then the export values will be returned and not the list
  85. values if there are export values present.
  86. */
  87. int pdf_choice_widget_options(fz_context *ctx, pdf_document *doc, pdf_widget *tw, int exportval, char *opts[]);
  88. /*
  89. pdf_choice_widget_is_multiselect: returns whether a list box or
  90. combo box supports selection of multiple options
  91. */
  92. int pdf_choice_widget_is_multiselect(fz_context *ctx, pdf_document *doc, pdf_widget *tw);
  93. /*
  94. pdf_choice_widget_value: get the value of a choice widget.
  95. Returns the number of options currently selected and fills in
  96. the supplied array with their strings. Should first be called
  97. with NULL as the array to find out how big the array need to
  98. be. The filled in elements should not be freed by the caller.
  99. */
  100. int pdf_choice_widget_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw, char *opts[]);
  101. /*
  102. pdf_widget_set_value: set the value of a choice widget. The
  103. caller should pass the number of options selected and an
  104. array of their names
  105. */
  106. void pdf_choice_widget_set_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw, int n, char *opts[]);
  107. #endif