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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
/*
Rosegarden
A MIDI and audio sequencer and musical notation editor.
This program is Copyright 2000-2008
Guillaume Laurent <glaurent@telegraph-road.org>,
Chris Cannam <cannam@all-day-breakfast.com>,
Richard Bown <richard.bown@ferventsoftware.com>
The moral rights of Guillaume Laurent, Chris Cannam, and Richard
Bown to claim authorship of this work have been asserted.
Other copyrights also apply to some parts of this work. Please
see the AUTHORS file and individual file headers for details.
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. See the file
COPYING included with this distribution for more information.
*/
#ifndef _RG_ROSEGARDENCANVASVIEW_H_
#define _RG_ROSEGARDENCANVASVIEW_H_
#include <tqpoint.h>
#include <tqtimer.h>
#include <tqcanvas.h>
#include <tqdatetime.h>
#include <tqwmatrix.h>
class TQWidget;
class TQWheelEvent;
class TQScrollBar;
class TQResizeEvent;
namespace Rosegarden
{
/**
* A TQCanvasView with an auxiliary horiz. scrollbar
* That scrollbar should be provided by the parent widget
* (typically an EditView). The RosegardenCanvasView keeps
* the auxilliary horiz. scrollbar range in sync with the
* one of its own scrollbar with slotUpdate().
*/
class RosegardenCanvasView : public TQCanvasView
{
Q_OBJECT
public:
RosegardenCanvasView(TQCanvas*,
TQWidget* parent=0, const char* name=0, WFlags f=0);
/**
* EditTool::handleMouseMove() returns a OR-ed combination of these
* to indicate which direction to scroll to
*/
enum {
NoFollow = 0x0,
FollowHorizontal = 0x1,
FollowVertical = 0x2
};
/**
* Sets the canvas width to be exactly the width needed to show
* all the items
*/
void fitWidthToContents();
/**
* Sets the widget which will be between the scrollable part of the view
* and the horizontal scrollbar
*/
void setBottomFixedWidget(TQWidget*);
void updateBottomWidgetGeometry();
/**
* Sets the widget which will be between the scrollable part of the view
* and the left edge of the view.
*/
void setLeftFixedWidget(TQWidget*);
void updateLeftWidgetGeometry();
/// Map a point with the inverse world matrix
TQPoint inverseMapPoint(const TQPoint& p) { return inverseWorldMatrix().map(p); }
void setSmoothScroll(bool s) { m_smoothScroll = s; }
bool isTimeForSmoothScroll();
void setScrollDirectionConstraint(int d) { m_scrollDirectionConstraint = d; }
bool isAutoScrolling() const { return m_autoScrolling; }
virtual void wheelEvent(TQWheelEvent *);
public slots:
/// Update the RosegardenCanvasView after a change of content
virtual void slotUpdate();
/**
* Scroll horizontally to make the given position visible,
* paging to as to get some visibility of the next screenful
* (for playback etc)
*/
void slotScrollHoriz(int hpos);
/**
* Scroll horizontally to make the given position somewhat
* nearer to visible, scrolling by only "a small distance"
* at a time
*/
void slotScrollHorizSmallSteps(int hpos);
/**
* Scroll vertically to make the given position somewhat
* nearer to visible, scrolling by only "a small distance"
* at a time
*/
void slotScrollVertSmallSteps(int vpos);
/**
* Scroll vertically so as to place the given position
* somewhere near the top of the viewport.
*/
void slotScrollVertToTop(int vpos);
/**
* Set the x and y scrollbars to a particular position
*/
void slotSetScrollPos(const TQPoint &);
void startAutoScroll();
void startAutoScroll(int directionConstraint);
void stopAutoScroll();
void doAutoScroll();
signals:
void bottomWidgetHeightChanged(int);
void zoomIn();
void zoomOut();
protected:
virtual void resizeEvent(TQResizeEvent*);
virtual void setHBarGeometry(TQScrollBar &hbar, int x, int y, int w, int h);
virtual TQScrollBar* getMainHorizontalScrollBar() { return horizontalScrollBar(); }
//--------------- Data members ---------------------------------
enum ScrollDirection { None, Top, Bottom, Left, Right };
TQWidget* m_bottomWidget;
int m_currentBottomWidgetHeight;
TQWidget* m_leftWidget;
bool m_smoothScroll;
int m_smoothScrollTimeInterval;
float m_minDeltaScroll;
TQTime m_scrollTimer;
TQTime m_scrollAccelerationTimer;
TQTimer m_autoScrollTimer;
int m_autoScrollTime;
int m_autoScrollAccel;
TQPoint m_previousP;
int m_autoScrollXMargin;
int m_autoScrollYMargin;
ScrollDirection m_currentScrollDirection;
int m_scrollDirectionConstraint;
bool m_autoScrolling;
static const int DefaultSmoothScrollTimeInterval;
static const double DefaultMinDeltaScroll;
static const int AutoscrollMargin;
static const int InitialScrollTime;
static const int InitialScrollAccel;
static const int MaxScrollDelta;
static const double ScrollAccelValue;
};
}
#endif
|