summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2006-07-28 15:09:05 +0200
committerTor Andersson <tor@ghostscript.com>2006-07-28 15:09:05 +0200
commit2366ad7de028d397fbd6ed4d7a5d5d1b7915b6cf (patch)
tree6018eabf6c54a90deafdd0d62867e36a640b8ff7 /apps
parent58a89ac205790471a298b210fb47f955c411b04b (diff)
downloadmupdf-2366ad7de028d397fbd6ed4d7a5d5d1b7915b6cf.tar.xz
update windows apps and mozilla plugin
Diffstat (limited to 'apps')
-rw-r--r--apps/Jamfile14
-rw-r--r--apps/mozilla/moz_main.c1209
-rw-r--r--apps/mozilla/moz_winres.rc2
-rw-r--r--apps/mozilla/npwin.c142
-rw-r--r--apps/windows/winmain.c1086
-rw-r--r--apps/windows/winres.rc4
6 files changed, 1236 insertions, 1221 deletions
diff --git a/apps/Jamfile b/apps/Jamfile
index 13b15cce..f526c4c9 100644
--- a/apps/Jamfile
+++ b/apps/Jamfile
@@ -31,7 +31,7 @@ if $(OS) = MINGW
{
SubDir TOP apps windows ;
- Main fzview :
+ Main apparition :
winmain.c
winres.rc
;
@@ -39,19 +39,19 @@ if $(OS) = MINGW
WINLIBS = -lgdi32 -lcomdlg32 ;
if $(BUILD) = release { WINLIBS += -mwindows ; }
- LinkLibraries fzview : libpdfapp $(FITZLIBS) ;
+ LinkLibraries apparition : libpdfapp $(FITZLIBS) ;
- LINKLIBS on fzview$(SUFEXE) = $(LINKLIBS) $(WINLIBS) ;
+ LINKLIBS on apparition$(SUFEXE) = $(LINKLIBS) $(WINLIBS) ;
- InstallBin $(BINDIR) : fzview$(SUFEXE) ;
+ InstallBin $(BINDIR) : apparition$(SUFEXE) ;
}
if $(HAVE_X11) = yes
{
SubDir TOP apps unix ;
- Main fzview : x11pdf.c ximage.c ;
- LinkLibraries fzview : libpdfapp $(FITZLIBS) ;
- LINKLIBS on fzview$(SUFEXE) = $(LINKLIBS) -lX11 -lXext ;
+ Main apparition : x11pdf.c ximage.c ;
+ LinkLibraries apparition : libpdfapp $(FITZLIBS) ;
+ LINKLIBS on apparition$(SUFEXE) = $(LINKLIBS) -lX11 -lXext ;
}
if $(OS) = noMACOSX
diff --git a/apps/mozilla/moz_main.c b/apps/mozilla/moz_main.c
index f09fddff..4c38b78b 100644
--- a/apps/mozilla/moz_main.c
+++ b/apps/mozilla/moz_main.c
@@ -7,866 +7,883 @@
#include "npapi.h"
#include "npupp.h"
-#define MSG(s) MessageBox(0,s,"GhostPDF Debug",MB_OK)
+#define PAD 5
+
+#define MSG(s) MessageBox(0,s,"MuPDF Debug",MB_OK)
typedef struct pdfmoz_s pdfmoz_t;
typedef struct page_s page_t;
struct page_s
{
- fz_obj *ref;
- fz_obj *obj;
- pdf_page *page;
- fz_pixmap *image;
- int w, h; /* page size in units */
- int px; /* pixel height */
+ fz_obj *ref;
+ fz_obj *obj;
+ pdf_page *page;
+ fz_pixmap *image;
+ int w, h; /* page size in units */
+ int px; /* pixel height */
};
struct pdfmoz_s
{
- NPP inst;
- HWND hwnd;
- HWND sbar;
- WNDPROC winproc;
- HCURSOR arrow, hand, wait;
- BITMAPINFO *dibinf;
+ NPP inst;
+ HWND hwnd;
+ HWND sbar;
+ WNDPROC winproc;
+ HCURSOR arrow, hand, wait;
+ BITMAPINFO *dibinf;
+ HBRUSH graybrush;
- int scrollpage; /* scrollbar -> page (n) */
- int scrollyofs; /* scrollbar -> page offset in pixels */
+ int scrollpage; /* scrollbar -> page (n) */
+ int scrollyofs; /* scrollbar -> page offset in pixels */
- int pagecount;
- page_t *pages;
+ int pagecount;
+ page_t *pages;
- char *filename;
- char *doctitle;
+ char *filename;
+ char *doctitle;
- pdf_xref *xref;
- fz_renderer *rast;
+ pdf_xref *xref;
+ fz_renderer *rast;
- char error[1024]; /* empty if no error has occured */
+ char error[1024]; /* empty if no error has occured */
};
void pdfmoz_warn(pdfmoz_t *moz, const char *fmt, ...)
{
- char buf[1024];
- va_list ap;
- va_start(ap, fmt);
- vsprintf(buf, fmt, ap);
- va_end(ap);
- strcpy(moz->error, buf);
- InvalidateRect(moz->hwnd, NULL, FALSE);
- NPN_Status(moz->inst, moz->error);
+ char buf[1024];
+ va_list ap;
+ va_start(ap, fmt);
+ vsprintf(buf, fmt, ap);
+ va_end(ap);
+ strcpy(moz->error, buf);
+ InvalidateRect(moz->hwnd, NULL, FALSE);
+ NPN_Status(moz->inst, moz->error);
}
void pdfmoz_error(pdfmoz_t *moz, fz_error *error)
{
- strcpy(moz->error, error->msg);
- InvalidateRect(moz->hwnd, NULL, FALSE);
- NPN_Status(moz->inst, moz->error);
+ strcpy(moz->error, error->msg);
+ InvalidateRect(moz->hwnd, NULL, FALSE);
+ NPN_Status(moz->inst, moz->error);
}
void pdfmoz_open(pdfmoz_t *moz, char *filename)
{
- SCROLLINFO si;
- fz_error *error;
- fz_obj *obj;
- char *password = "";
- pdf_pagetree *pages;
- fz_irect bbox;
- int rot;
- int i;
-
- strcpy(moz->error, "");
-
- error = fz_newrenderer(&moz->rast, pdf_devicergb, 0, 1024 * 512);
+ SCROLLINFO si;
+ fz_error *error;
+ fz_obj *obj;
+ char *password = "";
+ pdf_pagetree *pages;
+ fz_irect bbox;
+ int rot;
+ int i;
+
+ strcpy(moz->error, "");
+
+ error = fz_newrenderer(&moz->rast, pdf_devicergb, 0, 1024 * 512);
+ if (error)
+ pdfmoz_error(moz, error);
+
+ /*
+ * Open PDF and load xref table
+ */
+
+ moz->filename = filename;
+
+ error = pdf_newxref(&moz->xref);
+ if (error)
+ pdfmoz_error(moz, error);
+
+ error = pdf_loadxref(moz->xref, filename);
+ if (error)
+ {
+ if (!strncmp(error->msg, "ioerror", 7))
+ pdfmoz_error(moz, error);
+ error = pdf_repairxref(moz->xref, filename);
if (error)
- pdfmoz_error(moz, error);
-
- /*
- * Open PDF and load xref table
- */
-
- moz->filename = filename;
-
- error = pdf_newxref(&moz->xref);
+ pdfmoz_error(moz, error);
+ }
+
+ /*
+ * Handle encrypted PDF files
+ */
+
+ error = pdf_decryptxref(moz->xref);
+ if (error)
+ pdfmoz_error(moz, error);
+
+ if (moz->xref->crypt)
+ {
+ error = pdf_setpassword(moz->xref->crypt, password);
+ // while (error)
+ // {
+ // fz_droperror(error);
+ // password = winpassword(moz, filename);
+ // if (!password)
+ // exit(1);
+ // error = pdf_setpassword(moz->xref->crypt, password);
if (error)
- pdfmoz_error(moz, error);
+ pdfmoz_warn(moz, "Invalid password.");
+ // }
+ }
- error = pdf_loadxref(moz->xref, filename);
- if (error)
- {
- if (!strncmp(error->msg, "ioerror", 7))
- pdfmoz_error(moz, error);
- error = pdf_repairxref(moz->xref, filename);
- if (error)
- pdfmoz_error(moz, error);
- }
+ /*
+ * Load page tree
+ */
- /*
- * Handle encrypted PDF files
- */
+ error = pdf_loadpagetree(&pages, moz->xref);
+ if (error)
+ pdfmoz_error(moz, error);
- error = pdf_decryptxref(moz->xref);
- if (error)
- pdfmoz_error(moz, error);
+ moz->pagecount = pdf_getpagecount(pages);
+ moz->pages = fz_malloc(sizeof(page_t) * moz->pagecount);
- if (moz->xref->crypt)
- {
- error = pdf_setpassword(moz->xref->crypt, password);
-// while (error)
-// {
-// fz_droperror(error);
-// password = winpassword(moz, filename);
-// if (!password)
-// exit(1);
-// error = pdf_setpassword(moz->xref->crypt, password);
- if (error)
- pdfmoz_warn(moz, "Invalid password.");
-// }
- }
-
- /*
- * Load page tree
- */
-
- error = pdf_loadpagetree(&pages, moz->xref);
- if (error)
- pdfmoz_error(moz, error);
+ for (i = 0; i < moz->pagecount; i++)
+ {
+ moz->pages[i].ref = fz_keepobj(pages->pref[i]);
+ moz->pages[i].obj = fz_keepobj(pdf_getpageobject(pages, i));
+ moz->pages[i].page = nil;
+ moz->pages[i].image = nil;
- moz->pagecount = pdf_getpagecount(pages);
- moz->pages = fz_malloc(sizeof(page_t) * moz->pagecount);
+ obj = fz_dictgets(moz->pages[i].obj, "CropBox");
+ if (!obj)
+ obj = fz_dictgets(moz->pages[i].obj, "MediaBox");
+ bbox = fz_roundrect(pdf_torect(obj));
+ moz->pages[i].w = bbox.x1 - bbox.x0;
+ moz->pages[i].h = bbox.y1 - bbox.y0;
- for (i = 0; i < moz->pagecount; i++)
+ rot = fz_toint(fz_dictgets(moz->pages[i].obj, "Rotate"));
+ if ((rot / 90) % 2)
{
- moz->pages[i].ref = fz_keepobj(pages->pref[i]);
- moz->pages[i].obj = fz_keepobj(pdf_getpageobject(pages, i));
- moz->pages[i].page = nil;
- moz->pages[i].image = nil;
-
- obj = fz_dictgets(moz->pages[i].obj, "CropBox");
- if (!obj)
- obj = fz_dictgets(moz->pages[i].obj, "MediaBox");
- bbox = fz_roundrect(pdf_torect(obj));
- moz->pages[i].w = bbox.x1 - bbox.x0;
- moz->pages[i].h = bbox.y1 - bbox.y0;
+ int t = moz->pages[i].w;
+ moz->pages[i].w = moz->pages[i].h;
+ moz->pages[i].h = t;
+ }
- rot = fz_toint(fz_dictgets(moz->pages[i].obj, "Rotate"));
- if ((rot / 90) % 2)
- {
- int t = moz->pages[i].w;
- moz->pages[i].w = moz->pages[i].h;
- moz->pages[i].h = t;
- }
+ moz->pages[i].px = 1 + PAD;
+ }
- moz->pages[i].px = 1;
- }
+ pdf_droppagetree(pages);
- pdf_droppagetree(pages);
+ /*
+ * Load meta information
+ * TODO: move this into mupdf library
+ */
- /*
- * Load meta information
- * TODO: move this into mupdf library
- */
+ obj = fz_dictgets(moz->xref->trailer, "Root");
+ if (!obj)
+ pdfmoz_error(moz, fz_throw("syntaxerror: missing Root object"));
- obj = fz_dictgets(moz->xref->trailer, "Root");
- if (!obj)
- pdfmoz_error(moz, fz_throw("syntaxerror: missing Root object"));
+ error = pdf_loadindirect(&moz->xref->root, moz->xref, obj);
+ if (error)
+ pdfmoz_error(moz, error);
- error = pdf_loadindirect(&moz->xref->root, moz->xref, obj);
+ obj = fz_dictgets(moz->xref->trailer, "Info");
+ if (obj)
+ {
+ error = pdf_loadindirect(&moz->xref->info, moz->xref, obj);
if (error)
- pdfmoz_error(moz, error);
-
- obj = fz_dictgets(moz->xref->trailer, "Info");
+ pdfmoz_error(moz, error);
+ }
+
+ error = pdf_loadnametrees(moz->xref);
+ if (error)
+ pdfmoz_error(moz, error);
+
+ moz->doctitle = filename;
+ if (strrchr(moz->doctitle, '\\'))
+ moz->doctitle = strrchr(moz->doctitle, '\\') + 1;
+ if (strrchr(moz->doctitle, '/'))
+ moz->doctitle = strrchr(moz->doctitle, '/') + 1;
+ if (moz->xref->info)
+ {
+ obj = fz_dictgets(moz->xref->info, "Title");
if (obj)
{
- error = pdf_loadindirect(&moz->xref->info, moz->xref, obj);
- if (error)
- pdfmoz_error(moz, error);
- }
-
- error = pdf_loadnametrees(moz->xref);
- if (error)
+ error = pdf_toutf8(&moz->doctitle, obj);
+ if (error)
pdfmoz_error(moz, error);
-
- moz->doctitle = filename;
- if (strrchr(moz->doctitle, '\\'))
- moz->doctitle = strrchr(moz->doctitle, '\\') + 1;
- if (strrchr(moz->doctitle, '/'))
- moz->doctitle = strrchr(moz->doctitle, '/') + 1;
- if (moz->xref->info)
- {
- obj = fz_dictgets(moz->xref->info, "Title");
- if (obj)
- {
- error = pdf_toutf8(&moz->doctitle, obj);
- if (error)
- pdfmoz_error(moz, error);
- }
}
+ }
- /*
- * Start at first page
- */
+ /*
+ * Start at first page
+ */
- si.cbSize = sizeof(si);
- si.fMask = SIF_POS | SIF_RANGE; // XXX | SIF_PAGE;
- si.nPos = 0;
- si.nMin = 0;
- si.nMax = 1;
- si.nPage = 1;
- SetScrollInfo(moz->hwnd, SB_VERT, &si, TRUE);
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_POS | SIF_RANGE; // XXX | SIF_PAGE;
+ si.nPos = 0;
+ si.nMin = 0;
+ si.nMax = 1;
+ si.nPage = 1;
+ SetScrollInfo(moz->hwnd, SB_VERT, &si, TRUE);
- moz->scrollpage = 0;
- moz->scrollyofs = 0;
+ moz->scrollpage = 0;
+ moz->scrollyofs = 0;
- InvalidateRect(moz->hwnd, NULL, FALSE);
+ InvalidateRect(moz->hwnd, NULL, FALSE);
}
static void decodescroll(pdfmoz_t *moz, int spos)
{
- int i, y = 0;
- moz->scrollpage = 0;
- moz->scrollyofs = 0;
- for (i = 0; i < moz->pagecount; i++)
+ int i, y = 0;
+ moz->scrollpage = 0;
+ moz->scrollyofs = 0;
+ for (i = 0; i < moz->pagecount; i++)
+ {
+ if (spos >= y && spos < y + moz->pages[i].px)
{
- if (spos >= y && spos < y + moz->pages[i].px)
- {
- moz->scrollpage = i;
- moz->scrollyofs = spos - y;
- return;
- }
- y += moz->pages[i].px;
+ moz->scrollpage = i;
+ moz->scrollyofs = spos - y;
+ return;
}
+ y += moz->pages[i].px;
+ }
}
fz_matrix pdfmoz_pagectm(pdfmoz_t *moz, int pagenum)
{
- page_t *page = moz->pages + pagenum;
- fz_matrix ctm;
- float zoom;
- RECT rc;
+ page_t *page = moz->pages + pagenum;
+ fz_matrix ctm;
+ float zoom;
+ RECT rc;
- GetClientRect(moz->hwnd, &rc);
+ GetClientRect(moz->hwnd, &rc);
- zoom = (rc.right - rc.left) / (float) page->w;
+ zoom = (rc.right - rc.left) / (float) page->w;
- ctm = fz_identity();
- ctm = fz_concat(ctm, fz_translate(0, -page->page->mediabox.y1));
- ctm = fz_concat(ctm, fz_scale(zoom, -zoom));
- ctm = fz_concat(ctm, fz_rotate(page->page->rotate));
+ ctm = fz_identity();
+ ctm = fz_concat(ctm, fz_translate(0, -page->page->mediabox.y1));
+ ctm = fz_concat(ctm, fz_scale(zoom, -zoom));
+ ctm = fz_concat(ctm, fz_rotate(page->page->rotate));
- return ctm;
+ return ctm;
}
void pdfmoz_loadpage(pdfmoz_t *moz, int pagenum)
{
- page_t *page = moz->pages + pagenum;
- fz_error *error;
+ page_t *page = moz->pages + pagenum;
+ fz_error *error;
- if (page->page)
- return;
+ if (page->page)
+ return;
- error = pdf_loadpage(&page->page, moz->xref, page->obj);
- if (error)
- pdfmoz_error(moz, error);
+ error = pdf_loadpage(&page->page, moz->xref, page->obj);
+ if (error)
+ pdfmoz_error(moz, error);
}
void pdfmoz_drawpage(pdfmoz_t *moz, int pagenum)
{
- page_t *page = moz->pages + pagenum;
- fz_error *error;
- fz_matrix ctm;
- fz_rect bbox;
+ page_t *page = moz->pages + pagenum;
+ fz_error *error;
+ fz_matrix ctm;
+ fz_rect bbox;
- if (page->image)
- return;
+ if (page->image)
+ return;
- ctm = pdfmoz_pagectm(moz, pagenum);
- bbox = fz_transformaabb(ctm, page->page->mediabox);
+ ctm = pdfmoz_pagectm(moz, pagenum);
+ bbox = fz_transformaabb(ctm, page->page->mediabox);
- error = fz_rendertree(&page->image, moz->rast, page->page->tree,
- ctm, fz_roundrect(bbox), 1);
- if (error)
- pdfmoz_error(moz, error);
+ error = fz_rendertree(&page->image, moz->rast, page->page->tree,
+ ctm, fz_roundrect(bbox), 1);
+ if (error)
+ pdfmoz_error(moz, error);
}
void pdfmoz_gotouri(pdfmoz_t *moz, fz_obj *uri)
{
- char buf[2048];
- memcpy(buf, fz_tostrbuf(uri), fz_tostrlen(uri));
- buf[fz_tostrlen(uri)] = 0;
- NPN_GetURL(moz->inst, buf, "_blank");
+ char buf[2048];
+ memcpy(buf, fz_tostrbuf(uri), fz_tostrlen(uri));
+ buf[fz_tostrlen(uri)] = 0;
+ NPN_GetURL(moz->inst, buf, "_blank");
}
int pdfmoz_getpagenum(pdfmoz_t *moz, fz_obj *obj)
{
- int oid = fz_tonum(obj);
- int i;
- for (i = 0; i < moz->pagecount; i++)
- if (fz_tonum(moz->pages[i].ref) == oid)
- return i;
- return 0;
+ int oid = fz_tonum(obj);
+ int i;
+ for (i = 0; i < moz->pagecount; i++)
+ if (fz_tonum(moz->pages[i].ref) == oid)
+ return i;
+ return 0;
}
void pdfmoz_gotopage(pdfmoz_t *moz, fz_obj *obj)
{
- int oid = fz_tonum(obj);
- int i, y = 0;
- for (i = 0; i < moz->pagecount; i++)
+ int oid = fz_tonum(obj);
+ int i, y = 0;
+ for (i = 0; i < moz->pagecount; i++)
+ {
+ if (fz_tonum(moz->pages[i].ref) == oid)
{
- if (fz_tonum(moz->pages[i].ref) == oid)
- {
- SetScrollPos(moz->hwnd, SB_VERT, y, TRUE);
- InvalidateRect(moz->hwnd, NULL, FALSE);
- return;
- }
- y += moz->pages[i].px;
+ SetScrollPos(moz->hwnd, SB_VERT, y, TRUE);
+ InvalidateRect(moz->hwnd, NULL, FALSE);
+ return;
}
+ y += moz->pages[i].px;
+ }
}
void pdfmoz_onmouse(pdfmoz_t *moz, int x, int y, int click)
{
- char buf[512];
- pdf_link *link;
- fz_matrix ctm;
- fz_point p;
- int pi;
- int py;
-
- if (!moz->pages)
- return;
-
- pi = moz->scrollpage;
- py = -moz->scrollyofs;
- while (pi < moz->pagecount)
- {
- if (!moz->pages[pi].image)
- return;
- if (y > py && y < moz->pages[pi].px)
- break;
- py += moz->pages[pi].px;
- pi ++;
- }
- if (pi == moz->pagecount)
- return;
-
- p.x = x + moz->pages[pi].image->x;
- p.y = y + moz->pages[pi].image->y - py;
-
- ctm = pdfmoz_pagectm(moz, pi);
- ctm = fz_invertmatrix(ctm);
-
- p = fz_transformpoint(ctm, p);
-
- for (link = moz->pages[pi].page->links; link; link = link->next)
- {
- if (p.x >= link->rect.x0 && p.x <= link->rect.x1)
- if (p.y >= link->rect.y0 && p.y <= link->rect.y1)
- break;
- }
+ char buf[512];
+ pdf_link *link;
+ fz_matrix ctm;
+ fz_point p;
+ int pi;
+ int py;
+
+ if (!moz->pages)
+ return;
+
+ pi = moz->scrollpage;
+ py = -moz->scrollyofs;
+ while (pi < moz->pagecount)
+ {
+ if (!moz->pages[pi].image)
+ return;
+ if (y > py && y < moz->pages[pi].px)
+ break;
+ py += moz->pages[pi].px;
+ pi ++;
+ }
+ if (pi == moz->pagecount)
+ return;
+
+ p.x = x + moz->pages[pi].image->x;
+ p.y = y + moz->pages[pi].image->y - py;
+
+ ctm = pdfmoz_pagectm(moz, pi);
+ ctm = fz_invertmatrix(ctm);
+
+ p = fz_transformpoint(ctm, p);
+
+ for (link = moz->pages[pi].page->links; link; link = link->next)
+ {
+ if (p.x >= link->rect.x0 && p.x <= link->rect.x1)
+ if (p.y >= link->rect.y0 && p.y <= link->rect.y1)
+ break;
+ }
- if (link)
+ if (link)
+ {
+ SetCursor(moz->hand);
+ if (click)
{
- SetCursor(moz->hand);
- if (click)
- {
- if (fz_isstring(link->dest))
- pdfmoz_gotouri(moz, link->dest);
- if (fz_isindirect(link->dest))
- pdfmoz_gotopage(moz, link->dest);
- return;
- }
- else
- {
- if (fz_isstring(link->dest))
- {
- memcpy(buf, fz_tostrbuf(link->dest), fz_tostrlen(link->dest));
- buf[fz_tostrlen(link->dest)] = 0;
- NPN_Status(moz->inst, buf);
- }
- else if (fz_isindirect(link->dest))
- {
- sprintf(buf, "Go to page %d",
- pdfmoz_getpagenum(moz, link->dest) + 1);
- NPN_Status(moz->inst, buf);
- }
- else
- NPN_Status(moz->inst, "Say what?");
- }
+ if (fz_isstring(link->dest))
+ pdfmoz_gotouri(moz, link->dest);
+ if (fz_isindirect(link->dest))
+ pdfmoz_gotopage(moz, link->dest);
+ return;
}
else
{
- sprintf(buf, "Page %d of %d", moz->scrollpage + 1, moz->pagecount);
+ if (fz_isstring(link->dest))
+ {
+ memcpy(buf, fz_tostrbuf(link->dest), fz_tostrlen(link->dest));
+ buf[fz_tostrlen(link->dest)] = 0;
+ NPN_Status(moz->inst, buf);
+ }
+ else if (fz_isindirect(link->dest))
+ {
+ sprintf(buf, "Go to page %d",
+ pdfmoz_getpagenum(moz, link->dest) + 1);
NPN_Status(moz->inst, buf);
- SetCursor(moz->arrow);
+ }
+ else
+ NPN_Status(moz->inst, "Say what?");
}
+ }
+ else
+ {
+ sprintf(buf, "Page %d of %d", moz->scrollpage + 1, moz->pagecount);
+ NPN_Status(moz->inst, buf);
+ SetCursor(moz->arrow);
+ }
}
static void drawimage(HDC hdc, pdfmoz_t *moz, fz_pixmap *image, int yofs)
{
- int bmpstride = ((image->w * 3 + 3) / 4) * 4;
- char *bmpdata = fz_malloc(image->h * bmpstride);
- int x, y;
-
- if (!bmpdata)
- return;
-
- for (y = 0; y < image->h; y++)
+ int bmpstride = ((image->w * 3 + 3) / 4) * 4;
+ char *bmpdata = fz_malloc(image->h * bmpstride);
+ int x, y;
+
+ if (!bmpdata)
+ return;
+
+ for (y = 0; y < image->h; y++)
+ {
+ char *p = bmpdata + y * bmpstride;
+ char *s = image->samples + y * image->w * 4;
+ for (x = 0; x < image->w; x++)
{
- char *p = bmpdata + y * bmpstride;
- char *s = image->samples + y * image->w * 4;
- for (x = 0; x < image->w; x++)
- {
- p[x * 3 + 0] = s[x * 4 + 3];
- p[x * 3 + 1] = s[x * 4 + 2];
- p[x * 3 + 2] = s[x * 4 + 1];
- }
+ p[x * 3 + 0] = s[x * 4 + 3];
+ p[x * 3 + 1] = s[x * 4 + 2];
+ p[x * 3 + 2] = s[x * 4 + 1];
}
-
- moz->dibinf->bmiHeader.biWidth = image->w;
- moz->dibinf->bmiHeader.biHeight = -image->h;
- moz->dibinf->bmiHeader.biSizeImage = image->h * bmpstride;
- SetDIBitsToDevice(hdc,
- 0, /* destx */
- yofs, /* desty */
- image->w, /* destw */
- image->h, /* desth */
- 0, /* srcx */
- 0, /* srcy */
- 0, /* startscan */
- image->h, /* numscans */
- bmpdata, /* pBits */
- moz->dibinf, /* pInfo */
- DIB_RGB_COLORS /* color use flag */
- );
-
- fz_free(bmpdata);
+ }
+
+ moz->dibinf->bmiHeader.biWidth = image->w;
+ moz->dibinf->bmiHeader.biHeight = -image->h;
+ moz->dibinf->bmiHeader.biSizeImage = image->h * bmpstride;
+ SetDIBitsToDevice(hdc,
+ 0, /* destx */
+ yofs, /* desty */
+ image->w, /* destw */
+ image->h, /* desth */
+ 0, /* srcx */
+ 0, /* srcy */
+ 0, /* startscan */
+ image->h, /* numscans */
+ bmpdata, /* pBits */
+ moz->dibinf, /* pInfo */
+ DIB_RGB_COLORS /* color use flag */
+ );
+
+ fz_free(bmpdata);
}
LRESULT CALLBACK
MozWinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- pdfmoz_t *moz = (pdfmoz_t*) GetWindowLongPtr(hwnd, GWLP_USERDATA);
- char buf[256];
+ pdfmoz_t *moz = (pdfmoz_t*) GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ char buf[256];
+
+ int x = (signed short) LOWORD(lParam);
+ int y = (signed short) HIWORD(lParam);
+ int i, h;
+
+ SCROLLINFO si;
+ PAINTSTRUCT ps;
+ HDC hdc;
+ RECT rc;
+ RECT pad;
+ WORD sendmsg;
+ float zoom;
+
+ GetClientRect(hwnd, &rc);
+ h = rc.bottom - rc.top;
+
+ if (strlen(moz->error))
+ {
+ if (msg == WM_PAINT)
+ {
+ hdc = BeginPaint(hwnd, &ps);
+ FillRect(hdc, &rc, GetStockBrush(WHITE_BRUSH));
+ rc.top += 10;
+ rc.bottom -= 10;
+ rc.left += 10;
+ rc.right -= 10;
+ DrawText(hdc, moz->error, strlen(moz->error), &rc, 0);
+ // DT_SINGLELINE|DT_CENTER|DT_VCENTER);
+ EndPaint(hwnd, &ps);
+ }
+ if (msg == WM_MOUSEMOVE)
+ {
+ SetCursor(moz->arrow);
+ }
+ return 0;
+ }
+
+ switch (msg)
+ {
- int x = (signed short) LOWORD(lParam);
- int y = (signed short) HIWORD(lParam);
- int i, h;
+ case WM_PAINT:
+ GetClientRect(moz->hwnd, &rc);
- SCROLLINFO si;
- PAINTSTRUCT ps;
- HDC hdc;
- RECT rc;
- WORD sendmsg;
- float zoom;
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL;
+ GetScrollInfo(hwnd, SB_VERT, &si);
- GetClientRect(hwnd, &rc);
- h = rc.bottom - rc.top;
+ decodescroll(moz, si.nPos);
- if (strlen(moz->error))
+ /* evict out-of-range images and pages */
+ for (i = 0; i < moz->pagecount; i++)
{
- if (msg == WM_PAINT)
+ if (i < moz->scrollpage - 2 || i > moz->scrollpage + 6)
+ {
+ if (moz->pages[i].page)
{
- hdc = BeginPaint(hwnd, &ps);
- FillRect(hdc, &rc, GetStockBrush(WHITE_BRUSH));
-rc.top += 10;
-rc.bottom -= 10;
-rc.left += 10;
-rc.right -= 10;
- DrawText(hdc, moz->error, strlen(moz->error), &rc, 0);
-// DT_SINGLELINE|DT_CENTER|DT_VCENTER);
- EndPaint(hwnd, &ps);
+ pdf_droppage(moz->pages[i].page);
+ moz->pages[i].page = nil;
}
- if (msg == WM_MOUSEMOVE)
+ }
+ if (i < moz->scrollpage - 1 || i > moz->scrollpage + 3)
+ {
+ if (moz->pages[i].image)
{
- SetCursor(moz->arrow);
+ fz_droppixmap(moz->pages[i].image);
+ moz->pages[i].image = nil;
}
- return 0;
+ }
}
- switch (msg)
- {
-
- case WM_PAINT:
-
- si.cbSize = sizeof(si);
- si.fMask = SIF_ALL;
- GetScrollInfo(hwnd, SB_VERT, &si);
+ i = moz->scrollpage;
- decodescroll(moz, si.nPos);
+ pdfmoz_loadpage(moz, i);
+ if (moz->error[0]) return 0;
- /* evict out-of-range images and pages */
- for (i = 0; i < moz->pagecount; i++)
- {
- if (i < moz->scrollpage - 2 || i > moz->scrollpage + 6)
- {
- if (moz->pages[i].page)
- {
- pdf_droppage(moz->pages[i].page);
- moz->pages[i].page = nil;
- }
- }
- if (i < moz->scrollpage - 1 || i > moz->scrollpage + 3)
- {
- if (moz->pages[i].image)
- {
- fz_droppixmap(moz->pages[i].image);
- moz->pages[i].image = nil;
- }
- }
- }
+ pdfmoz_drawpage(moz, i);
+ if (moz->error[0]) return 0;
- i = moz->scrollpage;
+ y = -moz->scrollyofs;
+ while (y < h && i < moz->pagecount)
+ {
+ pdfmoz_loadpage(moz, i);
+ if (moz->error[0]) return 0;
+ pdfmoz_drawpage(moz, i);
+ if (moz->error[0]) return 0;
+ y += moz->pages[i].image->h;
+ i ++;
+ }
- pdfmoz_loadpage(moz, i);
- if (moz->error[0]) return 0;
+ hdc = BeginPaint(hwnd, &ps);
- pdfmoz_drawpage(moz, i);
- if (moz->error[0]) return 0;
+ pad.left = rc.left;
+ pad.right = rc.right;
- y = -moz->scrollyofs;
- while (y < h && i < moz->pagecount)
- {
- pdfmoz_loadpage(moz, i);
- if (moz->error[0]) return 0;
- pdfmoz_drawpage(moz, i);
- if (moz->error[0]) return 0;
- y += moz->pages[i].image->h;
- i ++;
- }
+ i = moz->scrollpage;
+ y = -moz->scrollyofs;
+ while (y < h && i < moz->pagecount)
+ {
+ drawimage(hdc, moz, moz->pages[i].image, y);
+ y += moz->pages[i].image->h;
+ i ++;
+
+ pad.top = y;
+ pad.bottom = y + PAD;
+ FillRect(hdc, &pad, moz->graybrush);
+ y += PAD;
+ }
- hdc = BeginPaint(hwnd, &ps);
+ if (y < h)
+ {
+ pad.top = y;
+ pad.bottom = h;
+ FillRect(hdc, &pad, moz->graybrush);
+ }
- i = moz->scrollpage;
- y = -moz->scrollyofs;
- while (y < h && i < moz->pagecount)
- {
- drawimage(hdc, moz, moz->pages[i].image, y);
- y += moz->pages[i].image->h;
- i ++;
- }
+ EndPaint(hwnd, &ps);
- if (y < h)
- {
- rc.top = y;
- rc.bottom = h;
- FillRect(hdc, &rc, GetStockBrush(BLACK_BRUSH));
- }
+ return 0;
- EndPaint(hwnd, &ps);
-
- return 0;
+ case WM_SIZE:
+ ShowScrollBar(moz->hwnd, SB_VERT, TRUE);
+ GetClientRect(moz->hwnd, &rc);
- case WM_SIZE:
- ShowScrollBar(moz->hwnd, SB_VERT, TRUE);
- GetClientRect(moz->hwnd, &rc);
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
+ si.nPos = 0;
+ si.nMin = 0;
+ si.nMax = 0;
+ // si.nPage = MAX(30, rc.bottom - rc.top - 30);
+ si.nPage = rc.bottom - rc.top;
- si.cbSize = sizeof(si);
- si.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
- si.nPos = 0;
- si.nMin = 0;
- si.nMax = 0;
- // si.nPage = MAX(30, rc.bottom - rc.top - 30);
- si.nPage = rc.bottom - rc.top;
+ for (i = 0; i < moz->pagecount; i++)
+ {
+ zoom = (rc.right - rc.left) / (float) moz->pages[i].w;
+ moz->pages[i].px = zoom * moz->pages[i].h + PAD;
- for (i = 0; i < moz->pagecount; i++)
+ if (moz->scrollpage == i)
+ {
+ si.nPos = si.nMax;
+ if (moz->pages[i].image)
{
- zoom = (rc.right - rc.left) / (float) moz->pages[i].w;
- moz->pages[i].px = zoom * moz->pages[i].h;
-
- if (moz->scrollpage == i)
- {
- si.nPos = si.nMax;
- if (moz->pages[i].image)
- {
- si.nPos +=
- moz->pages[i].px *
- moz->scrollyofs /
- moz->pages[i].image->h + 1;
- }
- }
-
- if (moz->pages[i].image)
- {
- fz_droppixmap(moz->pages[i].image);
- moz->pages[i].image = nil;
- }
-
- si.nMax += moz->pages[i].px;
+ si.nPos +=
+ moz->pages[i].px *
+ moz->scrollyofs /
+ moz->pages[i].image->h + 1;
}
+ }
- si.nMax --;
+ if (moz->pages[i].image)
+ {
+ fz_droppixmap(moz->pages[i].image);
+ moz->pages[i].image = nil;
+ }
- SetScrollInfo(moz->hwnd, SB_VERT, &si, TRUE);
+ si.nMax += moz->pages[i].px;
+ }
- break;
+ si.nMax --;
- case WM_MOUSEMOVE:
- pdfmoz_onmouse(moz, x, y, 0);
- break;
+ SetScrollInfo(moz->hwnd, SB_VERT, &si, TRUE);
- case WM_LBUTTONDOWN:
- SetFocus(hwnd);
- pdfmoz_onmouse(moz, x, y, 1);
- break;
+ break;
- case WM_VSCROLL:
+ case WM_MOUSEMOVE:
+ pdfmoz_onmouse(moz, x, y, 0);
+ break;
- si.cbSize = sizeof(si);
- si.fMask = SIF_ALL;
- GetScrollInfo(hwnd, SB_VERT, &si);
+ case WM_LBUTTONDOWN:
+ SetFocus(hwnd);
+ pdfmoz_onmouse(moz, x, y, 1);
+ break;
- switch (LOWORD(wParam))
- {
- case SB_BOTTOM: si.nPos = si.nMax; break;
- case SB_TOP: si.nPos = 0; break;
- case SB_LINEUP: si.nPos -= 50; break;
- case SB_LINEDOWN: si.nPos += 50; break;
- case SB_PAGEUP: si.nPos -= si.nPage; break;
- case SB_PAGEDOWN: si.nPos += si.nPage; break;
- case SB_THUMBTRACK: si.nPos = si.nTrackPos; break;
- case SB_THUMBPOSITION: si.nPos = si.nTrackPos; break;
- }
+ case WM_VSCROLL:
- si.fMask = SIF_POS;
- si.nPos = MAX(0, MIN(si.nPos, si.nMax));
- SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL;
+ GetScrollInfo(hwnd, SB_VERT, &si);
- InvalidateRect(moz->hwnd, NULL, FALSE);
+ switch (LOWORD(wParam))
+ {
+ case SB_BOTTOM: si.nPos = si.nMax; break;
+ case SB_TOP: si.nPos = 0; break;
+ case SB_LINEUP: si.nPos -= 50; break;
+ case SB_LINEDOWN: si.nPos += 50; break;
+ case SB_PAGEUP: si.nPos -= si.nPage; break;
+ case SB_PAGEDOWN: si.nPos += si.nPage; break;
+ case SB_THUMBTRACK: si.nPos = si.nTrackPos; break;
+ case SB_THUMBPOSITION: si.nPos = si.nTrackPos; break;
+ }
- decodescroll(moz, si.nPos);
- sprintf(buf, "Page %d of %d", moz->scrollpage + 1, moz->pagecount);
- NPN_Status(moz->inst, buf);
+ si.fMask = SIF_POS;
+ si.nPos = MAX(0, MIN(si.nPos, si.nMax));
+ SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
- return 0;
+ InvalidateRect(moz->hwnd, NULL, FALSE);
- case WM_MOUSEWHEEL:
- if ((signed short)HIWORD(wParam) > 0)
- SendMessage(hwnd, WM_VSCROLL, MAKELONG(SB_LINEUP, 0), 0);
- else
- SendMessage(hwnd, WM_VSCROLL, MAKELONG(SB_LINEDOWN, 0), 0);
- break;
+ decodescroll(moz, si.nPos);
+ sprintf(buf, "Page %d of %d", moz->scrollpage + 1, moz->pagecount);
+ NPN_Status(moz->inst, buf);
- case WM_KEYDOWN:
- sendmsg = 0xFFFF;
+ return 0;
- switch (wParam)
- {
- case VK_UP: sendmsg = SB_LINEUP; break;
- case VK_PRIOR: sendmsg = SB_PAGEUP; break;
- case ' ':
- case VK_NEXT: sendmsg = SB_PAGEDOWN; break;
- case '\r':
- case VK_DOWN: sendmsg = SB_LINEDOWN; break;
- case VK_HOME: sendmsg = SB_TOP; break;
- case VK_END: sendmsg = SB_BOTTOM; break;
- }
+ case WM_MOUSEWHEEL:
+ if ((signed short)HIWORD(wParam) > 0)
+ SendMessage(hwnd, WM_VSCROLL, MAKELONG(SB_LINEUP, 0), 0);
+ else
+ SendMessage(hwnd, WM_VSCROLL, MAKELONG(SB_LINEDOWN, 0), 0);
+ break;
- if (sendmsg != 0xFFFF)
- SendMessage(hwnd, WM_VSCROLL, MAKELONG(sendmsg, 0), 0);
+ case WM_KEYDOWN:
+ sendmsg = 0xFFFF;
- /* ick! someone eats events instead of bubbling... not my fault! */
+ switch (wParam)
+ {
+ case VK_UP: sendmsg = SB_LINEUP; break;
+ case VK_PRIOR: sendmsg = SB_PAGEUP; break;
+ case ' ':
+ case VK_NEXT: sendmsg = SB_PAGEDOWN; break;
+ case '\r':
+ case VK_DOWN: sendmsg = SB_LINEDOWN; break;
+ case VK_HOME: sendmsg = SB_TOP; break;
+ case VK_END: sendmsg = SB_BOTTOM; break;
+ }
- break;
+ if (sendmsg != 0xFFFF)
+ SendMessage(hwnd, WM_VSCROLL, MAKELONG(sendmsg, 0), 0);
- default:
- break;
+ /* ick! someone eats events instead of bubbling... not my fault! */
- }
+ break;
+
+ default:
+ break;
+
+ }
- return moz->winproc(hwnd, msg, wParam, lParam);
+ return moz->winproc(hwnd, msg, wParam, lParam);
}
NPError
NPP_New(NPMIMEType mime, NPP inst, uint16 mode,
- int16 argc, char *argn[], char *argv[], NPSavedData *saved)
+ int16 argc, char *argn[], char *argv[], NPSavedData *saved)
{
- pdfmoz_t *moz;
+ pdfmoz_t *moz;
- //MSG("NPP_New");
+ //MSG("NPP_New");
- moz = fz_malloc(sizeof(pdfmoz_t));
- if (!moz)
- return NPERR_OUT_OF_MEMORY_ERROR;
+ moz = fz_malloc(sizeof(pdfmoz_t));
+ if (!moz)
+ return NPERR_OUT_OF_MEMORY_ERROR;
- memset(moz, 0, sizeof(pdfmoz_t));
+ memset(moz, 0, sizeof(pdfmoz_t));
- sprintf(moz->error, "GhostPDF is loading the file...");
+ sprintf(moz->error, "MuPDF is loading the file...");
- moz->inst = inst;
+ moz->inst = inst;
- moz->arrow = LoadCursor(NULL, IDC_ARROW);
- moz->hand = LoadCursor(NULL, IDC_HAND);
- moz->wait = LoadCursor(NULL, IDC_WAIT);
+ moz->arrow = LoadCursor(NULL, IDC_ARROW);
+ moz->hand = LoadCursor(NULL, IDC_HAND);
+ moz->wait = LoadCursor(NULL, IDC_WAIT);
- moz->dibinf = fz_malloc(sizeof(BITMAPINFO) + 12);
- if (!moz->dibinf)
- return NPERR_OUT_OF_MEMORY_ERROR;
+ moz->dibinf = fz_malloc(sizeof(BITMAPINFO) + 12);
+ if (!moz->dibinf)
+ return NPERR_OUT_OF_MEMORY_ERROR;
- moz->dibinf->bmiHeader.biSize = sizeof(moz->dibinf->bmiHeader);
- moz->dibinf->bmiHeader.biPlanes = 1;
- moz->dibinf->bmiHeader.biBitCount = 24;
- moz->dibinf->bmiHeader.biCompression = BI_RGB;
- moz->dibinf->bmiHeader.biXPelsPerMeter = 2834;
- moz->dibinf->bmiHeader.biYPelsPerMeter = 2834;
- moz->dibinf->bmiHeader.biClrUsed = 0;
- moz->dibinf->bmiHeader.biClrImportant = 0;
- moz->dibinf->bmiHeader.biClrUsed = 0;
+ moz->dibinf->bmiHeader.biSize = sizeof(moz->dibinf->bmiHeader);
+ moz->dibinf->bmiHeader.biPlanes = 1;
+ moz->dibinf->bmiHeader.biBitCount = 24;
+ moz->dibinf->bmiHeader.biCompression = BI_RGB;
+ moz->dibinf->bmiHeader.biXPelsPerMeter = 2834;
+ moz->dibinf->bmiHeader.biYPelsPerMeter = 2834;
+ moz->dibinf->bmiHeader.biClrUsed = 0;
+ moz->dibinf->bmiHeader.biClrImportant = 0;
+ moz->dibinf->bmiHeader.biClrUsed = 0;
- inst->pdata = moz;
+ moz->graybrush = CreateSolidBrush(RGB(0x70,0x70,0x70));
- return NPERR_NO_ERROR;
+ inst->pdata = moz;
+
+ return NPERR_NO_ERROR;
}
NPError
NPP_Destroy(NPP inst, NPSavedData **saved)
{
- pdfmoz_t *moz = inst->pdata;
- int i;
+ pdfmoz_t *moz = inst->pdata;
+ int i;
- //MSG("NPP_Destroy");
+ //MSG("NPP_Destroy");
- inst->pdata = NULL;
+ inst->pdata = NULL;
- DestroyCursor(moz->arrow);
- DestroyCursor(moz->hand);
- DestroyCursor(moz->wait);
+ DeleteObject(moz->graybrush);
- fz_free(moz->dibinf);
+ DestroyCursor(moz->arrow);
+ DestroyCursor(moz->hand);
+ DestroyCursor(moz->wait);
- for (i = 0; i < moz->pagecount; i++)
- {
- if (moz->pages[i].obj)
- fz_dropobj(moz->pages[i].obj);
- if (moz->pages[i].page)
- pdf_droppage(moz->pages[i].page);
- if (moz->pages[i].image)
- fz_droppixmap(moz->pages[i].image);
- }
+ fz_free(moz->dibinf);
- fz_free(moz->pages);
+ for (i = 0; i < moz->pagecount; i++)
+ {
+ if (moz->pages[i].obj)
+ fz_dropobj(moz->pages[i].obj);
+ if (moz->pages[i].page)
+ pdf_droppage(moz->pages[i].page);
+ if (moz->pages[i].image)
+ fz_droppixmap(moz->pages[i].image);
+ }
- if (moz->xref)
- {
- if (moz->xref->store)
- {
- pdf_dropstore(moz->xref->store);
- moz->xref->store = nil;
- }
+ fz_free(moz->pages);
- pdf_closexref(moz->xref);
+ if (moz->xref)
+ {
+ if (moz->xref->store)
+ {
+ pdf_dropstore(moz->xref->store);
+ moz->xref->store = nil;
}
- fz_free(moz);
+ pdf_closexref(moz->xref);
+ }
+
+ fz_free(moz);
- return NPERR_NO_ERROR;
+ return NPERR_NO_ERROR;
}
NPError
NPP_SetWindow(NPP inst, NPWindow *npwin)
{
- pdfmoz_t *moz = inst->pdata;
+ pdfmoz_t *moz = inst->pdata;
- if (moz->hwnd != npwin->window)
- {
- moz->hwnd = npwin->window;
- SetWindowLongPtr(moz->hwnd, GWLP_USERDATA, (LONG_PTR)moz);
- moz->winproc = (WNDPROC)
- SetWindowLongPtr(moz->hwnd, GWLP_WNDPROC, (LONG_PTR)MozWinProc);
- }
+ if (moz->hwnd != npwin->window)
+ {
+ moz->hwnd = npwin->window;
+ SetWindowLongPtr(moz->hwnd, GWLP_USERDATA, (LONG_PTR)moz);
+ moz->winproc = (WNDPROC)
+ SetWindowLongPtr(moz->hwnd, GWLP_WNDPROC, (LONG_PTR)MozWinProc);
+ }
- SetFocus(moz->hwnd);
+ SetFocus(moz->hwnd);
- return NPERR_NO_ERROR;
+ return NPERR_NO_ERROR;
}
NPError
NPP_NewStream(NPP inst, NPMIMEType type,
- NPStream* stream, NPBool seekable,
- uint16* stype)
+ NPStream* stream, NPBool seekable,
+ uint16* stype)
{
- //MSG("NPP_NewStream");
- *stype = NP_ASFILE;
- return NPERR_NO_ERROR;
+ //MSG("NPP_NewStream");
+ *stype = NP_ASFILE;
+ return NPERR_NO_ERROR;
}
NPError
NPP_DestroyStream(NPP inst, NPStream* stream, NPReason reason)
{
- //MSG("NPP_DestroyStream");
- return NPERR_NO_ERROR;
+ //MSG("NPP_DestroyStream");
+ return NPERR_NO_ERROR;
}
int32
NPP_WriteReady(NPP inst, NPStream* stream)
{
- //MSG("NPP_WriteReady");
- return 2147483647;
+ //MSG("NPP_WriteReady");
+ return 2147483647;
}
int32
NPP_Write(NPP inst, NPStream* stream, int32 offset, int32 len, void* buffer)
{
- //MSG("NPP_Write");
- return len;
+ //MSG("NPP_Write");
+ return len;
}
void
NPP_StreamAsFile(NPP inst, NPStream* stream, const char* fname)
{
- pdfmoz_t *moz = inst->pdata;
- //MSG("NPP_StreamAsFile");
- pdfmoz_open(moz, (char*)fname);
+ pdfmoz_t *moz = inst->pdata;
+ //MSG("NPP_StreamAsFile");
+ pdfmoz_open(moz, (char*)fname);
}
void
NPP_Print(NPP inst, NPPrint* platformPrint)
{
- MSG("Sorry, printing is not supported.");
+ MSG("Sorry, printing is not supported.");
}
int16
NPP_HandleEvent(NPP inst, void* event)
{
- MSG("handle event\n");
- return 0;
+ MSG("handle event\n");
+ return 0;
}
void
NPP_URLNotify(NPP inst, const char* url,
- NPReason reason, void* notifyData)
+ NPReason reason, void* notifyData)
{
- MSG("notify url\n");
+ MSG("notify url\n");
}
NPError
NPP_GetValue(void* inst, NPPVariable variable, void *value)
{
- return NPERR_NO_ERROR;
+ return NPERR_NO_ERROR;
}
NPError
NPP_SetValue(void* inst, NPNVariable variable, void *value)
{
- return NPERR_NO_ERROR;
+ return NPERR_NO_ERROR;
}
void* NPP_GetJavaClass(void)
{
- return 0;
+ return 0;
}
NPError
NPP_Initialize(void)
{
-// MSG("NPP_Initialize");
- return NPERR_NO_ERROR;
+ // MSG("NPP_Initialize");
+ return NPERR_NO_ERROR;
}
void
NPP_Shutdown(void)
{
-// MSG("NPP_Shutdown");
+ // MSG("NPP_Shutdown");
}
diff --git a/apps/mozilla/moz_winres.rc b/apps/mozilla/moz_winres.rc
index da421383..ad37bf2b 100644
--- a/apps/mozilla/moz_winres.rc
+++ b/apps/mozilla/moz_winres.rc
@@ -11,7 +11,7 @@ BEGIN
BEGIN
VALUE "ProductName", "MuPDF Plug-in\0"
VALUE "OriginalFilename", "npmupdf.dll\0"
- VALUE "FileDescription", "The MuPDF plugin allows you to browse PDF files with a simple light-weight scrolling interface.<br>See <a href=""http://ghostscript.com/~tor/software/fitz.html">ghostscript.com</a> for more information.\0"
+ VALUE "FileDescription", "The MuPDF plugin allows you to browse PDF files with a simple light-weight scrolling interface.\0"
VALUE "MIMEType", "application/pdf|application/x-mupdf\0"
VALUE "FileExtents", "pdf|foo"
VALUE "FileOpenName", "Acrobat PDF File|Acrobat PDF File"
diff --git a/apps/mozilla/npwin.c b/apps/mozilla/npwin.c
index 398e3622..5d60a893 100644
--- a/apps/mozilla/npwin.c
+++ b/apps/mozilla/npwin.c
@@ -38,8 +38,8 @@ Private_GetJavaClass(void)
{
jref clazz = NPP_GetJavaClass();
if (clazz) {
- JRIEnv* env = NPN_GetJavaEnv();
- return JRI_NewGlobalRef(env, clazz);
+ JRIEnv* env = NPN_GetJavaEnv();
+ return JRI_NewGlobalRef(env, clazz);
}
return NULL;
}
@@ -70,7 +70,7 @@ NP_GetEntryPoints(NPPluginFuncs* pFuncs)
{
// trap a NULL ptr
if(pFuncs == NULL)
- return NPERR_INVALID_FUNCTABLE_ERROR;
+ return NPERR_INVALID_FUNCTABLE_ERROR;
// if the plugin's function table is smaller than the plugin expects,
// then they are incompatible, and should return an error
@@ -87,7 +87,7 @@ NP_GetEntryPoints(NPPluginFuncs* pFuncs)
pFuncs->print = NPP_Print;
pFuncs->event = 0; /// reserved
- g_pluginFuncs = pFuncs;
+ g_pluginFuncs = pFuncs;
return NPERR_NO_ERROR;
}
@@ -103,31 +103,31 @@ NP_Initialize(NPNetscapeFuncs* pFuncs)
{
// trap a NULL ptr
if(pFuncs == NULL)
- return NPERR_INVALID_FUNCTABLE_ERROR;
+ return NPERR_INVALID_FUNCTABLE_ERROR;
g_pNavigatorFuncs = pFuncs; // save it for future reference
// if the plugin's major ver level is lower than the Navigator's,
// then they are incompatible, and should return an error
if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
- return NPERR_INCOMPATIBLE_VERSION_ERROR;
+ return NPERR_INCOMPATIBLE_VERSION_ERROR;
- // We have to defer these assignments until g_pNavigatorFuncs is set
+ // We have to defer these assignments until g_pNavigatorFuncs is set
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
- if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
- g_pluginFuncs->urlnotify = NPP_URLNotify;
- }
-
+ if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
+ g_pluginFuncs->urlnotify = NPP_URLNotify;
+ }
+
#ifdef WIN32 // An ugly hack, because Win16 lags behind in Java
- if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) {
+ if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) {
#else
- if( navMinorVers >= NPVERS_WIN16_HAS_LIVECONNECT )
+ if( navMinorVers >= NPVERS_WIN16_HAS_LIVECONNECT ) {
#endif // WIN32
- g_pluginFuncs->javaClass = Private_GetJavaClass();
- }
+ g_pluginFuncs->javaClass = Private_GetJavaClass();
+ }
- // NPP_Initialize is a standard (cross-platform) initialize function.
+ // NPP_Initialize is a standard (cross-platform) initialize function.
return NPP_Initialize();
}
@@ -180,17 +180,16 @@ void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int*
/* causes the specified URL to be fetched and streamed in
*/
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
-
{
- int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
- NPError err;
- if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
- err = g_pNavigatorFuncs->geturlnotify(instance, url, target, notifyData);
- }
- else {
- err = NPERR_INCOMPATIBLE_VERSION_ERROR;
- }
- return err;
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ NPError err;
+ if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
+ err = g_pNavigatorFuncs->geturlnotify(instance, url, target, notifyData);
+ }
+ else {
+ err = NPERR_INCOMPATIBLE_VERSION_ERROR;
+ }
+ return err;
}
@@ -201,15 +200,15 @@ NPError NPN_GetURL(NPP instance, const char *url, const char *target)
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
{
- int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
- NPError err;
- if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
- err = g_pNavigatorFuncs->posturlnotify(instance, url, window, len, buf, file, notifyData);
- }
- else {
- err = NPERR_INCOMPATIBLE_VERSION_ERROR;
- }
- return err;
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ NPError err;
+ if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
+ err = g_pNavigatorFuncs->posturlnotify(instance, url, window, len, buf, file, notifyData);
+ }
+ else {
+ err = NPERR_INCOMPATIBLE_VERSION_ERROR;
+ }
+ return err;
}
@@ -229,37 +228,36 @@ NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
/* Creates a new stream of data from the plug-in to be interpreted
by Netscape in the current window.
-*/
+ */
NPError NPN_NewStream(NPP instance, NPMIMEType type,
- const char* target, NPStream** stream)
+ const char* target, NPStream** stream)
{
- int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
- NPError err;
-
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
- err = g_pNavigatorFuncs->newstream(instance, type, target, stream);
- }
- else {
- err = NPERR_INCOMPATIBLE_VERSION_ERROR;
- }
- return err;
+ int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
+ NPError err;
+
+ if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
+ err = g_pNavigatorFuncs->newstream(instance, type, target, stream);
+ }
+ else {
+ err = NPERR_INCOMPATIBLE_VERSION_ERROR;
+ }
+ return err;
}
/* Provides len bytes of data.
*/
-int32 NPN_Write(NPP instance, NPStream *stream,
- int32 len, void *buffer)
+int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
{
- int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
- int32 result;
-
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
- result = g_pNavigatorFuncs->write(instance, stream, len, buffer);
- }
- else {
- result = -1;
- }
- return result;
+ int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
+ int32 result;
+
+ if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
+ result = g_pNavigatorFuncs->write(instance, stream, len, buffer);
+ }
+ else {
+ result = -1;
+ }
+ return result;
}
/* Closes a stream object.
@@ -267,16 +265,16 @@ reason indicates why the stream was closed.
*/
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
- int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
- NPError err;
-
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
- err = g_pNavigatorFuncs->destroystream(instance, stream, reason);
- }
- else {
- err = NPERR_INCOMPATIBLE_VERSION_ERROR;
- }
- return err;
+ int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
+ NPError err;
+
+ if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
+ err = g_pNavigatorFuncs->destroystream(instance, stream, reason);
+ }
+ else {
+ err = NPERR_INCOMPATIBLE_VERSION_ERROR;
+ }
+ return err;
}
/* Provides a text status message in the Netscape client user interface
@@ -311,7 +309,7 @@ void NPN_MemFree(void* ptr)
}
/* private function to Netscape. do not use!
-*/
+ */
void NPN_ReloadPlugins(NPBool reloadPages)
{
g_pNavigatorFuncs->reloadplugins(reloadPages);
@@ -319,11 +317,11 @@ void NPN_ReloadPlugins(NPBool reloadPages)
JRIEnv* NPN_GetJavaEnv(void)
{
- return g_pNavigatorFuncs->getJavaEnv();
+ return g_pNavigatorFuncs->getJavaEnv();
}
jref NPN_GetJavaPeer(NPP instance)
{
- return g_pNavigatorFuncs->getJavaPeer(instance);
+ return g_pNavigatorFuncs->getJavaPeer(instance);
}
diff --git a/apps/windows/winmain.c b/apps/windows/winmain.c
index cd06d41a..0ce61472 100644
--- a/apps/windows/winmain.c
+++ b/apps/windows/winmain.c
@@ -15,7 +15,7 @@ static HDC hdc;
static HBRUSH bgbrush;
static HBRUSH shbrush;
static BITMAPINFO *dibinf;
-static TCHAR szAppName[] = TEXT("fzview");
+static TCHAR szAppName[] = TEXT("Apparition");
static HCURSOR arrowcurs, handcurs, waitcurs;
static LRESULT CALLBACK windproc(HWND, UINT, WPARAM, LPARAM);
@@ -26,75 +26,75 @@ static int justcopied = 0;
static pdfapp_t gapp;
/*
- * Associate FzView with PDF files.
+ * Associate Apparition with PDF files.
*/
void associate(char *argv0)
{
- char tmp[256];
- char *name = "Adobe PDF Document";
- HKEY key, kicon, kshell, kopen, kcmd;
- DWORD disp;
+ char tmp[256];
+ char *name = "Adobe PDF Document";
+ HKEY key, kicon, kshell, kopen, kcmd;
+ DWORD disp;
- /* HKEY_CLASSES_ROOT\.pdf */
+ /* HKEY_CLASSES_ROOT\.pdf */
- if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
- ".pdf", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &key, &disp))
- return;
+ if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
+ ".pdf", 0, NULL, REG_OPTION_NON_VOLATILE,
+ KEY_WRITE, NULL, &key, &disp))
+ return;
- if (RegSetValueEx(key, "", 0, REG_SZ, "FzView", strlen("FzView")+1))
- return;
+ if (RegSetValueEx(key, "", 0, REG_SZ, "Apparition", strlen("Apparition")+1))
+ return;
- RegCloseKey(key);
+ RegCloseKey(key);
- /* HKEY_CLASSES_ROOT\FzView */
+ /* HKEY_CLASSES_ROOT\Apparition */
- if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
- "FzView", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &key, &disp))
- return;
+ if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
+ "Apparition", 0, NULL, REG_OPTION_NON_VOLATILE,
+ KEY_WRITE, NULL, &key, &disp))
+ return;
- if (RegSetValueEx(key, "", 0, REG_SZ, name, strlen(name)+1))
- return;
+ if (RegSetValueEx(key, "", 0, REG_SZ, name, strlen(name)+1))
+ return;
- /* HKEY_CLASSES_ROOT\FzView\DefaultIcon */
+ /* HKEY_CLASSES_ROOT\Apparition\DefaultIcon */
- if (RegCreateKeyEx(key,
- "DefaultIcon", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &kicon, &disp))
- return;
+ if (RegCreateKeyEx(key,
+ "DefaultIcon", 0, NULL, REG_OPTION_NON_VOLATILE,
+ KEY_WRITE, NULL, &kicon, &disp))
+ return;
- sprintf(tmp, "%s,1", argv0);
- if (RegSetValueEx(kicon, "", 0, REG_SZ, tmp, strlen(tmp)+1))
- return;
+ sprintf(tmp, "%s,1", argv0);
+ if (RegSetValueEx(kicon, "", 0, REG_SZ, tmp, strlen(tmp)+1))
+ return;
- RegCloseKey(kicon);
+ RegCloseKey(kicon);
- /* HKEY_CLASSES_ROOT\FzView\Shell\Open\Command */
+ /* HKEY_CLASSES_ROOT\Apparition\Shell\Open\Command */
- if (RegCreateKeyEx(key,
- "shell", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &kshell, &disp))
- return;
- if (RegCreateKeyEx(kshell,
- "open", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &kopen, &disp))
- return;
- if (RegCreateKeyEx(kopen,
- "command", 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &kcmd, &disp))
- return;
+ if (RegCreateKeyEx(key,
+ "shell", 0, NULL, REG_OPTION_NON_VOLATILE,
+ KEY_WRITE, NULL, &kshell, &disp))
+ return;
+ if (RegCreateKeyEx(kshell,
+ "open", 0, NULL, REG_OPTION_NON_VOLATILE,
+ KEY_WRITE, NULL, &kopen, &disp))
+ return;
+ if (RegCreateKeyEx(kopen,
+ "command", 0, NULL, REG_OPTION_NON_VOLATILE,
+ KEY_WRITE, NULL, &kcmd, &disp))
+ return;
- sprintf(tmp, "\"%s\" \"%%1\"", argv0);
- if (RegSetValueEx(kcmd, "", 0, REG_SZ, tmp, strlen(tmp)+1))
- return;
+ sprintf(tmp, "\"%s\" \"%%1\"", argv0);
+ if (RegSetValueEx(kcmd, "", 0, REG_SZ, tmp, strlen(tmp)+1))
+ return;
- RegCloseKey(kcmd);
- RegCloseKey(kopen);
- RegCloseKey(kshell);
+ RegCloseKey(kcmd);
+ RegCloseKey(kopen);
+ RegCloseKey(kshell);
- RegCloseKey(key);
+ RegCloseKey(key);
}
/*
@@ -103,27 +103,27 @@ void associate(char *argv0)
void winwarn(pdfapp_t *app, char *msg)
{
- MessageBoxA(hwnd, msg, "FzView: Warning", MB_ICONWARNING);
+ MessageBoxA(hwnd, msg, "Apparition: Warning", MB_ICONWARNING);
}
void winerror(pdfapp_t *app, char *msg)
{
- MessageBoxA(hwnd, msg, "FzView: Error", MB_ICONERROR);
- exit(1);
+ MessageBoxA(hwnd, msg, "Apparition: Error", MB_ICONERROR);
+ exit(1);
}
int winfilename(char *buf, int len)
{
OPENFILENAME ofn;
- strcpy(buf, "");
+ strcpy(buf, "");
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = buf;
ofn.nMaxFile = len;
ofn.lpstrInitialDir = NULL;
- ofn.lpstrTitle = "FzView: Open PDF file";
- ofn.lpstrFilter = "PDF Files (*.pdf)\0*.pdf\0All Files\0*\0\0";
+ ofn.lpstrTitle = "Apparition: Open PDF file";
+ ofn.lpstrFilter = "PDF Files (*.pdf)\0*.pdf\0All Files\0*\0\0";
ofn.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
return GetOpenFileName(&ofn);
}
@@ -135,144 +135,144 @@ static int pd_okay = 0;
INT CALLBACK
dlogpassproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message)
+ switch(message)
+ {
+ case WM_INITDIALOG:
+ SetDlgItemText(hwnd, 4, pd_filename);
+ return TRUE;
+ case WM_COMMAND:
+ switch(wParam)
{
- case WM_INITDIALOG:
- SetDlgItemText(hwnd, 4, pd_filename);
- return TRUE;
- case WM_COMMAND:
- switch(wParam)
- {
- case 1:
- pd_okay = 1;
- GetDlgItemText(hwnd, 3, pd_password, sizeof pd_password);
- EndDialog(hwnd, 0);
- return TRUE;
- case 2:
- pd_okay = 0;
- EndDialog(hwnd, 0);
- return TRUE;
- }
- break;
+ case 1:
+ pd_okay = 1;
+ GetDlgItemText(hwnd, 3, pd_password, sizeof pd_password);
+ EndDialog(hwnd, 0);
+ return TRUE;
+ case 2:
+ pd_okay = 0;
+ EndDialog(hwnd, 0);
+ return TRUE;
}
- return FALSE;
+ break;
+ }
+ return FALSE;
}
char *winpassword(pdfapp_t *app, char *filename)
{
- char buf[124], *s;
- strcpy(buf, filename);
- s = buf;
- if (strrchr(s, '\\')) s = strrchr(s, '\\') + 1;
- if (strrchr(s, '/')) s = strrchr(s, '/') + 1;
- if (strlen(s) > 32)
- strcpy(s + 30, "...");
- sprintf(pd_filename, "The file \"%s\" is encrypted.", s);
- DialogBox(NULL, "IDD_DLOGPASS", hwnd, dlogpassproc);
- if (pd_okay)
- return pd_password;
- return NULL;
+ char buf[124], *s;
+ strcpy(buf, filename);
+ s = buf;
+ if (strrchr(s, '\\')) s = strrchr(s, '\\') + 1;
+ if (strrchr(s, '/')) s = strrchr(s, '/') + 1;
+ if (strlen(s) > 32)
+ strcpy(s + 30, "...");
+ sprintf(pd_filename, "The file \"%s\" is encrypted.", s);
+ DialogBox(NULL, "IDD_DLOGPASS", hwnd, dlogpassproc);
+ if (pd_okay)
+ return pd_password;
+ return NULL;
}
INT CALLBACK
dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- char buf[256];
- pdf_xref *xref = gapp.xref;
- fz_obj *obj;
+ char buf[256];
+ pdf_xref *xref = gapp.xref;
+ fz_obj *obj;
- switch(message)
+ switch(message)
+ {
+ case WM_INITDIALOG:
+
+ SetDlgItemTextA(hwnd, 0x10, gapp.filename);
+
+ sprintf(buf, "PDF %g", xref->version);
+ SetDlgItemTextA(hwnd, 0x11, buf);
+
+ if (xref->crypt)
{
- case WM_INITDIALOG:
-
- SetDlgItemTextA(hwnd, 0x10, gapp.filename);
-
- sprintf(buf, "PDF %g", xref->version);
- SetDlgItemTextA(hwnd, 0x11, buf);
-
- if (xref->crypt)
- {
- sprintf(buf, "Standard %d bit RC4", xref->crypt->n * 8);
- SetDlgItemTextA(hwnd, 0x12, buf);
- strcpy(buf, "");
- if (xref->crypt->p & (1 << 2))
- strcat(buf, "print, ");
- if (xref->crypt->p & (1 << 3))
- strcat(buf, "modify, ");
- if (xref->crypt->p & (1 << 4))
- strcat(buf, "copy, ");
- if (xref->crypt->p & (1 << 5))
- strcat(buf, "annotate, ");
- if (strlen(buf) > 2)
- buf[strlen(buf)-2] = 0;
- else
- strcpy(buf, "none");
- SetDlgItemTextA(hwnd, 0x13, buf);
- }
- else
- {
- SetDlgItemTextA(hwnd, 0x12, "None");
- SetDlgItemTextA(hwnd, 0x13, "n/a");
- }
-
- if (!xref->info)
- return TRUE;
-
- #define SETUCS(ID) \
+ sprintf(buf, "Standard %d bit RC4", xref->crypt->n * 8);
+ SetDlgItemTextA(hwnd, 0x12, buf);
+ strcpy(buf, "");
+ if (xref->crypt->p & (1 << 2))
+ strcat(buf, "print, ");
+ if (xref->crypt->p & (1 << 3))
+ strcat(buf, "modify, ");
+ if (xref->crypt->p & (1 << 4))
+ strcat(buf, "copy, ");
+ if (xref->crypt->p & (1 << 5))
+ strcat(buf, "annotate, ");
+ if (strlen(buf) > 2)
+ buf[strlen(buf)-2] = 0;
+ else
+ strcpy(buf, "none");
+ SetDlgItemTextA(hwnd, 0x13, buf);
+ }
+ else
+ {
+ SetDlgItemTextA(hwnd, 0x12, "None");
+ SetDlgItemTextA(hwnd, 0x13, "n/a");
+ }
+
+ if (!xref->info)
+ return TRUE;
+
+#define SETUCS(ID) \
+ { \
+ fz_error *error; \
+ unsigned short *ucs; \
+ error = pdf_toucs2(&ucs, obj); \
+ if (!error) \
{ \
- fz_error *error; \
- unsigned short *ucs; \
- error = pdf_toucs2(&ucs, obj); \
- if (!error) \
- { \
- SetDlgItemTextW(hwnd, ID, ucs); \
- fz_free(ucs); \
- } \
- }
-
- if ((obj = fz_dictgets(xref->info, "Title"))) SETUCS(0x20)
- if ((obj = fz_dictgets(xref->info, "Author"))) SETUCS(0x21)
- if ((obj = fz_dictgets(xref->info, "Subject"))) SETUCS(0x22)
- if ((obj = fz_dictgets(xref->info, "Keywords"))) SETUCS(0x23)
- if ((obj = fz_dictgets(xref->info, "Creator"))) SETUCS(0x24)
- if ((obj = fz_dictgets(xref->info, "Producer"))) SETUCS(0x25)
- if ((obj = fz_dictgets(xref->info, "CreationDate"))) SETUCS(0x26)
- if ((obj = fz_dictgets(xref->info, "ModDate"))) SETUCS(0x27)
-
- return TRUE;
-
- case WM_COMMAND:
- EndDialog(hwnd, 0);
- return TRUE;
+ SetDlgItemTextW(hwnd, ID, ucs); \
+ fz_free(ucs); \
+ } \
}
- return FALSE;
+
+ if ((obj = fz_dictgets(xref->info, "Title"))) SETUCS(0x20)
+ if ((obj = fz_dictgets(xref->info, "Author"))) SETUCS(0x21)
+ if ((obj = fz_dictgets(xref->info, "Subject"))) SETUCS(0x22)
+ if ((obj = fz_dictgets(xref->info, "Keywords"))) SETUCS(0x23)
+ if ((obj = fz_dictgets(xref->info, "Creator"))) SETUCS(0x24)
+ if ((obj = fz_dictgets(xref->info, "Producer"))) SETUCS(0x25)
+ if ((obj = fz_dictgets(xref->info, "CreationDate"))) SETUCS(0x26)
+ if ((obj = fz_dictgets(xref->info, "ModDate"))) SETUCS(0x27)
+
+ return TRUE;
+
+ case WM_COMMAND:
+ EndDialog(hwnd, 0);
+ return TRUE;
+ }
+ return FALSE;
}
void info()
{
- DialogBox(NULL, "IDD_DLOGINFO", hwnd, dloginfoproc);
+ DialogBox(NULL, "IDD_DLOGINFO", hwnd, dloginfoproc);
}
INT CALLBACK
dlogaboutproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message)
- {
- case WM_INITDIALOG:
- SetDlgItemTextA(hwnd, 0x10, gapp.filename);
- SetDlgItemTextA(hwnd, 2, "FzView is Copyright (C) 2005 artofcode, LLC");
- SetDlgItemTextA(hwnd, 3, pdfapp_usage(&gapp));
- return TRUE;
- case WM_COMMAND:
- EndDialog(hwnd, 0);
- return TRUE;
- }
- return FALSE;
+ switch(message)
+ {
+ case WM_INITDIALOG:
+ SetDlgItemTextA(hwnd, 0x10, gapp.filename);
+ SetDlgItemTextA(hwnd, 2, "Apparition is Copyright (C) 2006 artofcode, LLC");
+ SetDlgItemTextA(hwnd, 3, pdfapp_usage(&gapp));
+ return TRUE;
+ case WM_COMMAND:
+ EndDialog(hwnd, 0);
+ return TRUE;
+ }
+ return FALSE;
}
void help()
{
- DialogBox(NULL, "IDD_DLOGABOUT", hwnd, dlogaboutproc);
+ DialogBox(NULL, "IDD_DLOGABOUT", hwnd, dlogaboutproc);
}
/*
@@ -281,228 +281,228 @@ void help()
void winopen()
{
- WNDCLASS wc;
- HMENU menu;
- RECT r;
-
- /* Create and register window class */
- wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
- wc.lpfnWndProc = windproc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = GetModuleHandle(NULL);
- wc.hIcon = LoadIcon(wc.hInstance, "IDI_ICONAPP");
- wc.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = NULL;//(HBRUSH) GetStockObject(BLACK_BRUSH);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = szAppName;
- assert(RegisterClass(&wc) && "Register window class");
-
- /* Get screen size */
- SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
- gapp.scrw = r.right - r.left;
- gapp.scrh = r.bottom - r.top;
-
- /* Create cursors */
- arrowcurs = LoadCursor(NULL, IDC_ARROW);
- handcurs = LoadCursor(NULL, IDC_HAND);
- waitcurs = LoadCursor(NULL, IDC_WAIT);
-
- /* And a background color */
- bgbrush = CreateSolidBrush(RGB(0x70,0x70,0x70));
- shbrush = CreateSolidBrush(RGB(0x40,0x40,0x40));
-
- /* Init DIB info for buffer */
- dibinf = malloc(sizeof(BITMAPINFO) + 12);
- assert(dibinf != NULL);
- dibinf->bmiHeader.biSize = sizeof(dibinf->bmiHeader);
- dibinf->bmiHeader.biPlanes = 1;
- dibinf->bmiHeader.biBitCount = 24;
- dibinf->bmiHeader.biCompression = BI_RGB;
- dibinf->bmiHeader.biXPelsPerMeter = 2834;
- dibinf->bmiHeader.biYPelsPerMeter = 2834;
- dibinf->bmiHeader.biClrUsed = 0;
- dibinf->bmiHeader.biClrImportant = 0;
- dibinf->bmiHeader.biClrUsed = 0;
-
- /* Create window */
- hwnd = CreateWindow(szAppName, // window class name
- NULL, // window caption
- WS_OVERLAPPEDWINDOW,
- 5, //CW_USEDEFAULT, // initial x position
- 5, //CW_USEDEFAULT, // initial y position
- 300, // initial x size
- 300, // initial y size
- NULL, // parent window handle
- NULL, // window menu handle
- 0,//hInstance, // program instance handle
- NULL); // creation parameters
-
- hdc = NULL;
-
- SetWindowTextA(hwnd, "FzView");
-
- menu = GetSystemMenu(hwnd, 0);
- AppendMenu(menu, MF_SEPARATOR, 0, NULL);
- AppendMenu(menu, MF_STRING, ID_ABOUT, "About FzView...");
- AppendMenu(menu, MF_STRING, ID_DOCINFO, "Document Properties...");
-
- SetCursor(arrowcurs);
+ WNDCLASS wc;
+ HMENU menu;
+ RECT r;
+
+ /* Create and register window class */
+ wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
+ wc.lpfnWndProc = windproc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = GetModuleHandle(NULL);
+ wc.hIcon = LoadIcon(wc.hInstance, "IDI_ICONAPP");
+ wc.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = NULL;//(HBRUSH) GetStockObject(BLACK_BRUSH);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = szAppName;
+ assert(RegisterClass(&wc) && "Register window class");
+
+ /* Get screen size */
+ SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
+ gapp.scrw = r.right - r.left;
+ gapp.scrh = r.bottom - r.top;
+
+ /* Create cursors */
+ arrowcurs = LoadCursor(NULL, IDC_ARROW);
+ handcurs = LoadCursor(NULL, IDC_HAND);
+ waitcurs = LoadCursor(NULL, IDC_WAIT);
+
+ /* And a background color */
+ bgbrush = CreateSolidBrush(RGB(0x70,0x70,0x70));
+ shbrush = CreateSolidBrush(RGB(0x40,0x40,0x40));
+
+ /* Init DIB info for buffer */
+ dibinf = malloc(sizeof(BITMAPINFO) + 12);
+ assert(dibinf != NULL);
+ dibinf->bmiHeader.biSize = sizeof(dibinf->bmiHeader);
+ dibinf->bmiHeader.biPlanes = 1;
+ dibinf->bmiHeader.biBitCount = 24;
+ dibinf->bmiHeader.biCompression = BI_RGB;
+ dibinf->bmiHeader.biXPelsPerMeter = 2834;
+ dibinf->bmiHeader.biYPelsPerMeter = 2834;
+ dibinf->bmiHeader.biClrUsed = 0;
+ dibinf->bmiHeader.biClrImportant = 0;
+ dibinf->bmiHeader.biClrUsed = 0;
+
+ /* Create window */
+ hwnd = CreateWindow(szAppName, // window class name
+ NULL, // window caption
+ WS_OVERLAPPEDWINDOW,
+ 5, //CW_USEDEFAULT, // initial x position
+ 5, //CW_USEDEFAULT, // initial y position
+ 300, // initial x size
+ 300, // initial y size
+ NULL, // parent window handle
+ NULL, // window menu handle
+ 0,//hInstance, // program instance handle
+ NULL); // creation parameters
+
+ hdc = NULL;
+
+ SetWindowTextA(hwnd, "Apparition");
+
+ menu = GetSystemMenu(hwnd, 0);
+ AppendMenu(menu, MF_SEPARATOR, 0, NULL);
+ AppendMenu(menu, MF_STRING, ID_ABOUT, "About Apparition...");
+ AppendMenu(menu, MF_STRING, ID_DOCINFO, "Document Properties...");
+
+ SetCursor(arrowcurs);
}
void wincursor(pdfapp_t *app, int curs)
{
- if (curs == ARROW)
- SetCursor(arrowcurs);
- if (curs == HAND)
- SetCursor(handcurs);
- if (curs == WAIT)
- SetCursor(waitcurs);
+ if (curs == ARROW)
+ SetCursor(arrowcurs);
+ if (curs == HAND)
+ SetCursor(handcurs);
+ if (curs == WAIT)
+ SetCursor(waitcurs);
}
void wintitle(pdfapp_t *app, char *title)
{
- unsigned short wide[256], *dp;
- char *sp;
- int rune;
-
- dp = wide;
- sp = title;
- while (*sp && dp < wide + 255)
- {
- sp += chartorune(&rune, sp);
- *dp++ = rune;
- }
- *dp = 0;
-
- SetWindowTextW(hwnd, wide);
+ unsigned short wide[256], *dp;
+ char *sp;
+ int rune;
+
+ dp = wide;
+ sp = title;
+ while (*sp && dp < wide + 255)
+ {
+ sp += chartorune(&rune, sp);
+ *dp++ = rune;
+ }
+ *dp = 0;
+
+ SetWindowTextW(hwnd, wide);
}
void winconvert(pdfapp_t *app, fz_pixmap *image)
{
- int y, x;
+ int y, x;
- if (bmpdata)
- fz_free(bmpdata);
+ if (bmpdata)
+ fz_free(bmpdata);
- bmpstride = ((image->w * 3 + 3) / 4) * 4;
- bmpdata = fz_malloc(image->h * bmpstride);
- if (!bmpdata)
- return;
+ bmpstride = ((image->w * 3 + 3) / 4) * 4;
+ bmpdata = fz_malloc(image->h * bmpstride);
+ if (!bmpdata)
+ return;
- for (y = 0; y < image->h; y++)
+ for (y = 0; y < image->h; y++)
+ {
+ char *p = bmpdata + y * bmpstride;
+ char *s = image->samples + y * image->w * 4;
+ for (x = 0; x < image->w; x++)
{
- char *p = bmpdata + y * bmpstride;
- char *s = image->samples + y * image->w * 4;
- for (x = 0; x < image->w; x++)
- {
- p[x * 3 + 0] = s[x * 4 + 3];
- p[x * 3 + 1] = s[x * 4 + 2];
- p[x * 3 + 2] = s[x * 4 + 1];
- }
+ p[x * 3 + 0] = s[x * 4 + 3];
+ p[x * 3 + 1] = s[x * 4 + 2];
+ p[x * 3 + 2] = s[x * 4 + 1];
}
+ }
}
void invertcopyrect(void)
{
- int x0 = gapp.selr.x0 - gapp.panx;
- int x1 = gapp.selr.x1 - gapp.panx;
- int y0 = gapp.selr.y0 - gapp.pany;
- int y1 = gapp.selr.y1 - gapp.pany;
- int x, y;
-
- x0 = CLAMP(x0, 0, gapp.image->w - 1);
- x1 = CLAMP(x1, 0, gapp.image->w - 1);
- y0 = CLAMP(y0, 0, gapp.image->h - 1);
- y1 = CLAMP(y1, 0, gapp.image->h - 1);
-
- unsigned char *p;
- for (y = y0; y < y1; y++)
+ int x0 = gapp.selr.x0 - gapp.panx;
+ int x1 = gapp.selr.x1 - gapp.panx;
+ int y0 = gapp.selr.y0 - gapp.pany;
+ int y1 = gapp.selr.y1 - gapp.pany;
+ int x, y;
+
+ x0 = CLAMP(x0, 0, gapp.image->w - 1);
+ x1 = CLAMP(x1, 0, gapp.image->w - 1);
+ y0 = CLAMP(y0, 0, gapp.image->h - 1);
+ y1 = CLAMP(y1, 0, gapp.image->h - 1);
+
+ unsigned char *p;
+ for (y = y0; y < y1; y++)
+ {
+ p = bmpdata + y * bmpstride + x0 * 3;
+ for (x = x0; x < x1; x++)
{
- p = bmpdata + y * bmpstride + x0 * 3;
- for (x = x0; x < x1; x++)
- {
- p[0] = 255 - p[0];
- p[1] = 255 - p[1];
- p[2] = 255 - p[2];
- p += 3;
- }
+ p[0] = 255 - p[0];
+ p[1] = 255 - p[1];
+ p[2] = 255 - p[2];
+ p += 3;
}
+ }
- justcopied = 1;
+ justcopied = 1;
}
void winblit()
{
- int x0 = gapp.panx;
- int y0 = gapp.pany;
- int x1 = gapp.panx + gapp.image->w;
- int y1 = gapp.pany + gapp.image->h;
- RECT r;
-
- if (bmpdata)
- {
- if (gapp.iscopying || justcopied)
- invertcopyrect();
-
- dibinf->bmiHeader.biWidth = gapp.image->w;
- dibinf->bmiHeader.biHeight = -gapp.image->h;
- dibinf->bmiHeader.biSizeImage = gapp.image->h * bmpstride;
- SetDIBitsToDevice(hdc,
- gapp.panx, /* destx */
- gapp.pany, /* desty */
- gapp.image->w, /* destw */
- gapp.image->h, /* desth */
- 0, /* srcx */
- 0, /* srcy */
- 0, /* startscan */
- gapp.image->h, /* numscans */
- bmpdata, /* pBits */
- dibinf, /* pInfo */
- DIB_RGB_COLORS /* color use flag */
- );
-
- if (gapp.iscopying || justcopied)
- invertcopyrect();
- }
-
- /* Grey background */
- r.top = 0; r.bottom = gapp.winh;
- r.left = 0; r.right = x0;
- FillRect(hdc, &r, bgbrush);
- r.left = x1; r.right = gapp.winw;
- FillRect(hdc, &r, bgbrush);
- r.left = 0; r.right = gapp.winw;
- r.top = 0; r.bottom = y0;
- FillRect(hdc, &r, bgbrush);
- r.top = y1; r.bottom = gapp.winh;
- FillRect(hdc, &r, bgbrush);
-
- /* Drop shadow */
- r.left = x0 + 2;
- r.right = x1 + 2;
- r.top = y1;
- r.bottom = y1 + 2;
- FillRect(hdc, &r, shbrush);
- r.left = x1;
- r.right = x1 + 2;
- r.top = y0 + 2;
- r.bottom = y1;
- FillRect(hdc, &r, shbrush);
+ int x0 = gapp.panx;
+ int y0 = gapp.pany;
+ int x1 = gapp.panx + gapp.image->w;
+ int y1 = gapp.pany + gapp.image->h;
+ RECT r;
+
+ if (bmpdata)
+ {
+ if (gapp.iscopying || justcopied)
+ invertcopyrect();
+
+ dibinf->bmiHeader.biWidth = gapp.image->w;
+ dibinf->bmiHeader.biHeight = -gapp.image->h;
+ dibinf->bmiHeader.biSizeImage = gapp.image->h * bmpstride;
+ SetDIBitsToDevice(hdc,
+ gapp.panx, /* destx */
+ gapp.pany, /* desty */
+ gapp.image->w, /* destw */
+ gapp.image->h, /* desth */
+ 0, /* srcx */
+ 0, /* srcy */
+ 0, /* startscan */
+ gapp.image->h, /* numscans */
+ bmpdata, /* pBits */
+ dibinf, /* pInfo */
+ DIB_RGB_COLORS /* color use flag */
+ );
+
+ if (gapp.iscopying || justcopied)
+ invertcopyrect();
+ }
+
+ /* Grey background */
+ r.top = 0; r.bottom = gapp.winh;
+ r.left = 0; r.right = x0;
+ FillRect(hdc, &r, bgbrush);
+ r.left = x1; r.right = gapp.winw;
+ FillRect(hdc, &r, bgbrush);
+ r.left = 0; r.right = gapp.winw;
+ r.top = 0; r.bottom = y0;
+ FillRect(hdc, &r, bgbrush);
+ r.top = y1; r.bottom = gapp.winh;
+ FillRect(hdc, &r, bgbrush);
+
+ /* Drop shadow */
+ r.left = x0 + 2;
+ r.right = x1 + 2;
+ r.top = y1;
+ r.bottom = y1 + 2;
+ FillRect(hdc, &r, shbrush);
+ r.left = x1;
+ r.right = x1 + 2;
+ r.top = y0 + 2;
+ r.bottom = y1;
+ FillRect(hdc, &r, shbrush);
}
void winresize(pdfapp_t *app, int w, int h)
{
- ShowWindow(hwnd, SW_SHOWDEFAULT);
- w += GetSystemMetrics(SM_CXFRAME) * 2;
- h += GetSystemMetrics(SM_CYFRAME) * 2;
- h += GetSystemMetrics(SM_CYCAPTION);
- SetWindowPos(hwnd, 0, 0, 0, w, h, SWP_NOZORDER | SWP_NOMOVE);
+ ShowWindow(hwnd, SW_SHOWDEFAULT);
+ w += GetSystemMetrics(SM_CXFRAME) * 2;
+ h += GetSystemMetrics(SM_CYFRAME) * 2;
+ h += GetSystemMetrics(SM_CYCAPTION);
+ SetWindowPos(hwnd, 0, 0, 0, w, h, SWP_NOZORDER | SWP_NOMOVE);
}
void winrepaint(pdfapp_t *app)
{
- InvalidateRect(hwnd, NULL, 0);
+ InvalidateRect(hwnd, NULL, 0);
}
/*
@@ -511,250 +511,250 @@ void winrepaint(pdfapp_t *app)
void windocopy(pdfapp_t *app)
{
- HGLOBAL handle;
- unsigned short *ucsbuf;
+ HGLOBAL handle;
+ unsigned short *ucsbuf;
- if (!OpenClipboard(hwnd))
- return;
- EmptyClipboard();
+ if (!OpenClipboard(hwnd))
+ return;
+ EmptyClipboard();
- handle = GlobalAlloc(GMEM_MOVEABLE, 4096 * sizeof(unsigned short));
- if (!handle)
- {
- CloseClipboard();
- return;
- }
+ handle = GlobalAlloc(GMEM_MOVEABLE, 4096 * sizeof(unsigned short));
+ if (!handle)
+ {
+ CloseClipboard();
+ return;
+ }
- ucsbuf = GlobalLock(handle);
- pdfapp_oncopy(&gapp, ucsbuf, 4096);
- GlobalUnlock(handle);
+ ucsbuf = GlobalLock(handle);
+ pdfapp_oncopy(&gapp, ucsbuf, 4096);
+ GlobalUnlock(handle);
- SetClipboardData(CF_UNICODETEXT, handle);
- CloseClipboard();
+ SetClipboardData(CF_UNICODETEXT, handle);
+ CloseClipboard();
- justcopied = 1; /* keep inversion around for a while... */
+ justcopied = 1; /* keep inversion around for a while... */
}
void winopenuri(pdfapp_t *app, char *buf)
{
- ShellExecute(hwnd, "open", buf, 0, 0, SW_SHOWNORMAL);
+ ShellExecute(hwnd, "open", buf, 0, 0, SW_SHOWNORMAL);
}
void handlekey(int c)
{
- if (GetCapture() == hwnd)
- return;
-
- if (justcopied)
- {
- justcopied = 0;
- winrepaint(&gapp);
- }
-
- /* translate VK into ascii equivalents */
- switch (c)
- {
- case VK_F1: c = '?'; break;
- case VK_ESCAPE: c = 'q'; break;
- case VK_DOWN: c = 'd'; break;
- case VK_UP: c = 'u'; break;
- case VK_LEFT: c = 'p'; break;
- case VK_RIGHT: c = 'n'; break;
- case VK_PRIOR: c = 'b'; break;
- case VK_NEXT: c = ' '; break;
- }
-
- if (c == 'q')
- exit(0);
- else if (c == '?' || c == 'h')
- help();
- else
- pdfapp_onkey(&gapp, c);
+ if (GetCapture() == hwnd)
+ return;
+
+ if (justcopied)
+ {
+ justcopied = 0;
+ winrepaint(&gapp);
+ }
+
+ /* translate VK into ascii equivalents */
+ switch (c)
+ {
+ case VK_F1: c = '?'; break;
+ case VK_ESCAPE: c = 'q'; break;
+ case VK_DOWN: c = 'd'; break;
+ case VK_UP: c = 'u'; break;
+ case VK_LEFT: c = 'p'; break;
+ case VK_RIGHT: c = 'n'; break;
+ case VK_PRIOR: c = 'b'; break;
+ case VK_NEXT: c = ' '; break;
+ }
+
+ if (c == 'q')
+ exit(0);
+ else if (c == '?' || c == 'h')
+ help();
+ else
+ pdfapp_onkey(&gapp, c);
}
void handlemouse(int x, int y, int btn, int state)
{
- if (state != 0 && justcopied)
- {
- justcopied = 0;
- winrepaint(&gapp);
- }
-
- if (state == 1)
- SetCapture(hwnd);
- if (state == -1)
- ReleaseCapture();
-
- pdfapp_onmouse(&gapp, x, y, btn, 0, state);
+ if (state != 0 && justcopied)
+ {
+ justcopied = 0;
+ winrepaint(&gapp);
+ }
+
+ if (state == 1)
+ SetCapture(hwnd);
+ if (state == -1)
+ ReleaseCapture();
+
+ pdfapp_onmouse(&gapp, x, y, btn, 0, state);
}
LRESULT CALLBACK
windproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- static int oldx = 0;
- static int oldy = 0;
- int x = (signed short) LOWORD(lParam);
- int y = (signed short) HIWORD(lParam);
+ static int oldx = 0;
+ static int oldy = 0;
+ int x = (signed short) LOWORD(lParam);
+ int y = (signed short) HIWORD(lParam);
+
+ switch (message)
+ {
+ case WM_CREATE:
+ return 0;
- switch (message)
+ case WM_DESTROY:
+ case WM_CLOSE:
+ PostQuitMessage(0);
+ return 0;
+
+ case WM_SYSCOMMAND:
+ if (wParam == ID_ABOUT)
+ {
+ help();
+ return 0;
+ }
+ if (wParam == ID_DOCINFO)
{
- case WM_CREATE:
- return 0;
-
- case WM_DESTROY:
- case WM_CLOSE:
- PostQuitMessage(0);
- return 0;
-
- case WM_SYSCOMMAND:
- if (wParam == ID_ABOUT)
- {
- help();
- return 0;
- }
- if (wParam == ID_DOCINFO)
- {
- info();
- return 0;
- }
- break;
-
- case WM_SIZE:
- if (wParam == SIZE_MINIMIZED)
- return 0;
- if (wParam == SIZE_MAXIMIZED)
- gapp.shrinkwrap = 0;
- pdfapp_onresize(&gapp, LOWORD(lParam), HIWORD(lParam));
- return 0;
-
- case WM_SIZING:
- gapp.shrinkwrap = 0;
- return 0;
+ info();
+ return 0;
+ }
+ break;
+
+ case WM_SIZE:
+ if (wParam == SIZE_MINIMIZED)
+ return 0;
+ if (wParam == SIZE_MAXIMIZED)
+ gapp.shrinkwrap = 0;
+ pdfapp_onresize(&gapp, LOWORD(lParam), HIWORD(lParam));
+ return 0;
+
+ case WM_SIZING:
+ gapp.shrinkwrap = 0;
+ return 0;
/* Paint events are low priority and automagically catenated
* so we don't need to do any fancy waiting to defer repainting.
*/
- case WM_PAINT:
+ case WM_PAINT:
{
- //puts("WM_PAINT");
- PAINTSTRUCT ps;
- hdc = BeginPaint(hwnd, &ps);
- winblit();
- hdc = NULL;
- EndPaint(hwnd, &ps);
- return 0;
+ //puts("WM_PAINT");
+ PAINTSTRUCT ps;
+ hdc = BeginPaint(hwnd, &ps);
+ winblit();
+ hdc = NULL;
+ EndPaint(hwnd, &ps);
+ return 0;
}
/* Mouse events */
- case WM_LBUTTONDOWN:
- SetFocus(hwnd);
- oldx = x; oldy = y;
- handlemouse(x, y, 1, 1);
- return 0;
- case WM_MBUTTONDOWN:
- SetFocus(hwnd);
- oldx = x; oldy = y;
- handlemouse(x, y, 2, 1);
- return 0;
- case WM_RBUTTONDOWN:
- SetFocus(hwnd);
- oldx = x; oldy = y;
- handlemouse(x, y, 3, 1);
- return 0;
-
- case WM_LBUTTONUP:
- oldx = x; oldy = y;
- handlemouse(x, y, 1, -1);
- return 0;
- case WM_MBUTTONUP:
- oldx = x; oldy = y;
- handlemouse(x, y, 2, -1);
- return 0;
- case WM_RBUTTONUP:
- oldx = x; oldy = y;
- handlemouse(x, y, 3, -1);
- return 0;
-
- case WM_MOUSEMOVE:
- oldx = x; oldy = y;
- handlemouse(x, y, 0, 0);
- return 0;
+ case WM_LBUTTONDOWN:
+ SetFocus(hwnd);
+ oldx = x; oldy = y;
+ handlemouse(x, y, 1, 1);
+ return 0;
+ case WM_MBUTTONDOWN:
+ SetFocus(hwnd);
+ oldx = x; oldy = y;
+ handlemouse(x, y, 2, 1);
+ return 0;
+ case WM_RBUTTONDOWN:
+ SetFocus(hwnd);
+ oldx = x; oldy = y;
+ handlemouse(x, y, 3, 1);
+ return 0;
+
+ case WM_LBUTTONUP:
+ oldx = x; oldy = y;
+ handlemouse(x, y, 1, -1);
+ return 0;
+ case WM_MBUTTONUP:
+ oldx = x; oldy = y;
+ handlemouse(x, y, 2, -1);
+ return 0;
+ case WM_RBUTTONUP:
+ oldx = x; oldy = y;
+ handlemouse(x, y, 3, -1);
+ return 0;
+
+ case WM_MOUSEMOVE:
+ oldx = x; oldy = y;
+ handlemouse(x, y, 0, 0);
+ return 0;
/* Mouse wheel */
- case WM_MOUSEWHEEL:
- if ((signed short)HIWORD(wParam) > 0)
- handlekey(LOWORD(wParam) & MK_SHIFT ? '+' : 'u');
- else
- handlekey(LOWORD(wParam) & MK_SHIFT ? '-' : 'd');
- return 0;
+ case WM_MOUSEWHEEL:
+ if ((signed short)HIWORD(wParam) > 0)
+ handlekey(LOWORD(wParam) & MK_SHIFT ? '+' : 'u');
+ else
+ handlekey(LOWORD(wParam) & MK_SHIFT ? '-' : 'd');
+ return 0;
/* Keyboard events */
- case WM_KEYDOWN:
- /* only handle special keys */
- switch (wParam)
- {
- case VK_F1:
- case VK_LEFT:
- case VK_UP:
- case VK_PRIOR:
- case VK_RIGHT:
- case VK_DOWN:
- case VK_NEXT:
- case VK_ESCAPE:
- handlekey(wParam);
- handlemouse(oldx, oldy, 0, 0); /* update cursor */
- return 0;
- }
- return 1;
+ case WM_KEYDOWN:
+ /* only handle special keys */
+ switch (wParam)
+ {
+ case VK_F1:
+ case VK_LEFT:
+ case VK_UP:
+ case VK_PRIOR:
+ case VK_RIGHT:
+ case VK_DOWN:
+ case VK_NEXT:
+ case VK_ESCAPE:
+ handlekey(wParam);
+ handlemouse(oldx, oldy, 0, 0); /* update cursor */
+ return 0;
+ }
+ return 1;
/* unicode encoded chars, including escape, backspace etc... */
- case WM_CHAR:
- handlekey(wParam);
- handlemouse(oldx, oldy, 0, 0); /* update cursor */
- return 0;
- }
+ case WM_CHAR:
+ handlekey(wParam);
+ handlemouse(oldx, oldy, 0, 0); /* update cursor */
+ return 0;
+ }
- fflush(stdout);
+ fflush(stdout);
- /* Pass on unhandled events to Windows */
- return DefWindowProc(hwnd, message, wParam, lParam);
+ /* Pass on unhandled events to Windows */
+ return DefWindowProc(hwnd, message, wParam, lParam);
}
int main(int argc, char **argv)
{
- char buf[1024];
- char *filename;
+ char buf[1024];
+ char *filename;
- fz_cpudetect();
- fz_accelerate();
+ fz_cpudetect();
+ fz_accelerate();
- pdfapp_init(&gapp);
+ pdfapp_init(&gapp);
- associate(argv[0]);
- winopen();
+ associate(argv[0]);
+ winopen();
- if (argc == 2)
- filename = strdup(argv[1]);
- else
- {
- if (!winfilename(buf, sizeof buf))
- exit(0);
- filename = buf;
- }
+ if (argc == 2)
+ filename = strdup(argv[1]);
+ else
+ {
+ if (!winfilename(buf, sizeof buf))
+ exit(0);
+ filename = buf;
+ }
- pdfapp_open(&gapp, filename);
+ pdfapp_open(&gapp, filename);
- MSG msg;
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
+ MSG msg;
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
- pdfapp_close(&gapp);
+ pdfapp_close(&gapp);
- return 0;
+ return 0;
}
diff --git a/apps/windows/winres.rc b/apps/windows/winres.rc
index cad44a1f..af941f03 100644
--- a/apps/windows/winres.rc
+++ b/apps/windows/winres.rc
@@ -4,7 +4,7 @@ IDI_ICONDOC ICON "gsdoc.ico"
IDD_DLOGPASS DIALOG 50, 50, 204, 60
//STYLE DS_MODALFRAME | WS_POPUP
STYLE 128 | 0x80000000
-CAPTION " FzView: Password "
+CAPTION " Apparition: Password "
FONT 8, "MS Shell Dlg"
BEGIN
EDITTEXT 3, 57,20,140,12, 32
@@ -52,7 +52,7 @@ END
IDD_DLOGABOUT DIALOG 50, 50, 200, 210
STYLE 128 | 0x80000000
-CAPTION " About FzView "
+CAPTION " About Apparition "
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "Okay", 1, 200-10-50,210-7-14,50,14, 0x50010001