• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

okular

  • sources
  • kde-4.12
  • kdegraphics
  • okular
  • core
misc.cpp
Go to the documentation of this file.
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  ***************************************************************************/
9 
10 #include "core/misc.h"
11 
12 #include <kdebug.h>
13 
14 #include "debug_p.h"
15 
16 using namespace Okular;
17 
18 class TextSelection::Private
19 {
20  public:
21  int direction;
22  int it[2];
23  NormalizedPoint cur[2];
24 };
25 
26 TextSelection::TextSelection( const NormalizedPoint & a, const NormalizedPoint & b )
27  : d( new Private )
28 {
29  if (b.y-a.y<0 || (b.y-a.y==0 && b.x-a.x <0))
30  d->direction = 1;
31  else
32  d->direction = 0;
33 
34  d->cur[0] = a;
35  d->cur[1] = b;
36  d->it[d->direction % 2] = -1;
37  d->it[(d->direction + 1) % 2] = -1;
38 }
39 
40 TextSelection::~TextSelection()
41 {
42  delete d;
43 }
44 
45 void TextSelection::end( const NormalizedPoint & p )
46 {
47  // changing direction as in 2b , assuming the bool->int conversion is correct
48  int dir1 = d->direction;
49  d->direction = (p.y - d->cur[0].y < 0 || (p.y - d->cur[0].y == 0 && p.x - d->cur[0].x < 0));
50  if (d->direction != dir1)
51  kDebug(OkularDebug) << "changing direction in selection";
52 
53  d->cur[1] = p;
54 }
55 
56 void TextSelection::itE( int p )
57 {
58  d->it[(d->direction + 1) % 2] = p;
59 }
60 
61 void TextSelection::itB( int p )
62 {
63  d->it[(d->direction) % 2] = p;
64 }
65 
66 int TextSelection::direction() const
67 {
68  return d->direction;
69 }
70 
71 NormalizedPoint TextSelection::start() const
72 {
73  return d->cur[d->direction % 2];
74 }
75 
76 NormalizedPoint TextSelection::end() const
77 {
78  return d->cur[(d->direction + 1) % 2];
79 }
80 
81 int TextSelection::itB() const
82 {
83  return d->it[d->direction % 2];
84 }
85 
86 int TextSelection::itE() const
87 {
88  return d->it[(d->direction + 1) % 2];
89 }
Okular::NormalizedPoint
NormalizedPoint is a helper class which stores the coordinates of a normalized point.
Definition: area.h:47
Okular::TextSelection::TextSelection
TextSelection(const NormalizedPoint &start, const NormalizedPoint &end)
Creates a new text selection with the given start and end point.
Definition: misc.cpp:26
misc.h
Okular::TextSelection::direction
int direction() const
Returns the direction of the selection.
Definition: misc.cpp:66
Okular::TextSelection::~TextSelection
~TextSelection()
Destroys the text selection.
Definition: misc.cpp:40
debug_p.h
Okular::NormalizedPoint::y
double y
The normalized y coordinate.
Definition: area.h:97
Okular::TextSelection::start
NormalizedPoint start() const
Returns the start point of the selection.
Definition: misc.cpp:71
Okular::TextSelection::end
NormalizedPoint end() const
Returns the end point of the selection.
Definition: misc.cpp:76
OkularDebug
#define OkularDebug
Definition: debug_p.h:13
Okular::NormalizedPoint::x
double x
The normalized x coordinate.
Definition: area.h:92
Okular::TextSelection::itB
int itB() const
Definition: misc.cpp:81
Okular::TextSelection::itE
int itE() const
Definition: misc.cpp:86
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:45:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal