Finale PDK Framework 0.77
Power Up Your Finale Music Software
Loading...
Searching...
No Matches
ff_fcctrlcanvas.h
1//
2// ff_fcctrlcanvas.h
3//
4// Created by Jari Williamsson on 2017-08-10.
5//
6// This will only be included if PDK_FRAMEWORK_CANVASCTRL is defined.
7
8#ifndef ff_fcctrlcanvas_h
9#define ff_fcctrlcanvas_h
10
11#ifdef PDK_FRAMEWORK_CANVASCTRL
12
13#include "finaleframework.h"
14
15
16#ifndef DOXYGEN_SHOULD_IGNORE_THIS
22struct __FCVIRTUALCANVASHANDLER_DATA
23{
24 float staffheight; /* In points */
25 float staffpos; /* In point coords (from canvas bottom) */
26 float penwidth; /* In points */
27 float pendashlength; /* Dash length, in points */
28 float pendashspace; /* Dash space, in points. 0 - solid line */
29 float penred; /* 0-100 for all color and alpha values */
30 float pengreen;
31 float penblue;
32 float penalpha;
33 float backred;
34 float backgreen;
35 float backblue;
36 float backalpha;
37 float textred;
38 float textgreen;
39 float textblue;
40 float textalpha;
41 FCFontInfo textfont;
42 float textx;
43 float texty;
44 MACCODE(void* line;) /* NSBezierPath* */
45
46 __FCVIRTUALCANVASHANDLER_DATA()
47 {
48 staffheight = 50;
49 staffpos = 0;
50 penwidth = 1;
51 pendashlength = 10;
52 pendashspace = 0; /* Solid line */
53 penred = 0;
54 pengreen = 0;
55 penblue = 0;
56 penalpha = 100.0;
57 backred = 100.0;
58 backgreen = 100.0;
59 backblue = 100.0;
60 backalpha = 100.0;
61 textred = 0;
62 textgreen = 0;
63 textblue = 0;
64 textalpha = 100.0;
65 textfont.SetName("Arial");
66 textfont.SetSize(16.0);
67 textx = 0.0;
68 texty = 0.0;
69 MACCODE(line = NULL;)
70 }
71};
72#endif /* #ifndef DOXYGEN_SHOULD_IGNORE_THIS */
73
74
81class FCVirtualCanvasInstruction : public __FCBase
82{
83 /* Reference pointer to the virtual canvas data, during draw processing. */
84 __FCVIRTUALCANVASHANDLER_DATA* _pCanvasDataRef;
85
86public:
87
89 enum VCANVASINSTRUCTIONS
90 {
92 VCINS_NULL = 0,
93
94
95 /* PRIMITIVES - SETTINGS */
96
101 VCINS_PENCOLOR,
102
104 VCINS_PENALPHA,
105
107 VCINS_PENWIDTH,
108
110 VCINS_PENDASHLENGTH,
111
113 VCINS_PENDASHSPACE,
114
115
116
117
122 VCINS_BACKCOLOR,
123
124 VCINS_BACKALPHA,
125
126
127
132 VCINS_TEXTCOLOR,
133
135 VCINS_TEXTALPHA,
136
138 VCINS_TEXTFONT,
139
141 VCINS_SAVETEXTFONT,
142
144 VCINS_RESTORETEXTFONT,
145
147 VCINS_TEXTPOS,
148
152 VCINS_STAFFHEIGHT,
153
156 VCINS_STAFFBASE,
157
158 /* PRIMITIVES - ACTIONS */
159
161 VCINS_STARTLINEPATH,
162
163 VCINS_ENDLINEPATH,
164
165 /* End the path by filling the area instead of drawing a line */
166 VCINS_ENDLINEPATHFILL,
167
168 VCINS_MOVEPEN,
169
170 VCINS_LINETO,
171
173 VCINS_FILLRECT,
174
176 VCINS_LINERECT,
177
179 VCINS_FILLOVAL,
180
182 VCINS_LINEOVAL,
183
185 VCINS_DRAWTEXT,
186
188 VCINS_RECTTEXT,
189
190
191 /* COMPOSITE LINE INSTRUCTIONS */
192
194 VCINS_LINEBETWEEN,
195
197 VCINS_BEAMLINEBETWEEN,
198
200 VCINS_FRAME,
201
203 VCINS_5STAFFLINES,
204
206 VCINS_BARLINE,
207
209 VCINS_DOUBLEBARLINE,
210
212 VCINS_FINALBARLINE,
213
215 VCINS_FILLALL,
216
218 VCINS_TEXTAT,
219
221 VCINS_NOTEHEAD
222
223
224
225 };
226private:
227
228 VCANVASINSTRUCTIONS _instructiontype;
229
230 /* The "_instructiontype" decides how many parameters the
231 * instruction has - and what object type it is.
232 *
233 * The "_parameters" collection must OWN all it's parameter objects,
234 * so they can be deleted from the heap on destruction.
235 */
236 __FCCollection _parameters;
237
238
239 void DEBUG_INSTRUCTION_CHECK([[maybe_unused]]const char* pszInstruction, [[maybe_unused]]int expectedcount, [[maybe_unused]]VCANVASINSTRUCTIONS expectedtype)
240 {
241#ifdef PDK_FRAMEWORK_DIAGNOSE
242 if (expectedcount != _parameters.GetCount()) DebugOutString("Incorrect number of parameters for instruction: ", pszInstruction);
243 if (expectedtype != GetInstructionType()) DebugOutString("Incorrect type for instruction: ", pszInstruction);
244#endif
245 }
246
247 void RangeAdjustFloat(float* pFloat, float fmin, float fmax)
248 {
249 if (*pFloat < fmin)
250 {
251#ifdef PDK_FRAMEWORK_DIAGNOSE
252 DebugOut("Float parameter is too low for instruction");
253#endif
254 *pFloat = fmin;
255 }
256 if (*pFloat > fmax)
257 {
258#ifdef PDK_FRAMEWORK_DIAGNOSE
259 DebugOut("Float parameter is too low for instruction");
260#endif
261 *pFloat = fmax;
262 }
263 }
264public:
265
266
272 FCVirtualCanvasInstruction() : __FCBase() {}
273
274 void SetInstructionType(VCANVASINSTRUCTIONS itype) { _instructiontype = itype; }
275
276 VCANVASINSTRUCTIONS GetInstructionType() { return _instructiontype; }
277
278 void SetFrame()
279 {
280 _parameters.ClearAll();
281 SetInstructionType(VCINS_FRAME);
282 DEBUG_INSTRUCTION_CHECK("Frame", 0, VCINS_FRAME);
283 }
284
285 void SetStaffHeight(float height)
286 {
287 _parameters.ClearAll();
288 _parameters.Add(new FCNumber(height));
289 SetInstructionType(VCINS_STAFFHEIGHT);
290 DEBUG_INSTRUCTION_CHECK("StaffHeight", 1, VCINS_STAFFHEIGHT);
291 }
292
293 void SetStaffBase(float verticalpos)
294 {
295 _parameters.ClearAll();
296 _parameters.Add(new FCNumber(verticalpos));
297 SetInstructionType(VCINS_STAFFBASE);
298 DEBUG_INSTRUCTION_CHECK("StaffBase", 1, VCINS_STAFFBASE);
299 }
300
301 void SetPenColor(float r, float g, float b)
302 {
303 _parameters.ClearAll();
304 RangeAdjustFloat(&r, 0, 100);
305 _parameters.Add(new FCNumber(r));
306 RangeAdjustFloat(&g, 0, 100);
307 _parameters.Add(new FCNumber(g));
308 RangeAdjustFloat(&b, 0, 100);
309 _parameters.Add(new FCNumber(b));
310 SetInstructionType(VCINS_PENCOLOR);
311 DEBUG_INSTRUCTION_CHECK("PenColor", 3, VCINS_PENCOLOR);
312 }
313
314 void SetPenAlpha(float a)
315 {
316 _parameters.ClearAll();
317 RangeAdjustFloat(&a, 0, 100);
318 _parameters.Add(new FCNumber(a));
319 SetInstructionType(VCINS_PENALPHA);
320 DEBUG_INSTRUCTION_CHECK("PenAlpha", 1, VCINS_PENALPHA);
321 }
322
324 void SetBackColor(float r, float g, float b)
325 {
326 _parameters.ClearAll();
327 RangeAdjustFloat(&r, 0, 100);
328 _parameters.Add(new FCNumber(r));
329 RangeAdjustFloat(&g, 0, 100);
330 _parameters.Add(new FCNumber(g));
331 RangeAdjustFloat(&g, 0, 100);
332 _parameters.Add(new FCNumber(b));
333 SetInstructionType(VCINS_BACKCOLOR);
334 DEBUG_INSTRUCTION_CHECK("BackColor", 3, VCINS_BACKCOLOR);
335 }
336
337 void SetBackAlpha(float a)
338 {
339 _parameters.ClearAll();
340 RangeAdjustFloat(&a, 0, 100);
341 _parameters.Add(new FCNumber(a));
342 SetInstructionType(VCINS_BACKALPHA);
343 DEBUG_INSTRUCTION_CHECK("BackAlpha", 1, VCINS_BACKALPHA);
344 }
345
346 void SetTextColor(float r, float g, float b)
347 {
348 _parameters.ClearAll();
349 RangeAdjustFloat(&r, 0, 100);
350 _parameters.Add(new FCNumber(r));
351 RangeAdjustFloat(&g, 0, 100);
352 _parameters.Add(new FCNumber(g));
353 RangeAdjustFloat(&b, 0, 100);
354 _parameters.Add(new FCNumber(b));
355 SetInstructionType(VCINS_TEXTCOLOR);
356 DEBUG_INSTRUCTION_CHECK("TextColor", 3, VCINS_TEXTCOLOR);
357 }
358
359 void SetTextAlpha(float a)
360 {
361 _parameters.ClearAll();
362 RangeAdjustFloat(&a, 0, 100);
363 _parameters.Add(new FCNumber(a));
364 SetInstructionType(VCINS_TEXTALPHA);
365 DEBUG_INSTRUCTION_CHECK("TextAlpha", 1, VCINS_TEXTALPHA);
366 }
367
368 void SetPenWidth(float pointsize)
369 {
370 _parameters.ClearAll();
371 _parameters.Add(new FCNumber(pointsize));
372 SetInstructionType(VCINS_PENWIDTH);
373 DEBUG_INSTRUCTION_CHECK("PenWidth", 1, VCINS_PENWIDTH);
374 }
375
377 void SetPenDashLength(float length)
378 {
379 _parameters.ClearAll();
380 _parameters.Add(new FCNumber(length));
381 SetInstructionType(VCINS_PENDASHLENGTH);
382 DEBUG_INSTRUCTION_CHECK("PenDashLength", 1, VCINS_PENDASHLENGTH);
383 }
384
386 void SetPenDashSpace(float space)
387 {
388 _parameters.ClearAll();
389 _parameters.Add(new FCNumber(space));
390 SetInstructionType(VCINS_PENDASHSPACE);
391 DEBUG_INSTRUCTION_CHECK("PenDashSpace", 1, VCINS_PENDASHSPACE);
392 }
393
394 void SetLineBetween(float x1, float y1, float x2, float y2)
395 {
396 _parameters.ClearAll();
397 _parameters.Add(new FCNumber(x1));
398 _parameters.Add(new FCNumber(y1));
399 _parameters.Add(new FCNumber(x2));
400 _parameters.Add(new FCNumber(y2));
401 SetInstructionType(VCINS_LINEBETWEEN);
402 DEBUG_INSTRUCTION_CHECK("LineBetween", 4, VCINS_LINEBETWEEN);
403 }
404
405 void SetBeamLineBetween(float x1, float y1, float x2, float y2)
406 {
407 _parameters.ClearAll();
408 _parameters.Add(new FCNumber(x1));
409 _parameters.Add(new FCNumber(y1));
410 _parameters.Add(new FCNumber(x2));
411 _parameters.Add(new FCNumber(y2));
412 SetInstructionType(VCINS_BEAMLINEBETWEEN);
413 DEBUG_INSTRUCTION_CHECK("BeamLineBetween", 4, VCINS_BEAMLINEBETWEEN);
414 }
415
416 void Set5StaffLines()
417 {
418 _parameters.ClearAll();
419 SetInstructionType(VCINS_5STAFFLINES);
420 DEBUG_INSTRUCTION_CHECK("5StaffLines", 0, VCINS_5STAFFLINES);
421 }
422
423 void SetBarline(float horizontalstart)
424 {
425 _parameters.ClearAll();
426 _parameters.Add(new FCNumber(horizontalstart));
427 SetInstructionType(VCINS_BARLINE);
428 DEBUG_INSTRUCTION_CHECK("Barline", 1, VCINS_BARLINE);
429 }
430
431 void SetDoubleBarline(float leftstart)
432 {
433 _parameters.ClearAll();
434 _parameters.Add(new FCNumber(leftstart));
435 SetInstructionType(VCINS_DOUBLEBARLINE);
436 DEBUG_INSTRUCTION_CHECK("DoubleBarline", 1, VCINS_DOUBLEBARLINE);
437 }
438
439 void SetFinalBarline(float rightedge)
440 {
441 _parameters.ClearAll();
442 _parameters.Add(new FCNumber(rightedge));
443 SetInstructionType(VCINS_FINALBARLINE);
444 DEBUG_INSTRUCTION_CHECK("FinalBarline", 1, VCINS_FINALBARLINE);
445 }
446
447 void SetStartLinePath()
448 {
449 _parameters.ClearAll();
450 SetInstructionType(VCINS_STARTLINEPATH);
451 DEBUG_INSTRUCTION_CHECK("StartLinePath", 0, VCINS_STARTLINEPATH);
452 }
453
454 void SetEndLinePath()
455 {
456 _parameters.ClearAll();
457 SetInstructionType(VCINS_ENDLINEPATH);
458 DEBUG_INSTRUCTION_CHECK("EndLinePath", 0, VCINS_ENDLINEPATH);
459 }
460
461 void SetEndLinePathFill()
462 {
463 _parameters.ClearAll();
464 SetInstructionType(VCINS_ENDLINEPATHFILL);
465 DEBUG_INSTRUCTION_CHECK("EndLinePathFill", 0, VCINS_ENDLINEPATHFILL);
466 }
467
468 void SetMovePen(float x, float y)
469 {
470 _parameters.ClearAll();
471 _parameters.Add(new FCNumber(x));
472 _parameters.Add(new FCNumber(y));
473 SetInstructionType(VCINS_MOVEPEN);
474 DEBUG_INSTRUCTION_CHECK("MovePen", 2, VCINS_MOVEPEN);
475 }
476
477 void SetLineTo(float x, float y)
478 {
479 _parameters.ClearAll();
480 _parameters.Add(new FCNumber(x));
481 _parameters.Add(new FCNumber(y));
482 SetInstructionType(VCINS_LINETO);
483 DEBUG_INSTRUCTION_CHECK("LineTo", 2, VCINS_LINETO);
484 }
485
486 void SetFillAll()
487 {
488 _parameters.ClearAll();
489 SetInstructionType(VCINS_FILLALL);
490 DEBUG_INSTRUCTION_CHECK("FillAll", 0, VCINS_FILLALL);
491 }
492
493 void SetFillRect(float x1, float y1, float x2, float y2)
494 {
495 _parameters.ClearAll();
496 _parameters.Add(new FCNumber(x1));
497 _parameters.Add(new FCNumber(y1));
498 _parameters.Add(new FCNumber(x2));
499 _parameters.Add(new FCNumber(y2));
500 SetInstructionType(VCINS_FILLRECT);
501 DEBUG_INSTRUCTION_CHECK("FillRect", 4, VCINS_FILLRECT);
502 }
503
504 void SetLineRect(float x1, float y1, float x2, float y2)
505 {
506 _parameters.ClearAll();
507 _parameters.Add(new FCNumber(x1));
508 _parameters.Add(new FCNumber(y1));
509 _parameters.Add(new FCNumber(x2));
510 _parameters.Add(new FCNumber(y2));
511 SetInstructionType(VCINS_LINERECT);
512 DEBUG_INSTRUCTION_CHECK("LineRect", 4, VCINS_LINERECT);
513 }
514
515 void SetFillOval(float x1, float y1, float x2, float y2)
516 {
517 _parameters.ClearAll();
518 _parameters.Add(new FCNumber(x1));
519 _parameters.Add(new FCNumber(y1));
520 _parameters.Add(new FCNumber(x2));
521 _parameters.Add(new FCNumber(y2));
522 SetInstructionType(VCINS_FILLOVAL);
523 DEBUG_INSTRUCTION_CHECK("FillOval", 4, VCINS_FILLOVAL);
524 }
525
526 void SetLineOval(float x1, float y1, float x2, float y2)
527 {
528 _parameters.ClearAll();
529 _parameters.Add(new FCNumber(x1));
530 _parameters.Add(new FCNumber(y1));
531 _parameters.Add(new FCNumber(x2));
532 _parameters.Add(new FCNumber(y2));
533 SetInstructionType(VCINS_LINEOVAL);
534 DEBUG_INSTRUCTION_CHECK("LineOval", 4, VCINS_LINEOVAL);
535 }
536
537 void SetTextPos(float x, float y)
538 {
539 _parameters.ClearAll();
540 _parameters.Add(new FCNumber(x));
541 _parameters.Add(new FCNumber(y));
542 SetInstructionType(VCINS_TEXTPOS);
543 DEBUG_INSTRUCTION_CHECK("TextPos", 2, VCINS_TEXTPOS);
544 }
545
546 void SetTextFont(FCFontInfo* pFontInfo)
547 {
548 if (!pFontInfo) return;
549 _parameters.ClearAll();
550 _parameters.Add(pFontInfo->CreateCopy());
551 SetInstructionType(VCINS_TEXTFONT);
552 DEBUG_INSTRUCTION_CHECK("TextFont", 1, VCINS_TEXTFONT);
553 }
554
555 void SetSaveTextFont()
556 {
557 _parameters.ClearAll();
558 SetInstructionType(VCINS_SAVETEXTFONT);
559 DEBUG_INSTRUCTION_CHECK("SaveTextFont", 0, VCINS_SAVETEXTFONT);
560 }
561
562 void SetRestoreTextFont()
563 {
564 _parameters.ClearAll();
565 SetInstructionType(VCINS_RESTORETEXTFONT);
566 DEBUG_INSTRUCTION_CHECK("RestoreTextFont", 0, VCINS_RESTORETEXTFONT);
567 }
568
569 void SetDrawText(FCString* pString)
570 {
571 if (!pString) return;
572 _parameters.ClearAll();
573 _parameters.Add(pString->CreateCopy());
574 SetInstructionType(VCINS_DRAWTEXT);
575 DEBUG_INSTRUCTION_CHECK("DrawText", 1, VCINS_DRAWTEXT);
576 }
577
578 void SetTextAt(FCString* pString, float x, float y)
579 {
580 if (!pString) return;
581 _parameters.ClearAll();
582 _parameters.Add(pString->CreateCopy());
583 _parameters.Add(new FCNumber(x));
584 _parameters.Add(new FCNumber(y));
585 SetInstructionType(VCINS_TEXTAT);
586 DEBUG_INSTRUCTION_CHECK("TextAt", 3, VCINS_TEXTAT);
587 }
588
589 void SetRectText(FCString* pString, float x1, float y1, float x2, float y2)
590 {
591 if (!pString) return;
592 _parameters.ClearAll();
593 _parameters.Add(pString->CreateCopy());
594 _parameters.Add(new FCNumber(x1));
595 _parameters.Add(new FCNumber(y1));
596 _parameters.Add(new FCNumber(x2));
597 _parameters.Add(new FCNumber(y2));
598 SetInstructionType(VCINS_RECTTEXT);
599 DEBUG_INSTRUCTION_CHECK("RectText", 5, VCINS_RECTTEXT);
600 }
601
602 void SetNotehead(int noteheadlevel, float horizontalpos, float noteheadwidth)
603 {
604 _parameters.ClearAll();
605 _parameters.Add(new FCNumber(noteheadlevel));
606 _parameters.Add(new FCNumber(horizontalpos));
607 _parameters.Add(new FCNumber(noteheadwidth));
608 SetInstructionType(VCINS_NOTEHEAD);
609 DEBUG_INSTRUCTION_CHECK("Notehead", 3, VCINS_NOTEHEAD);
610 }
611
612
613 /* END OF 'SET' METHODS */
614
615
616 void CopyFrom(FCVirtualCanvasInstruction* pSource);
617
621 float GetNumberParam(int index)
622 {
623 FCNumber* pNumber = (FCNumber*) _parameters.GetItemAt(index);
624 if (!pNumber)
625 {
626#ifdef PDK_FRAMEWORK_DEBUG
627 DebugOutInt("Index is out of range in FCVirtualCanvasInstruction::GetNumberParam() :", index);
628#endif
629 return 0;
630 }
631#ifdef PDK_FRAMEWORK_DIAGNOSE
632 if (pNumber->GetClassID() != FCID_NUMBER)
633 {
634 DebugOutInt("Class is not FCString in FCVirtualCanvasInstruction::GetStringParam() with index:", index);
635 return NULL;
636 }
637#endif /* #ifdef PDK_FRAMEWORK_DIAGNOSE */
638
639 return pNumber->GetFloat();
640 }
641
645 FCString* GetStringParam(int index)
646 {
647 FCString* pString = (FCString*) _parameters.GetItemAt(index);
648 if (!pString)
649 {
650#ifdef PDK_FRAMEWORK_DEBUG
651 DebugOutInt("Index is out of range in FCVirtualCanvasInstruction::GetStringParam() :", index);
652#endif
653 return NULL;
654 }
655#ifdef PDK_FRAMEWORK_DIAGNOSE
656 if (pString->GetClassID() != FCID_STRING)
657 {
658 DebugOutInt("Class is not FCString in FCVirtualCanvasInstruction::GetStringParam() with index:", index);
659 return NULL;
660 }
661#endif /* #ifdef PDK_FRAMEWORK_DIAGNOSE */
662 return pString;
663 }
664
668 FCFontInfo* GetFontInfoParam(int index)
669 {
670 FCFontInfo* pFontInfo = (FCFontInfo*) _parameters.GetItemAt(index);
671 if (!pFontInfo)
672 {
673#ifdef PDK_FRAMEWORK_DEBUG
674 DebugOutInt("Index is out of range in FCVirtualCanvasInstruction::GetFontInfoParam() :", index);
675#endif
676 return NULL;
677 }
678#ifdef PDK_FRAMEWORK_DIAGNOSE
679 if (pFontInfo->GetClassID() != FCID_FONTINFO)
680 {
681 DebugOutInt("Class is not FCFontInfo in FCVirtualCanvasInstruction::GetFontInfoParam() with index:", index);
682 return NULL;
683 }
684#endif /* #ifdef PDK_FRAMEWORK_DIAGNOSE */
685 return pFontInfo;
686 }
687
689 int _GetParameterCount() { return _parameters.GetCount(); }
690
692 __FCBase* _GetParameterAt(int index) { return _parameters.GetItemAt(index); }
693
694
696 void _SetCanvasDataPtr(__FCVIRTUALCANVASHANDLER_DATA* pCanvasData) { _pCanvasDataRef = pCanvasData; }
697
698 __FCVIRTUALCANVASHANDLER_DATA* _GetCanvasDataPtr() { return _pCanvasDataRef; }
699
700};
701
702
703
704#define VCCOL_MAP_RGB(r, g, b) \
705*pRed = r; \
706*pGreen = g; \
707*pBlue = b;
708
709
710
739class FCVirtualCanvasInstructions : public __FCCollection
740{
741public:
743 enum VCANVASCOLORS
744 {
746 VCCOL_WHITE = 0,
747
749 VCCOL_BLACK,
750
752 VCCOL_GRAYDK,
753
755 VCCOL_GRAYMED,
756
758 VCCOL_GRAYLT
759
760 };
761private:
762
763
764 bool _MapCanvasColor(
765#ifdef PDK_FRAMEWORK_LUAFRIENDLY
766 int colorconstant
767#else
768 VCANVASCOLORS colorconstant
769#endif
770 , float* pRed, float* pGreen, float* pBlue)
771 {
772 switch (colorconstant)
773 {
774 case VCCOL_WHITE:
775 VCCOL_MAP_RGB(100, 100, 100)
776 break;
777 case VCCOL_BLACK:
778 VCCOL_MAP_RGB(0, 0, 0)
779 break;
780 case VCCOL_GRAYDK:
781 VCCOL_MAP_RGB(128, 128, 128)
782 break;
783 case VCCOL_GRAYMED:
784 VCCOL_MAP_RGB(192, 192, 192)
785 break;
786 case VCCOL_GRAYLT:
787 VCCOL_MAP_RGB(224, 224, 224)
788 break;
789 default:
790#ifdef PDK_FRAMEWORK_DIAGNOSE
791 DebugOutInt("Unmapped color constant in FCVirtualCanvasInstructions::_MapCanvasColor: ", colorconstant);
792#endif
793 return false;
794 }
795 return true;
796 }
797
798
799 /* Helper method for range changing of parameters */
800 bool FloatRangeCheck(float f, float min, float max)
801 {
802 if (f < min) return false;
803 if (f > max) return false;
804 return true;
805 }
806
807public:
808
809
810
811
816 FCVirtualCanvasInstructions() : __FCCollection() {}
817
818 FCVirtualCanvasInstruction* GetItemAt(int index) { return (FCVirtualCanvasInstruction*) __FCCollection::GetItemAt(index); }
819
826 FCVirtualCanvasInstruction* AddStaffHeight(float staffheight)
827 {
828 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
829 pInstr->SetStaffHeight(staffheight);
830 Add(pInstr);
831 return pInstr;
832 }
833
840 FCVirtualCanvasInstruction* AddStaffBase(float verticalpos)
841 {
842 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
843 pInstr->SetStaffBase(verticalpos);
844 Add(pInstr);
845 return pInstr;
846 }
847
860 FCVirtualCanvasInstruction* AddPenColor(float r, float g, float b)
861 {
862 if (!FloatRangeCheck(r, 0, 100)) return NULL;
863 if (!FloatRangeCheck(g, 0, 100)) return NULL;
864 if (!FloatRangeCheck(b, 0, 100)) return NULL;
865
866 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
867 pInstr->SetPenColor(r, g, b);
868 Add(pInstr);
869 return pInstr;
870 }
871
883 FCVirtualCanvasInstruction* AddNamedPenColor(
884#ifdef PDK_FRAMEWORK_LUAFRIENDLY
885 int colorconstant
886#else
887 VCANVASCOLORS colorconstant
888#endif
889 )
890 {
891 float r, g, b;
892 if (!_MapCanvasColor(colorconstant, &r, &g, &b)) return NULL;
893
894 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
895 pInstr->SetPenColor(r, g, b);
896 Add(pInstr);
897 return pInstr;
898 }
899
900
910 FCVirtualCanvasInstruction* AddPenAlpha(float a)
911 {
912 if (!FloatRangeCheck(a, 0, 100)) return NULL;
913
914 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
915 pInstr->SetPenAlpha(a);
916 Add(pInstr);
917 return pInstr;
918 }
919
930 FCVirtualCanvasInstruction* AddBackColor(float r, float g, float b)
931 {
932 if (!FloatRangeCheck(r, 0, 100)) return NULL;
933 if (!FloatRangeCheck(g, 0, 100)) return NULL;
934 if (!FloatRangeCheck(b, 0, 100)) return NULL;
935
936 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
937 pInstr->SetBackColor(r, g, b);
938 Add(pInstr);
939 return pInstr;
940 }
941
953 FCVirtualCanvasInstruction* AddNamedBackColor(
954#ifdef PDK_FRAMEWORK_LUAFRIENDLY
955 int colorconstant
956#else
957 VCANVASCOLORS colorconstant
958#endif
959 )
960 {
961 float r, g, b;
962 if (!_MapCanvasColor(colorconstant, &r, &g, &b)) return NULL;
963
964 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
965 pInstr->SetBackColor(r, g, b);
966 Add(pInstr);
967 return pInstr;
968 }
969
979 FCVirtualCanvasInstruction* AddBackAlpha(float a)
980 {
981 if (!FloatRangeCheck(a, 0, 100)) return NULL;
982
983 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
984 pInstr->SetBackAlpha(a);
985 Add(pInstr);
986 return pInstr;
987 }
988
989
990
1003 FCVirtualCanvasInstruction* AddTextColor(float r, float g, float b)
1004 {
1005 if (!FloatRangeCheck(r, 0, 100)) return NULL;
1006 if (!FloatRangeCheck(g, 0, 100)) return NULL;
1007 if (!FloatRangeCheck(b, 0, 100)) return NULL;
1008
1009 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1010 pInstr->SetTextColor(r, g, b);
1011 Add(pInstr);
1012 return pInstr;
1013 }
1014
1026 FCVirtualCanvasInstruction* AddNamedTextColor(
1027#ifdef PDK_FRAMEWORK_LUAFRIENDLY
1028 int colorconstant
1029#else
1030 VCANVASCOLORS colorconstant
1031#endif
1032 )
1033 {
1034 float r, g, b;
1035 if (!_MapCanvasColor(colorconstant, &r, &g, &b)) return NULL;
1036
1037 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1038 pInstr->SetTextColor(r, g, b);
1039 Add(pInstr);
1040 return pInstr;
1041 }
1042
1043
1053 FCVirtualCanvasInstruction* AddTextAlpha(float a)
1054 {
1055 if (!FloatRangeCheck(a, 0, 100)) return NULL;
1056
1057 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1058 pInstr->SetTextAlpha(a);
1059 Add(pInstr);
1060 return pInstr;
1061 }
1062
1063
1068 FCVirtualCanvasInstruction* AddPenWidth(float pointsize)
1069 {
1070 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1071 pInstr->SetPenWidth(pointsize);
1072 Add(pInstr);
1073 return pInstr;
1074 }
1075
1087 FCVirtualCanvasInstruction* AddPenDashLength(float length)
1088 {
1089 if (!FloatRangeCheck(length, 0, 1000)) return NULL;
1090 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1091 pInstr->SetPenDashLength(length);
1092 Add(pInstr);
1093 return pInstr;
1094 }
1095
1105 FCVirtualCanvasInstruction* AddPenDashSpace(float space)
1106 {
1107 if (!FloatRangeCheck(space, 0, 1000)) return NULL;
1108 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1109 pInstr->SetPenDashSpace(space);
1110 Add(pInstr);
1111 return pInstr;
1112 }
1113
1114 FCVirtualCanvasInstruction* AddStartLinePath()
1115 {
1116 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1117 pInstr->SetStartLinePath();
1118 Add(pInstr);
1119 return pInstr;
1120 }
1121
1122 FCVirtualCanvasInstruction* AddEndLinePath()
1123 {
1124 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1125 pInstr->SetEndLinePath();
1126 Add(pInstr);
1127 return pInstr;
1128 }
1129
1130 FCVirtualCanvasInstruction* AddEndLinePathFill()
1131 {
1132 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1133 pInstr->SetEndLinePathFill();
1134 Add(pInstr);
1135 return pInstr;
1136 }
1137
1138 FCVirtualCanvasInstruction* AddMovePen(float x, float y)
1139 {
1140 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1141 pInstr->SetMovePen(x, y);
1142 Add(pInstr);
1143 return pInstr;
1144 }
1145
1146 FCVirtualCanvasInstruction* AddLineTo(float x, float y)
1147 {
1148 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1149 pInstr->SetLineTo(x, y);
1150 Add(pInstr);
1151 return pInstr;
1152 }
1153
1154
1161 FCVirtualCanvasInstruction* AddFrame()
1162 {
1163 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1164 pInstr->SetFrame();
1165 Add(pInstr);
1166 return pInstr;
1167 }
1168
1175 FCVirtualCanvasInstruction* AddLineBetween(float x1, float y1, float x2, float y2)
1176 {
1177 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1178 pInstr->SetLineBetween(x1, y1, x2, y2);
1179 Add(pInstr);
1180 return pInstr;
1181 }
1182
1189 FCVirtualCanvasInstruction* AddBeamLineBetween(float x1, float y1, float x2, float y2)
1190 {
1191 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1192 pInstr->SetBeamLineBetween(x1, y1, x2, y2);
1193 Add(pInstr);
1194 return pInstr;
1195 }
1196
1203 FCVirtualCanvasInstruction* Add5StaffLines()
1204 {
1205 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1206 pInstr->Set5StaffLines();
1207 Add(pInstr);
1208 return pInstr;
1209 }
1210
1217 FCVirtualCanvasInstruction* AddBarline(float horizontalstart, [[maybe_unused]]float verticalstart)
1218 {
1219 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1220 pInstr->SetBarline(horizontalstart);
1221 Add(pInstr);
1222 return pInstr;
1223 }
1224
1231 FCVirtualCanvasInstruction* AddDoubleBarline(float leftstart)
1232 {
1233 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1234 pInstr->SetDoubleBarline(leftstart);
1235 Add(pInstr);
1236 return pInstr;
1237 }
1238
1245 FCVirtualCanvasInstruction* AddFinalBarline(float rightedge)
1246 {
1247 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1248 pInstr->SetFinalBarline(rightedge);
1249 Add(pInstr);
1250 return pInstr;
1251 }
1252
1253
1260 FCVirtualCanvasInstruction* AddFillAll()
1261 {
1262 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1263 pInstr->SetFillAll();
1264 Add(pInstr);
1265 return pInstr;
1266 }
1267
1274 FCVirtualCanvasInstruction* AddFillRect(float x1, float y1, float x2, float y2)
1275 {
1276 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1277 pInstr->SetFillRect(x1, y1, x2, y2);
1278 Add(pInstr);
1279 return pInstr;
1280 }
1281
1288 FCVirtualCanvasInstruction* AddLineRect(float x1, float y1, float x2, float y2)
1289 {
1290 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1291 pInstr->SetLineRect(x1, y1, x2, y2);
1292 Add(pInstr);
1293 return pInstr;
1294 }
1295
1302 FCVirtualCanvasInstruction* AddFillOval(float x1, float y1, float x2, float y2)
1303 {
1304 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1305 pInstr->SetFillOval(x1, y1, x2, y2);
1306 Add(pInstr);
1307 return pInstr;
1308 }
1309
1316 FCVirtualCanvasInstruction* AddLineOval(float x1, float y1, float x2, float y2)
1317 {
1318 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1319 pInstr->SetLineOval(x1, y1, x2, y2);
1320 Add(pInstr);
1321 return pInstr;
1322 }
1323
1324 FCVirtualCanvasInstruction* AddTextPos(float x, float y)
1325 {
1326 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1327 pInstr->SetTextPos(x, y);
1328 Add(pInstr);
1329 return pInstr;
1330 }
1331
1340 FCVirtualCanvasInstruction* AddTextFont(FCFontInfo* pFontInfo)
1341 {
1342 if (!pFontInfo) return NULL;
1343 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1344 pInstr->SetTextFont(pFontInfo);
1345 Add(pInstr);
1346 return pInstr;
1347 }
1348
1353 FCVirtualCanvasInstruction* AddSaveTextFont()
1354 {
1355 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1356 pInstr->SetSaveTextFont();
1357 Add(pInstr);
1358 return pInstr;
1359 }
1360
1365 FCVirtualCanvasInstruction* AddRestoreTextFont()
1366 {
1367 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1368 pInstr->SetRestoreTextFont();
1369 Add(pInstr);
1370 return pInstr;
1371 }
1372
1373 FCVirtualCanvasInstruction* AddDrawText(FCString* pString)
1374 {
1375 if (!pString) return NULL;
1376 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1377 pInstr->SetDrawText(pString);
1378 Add(pInstr);
1379 return pInstr;
1380 }
1381
1388 FCVirtualCanvasInstruction* AddTextAt(FCString* pString, float x, float y)
1389 {
1390 if (!pString) return NULL;
1391 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1392 pInstr->SetTextAt(pString, x, y);
1393 Add(pInstr);
1394 return pInstr;
1395 }
1396
1402 FCVirtualCanvasInstruction* AddRectText(FCString* pString, float x1, float y1, float x2, float y2)
1403 {
1404 if (!pString) return NULL;
1405 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1406 pInstr->SetRectText(pString, x1, y1, x2, y2);
1407 Add(pInstr);
1408 return pInstr;
1409 }
1410
1420 FCVirtualCanvasInstruction* AddNotehead(int noteheadlevel, float horizontalpos, float noteheadwidth)
1421 {
1422 FCVirtualCanvasInstruction* pInstr = new FCVirtualCanvasInstruction();
1423 pInstr->SetNotehead(noteheadlevel, horizontalpos, noteheadwidth);
1424 Add(pInstr);
1425 return pInstr;
1426 }
1427
1428
1429 /* *** END OF 'ADD' METHODS *** */
1430
1435 void CopyFrom(FCVirtualCanvasInstructions* pSource);
1436};
1437
1438
1439
1440#ifndef DOXYGEN_SHOULD_IGNORE_THIS
1449class __FCVirtualCanvasHandler : public __FCBase
1450{
1451 /* The virtual canvas data */
1452 __FCVIRTUALCANVASHANDLER_DATA _canvasdata;
1453
1454 /* For save/restore operations */
1455 __FCVIRTUALCANVASHANDLER_DATA _savedcanvasdata;
1456
1457
1458 FCVirtualCanvasInstructions* _pInstructions;
1459
1460 /* The view's dimensions are retrieved at init */
1461 float _viewwidth;
1462 float _viewheight;
1463
1464 WINCODE(HWND _hwndCtrl;)
1465 MACCODE(void* _self;)
1466
1467 /* Handling of non-drawing primitives, that needs to be tracked, such as colors, pen sizes, etc.
1468 *
1469 * The abstract primitives are set in _canvasdata, instead of sent to the platform-specific drawing callback.
1470 */
1471 bool HandleAbstractPrimitives(FCVirtualCanvasInstruction* pInstruction);
1472
1473 /* Redirection of primitive drawing functions to platform-specific graphics code.
1474 *
1475 * Primitives are setting colors, drawing simple lines, etc.
1476 */
1477 void RedirectPrimitiveDraw(FCVirtualCanvasInstruction* pInstruction);
1478
1479 /* Splits all composite instructions into primitive drawing functions.
1480 *
1481 * If it returns true, it has been processed. If it returns false, it's already a primitive function.
1482 */
1483 bool ProcessCompositeInstruction(FCVirtualCanvasInstruction* pInstruction);
1484
1485 /* Processes one instruction in the virtual canvas instruction list. This can be a
1486 * composite or primitive drawing function. */
1487 void ProcessOneInstruction(FCVirtualCanvasInstruction* pInstruction);
1488
1489 /* Initializes the drawing, but setting default colors, pen sizes etc. */
1490 void ProcessInit();
1491
1492 /* Main processing method. Called by ProcessCocoa() and ProcessWindows(). */
1493 void Process();
1494public:
1495 __FCVirtualCanvasHandler(FCVirtualCanvasInstructions* pInstructions) : __FCBase()
1496 {
1497 _pInstructions = pInstructions;
1498 }
1499
1500#if OPERATING_SYSTEM == WINDOWS
1501 /* The Process() method for Windows. */
1502 void ProcessWindows(HWND hwndCtrl)
1503 {
1504 _hwndCtrl = hwndCtrl;
1505 Process();
1506 }
1507#else
1508 /* The Process() method for Cocoa.
1509 selfPtr is a NSFCCtrlCanvas*
1510 */
1511 void ProcessCocoa(void* selfPtr)
1512 {
1513 _self = selfPtr;
1514 Process();
1515 }
1516#endif
1517};
1518#endif /* #ifndef DOXYGEN_SHOULD_IGNORE_THIS */
1519
1520#endif /* PDK_FRAMEWORK_CANVASCTRL */
1521
1522#endif /* fcctrlcanvas_h */
Base class for the Finale Framework classes.
Definition ff_base.h:71
static void DebugOutString(const char *pszPrefixText, const char *thestring)
Static method that outputs a line for debugging purposes (C string version). The text appears with th...
Definition finaleframework.cpp:436
static void DebugOutInt(const char *pszPrefixText, int i)
Static method that outputs a line for debugging purposes. The text appears with the extra digit (in d...
Definition finaleframework.cpp:335
static void DebugOut(const char *pszLine)
Static method to output a line of text for debugging purposes.
Definition finaleframework.cpp:526
Base class for all collection classes. A collection is a storage that can store multiple objects of s...
Definition ff_basecollection.h:26
void Add(__FCBase *pNewItem)
Adds an element to the end of the collection.
Definition finaleframework.cpp:13726
void ClearAll()
Destroys all the objects in the collection and empties the collection.
Definition ff_basecollection.h:151
int GetCount() const
Returns the number of elements of the collection.
Definition ff_basecollection.h:102
__FCBase * GetItemAt(int index) const
Returns the object at the index position. Index is 0-based.
Definition finaleframework.cpp:13767
Class for document-independent font information.
Definition ff_base.h:1138
FCFontInfo * CreateCopy()
Creates a copy of the font info object on the heap.
Definition ff_base.h:1247
void SetName(const std::string &pszName)
Sets the font name.
Definition finaleframework.cpp:3634
void SetSize(int fontsize)
Sets the font size as an integer value.
Definition ff_base.h:1546
const PDKFRAMEWORK_CLASSID GetClassID() const override
Returns the internal class ID for the PDK Framework class. This is implemented mostly because Lua has...
Definition ff_base.h:1157
Simple class to put numbers into collections.
Definition ff_base.h:4821
double GetFloat() const
Returns the integer value version of the number.
Definition ff_base.h:4871
const PDKFRAMEWORK_CLASSID GetClassID() const override
Returns the internal class ID for the PDK Framework class. This is implemented mostly because Lua has...
Definition ff_base.h:4826
Class that provides storage for text. This is to achieve platform-transparent text handling,...
Definition ff_base.h:1877
FCString * CreateCopy()
Creates a copy of the string object on the heap.
Definition finaleframework.cpp:2411
const PDKFRAMEWORK_CLASSID GetClassID() const override
Returns the internal class ID for the PDK Framework class. This is implemented mostly because Lua has...
Definition ff_base.h:1961