moving printing from gfx to widget part 2. bug 326149. r=vlad

This commit is contained in:
pavlov%pavlov.net 2006-02-10 20:44:48 +00:00
Родитель 6a80da6c47
Коммит 7211d869d3
14 изменённых файлов: 75 добавлений и 2412 удалений

Просмотреть файл

@ -72,8 +72,6 @@ ifdef MOZ_ENABLE_XPRINT
REQUIRES += xprintutil
endif
CSRCS = nsPrintdGTK.c
# Code shared between GTK+, Xlib and Xprint gfx modules
X11SHARED_LCPPSRCS = \
nsAntiAliasedGlyph.cpp \
@ -93,15 +91,12 @@ endif
CPPSRCS = \
nsDeviceContextGTK.cpp \
nsDeviceContextSpecFactoryG.cpp \
nsDeviceContextSpecG.cpp \
nsDrawingSurfaceGTK.cpp \
nsGfxFactoryGTK.cpp \
nsGraphicsStateGTK.cpp \
nsImageGTK.cpp \
nsGCCache.cpp \
nsRenderingContextGTK.cpp \
nsPrintOptionsGTK.cpp \
nsFontMetricsUtils.cpp \
$(NULL)

Просмотреть файл

@ -1,94 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDeviceContextSpecFactoryG.h"
#include "nsDeviceContextSpecG.h"
#include "nsGfxCIID.h"
#include "plstr.h"
/** -------------------------------------------------------
* Constructor
* @update dc 2/16/98
*/
nsDeviceContextSpecFactoryGTK :: nsDeviceContextSpecFactoryGTK()
{
}
/** -------------------------------------------------------
* Destructor
* @update dc 2/16/98
*/
nsDeviceContextSpecFactoryGTK :: ~nsDeviceContextSpecFactoryGTK()
{
}
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryGTK, nsIDeviceContextSpecFactory)
/** -------------------------------------------------------
* Initialize the device context spec factory
* @update dc 2/16/98
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: Init(void)
{
return NS_OK;
}
/** -------------------------------------------------------
* Get a device context specification
* @update dc 2/16/98
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview)
{
nsresult rv;
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
if (NS_SUCCEEDED(rv))
{
rv = ((nsDeviceContextSpecGTK *)devSpec.get())->Init(aPrintSettings, aIsPrintPreview);
if (NS_SUCCEEDED(rv))
{
aNewSpec = devSpec;
NS_ADDREF(aNewSpec);
}
}
return rv;
}

Просмотреть файл

@ -1,61 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextSpecFactoryG_h___
#define nsDeviceContextSpecFactoryG_h___
#include "nsIDeviceContextSpecFactory.h"
#include "nsIDeviceContextSpec.h"
class nsDeviceContextSpecFactoryGTK : public nsIDeviceContextSpecFactory
{
public:
nsDeviceContextSpecFactoryGTK();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(void);
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview);
protected:
virtual ~nsDeviceContextSpecFactoryGTK();
};
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,139 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextSpecGTK_h___
#define nsDeviceContextSpecGTK_h___
#include "nsIDeviceContextSpec.h"
#include "nsIPrintSettings.h"
#include "nsIPrintOptions.h"
#include "nsVoidArray.h"
#include "nsCOMPtr.h"
#ifdef USE_POSTSCRIPT
#include "nsIDeviceContextSpecPS.h"
#endif /* USE_POSTSCRIPT */
#ifdef USE_XPRINT
#include "nsIDeviceContextSpecXPrint.h"
#endif /* USE_XPRINT */
#include "nsCRT.h" /* should be <limits.h>? */
#define NS_PORTRAIT 0
#define NS_LANDSCAPE 1
typedef enum
{
pmInvalid = 0,
pmXprint,
pmPostScript
} PrintMethod;
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec
#ifdef USE_POSTSCRIPT
, public nsIDeviceContextSpecPS
#endif /* USE_POSTSCRIPT */
#ifdef USE_XPRINT
, public nsIDeviceContextSpecXp
#endif /* USE_XPRINT */
{
public:
nsDeviceContextSpecGTK();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview);
NS_IMETHOD ClosePrintManager();
NS_IMETHOD GetToPrinter(PRBool &aToPrinter);
NS_IMETHOD GetIsPrintPreview(PRBool &aIsPPreview);
NS_IMETHOD GetPrinterName ( const char **aPrinter );
NS_IMETHOD GetCopies ( int &aCopies );
NS_IMETHOD GetFirstPageFirst(PRBool &aFpf);
NS_IMETHOD GetGrayscale(PRBool &aGrayscale);
NS_IMETHOD GetTopMargin(float &value);
NS_IMETHOD GetBottomMargin(float &value);
NS_IMETHOD GetLeftMargin(float &value);
NS_IMETHOD GetRightMargin(float &value);
NS_IMETHOD GetCommand(const char **aCommand);
NS_IMETHOD GetPath (const char **aPath);
NS_IMETHOD GetLandscape (PRBool &aLandscape);
NS_IMETHOD GetUserCancelled(PRBool &aCancel);
NS_IMETHOD GetPrintMethod(PrintMethod &aMethod);
static nsresult GetPrintMethod(const char *aPrinter, PrintMethod &aMethod);
NS_IMETHOD GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight);
NS_IMETHOD GetPaperName(const char **aPaperName);
NS_IMETHOD GetPlexName(const char **aPlexName);
NS_IMETHOD GetResolutionName(const char **aResolutionName);
NS_IMETHOD GetColorspace(const char **aColorspace);
NS_IMETHOD GetDownloadFonts(PRBool &aDownloadFonts);
virtual ~nsDeviceContextSpecGTK();
protected:
nsCOMPtr<nsIPrintSettings> mPrintSettings;
PRPackedBool mToPrinter : 1; /* If PR_TRUE, print to printer */
PRPackedBool mIsPPreview : 1; /* If PR_TRUE, is print preview */
PRPackedBool mFpf : 1; /* If PR_TRUE, first page first */
PRPackedBool mGrayscale : 1; /* If PR_TRUE, print grayscale */
PRPackedBool mDownloadFonts : 1; /* If PR_TRUE, download fonts to printer */
PRPackedBool mCancel : 1; /* If PR_TRUE, user cancelled */
int mOrientation; /* Orientation e.g. Portrait */
char mCommand[PATH_MAX]; /* Print command e.g., lpr */
char mPath[PATH_MAX]; /* If toPrinter = PR_FALSE, dest file */
char mPrinter[256]; /* Printer name */
char mPaperName[256]; /* Printer name */
char mPlexName[256]; /* Plex mode name */
char mResolutionName[256];/* Resolution name */
char mColorspace[256]; /* Colorspace */
int mCopies; /* number of copies */
float mLeft; /* left margin */
float mRight; /* right margin */
float mTop; /* top margin */
float mBottom; /* bottom margin */
};
//-------------------------------------------------------------------------
// Printer Enumerator
//-------------------------------------------------------------------------
class nsPrinterEnumeratorGTK : public nsIPrinterEnumerator
{
public:
nsPrinterEnumeratorGTK();
NS_DECL_ISUPPORTS
NS_DECL_NSIPRINTERENUMERATOR
};
#endif /* !nsDeviceContextSpecGTK_h___ */

Просмотреть файл

@ -46,14 +46,9 @@
#include "nsBlender.h"
#include "nsRenderingContextGTK.h"
#include "nsDeviceContextGTK.h"
// aka nsDeviceContextSpecGTK.h
#include "nsDeviceContextSpecG.h"
// aka nsDeviceContextSpecFactoryGTK.h
#include "nsDeviceContextSpecFactoryG.h"
#include "nsScriptableRegion.h"
#include "nsDeviceContextGTK.h"
#include "nsImageGTK.h"
#include "nsPrintOptionsGTK.h"
#include "nsFontList.h"
#include "nsRegionGTK.h"
#include "nsGCCache.h"
@ -67,7 +62,6 @@
#include "nsFontMetricsGTK.h"
#endif
#include "nsFontMetricsUtils.h"
#include "nsPrintSession.h"
#include "gfxImageFrame.h"
#ifdef MOZ_ENABLE_FREETYPE2
#include "nsFT2FontCatalog.h"
@ -81,12 +75,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsGTK, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
#ifdef MOZ_ENABLE_FREETYPE2
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFT2FontCatalog)
@ -264,21 +254,6 @@ static const nsModuleComponentInfo components[] =
// "@mozilla.org/gfx/blender;1",
"@mozilla.org/gfx/blender;1",
nsBlenderConstructor },
{ "Gtk Device Context Spec",
NS_DEVICE_CONTEXT_SPEC_CID,
// "@mozilla.org/gfx/device_context_spec/gtk;1",
"@mozilla.org/gfx/devicecontextspec;1",
nsDeviceContextSpecGTKConstructor },
{ "Gtk Device Context Spec Factory",
NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
// "@mozilla.org/gfx/device_context_spec_factory/gtk;1",
"@mozilla.org/gfx/devicecontextspecfactory;1",
nsDeviceContextSpecFactoryGTKConstructor },
{ "PrintSettings Service",
NS_PRINTSETTINGSSERVICE_CID,
// "@mozilla.org/gfx/printsettings-service;1",
"@mozilla.org/gfx/printsettings-service;1",
nsPrintOptionsGTKConstructor },
{ "GTK Font Enumerator",
NS_FONT_ENUMERATOR_CID,
// "@mozilla.org/gfx/font_enumerator/gtk;1",
@ -289,19 +264,10 @@ static const nsModuleComponentInfo components[] =
// "@mozilla.org/gfx/fontlist;1"
NS_FONTLIST_CONTRACTID,
nsFontListConstructor },
{ "Gtk Printer Enumerator",
NS_PRINTER_ENUMERATOR_CID,
// "@mozilla.org/gfx/printer_enumerator/gtk;1",
"@mozilla.org/gfx/printerenumerator;1",
nsPrinterEnumeratorGTKConstructor },
{ "windows image frame",
GFX_IMAGEFRAME_CID,
"@mozilla.org/gfx/image/frame;2",
gfxImageFrameConstructor, },
{ "Print Session",
NS_PRINTSESSION_CID,
"@mozilla.org/gfx/printsession;1",
nsPrintSessionConstructor },
#ifdef MOZ_ENABLE_FREETYPE2
{ "TrueType Font Catalog Service",
NS_FONTCATALOGSERVICE_CID,

Просмотреть файл

@ -1,57 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsPrintOptionsGTK.h"
/** ---------------------------------------------------
* See documentation in nsPrintOptionsWin.h
* @update 6/21/00 dwc
*/
nsPrintOptionsGTK::nsPrintOptionsGTK()
{
}
/** ---------------------------------------------------
* See documentation in nsPrintOptionsImpl.h
* @update 6/21/00 dwc
*/
nsPrintOptionsGTK::~nsPrintOptionsGTK()
{
}

Просмотреть файл

@ -1,60 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications, Inc.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Travis Bogard <travis@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsPrintOptionsGTK_h__
#define nsPrintOptionsGTK_h__
#include "nsPrintOptionsImpl.h"
//*****************************************************************************
//*** nsPrintOptions
//*****************************************************************************
class nsPrintOptionsGTK : public nsPrintOptions
{
public:
nsPrintOptionsGTK();
virtual ~nsPrintOptionsGTK();
};
#endif /* nsPrintOptions_h__ */

Просмотреть файл

@ -1,473 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Modified: syd@netscape.com 10/18/99 wired in margins
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Original Code: Syd Logan (syd@netscape.com) 3/12/99 */
#include <string.h>
#include <gtk/gtk.h>
#include "nspr.h"
#include "nsPrintdGTK.h"
/* A structure to hold widgets that need to be referenced in callbacks. We
declare this statically in the caller entry point (as a field of
UnixPrOps, below), and pass a pointer to the structure to Gtk+ for each
signal handler registered. This avoids use of globals. */
typedef struct prwidgets {
GtkWidget *toplevel; /* should be set to toplevel window */
GtkWidget *prDialog;
GtkWidget *cmdEntry;
GtkWidget *pathEntry;
GtkWidget *browseButton;
GtkWidget *fpfToggle;
GtkWidget *greyToggle;
GtkWidget *letterToggle;
GtkWidget *legalToggle;
GtkWidget *execToggle;
GtkWidget *topSpinner;
GtkWidget *bottomSpinner;
GtkWidget *leftSpinner;
GtkWidget *rightSpinner;
GtkFileSelection *fsWidget;
} PrWidgets;
typedef struct unixprops {
UnixPrData *prData; /* pointer to caller struct */
PrWidgets widgets;
} UnixPrOps;
/* user clicked cancel. tear things down, and set cancel field in
caller data to PR_TRUE so printing will not happen */
static void
CancelPrint (GtkWidget *widget, UnixPrOps *prOps)
{
gtk_main_quit();
gtk_widget_destroy( GTK_WIDGET(prOps->widgets.prDialog) );
prOps->prData->cancel = PR_TRUE;
}
/* user selected the Print button. Collect any remaining data from the
widgets, and set cancel field in caller data to PR_FALSE so printing
will be performed. Also, tear down dialog and exit inner main loop */
static void
DoPrint (GtkWidget *widget, UnixPrOps *prOps)
{
strcpy( prOps->prData->command,
gtk_entry_get_text( GTK_ENTRY( prOps->widgets.cmdEntry ) ) );
strcpy( prOps->prData->path,
gtk_entry_get_text( GTK_ENTRY( prOps->widgets.pathEntry ) ) );
if ( GTK_TOGGLE_BUTTON( prOps->widgets.fpfToggle )->active == PR_TRUE )
prOps->prData->fpf = PR_TRUE;
else
prOps->prData->fpf = PR_FALSE;
if ( GTK_TOGGLE_BUTTON( prOps->widgets.greyToggle )->active == PR_TRUE )
prOps->prData->grayscale = PR_TRUE;
else
prOps->prData->grayscale = PR_FALSE;
if ( GTK_TOGGLE_BUTTON( prOps->widgets.letterToggle )->active == PR_TRUE )
prOps->prData->size = NS_LETTER_SIZE;
else if ( GTK_TOGGLE_BUTTON( prOps->widgets.legalToggle )->active == PR_TRUE )
prOps->prData->size = NS_LEGAL_SIZE;
else if ( GTK_TOGGLE_BUTTON( prOps->widgets.execToggle )->active == PR_TRUE )
prOps->prData->size = NS_EXECUTIVE_SIZE;
else
prOps->prData->size = NS_A4_SIZE;
/* margins */
prOps->prData->top = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.topSpinner) );
prOps->prData->bottom = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.bottomSpinner) );
prOps->prData->left = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.leftSpinner) );
prOps->prData->right = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.rightSpinner) );
/* we got everything... bring down the dialog and tell caller
it's o.k. to print */
gtk_main_quit();
gtk_widget_destroy( GTK_WIDGET(prOps->widgets.prDialog) );
prOps->prData->cancel = PR_FALSE;
}
/* User hit ok in file selection widget brought up by the browse button.
snarf the selected file, stuff it in caller data */
static void
ModifyPrPath (GtkWidget *widget, UnixPrOps *prOps)
{
strcpy( prOps->prData->path,
gtk_file_selection_get_filename(prOps->widgets.fsWidget) );
gtk_entry_set_text (GTK_ENTRY (prOps->widgets.pathEntry),
prOps->prData->path);
gtk_widget_destroy( GTK_WIDGET(prOps->widgets.fsWidget) );
}
/* user selected print to printer. de-sensitize print to file fields */
static void
SwitchToPrinter (GtkWidget *widget, UnixPrOps *prOps)
{
gtk_widget_set_sensitive( prOps->widgets.cmdEntry, PR_TRUE );
gtk_widget_set_sensitive( prOps->widgets.pathEntry, PR_FALSE );
gtk_widget_set_sensitive( prOps->widgets.browseButton, PR_FALSE );
prOps->prData->toPrinter = PR_TRUE;
}
/* user selected print to file. de-sensitize print to printer fields */
static void
SwitchToFile (GtkWidget *widget, UnixPrOps *prOps)
{
gtk_widget_set_sensitive( prOps->widgets.cmdEntry, PR_FALSE );
gtk_widget_set_sensitive( prOps->widgets.pathEntry, PR_TRUE );
gtk_widget_set_sensitive( prOps->widgets.browseButton, PR_TRUE );
prOps->prData->toPrinter = PR_FALSE;
}
/* user hit the browse button. Pop up a file selection widget and grab
result */
static void
GetPrPath (GtkWidget *widget, UnixPrOps *prOps)
{
GtkWidget *fs;
fs = gtk_file_selection_new("File Browser");
gtk_file_selection_set_filename( GTK_FILE_SELECTION(fs),
prOps->prData->path );
gtk_window_set_modal (GTK_WINDOW(fs),PR_TRUE);
#if 0
/* XXX not sure what the toplevel window should be. */
gtk_window_set_transient_for (GTK_WINDOW (fs),
GTK_WINDOW (prOps->widgets.toplevel));
#endif
prOps->widgets.fsWidget = GTK_FILE_SELECTION(fs);
gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
"clicked", GTK_SIGNAL_FUNC(ModifyPrPath), prOps);
gtk_signal_connect_object (GTK_OBJECT(
GTK_FILE_SELECTION(fs)->cancel_button), "clicked",
GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT (fs));
gtk_widget_show(fs);
}
/* create file data dialog. XXX widget should be NULL */
static void
DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
{
GtkWidget *separator, *dialog, *label, *vbox, *entry, *hbox,
*button, *fileButton, *prButton, *table, *spinner1;
GtkAdjustment *adj;
prOps->widgets.prDialog = dialog =
gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_window_set_modal( GTK_WINDOW(dialog), PR_TRUE );
#if 0
/* not yet sure what the toplevel window should be */
gtk_window_set_transient_for (GTK_WINDOW (dialog),
GTK_WINDOW (prOps->widgets.toplevel));
#endif
gtk_window_set_title( GTK_WINDOW(dialog), "Print" );
vbox = gtk_vbox_new (PR_FALSE, 0);
gtk_container_add (GTK_CONTAINER (dialog), vbox);
table = gtk_table_new (3, 3, PR_FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_TRUE, 5);
label = gtk_label_new( "Print To:" );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
0, GTK_EXPAND | GTK_FILL, 0, 0);
button = prButton = gtk_radio_button_new_with_label (NULL, "Printer");
if ( prOps->prData->toPrinter == PR_TRUE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = fileButton = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)), "File");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
if ( prOps->prData->toPrinter == PR_FALSE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
label = gtk_label_new( "Print Command:" );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
0, GTK_EXPAND | GTK_FILL, 0, 0);
entry = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (entry), prOps->prData->command);
gtk_table_attach (GTK_TABLE (table), entry, 1, 3, 1, 2,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
if ( prOps->prData->toPrinter == PR_FALSE )
gtk_widget_set_sensitive( entry, PR_FALSE );
prOps->widgets.cmdEntry = entry;
label = gtk_label_new( "File Name:" );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
0, GTK_EXPAND | GTK_FILL, 0, 0);
entry = gtk_entry_new ();
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_entry_set_text (GTK_ENTRY (entry), prOps->prData->path);
if ( prOps->prData->toPrinter == PR_TRUE )
gtk_widget_set_sensitive( entry, PR_FALSE );
prOps->widgets.pathEntry = entry;
button = gtk_button_new_with_label ("Browse...");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (GetPrPath), prOps);
if ( prOps->prData->toPrinter == PR_TRUE )
gtk_widget_set_sensitive( entry, PR_FALSE );
prOps->widgets.browseButton = button;
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
table = gtk_table_new (2, 4, PR_FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_FALSE, 0);
label = gtk_label_new( "Print: " );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (NULL, "First Page First");
if ( prOps->prData->fpf == PR_TRUE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
prOps->widgets.fpfToggle = button;
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Last Page First");
if ( prOps->prData->fpf == PR_FALSE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Print: " );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (NULL, "Greyscale");
prOps->widgets.greyToggle = button;
if ( prOps->prData->grayscale == PR_TRUE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Color");
if ( prOps->prData->grayscale == PR_FALSE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Paper Size: " );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (NULL,
"Letter (8 1/2 x 11 in.)");
prOps->widgets.letterToggle = button;
if ( prOps->prData->size == NS_LETTER_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Legal (8 1/2 x 14 in.)");
prOps->widgets.legalToggle = button;
if ( prOps->prData->size == NS_LEGAL_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Executive (7 1/2 x 10 in.)");
prOps->widgets.execToggle = button;
if ( prOps->prData->size == NS_EXECUTIVE_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 4, 5,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"A4 (210 x 297 mm)");
if ( prOps->prData->size == NS_A4_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 4, 5,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
/* margins */
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, PR_FALSE, PR_FALSE, 5);
label = gtk_label_new( "Margins (inches):" );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_FALSE, PR_FALSE, 10);
table = gtk_table_new (1, 2, PR_FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_FALSE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Top: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new ( prOps->prData->top, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.topSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
label = gtk_label_new( "Bottom: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new ( prOps->prData->bottom, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.bottomSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Left: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new ( prOps->prData->left, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.leftSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
label = gtk_label_new( "Right: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new ( prOps->prData->right, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.rightSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, PR_TRUE, PR_FALSE, 5);
button = gtk_button_new_with_label ("Print");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (DoPrint), prOps );
gtk_box_pack_start (GTK_BOX (hbox), button, PR_TRUE, PR_FALSE, 0);
GTK_WIDGET_FLAGS (button) |= GTK_CAN_DEFAULT;
gtk_widget_grab_default (button);
button = gtk_button_new_with_label ("Cancel");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC ( CancelPrint ), prOps);
gtk_box_pack_start (GTK_BOX (hbox), button, PR_TRUE, PR_FALSE, 0);
/* Do this here, otherwise, upon creation the callbacks will be
triggered and the widgets these callbacks set sensitivity on
do not exist yet */
gtk_signal_connect (GTK_OBJECT (prButton), "clicked",
GTK_SIGNAL_FUNC (SwitchToPrinter), prOps);
gtk_signal_connect (GTK_OBJECT (fileButton), "clicked",
GTK_SIGNAL_FUNC (SwitchToFile), prOps);
gtk_widget_show_all( dialog );
gtk_main ();
}
/* public interface to print dialog. Caller passes in preferences using
argument, we return any changes and indication of whether to print
or cancel. */
void
UnixPrDialog( UnixPrData *prData )
{
static UnixPrOps prOps;
prOps.prData = prData;
DoPrintGTK( (GtkWidget *) NULL, &prOps );
}

Просмотреть файл

@ -1,92 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Original Code: Syd Logan (syd@netscape.com) 3/12/99 */
#ifndef nsPrintdGTK_h___
#define nsPrintdGTK_h___
#include <limits.h>
PR_BEGIN_EXTERN_C
/* stolen from nsPostScriptObj.h. needs to be put somewhere else that
both ps and gtk can see easily */
#ifndef NS_LEGAL_SIZE
#define NS_LETTER_SIZE 0
#define NS_LEGAL_SIZE 1
#define NS_EXECUTIVE_SIZE 2
#define NS_A4_SIZE 3
#define NS_A3_SIZE 4
#define NS_PORTRAIT 0
#define NS_LANDSCAPE 1
#endif
#ifndef PATH_MAX
#ifdef _POSIX_PATH_MAX
#define PATH_MAX _POSIX_PATH_MAX
#else
#define PATH_MAX 256
#endif
#endif
typedef struct unixprdata {
PRBool toPrinter; /* If PR_TRUE, print to printer */
PRBool fpf; /* If PR_TRUE, first page first */
PRBool grayscale; /* If PR_TRUE, print grayscale */
int size; /* Paper size e.g., SizeLetter */
int orientation; /* Orientation e.g. Portrait */
char command[ PATH_MAX ]; /* Print command e.g., lpr */
char path[ PATH_MAX ]; /* If toPrinter = PR_FALSE, dest file */
char printer[256]; /* Printer name */
int copies; /* number of copies */
PRBool cancel; /* If PR_TRUE, user cancelled */
float left; /* left margin */
float right; /* right margin */
float top; /* top margin */
float bottom; /* bottom margin */
} UnixPrData;
void UnixPrDialog(UnixPrData *prData);
PR_END_EXTERN_C
#endif /* !nsPrintdGTK_h___ */

Просмотреть файл

@ -83,6 +83,7 @@ CSRCS = \
mozcontainer.c \
mozdrawingarea.c \
keysym2ucs.c \
nsPrintdGTK.c \
$(NULL)
CPPSRCS = \
@ -101,6 +102,9 @@ CPPSRCS = \
nsNativeKeyBindings.cpp \
nsScreenGtk.cpp \
nsScreenManagerGtk.cpp \
nsDeviceContextSpecFactoryG.cpp \
nsDeviceContextSpecG.cpp \
nsPrintOptionsGTK.cpp \
$(NULL)
# build our subdirs, too
@ -143,8 +147,14 @@ DEFINES += -DUSE_XIM
ifdef MOZ_ENABLE_CAIRO_GFX
DEFINES += -DCAIRO_GFX
EXTRA_DSO_LDOPTS += -lgfxpsshar
endif
ifdef MOZ_ENABLE_POSTSCRIPT
DEFINES += -DUSE_POSTSCRIPT
endif
DEFINES +=
INCLUDES += \
-I$(srcdir)/../xpwidgets \

Просмотреть файл

@ -409,6 +409,33 @@ NS_IMPL_ISUPPORTS1(nsDeviceContextSpecGTK,
#error "This should not happen"
#endif
#ifdef MOZ_CAIRO_GFX
#include "gfxPDFSurface.h"
#include "nsUnitConversion.h"
NS_IMETHODIMP nsDeviceContextSpecGTK::GetSurfaceForPrinter(gfxASurface **aSurface)
{
const char *path = nsnull;
GetPath(&path);
PRInt32 width, height;
GetPageSizeInTwips(&width, &height);
double w, h;
// convert twips to points
w = width/20;
h = height/20;
printf("%s, %d, %d\n", path, width, height);
gfxPDFSurface *surface = new gfxPDFSurface(path, w, h);
surface->SetDPI(600, 600);
*aSurface = surface;
NS_ADDREF(*aSurface);
return NS_OK;
}
#endif
/** -------------------------------------------------------
* Initialize the nsDeviceContextSpecGTK
* @update dc 2/15/98

Просмотреть файл

@ -75,6 +75,10 @@ public:
NS_DECL_ISUPPORTS
#ifdef MOZ_CAIRO_GFX
NS_IMETHOD GetSurfaceForPrinter(gfxASurface **surface);
#endif
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview);
NS_IMETHOD ClosePrintManager();

Просмотреть файл

@ -52,6 +52,10 @@
#include "nsBidiKeyboard.h"
#include "nsNativeKeyBindings.h"
#include "nsScreenManagerGtk.h"
#include "nsPrintOptionsGTK.h"
#include "nsPrintSession.h"
#include "nsDeviceContextSpecG.h"
#include "nsDeviceContextSpecFactoryG.h"
#ifdef NATIVE_THEME_SUPPORT
#include "nsNativeThemeGTK.h"
@ -81,9 +85,14 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsClipboard, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerGtk)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryGTK)
#ifdef NATIVE_THEME_SUPPORT
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeGTK)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsGTK, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
static NS_IMETHODIMP
nsFilePickerConstructor(nsISupports *aOuter, REFNSIID aIID,
@ -226,9 +235,32 @@ static const nsModuleComponentInfo components[] =
{ "Native Theme Renderer",
NS_THEMERENDERER_CID,
"@mozilla.org/chrome/chrome-native-theme;1",
nsNativeThemeGTKConstructor }
nsNativeThemeGTKConstructor },
#endif
#endif
{ "PrintSettings Service",
NS_PRINTSETTINGSSERVICE_CID,
"@mozilla.org/gfx/printsettings-service;1",
nsPrintOptionsGTKConstructor },
{ "Gtk Printer Enumerator",
NS_PRINTER_ENUMERATOR_CID,
// "@mozilla.org/gfx/printer_enumerator/gtk;1",
"@mozilla.org/gfx/printerenumerator;1",
nsPrinterEnumeratorGTKConstructor },
{ "Print Session",
NS_PRINTSESSION_CID,
"@mozilla.org/gfx/printsession;1",
nsPrintSessionConstructor },
{ "Gtk Device Context Spec",
NS_DEVICE_CONTEXT_SPEC_CID,
// "@mozilla.org/gfx/device_context_spec/gtk;1",
"@mozilla.org/gfx/devicecontextspec;1",
nsDeviceContextSpecGTKConstructor },
{ "Gtk Device Context Spec Factory",
NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
// "@mozilla.org/gfx/device_context_spec_factory/gtk;1",
"@mozilla.org/gfx/devicecontextspecfactory;1",
nsDeviceContextSpecFactoryGTKConstructor },
};
PR_STATIC_CALLBACK(void)