Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* ex: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | |
michael@0 | 8 | #ifndef _PAPERPS_H_ |
michael@0 | 9 | #define _PAPERPS_H_ |
michael@0 | 10 | |
michael@0 | 11 | #include "nsDebug.h" |
michael@0 | 12 | |
michael@0 | 13 | struct nsPaperSizePS_ { |
michael@0 | 14 | const char *name; |
michael@0 | 15 | float width_mm; |
michael@0 | 16 | float height_mm; |
michael@0 | 17 | bool isMetric; // Present to the user in metric, if possible |
michael@0 | 18 | }; |
michael@0 | 19 | |
michael@0 | 20 | class nsPaperSizePS { |
michael@0 | 21 | public: |
michael@0 | 22 | /** --------------------------------------------------- |
michael@0 | 23 | * Constructor |
michael@0 | 24 | */ |
michael@0 | 25 | nsPaperSizePS() { mCurrent = 0; } |
michael@0 | 26 | |
michael@0 | 27 | /** --------------------------------------------------- |
michael@0 | 28 | * @return true if the cursor points past the last item. |
michael@0 | 29 | */ |
michael@0 | 30 | bool AtEnd() { return mCurrent >= mCount; } |
michael@0 | 31 | |
michael@0 | 32 | /** --------------------------------------------------- |
michael@0 | 33 | * Position the cursor at the beginning of the paper size list. |
michael@0 | 34 | * @return VOID |
michael@0 | 35 | */ |
michael@0 | 36 | void First() { mCurrent = 0; } |
michael@0 | 37 | |
michael@0 | 38 | /** --------------------------------------------------- |
michael@0 | 39 | * Advance the cursor to the next item. |
michael@0 | 40 | * @return VOID |
michael@0 | 41 | */ |
michael@0 | 42 | void Next() { |
michael@0 | 43 | NS_ASSERTION(!AtEnd(), "Invalid current item"); |
michael@0 | 44 | mCurrent++; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | /** --------------------------------------------------- |
michael@0 | 48 | * Point the cursor to the entry with the given paper name. |
michael@0 | 49 | * @return true if pointing to a valid entry. |
michael@0 | 50 | */ |
michael@0 | 51 | bool Find(const char *aName); |
michael@0 | 52 | |
michael@0 | 53 | /** --------------------------------------------------- |
michael@0 | 54 | * @return a pointer to the name of the current paper size |
michael@0 | 55 | */ |
michael@0 | 56 | const char *Name() { |
michael@0 | 57 | NS_PRECONDITION(!AtEnd(), "Invalid current item"); |
michael@0 | 58 | return mList[mCurrent].name; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | /** --------------------------------------------------- |
michael@0 | 62 | * @return the width of the page in millimeters |
michael@0 | 63 | */ |
michael@0 | 64 | float Width_mm() { |
michael@0 | 65 | NS_PRECONDITION(!AtEnd(), "Invalid current item"); |
michael@0 | 66 | return mList[mCurrent].width_mm; |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | /** --------------------------------------------------- |
michael@0 | 70 | * @return the height of the page in millimeters |
michael@0 | 71 | */ |
michael@0 | 72 | float Height_mm() { |
michael@0 | 73 | NS_PRECONDITION(!AtEnd(), "Invalid current item"); |
michael@0 | 74 | return mList[mCurrent].height_mm; |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | /** --------------------------------------------------- |
michael@0 | 78 | * @return true if the paper should be presented to |
michael@0 | 79 | * the user in metric units. |
michael@0 | 80 | */ |
michael@0 | 81 | bool IsMetric() { |
michael@0 | 82 | NS_PRECONDITION(!AtEnd(), "Invalid current item"); |
michael@0 | 83 | return mList[mCurrent].isMetric; |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | private: |
michael@0 | 87 | unsigned int mCurrent; |
michael@0 | 88 | static const nsPaperSizePS_ mList[]; |
michael@0 | 89 | static const unsigned int mCount; |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | #endif |
michael@0 | 93 |