1 #ifndef MUPDF_PDF_EVENT_H 2 #define MUPDF_PDF_EVENT_H 3 4 /* 5 Document events: the objects via which MuPDF informs the calling app 6 of occurrences emanating from the document, possibly from user interaction 7 or javascript execution. MuPDF informs the app of document events via a 8 callback. 9 */ 10 11 struct pdf_doc_event 12 { 13 int type; 14 }; 15 16 enum 17 { 18 PDF_DOCUMENT_EVENT_ALERT, 19 PDF_DOCUMENT_EVENT_PRINT, 20 PDF_DOCUMENT_EVENT_LAUNCH_URL, 21 PDF_DOCUMENT_EVENT_MAIL_DOC, 22 PDF_DOCUMENT_EVENT_SUBMIT, 23 PDF_DOCUMENT_EVENT_EXEC_MENU_ITEM, 24 }; 25 26 /* 27 set the function via which to receive 28 document events. 29 */ 30 void pdf_set_doc_event_callback(fz_context *ctx, pdf_document *doc, pdf_doc_event_cb *event_cb, void *data); 31 void *pdf_get_doc_event_callback_data(fz_context *ctx, pdf_document *doc); 32 33 /* 34 The various types of document events 35 */ 36 37 /* 38 details of an alert event. In response the app should 39 display an alert dialog with the buttons specified by "button_type_group". 40 If "check_box_message" is non-NULL, a checkbox should be displayed in 41 the lower-left corned along with the message. 42 43 "finally_checked" and "button_pressed" should be set by the app 44 before returning from the callback. "finally_checked" need be set 45 only if "check_box_message" is non-NULL. 46 */ 47 typedef struct 48 { 49 const char *message; 50 int icon_type; 51 int button_group_type; 52 const char *title; 53 const char *check_box_message; 54 int initially_checked; 55 int finally_checked; 56 int button_pressed; 57 } pdf_alert_event; 58 59 /* Possible values of icon_type */ 60 enum 61 { 62 PDF_ALERT_ICON_ERROR, 63 PDF_ALERT_ICON_WARNING, 64 PDF_ALERT_ICON_QUESTION, 65 PDF_ALERT_ICON_STATUS 66 }; 67 68 /* Possible values of button_group_type */ 69 enum 70 { 71 PDF_ALERT_BUTTON_GROUP_OK, 72 PDF_ALERT_BUTTON_GROUP_OK_CANCEL, 73 PDF_ALERT_BUTTON_GROUP_YES_NO, 74 PDF_ALERT_BUTTON_GROUP_YES_NO_CANCEL 75 }; 76 77 /* Possible values of button_pressed */ 78 enum 79 { 80 PDF_ALERT_BUTTON_NONE, 81 PDF_ALERT_BUTTON_OK, 82 PDF_ALERT_BUTTON_CANCEL, 83 PDF_ALERT_BUTTON_NO, 84 PDF_ALERT_BUTTON_YES 85 }; 86 87 /* 88 access the details of an alert event 89 The returned pointer and all the data referred to by the 90 structure are owned by mupdf and need not be freed by the 91 caller. 92 */ 93 pdf_alert_event *pdf_access_alert_event(fz_context *ctx, pdf_doc_event *event); 94 95 /* 96 access the details of am execMenuItem 97 event, which consists of just the name of the menu item 98 */ 99 const char *pdf_access_exec_menu_item_event(fz_context *ctx, pdf_doc_event *event); 100 101 /* 102 details of a launch-url event. The app should 103 open the url, either in a new frame or in the current window. 104 */ 105 typedef struct 106 { 107 const char *url; 108 int new_frame; 109 } pdf_launch_url_event; 110 111 /* 112 access the details of a launch-url 113 event. The returned pointer and all data referred to by the structure 114 are owned by mupdf and need not be freed by the caller. 115 */ 116 pdf_launch_url_event *pdf_access_launch_url_event(fz_context *ctx, pdf_doc_event *event); 117 118 /* 119 details of a mail_doc event. The app should save 120 the current state of the document and email it using the specified 121 parameters. 122 */ 123 typedef struct 124 { 125 int ask_user; 126 const char *to; 127 const char *cc; 128 const char *bcc; 129 const char *subject; 130 const char *message; 131 } pdf_mail_doc_event; 132 133 pdf_mail_doc_event *pdf_access_mail_doc_event(fz_context *ctx, pdf_doc_event *event); 134 135 void pdf_event_issue_alert(fz_context *ctx, pdf_document *doc, pdf_alert_event *event); 136 void pdf_event_issue_print(fz_context *ctx, pdf_document *doc); 137 void pdf_event_issue_exec_menu_item(fz_context *ctx, pdf_document *doc, const char *item); 138 void pdf_event_issue_launch_url(fz_context *ctx, pdf_document *doc, const char *url, int new_frame); 139 void pdf_event_issue_mail_doc(fz_context *ctx, pdf_document *doc, pdf_mail_doc_event *event); 140 141 #endif 142