Subversion Repositories Scribus

Rev

Rev 13839 | Rev 18181 | 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>
14522 jghali 27
#ifdef HAVE_UNISTD_H
28
#include <unistd.h>
29
#endif
13839 fschmid 30
#include <cstdlib>
31
#include <cassert>
32
#include <string>
33
#include "util_icon.h"
34
#include "AdapterWidget.h"
35
 
36
AdapterWidget::AdapterWidget ( QWidget * parent, const char * name, const QGLWidget * shareWidget, Qt::WFlags f ) : QGLWidget ( parent, shareWidget, f )
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
{
51
        _gw->getEventQueue()->keyPress ( ( osgGA::GUIEventAdapter::KeySymbol ) * ( event->text().toAscii().data() ) );
52
}
53
 
54
void AdapterWidget::keyReleaseEvent ( QKeyEvent* event )
55
{
56
        _gw->getEventQueue()->keyRelease ( ( osgGA::GUIEventAdapter::KeySymbol ) * ( event->text().toAscii().data() ) );
57
}
58
 
59
void AdapterWidget::mousePressEvent ( QMouseEvent* event )
60
{
61
        switch ( event->button() )
62
        {
63
                case Qt::LeftButton:
64
                        qApp->changeOverrideCursor(QCursor(Qt::OpenHandCursor));
65
                        button = 1;
66
                        break;
67
                case Qt::MidButton:
68
                        qApp->changeOverrideCursor(QCursor(Qt::SizeAllCursor));
69
                        button = 2;
70
                        break;
71
                case Qt::RightButton:
72
                        qApp->changeOverrideCursor(QCursor(loadIcon("LupeZ.xpm")));
73
                        button = 3;
74
                        break;
75
                case Qt::NoButton:
76
                        button = 0;
77
                        break;
78
                default:
79
                        button = 0;
80
                        break;
81
        }
82
        _gw->getEventQueue()->mouseButtonPress ( event->x(), event->y(), button );
83
}
84
 
85
void AdapterWidget::mouseReleaseEvent ( QMouseEvent* event )
86
{
87
        switch ( event->button() )
88
        {
89
                case ( Qt::LeftButton ) : button = 1; break;
90
                case ( Qt::MidButton ) : button = 2; break;
91
                case ( Qt::RightButton ) : button = 3; break;
92
                case ( Qt::NoButton ) : button = 0; break;
93
                default: button = 0; break;
94
        }
95
        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
96
        _gw->getEventQueue()->mouseButtonRelease ( event->x(), event->y(), button );
97
}
98
 
99
void AdapterWidget::mouseMoveEvent ( QMouseEvent* event )
100
{
101
        _gw->getEventQueue()->mouseMotion ( event->x(), event->y() );
102
        emit mouseMoved();
103
}