1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is the Mozilla browser.
18 * The Initial Developer of the Original Code is Mozilla Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2008
20 * the Initial Developer. All Rights Reserved.
23 * Michael Ventnor <m.ventnor@gmail.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef nsPrintSettingsGTK_h_
40 #define nsPrintSettingsGTK_h_
42 #include "nsPrintSettingsImpl.h"
46 #include <gtk/gtkprinter.h>
47 #include <gtk/gtkprintjob.h>
50 #define NS_PRINTSETTINGSGTK_IID \
51 { 0x758df520, 0xc7c3, 0x11dc, { 0x95, 0xff, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 } }
54 //*****************************************************************************
55 //*** nsPrintSettingsGTK
56 //*****************************************************************************
58 class nsPrintSettingsGTK
: public nsPrintSettings
61 NS_DECL_ISUPPORTS_INHERITED
62 NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRINTSETTINGSGTK_IID
)
65 virtual ~nsPrintSettingsGTK();
67 // We're overriding these methods because we want to read/write with GTK objects,
68 // not local variables. This allows a simpler settings implementation between
71 GtkPageSetup
* GetGtkPageSetup() { return mPageSetup
; };
72 void SetGtkPageSetup(GtkPageSetup
*aPageSetup
);
74 GtkPrintSettings
* GetGtkPrintSettings() { return mPrintSettings
; };
75 void SetGtkPrintSettings(GtkPrintSettings
*aPrintSettings
);
77 GtkPrinter
* GetGtkPrinter() { return mGTKPrinter
; };
78 void SetGtkPrinter(GtkPrinter
*aPrinter
);
80 PRBool
GetForcePrintSelectionOnly() { return mPrintSelectionOnly
; };
81 void SetForcePrintSelectionOnly(PRBool aPrintSelectionOnly
) { mPrintSelectionOnly
= aPrintSelectionOnly
; };
83 // If not printing the selection, this is stored in the GtkPrintSettings. Printing the
84 // selection is stored as a protected boolean (mPrintSelectionOnly).
85 NS_IMETHOD
GetPrintRange(PRInt16
*aPrintRange
);
86 NS_IMETHOD
SetPrintRange(PRInt16 aPrintRange
);
88 // The page range is stored as as single range in the GtkPrintSettings object.
89 NS_IMETHOD
GetStartPageRange(PRInt32
*aStartPageRange
);
90 NS_IMETHOD
SetStartPageRange(PRInt32 aStartPageRange
);
91 NS_IMETHOD
GetEndPageRange(PRInt32
*aEndPageRange
);
92 NS_IMETHOD
SetEndPageRange(PRInt32 aEndPageRange
);
94 // Reversed, color, orientation and file name are all stored in the GtkPrintSettings.
95 // Orientation is also stored in the GtkPageSetup and its setting takes priority when getting the orientation.
96 NS_IMETHOD
GetPrintReversed(PRBool
*aPrintReversed
);
97 NS_IMETHOD
SetPrintReversed(PRBool aPrintReversed
);
99 NS_IMETHOD
GetPrintInColor(PRBool
*aPrintInColor
);
100 NS_IMETHOD
SetPrintInColor(PRBool aPrintInColor
);
102 NS_IMETHOD
GetOrientation(PRInt32
*aOrientation
);
103 NS_IMETHOD
SetOrientation(PRInt32 aOrientation
);
105 NS_IMETHOD
GetToFileName(PRUnichar
* *aToFileName
);
106 NS_IMETHOD
SetToFileName(const PRUnichar
* aToFileName
);
108 // Gets/Sets the printer name in the GtkPrintSettings. If no printer name is specified there,
109 // you will get back the name of the current internal GtkPrinter.
110 NS_IMETHOD
GetPrinterName(PRUnichar
* *aPrinter
);
111 NS_IMETHOD
SetPrinterName(const PRUnichar
* aPrinter
);
113 // Number of copies is stored/gotten from the GtkPrintSettings.
114 NS_IMETHOD
GetNumCopies(PRInt32
*aNumCopies
);
115 NS_IMETHOD
SetNumCopies(PRInt32 aNumCopies
);
117 NS_IMETHOD
GetScaling(double *aScaling
);
118 NS_IMETHOD
SetScaling(double aScaling
);
120 // A name recognised by GTK is strongly advised here, as this is used to create a GtkPaperSize.
121 NS_IMETHOD
GetPaperName(PRUnichar
* *aPaperName
);
122 NS_IMETHOD
SetPaperName(const PRUnichar
* aPaperName
);
124 NS_IMETHOD
SetUnwriteableMarginInTwips(nsMargin
& aUnwriteableMargin
);
125 NS_IMETHOD
SetUnwriteableMarginTop(double aUnwriteableMarginTop
);
126 NS_IMETHOD
SetUnwriteableMarginLeft(double aUnwriteableMarginLeft
);
127 NS_IMETHOD
SetUnwriteableMarginBottom(double aUnwriteableMarginBottom
);
128 NS_IMETHOD
SetUnwriteableMarginRight(double aUnwriteableMarginRight
);
130 NS_IMETHOD
GetPaperWidth(double *aPaperWidth
);
131 NS_IMETHOD
SetPaperWidth(double aPaperWidth
);
133 NS_IMETHOD
GetPaperHeight(double *aPaperHeight
);
134 NS_IMETHOD
SetPaperHeight(double aPaperHeight
);
136 NS_IMETHOD
SetPaperSizeUnit(PRInt16 aPaperSizeUnit
);
138 NS_IMETHOD
GetEffectivePageSize(double *aWidth
, double *aHeight
);
140 NS_IMETHOD
SetupSilentPrinting();
143 nsPrintSettingsGTK(const nsPrintSettingsGTK
& src
);
144 nsPrintSettingsGTK
& operator=(const nsPrintSettingsGTK
& rhs
);
146 virtual nsresult
_Clone(nsIPrintSettings
**_retval
);
147 virtual nsresult
_Assign(nsIPrintSettings
*aPS
);
149 GtkUnit
GetGTKUnit(PRInt16 aGeckoUnit
);
150 void SaveNewPageSize();
153 * Re-initialize mUnwriteableMargin with values from mPageSetup.
154 * Should be called whenever mPageSetup is initialized or overwritten.
156 void InitUnwriteableMargin();
160 * - mPrintSettings, mPageSetup and mPaperSize are just new objects with defaults determined by GTK.
161 * - mGTKPrinter is NULL!!! Remember to be careful when accessing this property.
163 GtkPageSetup
* mPageSetup
;
164 GtkPrintSettings
* mPrintSettings
;
165 GtkPrinter
* mGTKPrinter
;
166 GtkPaperSize
* mPaperSize
;
168 PRBool mPrintSelectionOnly
;
171 NS_DEFINE_STATIC_IID_ACCESSOR(nsPrintSettingsGTK
, NS_PRINTSETTINGSGTK_IID
)
174 #endif // nsPrintSettingsGTK_h_