widget/gtk/nsPaperPS.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* ex: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */
     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/. */
     8 #ifndef _PAPERPS_H_
     9 #define _PAPERPS_H_
    11 #include "nsDebug.h"
    13 struct nsPaperSizePS_ {
    14     const char *name;
    15     float width_mm;
    16     float height_mm;
    17     bool isMetric;        // Present to the user in metric, if possible
    18 };
    20 class nsPaperSizePS {
    21     public:
    22         /** ---------------------------------------------------
    23          * Constructor
    24          */
    25         nsPaperSizePS() { mCurrent = 0; }
    27         /** ---------------------------------------------------
    28          * @return true if the cursor points past the last item.
    29          */
    30         bool AtEnd() { return mCurrent >= mCount; }
    32         /** ---------------------------------------------------
    33          * Position the cursor at the beginning of the paper size list.
    34          * @return VOID
    35          */
    36         void First() { mCurrent = 0; }
    38         /** ---------------------------------------------------
    39          * Advance the cursor to the next item.
    40          * @return VOID
    41          */
    42         void Next() {
    43             NS_ASSERTION(!AtEnd(), "Invalid current item");
    44             mCurrent++;
    45         }
    47         /** ---------------------------------------------------
    48          * Point the cursor to the entry with the given paper name.
    49          * @return true if pointing to a valid entry.
    50          */
    51         bool Find(const char *aName);
    53         /** ---------------------------------------------------
    54          * @return a pointer to the name of the current paper size
    55          */
    56         const char *Name() {
    57             NS_PRECONDITION(!AtEnd(), "Invalid current item");
    58             return mList[mCurrent].name;
    59         }
    61         /** ---------------------------------------------------
    62          * @return the width of the page in millimeters
    63          */
    64         float Width_mm() {
    65             NS_PRECONDITION(!AtEnd(), "Invalid current item");
    66             return mList[mCurrent].width_mm;
    67         }
    69         /** ---------------------------------------------------
    70          * @return the height of the page in millimeters
    71          */
    72         float Height_mm() {
    73             NS_PRECONDITION(!AtEnd(), "Invalid current item");
    74             return mList[mCurrent].height_mm;
    75         }
    77         /** ---------------------------------------------------
    78          * @return true if the paper should be presented to
    79          *                 the user in metric units.
    80          */
    81         bool IsMetric() {
    82             NS_PRECONDITION(!AtEnd(), "Invalid current item");
    83             return mList[mCurrent].isMetric;
    84         }
    86     private:
    87         unsigned int mCurrent;
    88         static const nsPaperSizePS_ mList[];
    89         static const unsigned int mCount;
    90 };
    92 #endif

mercurial