Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

/home/pete/Work/TSE3.svn/tse3/src/tse3/PhraseEdit.h

Go to the documentation of this file.
00001 /*
00002  * @(#)PhraseEdit.h 3.00 19 May 1999
00003  *
00004  * Copyright (c) 2000 Pete Goodliffe (pete@cthree.org)
00005  *
00006  * This file is part of TSE3 - the Trax Sequencer Engine version 3.00.
00007  *
00008  * This library is modifiable/redistributable under the terms of the GNU
00009  * General Public License.
00010  *
00011  * You should have received a copy of the GNU General Public License along
00012  * with this program; see the file COPYING. If not, write to the Free Software
00013  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00014  *
00015  */
00016 
00017 #ifndef TSE3_PHRASEEDIT_H
00018 #define TSE3_PHRASEEDIT_H
00019 
00020 #include "tse3/listen/PhraseEdit.h"
00021 
00022 #include "tse3/Notifier.h"
00023 #include "tse3/MidiData.h"
00024 
00025 #include <string>
00026 #include <cstddef>
00027 
00028 namespace TSE3
00029 {
00030     class Phrase;
00031     class PhraseList;
00032 
00110     class PhraseEdit : public MidiData,
00111                        public Notifier<PhraseEditListener>
00112     {
00113         public:
00114 
00128             explicit PhraseEdit(int noEvents = defaultSize);
00129 
00130             virtual ~PhraseEdit();
00131 
00132             /******************************************************************
00133              * Accessing the MidiEvents
00134              *****************************************************************/
00135 
00146             void reset(const MidiData *source = 0);
00147 
00176             void tidy(Clock stopTime = -1);
00177 
00213             void timeShift(Clock delta);
00214 
00241             Phrase *createPhrase(PhraseList *pl,
00242                                  const std::string &title = "") const;
00243 
00266             MidiEvent &operator[](size_t n) { return data[n]; }
00267 
00294             void insert(MidiEvent event);
00295 
00304             void erase(size_t n);
00305 
00314             void erase(MidiEvent event);
00315 
00316             /******************************************************************
00317              * Accessing the selection
00318              *****************************************************************/
00319 
00326             void select(size_t index);
00327 
00334             void selectRange(size_t from, size_t to);
00335 
00341             void deselect(size_t index);
00342 
00346             void clearSelection();
00347 
00351             void invertSelection();
00352 
00358             bool selection() const { return _selection; }
00359 
00367             size_t firstSelectionIndex() const
00368             {
00369                 return _selection ? _firstSelectionIndex : size();
00370             }
00371 
00379             size_t lastSelectionIndex() const
00380             {
00381                 return _selection ? _lastSelectionIndex : size();
00382             }
00383 
00389             void eraseSelection();
00390 
00391             /******************************************************************
00392              * Accessing modification state
00393              *****************************************************************/
00394 
00401             bool modified() const { return _modified; }
00402 
00410             void setModified(bool m) { if (m != _modified) modified(m); }
00411 
00412             /******************************************************************
00413              * Other definitions
00414              *****************************************************************/
00415 
00420             static const int defaultSize = 1024;
00421 
00428             static const int tollerance = Clock::PPQN/2;
00429 
00430         private:
00431 
00432             PhraseEdit &operator=(const PhraseEdit &);
00433             PhraseEdit(const PhraseEdit &);
00434 
00438             void updateSelectionInfo();
00439 
00447             void selected(size_t index, bool sel);
00448 
00452             void modified(bool m);
00453 
00466             size_t hint;
00467 
00468             /*
00469              * Selection information
00470              */
00471             bool   _selection;
00472             size_t _firstSelectionIndex;
00473             size_t _lastSelectionIndex;
00474 
00475             bool   _modified;
00476 
00477     };
00478 }
00479 
00480 #endif

Generated on Wed May 25 14:45:08 2005 for TSE3 by doxygen 1.3.2