File indexing completed on 2024-04-28 04:32:44
0001 /* 0002 SPDX-FileCopyrightText: 2005 Piotr Szymanski <niedakh@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef _OKULAR_MISC_H_ 0008 #define _OKULAR_MISC_H_ 0009 0010 #include "area.h" 0011 #include "okularcore_export.h" 0012 0013 namespace Okular 0014 { 0015 /** 0016 @short Wrapper around the information needed to generate the selection area 0017 There are two assumptions inside this class: 0018 1. the start never changes, one instance of this class is used for one selection, 0019 therefore the start of the selection will not change, only end and direction of 0020 the selection will change. 0021 By direction we mean the direction in which the end moves in relation to the start, 0022 forward selection is when end is after the start, backward when its before. 0023 0024 2. The following changes might appear during selection: 0025 a. the end moves without changing the direction (it can move up and down but not past the start): 0026 only itE will be updated 0027 b. the end moves with changing the direction then itB becomes itE if the previous direction was forward 0028 or itE becomes itB 0029 0030 3. Internally it that is related to the start cursor is always at it[0] while it related to end is it[1], 0031 transition between meanings (itB/itE) is done with dir modifier; 0032 */ 0033 class OKULARCORE_EXPORT TextSelection 0034 { 0035 public: 0036 /** 0037 * Creates a new text selection with the given @p start and @p end point. 0038 */ 0039 TextSelection(const NormalizedPoint &start, const NormalizedPoint &end); 0040 0041 /** 0042 * Destroys the text selection. 0043 */ 0044 ~TextSelection(); 0045 0046 TextSelection(const TextSelection &) = delete; 0047 TextSelection &operator=(const TextSelection &) = delete; 0048 0049 /** 0050 * Changes the end point of the selection to the given @p point. 0051 */ 0052 void end(const NormalizedPoint &point); 0053 0054 void itE(int pos); 0055 void itB(int pos); 0056 0057 /** 0058 * Returns the direction of the selection. 0059 */ 0060 int direction() const; 0061 0062 /** 0063 * Returns the start point of the selection. 0064 */ 0065 NormalizedPoint start() const; 0066 0067 /** 0068 * Returns the end point of the selection. 0069 */ 0070 NormalizedPoint end() const; 0071 0072 int itB() const; 0073 int itE() const; 0074 0075 private: 0076 class Private; 0077 Private *const d; 0078 }; 0079 0080 } 0081 0082 #endif