event.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. #ifndef MUPDF_PDF_EVENT_H
  2. #define MUPDF_PDF_EVENT_H
  3. enum
  4. {
  5. HOTSPOT_POINTER_DOWN = 0x1,
  6. HOTSPOT_POINTER_OVER = 0x2
  7. };
  8. /* Types of UI event */
  9. enum
  10. {
  11. PDF_EVENT_TYPE_POINTER,
  12. };
  13. /* Types of pointer event */
  14. enum
  15. {
  16. PDF_POINTER_DOWN,
  17. PDF_POINTER_UP,
  18. };
  19. /*
  20. UI events that can be passed to an interactive document.
  21. */
  22. typedef struct pdf_ui_event_s
  23. {
  24. int etype;
  25. union
  26. {
  27. struct
  28. {
  29. int ptype;
  30. fz_point pt;
  31. } pointer;
  32. } event;
  33. } pdf_ui_event;
  34. /*
  35. pdf_init_ui_pointer_event: Set up a pointer event
  36. */
  37. void pdf_init_ui_pointer_event(pdf_ui_event *event, int type, float x, float y);
  38. /*
  39. Document events: the objects via which MuPDF informs the calling app
  40. of occurrences emanating from the document, possibly from user interaction
  41. or javascript execution. MuPDF informs the app of document events via a
  42. callback.
  43. */
  44. /*
  45. pdf_pass_event: Pass a UI event to an interactive
  46. document.
  47. Returns a boolean indication of whether the ui_event was
  48. handled. Example of use for the return value: when considering
  49. passing the events that make up a drag, if the down event isn't
  50. accepted then don't send the move events or the up event.
  51. */
  52. int pdf_pass_event(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_ui_event *ui_event);
  53. struct pdf_doc_event_s
  54. {
  55. int type;
  56. };
  57. enum
  58. {
  59. PDF_DOCUMENT_EVENT_ALERT,
  60. PDF_DOCUMENT_EVENT_PRINT,
  61. PDF_DOCUMENT_EVENT_LAUNCH_URL,
  62. PDF_DOCUMENT_EVENT_MAIL_DOC,
  63. PDF_DOCUMENT_EVENT_SUBMIT,
  64. PDF_DOCUMENT_EVENT_EXEC_MENU_ITEM,
  65. PDF_DOCUMENT_EVENT_EXEC_DIALOG
  66. };
  67. /*
  68. pdf_set_doc_event_callback: set the function via which to receive
  69. document events.
  70. */
  71. void pdf_set_doc_event_callback(fz_context *ctx, pdf_document *doc, pdf_doc_event_cb *event_cb, void *data);
  72. /*
  73. The various types of document events
  74. */
  75. /*
  76. pdf_alert_event: details of an alert event. In response the app should
  77. display an alert dialog with the buttons specified by "button_type_group".
  78. If "check_box_message" is non-NULL, a checkbox should be displayed in
  79. the lower-left corned along with the message.
  80. "finally_checked" and "button_pressed" should be set by the app
  81. before returning from the callback. "finally_checked" need be set
  82. only if "check_box_message" is non-NULL.
  83. */
  84. typedef struct
  85. {
  86. const char *message;
  87. int icon_type;
  88. int button_group_type;
  89. const char *title;
  90. const char *check_box_message;
  91. int initially_checked;
  92. int finally_checked;
  93. int button_pressed;
  94. } pdf_alert_event;
  95. /* Possible values of icon_type */
  96. enum
  97. {
  98. PDF_ALERT_ICON_ERROR,
  99. PDF_ALERT_ICON_WARNING,
  100. PDF_ALERT_ICON_QUESTION,
  101. PDF_ALERT_ICON_STATUS
  102. };
  103. /* Possible values of button_group_type */
  104. enum
  105. {
  106. PDF_ALERT_BUTTON_GROUP_OK,
  107. PDF_ALERT_BUTTON_GROUP_OK_CANCEL,
  108. PDF_ALERT_BUTTON_GROUP_YES_NO,
  109. PDF_ALERT_BUTTON_GROUP_YES_NO_CANCEL
  110. };
  111. /* Possible values of button_pressed */
  112. enum
  113. {
  114. PDF_ALERT_BUTTON_NONE,
  115. PDF_ALERT_BUTTON_OK,
  116. PDF_ALERT_BUTTON_CANCEL,
  117. PDF_ALERT_BUTTON_NO,
  118. PDF_ALERT_BUTTON_YES
  119. };
  120. /*
  121. pdf_access_alert_event: access the details of an alert event
  122. The returned pointer and all the data referred to by the
  123. structure are owned by mupdf and need not be freed by the
  124. caller.
  125. */
  126. pdf_alert_event *pdf_access_alert_event(fz_context *ctx, pdf_doc_event *event);
  127. /*
  128. pdf_access_exec_menu_item_event: access the details of am execMenuItem
  129. event, which consists of just the name of the menu item
  130. */
  131. const char *pdf_access_exec_menu_item_event(fz_context *ctx, pdf_doc_event *event);
  132. /*
  133. pdf_submit_event: details of a submit event. The app should submit
  134. the specified data to the specified url. "get" determines whether
  135. to use the GET or POST method.
  136. */
  137. typedef struct
  138. {
  139. char *url;
  140. char *data;
  141. int data_len;
  142. int get;
  143. } pdf_submit_event;
  144. /*
  145. pdf_access_submit_event: access the details of a submit event
  146. The returned pointer and all data referred to by the structure are
  147. owned by mupdf and need not be freed by the caller.
  148. */
  149. pdf_submit_event *pdf_access_submit_event(fz_context *ctx, pdf_doc_event *event);
  150. /*
  151. pdf_launch_url_event: details of a launch-url event. The app should
  152. open the url, either in a new frame or in the current window.
  153. */
  154. typedef struct
  155. {
  156. const char *url;
  157. int new_frame;
  158. } pdf_launch_url_event;
  159. /*
  160. pdf_access_launch_url_event: access the details of a launch-url
  161. event. The returned pointer and all data referred to by the structure
  162. are owned by mupdf and need not be freed by the caller.
  163. */
  164. pdf_launch_url_event *pdf_access_launch_url_event(fz_context *ctx, pdf_doc_event *event);
  165. /*
  166. pdf_mail_doc_event: details of a mail_doc event. The app should save
  167. the current state of the document and email it using the specified
  168. parameters.
  169. */
  170. typedef struct
  171. {
  172. int ask_user;
  173. const char *to;
  174. const char *cc;
  175. const char *bcc;
  176. const char *subject;
  177. const char *message;
  178. } pdf_mail_doc_event;
  179. /*
  180. pdf_access_mail_doc_event: access the details of a mail-doc event.
  181. */
  182. pdf_mail_doc_event *pdf_access_mail_doc_event(fz_context *ctx, pdf_doc_event *event);
  183. void pdf_event_issue_alert(fz_context *ctx, pdf_document *doc, pdf_alert_event *event);
  184. void pdf_event_issue_print(fz_context *ctx, pdf_document *doc);
  185. void pdf_event_issue_exec_menu_item(fz_context *ctx, pdf_document *doc, const char *item);
  186. void pdf_event_issue_exec_dialog(fz_context *ctx, pdf_document *doc);
  187. void pdf_event_issue_launch_url(fz_context *ctx, pdf_document *doc, const char *url, int new_frame);
  188. void pdf_event_issue_mail_doc(fz_context *ctx, pdf_document *doc, pdf_mail_doc_event *event);
  189. #endif