#ifndef MUPDF_PDF_EVENT_H1#define MUPDF_PDF_EVENT_H23enum4{5HOTSPOT_POINTER_DOWN = 0x1,6HOTSPOT_POINTER_OVER = 0x27};89/* Types of UI event */10enum11{12PDF_EVENT_TYPE_POINTER,13};1415/* Types of pointer event */16enum17{18PDF_POINTER_DOWN,19PDF_POINTER_UP,20};2122/*23UI events that can be passed to an interactive document.24*/25typedef struct pdf_ui_event_s26{27int etype;28union29{30struct31{32int ptype;33fz_point pt;34} pointer;35} event;36} pdf_ui_event;3738/*39pdf_init_ui_pointer_event: Set up a pointer event40*/41void pdf_init_ui_pointer_event(pdf_ui_event *event, int type, float x, float y);4243/*44Document events: the objects via which MuPDF informs the calling app45of occurrences emanating from the document, possibly from user interaction46or javascript execution. MuPDF informs the app of document events via a47callback.48*/4950/*51pdf_pass_event: Pass a UI event to an interactive52document.5354Returns a boolean indication of whether the ui_event was55handled. Example of use for the return value: when considering56passing the events that make up a drag, if the down event isn't57accepted then don't send the move events or the up event.58*/59int pdf_pass_event(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_ui_event *ui_event);6061struct pdf_doc_event_s62{63int type;64};6566enum67{68PDF_DOCUMENT_EVENT_ALERT,69PDF_DOCUMENT_EVENT_PRINT,70PDF_DOCUMENT_EVENT_LAUNCH_URL,71PDF_DOCUMENT_EVENT_MAIL_DOC,72PDF_DOCUMENT_EVENT_SUBMIT,73PDF_DOCUMENT_EVENT_EXEC_MENU_ITEM,74PDF_DOCUMENT_EVENT_EXEC_DIALOG75};7677/*78pdf_set_doc_event_callback: set the function via which to receive79document events.80*/81void pdf_set_doc_event_callback(fz_context *ctx, pdf_document *doc, pdf_doc_event_cb *event_cb, void *data);8283/*84The various types of document events85*/8687/*88pdf_alert_event: details of an alert event. In response the app should89display an alert dialog with the bittons specified by "button_type_group".90If "check_box_message" is non-NULL, a checkbox should be displayed in91the lower-left corned along with the messsage.9293"finally_checked" and "button_pressed" should be set by the app94before returning from the callback. "finally_checked" need be set95only if "check_box_message" is non-NULL.96*/97typedef struct98{99char *message;100int icon_type;101int button_group_type;102char *title;103char *check_box_message;104int initially_checked;105int finally_checked;106int button_pressed;107} pdf_alert_event;108109/* Possible values of icon_type */110enum111{112PDF_ALERT_ICON_ERROR,113PDF_ALERT_ICON_WARNING,114PDF_ALERT_ICON_QUESTION,115PDF_ALERT_ICON_STATUS116};117118/* Possible values of button_group_type */119enum120{121PDF_ALERT_BUTTON_GROUP_OK,122PDF_ALERT_BUTTON_GROUP_OK_CANCEL,123PDF_ALERT_BUTTON_GROUP_YES_NO,124PDF_ALERT_BUTTON_GROUP_YES_NO_CANCEL125};126127/* Possible values of button_pressed */128enum129{130PDF_ALERT_BUTTON_NONE,131PDF_ALERT_BUTTON_OK,132PDF_ALERT_BUTTON_CANCEL,133PDF_ALERT_BUTTON_NO,134PDF_ALERT_BUTTON_YES135};136137/*138pdf_access_alert_event: access the details of an alert event139The returned pointer and all the data referred to by the140structire are owned by mupdf and need not be freed by the141caller.142*/143pdf_alert_event *pdf_access_alert_event(fz_context *ctx, pdf_doc_event *event);144145/*146pdf_access_exec_menu_item_event: access the details of am execMenuItem147event, which consists of just the name of the menu item148*/149char *pdf_access_exec_menu_item_event(fz_context *ctx, pdf_doc_event *event);150151/*152pdf_submit_event: details of a submit event. The app should submit153the specified data to the specified url. "get" determines whether154to use the GET or POST method.155*/156typedef struct157{158char *url;159char *data;160int data_len;161int get;162} pdf_submit_event;163164/*165pdf_access_submit_event: access the details of a submit event166The returned pointer and all data referred to by the structure are167owned by mupdf and need not be freed by the caller.168*/169pdf_submit_event *pdf_access_submit_event(fz_context *ctx, pdf_doc_event *event);170171/*172pdf_launch_url_event: details of a launch-url event. The app should173open the url, either in a new frame or in the current window.174*/175typedef struct176{177char *url;178int new_frame;179} pdf_launch_url_event;180181/*182pdf_access_launch_url_event: access the details of a launch-url183event. The returned pointer and all data referred to by the structure184are owned by mupdf and need not be freed by the caller.185*/186pdf_launch_url_event *pdf_access_launch_url_event(fz_context *ctx, pdf_doc_event *event);187188/*189pdf_mail_doc_event: details of a mail_doc event. The app should save190the current state of the document and email it using the specified191parameters.192*/193typedef struct194{195int ask_user;196char *to;197char *cc;198char *bcc;199char *subject;200char *message;201} pdf_mail_doc_event;202203/*204pdf_acccess_mail_doc_event: access the details of a mail-doc event.205*/206pdf_mail_doc_event *pdf_access_mail_doc_event(fz_context *ctx, pdf_doc_event *event);207208void pdf_event_issue_alert(fz_context *ctx, pdf_document *doc, pdf_alert_event *event);209void pdf_event_issue_print(fz_context *ctx, pdf_document *doc);210void pdf_event_issue_exec_menu_item(fz_context *ctx, pdf_document *doc, char *item);211void pdf_event_issue_exec_dialog(fz_context *ctx, pdf_document *doc);212void pdf_event_issue_launch_url(fz_context *ctx, pdf_document *doc, char *url, int new_frame);213void pdf_event_issue_mail_doc(fz_context *ctx, pdf_document *doc, pdf_mail_doc_event *event);214215#endif216217218