MenuBar.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /******************************************************************************/
  2. const_mem_addr STRUCT(MenuBar , GuiObj) // Gui Menu Bar !! must be stored in constant memory address !!
  3. //{
  4. struct Elm // Menu Element
  5. {
  6. Str name , // name (used for code commands)
  7. display_name; // display name
  8. Menu menu ;
  9. Elm();
  10. #if EE_PRIVATE
  11. Elm& create(C Elm &src);
  12. Flt x1()C {return x+w;}
  13. #endif
  14. #if !EE_PRIVATE
  15. private:
  16. #endif
  17. Bool hidden;
  18. Flt x, w;
  19. };
  20. // manage
  21. MenuBar& del ( ); // delete manually
  22. MenuBar& create(C Node<MenuElm> &node); // create, 'node'=menu node
  23. MenuBar& create(C MenuBar &src ); // create from 'src'
  24. // get / set
  25. Int elms( )C {return _elms.elms();} // get number of menu elements
  26. Elm& elm (Int i) {return _elms[i] ;} // get i-th menu element
  27. C Elm& elm (Int i)C {return _elms[i] ;} // get i-th menu element
  28. void operator()(C Str &command, Bool on, SET_MODE mode=SET_DEFAULT) ; // set 'command' 'on' state (enabled), sample usage: ("View/Wireframe",true)
  29. Bool operator()(C Str &command )C; // if 'command' is on (enabled), sample usage: ("View/Wireframe")
  30. Bool exists (C Str &command )C; // if 'command' exists in menu , sample usage: exists("File/Exit")
  31. MenuBar& setCommand(C Str &command, Bool visible, Bool enabled); // set 'command' visibility and if not disabled
  32. MenuBar& setCommand(C Str &command, Bool state ) {return setCommand(command, state, state);} // set 'command' visibility and if not disabled
  33. virtual MenuBar& rect(C Rect &rect); C Rect& rect()C {return super::rect();} // set/get rectangle
  34. Rect elmsRect()C; // get rectangle covering all Menu Elements
  35. MenuBar& skin(C GuiSkinPtr &skin, Bool sub_objects=true); C GuiSkinPtr& skin()C {return _skin ;} // set/get skin override, default=null (if set to null then current value of 'Gui.skin' is used), 'sub_objects'=if additionally change the skin of sub-menus
  36. GuiSkin* getSkin()C {return _skin ? _skin() : Gui.skin();} // get actual skin
  37. // main
  38. virtual void update(C GuiPC &gpc); // update object
  39. virtual void draw (C GuiPC &gpc); // draw object
  40. #if EE_PRIVATE
  41. void zero ();
  42. void setElms();
  43. #endif
  44. ~MenuBar() {del();}
  45. MenuBar();
  46. #if !EE_PRIVATE
  47. private:
  48. #endif
  49. Bool _alt;
  50. Int _lit, _push, _menu_prev;
  51. GuiSkinPtr _skin;
  52. Mems<Elm> _elms;
  53. protected:
  54. virtual void parentClientRectChanged(C Rect *old_client, C Rect *new_client);
  55. #if EE_PRIVATE
  56. friend struct GUI; friend struct GuiObjChildren; friend struct GuiObj;
  57. #endif
  58. };
  59. /******************************************************************************/
  60. inline Int Elms(C MenuBar &menu) {return menu.elms();}
  61. /******************************************************************************/