widget/gtk/nsPrintSettingsGTK.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     7 #ifndef nsPrintSettingsGTK_h_
     8 #define nsPrintSettingsGTK_h_
    10 #include "nsPrintSettingsImpl.h"
    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 }
    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
    31 {
    32 public:
    33   NS_DECL_ISUPPORTS_INHERITED
    34   NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRINTSETTINGSGTK_IID)
    36   nsPrintSettingsGTK();
    37   virtual ~nsPrintSettingsGTK();
    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.
    43   GtkPageSetup* GetGtkPageSetup() { return mPageSetup; };
    44   void SetGtkPageSetup(GtkPageSetup *aPageSetup);
    46   GtkPrintSettings* GetGtkPrintSettings() { return mPrintSettings; };
    47   void SetGtkPrintSettings(GtkPrintSettings *aPrintSettings);
    49   GtkPrinter* GetGtkPrinter() { return mGTKPrinter; };
    50   void SetGtkPrinter(GtkPrinter *aPrinter);
    52   bool GetForcePrintSelectionOnly() { return mPrintSelectionOnly; };
    53   void SetForcePrintSelectionOnly(bool aPrintSelectionOnly) { mPrintSelectionOnly = aPrintSelectionOnly; };
    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);
    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);
    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);
    71   NS_IMETHOD GetPrintInColor(bool *aPrintInColor);
    72   NS_IMETHOD SetPrintInColor(bool aPrintInColor);
    74   NS_IMETHOD GetOrientation(int32_t *aOrientation);
    75   NS_IMETHOD SetOrientation(int32_t aOrientation);
    77   NS_IMETHOD GetToFileName(char16_t * *aToFileName);
    78   NS_IMETHOD SetToFileName(const char16_t * aToFileName);
    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);
    85   // Number of copies is stored/gotten from the GtkPrintSettings.
    86   NS_IMETHOD GetNumCopies(int32_t *aNumCopies);
    87   NS_IMETHOD SetNumCopies(int32_t aNumCopies);
    89   NS_IMETHOD GetScaling(double *aScaling);
    90   NS_IMETHOD SetScaling(double aScaling);
    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);
    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);
   102   NS_IMETHOD GetPaperWidth(double *aPaperWidth);
   103   NS_IMETHOD SetPaperWidth(double aPaperWidth);
   105   NS_IMETHOD GetPaperHeight(double *aPaperHeight);
   106   NS_IMETHOD SetPaperHeight(double aPaperHeight);
   108   NS_IMETHOD SetPaperSizeUnit(int16_t aPaperSizeUnit);
   110   NS_IMETHOD GetEffectivePageSize(double *aWidth, double *aHeight);
   112   NS_IMETHOD SetupSilentPrinting();
   114   NS_IMETHOD GetPageRanges(nsTArray<int32_t> &aPages);
   116   NS_IMETHOD GetResolution(int32_t *aResolution);
   117   NS_IMETHOD SetResolution(int32_t aResolution);
   119   NS_IMETHOD GetDuplex(int32_t *aDuplex);
   120   NS_IMETHOD SetDuplex(int32_t aDuplex);
   122 protected:
   123   nsPrintSettingsGTK(const nsPrintSettingsGTK& src);
   124   nsPrintSettingsGTK& operator=(const nsPrintSettingsGTK& rhs);
   126   virtual nsresult _Clone(nsIPrintSettings **_retval);
   127   virtual nsresult _Assign(nsIPrintSettings *aPS);
   129   GtkUnit GetGTKUnit(int16_t aGeckoUnit);
   130   void SaveNewPageSize();
   132   /**
   133    * Re-initialize mUnwriteableMargin with values from mPageSetup.
   134    * Should be called whenever mPageSetup is initialized or overwritten.
   135    */
   136   void InitUnwriteableMargin();
   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;
   148   bool mPrintSelectionOnly;
   149 };
   151 NS_DEFINE_STATIC_IID_ACCESSOR(nsPrintSettingsGTK, NS_PRINTSETTINGSGTK_IID)
   154 #endif // nsPrintSettingsGTK_h_

mercurial