Finale PDK Framework  0.54
fflua_customluawindow.h
1 /*
2  * File: fflua_customluawindow.h
3  *
4  * Created by Jari Williamsson on 2015-11-01.
5  *
6  * ******* IMPORTANT!!! ******
7  * Although this file is available in the PDK Framework folder, it should NOT be used in
8  * the PDK Framework umbrella. This file is placed in the framework folder purely ONLY to
9  * provide online documentation for the FCCustomLuaWindow class!
10  *
11  * (The file will ONLY make sense in the context of the specific
12  * jwlua_luabridgeconnect.cpp implementation.)
13  *
14  * The following class implementation is for the special FCCustomLuaWindow class in JW Lua. Since
15  * a limitation of LuaBridge is that the include file can only be included at one place,
16  * this work-around is used.
17  */
18 
19 
20 
21 #ifndef jwlua_fflua_customluawindow_h
22 #define jwlua_fflua_customluawindow_h
23 
34 {
35  /* Lua event handlers */
36  luabridge::LuaRef _handleCommand;
37  luabridge::LuaRef _handleUpDownPressed;
38  luabridge::LuaRef _handleDataListSelect;
39  luabridge::LuaRef _handleDataListCheck;
40  luabridge::LuaRef _handleCancelButtonPressed;
41  luabridge::LuaRef _handleOkButtonPressed;
42  luabridge::LuaRef _handleInitWindow;
43 
44  bool _RegisterHandler(luabridge::LuaRef &class_storage, luabridge::LuaRef &lua_callback_function)
45  {
46  if (!lua_callback_function.isFunction()) return false;
47  class_storage = lua_callback_function;
48  return true;
49  }
50 
51  void _OutputExceptionError(luabridge::LuaException e)
52  {
53  FCString errstring;
54  errstring.SetCString(e.what());
55  LuaRun_AppendLineToOutput(&errstring);
56  }
57 public:
63  _handleCommand(_pGlobal_LuaState),
64  _handleUpDownPressed(_pGlobal_LuaState),
65  _handleDataListSelect(_pGlobal_LuaState),
66  _handleDataListCheck(_pGlobal_LuaState),
67  _handleCancelButtonPressed(_pGlobal_LuaState),
68  _handleOkButtonPressed(_pGlobal_LuaState),
69  _handleInitWindow(_pGlobal_LuaState)
70  {}
71 
81  bool RegisterHandleCommand(luabridge::LuaRef lua_callback_function)
82  {
83  return _RegisterHandler(_handleCommand, lua_callback_function);
84  }
85 
95  bool RegisterHandleUpDownPressed(luabridge::LuaRef lua_callback_function)
96  {
97  return _RegisterHandler(_handleUpDownPressed, lua_callback_function);
98  }
99 
109  bool RegisterHandleDataListSelect(luabridge::LuaRef lua_callback_function)
110  {
111  return _RegisterHandler(_handleDataListSelect, lua_callback_function);
112  }
113 
123  bool RegisterHandleDataListCheck(luabridge::LuaRef lua_callback_function)
124  {
125  return _RegisterHandler(_handleDataListCheck, lua_callback_function);
126  }
127 
137  bool RegisterHandleCancelButtonPressed(luabridge::LuaRef lua_callback_function)
138  {
139  return _RegisterHandler(_handleCancelButtonPressed, lua_callback_function);
140  }
141 
151  bool RegisterHandleOkButtonPressed(luabridge::LuaRef lua_callback_function)
152  {
153  return _RegisterHandler(_handleOkButtonPressed, lua_callback_function);
154  }
155 
165  bool RegisterInitWindow(luabridge::LuaRef lua_callback_function)
166  {
167  return _RegisterHandler(_handleInitWindow, lua_callback_function);
168  }
169 
177  virtual bool HandleCommand(FCControl* pControl)
178  {
179  bool result = FCCustomWindow::HandleCommand(pControl);
180  if (pControl && _handleCommand.isFunction())
181  {
182  try
183  {
184  _handleCommand(pControl);
185  }
186  catch (luabridge::LuaException e)
187  {
188  _OutputExceptionError(e);
189  }
190  }
191  return result;
192  }
193 
203  virtual void HandleUpDownPressed(FCControl* pControl, int delta)
204  {
205  FCCustomWindow::HandleUpDownPressed(pControl, delta);
206  if (pControl && _handleUpDownPressed.isFunction())
207  {
208  try
209  {
210  _handleUpDownPressed(pControl, delta);
211  }
212  catch (luabridge::LuaException e)
213  {
214  _OutputExceptionError(e);
215  }
216  }
217  }
218 
227  virtual void HandleDataListSelect(FCCtrlDataList* pControl, int lineindex)
228  {
229  FCCustomWindow::HandleDataListSelect(pControl, lineindex);
230  if (pControl && _handleDataListSelect.isFunction())
231  {
232  try
233  {
234  _handleDataListSelect(pControl, lineindex);
235  }
236  catch (luabridge::LuaException e)
237  {
238  _OutputExceptionError(e);
239  }
240  }
241  }
242 
252  virtual void HandleDataListCheck(FCCtrlDataList* pControl, int lineindex, bool checkstate)
253  {
254  FCCustomWindow::HandleDataListCheck(pControl, lineindex, checkstate);
255  if (pControl && _handleDataListCheck.isFunction())
256  {
257  try
258  {
259  _handleDataListCheck(pControl, lineindex, checkstate);
260  }
261  catch (luabridge::LuaException e)
262  {
263  _OutputExceptionError(e);
264  }
265  }
266  }
267 
273  virtual void CancelButtonPressed()
274  {
275  if (_handleCancelButtonPressed.isFunction())
276  {
277  try
278  {
279  _handleCancelButtonPressed();
280  }
281  catch (luabridge::LuaException e)
282  {
283  _OutputExceptionError(e);
284  }
285  }
287  }
288 
294  virtual void OkButtonPressed()
295  {
296  if (_handleOkButtonPressed.isFunction())
297  {
298  try
299  {
300  _handleOkButtonPressed();
301  }
302  catch (luabridge::LuaException e)
303  {
304  _OutputExceptionError(e);
305  }
306  }
308  }
309 
314  virtual void InitWindow()
315  {
317  if (_handleInitWindow.isFunction())
318  {
319  try
320  {
321  _handleInitWindow();
322  }
323  catch (luabridge::LuaException e)
324  {
325  _OutputExceptionError(e);
326  }
327  }
328  }
329 };
330 
331 #endif
bool RegisterInitWindow(luabridge::LuaRef lua_callback_function)
Registers a Lua function to the InitWindow() event handler.
Definition: fflua_customluawindow.h:165
virtual void CancelButtonPressed()
Virtual handler method that is called when a control with a "Cancel" action is pressed by the user...
Definition: fflua_customluawindow.h:273
bool RegisterHandleDataListCheck(luabridge::LuaRef lua_callback_function)
Registers a Lua function to the HandleDataListCheck() event handler.
Definition: fflua_customluawindow.h:123
bool RegisterHandleOkButtonPressed(luabridge::LuaRef lua_callback_function)
Registers a Lua function to the OkButtonPressed() event handler.
Definition: fflua_customluawindow.h:151
void SetCString(const char *pszBuffer, int maxchars=-1)
Sets the string, using a C-string version of the string.
Definition: finaleframework.cpp:1030
virtual void HandleUpDownPressed(FCControl *pControl, int delta)
Virtual handler method for up/down arrow controls when they are clicked. Overwrite to provide functio...
Definition: ff_dialogs.h:1042
FCCustomLuaWindow()
The constructor.
Definition: fflua_customluawindow.h:62
virtual void InitWindow()
Inherited implementation of InitWindow().
Definition: finaleframework.cpp:26482
Class that handles a contol with multiple lines of data, arranged in columns.
Definition: ff_dialogs.h:2357
Definition: ff_dialogs.h:1237
virtual bool HandleCommand(FCControl *pControl)
Virtual method that is called when a user command occurs, such as a button press. ...
Definition: ff_dialogs.h:1024
virtual void HandleDataListCheck(FCCtrlDataList *pControl, int lineindex, bool checkstate)
Virtual handler method for when FCCtrlDataList check state changes (for data list controls with check...
Definition: fflua_customluawindow.h:252
virtual bool HandleCommand(FCControl *pControl)
Virtual method that is called when a user command occurs, such as a button press. ...
Definition: fflua_customluawindow.h:177
virtual void OkButtonPressed()
Virtual handler method that is called when a control with a "OK" action is pressed by the user...
Definition: ff_dialogs.h:998
virtual void HandleDataListCheck(FCCtrlDataList *pControl, int lineindex, bool checkstate)
Virtual handler method for when FCCtrlDataList check state changes (for data list controls with check...
Definition: ff_dialogs.h:1062
bool RegisterHandleCancelButtonPressed(luabridge::LuaRef lua_callback_function)
Registers a Lua function to the CancelButtonPressed() event handler.
Definition: fflua_customluawindow.h:137
virtual void OkButtonPressed()
Virtual handler method that is called when a control with a "OK" action is pressed by the user...
Definition: fflua_customluawindow.h:294
virtual void HandleDataListSelect(FCCtrlDataList *pControl, int lineindex)
Virtual handler method for when FCCtrlDataList selection state changes.
Definition: fflua_customluawindow.h:227
bool RegisterHandleDataListSelect(luabridge::LuaRef lua_callback_function)
Registers a Lua function to the HandleDataListSelect() event handler.
Definition: fflua_customluawindow.h:109
bool RegisterHandleCommand(luabridge::LuaRef lua_callback_function)
Registers a Lua function to the HandleCommand() event handler.
Definition: fflua_customluawindow.h:81
Class that provides storage for text. This is to achieve platform-transparent text handling...
Definition: ff_base.h:1473
bool RegisterHandleUpDownPressed(luabridge::LuaRef lua_callback_function)
Registers a Lua function to the HandleUpDownPressed() event handler.
Definition: fflua_customluawindow.h:95
Special FCCustomWindow child class, that provides the additional functionality to hook up JW Lua call...
Definition: fflua_customluawindow.h:33
virtual void HandleDataListSelect(FCCtrlDataList *pControl, int lineindex)
Virtual handler method for when FCCtrlDataList selection state changes. Overwrite to provide function...
Definition: ff_dialogs.h:1051
virtual void CancelButtonPressed()
Virtual handler method that is called when a control with a "Cancel" action is pressed by the user...
Definition: ff_dialogs.h:1013
virtual void HandleUpDownPressed(FCControl *pControl, int delta)
Virtual handler method for up/down arrow controls when they are clicked.
Definition: fflua_customluawindow.h:203
virtual void InitWindow()
Virtual handler method that is called when a window just has been created, but not yet shown...
Definition: fflua_customluawindow.h:314
A class that supports programmatically created controls (that are not defined in resource files)...
Definition: ff_dialogs.h:3896