]> git.lyx.org Git - lyx.git/blob - src/support/types.h
LyX 2.1 will support only Qt>=4.5.
[lyx.git] / src / support / types.h
1 // -*- C++ -*-
2 /**
3  * \file types.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * Provide a set of typedefs for commonly used things like sizes and
8  * indices wile trying to stay compatible with types used
9  * by the standard containers.
10  *
11  * \author André Pönitz
12  *
13  * Full author contact details are available in file CREDITS.
14  */
15
16 #ifndef LYX_TYPES_H
17 #define LYX_TYPES_H
18
19 #include <cstddef>
20
21 namespace lyx {
22
23         /// a type for positions used in paragraphs
24         // needs to be signed for a while to hold the special value -1 that is
25         // used there
26         typedef ptrdiff_t  pos_type;
27
28         /// a type for paragraph offsets
29         // FIXME: should be unsigned as well.
30         // however, simply changing it breaks a downward loop somewhere...
31         typedef ptrdiff_t  pit_type;
32
33         /// a type for the nesting depth of a paragraph
34         typedef size_t     depth_type;
35
36 // set this to '0' if you want to have really safe types
37 #if 1
38
39         /// a type for sizes
40         typedef size_t     size_type;
41
42 #else
43
44         // These structs wrap simple things to make them distinguishible
45         // to the compiler.
46         // It's a shame that different typedefs are not "really" different
47
48         struct size_type {
49                 ///
50                 typedef size_t  base_type;
51                 ///
52                 size_type(base_type t) { data_ = t; }
53                 ///
54                 operator base_type() const { return data_; }
55                 ///
56                 private:
57                 base_type data_;
58         };
59
60 #endif
61
62         ///
63         enum word_location {
64                 // the word around the cursor, only if the cursor is
65                 //not at a boundary
66                 WHOLE_WORD_STRICT,
67                 // the word around the cursor
68                 WHOLE_WORD,
69                 /// the word begining from the cursor position
70                 PARTIAL_WORD,
71                 /// the word around the cursor or before the cursor
72                 PREVIOUS_WORD,
73                 /// the next word (not yet used)
74                 NEXT_WORD
75         };
76
77         ///
78         enum PageSides {
79                 ///
80                 OneSide,
81                 ///
82                 TwoSides
83         };
84
85 } // namespace lyx
86
87 #endif // LYX_TYPES_H