compile
[kdegraphics.git] / okular / core / misc.h
blobe45e112607a77214009df5c6612855b01c3a0c5e
1 /***************************************************************************
2 * Copyright (C) 2005 by Piotr Szymanski <niedakh@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #ifndef _OKULAR_MISC_H_
11 #define _OKULAR_MISC_H_
13 #include <okular/core/okular_export.h>
14 #include <okular/core/area.h>
16 namespace Okular {
18 /**
19 @short Wrapper around the information needed to generate the selection area
20 There are two assumptions inside this class:
21 1. the start never changes, one instance of this class is used for one selection,
22 therefore the start of the selection will not change, only end and direction of
23 the selection will change.
24 By direction we mean the direction in which the end moves in relation to the start,
25 forward selection is when end is after the start, backward when its before.
27 2. The following changes might appear during selection:
28 a. the end moves without changing the direction (it can move up and down but not past the start):
29 only itE will be updated
30 b. the end moves with changing the direction then itB becomes itE if the previous direction was forward
31 or itE becomes itB
33 3. Internally it that is related to the start cursor is always at it[0] while it related to end is it[1],
34 transition between meanings (itB/itE) is done with dir modifier;
36 class OKULAR_EXPORT TextSelection
38 public:
39 /**
40 * Creates a new text selection with the given @p start and @p end point.
42 TextSelection( const NormalizedPoint &start, const NormalizedPoint &end );
44 /**
45 * Destroys the text selection.
47 ~TextSelection();
49 /**
50 * Changes the end point of the selection to the given @p point.
52 void end( const NormalizedPoint &point );
54 void itE( int pos );
55 void itB( int pos );
57 /**
58 * Returns the direction of the selection.
60 int direction() const;
62 /**
63 * Returns the start point of the selection.
65 NormalizedPoint start() const;
67 /**
68 * Returns the end point of the selection.
70 NormalizedPoint end() const;
72 int itB() const;
73 int itE() const;
75 private:
76 class Private;
77 Private* const d;
82 #endif