Back to index

lightning-sunbird  0.9+nobinonly
nsPrintOptionsImpl.h
Go to the documentation of this file.
00001 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is the Mozilla browser.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications, Inc.
00020  * Portions created by the Initial Developer are Copyright (C) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Travis Bogard <travis@netscape.com>
00025  *   Jessica Blanco <jblanco@us.ibm.com>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #ifndef nsPrintOptionsImpl_h__
00042 #define nsPrintOptionsImpl_h__
00043 
00044 #include "nsCOMPtr.h"
00045 #include "nsIPrintOptions.h"
00046 #include "nsIPrintSettingsService.h"
00047 #include "nsIPrefBranch.h"
00048 
00049 #undef  IMETHOD_VISIBILITY
00050 #define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
00051 
00055 class NS_GFX nsPrintOptions : public nsIPrintOptions, public
00056                               nsIPrintSettingsService
00057 {
00058 public:
00059   NS_DECL_ISUPPORTS
00060   NS_DECL_NSIPRINTOPTIONS
00061   NS_DECL_NSIPRINTSETTINGSSERVICE
00062 
00069   virtual nsresult Init();
00070 
00071   nsPrintOptions();
00072   virtual ~nsPrintOptions();
00073 
00074 protected:
00075   void ReadBitFieldPref(const char * aPrefId, PRInt32 anOption);
00076   void WriteBitFieldPref(const char * aPrefId, PRInt32 anOption);
00077   void ReadJustification(const char * aPrefId, PRInt16& aJust,
00078                          PRInt16 aInitValue);
00079   void WriteJustification(const char * aPrefId, PRInt16 aJust);
00080   void ReadInchesToTwipsPref(const char * aPrefId, nscoord&  aTwips,
00081                              const char * aMarginPref);
00082   void WriteInchesFromTwipsPref(const char * aPrefId, nscoord aTwips);
00083 
00084   nsresult ReadPrefString(const char * aPrefId, nsAString& aString);
00089   nsresult WritePrefString(const char * aPrefId, const nsAString& aString);
00090   nsresult WritePrefString(PRUnichar*& aStr, const char* aPrefId);
00091   nsresult ReadPrefDouble(const char * aPrefId, double& aVal);
00092   nsresult WritePrefDouble(const char * aPrefId, double aVal);
00093 
00100   virtual nsresult ReadPrefs(nsIPrintSettings* aPS, const nsAString&
00101                              aPrinterName, PRUint32 aFlags);
00108   virtual nsresult WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrefName,
00109                               PRUint32 aFlags);
00110   const char* GetPrefName(const char *     aPrefName,
00111                           const nsAString&  aPrinterName);
00112 
00119   virtual nsresult _CreatePrintSettings(nsIPrintSettings **_retval);
00120 
00121   // Members
00122   nsCOMPtr<nsIPrintSettings> mGlobalPrintSettings;
00123 
00124   nsCString mPrefName;
00125 
00126   nsCOMPtr<nsIPrefBranch> mPrefBranch;
00127 
00128   nsFont* mDefaultFont;
00129 private:
00130   // These are not supported and are not implemented!
00131   nsPrintOptions(const nsPrintOptions& x);
00132   nsPrintOptions& operator=(const nsPrintOptions& x);
00133 };
00134 
00135 #undef  IMETHOD_VISIBILITY
00136 #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
00137 
00138 #endif /* nsPrintOptionsImpl_h__ */