Finale PDK Framework  0.54
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 
19 
25 class FCUI : public __FCBase
26 {
27  /* Use Finale's API for verifying font exist (default is OFF on Windows only, for performance reasons) */
28  bool _useFinaleFontExistAPI;
29 
30  EWND _parentwindow;
31 
32  bool _starttimerfound, _endtimerfound, _performancefrequencyfound; /* For the performance timer */
33 
34 #if OPERATING_SYSTEM == MAC_OS
35  _FCUI_cocoa _fcuicocoa;
36 #endif
37 
38 #if OPERATING_SYSTEM == WINDOWS
39 
40  int __Windows_MessageBox(FCString* pMessage, FCString* pTitle, int styles);
41 #endif
42 public:
48 
50  OKRETURN = 0,
51 
54 
57 
60 
63  };
64 
73 
77 
81 
85 
88 
91 
94 
97 
100 
103 
106 
109 
112 
115 
118 
121 
124 
127 
130 
133 
136 
139 
142 
145 
148 
152 
155 
158 
161 
164 
167 
170 
173 
176 
179 
182 
185 
188 
191 
194 
197 
200 
203 
206 
209 
212 
215 
218 
221 
224 
227 
230 
233 
236 
239 
242 
245 
248 
251 
254 
257 
260 
263 
266  };
267 
268 
273  FCUI(EWND parent) : __FCBase()
274  {
275  _parentwindow = parent;
276  _starttimerfound = false;
277  _endtimerfound = false;
278  _performancefrequencyfound = false;
279  WINCODE(_useFinaleFontExistAPI = false;) /* OFF because of huge performance issues when font name isn't found. */
280  MACCODE(_useFinaleFontExistAPI = true;) /* API is fast on the Mac */
281  }
282 
283  const char* ClassName() { return "FCUI"; }
284 
291  void AlertErrorCString(const char* pszMessage, const char* pszTitle = NULL);
292 
300  void AlertErrorUTF8(const char* pszMessage, const char* pszTitle = NULL);
301 
307  void AlertError(FCString* pMessage, FCString* pTitle = NULL);
308 
316 #ifndef PDK_FRAMEWORK_LUAFRIENDLY
318 #else
319  int
320 #endif
321  AlertYesNoCString(const char* pszMessage, const char* pszTitle = NULL);
322 
332 #ifndef PDK_FRAMEWORK_LUAFRIENDLY
334 #else
335  int
336 #endif
337  AlertYesNoUTF8(const char* pszMessage, const char* pszTitle = NULL);
338 
348  ALERT_RETURNS AlertYesNo(FCString* pMessage, FCString* pTitle = NULL);
349 
357 #ifndef PDK_FRAMEWORK_LUAFRIENDLY
359 #else
360  int
361 #endif
362  AlertYesNoCancelUTF8(const char* pszMessage, const char* pszTitle);
363 
371  ALERT_RETURNS AlertYesNoCancel(FCString* pMessage, FCString* pTitle = NULL);
372 
380 #ifndef PDK_FRAMEWORK_LUAFRIENDLY
382 #else
383  int
384 #endif
385  AlertOkCancelCString(const char* pszMessage, const char* pszTitle = NULL);
386 
396 #ifndef PDK_FRAMEWORK_LUAFRIENDLY
398 #else
399  int
400 #endif
401  AlertOkCancelUTF8(const char* pszMessage, const char* pszTitle = NULL);
402 
410  ALERT_RETURNS AlertOkCancel(FCString* pMessage, FCString* pTitle = NULL);
411 
417  void AlertNeutralCString(const char* pszMessage, const char* pszTitle = NULL);
418 
424  void AlertNeutralUTF8(const char* pszMessage, const char* pszTitle = NULL);
425 
431  void AlertNeutral(FCString* pMessage, FCString* pTitle = NULL);
432 
438  void AlertInfoCString(const char* pszMessage, const char* pszTitle = NULL);
439 
447  void AlertInfoUTF8(const char* pszMessage, const char* pszTitle = NULL);
448 
454  void AlertInfo(FCString* pMessage, FCString* pTitle = NULL);
455 
464  bool MenuCommand(
465 #ifndef PDK_FRAMEWORK_LUAFRIENDLY
466 MENU_COMMANDS menucmd
467 #else
468 int menucmd
469 #endif
470  );
471 
495  bool MenuPositionCommand(int mainmenuidx, int dropdownidx, int submenuidx);
496 
504  void RedrawDocument();
505 
512  bool IsPageView();
513 
519  bool IsPartView() { return (FX_GetCurrentPartID() != 0); }
520 
530  void GetDecimalSeparator(FCString* pString);
531 
543  void SetUseIsFontAvailableAPI(bool state) { _useFinaleFontExistAPI = state; }
544 
556  bool GetUseIsFontAvailableAPI() const { return _useFinaleFontExistAPI; }
557 
562  bool IsOnWindows()
563  {
564  WINCODE(return true;)
565  MACCODE(return false;)
566  }
567 
573  bool IsOnMac()
574  {
575  WINCODE(return false;)
576  MACCODE(return true;)
577  }
578 
585  bool TextToClipboard(const char* pszText);
586 
596  bool TextToClipboardUTF8(const char* pszText);
597 
604  twobyte GetCurrentPage() const;
605 
612  twobyte GetCurrentMeasure() const;
613 
618  twobyte GetZoomLevel() const;
619 
629  int GetMaxLayers() const;
630 
635  EWND GetDocumentWindow();
636 
643  bool ActivateDocumentWindow();
644 
646  EWND GetActiveWindow();
647 
649  bool ActivateWindow(EWND hwnd);
650 
656  EWND GetParentWindow() { return _parentwindow; }
657 
668  void MoveToMeasure(int measure, int staffno = 0);
669 
674  void Beep();
675 
680  int GetScreenWidth() const;
681 
686  int GetScreenHeight() const;
687 
698  CMPER DisplayTextExpressionDialog(CMPER cmperinit = 0);
699 
710  CMPER DisplayArticulationDialog(CMPER cmperinit = 0);
711 
722  CMPER DisplayShapeDialog(CMPER cmperinit = 0);
723 
733  eUniChar32 DisplaySymbolDialog(FCFontInfo* pFontInfo, eUniChar32 symbolinit = 0);
734 
742  bool IsFontAvailable(FCString* pFontName);
743 
748  bool DisplayWebURL(FCString* pURLString);
749 
758  bool DisplayShellFolder(FCString* pFolderString);
759 
761  void StartPerformanceTimer();
762 
764  void StopPerformanceTimer();
765 
767  double ReturnPerformanceTiming();
768 
774  static double GetHiResTimer();
775 
776 #ifdef PDK_FRAMEWORK_DEBUG
777  virtual void DebugDump()
778  {
780  DebugOutPtr("Parent Window: ", GetParentWindow());
781  DebugOutPtr("Document Window: ", GetDocumentWindow());
782  }
783 #endif
784 };
785 
786 #endif /* FF_UI_H */
787 
Class for document-independent font information.
Definition: ff_base.h:1024
void AlertNeutral(FCString *pMessage, FCString *pTitle=NULL)
Displays a standard message box / alert, with an OK button. FCString version.
Definition: finaleframework.cpp:21123
void MoveToMeasure(int measure, int staffno=0)
Moves the view to the indicated 1-based measure.
Definition: finaleframework.cpp:21726
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:21137
eUniChar32 DisplaySymbolDialog(FCFontInfo *pFontInfo, eUniChar32 symbolinit=0)
Displays the symbol selection dialog.
Definition: finaleframework.cpp:21815
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:21055
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:21069
Definition: ff_ui.h:214
Definition: ff_ui.h:126
bool MenuCommand(MENU_COMMANDS menucmd)
Executes a supported menu command from Finale's menu.
Definition: finaleframework.cpp:21170
Definition: ff_ui.h:259
Definition: ff_ui.h:141
Definition: ff_ui.h:232
const char * ClassName()
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition: ff_ui.h:283
static double GetHiResTimer()
Returns a high-resolution timer value, mainly for use with internal profilers.
Definition: finaleframework.cpp:22004
Definition: ff_ui.h:190
Definition: ff_ui.h:84
double ReturnPerformanceTiming()
Calculates the time difference after a start+stop of the hi-resolution timer.
Definition: finaleframework.cpp:21986
Definition: ff_ui.h:144
Definition: ff_ui.h:117
bool ActivateWindow(EWND hwnd)
Activates a specific window.
Definition: finaleframework.cpp:21714
MENU_COMMANDS
The menu commands available to the FCUI::MenuCommand() method.
Definition: ff_ui.h:70
twobyte GetCurrentMeasure() const
Returns the currently displayed measure number in Scroll View.
Definition: finaleframework.cpp:21649
FCUI(EWND parent)
The constructor.
Definition: ff_ui.h:273
bool IsPageView()
Returns true if the current view for the current document is Page View.
Definition: finaleframework.cpp:21573
Definition: ff_ui.h:229
Definition: ff_ui.h:80
ALERT_RETURNS
The return values used by the alert box methods.
Definition: ff_ui.h:47
Definition: ff_ui.h:193
int GetScreenHeight() const
Returns the height in pixels of the primary screen.
Definition: finaleframework.cpp:21759
Definition: ff_ui.h:253
Definition: ff_ui.h:154
Definition: ff_ui.h:160
Definition: ff_ui.h:62
Definition: ff_ui.h:96
twobyte GetCurrentPage() const
Returns the currently displayed page number in Page View.
Definition: finaleframework.cpp:21632
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:20919
Definition: ff_ui.h:256
Definition: ff_ui.h:50
void AlertInfo(FCString *pMessage, FCString *pTitle=NULL)
Displays an information message box / alert, with an OK button. FCString version. ...
Definition: finaleframework.cpp:21155
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:21501
CMPER DisplayShapeDialog(CMPER cmperinit=0)
Displays the shape definition selection dialog box.
Definition: finaleframework.cpp:21801
void AlertInfoUTF8(const char *pszMessage, const char *pszTitle=NULL)
Displays an information message box / alert, with an OK button. UTF8 version.
Definition: finaleframework.cpp:21146
Definition: ff_ui.h:76
EWND GetParentWindow()
Returns the window handle to the main window (that was passed to the constructor.) ...
Definition: ff_ui.h:656
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:20957
Definition: ff_ui.h:166
Definition: ff_ui.h:220
bool DisplayShellFolder(FCString *pFolderString)
Opens the file or folder in the operating system's workspace.
Definition: finaleframework.cpp:21935
Definition: ff_ui.h:169
Definition: ff_ui.h:178
ALERT_RETURNS AlertYesNo(FCString *pMessage, FCString *pTitle=NULL)
Displays a error message box / alert, with Yes+No buttons. FCString version.
Definition: finaleframework.cpp:20980
Definition: ff_ui.h:102
Definition: ff_ui.h:211
bool TextToClipboardUTF8(const char *pszText)
Copies text to the operating system's clipboard from an UTF8 source.
Definition: finaleframework.cpp:21609
Definition: ff_ui.h:184
CMPER DisplayTextExpressionDialog(CMPER cmperinit=0)
Displays the text expression definition selection dialog.
Definition: finaleframework.cpp:21773
Definition: ff_ui.h:163
Standard class for basic user interface functionality.
Definition: ff_ui.h:25
void StopPerformanceTimer()
Stops the high-resolution timer.
Definition: finaleframework.cpp:21977
Definition: ff_ui.h:120
Definition: ff_ui.h:105
ALERT_RETURNS AlertYesNoCancel(FCString *pMessage, FCString *pTitle=NULL)
Displays a error message box / alert, with Yes+No+Cancel buttons. FCString version.
Definition: finaleframework.cpp:21020
Definition: ff_ui.h:223
Base class for the Finale Framework classes.
Definition: ff_base.h:47
bool IsFontAvailable(FCString *pFontName)
Returns true if the font name exists on the running system.
Definition: finaleframework.cpp:21866
virtual void DebugDump()
Outputs the class data/information for debugging purposes.
Definition: ff_ui.h:777
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:20971
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:20928
Definition: ff_ui.h:99
void StartPerformanceTimer()
Starts the high-resolution timer.
Definition: finaleframework.cpp:21964
Definition: ff_ui.h:172
Definition: ff_ui.h:53
Definition: ff_ui.h:265
Definition: ff_ui.h:202
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:21105
Definition: ff_ui.h:238
Definition: ff_ui.h:247
Definition: ff_ui.h:93
Definition: ff_ui.h:59
void AlertError(FCString *pMessage, FCString *pTitle=NULL)
Displays a error message box / alert, with an OK button. FCString version.
Definition: finaleframework.cpp:20937
Definition: ff_ui.h:175
Definition: ff_ui.h:217
bool IsOnWindows()
Returns true if the user runs on Windows.
Definition: ff_ui.h:562
Definition: ff_ui.h:56
Definition: ff_ui.h:196
Class that provides storage for text. This is to achieve platform-transparent text handling...
Definition: ff_base.h:1473
Definition: ff_ui.h:262
Definition: ff_ui.h:250
CMPER DisplayArticulationDialog(CMPER cmperinit=0)
Displays the articulation definition selection dialog.
Definition: finaleframework.cpp:21787
Definition: ff_ui.h:226
bool TextToClipboard(const char *pszText)
Copies text to the operating system's clipboard.
Definition: finaleframework.cpp:21589
ALERT_RETURNS AlertOkCancel(FCString *pMessage, FCString *pTitle=NULL)
Displays a error message box / alert, with Ok+Cancel buttons. FCString version.
Definition: finaleframework.cpp:21078
Definition: ff_ui.h:244
Definition: ff_ui.h:241
void Beep()
Gives a beep from the speaker.
Definition: finaleframework.cpp:21740
bool IsOnMac()
Returns true if the user runs on the Mac.
Definition: ff_ui.h:573
EWND GetDocumentWindow()
Return the window handle to the current document window.
Definition: finaleframework.cpp:21681
bool ActivateDocumentWindow()
Brings the current document window to user focus.
Definition: finaleframework.cpp:21696
int GetScreenWidth() const
Returns the width in pixels of the primary screen.
Definition: finaleframework.cpp:21750
bool IsPartView()
Returns true if the current view is in a part (=not in the score).
Definition: ff_ui.h:519
Definition: ff_ui.h:208
Definition: ff_ui.h:187
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:258
twobyte GetZoomLevel() const
Returns the current zoom level.
Definition: finaleframework.cpp:21665
Definition: ff_ui.h:123
bool GetUseIsFontAvailableAPI() const
Returns if Finale's own API for checking font availability should be used for IsFontAvailable().
Definition: ff_ui.h:556
Definition: ff_ui.h:138
Definition: ff_ui.h:114
void RedrawDocument()
Visually redraws the current document.
Definition: finaleframework.cpp:21548
int GetMaxLayers() const
Returns the maximum number of layers that Finale supports.
Definition: finaleframework.cpp:21768
void GetDecimalSeparator(FCString *pString)
Fills a FCString with the decimal separator used for the current user's locale.
Definition: finaleframework.cpp:21560
Definition: ff_ui.h:90
Definition: ff_ui.h:151
Definition: ff_ui.h:72
Definition: ff_ui.h:181
Definition: ff_ui.h:147
Definition: ff_ui.h:199
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:21011
Definition: ff_ui.h:157
EWND GetActiveWindow()
Returns the currently active window.
Definition: finaleframework.cpp:21705
bool DisplayWebURL(FCString *pURLString)
Displays an URL in an external web browser.
Definition: finaleframework.cpp:21918
Definition: ff_ui.h:87
void AlertNeutralUTF8(const char *pszMessage, const char *pszTitle=NULL)
Displays a standard message box / alert, with an OK button. UTF8 verison.
Definition: finaleframework.cpp:21114
Definition: ff_ui.h:235
void SetUseIsFontAvailableAPI(bool state)
Sets if Finale's own API for checking font availability should be used for IsFontAvailable().
Definition: ff_ui.h:543
Definition: ff_ui.h:205
virtual void DebugDump()
Outputs the class data/information for debugging purposes.
Definition: finaleframework.cpp:547