1 /*
2  * ChannelView.h
3  *
4  * Copyright (C) 1999 Stephen F. White
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but 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 (see the file "COPYING" for details); if
18  * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19  * Cambridge, MA 02139, USA.
20  */
21 
22 #pragma once
23 
24 // undefine if you do not need the blinking channelview cursor
25 #define BLINKTIMER 1
26 
27 #include "Rect.h"
28 #include "Point.h"
29 #include "SceneView.h"
30 
31 class Node;
32 class DuneDoc;
33 
34 enum {
35     NORMAL,
36     DRAGGING,
37     SELECTING
38 };
39 
40 #include "swttypedef.h"
41 
42 class Interpolator;
43 
44 class ChannelView : public SceneView
45 {
46 public:
47                         ChannelView(Scene *scene, SWND parent);
48     virtual            ~ChannelView();
49 
50     virtual void        OnDraw(int x, int y, int width, int height,
51                                bool update = false);
52     virtual void        OnUpdate(SceneView *sender, int type, Hint *hint);
53 
54     virtual void        OnLButtonDown(int x, int y, int modifiers);
55     virtual void        OnLButtonUp(int x, int y, int modifiers);
56     virtual void        OnMouseMove(int x, int y, int modifiers);
57     virtual void        OnFastForward();
58     virtual void        OnRewind();
59     virtual void        OnEditDelete();
60     virtual void        OnSize(int width, int height);
61 //    virtual void      OnUpdateEditDelete(CCmdUI* pCmdUI);
62 
getName(void)63     const char         *getName(void) const { return "ChannelView"; }
64 
65     virtual void        DeleteLastSelection(void);
66     virtual void        GoToNextKey(void);
67     virtual void        GoToLastKey(void);
68 
69     void                CopyLastSelection(void);
70     void                PasteLastSelection(void);
71     void                PasteSymetricLastSelection(int direction);
72 
canPaste()73     bool                canPaste() { return m_copiedChannels != -1; }
74 
75 #ifdef BLINKTIMER
76     int                 OnBlinkTimer();
77 #endif
78     int                 OnAutoScrollTimer();
79 
80 private:
81     void                AutoScale();
82     void                DoMouseMove(int x, int y);
83     void                CheckAutoScroll(int x, int y);
84     void                DrawRulers(SDC dc, float xMin, float xMax,
85                                            float yMin, float yMax);
86     void                DrawKeys(SDC dc);
87     void                DrawSelection(SDC dc);
88     void                SetSelection(int pos);
89     void                InvalidateSelection();
90     bool                PointNearLine(int x, int y, int x1, int y1,
91                                                     int x2, int y2) const;
92     void                AddKey(int chan, int key, int x);
93     bool                isDrawableChannel(int chan);
94     void                findDrawableChannels(void);
95 
96 private:
97     Interpolator       *m_interpolator;
98     int                 m_selectedChannel;
99     int                 m_selectedKey;
100     float               m_yMin, m_yMax;
101     float               m_xScale;
102     float               m_yScale;
103     int                 m_state;
104     Rect                m_rect;
105     int                 m_anchor;
106     int                 m_lastX;
107     int                 m_selMin;
108     int                 m_selMax;
109 #ifdef BLINKTIMER
110     STIMER              m_timer;
111 #endif
112     STIMER              m_autoScrollTimer;
113     bool                m_cursorOn;
114     bool                m_autoScrolling;
115     int                 m_autoScrollPX, m_autoScrollPY;
116     MyArray<bool>       m_multipleValuesInChannel;
117     MyArray<float>      m_copiedValues;
118     int                 m_copiedChannels;
119 };
120