Fl_Sys_Menu_Bar.H 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // "$Id: Fl_Sys_Menu_Bar.H 10102 2014-02-11 17:59:20Z manolo $"
  3. //
  4. // MacOS system menu bar header file for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 by Bill Spitzak and others.
  7. //
  8. // This library is free software. Distribution and use rights are outlined in
  9. // the file "COPYING" which should have been included with this file. If this
  10. // file is missing or damaged, see the license at:
  11. //
  12. // http://www.fltk.org/COPYING.php
  13. //
  14. // Please report all bugs and problems on the following page:
  15. //
  16. // http://www.fltk.org/str.php
  17. //
  18. #ifndef Fl_Sys_Menu_Bar_H
  19. #define Fl_Sys_Menu_Bar_H
  20. #include "Fl_Menu_Bar.H"
  21. #include "x.H"
  22. #if defined(__APPLE__) || defined(FL_DOXYGEN)
  23. /**
  24. A class to create, modify and delete menus that appear on Mac OS X in the menu bar at the top of the screen.
  25. On other than Mac OS X platforms, Fl_Sys_Menu_Bar is a synonym of class Fl_Menu_Bar.
  26. \n To use this class, just replace Fl_Menu_Bar by Fl_Sys_Menu_Bar, and, on the Mac platform,
  27. a system menu at the top of the screen will be available. This menu will match an array
  28. of Fl_Menu_Item's exactly as with standard FLTK menus.
  29. \n A few FLTK features are not supported by the Mac System menu:
  30. \li no symbolic labels
  31. \li no embossed labels
  32. \li no font sizes
  33. You can configure a callback for the 'About' menu item to invoke your own code with fl_mac_set_about().
  34. */
  35. class FL_EXPORT Fl_Sys_Menu_Bar : public Fl_Menu_Bar {
  36. protected:
  37. void update();
  38. void draw();
  39. public:
  40. Fl_Sys_Menu_Bar(int x,int y,int w,int h,const char *l=0);
  41. ~Fl_Sys_Menu_Bar();
  42. /** Return the system menu's array of Fl_Menu_Item's
  43. */
  44. const Fl_Menu_Item *menu() const {return Fl_Menu_::menu();}
  45. void menu(const Fl_Menu_Item *m);
  46. int add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0);
  47. /** Adds a new menu item.
  48. \see Fl_Menu_::add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0)
  49. */
  50. int add(const char* label, const char* shortcut, Fl_Callback* cb, void *user_data=0, int flags=0) {
  51. return add(label, fl_old_shortcut(shortcut), cb, user_data, flags);
  52. }
  53. int add(const char* str);
  54. int insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data=0, int flags=0);
  55. /** Insert a new menu item.
  56. \see Fl_Menu_::insert(int index, const char* label, const char* shortcut, Fl_Callback *cb, void *user_data=0, int flags=0)
  57. */
  58. int insert(int index, const char* label, const char* shortcut, Fl_Callback *cb, void *user_data=0, int flags=0) {
  59. return insert(index, label, fl_old_shortcut(shortcut), cb, user_data, flags);
  60. }
  61. void remove(int n);
  62. void replace(int rank, const char *name);
  63. /** Set the Fl_Menu_Item array pointer to null, indicating a zero-length menu.
  64. \see Fl_Menu_::clear()
  65. */
  66. void clear();
  67. /** Clears the specified submenu pointed to by index of all menu items.
  68. \see Fl_Menu_::clear_submenu(int index)
  69. */
  70. int clear_submenu(int index);
  71. /** Make the shortcuts for this menu work no matter what window has the focus when you type it.
  72. */
  73. void global() {};
  74. /** Sets the flags of item i
  75. \see Fl_Menu_::mode(int i, int fl) */
  76. void mode (int i, int fl) {
  77. Fl_Menu_::mode(i, fl);
  78. update();
  79. }
  80. /** Gets the flags of item i.
  81. */
  82. int mode(int i) const { return Fl_Menu_::mode(i); }
  83. /** Changes the shortcut of item i to n.
  84. */
  85. void shortcut (int i, int s) { Fl_Menu_::shortcut(i, s); update(); };
  86. };
  87. #else
  88. typedef Fl_Menu_Bar Fl_Sys_Menu_Bar;
  89. #endif // defined(__APPLE__) || defined(FL_DOXYGEN)
  90. #endif // Fl_Sys_Menu_Bar_H
  91. //
  92. // End of "$Id: Fl_Sys_Menu_Bar.H 10102 2014-02-11 17:59:20Z manolo $".
  93. //