From b0f6e6f4e92ce461fa48d5d95ba7a863fc35966b Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Sat, 29 May 1999 22:10:37 +0000 Subject: [PATCH] Brutal hack of rendering for now, needs sensible font support. --- pdf/xpdf/ChangeLog | 3 + pdf/xpdf/Makefile.in | 6 +- pdf/xpdf/gpdf.cc | 164 ++++++++++++++++++++++++++++++------------- 3 files changed, 120 insertions(+), 53 deletions(-) diff --git a/pdf/xpdf/ChangeLog b/pdf/xpdf/ChangeLog index ca479602..e33fe490 100644 --- a/pdf/xpdf/ChangeLog +++ b/pdf/xpdf/ChangeLog @@ -1,5 +1,8 @@ 1999-05-29 Michael Meeks + * Makefile.in (GPDF_OBJS): Remove XOutputDev + (all): Remove all but gpdf. + * gpdf.cc: Add define GString / undef. (main): Argc not Argv :) diff --git a/pdf/xpdf/Makefile.in b/pdf/xpdf/Makefile.in index 7f6f628e..0e141289 100644 --- a/pdf/xpdf/Makefile.in +++ b/pdf/xpdf/Makefile.in @@ -70,8 +70,8 @@ CXX_SRC = \ all: gpdf -all: xpdf$(EXE) pdftops$(EXE) pdftotext$(EXE) pdfinfo$(EXE) \ - pdftopbm$(EXE) pdfimages$(EXE) +#all: xpdf$(EXE) pdftops$(EXE) pdftotext$(EXE) pdfinfo$(EXE) \ +# pdftopbm$(EXE) pdfimages$(EXE) #------------------------------------------------------------------------ @@ -83,7 +83,7 @@ XPDF_OBJS = Array.o Catalog.o Dict.o Error.o Gfx.o GfxFont.o \ GPDF_OBJS = Array.o Catalog.o Dict.o Error.o Gfx.o GfxFont.o \ GfxState.o Lexer.o Link.o GOutputDev.o Object.o OutputDev.o \ Page.o Params.o Parser.o PDFDoc.o PSOutputDev.o Stream.o \ - TextOutputDev.o XOutputDev.o XRef.o gpdf.o + TextOutputDev.o XRef.o gpdf.o XPDF_LIBS = -L$(LTKLIBDIR) -lLTK -L$(GOOLIBDIR) -lGoo $(XLIBS) $(OTHERLIBS) -lm diff --git a/pdf/xpdf/gpdf.cc b/pdf/xpdf/gpdf.cc index 33e3dda8..8a8860f4 100644 --- a/pdf/xpdf/gpdf.cc +++ b/pdf/xpdf/gpdf.cc @@ -3,8 +3,8 @@ // gpdf.cc // // Copyright 1996 Derek B. Noonburg -// Copyright 1999 Miguel de Icaza // Copyright 1999 Michael Meeks. +// Copyright 1999 Miguel de Icaza // //======================================================================== @@ -41,6 +41,27 @@ GBool printCommands = gFalse; gint gpdf_debug; poptContext ctx; +struct DOC_ROOT { + GString *title; + PDFDoc *pdf; + GtkWidget *toplevel; + GtkWidget *table; + GnomeAppBar *appbar; + GtkDrawingArea *area; + GdkVisual *visual; + GdkPixmap *pixmap; + OutputDev *out; + GdkColor paper; +}; + + +static void +crummy_cmd (GtkWidget *widget, DOC_ROOT *tmp) +{ + printf ("Crummy\n"); +} + + const struct poptOption gpdf_popt_options [] = { { "debug", '\0', POPT_ARG_INT, &gpdf_debug, 0, N_("Enables some debugging functions"), N_("LEVEL") }, @@ -48,69 +69,108 @@ const struct poptOption gpdf_popt_options [] = { }; +static GnomeUIInfo dummy_menu [] = { + { GNOME_APP_UI_ITEM, N_("_dummy"), + N_("What a dummy!"), crummy_cmd }, + GNOMEUIINFO_END +}; + +static GnomeUIInfo main_menu [] = { + { GNOME_APP_UI_SUBTREE, N_("_Dummy"), NULL, dummy_menu }, + GNOMEUIINFO_END +}; + //------------------------------------------------------------------------ // loadFile / displayPage //------------------------------------------------------------------------ -static GBool loadFile(GString *fileName) { - GString *title; - PDFDoc *newDoc; +static gint +doc_config_event (GtkWidget *widget, DOC_ROOT *doc) +{ + if (!doc) + return TRUE; + + if (doc->pixmap) + gdk_pixmap_unref(doc->pixmap); + + doc->pixmap = gdk_pixmap_new(widget->window, + widget->allocation.width, + widget->allocation.height, + -1); + gdk_draw_rectangle (doc->pixmap, + widget->style->white_gc, + TRUE, + 0, 0, + widget->allocation.width, + widget->allocation.height); + return TRUE; +} + +static gint +doc_redraw_event (GtkWidget *widget, DOC_ROOT *doc) +{ +/* Redraw the screen from the backing pixmap */ + + gdk_color_white (gtk_widget_get_default_colormap(), &doc->paper); + doc->out = new GOutputDev (doc->pixmap, doc->paper); + + doc->pdf->displayPage(doc->out, 1, 1, 0, gTrue); + +/* gdk_draw_pixmap(widget->window, + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + doc->pixmap, + event->area.x, event->area.y, + event->area.x, event->area.y, + event->area.width, event->area.height);*/ + + return FALSE; +} + +static GBool +loadFile(GString *fileName) +{ + DOC_ROOT *doc = new DOC_ROOT(); 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); + doc->pdf = new PDFDoc(fileName); + if (!doc->pdf->isOk()) { + delete doc->pdf; + delete doc; return gFalse; } - // replace old document - if (doc) - delete doc; - doc = newDoc; - - // nothing displayed yet - page = -99; + doc->toplevel = gnome_app_new ("gpdf", "gpdf"); + gtk_window_set_policy(GTK_WINDOW(doc->toplevel), 1, 1, 0); + gtk_window_set_default_size (GTK_WINDOW(doc->toplevel), 600, 400); + doc->table = GTK_WIDGET (gtk_table_new (0, 0, 0)); + doc->appbar = GNOME_APPBAR (gnome_appbar_new (FALSE, TRUE, + GNOME_PREFERENCES_USER)); + gnome_app_set_statusbar (GNOME_APP (doc->toplevel), + GTK_WIDGET (doc->appbar)); + gnome_app_set_contents (GNOME_APP (doc->toplevel), doc->table); + gnome_app_create_menus_with_data (GNOME_APP (doc->toplevel), main_menu, doc); + gnome_app_install_menu_hints(GNOME_APP (doc->toplevel), main_menu); + + doc->pixmap = NULL; + doc->area = GTK_DRAWING_AREA (gtk_drawing_area_new ()); + gtk_signal_connect (GTK_OBJECT (doc->area), "expose_event", + (GtkSignalFunc) doc_redraw_event, NULL); + gtk_signal_connect (GTK_OBJECT(doc->area),"configure_event", + (GtkSignalFunc) doc_config_event, NULL); + + gtk_table_attach (GTK_TABLE (doc->table), GTK_WIDGET (doc->area), + 0, 1, 1, 2, + GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, + 0, 0); + + gtk_widget_show_all (doc->toplevel); - // 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) { +/*static void displayPage(int page1, int zoom1, int rotate1) { char s[20]; // check for document @@ -144,7 +204,7 @@ static void displayPage(int page1, int zoom1, int rotate1) { // back to regular cursor win->setBusyCursor(gFalse); -} + }*/ int main (int argc, char *argv []) @@ -156,6 +216,8 @@ main (int argc, char *argv []) "gpdf", "0.1", argc, argv, gpdf_popt_options, 0, &ctx); + initParams (xpdfConfigFile); /* Init font path */ + view_files = poptGetArgs (ctx); /* Load files */ if (view_files) { @@ -171,6 +233,8 @@ main (int argc, char *argv []) poptFreeContext (ctx); + freeParams(); + gtk_main (); /* Destroy files */ -- 2.43.5