summaryrefslogtreecommitdiffstats
path: root/kviewshell/pageNumber.h
blob: 9fd48dc6c2763d3e920ee4c90e6d980d0dc86c5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// -*- C++ -*-
//
// pageNumber.h
//
// Part of KVIEWSHELL - A framework for multipage text/gfx viewers
//
// (C) 2004 Stefan Kebekus
// Distributed under the GPL

// Add header files alphabetically

#ifndef PAGENUMBER_H
#define PAGENUMBER_H

#include <tqglobal.h>


/** \brief Class to represent a page number
    
The class PageNumber is really nothing but an alias for TQ_UINT16, and
can be casted to and from TQ_UINT16. It is used in kviewshell to remind
the programmer of the convention that page numbers start at '1' (for
'first page'), and that the value '0' means 'illegal page number' or
'no page number'. Accordingly, the value '0' is also named
PageNumber::invalidPage, and there is a trivial method isInvalid()
that checks if the page number is 0.

@author Stefan Kebekus <kebekus@kde.org>
@version 1.0 0
*/

class PageNumber
{
 public:
  enum pageNums {
    invalidPage   = 0 /*! Invalid page number */
  };

  /** The default constructor sets the page number to 'invalidPage' */
  PageNumber() {pgNum = invalidPage;}

  /** \brief Constructor that sets the page number

  @param num page number that is set initially
  */
  PageNumber(TQ_UINT16 num) {pgNum = num;}

  /** \brief this method implements typecasts from TQ_UINT16 */
  PageNumber &operator=(const TQ_UINT16 p) { pgNum = p; return *this; }

  /** \brief This method implements typecasts to TQ_UINT16 */
  operator TQ_UINT16() const { return pgNum; }

  /** \brief Checks if the page number is invalid

  @returns true, if pgNum != invalidPage, i.e., does not equal 0
  */
  bool isValid() const {return (pgNum != invalidPage);}

 private:
  /** \brief Single number that represents the page number */
  TQ_UINT16 pgNum;
};

#endif