diff options
author | Roland Mainz <roland.mainz@nrubsig.org> | 2004-04-13 03:16:49 +0000 |
---|---|---|
committer | Roland Mainz <roland.mainz@nrubsig.org> | 2004-04-13 03:16:49 +0000 |
commit | 4602d07dd836bea1fbb3232a2df35b89d8d89311 (patch) | |
tree | 850b89f69728f1ba5d1a13783c7845de72bc40ab |
file xpxthelloworld.sgml was initially added on branch XPRINT.
34 files changed, 3343 insertions, 0 deletions
diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..249a78c --- /dev/null +++ b/.cvsignore @@ -0,0 +1,15 @@ +.deps +Makefile +Makefile.in +aclocal.m4 +autom4te.cache +compile +config.h +config.h.in +config.log +config.status +configure +depcomp +install-sh +missing +stamp-h1 @@ -0,0 +1,12 @@ +This is a stub file. This package has not yet had its complete licensing +information compiled. Please see the individual source files for details on +your rights to use and modify this software. + +Please submit updated COPYING files to the Xorg bugzilla: + +https://bugs.freedesktop.org/enter_bug.cgi?product=xorg + +All licensing questions regarding this software should be directed at the +Xorg mailing list: + +http://lists.freedesktop.org/mailman/listinfo/xorg diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..540e528 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,37 @@ +2005-12-20 Kevin E. Martin <kem-at-freedesktop-dot-org> + + * configure.ac: + Update package version for X11R7 release. + +2005-12-14 Kevin E. Martin <kem-at-freedesktop-dot-org> + + * configure.ac: + Update package version number for final X11R7 release candidate. + +2005-12-03 Kevin E. Martin <kem-at-freedesktop-dot-org> + + * configure.ac: + Update package version number for X11R7 RC3 release. + +2005-11-19 Alan Coopersmith <alan.coopersmith@sun.com> + + * configure.ac: + Add dependencies on xp module + +2005-11-19 Kevin E. Martin <kem-at-freedesktop-dot-org> + + * configure.ac: + Update dependencies to work with separate build roots. + +2005-10-18 Kevin E. Martin <kem-at-freedesktop-dot-org> + + * configure.ac: + Update package version number for RC1 release. + +2005-10-05 Kevin E. Martin <kem-at-freedesktop-dot-org> + + * xphelloworld/Makefile.am: + * xpsimplehelloworld/Makefile.am: + * xpxmhelloworld/Makefile.am: + * xpxthelloworld/Makefile.am: + Add .sgml files to EXTRA_DIST diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..9f7d128 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,28 @@ +# +# Copyright 2005 Red Hat, Inc. +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of Red Hat not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. Red Hat makes no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +if BUILD_MOTIFAPPS +MOTIFAPPS=xpawhelloworld xpxmhelloworld +else +MOTIFAPPS= +endif + +SUBDIRS = $(MOTIFAPPS) xphelloworld xpsimplehelloworld xpxthelloworld diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..e81f989 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,13 @@ +#! /bin/sh + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +ORIGDIR=`pwd` +cd $srcdir + +autoreconf -v --install || exit 1 +cd $ORIGDIR || exit $? + +$srcdir/configure --enable-maintainer-mode "$@" + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..d924b03 --- /dev/null +++ b/configure.ac @@ -0,0 +1,119 @@ + +dnl Copyright 2005 Red Hat, Inc. +dnl +dnl Permission to use, copy, modify, distribute, and sell this software and its +dnl documentation for any purpose is hereby granted without fee, provided that +dnl the above copyright notice appear in all copies and that both that +dnl copyright notice and this permission notice appear in supporting +dnl documentation, and that the name of Red Hat not be used in +dnl advertising or publicity pertaining to distribution of the software without +dnl specific, written prior permission. Red Hat makes no +dnl representations about the suitability of this software for any purpose. It +dnl is provided "as is" without express or implied warranty. +dnl +dnl RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +dnl EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR +dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +dnl PERFORMANCE OF THIS SOFTWARE. +dnl +dnl Process this file with autoconf to create configure. + +AC_PREREQ([2.57]) +AC_INIT(xphelloworld,[1.0.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],xphelloworld) +AM_INIT_AUTOMAKE([dist-bzip2]) +AM_MAINTAINER_MODE + +AM_CONFIG_HEADER(config.h) + +AC_PROG_CC +AC_PROG_INSTALL + +# Checking for Motif +# +build_motifapps=yes + +AC_ARG_WITH(motif-libraries, [Directory containing the Motif libraries], + motif_libs=$withval) +AC_ARG_WITH(motif-includes, [Directory containing the Xm direcotry with the Motif header files (eg. /usr/X11R6/include)], + motif_includes=$withval) + +if test x$with_motif_libraries = xno; then + echo no motif - commandline $with_motif_libraries + build_motifapps=no +fi + +if [[ -z $motif_libs ]] ; then + PKG_CHECK_MODULES(X11, x11) + AC_CHECK_LIB(Xm, XmFontListCreate, build_motifapps=no, [$X11]) + echo motif library not found + build_motifapps=no +fi + +if test x$build_motifapps = xyes ; then + if [[ ! -z $motif_includes ]] ; then + MOTIF_CFLAGS=-I$motif_includes + fi + + if [[ ! -z $motif_libs ]] ; then + MOTIF_LIBS="-L$motif_libs -lXm" + else + MOTIF_LIBS="-lXm" + fi +fi + +echo build: Build Motif Applications: $build_motifapps + +AM_CONDITIONAL([BUILD_MOTIFAPPS], test "$build_motifapps" = yes) + +# xpawhelloworld +# +if test x$build_motifapps = xyes ; then + PKG_CHECK_MODULES(XPAWHELLOWORLD, xaw8 xprintutil xp) + XPAWHELLOWORLD_CFLAGS="$XPAWHELLOWORLD_CFLAGS $MOTIF_CFLAGS" + XPAWHELLOWORLD_LIBS="$XPAWHELLOWORLD_LIBS $MOTIF_LIBS" +fi + +AC_SUBST(XPAWHELLOWORLD_CFLAGS) +AC_SUBST(XPAWHELLOWORLD_LIBS) + +# +# xphelloworld +# + +PKG_CHECK_MODULES(XPHELLOWORLD, xprintapputil xprintutil xp) + +# +# xpsimplehelloworld +# + +PKG_CHECK_MODULES(XPSIMPLEHELLOWORLD, xprintutil xp) + +# +# xpxmhellowolrd +# + +if test x$build_motifapps = xyes ; then + PKG_CHECK_MODULES(XPXMHELLOWORLD, xprintutil xt xp) + XPXMHELLOWORLD_CFLAGS="$XPXMHELLOWORLD_CFLAGS $MOTIF_CFLAGS" + XPXMHELLOWORLD_LIBS="$XPXMHELLOWORLD_LIBS $MOTIF_LIBS" +fi + +# +# xpxthelloworld +# + +PKG_CHECK_MODULES(XPXTHELLOWORLD, xaw8 xprintutil xt xp) + +XORG_RELEASE_VERSION + +AC_OUTPUT([ + Makefile + xpawhelloworld/Makefile + xphelloworld/Makefile + xpsimplehelloworld/Makefile + xpxmhelloworld/Makefile + xpxthelloworld/Makefile +]) diff --git a/xpawhelloworld/.cvsignore b/xpawhelloworld/.cvsignore new file mode 100644 index 0000000..af533f9 --- /dev/null +++ b/xpawhelloworld/.cvsignore @@ -0,0 +1,4 @@ +.deps +Makefile +Makefile.in +xpxmhelloworld diff --git a/xpawhelloworld/Makefile.am b/xpawhelloworld/Makefile.am new file mode 100644 index 0000000..6c0bc48 --- /dev/null +++ b/xpawhelloworld/Makefile.am @@ -0,0 +1,31 @@ +# +# Copyright 2005 Red Hat, Inc. +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of Red Hat not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. Red Hat makes no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +bin_PROGRAMS = xpawhelloworld + +xpawhelloworld_CFLAGS = $(XPAWHELLOWORLD_CFLAGS) +xpawhelloworld_LDADD = $(XPAWHELLOWORLD_LIBS) + +xpawhelloworld_SOURCES = \ + xpawhelloworld.c + +dist_man1_MANS = \ + xpawhelloworld.man diff --git a/xpawhelloworld/xpawhelloworld.c b/xpawhelloworld/xpawhelloworld.c new file mode 100644 index 0000000..96e5009 --- /dev/null +++ b/xpawhelloworld/xpawhelloworld.c @@ -0,0 +1,467 @@ + +/* + * $Xorg: xpawhelloworld.c,v 1.1 2003/07/30 14:44:31 gisburn Exp $ + * + * xpawhelloworld - Xprint version of hello world using the + * Athena PrintShell widget class + * + * + +Copyright 2003-2004 Roland Mainz <roland.mainz@nrubsig.org> + +All Rights Reserved. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + * + * Author: Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> + */ + +/* + * Referencess: + * http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmPrintShell.htm + * http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmText.htm + * + */ + +#include <X11/IntrinsicP.h> +#include <X11/ShellP.h> +#include <X11/StringDefs.h> +#include <Xm/Xm.h> +#include <Xm/Text.h> +#include <X11/Xaw/XawInit.h> +#include <X11/Xaw/Print.h> +#include <X11/XprintUtil/xprintutil.h> + +#include <stdlib.h> +#include <stdio.h> + +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Error(x) { printf x ; exit(EXIT_FAILURE); } +#define Log(x) { if(verbose) printf x; } +#define Msg(x) { if(!quiet) printf x; } + +/* Prototypes */ +static int do_hello_world( int argc, char *argv[], const char *printername, + const char *toFile, const char *sample_string ); + +/* Global vars */ +const char *ProgramName; /* program name (from argv[0]) */ +Bool verbose = False; /* verbose output what the program is doing */ +Bool quiet = False; /* be quiet (no output except errors) */ +Bool doPrint = False; /* Do we print on a printer ? */ +Display *pdpy = NULL; /* (Paper) display */ +Screen *pscreen = NULL; /* (Paper) screen (DDX-specific!) */ +XPContext pcontext = None; /* Xprint context */ +void *printtofile_handle = NULL; /* XprintUtil "context" when printing to file */ +Drawable pdrawable = None; /* paper drawable */ + +static +void usage( void ) +{ + fprintf(stderr, "usage: %s [options] string\n", ProgramName); + fprintf(stderr, "-print\tPrint via Xprint instead of displaying on the Xserver\n"); + fprintf(stderr, "-printer printernname\tprinter to use\n"); + fprintf(stderr, "-printfile file\tprint to file instead of printer\n"); + fprintf(stderr, "-v\tverbose output\n"); + fprintf(stderr, "-q\tbe quiet (no output except errors)\n"); + fprintf(stderr, "\n"); + exit(EXIT_FAILURE); +} + +static +void PrintSpoolerCommandResults( Display *pdpy, XPContext pcontext ) +{ + char *scr; + + scr = XpGetOneAttribute(pdpy, pcontext, XPJobAttr, "xp-spooler-command-results"); + if( scr ) + { + if( strlen(scr) > 0 ) + { + const char *msg = XpuCompoundTextToXmb(pdpy, scr); + if( msg ) + { + Msg(("Spooler command returned '%s'.\n", msg)); + XpuFreeXmbString(msg); + } + else + { + Msg(("Spooler command returned '%s' (unconverted).\n", scr)); + } + } + + XFree((void *)scr); + } +} + +int main( int argc, char *argv[] ) +{ + const char *printername = NULL; /* printer to query */ + const char *toFile = NULL; /* output file (instead of printer) */ + XPPrinterList plist; /* list of printers */ + int plist_count; /* number of entries in |plist|-array */ + int i; + int retval; + const char *sample_string; + + ProgramName = argv[0]; + + if( argc < 2 ) + { + usage(); + } + + for( i = 1 ; i < (argc-1) ; i++ ) + { + char *arg = argv[i]; + int len = strlen(arg); + + if (!strncmp("-print", arg, len)) + { + doPrint = True; + } + else if (!strncmp("-printer", arg, len)) + { + if (++i >= argc) + usage(); + printername = argv[i]; + doPrint = True; + } + else if (!strncmp("-printfile", arg, len)) + { + if (++i >= argc) + usage(); + toFile = argv[i]; + doPrint = True; + } + else if (!strncmp("-v", arg, len)) + { + verbose = True; + quiet = False; + } + else if (!strncmp("-q", arg, len)) + { + verbose = False; + quiet = True; + } + else + { + usage(); + } + } + + sample_string = argv[argc-1]; + + if( doPrint ) + { + plist = XpuGetPrinterList(printername, &plist_count); + + if (!plist) { + fprintf(stderr, "%s: no printers found for printer spec \"%s\".\n", + ProgramName, NULLSTR(printername)); + exit(EXIT_FAILURE); + } + + Log(("Using printer '%s'\n", plist[0].name)); + + retval = do_hello_world(argc, argv, plist[0].name, toFile, sample_string); + + XpuFreePrinterList(plist); + } + else + { + Log(("Displaying on framebuffer Xserver\n")); + + retval = do_hello_world(argc, argv, NULL, NULL, sample_string); + } + + return retval; +} + +typedef struct +{ + int num_pages; + Widget printshell_content; + int num_visible_rows; + XtAppContext appcontext; /* for XtAppSetExitFlag() */ +} MyPrintCallbackData; + +static +int GetCurrPageNum(Widget printshell) +{ + Cardinal n; + Arg args[2]; + int pagenum = -666; /* bah! */ + + n = 0; + XtSetArg(args[n], XawNcurrPageNumInJob, &pagenum); n++; + XtGetValues(printshell, args, n); + + return pagenum; +} + +static +void PrintOnePageCB(Widget pshell, XtPointer context, XtPointer call_data) +{ + MyPrintCallbackData *mpcd = (MyPrintCallbackData *)context; + XawPrintShellCallbackStruct *psp = (XawPrintShellCallbackStruct *)call_data; + int curr_page; + + curr_page = GetCurrPageNum(pshell); + Log(("--> PrintOnePageCB, printing page %d of %d\n", curr_page, mpcd->num_pages)); + + /* Get ready for next page + * Scroll widget to display the next page (except for the first page :) + */ + if (!psp->last_page_in_job && curr_page > 1) + { + /* XmText allows two solutions to scroll a page down + * - Either scroll num_rows_per_page down (this is XmText-specific) + * or + * - Call the "next-page" action procedure (this works for all widgets + * which support this action proc) + */ +#define USE_ACTION_TO_SCROLL_DOWN 1 +#ifdef USE_ACTION_TO_SCROLL_DOWN + Log(("Scrolling down one page ...\n")); + XtCallActionProc(mpcd->printshell_content, "next-page", NULL, NULL, 0); +#else + Log(("Scrolling down %d rows (=one page) ...\n", mpcd->num_visible_rows)); + XmTextScroll(mpcd->printshell_content, mpcd->num_visible_rows); +#endif /* USE_ACTION_TO_SCROLL_DOWN */ + } + + if (curr_page == (int)mpcd->num_pages) + { + Log(("Printing last page.\n")); + psp->last_page_in_job = True; + } + + Log(("PrintOnePageCB: done\n")); +} + +static +void PrintStartJobCB(Widget pshell, XtPointer context, XtPointer call_data) +{ + XawPrintShellCallbackStruct *psp = (XawPrintShellCallbackStruct *)call_data; + + Log(("--> PrintStartJobCB\n")); +} + +static +void PrintEndJobCB(Widget pshell, XtPointer context, XtPointer call_data) +{ + MyPrintCallbackData *mpcd = (MyPrintCallbackData *)context; + XawPrintShellCallbackStruct *psp = (XawPrintShellCallbackStruct *)call_data; + + Log(("--> PrintEndJobCB\n")); + + /* We're done with printing, tell |XtAppMainLoop()| that it can exit */ + XtAppSetExitFlag(mpcd->appcontext); +} + +int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile, const char *sample_string ) +{ + XtAppContext app; + Widget toplevel, + shell, + print_shell, + hello; + long dpi_x = 0L, + dpi_y = 0L; + char fontname[256]; /* BUG: is this really big enougth ? */ + XFontStruct *textFont; + XmFontList textFontList; + Cardinal n; + Arg args[10]; + MyPrintCallbackData mpcd; + + if( doPrint ) + { + /* Get printer, either by "name" (foobar) or "name@display" (foobar@gaja:5) */ + if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) + Error(("XpuGetPrinter failure.\n")); + + /* Configure the print context (paper size, title etc.) + * We must do this before creating any Xt widgets - otherwise they will + * make wrong assuptions about fonts, resultions etc. ... + */ + XpuSetJobTitle(pdpy, pcontext, "Simple Xprint XawPrintShell widget demo"); + + /* Configuration done, set the context */ + XpSetContext(pdpy, pcontext); + + /* Get default printer resolution */ + if( XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1 ) + { + fprintf(stderr, "No default resolution for printer '%s'\n", printername); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + + pscreen = XpGetScreenOfContext(pdpy, pcontext); + } + else + { + pdpy = XOpenDisplay(NULL); + if( !pdpy ) + Error(("XOpenDisplay failure.\n")); + + dpi_x = dpi_y = 0L; + + pscreen = XDefaultScreenOfDisplay(pdpy); + } + + toplevel = XawOpenApplication(&app, + pdpy, pscreen, + "xpawprintshelldemo", "XpXawPrintShellDemo", + applicationShellWidgetClass, + &argc, argv); + + if( !toplevel ) + Error(("XawOpenApplication failure.\n")); + + if( doPrint ) + { + n = 0; + /* Override any geometry resource settings as XawPrintShell adjusts it's size + * to the current page siue when |XawPrintLAYOUTMODE_DRAWABLEAREA| or + * |XawPrintLAYOUTMODE_PAGESIZE| are used. */ + XtSetArg(args[n], XtNgeometry, "+0+0"); n++; + XtSetArg(args[n], XawNlayoutMode, XawPrintLAYOUTMODE_DRAWABLEAREA); n++; + print_shell = XtCreatePopupShell("myprintshell", + xawPrintShellWidgetClass, + toplevel, args, n); + + /* we're mapping/unmapping at start/end page time */ + XtSetMappedWhenManaged(print_shell, False); + + shell = print_shell; + } + else + { + shell = toplevel; + } + + sprintf(fontname, "-adobe-courier-medium-r-normal--40-*-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); + textFont = XLoadQueryFont(pdpy, fontname); + if( !textFont ) + { + sprintf(fontname, "-*-*-*-*-*-*-*-160-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); + textFont = XLoadQueryFont(pdpy, fontname); + } + if( !textFont ) + Error(("XLoadQueryFont failure.\n")); + textFontList = XmFontListCreate(textFont, XmSTRING_DEFAULT_CHARSET); + + n = 0; + /* Make sure the cursor is off, current Xprt servers do not seem to like + * blinking cursors that much... ;-/ */ + XtSetArg(args[n], XmNcursorPositionVisible, False); n++; + XtSetArg(args[n], XmNvalue, sample_string); n++; + XtSetArg(args[n], XmNfontList, textFontList); n++; + XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; + + hello = XmCreateText(shell, "mytext", args, n); + if( !hello ) + Error(("XmCreateText failure.\n")); + + XtManageChild(hello); + XtRealizeWidget(toplevel); + XtRealizeWidget(shell); + + if( doPrint ) + { + int num_total_rows; + short num_visible_rows; + int num_pages; + + pdpy = XtDisplay(toplevel); + pdrawable = XtWindow(toplevel); + if( !pdpy || !pdrawable ) + Error(("No display.\n")); + + /* Make sure that the Xt machinery is really using the right screen (assertion) */ + if( XpGetScreenOfContext(XtDisplay(toplevel), pcontext) != XtScreen(toplevel) ) + Error(("Widget's screen != print screen. BAD.\n")); + + /* Get number of rows visible per page and the number of total rows + * in the whole text widget... */ + n = 0; + XtSetArg(args[n], XmNrows, &num_visible_rows); n++ ; + XtSetArg(args[n], XmNtotalLines, &num_total_rows); n++ ; + XtGetValues(hello, args, n); + + /* Take away one row to match the one-line overlapping used by the + * "next-page" action proc */ + num_visible_rows -= 1; + + /* Calculate the number of pages */ + num_pages = (num_total_rows+num_visible_rows-1) / num_visible_rows; + Log(("Printing %d pages (num_total_rows=%d, num_visible_rows=%d)...\n", + num_pages, num_total_rows, num_visible_rows)); + + /* Prepare our own context data for the print shell callbacks */ + mpcd.num_pages = num_pages; + mpcd.printshell_content = hello; + mpcd.num_visible_rows = num_visible_rows; + mpcd.appcontext = app; + + /* Setup the print shell callbacks... */ + XtAddCallback(print_shell, XawNpageSetupCallback, PrintOnePageCB, (XtPointer)&mpcd); + XtAddCallback(print_shell, XawNstartJobCallback, PrintStartJobCB, NULL); + XtAddCallback(print_shell, XawNendJobCallback, PrintEndJobCB, (XtPointer)&mpcd); + + /* ... and finally start the print job. */ + if( toFile ) + { + printtofile_handle = XpuStartJobToFile(pdpy, pcontext, toFile); + if( !printtofile_handle ) + { + perror("XpuStartJobToFile failure"); + Error(("XpuStartJobToFile failure.")); + } + } + else + { + XpuStartJobToSpooler(pdpy); + } + } + + XtAppMainLoop(app); + + if( doPrint ) + { + if( toFile ) + { + if( XpuWaitForPrintFileChild(printtofile_handle) != XPGetDocFinished ) + { + fprintf(stderr, "%s: Error while printing to file.\n", ProgramName); + } + } + + PrintSpoolerCommandResults(pdpy, pcontext); + + /* We have to use XpDestroyContext() and XtCloseDisplay() instead + * of XpuClosePrinterDisplay() to make libXt happy... */ + if( pcontext != None ) + XpDestroyContext(pdpy, pcontext); + XtCloseDisplay(pdpy); + } + + return EXIT_SUCCESS; +} diff --git a/xpawhelloworld/xpawhelloworld.man b/xpawhelloworld/xpawhelloworld.man new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/xpawhelloworld/xpawhelloworld.man diff --git a/xphelloworld/.cvsignore b/xphelloworld/.cvsignore new file mode 100644 index 0000000..5dbf588 --- /dev/null +++ b/xphelloworld/.cvsignore @@ -0,0 +1,4 @@ +.deps +Makefile +Makefile.in +xphelloworld diff --git a/xphelloworld/Makefile.am b/xphelloworld/Makefile.am new file mode 100644 index 0000000..2a9b0be --- /dev/null +++ b/xphelloworld/Makefile.am @@ -0,0 +1,33 @@ +# +# Copyright 2005 Red Hat, Inc. +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of Red Hat not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. Red Hat makes no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +bin_PROGRAMS = xphelloworld + +xphelloworld_CFLAGS = $(XPHELLOWORLD_CFLAGS) +xphelloworld_LDADD = $(XPHELLOWORLD_LIBS) + +xphelloworld_SOURCES = \ + xphelloworld.c + +dist_man1_MANS = \ + xphelloworld.man + +EXTRA_DIST = xphelloworld.sgml diff --git a/xphelloworld/xphelloworld.c b/xphelloworld/xphelloworld.c new file mode 100644 index 0000000..bfd5993 --- /dev/null +++ b/xphelloworld/xphelloworld.c @@ -0,0 +1,311 @@ +/* + * $Xorg: xphelloworld.c,v 1.1 2002/02/10 22:54:18 gisburn Exp $ + * + * xphelloworld - Xprint version of hello world + * + * +Copyright 2002-2004 Roland Mainz <roland.mainz@nrubsig.org> + +All Rights Reserved. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + * + * Author: Roland Mainz <roland.mainz@nrubsig.org> + */ + +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/XprintAppUtil/xpapputil.h> + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Log(x) { if(verbose) printf x; } +#define Msg(x) { if(!quiet) printf x; } + +const char *ProgramName; /* program name (from argv[0]) */ +Bool verbose = False; /* verbose output what the program is doing */ +Bool quiet = False; /* be quiet (no output except errors) */ + +static +void usage( void ) +{ + fprintf (stderr, "usage: %s [options]\n", ProgramName); + fprintf (stderr, "-printer printernname\tprinter to use\n"); + fprintf (stderr, "-printargs args\t[ arg=value , ... ]\n"); + fprintf (stderr, "\targs:\ttofile=<filename>\n"); + fprintf (stderr, "\t\tpapersize=<paper name>\n"); + fprintf (stderr, "\t\torientation=<orientation>\n"); + fprintf (stderr, "\t\tresolution=<DPI>\n"); + fprintf (stderr, "\t\tplex=<plex>\n"); + fprintf (stderr, "\t\ttitle=<string>\n"); + fprintf (stderr, "-v\tverbose output\n"); + fprintf (stderr, "-q\tbe quiet (no output except errors)\n"); + fprintf (stderr, "-text <string>\ttext to print (in ISO-8859-1)\n"); + fprintf (stderr, "\n"); + exit(EXIT_FAILURE); +} + +static +void PrintSpoolerCommandResults( Display *pdpy, XPContext pcontext ) +{ + char *scr; + + scr = XpGetOneAttribute(pdpy, pcontext, XPJobAttr, "xp-spooler-command-results"); + if( scr ) + { + if( strlen(scr) > 0 ) + { + const char *msg = XpuCompoundTextToXmb(pdpy, scr); + if( msg ) + { + Msg(("Spooler command returned '%s'.\n", msg)); + XpuFreeXmbString(msg); + } + else + { + Msg(("Spooler command returned '%s' (unconverted).\n", scr)); + } + } + + XFree((void *)scr); + } +} + +static +int do_hello_world( const char *printername, const char *printerargs, const char *hello_world_message ) +{ + char *printerfile = NULL; + Window pwin; + XGCValues gcvalues; + GC pgc; + unsigned short dummy; + XRectangle winrect; + char fontname[256]; /* BUG: is this really big enougth ? */ + XFontStruct *font; + XpauContext *context; + XpauFlags docvalueflags = 0UL; + XpauDocValues x_docvalues; + XpauDocValues *docvalues = &x_docvalues; + XpAuErrorValue result; + + XpauFlags jobvalueflags = 0UL; + XpauJobValues x_jobvalues; + XpauJobValues *jobvalues = &x_jobvalues; + memset(&x_jobvalues, 0, sizeof(x_jobvalues)); + memset(&x_docvalues, 0, sizeof(x_docvalues)); + + context = XpauGetContext(printername); + if( !context ) + { + fprintf(stderr, "XpauGetContext() failure.\n"); + return(EXIT_FAILURE); + } + + if( (result = XpauParseArgs(context, &jobvalueflags, jobvalues, &docvalueflags, docvalues, &printerfile, printerargs)) != XpAuError_success ) + { + fprintf(stderr, "XpuParseArgs() failure: %s.\n", XpAuErrorValueToString(result)); + XpauReleaseContext(context); + return(EXIT_FAILURE); + } + + if( (result = XpauSetJobValues(context, jobvalueflags, jobvalues)) != XpAuError_success ) + { + fprintf(stderr, "XpauSetJobValues() failure: %s.\n", XpAuErrorValueToString(result)); + XpauReleaseContext(context); + return(EXIT_FAILURE); + } + + if( (result = XpauSetDocValues(context, docvalueflags, docvalues)) != XpAuError_success ) + { + fprintf(stderr, "XpauSetDocValues() failure: %s.\n", XpAuErrorValueToString(result)); + XpauReleaseContext(context); + return(EXIT_FAILURE); + } + + /* Listen to XP(Start|End)(Job|Doc|Page)Notify events). + * This is mantatory as Xp(Start|End)(Job|Doc|Page) functions are _not_ + * syncronous !! + * Not waiting for such events may cause that subsequent data may be + * destroyed/corrupted!! + */ + XpSelectInput(context->pdpy, context->pcontext, XPPrintMask); + + if( printerfile ) + { + Log(("starting job (to file '%s').\n", printerfile)); + } + else + { + Log(("starting job.\n")); + } + + if( (result = XpauStartJob(context, printerfile)) != XpAuError_success ) + { + fprintf(stderr, "%s: Error: %s while trying to print.\n", + ProgramName, XpAuErrorValueToString(result)); + XpauReleaseContext(context); + return(EXIT_FAILURE); + } + + XpauWaitForPrintNotify(context, XPStartJobNotify); + + /* Obtain some info about page geometry */ + XpGetPageDimensions(context->pdpy, context->pcontext, &dummy, &dummy, &winrect); + + pwin = XCreateSimpleWindow(context->pdpy, XRootWindowOfScreen(context->pscreen), + winrect.x, winrect.y, winrect.width, winrect.height, + 10, + XBlackPixel(context->pdpy, context->pscreennumber), + XWhitePixel(context->pdpy, context->pscreennumber)); + + gcvalues.background = XWhitePixel(context->pdpy, context->pscreennumber); + gcvalues.foreground = XBlackPixel(context->pdpy, context->pscreennumber); + + pgc = XCreateGC(context->pdpy, pwin, GCBackground|GCForeground, &gcvalues); + + Log(("start page.\n")); + XpauStartPage(context, pwin); + XpauWaitForPrintNotify(context, XPStartPageNotify); + + /* Mapping the window inside XpStartPage()/XpEndPage() + * Set XCreateWindow/border_width to 0 or move XMapWindow in front of + * XpStartPage() to get rid of the surrounding black border lines. + * (This is usually done before XpStartPage() in real applications) + */ + XMapWindow(context->pdpy, pwin); + + /* usual rendering stuff..... */ + + sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", context->document_dpi_x, context->document_dpi_y); + font = XLoadQueryFont(context->pdpy, fontname); + XSetFont(context->pdpy, pgc, font->fid); + if (!hello_world_message) + hello_world_message = "hello world from X11 print system"; + XDrawString(context->pdpy, pwin, pgc, 100, 100, hello_world_message, strlen(hello_world_message)); + + XpauEndPage(context); + XpauWaitForPrintNotify(context, XPEndPageNotify); + Log(("end page.\n")); + + Log(("end job.\n")); + + if( (result = XpauEndJob(context)) != XpAuError_success ) + { + fprintf(stderr, "%s: Error while printing: %s.\n", + ProgramName, XpAuErrorValueToString(result)); + XpauReleaseContext(context); + return(EXIT_FAILURE); + } + + XpauWaitForPrintNotify(context, XPEndJobNotify); + + /* end of spooled job - get spooler command results and print them */ + PrintSpoolerCommandResults(context->pdpy, context->pcontext); + + XpauReleaseContext(context); + return(EXIT_SUCCESS); +} + + +int main (int argc, char *argv[]) +{ + const char *printername = NULL; /* printer to query */ + const char *printargs = NULL; + const char *hello_world_message = NULL; + Bool use_threadsafe_api = False; /* Use threadsafe API (for debugging) */ + XPPrinterList plist; /* list of printers */ + int plist_count; /* number of entries in |plist|-array */ + int i; + int retval; + + ProgramName = argv[0]; + + for (i = 1; i < argc; i++) + { + char *arg = argv[i]; + int len = strlen(arg); + + if (!strncmp("-printer", arg, len)) + { + if (++i >= argc) + usage(); + printername = argv[i]; + } + else if (!strncmp("-printargs", arg, len)) + { + if (++i >= argc) + usage(); + + printargs = argv[i]; + } + else if (!strncmp("-text", arg, len)) + { + if (++i >= argc) + usage(); + + hello_world_message = argv[i]; + } + else if( !strncmp("-debug_use_threadsafe_api", arg, len) ) + { + use_threadsafe_api = True; + } + else if (!strncmp("-v", arg, len)) + { + verbose = True; + quiet = False; + } + else if (!strncmp("-q", arg, len)) + { + verbose = False; + quiet = True; + } + else + { + usage(); + } + } + + if( use_threadsafe_api ) + { + if( !XInitThreads() ) + { + fprintf(stderr, "%s: XInitThreads() failure.\n", ProgramName); + exit(EXIT_FAILURE); + } + } + + plist = XpuGetPrinterList(printername, &plist_count); + + if (!plist) { + fprintf(stderr, "%s: no printers found for printer spec \"%s\".\n", + ProgramName, NULLSTR(printername)); + exit(EXIT_FAILURE); + } + + Log(("Using printer '%s'\n", plist[0].name)); + + retval = do_hello_world(plist[0].name, printargs, hello_world_message); + + XpuFreePrinterList(plist); + + return(retval); +} + + diff --git a/xphelloworld/xphelloworld.man b/xphelloworld/xphelloworld.man new file mode 100644 index 0000000..027ed72 --- /dev/null +++ b/xphelloworld/xphelloworld.man @@ -0,0 +1,63 @@ +.\" -*- coding: us-ascii -*- +.TH xphelloworld __appmansuffix__ "8 October 2004" +.SH NAME +xphelloworld \- sends a test page to an Xprint printer +.SH SYNOPSIS +.ad l +\fBxphelloworld\fR \kx +.if (\nxu > (\n(.lu / 2)) .nr x (\n(.lu / 5) +'in \n(.iu+\nxu +[\fB\-printer \fBprinternname\fR\fR] [\fB\-printargs +\fBarg\fR= \fBvalue\fR [,...]\fR] [\fB\-v\fR] [\fB\-text \fBtext\fR\fR] [\fB\-h\fR] +'in \n(.iu-\nxu +.ad b +.SH DESCRIPTION +xphelloworld is a utility for Xprint, the +printing system for the X Window system. It sends a test page to +the specified printer (or the default printer, if none is specified). +.SH OPTIONS +.TP +\fB\-printer \fIprinternname\fB\fR +printer to use +.TP +\fB\-printargs \fIarg\fB=\fIvalue\fB [,...]\fR +Args: +.RS +.TP +\fBtofile=\fIfilename\fB\fR +.TP +\fBpapersize=\fIpaper name\fB\fR +.TP +\fBorientation=\fIorientation\fB\fR +.TP +\fBresolution=\fIDPI\fB\fR +.TP +\fBplex=\fIplex\fB\fR +.TP +\fBtitle=\fIstring\fB\fR +.RE + +.TP +\fB\-text \fItext\fB\fR +Sample text to print. Default is "hello world from X11 print system". +.TP +\fB\-v\fR +verbose output +.TP +\fB\-h\fR +print usage +.SH ENVIRONMENT +.TP +\fBXPSERVERLIST\fR +\fB${XPSERVERLIST}\fR must be set, +identifying the available Xprint servers. +See \fBXprint\fR(__miscmansuffix__) +for more details. +.SH "KNOWN BUGS" + +The \fB\-text\fR option assumes that the text is in ISO8859-1 encoding +(the \fB${LANG}\fR environment variable is not honored in this case). + +A full list of bugs can be obtained from the Xprint.org bug database (http://xprint.mozdev.org/xprint_bugs.html). +.SH "SEE ALSO" +\fBXprint\fR(__miscmansuffix__), \fBX11\fR(__miscmansuffix__), \fBxplsprinters\fR(__appmansuffix__), \fBxpxmhelloworld\fR(__appmansuffix__), \fBxpawhelloworld\fR(__appmansuffix__), \fBxpxthelloworld\fR(__appmansuffix__), \fBxpsimplehelloworld\fR(__appmansuffix__), \fBXserver\fR(__appmansuffix__), \fBXprt\fR(__appmansuffix__), \fBlibXp\fR(__libmansuffix__), \fBlibXprintUtils\fR(__libmansuffix__), \fBlibXprintAppUtils\fR(__libmansuffix__), \fBXmPrintShell\fR(__libmansuffix__), \fBXawPrintShell\fR(__libmansuffix__), Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html), Xprint main site (http://xprint.mozdev.org/) diff --git a/xphelloworld/xphelloworld.sgml b/xphelloworld/xphelloworld.sgml new file mode 100644 index 0000000..14760d5 --- /dev/null +++ b/xphelloworld/xphelloworld.sgml @@ -0,0 +1,187 @@ +<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.2//EN" 'http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd'> + +<!-- Process this file with DocBook tools to generate the output format +(such as manual pages or HTML documents). + +Note that strings like __appmansuffix__, __filemansuffix__, __libmansuffix__, +__miscmansuffix__ etc. have to be replaced first (in theory that's the +job of ENTITIES but some XML tools are highly allergic to such stuff... ;-(). +A quick way to do that is to filter this document via +/usr/bin/sed "s/__appmansuffix__/${MANSUFFIX}/g;s/__filemansuffix__/${FILEMANSUFFIX}/g;s/__libmansuffix__/${LIBMANSUFFIX}/g;s/__miscmansuffix__/${MISCMANSUFFIX}/g" +assuming that env vars like MANSUFFIX etc. have been set to the matching +manual volume numbers. + --> + +<refentry> + <refmeta> + <refentrytitle>xphelloworld</refentrytitle> + <manvolnum>__appmansuffix__</manvolnum> + </refmeta> + <refnamediv> + <refname>xphelloworld</refname> + + <refpurpose>sends a test page to an Xprint printer</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>xphelloworld</command> + + <arg><option>-printer <replaceable>printernname</replaceable></option></arg> + + <arg><option>-printargs + <replaceable>arg</replaceable>=<replaceable>value</replaceable> [,...]</option></arg> + + <arg><option>-v</option></arg> + + <arg><option>-text <replaceable>text</replaceable></option></arg> + + <arg><option>-h</option></arg> + + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>DESCRIPTION</title> + + <para><command>xphelloworld</command> is a utility for Xprint, the + printing system for the X Window system. It sends a test page to + the specified printer (or the default printer, if none is specified). + </para> + + </refsect1> + + <refsect1> + <title>OPTIONS</title> + + <variablelist> + <varlistentry> + <term><option>-printer <replaceable>printernname</replaceable></option> + </term> + <listitem> + <para>printer to use</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-printargs <replaceable>arg</replaceable>=<replaceable>value</replaceable> [,...]</option> + </term> + <listitem> + <para>Args: + <variablelist> + <varlistentry> + <term><userinput>tofile=<replaceable>filename</replaceable></userinput></term> + <listitem><para></para></listitem> + </varlistentry> + <varlistentry> + <term><userinput>papersize=<replaceable>paper name</replaceable></userinput></term> + <listitem><para></para></listitem> + </varlistentry> + <varlistentry> + <term><userinput>orientation=<replaceable>orientation</replaceable></userinput></term> + <listitem><para></para></listitem> + </varlistentry> + <varlistentry> + <term><userinput>resolution=<replaceable>DPI</replaceable></userinput></term> + <listitem><para></para></listitem> + </varlistentry> + <varlistentry> + <term><userinput>plex=<replaceable>plex</replaceable></userinput></term> + <listitem><para></para></listitem> + </varlistentry> + <varlistentry> + <term><userinput>title=<replaceable>string</replaceable></userinput></term> + <listitem><para></para></listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-text <replaceable>text</replaceable></option> + </term> + <listitem> + <para>Sample text to print. Default is "hello world from X11 print system".</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-v</option> + </term> + <listitem> + <para>verbose output</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-h</option> + </term> + <listitem> + <para>print usage</para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1> + <title>ENVIRONMENT</title> + <variablelist> + <varlistentry> + <term><envar>XPSERVERLIST</envar> + </term> + <listitem> + <para> + <envar>${XPSERVERLIST}</envar> must be set, + identifying the available Xprint servers. + See <citerefentry><refentrytitle>Xprint</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry> + for more details. + </para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1> + <title>KNOWN BUGS</title> + <para> + <simplelist type="vert"> + <member> + The <option>-text</option> option assumes that the text is in ISO8859-1 encoding + (the <envar>${LANG}</envar> environment variable is not honored in this case). + </member> + </simplelist> + A full list of bugs can be obtained from the Xprint.org bug database (<ulink url="http://xprint.mozdev.org/xprint_bugs.html">http://xprint.mozdev.org/xprint_bugs.html</ulink>). + </para> + </refsect1> + + <refsect1> + <title>SEE ALSO</title> + <para> + <simplelist type="inline"> + <!-- specific references --> + <!-- none --> + + <!-- Xprint general references --> + <member><citerefentry><refentrytitle>Xprint</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>X11</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xplsprinters</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> +<!-- + <member><citerefentry><refentrytitle>xphelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> +--> + <member><citerefentry><refentrytitle>xpxmhelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xpawhelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xpxthelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xpsimplehelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>Xserver</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>Xprt</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <!-- ToDO: Add manual pages for the single Xprint DDX implementations (PostScript/PDF/PCL/PCL-MONO/Raster/etc.) --> + <member><citerefentry><refentrytitle>libXp</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>libXprintUtils</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>libXprintAppUtils</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>XmPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>XawPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member>Xprint FAQ (<ulink url="http://xprint.mozdev.org/docs/Xprint_FAQ.html">http://xprint.mozdev.org/docs/Xprint_FAQ.html</ulink>)</member> + <member>Xprint main site (<ulink url="http://xprint.mozdev.org/">http://xprint.mozdev.org/</ulink>)</member> + </simplelist> + </para> + </refsect1> + +</refentry> + + + diff --git a/xpsimplehelloworld/.cvsignore b/xpsimplehelloworld/.cvsignore new file mode 100644 index 0000000..6b6b632 --- /dev/null +++ b/xpsimplehelloworld/.cvsignore @@ -0,0 +1,4 @@ +.deps +Makefile +Makefile.in +xpsimplehelloworld diff --git a/xpsimplehelloworld/Makefile.am b/xpsimplehelloworld/Makefile.am new file mode 100644 index 0000000..b62f14f --- /dev/null +++ b/xpsimplehelloworld/Makefile.am @@ -0,0 +1,33 @@ +# +# Copyright 2005 Red Hat, Inc. +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of Red Hat not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. Red Hat makes no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +bin_PROGRAMS = xpsimplehelloworld + +xpsimplehelloworld_CFLAGS = $(XPSIMPLEHELLOWORLD_CFLAGS) +xpsimplehelloworld_LDADD = $(XPSIMPLEHELLOWORLD_LIBS) + +xpsimplehelloworld_SOURCES = \ + xpsimplehelloworld.c + +dist_man1_MANS = \ + xpsimplehelloworld.man + +EXTRA_DIST = xpsimplehelloworld.sgml diff --git a/xpsimplehelloworld/xpsimplehelloworld.c b/xpsimplehelloworld/xpsimplehelloworld.c new file mode 100644 index 0000000..3fd05e8 --- /dev/null +++ b/xpsimplehelloworld/xpsimplehelloworld.c @@ -0,0 +1,405 @@ +/* + * $Xorg: xphelloworld.c,v 1.2 2002/05/10 06:54:^1 gisburn Exp $ + * + * xphelloworld - Xprint version of hello world + * + * +Copyright 2002-2004 Roland Mainz <roland.mainz@nrubsig.org> + +All Rights Reserved. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + * + * Author: Roland Mainz <roland.mainz@nrubsig.org> + */ + +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/XprintUtil/xprintutil.h> + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> + +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Log(x) { if(verbose) printf x; } +#define Msg(x) { if(!quiet) printf x; } + +static const char *ProgramName; /* program name (from argv[0]) */ +static Bool verbose = False; /* verbose output what the program is doing */ +Bool quiet = False; /* be quiet (no output except errors) */ + +static +void usage(void) +{ + fprintf (stderr, "usage: %s [options]\n", ProgramName); + fprintf (stderr, "-printer printernname\tprinter to use\n"); + fprintf (stderr, "-printfile file\tprint to file instead of printer\n"); + fprintf (stderr, "-embedpsl2data string\tPostScript level 2 fragment to embed\n" + "\t\t(use 'xppsembeddemo1' to embed demo data)\n"); + fprintf (stderr, "-v\tverbose output\n"); + fprintf (stderr, "-q\tbe quiet (no output except errors)\n"); + fprintf (stderr, "\n"); + exit(EXIT_FAILURE); +} + +/* strstr(), case-insensitive */ +static +char *str_case_str(const char *s, const char *find) +{ + size_t len; + char c, + sc; + + if ((c = tolower(*find++)) != '\0') + { + len = strlen(find); + do + { + do + { + if ((sc = tolower(*s++)) == '\0') + return NULL; + } while (sc != c); + } while (strncasecmp(s, find, len) != 0); + s--; + } + return ((char *)s); +} + +static +int do_hello_world(const char *printername, const char *printerfile, const char *psembeddata ) +{ + Display *pdpy; /* X connection */ + XPContext pcontext; /* Xprint context */ + void *printtofile_handle; /* "context" when printing to file */ + int xp_event_base, /* XpExtension even base */ + xp_error_base; /* XpExtension error base */ + long dpi_x = 0L, + dpi_y = 0L; + Screen *pscreen; + int pscreennumber; + Window pwin; + XGCValues gcvalues; + GC pgc; + unsigned short dummy; + XRectangle winrect; + char fontname[256]; /* BUG: is this really big enougth ? */ + XFontStruct *font; + char *scr; + + if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) + { + fprintf(stderr, "Cannot open printer '%s'\n", printername); + return(EXIT_FAILURE); + } + + if( XpQueryExtension(pdpy, &xp_event_base, &xp_error_base) == False ) + { + fprintf(stderr, "XpQueryExtension() failed.\n"); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + + /* Listen to XP(Start|End)(Job|Doc|Page)Notify events). + * This is mantatory as Xp(Start|End)(Job|Doc|Page) functions are _not_ + * syncronous !! + * Not waiting for such events may cause that subsequent data may be + * destroyed/corrupted!! + */ + XpSelectInput(pdpy, pcontext, XPPrintMask); + + /* Set job title */ + XpuSetJobTitle(pdpy, pcontext, "Hello world for Xprint"); + + /* Set print context + * Note that this modifies the available fonts, including builtin printer prints. + * All XListFonts()/XLoadFont() stuff should be done _after_ setting the print + * context to obtain the proper fonts. + */ + XpSetContext(pdpy, pcontext); + + /* Get default printer reolution */ + if( XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1 ) + { + fprintf(stderr, "No default resolution for printer '%s'.\n", printername); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + + if( printerfile ) + { + Log(("starting job (to file '%s').\n", printerfile)); + printtofile_handle = XpuStartJobToFile(pdpy, pcontext, printerfile); + if( !printtofile_handle ) + { + fprintf(stderr, "%s: Error: %s while trying to print to file.\n", + ProgramName, strerror(errno)); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + + XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartJobNotify); + } + else + { + Log(("starting job.\n")); + XpuStartJobToSpooler(pdpy); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartJobNotify); + } + +#ifdef MULTIPLE_DOCUMENTS_IN_ONE_JOB + /* Start document (one job can contain any number of "documents") + * XpStartDoc() isn't mandatory if job only contains one document - first + * XpStartPage() will generate a "synthetic" XpStartDoc() if one had not + * already been done. + */ + XpStartDoc(pdpy, XPDocNormal); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartDocNotify); +#endif /* MULTIPLE_DOCUMENTS_IN_ONE_JOB */ + + pscreen = XpGetScreenOfContext(pdpy, pcontext); + pscreennumber = XScreenNumberOfScreen(pscreen); + + /* Obtain some info about page geometry */ + XpGetPageDimensions(pdpy, pcontext, &dummy, &dummy, &winrect); + + pwin = XCreateSimpleWindow(pdpy, XRootWindowOfScreen(pscreen), + winrect.x, winrect.y, winrect.width, winrect.height, + 10, + XBlackPixel(pdpy, pscreennumber), + XWhitePixel(pdpy, pscreennumber)); + + gcvalues.background = XWhitePixel(pdpy, pscreennumber); + gcvalues.foreground = XBlackPixel(pdpy, pscreennumber); + + pgc = XCreateGC(pdpy, pwin, GCBackground|GCForeground, &gcvalues); + + Log(("start page.\n")); + XpStartPage(pdpy, pwin); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartPageNotify); + + /* Mapping the window inside XpStartPage()/XpEndPage() + * Set XCreateWindow/border_width to 0 or move XMapWindow in front of + * XpStartPage() to get rid of the surrounding black border lines. + * (This is usually done before XpStartPage() in real applications) + */ + XMapWindow(pdpy, pwin); + + /* usual rendering stuff..... */ + + sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); + font = XLoadQueryFont(pdpy, fontname); + XSetFont(pdpy, pgc, font->fid); + XDrawString(pdpy, pwin, pgc, 100, 100, "hello world from X11 print system", 33); + +#define DO_EMBED_TEST 1 + +#ifdef DO_EMBED_TEST + if( psembeddata ) + { + char *embedded_formats_supported; + + embedded_formats_supported = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "xp-embedded-formats-supported"); + + Log(("psembed: xp-embedded-formats-supported='%s'\n", NULLSTR(embedded_formats_supported))); + + /* MAX(XExtendedMaxRequestSize(pdpy), XMaxRequestSize(pdpy)) defines the + * maximum length of emebdded PostScript data which can be send in one + * step using XpPutDocumentData() */ + Log(("psembed: XExtendedMaxRequestSize=%ld\n", (long)XExtendedMaxRequestSize(pdpy))); + Log(("psembed: XMaxRequestSize=%ld\n", (long)XMaxRequestSize(pdpy))); + + /* Should we embed the demo ? */ + if( !strcmp(psembeddata, "xppsembeddemo1") ) + { + Log(("psembed: Using PS embedding demo 1\n")); + psembeddata = "newpath\n270 360 moveto\n 0 72 rlineto\n" + "72 0 rlineto\n 0 -72 rlineto\n closepath\n fill\n"; + } + else + { + Log(("psembed: Using user PS embedding data = '%s'\n", psembeddata)); + } + + /* Check whether "PostScript Level 2" is supported as embedding format + * (The content of the "xp-embedded-formats-supported" attribute needs + * to be searched in a case-insensitive way since the model-configs + * may use the same word with multiple variants of case + * (e.g. "PostScript" vs. "Postscript" or "PCL" vs. "Pcl" etc.") + * To avoid problems we simply use |str_case_str()| (case-insensitive + * strstr()) instead of |strstr()| here...) + */ + if( embedded_formats_supported && + (str_case_str(embedded_formats_supported, "PostScript 2") != NULL) ) + { + /* Note that the emebdded PostScript code uses the same resolution and + * coordinate space as currently be used by the DDX (if you don not + * want that simply reset it yourself :) */ + char *test = (char *)psembeddata; + int test_len = strlen(test); + char *type = "PostScript 2"; /* Format of embedded data + * (older PS DDX may be picky, fixed via + * http://xprint.mozdev.org/bugs/show_bug.cgi?id=4023) + */ + char *option = ""; /* PostScript DDX does not support any options yet + * (in general |BadValue| will be returned for not + * supported options/option values) */ + XpPutDocumentData(pdpy, pwin, test, test_len, type, option); + } + else + { + Log(("psembed: error: cannot embed data, 'PostScript 2' not supported as embedded data format for this printer\n")); + } + } +#endif /* DO_EMBED_TEST */ + + XpEndPage(pdpy); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPEndPageNotify); + Log(("end page.\n")); + +#ifdef DO_SOME_MORE_RENDERING + XpStartPage(pdpy); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartPageNotify); + + /* some more rendering..... */ + + XpEndPage(pdpy); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPEndPageNotify); +#endif /* DO_SOME_MORE_RENDERING */ + +#ifdef MULTIPLE_DOCUMENTS_IN_ONE_JOB + /* End document. Do _not_ use it if you did not explicitly used + * XpStartDoc() above (e.g. if XpStartDoc() was triggered by first + * XpStartPage() - see comment about XpStartDoc() above... + */ + XpEndDoc(pdpy); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPEndDocNotify); +#endif /* MULTIPLE_DOCUMENTS_IN_ONE_JOB */ + + /* End the print job - the final results are sent by the X print + * server to the spooler sub system. + */ + XpEndJob(pdpy); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPEndJobNotify); + Log(("end job.\n")); + + if( printerfile ) + { + if( XpuWaitForPrintFileChild(printtofile_handle) != XPGetDocFinished ) + { + fprintf(stderr, "%s: Error while printing to file.\n", ProgramName); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + } + + /* End of spooled job - get spooler command results and print them */ + scr = XpGetOneAttribute(pdpy, pcontext, XPJobAttr, "xp-spooler-command-results"); + if( scr ) + { + if( strlen(scr) > 0 ) + { + const char *msg = XpuCompoundTextToXmb(pdpy, scr); + if( msg ) + { + Msg(("Spooler command returned '%s'.\n", msg)); + XpuFreeXmbString(msg); + } + else + { + Msg(("Spooler command returned '%s' (unconverted).\n", scr)); + } + } + + XFree((void *)scr); + } + + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_SUCCESS); +} + +int main (int argc, char *argv[]) +{ + const char *printername = NULL; /* printer to query */ + const char *toFile = NULL; /* output file (instead of printer) */ + const char *embedpsl2data = NULL; /* PS Level 2 code fragment for embedding in output */ + XPPrinterList plist; /* list of printers */ + int plist_count; /* number of entries in |plist|-array */ + int i; + int retval; + + ProgramName = argv[0]; + + for (i = 1; i < argc; i++) + { + char *arg = argv[i]; + int len = strlen(arg); + + if (!strncmp("-printer", arg, len)) + { + if (++i >= argc) + usage(); + printername = argv[i]; + } + else if (!strncmp("-printfile", arg, len)) + { + if (++i >= argc) + usage(); + toFile = argv[i]; + } + else if (!strncmp("-embedpsl2data", arg, len)) + { + if (++i >= argc) + usage(); + embedpsl2data = argv[i]; + } + else if (!strncmp("-v", arg, len)) + { + verbose = True; + quiet = False; + } + else if (!strncmp("-q", arg, len)) + { + verbose = False; + quiet = True; + } + else + { + usage(); + } + } + + plist = XpuGetPrinterList(printername, &plist_count); + + if (!plist) { + fprintf(stderr, "%s: no printers found for printer spec \"%s\".\n", + ProgramName, NULLSTR(printername)); + exit(EXIT_FAILURE); + } + + Log(("Using printer '%s'\n", plist[0].name)); + + retval = do_hello_world(plist[0].name, toFile, embedpsl2data); + + XpuFreePrinterList(plist); + + return(retval); +} + + diff --git a/xpsimplehelloworld/xpsimplehelloworld.man b/xpsimplehelloworld/xpsimplehelloworld.man new file mode 100644 index 0000000..0a2c9ea --- /dev/null +++ b/xpsimplehelloworld/xpsimplehelloworld.man @@ -0,0 +1,43 @@ +.\" -*- coding: us-ascii -*- +.TH xpsimplehelloworld __appmansuffix__ "8 October 2004" +.SH NAME +xpsimplehelloworld \- "Hello World"-like Xprint sample utility based on plain X11 rendering calls +.SH SYNOPSIS +.ad l +\fBxpsimplehelloworld\fR \kx +.if (\nxu > (\n(.lu / 2)) .nr x (\n(.lu / 5) +'in \n(.iu+\nxu +[\fB\-printer \fBprinternname\fR\fR] [\fB\-v\fR] [\fB\-h\fR] +'in \n(.iu-\nxu +.ad b +.SH DESCRIPTION +xpsimplehelloworld is a sample utility for Xprint, the +printing system for the X Window system. It demonstrates how to send a test page to +the specified printer (or the default printer, if none is specified) using plain X11 +rendering instructions and without using special toolkit support (like one of +the special Xt print shell widget classes +(such as +\fBXmPrintShell\fR(__libmansuffix__) +or +\fBXawPrintShell\fR(__libmansuffix__))). +.SH OPTIONS +.TP +\fB\-printer \fIprinternname\fB\fR +printer to use +.TP +\fB\-v\fR +verbose output +.TP +\fB\-h\fR +print usage +.SH ENVIRONMENT +.TP +\fBXPSERVERLIST\fR +\fB${XPSERVERLIST}\fR must be set, +identifying the available Xprint servers. +See \fBXprint\fR(__miscmansuffix__) +for more details. +.SH "KNOWN BUGS" +A full list of bugs can be obtained from the Xprint.org bug database (http://xprint.mozdev.org/xprint_bugs.html). +.SH "SEE ALSO" +\fBXprint\fR(__miscmansuffix__), \fBX11\fR(__miscmansuffix__), \fBxplsprinters\fR(__appmansuffix__), \fBxphelloworld\fR(__appmansuffix__), \fBxpxmhelloworld\fR(__appmansuffix__), \fBxpawhelloworld\fR(__appmansuffix__), \fBxpxthelloworld\fR(__appmansuffix__), \fBXserver\fR(__appmansuffix__), \fBXprt\fR(__appmansuffix__), \fBlibXp\fR(__libmansuffix__), \fBlibXprintUtils\fR(__libmansuffix__), \fBlibXprintAppUtils\fR(__libmansuffix__), \fBXmPrintShell\fR(__libmansuffix__), \fBXawPrintShell\fR(__libmansuffix__), Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html), Xprint main site (http://xprint.mozdev.org/) diff --git a/xpsimplehelloworld/xpsimplehelloworld.sgml b/xpsimplehelloworld/xpsimplehelloworld.sgml new file mode 100644 index 0000000..10312cc --- /dev/null +++ b/xpsimplehelloworld/xpsimplehelloworld.sgml @@ -0,0 +1,140 @@ +<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.2//EN" 'http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd'> + +<!-- Process this file with DocBook tools to generate the output format +(such as manual pages or HTML documents). + +Note that strings like __appmansuffix__, __filemansuffix__, __libmansuffix__, +__miscmansuffix__ etc. have to be replaced first (in theory that's the +job of ENTITIES but some XML tools are highly allergic to such stuff... ;-(). +A quick way to do that is to filter this document via +/usr/bin/sed "s/__appmansuffix__/${MANSUFFIX}/g;s/__filemansuffix__/${FILEMANSUFFIX}/g;s/__libmansuffix__/${LIBMANSUFFIX}/g;s/__miscmansuffix__/${MISCMANSUFFIX}/g" +assuming that env vars like MANSUFFIX etc. have been set to the matching +manual volume numbers. + --> + +<refentry> + <refmeta> + <refentrytitle>xpsimplehelloworld</refentrytitle> + <manvolnum>__appmansuffix__</manvolnum> + </refmeta> + <refnamediv> + <refname>xpsimplehelloworld</refname> + + <refpurpose>"Hello World"-like Xprint sample utility based on plain X11 rendering calls</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>xpsimplehelloworld</command> + + <arg><option>-printer <replaceable>printernname</replaceable></option></arg> + + <arg><option>-v</option></arg> + + <arg><option>-h</option></arg> + + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>DESCRIPTION</title> + + <para><command>xpsimplehelloworld</command> is a sample utility for Xprint, the + printing system for the X Window system. It demonstrates how to send a test page to + the specified printer (or the default printer, if none is specified) using plain X11 + rendering instructions and without using special toolkit support (like one of + the special Xt print shell widget classes + (such as + <citerefentry><refentrytitle>XmPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry> + or + <citerefentry><refentrytitle>XawPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry>)). + </para> + + </refsect1> + + <refsect1> + <title>OPTIONS</title> + + <variablelist> + <varlistentry> + <term><option>-printer <replaceable>printernname</replaceable></option> + </term> + <listitem> + <para>printer to use</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-v</option> + </term> + <listitem> + <para>verbose output</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-h</option> + </term> + <listitem> + <para>print usage</para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1> + <title>ENVIRONMENT</title> + <variablelist> + <varlistentry> + <term><envar>XPSERVERLIST</envar> + </term> + <listitem> + <para> + <envar>${XPSERVERLIST}</envar> must be set, + identifying the available Xprint servers. + See <citerefentry><refentrytitle>Xprint</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry> + for more details. + </para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1> + <title>KNOWN BUGS</title> + <para> + A full list of bugs can be obtained from the Xprint.org bug database (<ulink url="http://xprint.mozdev.org/xprint_bugs.html">http://xprint.mozdev.org/xprint_bugs.html</ulink>). + </para> + </refsect1> + + <refsect1> + <title>SEE ALSO</title> + <para> + <simplelist type="inline"> + <!-- specific references --> + <!-- none --> + + <!-- Xprint general references --> + <member><citerefentry><refentrytitle>Xprint</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>X11</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xplsprinters</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xphelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xpxmhelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xpawhelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xpxthelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> +<!-- + <member><citerefentry><refentrytitle>xpsimplehelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> +--> + <member><citerefentry><refentrytitle>Xserver</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>Xprt</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <!-- ToDO: Add manual pages for the single Xprint DDX implementations (PostScript/PDF/PCL/PCL-MONO/Raster/etc.) --> + <member><citerefentry><refentrytitle>libXp</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>libXprintUtils</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>libXprintAppUtils</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>XmPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>XawPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member>Xprint FAQ (<ulink url="http://xprint.mozdev.org/docs/Xprint_FAQ.html">http://xprint.mozdev.org/docs/Xprint_FAQ.html</ulink>)</member> + <member>Xprint main site (<ulink url="http://xprint.mozdev.org/">http://xprint.mozdev.org/</ulink>)</member> + </simplelist> + </para> + </refsect1> + +</refentry> + + diff --git a/xpxmhelloworld/.cvsignore b/xpxmhelloworld/.cvsignore new file mode 100644 index 0000000..af533f9 --- /dev/null +++ b/xpxmhelloworld/.cvsignore @@ -0,0 +1,4 @@ +.deps +Makefile +Makefile.in +xpxmhelloworld diff --git a/xpxmhelloworld/Makefile.am b/xpxmhelloworld/Makefile.am new file mode 100644 index 0000000..4e84dee --- /dev/null +++ b/xpxmhelloworld/Makefile.am @@ -0,0 +1,33 @@ +# +# Copyright 2005 Red Hat, Inc. +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of Red Hat not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. Red Hat makes no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +bin_PROGRAMS = xpxmhelloworld + +xpxmhelloworld_CFLAGS = $(XPXMHELLOWORLD_CFLAGS) +xpxmhelloworld_LDADD = $(XPXMHELLOWORLD_LIBS) + +xpxmhelloworld_SOURCES = \ + xpxmhelloworld.c + +dist_man1_MANS = \ + xpxmhelloworld.man + +EXTRA_DIST = xpxmhelloworld.sgml diff --git a/xpxmhelloworld/xpxmhelloworld.c b/xpxmhelloworld/xpxmhelloworld.c new file mode 100644 index 0000000..4d1538e --- /dev/null +++ b/xpxmhelloworld/xpxmhelloworld.c @@ -0,0 +1,487 @@ + +/* + * $Xorg: xpxmhelloworld.c,v 1.2 2003/10/19 00:3:26 gisburn Exp $ + * + * xpxmhelloworld - Xprint version of hello world using Motif widgets + * + * +Copyright 2002-2004 Roland Mainz <roland.mainz@nrubsig.org> + +All Rights Reserved. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + * + * Author: Roland Mainz <roland.mainz@nrubsig.org> + */ + +/* + * Referencess: + * http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmPrintShell.htm + * http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmText.htm + * + */ + +#include <X11/IntrinsicP.h> +#include <X11/ShellP.h> +#include <X11/StringDefs.h> +#include <Xm/Xm.h> +#include <Xm/Text.h> +#include <Xm/Print.h> +#include <X11/XprintUtil/xprintutil.h> + +#include <stdlib.h> +#include <stdio.h> + +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Error(x) { printf x ; exit(EXIT_FAILURE); } +#define Log(x) { if(verbose) printf x; } +#define Msg(x) { if(!quiet) printf x; } + +/* Prototypes */ +static int do_hello_world( int argc, char *argv[], const char *printername, + const char *toFile, const char *sample_string ); + +/* Global vars */ +const char *ProgramName; /* program name (from argv[0]) */ +Bool verbose = False; /* verbose output what the program is doing */ +Bool quiet = False; /* be quiet (no output except errors) */ +Bool doPrint = False; /* Do we print on a printer ? */ +Display *pdpy = NULL; /* (Paper) display */ +Screen *pscreen = NULL; /* (Paper) screen (DDX-specific!) */ +XPContext pcontext = None; /* Xprint context */ +void *printtofile_handle = NULL; /* XprintUtil "context" when printing to file */ +Drawable pdrawable = None; /* paper drawable */ + +static +void usage( void ) +{ + fprintf(stderr, "usage: %s [options] string\n", ProgramName); + fprintf(stderr, "-print\tPrint via Xprint instead of displaying on the Xserver\n"); + fprintf(stderr, "-printer printernname\tprinter to use\n"); + fprintf(stderr, "-printfile file\tprint to file instead of printer\n"); + fprintf(stderr, "-v\tverbose output\n"); + fprintf(stderr, "-q\tbe quiet (no output except errors)\n"); + fprintf(stderr, "\n"); + exit(EXIT_FAILURE); +} + +static +void PrintSpoolerCommandResults( Display *pdpy, XPContext pcontext ) +{ + char *scr; + + scr = XpGetOneAttribute(pdpy, pcontext, XPJobAttr, "xp-spooler-command-results"); + if( scr ) + { + if( strlen(scr) > 0 ) + { + const char *msg = XpuCompoundTextToXmb(pdpy, scr); + if( msg ) + { + Msg(("Spooler command returned '%s'.\n", msg)); + XpuFreeXmbString(msg); + } + else + { + Msg(("Spooler command returned '%s' (unconverted).\n", scr)); + } + } + + XFree((void *)scr); + } +} + +int main( int argc, char *argv[] ) +{ + const char *printername = NULL; /* printer to query */ + const char *toFile = NULL; /* output file (instead of printer) */ + XPPrinterList plist; /* list of printers */ + int plist_count; /* number of entries in |plist|-array */ + int i; + int retval; + const char *sample_string; + + ProgramName = argv[0]; + + if( argc < 2 ) + { + usage(); + } + + for( i = 1 ; i < (argc-1) ; i++ ) + { + char *arg = argv[i]; + int len = strlen(arg); + + if (!strncmp("-print", arg, len)) + { + doPrint = True; + } + else if (!strncmp("-printer", arg, len)) + { + if (++i >= argc) + usage(); + printername = argv[i]; + doPrint = True; + } + else if (!strncmp("-printfile", arg, len)) + { + if (++i >= argc) + usage(); + toFile = argv[i]; + doPrint = True; + } + else if (!strncmp("-v", arg, len)) + { + verbose = True; + quiet = False; + } + else if (!strncmp("-q", arg, len)) + { + verbose = False; + quiet = True; + } + else + { + usage(); + } + } + + sample_string = argv[argc-1]; + + if( doPrint ) + { + plist = XpuGetPrinterList(printername, &plist_count); + + if (!plist) { + fprintf(stderr, "%s: no printers found for printer spec \"%s\".\n", + ProgramName, NULLSTR(printername)); + exit(EXIT_FAILURE); + } + + Log(("Using printer '%s'\n", plist[0].name)); + + retval = do_hello_world(argc, argv, plist[0].name, toFile, sample_string); + + XpuFreePrinterList(plist); + } + else + { + Log(("Displaying on framebuffer Xserver\n")); + + retval = do_hello_world(argc, argv, NULL, NULL, sample_string); + } + + return retval; +} + +/* xt_xp_openapplication() - mainly identical to XtOpenApplication() but + * takes a |Display *| and |Screen *| as arguments, too... */ +static +Widget xt_xp_openapplication(XtAppContext *app_context_return, + Display *dpy, + Screen *screen, + String application_name, + String application_class, + WidgetClass widget_class, + int *argc, + String *argv) +{ + Widget toplevel; + Cardinal n; + Arg args[2]; + + XtToolkitInitialize(); + *app_context_return = XtCreateApplicationContext(); + if( *app_context_return == NULL ) + return NULL; + + XtDisplayInitialize(*app_context_return, dpy, + application_name, application_class, + NULL, 0, + argc, argv); + + n = 0; + XtSetArg(args[n], XtNscreen, screen); n++; + toplevel = XtAppCreateShell(application_name, + application_class, + widget_class, + dpy, + args, n); + + return toplevel; +} + +typedef struct +{ + int num_pages; + int curr_page; + + Widget printshell_content; + int num_visible_rows; + XtAppContext appcontext; /* for XtAppSetExitFlag() */ +} MyPrintCallbackData; + + +static +void PrintOnePageCB(Widget pshell, XtPointer context, XtPointer call_data) +{ + MyPrintCallbackData *mpcd = (MyPrintCallbackData *)context; + XmPrintShellCallbackStruct *psp = (XmPrintShellCallbackStruct *)call_data; + + Log(("--> PrintOnePageCB, printing page %d of %d\n", mpcd->curr_page, mpcd->num_pages)); + + mpcd->curr_page++; + + /* Get ready for next page + * Scroll widget to display the next page (except for the first page :) + */ + if (!psp->last_page && mpcd->curr_page > 1) + { + /* XmText allows two solutions to scroll a page down + * - Either scroll num_rows_per_page down (this is XmText-specific) + * or + * - Call the "next-page" action procedure (this works for all widgets + * which support this action proc) + */ +#define USE_ACTION_TO_SCROLL_DOWN 1 +#ifdef USE_ACTION_TO_SCROLL_DOWN + Log(("Scrolling down one page ...\n")); + XtCallActionProc(mpcd->printshell_content, "next-page", NULL, NULL, 0); +#else + Log(("Scrolling down %d rows (=one page) ...\n", mpcd->num_visible_rows)); + XmTextScroll(mpcd->printshell_content, mpcd->num_visible_rows); +#endif /* USE_ACTION_TO_SCROLL_DOWN */ + } + + if (mpcd->curr_page == (int)mpcd->num_pages) + { + Log(("Printing last page.\n")); + psp->last_page = True; + } + + Log(("PrintOnePageCB: done\n")); +} + +static +void PrintStartJobCB(Widget pshell, XtPointer context, XtPointer call_data) +{ + XmPrintShellCallbackStruct *psp = (XmPrintShellCallbackStruct *)call_data; + + Log(("--> PrintStartJobCB\n")); +} + +static +void PrintEndJobCB(Widget pshell, XtPointer context, XtPointer call_data) +{ + MyPrintCallbackData *mpcd = (MyPrintCallbackData *)context; + XmPrintShellCallbackStruct *psp = (XmPrintShellCallbackStruct *)call_data; + + Log(("--> PrintEndJobCB\n")); + + /* We're done with printing, tell |XtAppMainLoop()| that it can exit */ + XtAppSetExitFlag(mpcd->appcontext); +} + +int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile, const char *sample_string ) +{ + XtAppContext app; + Widget toplevel, + shell, + print_shell, + hello; + long dpi_x = 0L, + dpi_y = 0L; + char fontname[256]; /* BUG: is this really big enougth ? */ + XFontStruct *textFont; + XmFontList textFontList; + Cardinal n; + Arg args[10]; + MyPrintCallbackData mpcd; + + if( doPrint ) + { + /* Get printer, either by "name" (foobar) or "name@display" (foobar@gaja:5) */ + if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) + Error(("XpuGetPrinter failure.\n")); + + /* Configure the print context (paper size, title etc.) + * We must do this before creating any Xt widgets - otherwise they will + * make wrong assuptions about fonts, resultions etc. ... + */ + XpuSetJobTitle(pdpy, pcontext, "Simple Xprint XmPrintShell widget demo"); + + /* Configuration done, set the context */ + XpSetContext(pdpy, pcontext); + + /* Get default printer resolution */ + if( XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1 ) + { + fprintf(stderr, "No default resolution for printer '%s'\n", printername); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + + pscreen = XpGetScreenOfContext(pdpy, pcontext); + } + else + { + pdpy = XOpenDisplay(NULL); + if( !pdpy ) + Error(("XOpenDisplay failure.\n")); + + dpi_x = dpi_y = 0L; + + pscreen = XDefaultScreenOfDisplay(pdpy); + } + + toplevel = xt_xp_openapplication(&app, + pdpy, pscreen, + "xpxmprintshelldemo", "XpXmPrintShellDemo", + applicationShellWidgetClass, + &argc, argv); + + if( !toplevel ) + Error(("xt_xp_openapplication failure.\n")); + + if( doPrint ) + { + n = 0; + print_shell = XtCreatePopupShell("myprintshell", + xmPrintShellWidgetClass, + toplevel, args, n); + + /* we're mapping/unmapping at start/end page time */ + XtSetMappedWhenManaged(print_shell, False); + + shell = print_shell; + } + else + { + shell = toplevel; + } + + sprintf(fontname, "-adobe-courier-medium-r-normal--40-*-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); + textFont = XLoadQueryFont(pdpy, fontname); + if( !textFont ) + { + sprintf(fontname, "-*-*-*-*-*-*-*-160-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); + textFont = XLoadQueryFont(pdpy, fontname); + } + if( !textFont ) + Error(("XLoadQueryFont failure.\n")); + textFontList = XmFontListCreate(textFont, XmSTRING_DEFAULT_CHARSET); + + n = 0; + /* Make sure the cursor is off, current Xprt servers do not seem to like + * blinking cursors that much... ;-/ */ + XtSetArg(args[n], XmNcursorPositionVisible, False); n++; + XtSetArg(args[n], XmNvalue, sample_string); n++; + XtSetArg(args[n], XmNfontList, textFontList); n++; + XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; + + hello = XmCreateText(shell, "mytext", args, n); + if( !hello ) + Error(("XmCreateText failure.\n")); + + XtManageChild(hello); + XtRealizeWidget(toplevel); + XtRealizeWidget(shell); + + if( doPrint ) + { + int num_total_rows; + short num_visible_rows; + int num_pages; + + pdpy = XtDisplay(toplevel); + pdrawable = XtWindow(toplevel); + if( !pdpy || !pdrawable ) + Error(("No display.\n")); + + /* Make sure that the Xt machinery is really using the right screen (assertion) */ + if( XpGetScreenOfContext(XtDisplay(toplevel), pcontext) != XtScreen(toplevel) ) + Error(("Widget's screen != print screen. BAD.\n")); + + /* Get number of rows visible per page and the number of total rows + * in the whole text widget... */ + n = 0; + XtSetArg(args[n], XmNrows, &num_visible_rows); n++ ; + XtSetArg(args[n], XmNtotalLines, &num_total_rows); n++ ; + XtGetValues(hello, args, n); + + /* Take away one row to match the one-line overlapping used by the + * "next-page" action proc */ + num_visible_rows -= 1; + + /* Calculate the number of pages */ + num_pages = (num_total_rows+num_visible_rows-1) / num_visible_rows; + Log(("Printing %d pages (num_total_rows=%d, num_visible_rows=%d)...\n", + num_pages, num_total_rows, num_visible_rows)); + + /* Prepare our own context data for the print shell callbacks */ + mpcd.num_pages = num_pages; + mpcd.curr_page = 0; + mpcd.printshell_content = hello; + mpcd.num_visible_rows = num_visible_rows; + mpcd.appcontext = app; + + /* Setup the print shell callbacks... */ + XtAddCallback(print_shell, XmNpageSetupCallback, PrintOnePageCB, (XtPointer)&mpcd); + XtAddCallback(print_shell, XmNstartJobCallback, PrintStartJobCB, NULL); + XtAddCallback(print_shell, XmNendJobCallback, PrintEndJobCB, (XtPointer)&mpcd); + + /* ... and finally start the print job. */ + if( toFile ) + { + printtofile_handle = XpuStartJobToFile(pdpy, pcontext, toFile); + if( !printtofile_handle ) + { + perror("XpuStartJobToFile failure"); + Error(("XpuStartJobToFile failure.")); + } + } + else + { + XpuStartJobToSpooler(pdpy); + } + } + + XtAppMainLoop(app); + + if( doPrint ) + { + if( toFile ) + { + if( XpuWaitForPrintFileChild(printtofile_handle) != XPGetDocFinished ) + { + fprintf(stderr, "%s: Error while printing to file.\n", ProgramName); + } + } + + PrintSpoolerCommandResults(pdpy, pcontext); + + /* We have to use XpDestroyContext() and XtCloseDisplay() instead + * of XpuClosePrinterDisplay() to make libXt happy... */ + if( pcontext != None ) + XpDestroyContext(pdpy, pcontext); + XtCloseDisplay(pdpy); + } + + return EXIT_SUCCESS; +} + diff --git a/xpxmhelloworld/xpxmhelloworld.man b/xpxmhelloworld/xpxmhelloworld.man new file mode 100644 index 0000000..768d413 --- /dev/null +++ b/xpxmhelloworld/xpxmhelloworld.man @@ -0,0 +1,43 @@ +.\" -*- coding: us-ascii -*- +.TH xpxmhelloworld __appmansuffix__ "8 October 2004" +.SH NAME +xpxmhelloworld \- "Hello World"-like Xprint sample utility based on the Motif2 toolkit +.SH SYNOPSIS +.ad l +\fBxpxmhelloworld\fR \kx +.if (\nxu > (\n(.lu / 2)) .nr x (\n(.lu / 5) +'in \n(.iu+\nxu +[\fB\-print\fR] [\fB\-printer \fBprinternname\fR\fR] [\fB\-v\fR] [\fB\-h\fR] \fBstring\fR \&... +'in \n(.iu-\nxu +.ad b +.SH DESCRIPTION +xpxmhelloworld is a sample utility for Xprint, the +printing system for the X Window system. It demonstrates how to send a test page to +the specified printer (or the default printer, if none is specified) based on +the Motif2 toolkit using the +\fBXmPrintShell\fR(__libmansuffix__) +widget class. +.SH OPTIONS +.TP +\fB\-print\fR +Print (default is to display on the video Xserver) +.TP +\fB\-printer \fIprinternname\fB\fR +printer to use +.TP +\fB\-v\fR +verbose output +.TP +\fB\-h\fR +print usage +.SH ENVIRONMENT +.TP +\fBXPSERVERLIST\fR +\fB${XPSERVERLIST}\fR must be set, +identifying the available Xprint servers. +See \fBXprint\fR(__miscmansuffix__) +for more details. +.SH "KNOWN BUGS" +A full list of bugs can be obtained from the Xprint.org bug database (http://xprint.mozdev.org/xprint_bugs.html). +.SH "SEE ALSO" +http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmPrintShell.htm, http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmText.htm, \fBXprint\fR(__miscmansuffix__), \fBX11\fR(__miscmansuffix__), \fBxplsprinters\fR(__appmansuffix__), \fBxphelloworld\fR(__appmansuffix__), \fBxpawhelloworld\fR(__appmansuffix__), \fBxpxthelloworld\fR(__appmansuffix__), \fBxpsimplehelloworld\fR(__appmansuffix__), \fBXserver\fR(__appmansuffix__), \fBXprt\fR(__appmansuffix__), \fBlibXp\fR(__libmansuffix__), \fBlibXprintUtils\fR(__libmansuffix__), \fBlibXprintAppUtils\fR(__libmansuffix__), \fBXmPrintShell\fR(__libmansuffix__), \fBXawPrintShell\fR(__libmansuffix__), Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html), Xprint main site (http://xprint.mozdev.org/) diff --git a/xpxmhelloworld/xpxmhelloworld.sgml b/xpxmhelloworld/xpxmhelloworld.sgml new file mode 100644 index 0000000..e53c521 --- /dev/null +++ b/xpxmhelloworld/xpxmhelloworld.sgml @@ -0,0 +1,146 @@ +<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.2//EN" 'http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd'> + +<!-- Process this file with DocBook tools to generate the output format +(such as manual pages or HTML documents). + +Note that strings like __appmansuffix__, __filemansuffix__, __libmansuffix__, +__miscmansuffix__ etc. have to be replaced first (in theory that's the +job of ENTITIES but some XML tools are highly allergic to such stuff... ;-(). +A quick way to do that is to filter this document via +/usr/bin/sed "s/__appmansuffix__/${MANSUFFIX}/g;s/__filemansuffix__/${FILEMANSUFFIX}/g;s/__libmansuffix__/${LIBMANSUFFIX}/g;s/__miscmansuffix__/${MISCMANSUFFIX}/g" +assuming that env vars like MANSUFFIX etc. have been set to the matching +manual volume numbers. + --> + +<refentry> + <refmeta> + <refentrytitle>xpxmhelloworld</refentrytitle> + <manvolnum>__appmansuffix__</manvolnum> + </refmeta> + <refnamediv> + <refname>xpxmhelloworld</refname> + + <refpurpose>"Hello World"-like Xprint sample utility based on the Motif2 toolkit</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>xpxmhelloworld</command> + + <arg><option>-print</option></arg> + + <arg><option>-printer <replaceable>printernname</replaceable></option></arg> + + <arg><option>-v</option></arg> + + <arg><option>-h</option></arg> + + <arg choice="plain" rep="repeat"><replaceable>string</replaceable></arg> + + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>DESCRIPTION</title> + + <para><command>xpxmhelloworld</command> is a sample utility for Xprint, the + printing system for the X Window system. It demonstrates how to send a test page to + the specified printer (or the default printer, if none is specified) based on + the Motif2 toolkit using the + <citerefentry><refentrytitle>XmPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry> + widget class. + </para> + </refsect1> + + <refsect1> + <title>OPTIONS</title> + + <variablelist> + <varlistentry> + <term><option>-print</option> + </term> + <listitem> + <para>Print (default is to display on the video Xserver)</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-printer <replaceable>printernname</replaceable></option> + </term> + <listitem> + <para>printer to use</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-v</option> + </term> + <listitem> + <para>verbose output</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-h</option> + </term> + <listitem> + <para>print usage</para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1> + <title>ENVIRONMENT</title> + <variablelist> + <varlistentry> + <term><envar>XPSERVERLIST</envar> + </term> + <listitem> + <para> + <envar>${XPSERVERLIST}</envar> must be set, + identifying the available Xprint servers. + See <citerefentry><refentrytitle>Xprint</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry> + for more details. + </para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1> + <title>KNOWN BUGS</title> + <para> + A full list of bugs can be obtained from the Xprint.org bug database (<ulink url="http://xprint.mozdev.org/xprint_bugs.html">http://xprint.mozdev.org/xprint_bugs.html</ulink>). + </para> + </refsect1> + + <refsect1> + <title>SEE ALSO</title> + <para> + <simplelist type="inline"> + <!-- specific references --> + <member><ulink url="http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmPrintShell.htm">http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmPrintShell.htm</ulink></member> + <member><ulink url="http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmText.htm">http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmText.htm</ulink></member> + + <!-- Xprint general references --> + <member><citerefentry><refentrytitle>Xprint</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>X11</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xplsprinters</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xphelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> +<!-- + <member><citerefentry><refentrytitle>xpxmhelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> +--> + <member><citerefentry><refentrytitle>xpawhelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xpxthelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xpsimplehelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>Xserver</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>Xprt</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <!-- ToDO: Add manual pages for the single Xprint DDX implementations (PostScript/PDF/PCL/PCL-MONO/Raster/etc.) --> + <member><citerefentry><refentrytitle>libXp</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>libXprintUtils</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>libXprintAppUtils</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>XmPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>XawPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member>Xprint FAQ (<ulink url="http://xprint.mozdev.org/docs/Xprint_FAQ.html">http://xprint.mozdev.org/docs/Xprint_FAQ.html</ulink>)</member> + <member>Xprint main site (<ulink url="http://xprint.mozdev.org/">http://xprint.mozdev.org/</ulink>)</member> + </simplelist> + </para> + </refsect1> + +</refentry> diff --git a/xpxthelloworld/.cvsignore b/xpxthelloworld/.cvsignore new file mode 100644 index 0000000..55129f0 --- /dev/null +++ b/xpxthelloworld/.cvsignore @@ -0,0 +1,4 @@ +.deps +Makefile +Makefile.in +xpxthelloworld diff --git a/xpxthelloworld/Makefile.am b/xpxthelloworld/Makefile.am new file mode 100644 index 0000000..9f0a4a7 --- /dev/null +++ b/xpxthelloworld/Makefile.am @@ -0,0 +1,33 @@ +# +# Copyright 2005 Red Hat, Inc. +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of Red Hat not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. Red Hat makes no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +bin_PROGRAMS = xpxthelloworld + +xpxthelloworld_CFLAGS = $(XPXTHELLOWORLD_CFLAGS) +xpxthelloworld_LDADD = $(XPXTHELLOWORLD_LIBS) + +xpxthelloworld_SOURCES = \ + xpxthelloworld.c + +dist_man1_MANS = \ + xpxthelloworld.man + +EXTRA_DIST = xpxthelloworld.sgml diff --git a/xpxthelloworld/xpxthelloworld.c b/xpxthelloworld/xpxthelloworld.c new file mode 100644 index 0000000..929f655 --- /dev/null +++ b/xpxthelloworld/xpxthelloworld.c @@ -0,0 +1,451 @@ + +/* + * $Xorg: xpxthelloworld.c,v 1.1 2002/07/28 08:44:26 gisburn Exp $ + * + * xpxthelloworld - Xprint version of hello world using Athena widgets + * + * +Copyright 2002-2004 Roland Mainz <roland.mainz@nrubsig.org> + +All Rights Reserved. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + * + * Author: Roland Mainz <roland.mainz@nrubsig.org> + */ + +#include <X11/IntrinsicP.h> +#include <X11/ShellP.h> +#include <X11/StringDefs.h> +#include <X11/Xaw/Label.h> + +#include <X11/XprintUtil/xprintutil.h> + +#include <stdlib.h> +#include <stdio.h> + +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Error(x) { printf x ; exit(EXIT_FAILURE); } +#define Log(x) { if(verbose) printf x; } +#define Msg(x) { if(!quiet) printf x; } + +/* Local prototypes */ +static void PrintSpoolerCommandResults(Display *pdpy, XPContext pcontext); +static void redisplayWidget(Widget widget); +static void MyAppMainLoop(XtAppContext app, Widget printwidget); +static int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile ); + +/* Global vars */ +const char *ProgramName; /* program name (from argv[0]) */ +Bool verbose = False; /* verbose output what the program is doing */ +Bool quiet = False; /* be quiet (no output except errors) */ +Bool done = False; /* Done with printing ? */ +Bool doPrint = False; /* Do we print on a printer ? */ +int xp_eventbase, /* XpExtension event base */ + xp_errorbase; /* XpExtension error base */ +Display *pdpy = NULL; /* (Paper) display */ +Screen *pscreen = NULL; /* (Paper) screen (DDX-specific!) */ +XPContext pcontext = None; /* Xprint context */ +void *printtofile_handle = NULL; /* XprintUtil "context" when printing to file */ +Drawable pdrawable = None; /* paper drawable */ +int numpages = 0; /* pages being printed */ + + +static +void PrintSpoolerCommandResults( Display *pdpy, XPContext pcontext ) +{ + char *scr; + + scr = XpGetOneAttribute(pdpy, pcontext, XPJobAttr, "xp-spooler-command-results"); + if( scr ) + { + if( strlen(scr) > 0 ) + { + const char *msg = XpuCompoundTextToXmb(pdpy, scr); + if( msg ) + { + Msg(("Spooler command returned '%s'.\n", msg)); + XpuFreeXmbString(msg); + } + else + { + Msg(("Spooler command returned '%s' (unconverted).\n", scr)); + } + } + + XFree((void *)scr); + } +} + +static +void MyAppMainLoop(XtAppContext app, Widget printwidget) +{ + XEvent xevent; + + /* process events. */ + while( !done ) + { + XtAppNextEvent(app, &xevent); + + if( XtDispatchEvent(&xevent) == False ) + { + /* XpExtension event ? */ + if( xevent.type == xp_eventbase+XPPrintNotify ) + { + XPPrintEvent *pev = (XPPrintEvent *)&xevent; + + Log(("--> got XPPrintEvent\n")); + + switch( pev->detail ) + { + case XPStartJobNotify: + Log(("Starting page...\n")); + XpStartPage(pdpy, pdrawable); + break; + case XPEndJobNotify: + /* Job done... */ + done = True; + break; + case XPStartPageNotify: + Log(("Rendering page...\n")); + redisplayWidget(printwidget); + + Log(("Page end reached.\n")); + XpEndPage(pdpy); + break; + case XPEndPageNotify: + /* next page or exit */ + numpages++; + + if( numpages >= 1 ) + { + Log(("Finishing job...\n")); + XpEndJob(pdpy); + } + break; + default: + Log(("--> other XPPrintEvent event\n")); + break; + } + } + else + { + Log(("--> other event\n")); + } + } + } +} + +/* Code from the OpenMotif sources (XmRedisplayWidget) */ +static +void redisplayWidget(Widget widget) +{ + XExposeEvent xev ; + Region region ; + + xev.type = Expose ; + /* is this better than 0 ? shouldn't make much difference + * unless the expose method is very tricky... */ + xev.serial = LastKnownRequestProcessed(XtDisplay(widget)) ; + xev.send_event = False ; + xev.display = XtDisplay(widget); + xev.window = XtWindowOfObject(widget); /* work with gadget too */ + xev.x = 0 ; + xev.y = 0 ; + xev.width = widget->core.width ; + xev.height = widget->core.height ; + xev.count = 0 ; + + region = XCreateRegion(); + XtAddExposureToRegion((XEvent*)&xev, region); + + if (widget->core.widget_class->core_class.expose) + (*(widget->core.widget_class->core_class.expose)) + (widget, (XEvent*)&xev, region); + + XDestroyRegion(region); +} + +static +void usage( void ) +{ + fprintf (stderr, "usage: %s [options]\n", ProgramName); + fprintf (stderr, "-print\tPrint via Xprint instead of displaying on the Xserver\n"); + fprintf (stderr, "-printer printernname\tprinter to use\n"); + fprintf (stderr, "-printfile file\tprint to file instead of printer\n"); + fprintf (stderr, "-v\tverbose output\n"); + fprintf (stderr, "-q\tbe quiet (no output except errors)\n"); + fprintf (stderr, "\n"); + exit(EXIT_FAILURE); +} + +int main( int argc, char *argv[] ) +{ + const char *printername = NULL; /* printer to query */ + const char *toFile = NULL; /* output file (instead of printer) */ + XPPrinterList plist; /* list of printers */ + int plist_count; /* number of entries in |plist|-array */ + int i; + int retval; + + ProgramName = argv[0]; + + for( i = 1 ; i < argc ; i++ ) + { + char *arg = argv[i]; + int len = strlen(arg); + + if (!strncmp("-print", arg, len)) + { + doPrint = True; + } + else if (!strncmp("-printer", arg, len)) + { + if (++i >= argc) + usage(); + printername = argv[i]; + doPrint = True; + } + else if (!strncmp("-printfile", arg, len)) + { + if (++i >= argc) + usage(); + toFile = argv[i]; + doPrint = True; + } + else if (!strncmp("-v", arg, len)) + { + verbose = True; + quiet = False; + } + else if (!strncmp("-q", arg, len)) + { + verbose = False; + quiet = True; + } + else + { + usage(); + } + } + + if( doPrint ) + { + plist = XpuGetPrinterList(printername, &plist_count); + + if (!plist) { + fprintf(stderr, "%s: no printers found for printer spec \"%s\".\n", + ProgramName, NULLSTR(printername)); + exit(EXIT_FAILURE); + } + + Log(("Using printer '%s'\n", plist[0].name)); + + retval = do_hello_world(argc, argv, plist[0].name, toFile); + + XpuFreePrinterList(plist); + } + else + { + Log(("Displaying on framebuffer Xserver\n")); + + retval = do_hello_world(argc, argv, NULL, NULL); + } + + return(retval); +} + +/* xt_xp_openapplication() - mainly identical to XtOpenApplication() but + * takes a |Display *| and |Screen *| as arguments, too... */ +static +Widget xt_xp_openapplication(XtAppContext *app_context_return, + Display *dpy, + Screen *screen, + String application_name, + String application_class, + WidgetClass widget_class, + int *argc, + String *argv) +{ + Widget toplevel; + Cardinal n; + Arg args[2]; + + XtToolkitInitialize(); + *app_context_return = XtCreateApplicationContext(); + if( *app_context_return == NULL ) + return NULL; + + XtDisplayInitialize(*app_context_return, dpy, + application_name, application_class, + NULL, 0, + argc, argv); + + n = 0; + XtSetArg(args[n], XtNscreen, screen); n++; + toplevel = XtAppCreateShell(application_name, + application_class, + widget_class, + dpy, + args, n); + + return toplevel; +} + +int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile ) +{ + XtAppContext app; + Widget toplevel, + hello; + long dpi_x = 0L, + dpi_y = 0L; + char fontname[256]; /* BUG: is this really big enougth ? */ + XFontStruct *labelFont; + Cardinal n; + Arg args[10]; + + if( doPrint ) + { + /* Get printer, either by "name" (foobar) or "name@display" (foobar@gaja:5) */ + if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) + Error(("XpuGetPrinter failure.\n")); + + if( XpQueryExtension(pdpy, &xp_eventbase, &xp_errorbase) == False ) + Error(("XpQueryExtension failure.\n")); + + XpSelectInput(pdpy, pcontext, XPPrintMask); + + /* Configure the print context (paper size, title etc.) + * We must do this before creating any Xt widgets - otherwise they will + * make wrong assuptions about fonts, resultions etc. ... + */ + XpuSetJobTitle(pdpy, pcontext, "Simple Xprint Athena widget demo"); + + /* Configuration done, set the context */ + XpSetContext(pdpy, pcontext); + + /* Get default printer resolution */ + if( XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1 ) + { + fprintf(stderr, "No default resolution for printer '%s'\n", printername); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + + pscreen = XpGetScreenOfContext(pdpy, pcontext); + } + else + { + pdpy = XOpenDisplay(NULL); + if( !pdpy ) + Error(("XOpenDisplay failure.\n")); + + dpi_x = dpi_y = 0L; + + pscreen = XDefaultScreenOfDisplay(pdpy); + } + + toplevel = xt_xp_openapplication(&app, + pdpy, pscreen, + "xpxtawhenademo", "XpXtAthenaDemo", + applicationShellWidgetClass, + &argc, argv); + + if( !toplevel ) + Error(("xt_xp_openapplication failure.\n")); + + sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); + labelFont = XLoadQueryFont(pdpy, fontname); + if( !labelFont ) + Error(("XLoadQueryFont failure.\n")); + + n = 0; + XtSetArg(args[n], XtNlabel, "Hello world\n" + "(Xprint/Athena widget version)"); n++; + XtSetArg(args[n], XtNfont, labelFont); n++; + hello = XtCreateManagedWidget( + "hello", /* arbitrary widget name */ + labelWidgetClass, /* widget class from Label.h */ + toplevel, /* parent widget*/ + args, /* argument list */ + n /* arg list size */ + ); + if( !hello ) + Error(("XtCreateManagedWidget failure.\n")); + + XtRealizeWidget(toplevel); + + if( doPrint ) + { + unsigned short pwidth, pheight; + XRectangle pagerect; + + pdpy = XtDisplay(toplevel); + pdrawable = XtWindow(toplevel); + if( !pdpy || !pdrawable ) + Error(("No display.\n")); + + /* Make sure that the Xt machinery is really using the right screen (assertion) ... */ + if( XpGetScreenOfContext(XtDisplay(toplevel), pcontext) != XtScreen(toplevel) ) + Error(("Widget's screen != print screen. BAD.\n")); + + /* Get the page dimensions and resize the widget based on that info ... */ + XpGetPageDimensions(pdpy, pcontext, &pwidth, &pheight, &pagerect); + XMoveResizeWindow(pdpy, pdrawable, pagerect.x, pagerect.y, pagerect.width, pagerect.height); + + /* ... and then start the print job. */ + if( toFile ) + { + printtofile_handle = XpuStartJobToFile(pdpy, pcontext, toFile); + if( !printtofile_handle ) + { + perror("XpuStartJobToFile failure"); + Error(("XpuStartJobToFile failure.")); + } + } + else + { + XpuStartJobToSpooler(pdpy); + } + + numpages = 0; + } + + MyAppMainLoop(app, toplevel); + + if( doPrint ) + { + if( toFile ) + { + if( XpuWaitForPrintFileChild(printtofile_handle) != XPGetDocFinished ) + { + fprintf(stderr, "%s: Error while printing to file.\n", ProgramName); + } + } + + PrintSpoolerCommandResults(pdpy, pcontext); + + /* We have to use XpDestroyContext() and XtCloseDisplay() instead + * of XpuClosePrinterDisplay() to make libXt happy... */ + if( pcontext != None ) + XpDestroyContext(pdpy, pcontext); + XtCloseDisplay(pdpy); + } + + return EXIT_SUCCESS; +} + diff --git a/xpxthelloworld/xpxthelloworld.man b/xpxthelloworld/xpxthelloworld.man new file mode 100644 index 0000000..cc5b6e8 --- /dev/null +++ b/xpxthelloworld/xpxthelloworld.man @@ -0,0 +1,45 @@ +.\" -*- coding: us-ascii -*- +.TH xpxthelloworld __appmansuffix__ "8 October 2004" +.SH NAME +xpxthelloworld \- "Hello World"-like Xprint sample utility based on the Xt toolkit +.SH SYNOPSIS +.ad l +\fBxpxthelloworld\fR \kx +.if (\nxu > (\n(.lu / 2)) .nr x (\n(.lu / 5) +'in \n(.iu+\nxu +[\fB\-print\fR] [\fB\-printer \fBprinternname\fR\fR] [\fB\-v\fR] [\fB\-h\fR] +'in \n(.iu-\nxu +.ad b +.SH DESCRIPTION +xpxthelloworld is a sample utility for Xprint, the +printing system for the X Window system. It demonstrates how to send a test page to +the specified printer (or the default printer, if none is specified) based on +the Xt toolkit without using one of the special print shell widget classes +(such as +\fBXmPrintShell\fR(__libmansuffix__) +or +\fBXawPrintShell\fR(__libmansuffix__)). +.SH OPTIONS +.TP +\fB\-print\fR +Print (default is to display on the video Xserver) +.TP +\fB\-printer \fIprinternname\fB\fR +printer to use +.TP +\fB\-v\fR +verbose output +.TP +\fB\-h\fR +print usage +.SH ENVIRONMENT +.TP +\fBXPSERVERLIST\fR +\fB${XPSERVERLIST}\fR must be set, +identifying the available Xprint servers. +See \fBXprint\fR(__miscmansuffix__) +for more details. +.SH "KNOWN BUGS" +A full list of bugs can be obtained from the Xprint.org bug database (http://xprint.mozdev.org/xprint_bugs.html). +.SH "SEE ALSO" +\fBXprint\fR(__miscmansuffix__), \fBX11\fR(__miscmansuffix__), \fBxplsprinters\fR(__appmansuffix__), \fBxphelloworld\fR(__appmansuffix__), \fBxpxmhelloworld\fR(__appmansuffix__), \fBxpawhelloworld\fR(__appmansuffix__), \fBxpsimplehelloworld\fR(__appmansuffix__), \fBXserver\fR(__appmansuffix__), \fBXprt\fR(__appmansuffix__), \fBlibXp\fR(__libmansuffix__), \fBlibXprintUtils\fR(__libmansuffix__), \fBlibXprintAppUtils\fR(__libmansuffix__), \fBXmPrintShell\fR(__libmansuffix__), \fBXawPrintShell\fR(__libmansuffix__), Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html), Xprint main site (http://xprint.mozdev.org/) diff --git a/xpxthelloworld/xpxthelloworld.sgml b/xpxthelloworld/xpxthelloworld.sgml new file mode 100644 index 0000000..6ac81ab --- /dev/null +++ b/xpxthelloworld/xpxthelloworld.sgml @@ -0,0 +1,148 @@ +<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.2//EN" 'http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd'> + +<!-- Process this file with DocBook tools to generate the output format +(such as manual pages or HTML documents). + +Note that strings like __appmansuffix__, __filemansuffix__, __libmansuffix__, +__miscmansuffix__ etc. have to be replaced first (in theory that's the +job of ENTITIES but some XML tools are highly allergic to such stuff... ;-(). +A quick way to do that is to filter this document via +/usr/bin/sed "s/__appmansuffix__/${MANSUFFIX}/g;s/__filemansuffix__/${FILEMANSUFFIX}/g;s/__libmansuffix__/${LIBMANSUFFIX}/g;s/__miscmansuffix__/${MISCMANSUFFIX}/g" +assuming that env vars like MANSUFFIX etc. have been set to the matching +manual volume numbers. + --> + +<refentry> + <refmeta> + <refentrytitle>xpxthelloworld</refentrytitle> + <manvolnum>__appmansuffix__</manvolnum> + </refmeta> + <refnamediv> + <refname>xpxthelloworld</refname> + + <refpurpose>"Hello World"-like Xprint sample utility based on the Xt toolkit</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>xpxthelloworld</command> + + <arg><option>-print</option></arg> + + <arg><option>-printer <replaceable>printernname</replaceable></option></arg> + + <arg><option>-v</option></arg> + + <arg><option>-h</option></arg> + + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>DESCRIPTION</title> + + <para><command>xpxthelloworld</command> is a sample utility for Xprint, the + printing system for the X Window system. It demonstrates how to send a test page to + the specified printer (or the default printer, if none is specified) based on + the Xt toolkit without using one of the special print shell widget classes + (such as + <citerefentry><refentrytitle>XmPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry> + or + <citerefentry><refentrytitle>XawPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry>). + </para> + + </refsect1> + + <refsect1> + <title>OPTIONS</title> + + <variablelist> + <varlistentry> + <term><option>-print</option> + </term> + <listitem> + <para>Print (default is to display on the video Xserver)</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-printer <replaceable>printernname</replaceable></option> + </term> + <listitem> + <para>printer to use</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-v</option> + </term> + <listitem> + <para>verbose output</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-h</option> + </term> + <listitem> + <para>print usage</para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1> + <title>ENVIRONMENT</title> + <variablelist> + <varlistentry> + <term><envar>XPSERVERLIST</envar> + </term> + <listitem> + <para> + <envar>${XPSERVERLIST}</envar> must be set, + identifying the available Xprint servers. + See <citerefentry><refentrytitle>Xprint</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry> + for more details. + </para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1> + <title>KNOWN BUGS</title> + <para> + A full list of bugs can be obtained from the Xprint.org bug database (<ulink url="http://xprint.mozdev.org/xprint_bugs.html">http://xprint.mozdev.org/xprint_bugs.html</ulink>). + </para> + </refsect1> + + <refsect1> + <title>SEE ALSO</title> + <para> + <simplelist type="inline"> + <!-- specific references --> + <!-- none --> + + <!-- Xprint general references --> + <member><citerefentry><refentrytitle>Xprint</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>X11</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xplsprinters</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xphelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xpxmhelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>xpawhelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> +<!-- + <member><citerefentry><refentrytitle>xpxthelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> +--> + <member><citerefentry><refentrytitle>xpsimplehelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>Xserver</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>Xprt</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member> + <!-- ToDO: Add manual pages for the single Xprint DDX implementations (PostScript/PDF/PCL/PCL-MONO/Raster/etc.) --> + <member><citerefentry><refentrytitle>libXp</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>libXprintUtils</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>libXprintAppUtils</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>XmPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member><citerefentry><refentrytitle>XawPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member> + <member>Xprint FAQ (<ulink url="http://xprint.mozdev.org/docs/Xprint_FAQ.html">http://xprint.mozdev.org/docs/Xprint_FAQ.html</ulink>)</member> + <member>Xprint main site (<ulink url="http://xprint.mozdev.org/">http://xprint.mozdev.org/</ulink>)</member> + </simplelist> + </para> + </refsect1> + +</refentry> + + |