1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/gtk/nsPaperPS.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,93 @@ 1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* ex: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */ 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 + 1.11 +#ifndef _PAPERPS_H_ 1.12 +#define _PAPERPS_H_ 1.13 + 1.14 +#include "nsDebug.h" 1.15 + 1.16 +struct nsPaperSizePS_ { 1.17 + const char *name; 1.18 + float width_mm; 1.19 + float height_mm; 1.20 + bool isMetric; // Present to the user in metric, if possible 1.21 +}; 1.22 + 1.23 +class nsPaperSizePS { 1.24 + public: 1.25 + /** --------------------------------------------------- 1.26 + * Constructor 1.27 + */ 1.28 + nsPaperSizePS() { mCurrent = 0; } 1.29 + 1.30 + /** --------------------------------------------------- 1.31 + * @return true if the cursor points past the last item. 1.32 + */ 1.33 + bool AtEnd() { return mCurrent >= mCount; } 1.34 + 1.35 + /** --------------------------------------------------- 1.36 + * Position the cursor at the beginning of the paper size list. 1.37 + * @return VOID 1.38 + */ 1.39 + void First() { mCurrent = 0; } 1.40 + 1.41 + /** --------------------------------------------------- 1.42 + * Advance the cursor to the next item. 1.43 + * @return VOID 1.44 + */ 1.45 + void Next() { 1.46 + NS_ASSERTION(!AtEnd(), "Invalid current item"); 1.47 + mCurrent++; 1.48 + } 1.49 + 1.50 + /** --------------------------------------------------- 1.51 + * Point the cursor to the entry with the given paper name. 1.52 + * @return true if pointing to a valid entry. 1.53 + */ 1.54 + bool Find(const char *aName); 1.55 + 1.56 + /** --------------------------------------------------- 1.57 + * @return a pointer to the name of the current paper size 1.58 + */ 1.59 + const char *Name() { 1.60 + NS_PRECONDITION(!AtEnd(), "Invalid current item"); 1.61 + return mList[mCurrent].name; 1.62 + } 1.63 + 1.64 + /** --------------------------------------------------- 1.65 + * @return the width of the page in millimeters 1.66 + */ 1.67 + float Width_mm() { 1.68 + NS_PRECONDITION(!AtEnd(), "Invalid current item"); 1.69 + return mList[mCurrent].width_mm; 1.70 + } 1.71 + 1.72 + /** --------------------------------------------------- 1.73 + * @return the height of the page in millimeters 1.74 + */ 1.75 + float Height_mm() { 1.76 + NS_PRECONDITION(!AtEnd(), "Invalid current item"); 1.77 + return mList[mCurrent].height_mm; 1.78 + } 1.79 + 1.80 + /** --------------------------------------------------- 1.81 + * @return true if the paper should be presented to 1.82 + * the user in metric units. 1.83 + */ 1.84 + bool IsMetric() { 1.85 + NS_PRECONDITION(!AtEnd(), "Invalid current item"); 1.86 + return mList[mCurrent].isMetric; 1.87 + } 1.88 + 1.89 + private: 1.90 + unsigned int mCurrent; 1.91 + static const nsPaperSizePS_ mList[]; 1.92 + static const unsigned int mCount; 1.93 +}; 1.94 + 1.95 +#endif 1.96 +