DI-Guy SDK Documentation  13.2
diguyViewButtonPanel.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2019 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************
8  **
9  *t diguyViewButtonPanel
10  **
11  *b Link against: libdiguy
12  */
13 
14 #ifndef __diguyViewButtonPanel_H
15 #define __diguyViewButtonPanel_H
16 
17 #ifdef SWIG
19 #else
20 #define CPLUSPLUS_ONLY
21 #endif
22 
23 #ifdef CPLUSPLUS_ONLY
24 class bdiViewButtonPanel;
25 #include <declspec_diguy.h>
26 // for NULL
27 #include <stdlib.h>
28 
29 typedef bdiViewButtonPanel* makeButtonPanelCallback(const char* name,
30  int horizontal,
31  int title);
32 
33 #endif
34 
35 
36 /****************************************************************************/
37 class BDI_DECLSPEC_diguy diguyViewButtonPanel
38 {
39 
40 public:
41 
42  /*l
43  *b Description:
44  **
45  ** Returns the named button panel or creates it.
46  **
47  *b Arguments:
48  **
49  *a name - name of panel (must be unique)
50  *a horizontal - if 1, make a horizontal panel
51  *a title - if 1, show panel title
52  **
53  *b Returns:
54  **
55  ** pointer to the button panel
56  **
57  *b Callable From:
58  **
59  *- - C++
60  *- - Script
61  */
62  static diguyViewButtonPanel* find_or_create_instance(const char* name,
63  int horizontal = 0,
64  int title = 1);
65 
66  /*l
67  *b Description:
68  **
69  ** Makes a button panel with the given name and attributes.
70  **
71  *b Arguments:
72  **
73  *a name - name of panel (must be unique)
74  *a horizontal - if 1, make a horizontal panel
75  *a title - if 1, show panel title
76  **
77  *b Returns:
78  **
79  ** pointer to the button panel
80  **
81  *b Callable From:
82  **
83  *- - C++
84  *- - Script
85  */
86  static diguyViewButtonPanel* make_instance(const char* name,
87  int horizontal = 0,
88  int title = 1);
89 
90  /*l
91  *b Description:
92  **
93  ** Returns a pointer to the named button panel, if it exists.
94  * Otherwise returns NULL.
95  **
96  *b Arguments:
97  **
98  *a name - name of panel
99  **
100  *b Returns:
101  **
102  ** pointer to the button panel or NULL
103  **
104  *b Callable From:
105  **
106  *- - C++
107  *- - Script
108  */
109  static diguyViewButtonPanel* get_instance(const char* name);
110 
111  /*l
112  *b Description:
113  **
114  ** Destroys named button panel, if found.
115  **
116  *b Arguments:
117  **
118  *a name - name of panel
119  **
120  *b Returns:
121  **
122  ** 0 on success, -1 on failure
123  **
124  *b Callable From:
125  **
126  *- - C++
127  *- - Script
128  */
129  static int destroy_instance(const char* name);
130 
131  /*l
132  *b Description:
133  **
134  ** Destroys all button panels.
135  **
136  *b Returns:
137  **
138  ** 0 on success, -1 on failure
139  **
140  *b Callable From:
141  **
142  *- - C++
143  *- - Script
144  */
145  static int destroy_all();
146 
147  /*l
148  *b Description:
149  **
150  ** Returns the name of the object. This pointer will never be NULL.
151  **
152  *b Returns:
153  **
154  ** name of the object
155  **
156  *b Callable From:
157  **
158  *- - C++
159  *- - Script
160  */
161  const char* get_name();
162 
163  /*l
164  *b Description:
165  **
166  ** Returns the x and y coordinate of the panel.
167  **
168  *b Callable From:
169  **
170  *- - C++
171  *- - Script
172  */
173  int get_position(int* ret_x, int* ret_y);
174 
175  /*l
176  *b Description:
177  **
178  ** Returns the width of the panel
179  **
180  *b Callable From:
181  **
182  *- - C++
183  *- - Script
184  */
185  int get_width();
186 
187  /*l
188  *b Description:
189  **
190  ** Returns the height of the panel
191  **
192  *b Callable From:
193  **
194  *- - C++
195  *- - Script
196  */
197  int get_height();
198 
199  /*l
200  *b Description:
201  **
202  ** Makes button panel visible or invisible.
203  **
204  *b Arguments:
205  **
206  *a visible - pass 1 to make visible, 0 to make invisible
207  **
208  *b Returns:
209  **
210  ** 0 on success, -1 on failure
211  **
212  *b Callable From:
213  **
214  *- - C++
215  *- - Script
216  */
217  int set_visible(int visible);
218 
219  /*l
220  *b Description:
221  **
222  ** Makes button panel minimized (or un-minimized).
223  **
224  *b Arguments:
225  **
226  *a visible - pass 1 to make minimized, 0 to make full size
227  **
228  *b Returns:
229  **
230  ** 0 on success, -1 on failure
231  **
232  *b Callable From:
233  **
234  *- - C++
235  *- - Script
236  */
237  int set_minimized_state(int minimized);
238 
239  /*l
240  *b Description:
241  **
242  ** Sets the position of the panel in its parent window. Coordinates
243  ** work differently if panel is right/bottom justified on its x/y
244  ** (see set_justification()). In that case, the coordinate will
245  ** imply the position of the panel's right/bottom edge relative to
246  ** the right/bottom edge of the containing window.
247  **
248  *b Arguments:
249  **
250  *a x - x position, in pixels
251  *a y - y position, in pixels
252  **
253  *b Returns:
254  **
255  ** 0 on success, -1 on failure
256  **
257  *b Callable From:
258  **
259  *- - C++
260  *- - Script
261  */
262  int set_position(int x, int y);
263 
264  /*l
265  *b Description:
266  **
267  ** Sets the desired dimensions of the panel.
268  **
269  *b Arguments:
270  **
271  *a w - width, in pixels
272  *a h - height, in pixels
273  **
274  *b Returns:
275  **
276  ** 0 on success, -1 on failure
277  **
278  *b Callable From:
279  **
280  *- - C++
281  *- - Script
282  */
283  int set_dimensions(int w, int h);
284 
285  /*l
286  *b Description:
287  **
288  ** Sets the desired z depth of the panel.
289  **
290  *b Arguments:
291  **
292  *a z - depth
293  **
294  *b Returns:
295  **
296  ** 0 on success, -1 on failure
297  **
298  *b Callable From:
299  **
300  *- - C++
301  *- - Script
302  */
303  int set_depth(int z);
304 
305  /*l
306  *b Description:
307  **
308  ** Sets the horizontal/vertical justifications of the panel (see
309  ** description in set_position()).
310  **
311  *b Arguments:
312  **
313  *a h - horizontal justification (> 0 for left, 0 for center, < 0 for right)
314  *a v - vertical justification (> 0 for top, 0 for center, < 0 for bottom)
315  **
316  *b Returns:
317  **
318  ** 0 on success, -1 on failure
319  **
320  *b Callable From:
321  **
322  *- - C++
323  *- - Script
324  */
325  int set_justifications(int h, int v);
326 
327  /*l
328  *b Description:
329  **
330  ** Sets the spacing between items in panel.
331  **
332  *b Arguments:
333  **
334  *a spacing - spacing in pixels
335  **
336  *b Returns:
337  **
338  ** 0 on success, -1 on failure
339  **
340  *b Callable From:
341  **
342  *- - C++
343  *- - Script
344  */
345  int set_spacing(int spacing);
346 
347  /*l
348  *b Description:
349  **
350  ** Sets the display title of the panel.
351  **
352  *b Arguments:
353  **
354  *a title - text to show
355  **
356  *b Returns:
357  **
358  ** 0 on success, -1 on failure
359  **
360  *b Callable From:
361  **
362  *- - C++
363  *- - Script
364  */
365  int set_title(const char* title);
366 
367  /*l
368  *b Description:
369  **
370  ** Adds a button to the panel and specifies the lua script that should
371  ** be run upon press.
372  **
373  *b Arguments:
374  **
375  *a name - text of button
376  *a lua_object_name - name of lua table containing function to run
377  *a lua_function_name - name of lua function to run
378  *a style_sheet - optional css to set on button
379  **
380  ** An example style sheet string:
381  ** "QPushButton {background-color : rgba( 192, 210, 192, 192 ); }"
382  **
383  *b Returns:
384  **
385  ** index of the new button (zero-indexed)
386  **
387  *b Callable From:
388  **
389  *- - C++
390  *- - Script
391  */
392  int add_button(const char* name,
393  const char* lua_object_name,
394  const char* lua_function_name,
395  const char* style_sheet = NULL);
396 
397  /*l
398  *b Description:
399  **
400  ** Adds a button to the panel and specifies the lua script that
401  ** should be run upon press.
402  **
403  *b Arguments:
404  **
405  *a name - text of button
406  *a script - Lua script to run (the script itself)
407  *a style_sheet - optional css to set on button
408  **
409  ** An example style sheet string:
410  ** "QPushButton {background-color : rgba( 192, 210, 192, 192 ); }"
411  **
412  *b Returns:
413  **
414  ** index of the new button (zero-indexed)
415  **
416  *b Callable From:
417  **
418  *- - C++
419  *- - Script
420  */
421  int add_button_with_script(const char* name, const char* script,
422  const char* style_sheet = NULL);
423 
424  /*l
425  *b Description:
426  **
427  ** Sets the name (text) of button at index n (zero-indexed).
428  **
429  *b Arguments:
430  **
431  *a index - index of button (starting from 0)
432  **
433  *b Returns:
434  **
435  ** 0 on success, -1 on failure
436  **
437  *b Callable From:
438  **
439  *- - C++
440  *- - Script
441  */
442  int set_button_name(int index, const char* name);
443 
444  /*l
445  *b Description:
446  **
447  ** Sets whether or not the specified button will be a toggle button.
448  ** A toggle button can be clicked back and forth between an on and
449  ** off state, whereas a regular button provides only a once-off
450  ** action.
451  **
452  *b Arguments:
453  **
454  *a index - index of button (starting from 0)
455  *a can_toggle - true if toggle button
456  **
457  *b Returns:
458  **
459  ** 0 on success, -1 on failure
460  **
461  *b Callable From:
462  **
463  *- - C++
464  *- - Script
465  */
466  int set_allow_toggle(int index, int can_toggle);
467 
468  /*l
469  *b Description:
470  **
471  ** Sets the specified button to be the "selected" one within the
472  ** panel. The selected button may have a special appearance
473  ** depending on style sheet. See notes for set_style_sheet().
474  **
475  *b Arguments:
476  **
477  *a index - index of button (starting from 0)
478  **
479  *b Returns:
480  **
481  ** 0 on success, -1 on failure
482  **
483  *b Callable From:
484  **
485  *- - C++
486  *- - Script
487  */
488  int set_selected_button(int index);
489 
490  /*l
491  *b Description:
492  **
493  ** Similar to set_selected_button(), but using button name (text).
494  **
495  *b Arguments:
496  **
497  *a name - name (text) of button
498  **
499  *b Returns:
500  **
501  ** 0 on success, -1 on failure
502  **
503  *b Callable From:
504  **
505  *- - C++
506  *- - Script
507  */
508  int set_selected_button_by_name(const char* name);
509 
510  /*l
511  *b Description:
512  **
513  ** Adds an integer slider to the panel and specifies the lua script
514  ** that should be run upon the slider changing value. lua function
515  ** should be:
516  **
517  *e function lua_object_name:lua_function_name(value)
518  **
519  *b Arguments:
520  **
521  *a name - text of label description
522  *a lua_object_name - name of lua table containing function to run
523  *a lua_function_name - name of lua function to run
524  **
525  *b Returns:
526  **
527  ** index of the new slider (zero-indexed)
528  **
529  *b Callable From:
530  **
531  *- - C++
532  *- - Script
533  */
534  int add_int_slider(const char* name,
535  const char* lua_object_name,
536  const char* lua_function_name,
537  int init_val,
538  int min_val,
539  int max_val,
540  const char* style_sheet = NULL);
541 
542  /*l
543  *b Description:
544  **
545  ** Adds a continuous floating slider to the panel and specifies the
546  ** lua script that should be run upon the slider changing value. lua
547  ** function should be:
548  **
549  *e function lua_object_name:lua_function_name(value)
550  **
551  *b Arguments:
552  **
553  *a name - text of label description
554  *a lua_object_name - name of lua table containing function to run
555  *a lua_function_name - name of lua function to run
556  **
557  *b Returns:
558  **
559  ** index of the new slider (zero-indexed)
560  **
561  *b Callable From:
562  **
563  *- - C++
564  *- - Script
565  */
566  int add_float_slider(const char* name,
567  const char* lua_object_name,
568  const char* lua_function_name,
569  float init_val,
570  float min_val,
571  float max_val,
572  const char* style_sheet = NULL);
573 
574  /*l
575  *b Description:
576  **
577  ** Updates specified slider with the value specified.
578  **
579  *b Arguments:
580  **
581  *a name - name of slider
582  *a value - value of slider
583  */
584  int set_slider_value(const char* name, float value);
585 
586  /*l
587  *b Description:
588  **
589  ** Adds a vertical or horizontal spacer element.
590  **
591  */
592  int add_spacer(int pixels);
593 
594  /*l
595  *b Description:
596  **
597  ** Change visibility of item specified by index
598  **
599  */
600  void set_item_visibility(int index, bool visible);
601 
602  /*l
603  *b Description:
604  **
605  ** Clears all items out of panel
606  **
607  */
608  void remove_all_items();
609 
610  /*l
611  *b Description:
612  **
613  ** Sets a Lua script to be called when panel is opened (un-minimized).
614  **
615  *b Arguments:
616  **
617  *a lua_script - the entire script
618  */
619  void set_open_script(const char* lua_script);
620 
621  /*l
622  *b Description:
623  **
624  ** Sets a Lua script to be called when panel is opened (un-minimized).
625  **
626  *b Arguments:
627  **
628  *a lua_script - the entire script
629  */
630  void set_minimize_script(const char* lua_script);
631 
632  /*l
633  *b Description:
634  **
635  ** Passes a Qt style sheet to the panel.
636  **
637  ** Sample one (user must replace "MAIN_BG_COLOR" and other tags with
638  ** meaningful values):
639  **
640  *b Note:
641  **
642  ** "isSelected" used to set visual properties of selected button
643  **
644  ** ----------------
645  *e basic_style = [[
646  *e * {
647  *e background-color : rgba( 192, 192, 192, 192 );
648  *e color : white;
649  *e }
650  *e QFrame#m_button_frame {
651  *e background-color : MAIN_BG_COLOR;
652  *e }
653  *e QLabel#m_title_label {
654  *e color : white;
655  *e }
656  *e QPushButton {
657  *e color : BUTTON_TEXT_COLOR;
658  *e background-color : BUTTON_BG_COLOR;
659  *e }
660  *e QPushButton[isSelected="true"] {
661  *e color : BUTTON_SELECTED_TEXT_COLOR;
662  *e background-color : BUTTON_SELECTED_BG_COLOR;
663  *e }
664  *e ]];
665  **
666  ** Sample two (user must replace "MAIN_BG_COLOR" and other tags with
667  ** meaningful values):
668  **
669  ** Note:
670  **
671  ** "isToggled" used to set visual properties on button that is
672  ** toggled on
673  **
674  ** ----------------
675  *e basic_style = [[
676  *e * {
677  *e background-color : rgba( 192, 192, 192, 192 );
678  *e color : white;
679  *e }
680  *e QFrame#m_button_frame {
681  *e background-color : MAIN_BG_COLOR;
682  *e }
683  *e QLabel#m_title_label {
684  *e color : white;
685  *e }
686  *e QPushButton {
687  *e color : BUTTON_TEXT_COLOR;
688  *e background-color : BUTTON_BG_COLOR;
689  *e }
690  *e QPushButton[isToggled="true"] {
691  *e color : BUTTON_TOGGLED_TEXT_COLOR;
692  *e background-color : BUTTON_TOGGLED_BG_COLOR;
693  *e }
694  *e ]];
695  **
696  *b Arguments:
697  **
698  *a sheet - the style sheet
699  **
700  *b Returns:
701  **
702  ** 0 on success, -1 on failure
703  **
704  *b Callable From:
705  **
706  *- - C++
707  *- - Script
708  */
709  int set_style_sheet(const char* sheet);
710 
711 
712 /****************************************************************************/
713 /****************************************************************************/
714 
719 #ifdef CPLUSPLUS_ONLY
720  friend class bdiViewButtonPanel;
721 
722  bdiViewButtonPanel* get_scripted_object() {return m_panel;}
723 
724  static void set_create_callback(makeButtonPanelCallback* the_callback);
725 
726 private:
727 
728  /*l
729  ** A private constructor.
730  */
731  diguyViewButtonPanel(bdiViewButtonPanel* panel);
732 
733  /*l
734  ** A private destructor.
735  */
737 
738 protected:
739 
740  /*l
741  ** A pointer to internal data.
742  */
743  bdiViewButtonPanel* m_panel;
744 
745 #endif
746 
747 };
748 
749 #endif //__diguyViewButtonPanel_H
750 
bdiViewButtonPanel * makeButtonPanelCallback(const char *name, int horizontal, int title)
Definition: diguyViewButtonPanel.h:28
Definition: diguyViewButtonPanel.h:35