Finale PDK Framework  0.54
ff_cell.h
1 /*
2  * File: ff_cell.h
3  * Author: Jari Williamsson
4  *
5  * Created on den 18 november 2010, 00:59
6  */
7 
8 #ifndef FF_CELL_H
9 #define FF_CELL_H
10 
17 class FCCell : public __FCBase
18 {
19  int _measure;
20  int _staff;
21  FCKeySignature* _pKeySig;
22  FCTimeSignature* _pTimeSig;
23 
25  bool _SetIndependentTimeSignature(FCTimeSignature* pTimeSig);
26 
28  bool _SetGlobalTimeSignature(FCTimeSignature* pTimeSig);
29 
31  bool _SetIndependentKeySignature(FCKeySignature* pKeySig);
32 
34  bool _SetGlobalKeySignature(FCKeySignature* pKeySig);
35 
36 public:
41  FCCell(int measure, int staff)
42  {
43  _measure = measure;
44  _staff = staff;
45  _pKeySig = NULL;
46  _pTimeSig = NULL;
47  }
48 
49  virtual ~FCCell()
50  {
51  delete _pKeySig;
52  delete _pTimeSig;
53  }
54 
55 #ifdef PDK_FRAMEWORK_ENTRIES
56 
74  FCNoteEntryCell* CreateNoteEntryCell(bool shouldload, int loadlayermode = 0)
75  {
76  FCNoteEntryCell* pFrame = new FCNoteEntryCell(_measure, _staff);
77  if (shouldload)
78  {
79  pFrame->SetLoadLayerMode(loadlayermode);
80  pFrame->Load();
81  }
82  return pFrame;
83  }
84 
85 #ifdef PDK_FRAMEWORK_LUAFRIENDLY
86 
87  FCNoteEntryCell* CreateNoteEntryCell_GC(bool shouldload, int loadlayermode = 0);
88 #endif
89 
90 #endif // #ifdef PDK_FRAMEWORK_ENTRIES
91 
92  virtual const char* ClassName() { return "FCCell"; }
93 
100  int GetMeasure() const { return _measure; }
101 
108  int GetStaff() const { return _staff; }
109 
125  TimeEdu32 CalcEntryDuration(int layer = 0);
126 
135  int CalcClefIndexAt(TimeEdu32 pos);
136 
142  TimeEdu32 CalcDuration()
143  {
144  return FX_GetMeasureDuration(GetStaff(), GetMeasure());
145  }
146 
160 
166  bool HasIndependentTimeSig();
167 
173  bool HasIndependentKeySig();
174 
189 
198  void ReAssign(int measure, int staff)
199  {
200  if ((_measure == measure) && (_staff == staff)) return;
201  _measure = measure;
202  _staff = staff;
203  delete _pKeySig;
204  delete _pTimeSig;
205  _pKeySig = NULL;
206  _pTimeSig = NULL;
207  }
208 
216  {
217  FCCellMetrics *pMetrics = new FCCellMetrics();
218  if (pMetrics->LoadAtCell(this)) return pMetrics;
219  delete pMetrics;
220  return NULL;
221  }
222 
231 
240 
241 
242 #ifdef PDK_FRAMEWORK_LUAFRIENDLY
243 
244  FCCellMetrics* CreateCellMetrics_GC();
245 #endif
246 
247 
256  bool Save();
257 
258 };
259 
266 class FCCellPos : public __FCBase
267 {
268  eMeas _measure;
269  eStaff _staff;
270  TimeEdu32 _measurepos;
271 public:
276  FCCellPos(int measure, int staff, TimeEdu32 measurepos)
277  {
278  _measure = measure;
279  _staff = staff;
280  _measurepos = measurepos;
281  }
282 
289  eMeas GetMeasure() const { return _measure; }
290 
297  eStaff GetStaff() const { return _staff; }
298 
307  TimeEdu32 GetMeasurePos() const { return _measurepos; }
308 
315  int CalcClefIndex();
316 };
317 
323 class FCCells : public __FCCollection
324 {
325 public:
326  virtual const char* ClassName() { return "FCCells"; }
327 
333  {}
334 
343  void ApplyRegion(FCMusicRegion* pRegion);
344 
352  int ForEachAtMeasure(int measure, FCIteratorHandler* pIterator);
353 
361  int ForEachAtStaff(int staff, FCIteratorHandler* pIterator);
362 
370  FCCell* Find(int measure, int staff);
371 
377  FCCell* GetItemAt(int index) { return (FCCell*) __FCCollection::GetItemAt(index); }
378 };
379 
380 
381 
382 #endif /* FF_CELL_H */
383 
void ReAssign(int measure, int staff)
Reassigns the cell to a different cell position, which will also delete attached cell data...
Definition: ff_cell.h:198
__FCBase * GetItemAt(int index)
Returns the object at the index position. Index is 0-based.
Definition: finaleframework.cpp:12797
TimeEdu32 CalcEntryDuration(int layer=0)
Returns the duration for all the entries in the cell. The value of the layer with the longest duratio...
Definition: finaleframework.cpp:18508
eMeas GetMeasure() const
Returns the measure for the cell.
Definition: ff_cell.h:289
bool Load()
Loads the note entries for the cell. Which layers that will be loaded are controlled by the SetLoadLa...
Definition: finaleframework.cpp:17455
void ApplyRegion(FCMusicRegion *pRegion)
Collects the cells (FCCell members) that belongs to a region.
Definition: finaleframework.cpp:18808
FCKeySignature * GetKeySignature()
Returns a pointer to the key signature object.
Definition: finaleframework.cpp:18551
int GetMeasure() const
Returns the measure for the cell.
Definition: ff_cell.h:100
FCKeySignature * AssureSavedIndependentKeySig()
Makes sure that the cell has saved indepentent key signature data.
Definition: finaleframework.cpp:18666
FCCellMetrics * CreateCellMetrics()
Creates a cell metrics object for a cell. The created object must be disposed after use...
Definition: ff_cell.h:215
virtual const char * ClassName()
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition: ff_cell.h:92
FCCell * GetItemAt(int index)
Overridden GetItemAt() method that returns a FCCell object.
Definition: ff_cell.h:377
FCCellPos(int measure, int staff, TimeEdu32 measurepos)
The constructor.
Definition: ff_cell.h:276
FCCell(int measure, int staff)
The constructor.
Definition: ff_cell.h:41
eStaff GetStaff() const
Returns the staff for the cell.
Definition: ff_cell.h:297
FCTimeSignature * GetTimeSignature()
Returns a pointer to the time signature object.
Definition: finaleframework.cpp:18649
FCCells()
The constructor.
Definition: ff_cell.h:332
int CalcClefIndex()
Calculates the clef index at the position indicated by the FCCellPos object.
Definition: finaleframework.cpp:18714
FCCell * Find(int measure, int staff)
Returns the first found cell in the collection that matches the measure and staff.
Definition: finaleframework.cpp:18856
int ForEachAtMeasure(int measure, FCIteratorHandler *pIterator)
Processes all elements in the collection that belong to a certain measure, or until the iterator Iter...
Definition: finaleframework.cpp:18824
Class for time signatures.
Definition: ff_timesig.h:25
TimeEdu32 CalcDuration()
Returns the duration of the frame, according to the time signature.
Definition: ff_cell.h:142
Class that encapsulate the measure metrics info data.
Definition: ff_base.h:3007
FCTimeSignature * AssureSavedIndependentTimeSig()
Makes sure that the cell has saved indepentent time signature data.
Definition: finaleframework.cpp:18688
The class that reference a cell (one measure on one staff) in the musical "grid". ...
Definition: ff_cell.h:17
int GetStaff() const
Returns the staff for the cell.
Definition: ff_cell.h:108
Base class for the Finale Framework classes.
Definition: ff_base.h:47
int ForEachAtStaff(int staff, FCIteratorHandler *pIterator)
Processes all elements in the collection that belong to a certain staff, or until the iterator Iterat...
Definition: finaleframework.cpp:18840
void SetLoadLayerMode(int mode)
Sets the "layer mode" for the Load method. This must be called/st before any Load() call...
Definition: ff_noteframe.h:3078
This class is similar to FCCell, but also includes a position within the measure. It represents a "mu...
Definition: ff_cell.h:266
Class for iterator handlers.
Definition: ff_iterator.h:25
FCNoteEntryCell * CreateNoteEntryCell(bool shouldload, int loadlayermode=0)
Creates a note entry cell object and optionally loads it with notes.
Definition: ff_cell.h:74
A collection of FCCell members.
Definition: ff_cell.h:323
Class that encapsulates EREGION and provides additional functionality to region handling.
Definition: ff_region.h:24
TimeEdu32 GetMeasurePos() const
Returns the (horizontal) duration position within the cell.
Definition: ff_cell.h:307
bool Save()
Saves any independent key and/or time signatures connected with the cell.
Definition: finaleframework.cpp:18486
Class that encapsulate a cell of note entries.
Definition: ff_noteframe.h:2574
bool HasIndependentKeySig()
Returns true if the cell has an independent key signature.
Definition: finaleframework.cpp:18580
Class for key signatures. Instances of this class is auto-created by FCMeasure:GetKeySignature and FC...
Definition: ff_keysig.h:22
int CalcClefIndexAt(TimeEdu32 pos)
Calculates the clef index at a specific position in the cell.
Definition: finaleframework.cpp:18545
bool HasIndependentTimeSig()
Returns true if the cell has an independent time signature.
Definition: finaleframework.cpp:18567
virtual const char * ClassName()
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition: ff_cell.h:326
bool LoadAtCell(FCCell *pCell)
Loads the measure metrics for a cell.
Definition: finaleframework.cpp:3419
Base class for all collection classes. A collection is a storage that can store multiple objects of s...
Definition: ff_basecollection.h:24