Subversion Repositories Kolibri OS

Rev

Rev 4680 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.  * Utility object for handling a pdf application / view
  3.  * Takes care of PDF loading and displaying and navigation,
  4.  * uses a number of callbacks to the GUI app.
  5.  */
  6.  
  7. #define MINRES 54
  8. #define MAXRES 300
  9.  
  10. typedef struct pdfapp_s pdfapp_t;
  11.  
  12. enum { ARROW, HAND, WAIT };
  13.  
  14. extern void winwarn(pdfapp_t*, char *s);
  15. extern void winerror(pdfapp_t*, fz_error error);
  16. extern void wintitle(pdfapp_t*, char *title);
  17. extern void winresize(pdfapp_t*, int w, int h);
  18. extern void winrepaint(pdfapp_t*);
  19. extern void winrepaintsearch(pdfapp_t*);
  20. extern char *winpassword(pdfapp_t*, char *filename);
  21. extern void winopenuri(pdfapp_t*, char *s);
  22. extern void wincursor(pdfapp_t*, int curs);
  23. extern void windocopy(pdfapp_t*);
  24. extern void winreloadfile(pdfapp_t*);
  25. extern void windrawstring(pdfapp_t*, int x, int y, char *s);
  26. extern void winclose(pdfapp_t*);
  27. extern void winhelp(pdfapp_t*);
  28.  
  29. struct pdfapp_s
  30. {
  31.         /* current document params */
  32.         char *doctitle;
  33.         pdf_xref *xref;
  34.         pdf_outline *outline;
  35.  
  36.         int pagecount;
  37.         fz_glyph_cache *cache;
  38.  
  39.         /* current view params */
  40.         int resolution;
  41.         int rotate;
  42.         fz_pixmap *image;
  43.         int grayscale;
  44.  
  45.         /* current page params */
  46.         int pageno;
  47.         fz_rect page_bbox;
  48.         float page_rotate;
  49.         fz_display_list *page_list;
  50.         fz_text_span *page_text;
  51.         pdf_link *page_links;
  52.  
  53.         /* snapback history */
  54.         int hist[256];
  55.         int histlen;
  56.         int marks[10];
  57.  
  58.         /* window system sizes */
  59.         int winw, winh;
  60.         int scrw, scrh;
  61.         int shrinkwrap;
  62.  
  63.         /* event handling state */
  64.         char number[256];
  65.         int numberlen;
  66.  
  67.         int ispanning;
  68.         int panx, pany;
  69.  
  70.         int iscopying;
  71.         int selx, sely;
  72.         /* TODO - While sely keeps track of the relative change in
  73.          * cursor position between two ticks/events, beyondy shall keep
  74.          * track of the relative change in cursor position from the
  75.          * point where the user hits a scrolling limit. This is ugly.
  76.          * Used in pdfapp.c:pdfapp_onmouse.
  77.          */
  78.         int beyondy;
  79.         fz_bbox selr;
  80.  
  81.         /* search state */
  82.         int isediting;
  83.         char search[512];
  84.         int hit;
  85.         int hitlen;
  86.  
  87.         /* client context storage */
  88.         void *userdata;
  89. };
  90.  
  91. void pdfapp_init(pdfapp_t *app);
  92. void pdfapp_open(pdfapp_t *app, char *filename, int fd, int reload);
  93. void pdfapp_close(pdfapp_t *app);
  94.  
  95. char *pdfapp_version(pdfapp_t *app);
  96. char *pdfapp_usage(pdfapp_t *app);
  97.  
  98. void pdfapp_onkey(pdfapp_t *app, int c);
  99. void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int state);
  100. void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen);
  101. void pdfapp_onresize(pdfapp_t *app, int w, int h);
  102.  
  103. void pdfapp_invert(pdfapp_t *app, fz_bbox rect);
  104. void pdfapp_inverthit(pdfapp_t *app);
  105.