summaryrefslogtreecommitdiffstats
path: root/src/svnfrontend/graphtree/pannerview.cpp
blob: 5731f5d9d355286ad8a477f78d596cd7e2243c63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/***************************************************************************
 *   Copyright (C) 2006-2007 by Rajko Albrecht                             *
 *   ral@alwins-world.de                                                   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/
#include "pannerview.h"
#include <tqpainter.h>

PannerView::PannerView(TQWidget* parent, const char* name)
    : TQCanvasView(parent, name,WNoAutoErase | WStaticContents )
{
    m_Moving = false;
    viewport()->setBackgroundMode(TQt::NoBackground);
    setBackgroundMode(TQt::NoBackground);
}

PannerView::~PannerView()
{
}

void PannerView::drawContents(TQPainter* p,  int clipx, int clipy, int clipw, int cliph)
{
    p->save();
    TQCanvasView::drawContents(p,clipx,clipy,clipw,cliph);
    p->restore();
    if (m_ZoomRect.isValid()) {
        p->setPen(red.dark());
        p->drawRect(m_ZoomRect);
        p->setPen( red);
        p->drawRect(TQRect(m_ZoomRect.x()+1, m_ZoomRect.y()+1,
            m_ZoomRect.width()-2, m_ZoomRect.height()-2));
    }
}

void PannerView::setZoomRect(const TQRect& theValue)
{
    TQRect oldRect = m_ZoomRect;
    m_ZoomRect = theValue;
    updateContents(oldRect);
    updateContents(m_ZoomRect);
}

/*!
    \fn PannerView::contentsMouseMoveEvent(TQMouseEvent* e)
 */
void PannerView::contentsMouseMoveEvent(TQMouseEvent* e)
{
    if (m_Moving) {
        emit zoomRectMoved(e->pos().x() - m_LastPos.x(), e->pos().y() - m_LastPos.y());
        m_LastPos = e->pos();
    }
}

/*!
    \fn PannerView::contentsMousePressEvent(TQMouseEvent* e)
 */
void PannerView::contentsMousePressEvent(TQMouseEvent* e)
{
    if (m_ZoomRect.isValid()) {
        if (!m_ZoomRect.contains(e->pos())) {
            emit zoomRectMoved(e->pos().x() - m_ZoomRect.center().x(),
                e->pos().y() - m_ZoomRect.center().y());
        }
        m_Moving = true;
        m_LastPos = e->pos();
    }
}

/*!
    \fn PannerView::contentsMouseReleaseEvent(TQMouseEvent*)
 */
void PannerView::contentsMouseReleaseEvent(TQMouseEvent*)
{
    m_Moving = false;
    emit zoomRectMoveFinished();
}

/*!
    \fn PannerView::updateCurrentRect()
 */
void PannerView::updateCurrentRect()
{
    if (m_ZoomRect.isValid()) updateContents(m_ZoomRect);
}

#include "pannerview.moc"