Finale PDK Framework 0.77
Power Up Your Finale Music Software
Loading...
Searching...
No Matches
ff_ui.h
1/*
2 * File: ff_ui.h
3 * Author: Jari Williamsson
4 *
5 * Created on den 16 januari 2011, 16:27
6 *
7 * User interface stuff.
8 */
9
10#ifndef FF_UI_H
11#define FF_UI_H
12
13#include "ff_base.h"
14
15#if OPERATING_SYSTEM == MAC_OS
16#include "ff_cocoa_cppinterface.h"
17#endif
18
20
28class FCUI : public __FCBase
29{
30 /* Use Finale's API for verifying font exist (default is OFF on Windows only, for performance reasons) */
31 bool _useFinaleFontExistAPI;
32
33 EWND _parentwindow;
34
35#ifdef PDK_FRAMEWORK_LUAFRIENDLY
36 lua_State* _luastate;
37#endif
38
39 bool _starttimerfound, _endtimerfound, _performancefrequencyfound; /* For the performance timer */
40
41#if OPERATING_SYSTEM == MAC_OS
42 _FCUI_cocoa _fcuicocoa;
43#endif
44
45#if OPERATING_SYSTEM == WINDOWS
47 int __Windows_MessageBox(FCString* pMessage, FCString* pTitle, int styles);
48#endif
49public:
71
80
84
88
92
95
98
101
104
107
110
113
116
119
122
125
128
131
134
137
140
143
146
149
152
155
159
162
165
168
171
174
177
180
183
186
189
192
195
198
201
204
207
210
213
216
219
222
225
228
231
234
237
240
243
246
249
252
255
258
261
264
267
270
273 };
274
275
301#if PDK_FRAMEWORK_LUAFRIENDLY
302 FCUI(EWND parent, lua_State *L = nullptr) : __FCBase(), _luastate(L)
303#else
304 FCUI(EWND parent) : __FCBase()
305#endif
306 {
307 _parentwindow = parent;
308 _starttimerfound = false;
309 _endtimerfound = false;
310 _performancefrequencyfound = false;
311 WINCODE(_useFinaleFontExistAPI = false;) /* OFF because of huge performance issues when font name isn't found. */
312 MACCODE(_useFinaleFontExistAPI = true;) /* API is fast on the Mac */
313 }
314
315 const char* ClassName() const override { return "FCUI"; }
316
317#ifndef DOXYGEN_SHOULD_IGNORE_THIS
319 void _NotifyModalWindowWillOpen();
321 void _NotifyModalWindowDidClose();
322#endif // DOXYGEN_SHOULD_IGNORE_THIS
323
330 void AlertErrorCString(const char* pszMessage, const char* pszTitle = NULL);
331
339 void AlertErrorUTF8(const char* pszMessage, const char* pszTitle = NULL);
340
346 void AlertError(FCString* pMessage, FCString* pTitle = NULL);
347
355#ifndef PDK_FRAMEWORK_LUAFRIENDLY
357#else
358 int
359#endif
360 AlertYesNoCString(const char* pszMessage, const char* pszTitle = NULL);
361
371#ifndef PDK_FRAMEWORK_LUAFRIENDLY
373#else
374 int
375#endif
376 AlertYesNoUTF8(const char* pszMessage, const char* pszTitle = NULL);
377
385 ALERT_RETURNS AlertYesNo(FCString* pMessage, FCString* pTitle = NULL);
386
396#ifndef PDK_FRAMEWORK_LUAFRIENDLY
398#else
399 int
400#endif
401 AlertYesNoCancelUTF8(const char* pszMessage, const char* pszTitle);
402
410 ALERT_RETURNS AlertYesNoCancel(FCString* pMessage, FCString* pTitle = NULL);
411
419#ifndef PDK_FRAMEWORK_LUAFRIENDLY
421#else
422 int
423#endif
424 AlertOkCancelCString(const char* pszMessage, const char* pszTitle = NULL);
425
435#ifndef PDK_FRAMEWORK_LUAFRIENDLY
437#else
438 int
439#endif
440 AlertOkCancelUTF8(const char* pszMessage, const char* pszTitle = NULL);
441
449 ALERT_RETURNS AlertOkCancel(FCString* pMessage, FCString* pTitle = NULL);
450
456 void AlertNeutralCString(const char* pszMessage, const char* pszTitle = NULL);
457
465 void AlertNeutralUTF8(const char* pszMessage, const char* pszTitle = NULL);
466
472 void AlertNeutral(FCString* pMessage, FCString* pTitle = NULL);
473
479 void AlertInfoCString(const char* pszMessage, const char* pszTitle = NULL);
480
488 void AlertInfoUTF8(const char* pszMessage, const char* pszTitle = NULL);
489
495 void AlertInfo(FCString* pMessage, FCString* pTitle = NULL);
496
505 bool MenuCommand(
506#ifndef PDK_FRAMEWORK_LUAFRIENDLY
507MENU_COMMANDS menucmd
508#else
509int menucmd
510#endif
511 );
512
551 EMENUID GetOSMenuCommandFromItemText(const char *pszTopMenu, const char *pszItemText);
552
570 bool ExecuteOSMenuCommand(EMENUID osmenucmd, bool usemacfinaleapi = false) const;
571
598 [[deprecated]] bool MenuPositionCommand(int mainmenuidx, int dropdownidx, int submenuidx);
599
606 void RedrawDocument();
607
614 bool IsPageView() const;
615
621 bool IsPartView() const { return (FX_GetCurrentPartID() != 0); }
622
630 bool IsLayerVisible(twobyte layernum) const { return FX_GetShowLayer(layernum-1); }
631
641 void GetDecimalSeparator(FCString* pString);
642
650 void GetUserLocaleName(FCString* pString);
651
663 void SetUseIsFontAvailableAPI(bool state) { _useFinaleFontExistAPI = state; }
664
676 bool GetUseIsFontAvailableAPI() const { return _useFinaleFontExistAPI; }
677
682 bool IsOnWindows() const
683 {
684 WINCODE(return true;)
685 MACCODE(return false;)
686 }
687
693 bool IsOnMac() const
694 {
695 WINCODE(return false;)
696 MACCODE(return true;)
697 }
698
705 bool TextToClipboard(const char* pszText);
706
716 bool TextToClipboardUTF8(const char* pszText);
717
724 twobyte GetCurrentPage() const;
725
732 twobyte GetCurrentMeasure() const;
733
738 twobyte GetZoomLevel() const;
739
749 int GetMaxLayers() const;
750
755 EWND GetDocumentWindow();
756
764
766 EWND GetActiveWindow();
767
769 bool ActivateWindow(EWND hwnd);
770
776 FXWND GetParentWindow() { return _parentwindow; }
777
788 void MoveToMeasure(int measure, int staffno = 0);
789
794 void Beep();
795
800 int GetScreenWidth() const;
801
806 int GetScreenHeight() const;
807
824 [[deprecated]] CMPER DisplayTextExpressionDialog(CMPER cmperinit = 0);
825
841 std::pair<CMPER,bool> DisplayExpressionDialog(CMPER cmperinit = 0, bool isshape = false);
842
843#ifdef PDK_FRAMEWORK_LUAFRIENDLY_CPP
845 int DisplayExpressionDialog_LuaCFunction(lua_State *l)
846 {
847 //auto myRef = luabridge::Stack<FCUI *>::get(l, 1); // the first parameter passed to the Lua C function is "this"
848 CMPER cmperint = luabridge::Stack<CMPER>::get(l, 2) LB3(.value());
849 bool isshape = luabridge::Stack<bool>::get(l, 3) LB3(.value());
850
851 auto returnVal = DisplayExpressionDialog(cmperint, isshape);
852
853 luabridge::Stack<CMPER>::push(l, returnVal.first) LB3(.throw_on_error());
854 luabridge::Stack<bool>::push(l, returnVal.second) LB3(.throw_on_error());
855
856 return 2;
857 }
858#endif
859
870 CMPER DisplayArticulationDialog(CMPER cmperinit = 0);
871
882 CMPER DisplayShapeDialog(CMPER cmperinit = 0);
883
893 eUniChar32 DisplaySymbolDialog(FCFontInfo* pFontInfo, eUniChar32 symbolinit = 0);
894
905
913 bool IsFontAvailable(FCString* pFontName);
914
919 bool DisplayWebURL(FCString* pURLString);
920
929 bool DisplayShellFolder(FCString* pFolderString);
930
933
936
939
947 static double GetHiResTimer();
948
949#ifdef PDK_FRAMEWORK_DEBUG
950 void DebugDump() override
951 {
953 DebugOutPtr("Parent Window: ", GetParentWindow());
954 DebugOutPtr("Document Window: ", GetDocumentWindow());
955 }
956#endif
957};
958
959#endif /* FF_UI_H */
960
Base class for the Finale Framework classes.
Definition ff_base.h:71
virtual void DebugDump()
Outputs the class data/information for debugging purposes.
Definition finaleframework.cpp:609
static void DebugOutPtr(const char *pszPrefixText, void *ptr)
Static method that outputs a line for debugging purposes. The prefix text appears with the extra ptr ...
Definition finaleframework.cpp:319
Class for document-independent font information.
Definition ff_base.h:1138
Class to return the results of the ListenToMidi dialog box.
Definition ff_playback.h:28
Class that provides storage for text. This is to achieve platform-transparent text handling,...
Definition ff_base.h:1877
Standard class for basic user interface functionality.
Definition ff_ui.h:29
bool ExecuteOSMenuCommand(EMENUID osmenucmd, bool usemacfinaleapi=false) const
Executes an OS menu command returned by GetOSMenuCommandFromItemText.
Definition finaleframework.cpp:23774
void AlertErrorCString(const char *pszMessage, const char *pszTitle=NULL)
Displays a error message box / alert, with an OK button. C string version.
Definition finaleframework.cpp:23069
bool IsOnMac() const
Returns true if the user runs on the Mac.
Definition ff_ui.h:693
void AlertError(FCString *pMessage, FCString *pTitle=NULL)
Displays a error message box / alert, with an OK button. FCString version.
Definition finaleframework.cpp:23087
bool IsPartView() const
Returns true if the current view is in a part (=not in the score).
Definition ff_ui.h:621
bool TextToClipboard(const char *pszText)
Copies text to the operating system's clipboard.
Definition finaleframework.cpp:23834
void AlertInfoUTF8(const char *pszMessage, const char *pszTitle=NULL)
Displays an information message box / alert, with an OK button. UTF8 version.
Definition finaleframework.cpp:23306
ALERT_RETURNS AlertYesNoUTF8(const char *pszMessage, const char *pszTitle=NULL)
Displays a error message box / alert, with Yes+No buttons. UTF8 version.
Definition finaleframework.cpp:23123
void AlertErrorUTF8(const char *pszMessage, const char *pszTitle=NULL)
Displays a error message box / alert, with an OK button. UTF8 string version.
Definition finaleframework.cpp:23078
bool MenuCommand(MENU_COMMANDS menucmd)
Executes a supported menu command from Finale's menu.
Definition finaleframework.cpp:23332
eUniChar32 DisplaySymbolDialog(FCFontInfo *pFontInfo, eUniChar32 symbolinit=0)
Displays the symbol selection dialog.
Definition finaleframework.cpp:24085
void AlertInfo(FCString *pMessage, FCString *pTitle=NULL)
Displays an information message box / alert, with an OK button. FCString version.
Definition finaleframework.cpp:23315
void RedrawDocument()
Visually redraws the current document.
Definition finaleframework.cpp:23784
FCUI(EWND parent)
The constructor.
Definition ff_ui.h:304
bool DisplayWebURL(FCString *pURLString)
Displays an URL in an external web browser.
Definition finaleframework.cpp:24200
ALERT_RETURNS AlertOkCancel(FCString *pMessage, FCString *pTitle=NULL)
Displays a error message box / alert, with Ok+Cancel buttons. FCString version.
Definition finaleframework.cpp:23234
ALERT_RETURNS AlertOkCancelUTF8(const char *pszMessage, const char *pszTitle=NULL)
Displays a error message box / alert, with OK+Cancel buttons. UTF8 version.
Definition finaleframework.cpp:23225
bool ActivateWindow(EWND hwnd)
Activates a specific window.
Definition finaleframework.cpp:23959
void StopPerformanceTimer()
Stops the high-resolution timer.
Definition finaleframework.cpp:24259
void GetDecimalSeparator(FCString *pString)
Fills a FCString with the decimal separator used for the current user's locale.
Definition finaleframework.cpp:23792
void MoveToMeasure(int measure, int staffno=0)
Moves the view to the indicated 1-based measure.
Definition finaleframework.cpp:23971
EMENUID GetOSMenuCommandFromItemText(const char *pszTopMenu, const char *pszItemText)
Returns the OS-dependent menu command for a specific item in one of Finale's main menus.
Definition finaleframework.cpp:23710
void AlertNeutral(FCString *pMessage, FCString *pTitle=NULL)
Displays a standard message box / alert, with an OK button. FCString version.
Definition finaleframework.cpp:23281
void DebugDump() override
Outputs the class data/information for debugging purposes.
Definition ff_ui.h:950
FCUI::ALERT_RETURNS AlertYesNoCancelUTF8(const char *pszMessage, const char *pszTitle)
Displays a error message box / alert, with Yes+No+Cancel buttons. UTF8 version.
Definition finaleframework.cpp:23165
CMPER DisplayArticulationDialog(CMPER cmperinit=0)
Displays the articulation definition selection dialog.
Definition finaleframework.cpp:24053
void GetUserLocaleName(FCString *pString)
Fills a FCString with the locale name used for the current user's locale.
Definition finaleframework.cpp:23805
void Beep()
Gives a beep from the speaker.
Definition finaleframework.cpp:23985
int GetScreenHeight() const
Returns the height in pixels of the primary screen.
Definition finaleframework.cpp:24004
int GetMaxLayers() const
Returns the maximum number of layers that Finale supports.
Definition finaleframework.cpp:24013
int GetScreenWidth() const
Returns the width in pixels of the primary screen.
Definition finaleframework.cpp:23995
ALERT_RETURNS AlertOkCancelCString(const char *pszMessage, const char *pszTitle=NULL)
Displays a error message box / alert, with OK+Cancel buttons. C string version.
Definition finaleframework.cpp:23211
FXWND GetParentWindow()
Returns the window handle to the main window (that was passed to the constructor.)
Definition ff_ui.h:776
bool DisplayShellFolder(FCString *pFolderString)
Opens the file or folder in the operating system's workspace.
Definition finaleframework.cpp:24217
bool MenuPositionCommand(int mainmenuidx, int dropdownidx, int submenuidx)
Executes a menu command from a specific location in Finale's menu. Use this method with care!
Definition finaleframework.cpp:23663
ALERT_RETURNS
The return values used by the alert box methods.
Definition ff_ui.h:54
@ UNKNOWNRETURN
Definition ff_ui.h:69
@ YESRETURN
Definition ff_ui.h:63
@ NORETURN
Definition ff_ui.h:66
@ OKRETURN
Definition ff_ui.h:57
@ CANCELRETURN
Definition ff_ui.h:60
void SetUseIsFontAvailableAPI(bool state)
Sets if Finale's own API for checking font availability should be used for IsFontAvailable().
Definition ff_ui.h:663
EWND GetDocumentWindow()
Return the window handle to the current document window.
Definition finaleframework.cpp:23926
bool IsOnWindows() const
Returns true if the user runs on Windows.
Definition ff_ui.h:682
twobyte GetZoomLevel() const
Returns the current zoom level.
Definition finaleframework.cpp:23910
void AlertInfoCString(const char *pszMessage, const char *pszTitle=NULL)
Displays an information message box / alert, with an OK button. C string version.
Definition finaleframework.cpp:23297
ALERT_RETURNS AlertYesNo(FCString *pMessage, FCString *pTitle=NULL)
Displays a error message box / alert, with Yes+No buttons. FCString version.
Definition finaleframework.cpp:23132
void StartPerformanceTimer()
Starts the high-resolution timer.
Definition finaleframework.cpp:24246
bool GetUseIsFontAvailableAPI() const
Returns if Finale's own API for checking font availability should be used for IsFontAvailable().
Definition ff_ui.h:676
bool IsPageView() const
Returns true if the current view for the current document is Page View.
Definition finaleframework.cpp:23818
bool IsFontAvailable(FCString *pFontName)
Returns true if the font name exists on the running system.
Definition finaleframework.cpp:24148
bool ActivateDocumentWindow()
Brings the current document window to user focus.
Definition finaleframework.cpp:23941
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_ui.h:315
bool IsLayerVisible(twobyte layernum) const
Returns true for any valid layer number unless "Show Active Layer Only" is checked....
Definition ff_ui.h:630
twobyte GetCurrentPage() const
Returns the currently displayed page number in Page View.
Definition finaleframework.cpp:23877
bool TextToClipboardUTF8(const char *pszText)
Copies text to the operating system's clipboard from an UTF8 source.
Definition finaleframework.cpp:23854
ALERT_RETURNS AlertYesNoCString(const char *pszMessage, const char *pszTitle=NULL)
Displays a error message box / alert, with Yes+No buttons. C string version.
Definition finaleframework.cpp:23109
MENU_COMMANDS
The menu commands available to the FCUI::MenuCommand() method.
Definition ff_ui.h:77
@ MENUCMD_CREATEMMRESTS
Definition ff_ui.h:194
@ MENUCMD_TIMESIGTOOL
Definition ff_ui.h:212
@ MENUCMD_TEMPOTOOL
Definition ff_ui.h:263
@ MENUCMD_EHSPELLING_USESPELLINGTABLES
Definition ff_ui.h:142
@ MENUCMD_STAFFSETALLSTAVES
Definition ff_ui.h:164
@ MENUCMD_CHORDTOOL
Definition ff_ui.h:224
@ MENUCMD_OSSIATOOL
Definition ff_ui.h:251
@ MENUCMD_CLEARALLITEMS
Definition ff_ui.h:130
@ MENUCMD_FILLWITHRESTS
Definition ff_ui.h:112
@ MENUCMD_VIEWPAGEVIEW
Definition ff_ui.h:151
@ MENUCMD_REBEAM
Definition ff_ui.h:145
@ MENUCMD_HYPERSCRIBETOOL
Definition ff_ui.h:236
@ MENUCMD_MOVETONEXTSYSTEM
Definition ff_ui.h:100
@ MENUCMD_TIMESIGSPACING
Definition ff_ui.h:91
@ MENUCMD_PAGELAYOUTTOOL
Definition ff_ui.h:254
@ MENUCMD_REPEATTOOL
Definition ff_ui.h:218
@ MENUCMD_HANDGRABBERTOOL
Definition ff_ui.h:233
@ MENUCMD_ZOOMTOOL
Definition ff_ui.h:272
@ MENUCMD_VIEWSTUDIOVIEW
Definition ff_ui.h:154
@ MENUCMD_RESPELLNOTES
Definition ff_ui.h:94
@ MENUCMD_NULL
Definition ff_ui.h:79
@ MENUCMD_CLEFTOOL
Definition ff_ui.h:215
@ MENUCMD_STAFFSET4
Definition ff_ui.h:176
@ MENUCMD_STAFFSET7
Definition ff_ui.h:185
@ MENUCMD_CHECKTIES
Definition ff_ui.h:109
@ MENUCMD_RETRANSCRIBE
Definition ff_ui.h:191
@ MENUCMD_EHSPELLING_FAVORFLATS
Definition ff_ui.h:139
@ MENUCMD_MIDITOOL
Definition ff_ui.h:242
@ MENUCMD_EXPRESSIONTOOL
Definition ff_ui.h:227
@ MENUCMD_LOCKSYSTEMS
Definition ff_ui.h:103
@ MENUCMD_STEMDIRECTIONDOWN
Definition ff_ui.h:124
@ MENUCMD_TUPLETTOOL
Definition ff_ui.h:269
@ MENUCMD_STEMDIRECTIONUP
Definition ff_ui.h:121
@ MENUCMD_EHSPELLING_DEFAULT
Definition ff_ui.h:133
@ MENUCMD_KEYSIGTOOL
Definition ff_ui.h:209
@ MENUCMD_STAFFSET8
Definition ff_ui.h:188
@ MENUCMD_STAFFTOOL
Definition ff_ui.h:203
@ MENUCMD_REDRAWSCREEN
Definition ff_ui.h:158
@ MENUCMD_BREAKMMRESTS
Definition ff_ui.h:197
@ MENUCMD_UNLOCKSYSTEMS
Definition ff_ui.h:106
@ MENUCMD_SELECTIONTOOL
Definition ff_ui.h:200
@ MENUCMD_MEASURETOOL
Definition ff_ui.h:206
@ MENUCMD_NOTESPACING
Definition ff_ui.h:83
@ MENUCMD_RESIZETOOL
Definition ff_ui.h:257
@ MENUCMD_STAFFSET1
Definition ff_ui.h:167
@ MENUCMD_STEMDIRECTIONDEFAULT
Definition ff_ui.h:127
@ MENUCMD_STAFFSET3
Definition ff_ui.h:173
@ MENUCMD_EDITSCORE
Definition ff_ui.h:161
@ MENUCMD_EHSPELLING_FAVORSHARPS
Definition ff_ui.h:136
@ MENUCMD_RESETALLGROUPSANDBRACKETS
Definition ff_ui.h:118
@ MENUCMD_ARTICULATIONTOOL
Definition ff_ui.h:221
@ MENUCMD_STAFFSET2
Definition ff_ui.h:170
@ MENUCMD_REMOVEMANUALSLURADJUSTMENTS
Definition ff_ui.h:115
@ MENUCMD_NOTEMOVERTOOL
Definition ff_ui.h:248
@ MENUCMD_SPEEDYENTRYTOOL
Definition ff_ui.h:260
@ MENUCMD_LYRICSTOOL
Definition ff_ui.h:239
@ MENUCMD_MIRRORTOOL
Definition ff_ui.h:245
@ MENUCMD_GRAPHICSTOOL
Definition ff_ui.h:230
@ MENUCMD_BEATSPACING
Definition ff_ui.h:87
@ MENUCMD_STAFFSET6
Definition ff_ui.h:182
@ MENUCMD_TEXTTOOL
Definition ff_ui.h:266
@ MENUCMD_STAFFSET5
Definition ff_ui.h:179
@ MENUCMD_VIEWSCROLLVIEW
Definition ff_ui.h:148
@ MENUCMD_MOVETOPREVSYSTEM
Definition ff_ui.h:97
bool DisplayListenToMidiDialog(FCListenToMidiResult *result)
Displays the ListenToMidi dialog.
Definition finaleframework.cpp:24117
CMPER DisplayTextExpressionDialog(CMPER cmperinit=0)
Displays the expression selection dialog.
Definition finaleframework.cpp:24018
double ReturnPerformanceTiming()
Calculates the time difference after a start+stop of the hi-resolution timer.
Definition finaleframework.cpp:24268
ALERT_RETURNS AlertYesNoCancel(FCString *pMessage, FCString *pTitle=NULL)
Displays a error message box / alert, with Yes+No+Cancel buttons. FCString version.
Definition finaleframework.cpp:23174
twobyte GetCurrentMeasure() const
Returns the currently displayed measure number in Scroll View.
Definition finaleframework.cpp:23894
void AlertNeutralUTF8(const char *pszMessage, const char *pszTitle=NULL)
Displays a standard message box / alert, with an OK button. UTF8 verison.
Definition finaleframework.cpp:23272
void AlertNeutralCString(const char *pszMessage, const char *pszTitle=NULL)
Displays a standard message box / alert, with an OK button. C string verison.
Definition finaleframework.cpp:23263
static double GetHiResTimer()
Returns a high-resolution timer value, mainly for use with internal profilers.
Definition finaleframework.cpp:24286
CMPER DisplayShapeDialog(CMPER cmperinit=0)
Displays the shape definition selection dialog box.
Definition finaleframework.cpp:24069
std::pair< CMPER, bool > DisplayExpressionDialog(CMPER cmperinit=0, bool isshape=false)
Displays the expression selection dialog.
Definition finaleframework.cpp:24034
EWND GetActiveWindow()
Returns the currently active window.
Definition finaleframework.cpp:23950