1 /*
2  * Copyright (C) 2002 - David W. Durham
3  *
4  * This file is part of ReZound, an audio editing application.
5  *
6  * ReZound is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published
8  * by the Free Software Foundation; either version 2 of the License,
9  * or (at your option) any later version.
10  *
11  * ReZound is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
19  */
20 
21 #ifndef __FXWaveScrollArea
22 #define __FXWaveScrollArea
23 
24 #include "../../config/common.h"
25 #include "fox_compat.h"
26 
27 #include "FXWaveCanvas.h" // for FXWaveCanvas::HorzRecenterTypes
28 
29 class FXRezWaveView;
30 
31 class CLoadedSound;
32 #include "../backend/CSound_defs.h"
33 
34 #include "../backend/Edits/CCueAction.h"
35 
36 class FXWaveScrollArea : public FXScrollArea
37 {
38 	FXDECLARE(FXWaveScrollArea)
39 public:
40 	FXWaveScrollArea(FXRezWaveView *parent,CLoadedSound *_loadedSound);
41 	virtual ~FXWaveScrollArea();
42 
43 	void updateFromEdit(bool undoing=false);
44 
45 						// ??? might be able to simply implement by setting the zoom factor and then calling centerStartPos or centerStopPos
46 	void setHorzZoom(double v,FXWaveCanvas::HorzRecenterTypes horzRecenterType);
47 	double getHorzZoom() const;
48 
49 	void setVertZoom(float v);
50 	float getVertZoom() const;
51 
52 	void setHorzOffset(sample_pos_t offset);
53 	sample_pos_t getHorzOffset() const;
54 
55 	void setVertOffset(int offset);
56 	int getVertOffset() const;
57 
58 	void centerTime(const sample_pos_t time);
59 	void centerStartPos();
60 	void centerStopPos();
61 	void showAmount(double seconds,sample_pos_t pos,int marginPixels=0);
62 
63 	void drawPlayPosition(sample_pos_t dataPosition,bool justErasing,bool scrollToMakeVisible);
64 	const sample_pos_t getSamplePosForScreenX(FXint x) const;
65 
66 	const FXint getCanvasWidth() const;
67 	const FXint getCueScreenX(size_t cueIndex) const;
68 
69 
70 	void updateFromSelectionChange(FXWaveCanvas::LastChangedPositions lastChangedPosition=FXWaveCanvas::lcpNone);
71 
72 
73 	// events I overload
74 	virtual FXint getContentWidth();
75 	virtual FXint getContentHeight();
76 	virtual void moveContents(FXint x,FXint y);
77 	virtual void layout();
78 
79 	void redraw();
80 	void redraw(FXint x,FXint w);
81 
82 	// events I get by message (actually sent by FXWaveCanvas since that's what will be clicked on)
83 	long onResize(FXObject *object,FXSelector sel,void *ptr);
84 	long onMouseDown(FXObject *object,FXSelector sel,void *ptr);
85 	long onMouseUp(FXObject *object,FXSelector sel,void *ptr);
86 	long onMouseMove(FXObject *object,FXSelector sel,void *ptr);
87 
88 	long onAutoScroll(FXObject *object,FXSelector sel,void *ptr);
89 
90 	long onHMouseWheel(FXObject *object,FXSelector sel,void *ptr);
91 
92 	enum
93 	{
94 		ID_CANVAS=FXScrollArea::ID_LAST,
95 		ID_LAST
96 	};
97 
98 protected:
FXWaveScrollArea()99 	FXWaveScrollArea() {}
100 
101 private:
102 	friend class FXWaveRuler; // so it can cause an auto scroll and so it can call canvas->repaint()
103 
104 	FXRezWaveView *parent;
105 	FXWaveCanvas *canvas;
106 	CLoadedSound *loadedSound;
107 	bool draggingSelectStart,draggingSelectStop;
108 
109 	bool momentaryPlaying;
110 
111 	CAddCueActionFactory *addCueActionFactory;
112 
113 	void handleMouseMoveSelectChange(FXint X);
114 };
115 
116 
117 #endif
118