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

okular

misc.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005   by Piotr Szymanski <niedakh@gmail.com>           *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  ***************************************************************************/
00009 
00010 #include "core/misc.h"
00011 
00012 #include <kdebug.h>
00013 
00014 #include "debug_p.h"
00015 
00016 using namespace Okular;
00017 
00018 class TextSelection::Private
00019 {
00020     public:
00021         int direction;
00022         int it[2];
00023         NormalizedPoint cur[2];
00024 };
00025 
00026 TextSelection::TextSelection( const NormalizedPoint & a, const NormalizedPoint & b )
00027     : d( new Private )
00028 {
00029     if (b.y-a.y<0 || (b.y-a.y==0 && b.x-a.x <0))
00030         d->direction = 1;
00031     else
00032         d->direction = 0;
00033 
00034     d->cur[0] = a;
00035     d->cur[1] = b;
00036     d->it[d->direction % 2] = -1;
00037     d->it[(d->direction + 1) % 2] = -1;
00038 }
00039 
00040 TextSelection::~TextSelection()
00041 {
00042     delete d;
00043 }
00044 
00045 void TextSelection::end( const NormalizedPoint & p )
00046 {
00047   // changing direction as in 2b , assuming the bool->int conversion is correct
00048   int dir1 = d->direction;
00049   d->direction = (p.y - d->cur[0].y < 0 || (p.y - d->cur[0].y == 0 && p.x - d->cur[0].x < 0));
00050   if (d->direction != dir1)
00051     kDebug(OkularDebug) << "changing direction in selection";
00052 
00053   d->cur[1] = p;
00054 }
00055 
00056 void TextSelection::itE( int p )
00057 {
00058     d->it[(d->direction + 1) % 2] = p;
00059 }
00060 
00061 void TextSelection::itB( int p )
00062 {
00063     d->it[(d->direction) % 2] = p;
00064 }
00065 
00066 int TextSelection::direction() const
00067 {
00068     return d->direction;
00069 }
00070 
00071 NormalizedPoint TextSelection::start() const
00072 {
00073     return d->cur[d->direction % 2];
00074 }
00075 
00076 NormalizedPoint TextSelection::end() const
00077 {
00078     return d->cur[(d->direction + 1) % 2];
00079 }
00080 
00081 int TextSelection::itB() const
00082 {
00083     return d->it[d->direction % 2];
00084 }
00085 
00086 int TextSelection::itE() const
00087 {
00088     return d->it[(d->direction + 1) % 2];
00089 }

okular

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

kdegraphics

Skip menu "kdegraphics"
  • okular
Generated for kdegraphics by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal