From 8db6ea908fea5d48ff174580a3398b67ee265717 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Sat, 29 May 1999 12:35:54 +0000 Subject: [PATCH] GOutputDev now compiles... move onto gpdf GUI. --- pdf/xpdf/ChangeLog | 8 +++ pdf/xpdf/Makefile.in | 2 +- pdf/xpdf/gpdf.cc | 142 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 147 insertions(+), 5 deletions(-) diff --git a/pdf/xpdf/ChangeLog b/pdf/xpdf/ChangeLog index a186cb4f..ca479602 100644 --- a/pdf/xpdf/ChangeLog +++ b/pdf/xpdf/ChangeLog @@ -1,3 +1,11 @@ +1999-05-29 Michael Meeks + + * gpdf.cc: Add define GString / undef. + (main): Argc not Argv :) + + * GOutputDev.cc (findColor): Made pigs ear of colour + mappings. + 1999-05-28 Michael Meeks * GOutputDev.cc (drawChar16): XChar2b -> GdkWChar diff --git a/pdf/xpdf/Makefile.in b/pdf/xpdf/Makefile.in index cf062fe0..7f6f628e 100644 --- a/pdf/xpdf/Makefile.in +++ b/pdf/xpdf/Makefile.in @@ -87,7 +87,7 @@ GPDF_OBJS = Array.o Catalog.o Dict.o Error.o Gfx.o GfxFont.o \ XPDF_LIBS = -L$(LTKLIBDIR) -lLTK -L$(GOOLIBDIR) -lGoo $(XLIBS) $(OTHERLIBS) -lm -GPDF_LIBS = `gnome-config --libs gnomeui` +GPDF_LIBS = -L$(GOOLIBDIR) $(OTHERLIBS) -lGoo `gnome-config --libs gnomeui` -lm gpdf: $(GPDF_OBJS) $(CXX) $(CXXFLAGS) -o gpdf $(GPDF_OBJS) $(GPDF_LIBS) diff --git a/pdf/xpdf/gpdf.cc b/pdf/xpdf/gpdf.cc index 02103cb2..33e3dda8 100644 --- a/pdf/xpdf/gpdf.cc +++ b/pdf/xpdf/gpdf.cc @@ -1,9 +1,10 @@ //======================================================================== // -// xpdf.cc +// gpdf.cc // // Copyright 1996 Derek B. Noonburg // Copyright 1999 Miguel de Icaza +// Copyright 1999 Michael Meeks. // //======================================================================== @@ -12,7 +13,9 @@ #include #include #include +#define GString G_String #include +#undef GString #include "gtypes.h" #include "GString.h" #include "parseargs.h" @@ -27,17 +30,148 @@ #include "Page.h" #include "Link.h" #include "PDFDoc.h" -#include "XOutputDev.h" +#include "GOutputDev.h" #include "PSOutputDev.h" #include "TextOutputDev.h" #include "Params.h" #include "Error.h" #include "config.h" +GBool printCommands = gFalse; +gint gpdf_debug; +poptContext ctx; + +const struct poptOption gpdf_popt_options [] = { + { "debug", '\0', POPT_ARG_INT, &gpdf_debug, 0, + N_("Enables some debugging functions"), N_("LEVEL") }, + { NULL, '\0', 0, NULL, 0 } +}; + + +//------------------------------------------------------------------------ +// loadFile / displayPage +//------------------------------------------------------------------------ + +static GBool loadFile(GString *fileName) { + GString *title; + PDFDoc *newDoc; + char s[20]; + char *p; + + // busy cursor + if (win) + win->setBusyCursor(gTrue); + + // open PDF file + newDoc = new PDFDoc(fileName); + if (!newDoc->isOk()) { + delete newDoc; + if (win) + win->setBusyCursor(gFalse); + return gFalse; + } + + // replace old document + if (doc) + delete doc; + doc = newDoc; + + // nothing displayed yet + page = -99; + + // init PostScript output params + if (psFileName) + delete psFileName; + if (defPSFileName) { + psFileName = defPSFileName->copy(); + } else { + p = fileName->getCString() + fileName->getLength() - 4; + if (!strcmp(p, ".pdf") || !strcmp(p, ".PDF")) + psFileName = new GString(fileName->getCString(), + fileName->getLength() - 4); + else + psFileName = fileName->copy(); + psFileName->append(".ps"); + } + psFirstPage = 1; + psLastPage = doc->getNumPages(); + + // set up title, number-of-pages display; back to normal cursor + if (win) { + title = new GString("xpdf: "); + title->append(fileName); + win->setTitle(title); + sprintf(s, "of %d", doc->getNumPages()); + numPagesLabel->setText(s); + win->setBusyCursor(gFalse); + } + + // done + return gTrue; +} + +static void displayPage(int page1, int zoom1, int rotate1) { + char s[20]; + + // check for document + if (!doc) + return; + + // busy cursor + if (win) + win->setBusyCursor(gTrue); + + // new page/zoom/rotate values + page = page1; + zoom = zoom1; + rotate = rotate1; + + // initialize mouse-related stuff + linkAction = NULL; + win->setDefaultCursor(); + linkLabel->setText(NULL); + selectXMin = selectXMax = 0; + selectYMin = selectYMax = 0; + lastDragLeft = lastDragTop = gTrue; + + // draw the page + doc->displayPage(out, page, zoomDPI[zoom - minZoom], rotate, gTrue); + layoutCbk(win); + + // update page number display + sprintf(s, "%d", page); + pageNumText->setText(s); + + // back to regular cursor + win->setBusyCursor(gFalse); +} + int main (int argc, char *argv []) { - gnome_init ("GPDF", "1.0", argv, argv); + char **view_files = NULL; + int lp; + + gnome_init_with_popt_table ( + "gpdf", "0.1", argc, argv, + gpdf_popt_options, 0, &ctx); + + view_files = poptGetArgs (ctx); + /* Load files */ + if (view_files) { + for (lp=0;view_files[lp];lp++) { + GString *name = new GString (view_files[lp]); + if (!name || !loadFile(name)) + printf ("Error loading '%s'\n", view_files[lp]); + } + } else { + printf ("Need filenames...\n"); + exit (0); + } + + poptFreeContext (ctx); + + gtk_main (); - gtk_main (); + /* Destroy files */ } -- 2.43.5