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