Fl_Menu_Bar.H 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // "$Id: Fl_Menu_Bar.H 12575 2017-12-02 16:20:30Z manolo $"
  3. //
  4. // Menu bar header file for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2017 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. /* \file
  19. Fl_Menu_Bar widget . */
  20. #ifndef Fl_Menu_Bar_H
  21. #define Fl_Menu_Bar_H
  22. #include "Fl_Menu_.H"
  23. /**
  24. This widget provides a standard menubar interface. Usually you will
  25. put this widget along the top edge of your window. The height of the
  26. widget should be 30 for the menu titles to draw correctly with the
  27. default font.
  28. The items on the bar and the menus they bring up are defined by a
  29. single Fl_Menu_Item array.
  30. Because a Fl_Menu_Item array defines a hierarchy, the
  31. top level menu defines the items in the menubar, while the submenus
  32. define the pull-down menus. Sub-sub menus and lower pop up to the right
  33. of the submenus.
  34. \image html menubar.png
  35. \image latex menubar.png " menubar" width=12cm
  36. If there is an item in the top menu that is not a title of a
  37. submenu, then it acts like a "button" in the menubar. Clicking on it
  38. will pick it.
  39. When the user clicks a menu item, value() is set to that item
  40. and then:
  41. - The item's callback is done if one has been set; the
  42. Fl_Menu_Bar is passed as the Fl_Widget* argument,
  43. along with any userdata configured for the callback.
  44. - If the item does not have a callback, the Fl_Menu_Bar's callback
  45. is done instead, along with any userdata configured for the callback.
  46. The callback can determine which item was picked using
  47. value(), mvalue(), item_pathname(), etc.
  48. Submenus will also pop up in response to shortcuts indicated by
  49. putting a '&' character in the name field of the menu item. If you put a
  50. '&' character in a top-level "button" then the shortcut picks it. The
  51. '&' character in submenus is ignored until the menu is popped up.
  52. Typing the shortcut() of any of the menu items will cause
  53. callbacks exactly the same as when you pick the item with the mouse.
  54. */
  55. class FL_EXPORT Fl_Menu_Bar : public Fl_Menu_ {
  56. friend class Fl_Sys_Menu_Bar_Driver;
  57. protected:
  58. void draw();
  59. public:
  60. int handle(int);
  61. /**
  62. Creates a new Fl_Menu_Bar widget using the given position,
  63. size, and label string. The default boxtype is FL_UP_BOX.
  64. The constructor sets menu() to NULL. See
  65. Fl_Menu_ for the methods to set or change the menu.
  66. labelsize(), labelfont(), and labelcolor()
  67. are used to control how the menubar items are drawn. They are
  68. initialized from the Fl_Menu static variables, but you can
  69. change them if desired.
  70. label() is ignored unless you change align() to
  71. put it outside the menubar.
  72. The destructor removes the Fl_Menu_Bar widget and all of its
  73. menu items.
  74. */
  75. Fl_Menu_Bar(int X, int Y, int W, int H, const char *l=0);
  76. /** Updates the menu bar after any change to its items.
  77. This is useful when the menu bar can be an Fl_Sys_Menu_Bar object.
  78. */
  79. virtual void update() {}
  80. DECLARE_CLASS_CHEAP_RTTI_2(Fl_Menu_Bar, Fl_Menu_)
  81. };
  82. #endif
  83. //
  84. // End of "$Id: Fl_Menu_Bar.H 12575 2017-12-02 16:20:30Z manolo $".
  85. //