Subversion Repositories Scribus

Rev

Rev 18181 | Rev 20189 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
13839 fschmid 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
7
/***************************************************************************
8
*                                                                         *
9
*   This program is free software; you can redistribute it and/or modify  *
10
*   it under the terms of the GNU General Public License as published by  *
11
*   the Free Software Foundation; either version 2 of the License, or     *
12
*   (at your option) any later version.                                   *
13
*                                                                         *
14
***************************************************************************/
15
#include <osgViewer/Viewer>
16
#include <osgViewer/ViewerEventHandlers>
17
#include <osgGA/TrackballManipulator>
18
 
14522 jghali 19
#include "scconfig.h"
20
 
13839 fschmid 21
#include <QtCore>
22
#include <QtGui>
23
#include <QtOpenGL>
24
#include <iostream>
25
#include <iomanip>
26
#include <fstream>
18181 fschmid 27
#ifdef HAVE_UNISTD_H
28
#include <unistd.h>
14522 jghali 29
#endif
13839 fschmid 30
#include <cstdlib>
31
#include <cassert>
32
#include <string>
33
#include "util_icon.h"
34
#include "AdapterWidget.h"
35
 
18194 fschmid 36
AdapterWidget::AdapterWidget ( QWidget * parent, const char * name, const QGLWidget * shareWidget) : QGLWidget ( parent, shareWidget)
13839 fschmid 37
{
38
        _gw = new osgViewer::GraphicsWindowEmbedded ( 0,0,width(),height() );
39
        setFocusPolicy ( Qt::ClickFocus );
40
        button = 0;
41
}
42
 
43
void AdapterWidget::resizeGL ( int width, int height )
44
{
45
        _gw->getEventQueue()->windowResize ( 0, 0, width, height );
46
        _gw->resized ( 0,0,width,height );
47
}
48
 
49
void AdapterWidget::keyPressEvent ( QKeyEvent* event )
50
{
18194 fschmid 51
        _gw->getEventQueue()->keyPress ( ( osgGA::GUIEventAdapter::KeySymbol ) * ( event->text().toLatin1().data() ) );
13839 fschmid 52
}
53
 
54
void AdapterWidget::keyReleaseEvent ( QKeyEvent* event )
55
{
18194 fschmid 56
        _gw->getEventQueue()->keyRelease ( ( osgGA::GUIEventAdapter::KeySymbol ) * ( event->text().toLatin1().data() ) );
13839 fschmid 57
}
58
 
59
void AdapterWidget::mousePressEvent ( QMouseEvent* event )
60
{
61
        switch ( event->button() )
62
        {
63
                case Qt::LeftButton:
18181 fschmid 64
                        qApp->setOverrideCursor(QCursor(Qt::OpenHandCursor));
13839 fschmid 65
                        button = 1;
66
                        break;
67
                case Qt::MidButton:
18181 fschmid 68
                        qApp->setOverrideCursor(QCursor(Qt::SizeAllCursor));
13839 fschmid 69
                        button = 2;
70
                        break;
71
                case Qt::RightButton:
18181 fschmid 72
                        qApp->setOverrideCursor(QCursor(loadIcon("LupeZ.xpm")));
13839 fschmid 73
                        button = 3;
74
                        break;
75
                case Qt::NoButton:
18181 fschmid 76
                        qApp->setOverrideCursor(QCursor(Qt::ArrowCursor));
13839 fschmid 77
                        button = 0;
78
                        break;
79
                default:
18181 fschmid 80
                        qApp->setOverrideCursor(QCursor(Qt::ArrowCursor));
13839 fschmid 81
                        button = 0;
82
                        break;
83
        }
84
        _gw->getEventQueue()->mouseButtonPress ( event->x(), event->y(), button );
85
}
86
 
87
void AdapterWidget::mouseReleaseEvent ( QMouseEvent* event )
88
{
89
        switch ( event->button() )
90
        {
91
                case ( Qt::LeftButton ) : button = 1; break;
92
                case ( Qt::MidButton ) : button = 2; break;
93
                case ( Qt::RightButton ) : button = 3; break;
94
                case ( Qt::NoButton ) : button = 0; break;
95
                default: button = 0; break;
96
        }
18181 fschmid 97
        qApp->restoreOverrideCursor();
13839 fschmid 98
        _gw->getEventQueue()->mouseButtonRelease ( event->x(), event->y(), button );
99
}
100
 
101
void AdapterWidget::mouseMoveEvent ( QMouseEvent* event )
102
{
103
        _gw->getEventQueue()->mouseMotion ( event->x(), event->y() );
104
        emit mouseMoved();
105
}