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