|
1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
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/. */ |
|
6 |
|
7 #ifndef nsPrintSettingsGTK_h_ |
|
8 #define nsPrintSettingsGTK_h_ |
|
9 |
|
10 #include "nsPrintSettingsImpl.h" |
|
11 |
|
12 extern "C" { |
|
13 #include <gtk/gtk.h> |
|
14 #if (MOZ_WIDGET_GTK == 2) |
|
15 #include <gtk/gtkprinter.h> |
|
16 #include <gtk/gtkprintjob.h> |
|
17 #else |
|
18 #include <gtk/gtkunixprint.h> |
|
19 #endif |
|
20 } |
|
21 |
|
22 #define NS_PRINTSETTINGSGTK_IID \ |
|
23 { 0x758df520, 0xc7c3, 0x11dc, { 0x95, 0xff, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 } } |
|
24 |
|
25 |
|
26 //***************************************************************************** |
|
27 //*** nsPrintSettingsGTK |
|
28 //***************************************************************************** |
|
29 |
|
30 class nsPrintSettingsGTK : public nsPrintSettings |
|
31 { |
|
32 public: |
|
33 NS_DECL_ISUPPORTS_INHERITED |
|
34 NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRINTSETTINGSGTK_IID) |
|
35 |
|
36 nsPrintSettingsGTK(); |
|
37 virtual ~nsPrintSettingsGTK(); |
|
38 |
|
39 // We're overriding these methods because we want to read/write with GTK objects, |
|
40 // not local variables. This allows a simpler settings implementation between |
|
41 // Gecko and GTK. |
|
42 |
|
43 GtkPageSetup* GetGtkPageSetup() { return mPageSetup; }; |
|
44 void SetGtkPageSetup(GtkPageSetup *aPageSetup); |
|
45 |
|
46 GtkPrintSettings* GetGtkPrintSettings() { return mPrintSettings; }; |
|
47 void SetGtkPrintSettings(GtkPrintSettings *aPrintSettings); |
|
48 |
|
49 GtkPrinter* GetGtkPrinter() { return mGTKPrinter; }; |
|
50 void SetGtkPrinter(GtkPrinter *aPrinter); |
|
51 |
|
52 bool GetForcePrintSelectionOnly() { return mPrintSelectionOnly; }; |
|
53 void SetForcePrintSelectionOnly(bool aPrintSelectionOnly) { mPrintSelectionOnly = aPrintSelectionOnly; }; |
|
54 |
|
55 // If not printing the selection, this is stored in the GtkPrintSettings. Printing the |
|
56 // selection is stored as a protected boolean (mPrintSelectionOnly). |
|
57 NS_IMETHOD GetPrintRange(int16_t *aPrintRange); |
|
58 NS_IMETHOD SetPrintRange(int16_t aPrintRange); |
|
59 |
|
60 // The page range is stored as as single range in the GtkPrintSettings object. |
|
61 NS_IMETHOD GetStartPageRange(int32_t *aStartPageRange); |
|
62 NS_IMETHOD SetStartPageRange(int32_t aStartPageRange); |
|
63 NS_IMETHOD GetEndPageRange(int32_t *aEndPageRange); |
|
64 NS_IMETHOD SetEndPageRange(int32_t aEndPageRange); |
|
65 |
|
66 // Reversed, color, orientation and file name are all stored in the GtkPrintSettings. |
|
67 // Orientation is also stored in the GtkPageSetup and its setting takes priority when getting the orientation. |
|
68 NS_IMETHOD GetPrintReversed(bool *aPrintReversed); |
|
69 NS_IMETHOD SetPrintReversed(bool aPrintReversed); |
|
70 |
|
71 NS_IMETHOD GetPrintInColor(bool *aPrintInColor); |
|
72 NS_IMETHOD SetPrintInColor(bool aPrintInColor); |
|
73 |
|
74 NS_IMETHOD GetOrientation(int32_t *aOrientation); |
|
75 NS_IMETHOD SetOrientation(int32_t aOrientation); |
|
76 |
|
77 NS_IMETHOD GetToFileName(char16_t * *aToFileName); |
|
78 NS_IMETHOD SetToFileName(const char16_t * aToFileName); |
|
79 |
|
80 // Gets/Sets the printer name in the GtkPrintSettings. If no printer name is specified there, |
|
81 // you will get back the name of the current internal GtkPrinter. |
|
82 NS_IMETHOD GetPrinterName(char16_t * *aPrinter); |
|
83 NS_IMETHOD SetPrinterName(const char16_t * aPrinter); |
|
84 |
|
85 // Number of copies is stored/gotten from the GtkPrintSettings. |
|
86 NS_IMETHOD GetNumCopies(int32_t *aNumCopies); |
|
87 NS_IMETHOD SetNumCopies(int32_t aNumCopies); |
|
88 |
|
89 NS_IMETHOD GetScaling(double *aScaling); |
|
90 NS_IMETHOD SetScaling(double aScaling); |
|
91 |
|
92 // A name recognised by GTK is strongly advised here, as this is used to create a GtkPaperSize. |
|
93 NS_IMETHOD GetPaperName(char16_t * *aPaperName); |
|
94 NS_IMETHOD SetPaperName(const char16_t * aPaperName); |
|
95 |
|
96 NS_IMETHOD SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin); |
|
97 NS_IMETHOD SetUnwriteableMarginTop(double aUnwriteableMarginTop); |
|
98 NS_IMETHOD SetUnwriteableMarginLeft(double aUnwriteableMarginLeft); |
|
99 NS_IMETHOD SetUnwriteableMarginBottom(double aUnwriteableMarginBottom); |
|
100 NS_IMETHOD SetUnwriteableMarginRight(double aUnwriteableMarginRight); |
|
101 |
|
102 NS_IMETHOD GetPaperWidth(double *aPaperWidth); |
|
103 NS_IMETHOD SetPaperWidth(double aPaperWidth); |
|
104 |
|
105 NS_IMETHOD GetPaperHeight(double *aPaperHeight); |
|
106 NS_IMETHOD SetPaperHeight(double aPaperHeight); |
|
107 |
|
108 NS_IMETHOD SetPaperSizeUnit(int16_t aPaperSizeUnit); |
|
109 |
|
110 NS_IMETHOD GetEffectivePageSize(double *aWidth, double *aHeight); |
|
111 |
|
112 NS_IMETHOD SetupSilentPrinting(); |
|
113 |
|
114 NS_IMETHOD GetPageRanges(nsTArray<int32_t> &aPages); |
|
115 |
|
116 NS_IMETHOD GetResolution(int32_t *aResolution); |
|
117 NS_IMETHOD SetResolution(int32_t aResolution); |
|
118 |
|
119 NS_IMETHOD GetDuplex(int32_t *aDuplex); |
|
120 NS_IMETHOD SetDuplex(int32_t aDuplex); |
|
121 |
|
122 protected: |
|
123 nsPrintSettingsGTK(const nsPrintSettingsGTK& src); |
|
124 nsPrintSettingsGTK& operator=(const nsPrintSettingsGTK& rhs); |
|
125 |
|
126 virtual nsresult _Clone(nsIPrintSettings **_retval); |
|
127 virtual nsresult _Assign(nsIPrintSettings *aPS); |
|
128 |
|
129 GtkUnit GetGTKUnit(int16_t aGeckoUnit); |
|
130 void SaveNewPageSize(); |
|
131 |
|
132 /** |
|
133 * Re-initialize mUnwriteableMargin with values from mPageSetup. |
|
134 * Should be called whenever mPageSetup is initialized or overwritten. |
|
135 */ |
|
136 void InitUnwriteableMargin(); |
|
137 |
|
138 /** |
|
139 * On construction: |
|
140 * - mPrintSettings, mPageSetup and mPaperSize are just new objects with defaults determined by GTK. |
|
141 * - mGTKPrinter is nullptr!!! Remember to be careful when accessing this property. |
|
142 */ |
|
143 GtkPageSetup* mPageSetup; |
|
144 GtkPrintSettings* mPrintSettings; |
|
145 GtkPrinter* mGTKPrinter; |
|
146 GtkPaperSize* mPaperSize; |
|
147 |
|
148 bool mPrintSelectionOnly; |
|
149 }; |
|
150 |
|
151 NS_DEFINE_STATIC_IID_ACCESSOR(nsPrintSettingsGTK, NS_PRINTSETTINGSGTK_IID) |
|
152 |
|
153 |
|
154 #endif // nsPrintSettingsGTK_h_ |