Okular

misc.h
1 /*
2  SPDX-FileCopyrightText: 2005 Piotr Szymanski <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #ifndef _OKULAR_MISC_H_
8 #define _OKULAR_MISC_H_
9 
10 #include "area.h"
11 #include "okularcore_export.h"
12 
13 namespace Okular
14 {
15 /**
16  @short Wrapper around the information needed to generate the selection area
17  There are two assumptions inside this class:
18  1. the start never changes, one instance of this class is used for one selection,
19  therefore the start of the selection will not change, only end and direction of
20  the selection will change.
21  By direction we mean the direction in which the end moves in relation to the start,
22  forward selection is when end is after the start, backward when its before.
23 
24  2. The following changes might appear during selection:
25  a. the end moves without changing the direction (it can move up and down but not past the start):
26  only itE will be updated
27  b. the end moves with changing the direction then itB becomes itE if the previous direction was forward
28  or itE becomes itB
29 
30  3. Internally it that is related to the start cursor is always at it[0] while it related to end is it[1],
31  transition between meanings (itB/itE) is done with dir modifier;
32 */
33 class OKULARCORE_EXPORT TextSelection
34 {
35 public:
36  /**
37  * Creates a new text selection with the given @p start and @p end point.
38  */
39  TextSelection(const NormalizedPoint &start, const NormalizedPoint &end);
40 
41  /**
42  * Destroys the text selection.
43  */
44  ~TextSelection();
45 
46  TextSelection(const TextSelection &) = delete;
47  TextSelection &operator=(const TextSelection &) = delete;
48 
49  /**
50  * Changes the end point of the selection to the given @p point.
51  */
52  void end(const NormalizedPoint &point);
53 
54  void itE(int pos);
55  void itB(int pos);
56 
57  /**
58  * Returns the direction of the selection.
59  */
60  int direction() const;
61 
62  /**
63  * Returns the start point of the selection.
64  */
65  NormalizedPoint start() const;
66 
67  /**
68  * Returns the end point of the selection.
69  */
70  NormalizedPoint end() const;
71 
72  int itB() const;
73  int itE() const;
74 
75 private:
76  class Private;
77  Private *const d;
78 };
79 
80 }
81 
82 #endif
NormalizedPoint is a helper class which stores the coordinates of a normalized point.
Definition: area.h:116
global.h
Definition: action.h:16
Wrapper around the information needed to generate the selection area There are two assumptions inside...
Definition: misc.h:33
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Nov 29 2021 22:32:19 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.