Subversion Repositories Scribus

Rev

Rev 14522 | Go to most recent revision | Details | 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
 
19
#include <QtCore>
20
#include <QtGui>
21
#include <QtOpenGL>
22
#include <iostream>
23
#include <iomanip>
24
#include <fstream>
25
#include <unistd.h>
26
#include <cstdlib>
27
#include <cassert>
28
#include <string>
29
#include "util_icon.h"
30
#include "AdapterWidget.h"
31
 
32
AdapterWidget::AdapterWidget ( QWidget * parent, const char * name, const QGLWidget * shareWidget, Qt::WFlags f ) : QGLWidget ( parent, shareWidget, f )
33
{
34
        _gw = new osgViewer::GraphicsWindowEmbedded ( 0,0,width(),height() );
35
        setFocusPolicy ( Qt::ClickFocus );
36
        button = 0;
37
}
38
 
39
void AdapterWidget::resizeGL ( int width, int height )
40
{
41
        _gw->getEventQueue()->windowResize ( 0, 0, width, height );
42
        _gw->resized ( 0,0,width,height );
43
}
44
 
45
void AdapterWidget::keyPressEvent ( QKeyEvent* event )
46
{
47
        _gw->getEventQueue()->keyPress ( ( osgGA::GUIEventAdapter::KeySymbol ) * ( event->text().toAscii().data() ) );
48
}
49
 
50
void AdapterWidget::keyReleaseEvent ( QKeyEvent* event )
51
{
52
        _gw->getEventQueue()->keyRelease ( ( osgGA::GUIEventAdapter::KeySymbol ) * ( event->text().toAscii().data() ) );
53
}
54
 
55
void AdapterWidget::mousePressEvent ( QMouseEvent* event )
56
{
57
        switch ( event->button() )
58
        {
59
                case Qt::LeftButton:
60
                        qApp->changeOverrideCursor(QCursor(Qt::OpenHandCursor));
61
                        button = 1;
62
                        break;
63
                case Qt::MidButton:
64
                        qApp->changeOverrideCursor(QCursor(Qt::SizeAllCursor));
65
                        button = 2;
66
                        break;
67
                case Qt::RightButton:
68
                        qApp->changeOverrideCursor(QCursor(loadIcon("LupeZ.xpm")));
69
                        button = 3;
70
                        break;
71
                case Qt::NoButton:
72
                        button = 0;
73
                        break;
74
                default:
75
                        button = 0;
76
                        break;
77
        }
78
        _gw->getEventQueue()->mouseButtonPress ( event->x(), event->y(), button );
79
}
80
 
81
void AdapterWidget::mouseReleaseEvent ( QMouseEvent* event )
82
{
83
        switch ( event->button() )
84
        {
85
                case ( Qt::LeftButton ) : button = 1; break;
86
                case ( Qt::MidButton ) : button = 2; break;
87
                case ( Qt::RightButton ) : button = 3; break;
88
                case ( Qt::NoButton ) : button = 0; break;
89
                default: button = 0; break;
90
        }
91
        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
92
        _gw->getEventQueue()->mouseButtonRelease ( event->x(), event->y(), button );
93
}
94
 
95
void AdapterWidget::mouseMoveEvent ( QMouseEvent* event )
96
{
97
        _gw->getEventQueue()->mouseMotion ( event->x(), event->y() );
98
        emit mouseMoved();
99
}