1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsPrintSettingsGTK_h_
8 #define nsPrintSettingsGTK_h_
10 #include "nsPrintSettingsImpl.h"
14 #if (MOZ_WIDGET_GTK == 2)
15 #include <gtk/gtkprinter.h>
16 #include <gtk/gtkprintjob.h>
18 #include <gtk/gtkunixprint.h>
22 #define NS_PRINTSETTINGSGTK_IID \
23 { 0x758df520, 0xc7c3, 0x11dc, { 0x95, 0xff, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 } }
26 //*****************************************************************************
27 //*** nsPrintSettingsGTK
28 //*****************************************************************************
30 class nsPrintSettingsGTK
: public nsPrintSettings
33 NS_DECL_ISUPPORTS_INHERITED
34 NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRINTSETTINGSGTK_IID
)
38 // We're overriding these methods because we want to read/write with GTK objects,
39 // not local variables. This allows a simpler settings implementation between
42 GtkPageSetup
* GetGtkPageSetup() { return mPageSetup
; };
43 void SetGtkPageSetup(GtkPageSetup
*aPageSetup
);
45 GtkPrintSettings
* GetGtkPrintSettings() { return mPrintSettings
; };
46 void SetGtkPrintSettings(GtkPrintSettings
*aPrintSettings
);
48 GtkPrinter
* GetGtkPrinter() { return mGTKPrinter
; };
49 void SetGtkPrinter(GtkPrinter
*aPrinter
);
51 bool GetForcePrintSelectionOnly() { return mPrintSelectionOnly
; };
52 void SetForcePrintSelectionOnly(bool aPrintSelectionOnly
) { mPrintSelectionOnly
= aPrintSelectionOnly
; };
54 // If not printing the selection, this is stored in the GtkPrintSettings. Printing the
55 // selection is stored as a protected boolean (mPrintSelectionOnly).
56 NS_IMETHOD
GetPrintRange(int16_t *aPrintRange
);
57 NS_IMETHOD
SetPrintRange(int16_t aPrintRange
);
59 // The page range is stored as as single range in the GtkPrintSettings object.
60 NS_IMETHOD
GetStartPageRange(int32_t *aStartPageRange
);
61 NS_IMETHOD
SetStartPageRange(int32_t aStartPageRange
);
62 NS_IMETHOD
GetEndPageRange(int32_t *aEndPageRange
);
63 NS_IMETHOD
SetEndPageRange(int32_t aEndPageRange
);
65 // Reversed, color, orientation and file name are all stored in the GtkPrintSettings.
66 // Orientation is also stored in the GtkPageSetup and its setting takes priority when getting the orientation.
67 NS_IMETHOD
GetPrintReversed(bool *aPrintReversed
);
68 NS_IMETHOD
SetPrintReversed(bool aPrintReversed
);
70 NS_IMETHOD
GetPrintInColor(bool *aPrintInColor
);
71 NS_IMETHOD
SetPrintInColor(bool aPrintInColor
);
73 NS_IMETHOD
GetOrientation(int32_t *aOrientation
);
74 NS_IMETHOD
SetOrientation(int32_t aOrientation
);
76 NS_IMETHOD
GetToFileName(char16_t
* *aToFileName
);
77 NS_IMETHOD
SetToFileName(const char16_t
* aToFileName
);
79 // Gets/Sets the printer name in the GtkPrintSettings. If no printer name is specified there,
80 // you will get back the name of the current internal GtkPrinter.
81 NS_IMETHOD
GetPrinterName(char16_t
* *aPrinter
);
82 NS_IMETHOD
SetPrinterName(const char16_t
* aPrinter
);
84 // Number of copies is stored/gotten from the GtkPrintSettings.
85 NS_IMETHOD
GetNumCopies(int32_t *aNumCopies
);
86 NS_IMETHOD
SetNumCopies(int32_t aNumCopies
);
88 NS_IMETHOD
GetScaling(double *aScaling
);
89 NS_IMETHOD
SetScaling(double aScaling
);
91 // A name recognised by GTK is strongly advised here, as this is used to create a GtkPaperSize.
92 NS_IMETHOD
GetPaperName(char16_t
* *aPaperName
);
93 NS_IMETHOD
SetPaperName(const char16_t
* aPaperName
);
95 NS_IMETHOD
SetUnwriteableMarginInTwips(nsIntMargin
& aUnwriteableMargin
);
96 NS_IMETHOD
SetUnwriteableMarginTop(double aUnwriteableMarginTop
);
97 NS_IMETHOD
SetUnwriteableMarginLeft(double aUnwriteableMarginLeft
);
98 NS_IMETHOD
SetUnwriteableMarginBottom(double aUnwriteableMarginBottom
);
99 NS_IMETHOD
SetUnwriteableMarginRight(double aUnwriteableMarginRight
);
101 NS_IMETHOD
GetPaperWidth(double *aPaperWidth
);
102 NS_IMETHOD
SetPaperWidth(double aPaperWidth
);
104 NS_IMETHOD
GetPaperHeight(double *aPaperHeight
);
105 NS_IMETHOD
SetPaperHeight(double aPaperHeight
);
107 NS_IMETHOD
SetPaperSizeUnit(int16_t aPaperSizeUnit
);
109 NS_IMETHOD
GetEffectivePageSize(double *aWidth
, double *aHeight
);
111 NS_IMETHOD
SetupSilentPrinting();
113 NS_IMETHOD
GetPageRanges(nsTArray
<int32_t> &aPages
);
115 NS_IMETHOD
GetResolution(int32_t *aResolution
);
116 NS_IMETHOD
SetResolution(int32_t aResolution
);
118 NS_IMETHOD
GetDuplex(int32_t *aDuplex
);
119 NS_IMETHOD
SetDuplex(int32_t aDuplex
);
122 virtual ~nsPrintSettingsGTK();
124 nsPrintSettingsGTK(const nsPrintSettingsGTK
& src
);
125 nsPrintSettingsGTK
& operator=(const nsPrintSettingsGTK
& rhs
);
127 virtual nsresult
_Clone(nsIPrintSettings
**_retval
);
128 virtual nsresult
_Assign(nsIPrintSettings
*aPS
);
130 GtkUnit
GetGTKUnit(int16_t aGeckoUnit
);
131 void SaveNewPageSize();
134 * Re-initialize mUnwriteableMargin with values from mPageSetup.
135 * Should be called whenever mPageSetup is initialized or overwritten.
137 void InitUnwriteableMargin();
141 * - mPrintSettings, mPageSetup and mPaperSize are just new objects with defaults determined by GTK.
142 * - mGTKPrinter is nullptr!!! Remember to be careful when accessing this property.
144 GtkPageSetup
* mPageSetup
;
145 GtkPrintSettings
* mPrintSettings
;
146 GtkPrinter
* mGTKPrinter
;
147 GtkPaperSize
* mPaperSize
;
149 bool mPrintSelectionOnly
;
152 NS_DEFINE_STATIC_IID_ACCESSOR(nsPrintSettingsGTK
, NS_PRINTSETTINGSGTK_IID
)
155 #endif // nsPrintSettingsGTK_h_