1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/gtk/nsPrintSettingsGTK.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,154 @@ 1.4 +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef nsPrintSettingsGTK_h_ 1.11 +#define nsPrintSettingsGTK_h_ 1.12 + 1.13 +#include "nsPrintSettingsImpl.h" 1.14 + 1.15 +extern "C" { 1.16 +#include <gtk/gtk.h> 1.17 +#if (MOZ_WIDGET_GTK == 2) 1.18 +#include <gtk/gtkprinter.h> 1.19 +#include <gtk/gtkprintjob.h> 1.20 +#else 1.21 +#include <gtk/gtkunixprint.h> 1.22 +#endif 1.23 +} 1.24 + 1.25 +#define NS_PRINTSETTINGSGTK_IID \ 1.26 +{ 0x758df520, 0xc7c3, 0x11dc, { 0x95, 0xff, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 } } 1.27 + 1.28 + 1.29 +//***************************************************************************** 1.30 +//*** nsPrintSettingsGTK 1.31 +//***************************************************************************** 1.32 + 1.33 +class nsPrintSettingsGTK : public nsPrintSettings 1.34 +{ 1.35 +public: 1.36 + NS_DECL_ISUPPORTS_INHERITED 1.37 + NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRINTSETTINGSGTK_IID) 1.38 + 1.39 + nsPrintSettingsGTK(); 1.40 + virtual ~nsPrintSettingsGTK(); 1.41 + 1.42 + // We're overriding these methods because we want to read/write with GTK objects, 1.43 + // not local variables. This allows a simpler settings implementation between 1.44 + // Gecko and GTK. 1.45 + 1.46 + GtkPageSetup* GetGtkPageSetup() { return mPageSetup; }; 1.47 + void SetGtkPageSetup(GtkPageSetup *aPageSetup); 1.48 + 1.49 + GtkPrintSettings* GetGtkPrintSettings() { return mPrintSettings; }; 1.50 + void SetGtkPrintSettings(GtkPrintSettings *aPrintSettings); 1.51 + 1.52 + GtkPrinter* GetGtkPrinter() { return mGTKPrinter; }; 1.53 + void SetGtkPrinter(GtkPrinter *aPrinter); 1.54 + 1.55 + bool GetForcePrintSelectionOnly() { return mPrintSelectionOnly; }; 1.56 + void SetForcePrintSelectionOnly(bool aPrintSelectionOnly) { mPrintSelectionOnly = aPrintSelectionOnly; }; 1.57 + 1.58 + // If not printing the selection, this is stored in the GtkPrintSettings. Printing the 1.59 + // selection is stored as a protected boolean (mPrintSelectionOnly). 1.60 + NS_IMETHOD GetPrintRange(int16_t *aPrintRange); 1.61 + NS_IMETHOD SetPrintRange(int16_t aPrintRange); 1.62 + 1.63 + // The page range is stored as as single range in the GtkPrintSettings object. 1.64 + NS_IMETHOD GetStartPageRange(int32_t *aStartPageRange); 1.65 + NS_IMETHOD SetStartPageRange(int32_t aStartPageRange); 1.66 + NS_IMETHOD GetEndPageRange(int32_t *aEndPageRange); 1.67 + NS_IMETHOD SetEndPageRange(int32_t aEndPageRange); 1.68 + 1.69 + // Reversed, color, orientation and file name are all stored in the GtkPrintSettings. 1.70 + // Orientation is also stored in the GtkPageSetup and its setting takes priority when getting the orientation. 1.71 + NS_IMETHOD GetPrintReversed(bool *aPrintReversed); 1.72 + NS_IMETHOD SetPrintReversed(bool aPrintReversed); 1.73 + 1.74 + NS_IMETHOD GetPrintInColor(bool *aPrintInColor); 1.75 + NS_IMETHOD SetPrintInColor(bool aPrintInColor); 1.76 + 1.77 + NS_IMETHOD GetOrientation(int32_t *aOrientation); 1.78 + NS_IMETHOD SetOrientation(int32_t aOrientation); 1.79 + 1.80 + NS_IMETHOD GetToFileName(char16_t * *aToFileName); 1.81 + NS_IMETHOD SetToFileName(const char16_t * aToFileName); 1.82 + 1.83 + // Gets/Sets the printer name in the GtkPrintSettings. If no printer name is specified there, 1.84 + // you will get back the name of the current internal GtkPrinter. 1.85 + NS_IMETHOD GetPrinterName(char16_t * *aPrinter); 1.86 + NS_IMETHOD SetPrinterName(const char16_t * aPrinter); 1.87 + 1.88 + // Number of copies is stored/gotten from the GtkPrintSettings. 1.89 + NS_IMETHOD GetNumCopies(int32_t *aNumCopies); 1.90 + NS_IMETHOD SetNumCopies(int32_t aNumCopies); 1.91 + 1.92 + NS_IMETHOD GetScaling(double *aScaling); 1.93 + NS_IMETHOD SetScaling(double aScaling); 1.94 + 1.95 + // A name recognised by GTK is strongly advised here, as this is used to create a GtkPaperSize. 1.96 + NS_IMETHOD GetPaperName(char16_t * *aPaperName); 1.97 + NS_IMETHOD SetPaperName(const char16_t * aPaperName); 1.98 + 1.99 + NS_IMETHOD SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin); 1.100 + NS_IMETHOD SetUnwriteableMarginTop(double aUnwriteableMarginTop); 1.101 + NS_IMETHOD SetUnwriteableMarginLeft(double aUnwriteableMarginLeft); 1.102 + NS_IMETHOD SetUnwriteableMarginBottom(double aUnwriteableMarginBottom); 1.103 + NS_IMETHOD SetUnwriteableMarginRight(double aUnwriteableMarginRight); 1.104 + 1.105 + NS_IMETHOD GetPaperWidth(double *aPaperWidth); 1.106 + NS_IMETHOD SetPaperWidth(double aPaperWidth); 1.107 + 1.108 + NS_IMETHOD GetPaperHeight(double *aPaperHeight); 1.109 + NS_IMETHOD SetPaperHeight(double aPaperHeight); 1.110 + 1.111 + NS_IMETHOD SetPaperSizeUnit(int16_t aPaperSizeUnit); 1.112 + 1.113 + NS_IMETHOD GetEffectivePageSize(double *aWidth, double *aHeight); 1.114 + 1.115 + NS_IMETHOD SetupSilentPrinting(); 1.116 + 1.117 + NS_IMETHOD GetPageRanges(nsTArray<int32_t> &aPages); 1.118 + 1.119 + NS_IMETHOD GetResolution(int32_t *aResolution); 1.120 + NS_IMETHOD SetResolution(int32_t aResolution); 1.121 + 1.122 + NS_IMETHOD GetDuplex(int32_t *aDuplex); 1.123 + NS_IMETHOD SetDuplex(int32_t aDuplex); 1.124 + 1.125 +protected: 1.126 + nsPrintSettingsGTK(const nsPrintSettingsGTK& src); 1.127 + nsPrintSettingsGTK& operator=(const nsPrintSettingsGTK& rhs); 1.128 + 1.129 + virtual nsresult _Clone(nsIPrintSettings **_retval); 1.130 + virtual nsresult _Assign(nsIPrintSettings *aPS); 1.131 + 1.132 + GtkUnit GetGTKUnit(int16_t aGeckoUnit); 1.133 + void SaveNewPageSize(); 1.134 + 1.135 + /** 1.136 + * Re-initialize mUnwriteableMargin with values from mPageSetup. 1.137 + * Should be called whenever mPageSetup is initialized or overwritten. 1.138 + */ 1.139 + void InitUnwriteableMargin(); 1.140 + 1.141 + /** 1.142 + * On construction: 1.143 + * - mPrintSettings, mPageSetup and mPaperSize are just new objects with defaults determined by GTK. 1.144 + * - mGTKPrinter is nullptr!!! Remember to be careful when accessing this property. 1.145 + */ 1.146 + GtkPageSetup* mPageSetup; 1.147 + GtkPrintSettings* mPrintSettings; 1.148 + GtkPrinter* mGTKPrinter; 1.149 + GtkPaperSize* mPaperSize; 1.150 + 1.151 + bool mPrintSelectionOnly; 1.152 +}; 1.153 + 1.154 +NS_DEFINE_STATIC_IID_ACCESSOR(nsPrintSettingsGTK, NS_PRINTSETTINGSGTK_IID) 1.155 + 1.156 + 1.157 +#endif // nsPrintSettingsGTK_h_