Fl_Menu_Button.H 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // "$Id: Fl_Menu_Button.H 10513 2015-01-10 22:05:15Z greg.ercolano $"
  3. //
  4. // Menu button 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. /* \file
  19. Fl_Menu_Button widget . */
  20. #ifndef Fl_Menu_Button_H
  21. #define Fl_Menu_Button_H
  22. #include "Fl_Menu_.H"
  23. /**
  24. This is a button that when pushed pops up a menu (or hierarchy of
  25. menus) defined by an array of
  26. Fl_Menu_Item objects.
  27. <P ALIGN=CENTER>\image html menu_button.png</P>
  28. \image latex menu_button.png " menu_button" width=5cm
  29. <P>Normally any mouse button will pop up a menu and it is lined up
  30. below the button as shown in the picture. However an Fl_Menu_Button
  31. may also control a pop-up menu. This is done by setting the type().
  32. If type() is zero a normal menu button is produced.
  33. If it is nonzero then this is a pop-up menu. The bits in type() indicate
  34. what mouse buttons pop up the menu (see Fl_Menu_Button::popup_buttons). </P>
  35. <P>The menu will also pop up in response to shortcuts indicated by
  36. putting a '&' character in the label(). </P>
  37. <P>Typing the shortcut() of any of the menu items will cause
  38. callbacks exactly the same as when you pick the item with the mouse.
  39. The '&' character in menu item names are only looked at when the menu is
  40. popped up, however. </P>
  41. When the user clicks a menu item, value() is set to that item
  42. and then:
  43. - The item's callback is done if one has been set; the
  44. Fl_Menu_Button is passed as the Fl_Widget* argument,
  45. along with any userdata configured for the callback.
  46. - If the item does not have a callback, the Fl_Menu_Button's callback
  47. is done instead, along with any userdata configured for it.
  48. The callback can determine which item was picked using
  49. value(), mvalue(), item_pathname(), etc.
  50. */
  51. class FL_EXPORT Fl_Menu_Button : public Fl_Menu_ {
  52. protected:
  53. void draw();
  54. public:
  55. /**
  56. \brief indicate what mouse buttons pop up the menu.
  57. Values for type() used to indicate what mouse buttons pop up the menu.
  58. Fl_Menu_Button::POPUP3 is usually what you want.
  59. */
  60. enum popup_buttons {POPUP1 = 1, /**< pops up with the mouse 1st button. */
  61. POPUP2, /**< pops up with the mouse 2nd button. */
  62. POPUP12, /**< pops up with the mouse 1st or 2nd buttons. */
  63. POPUP3, /**< pops up with the mouse 3rd button. */
  64. POPUP13, /**< pops up with the mouse 1st or 3rd buttons. */
  65. POPUP23, /**< pops up with the mouse 2nd or 3rd buttons. */
  66. POPUP123 /**< pops up with any mouse button. */
  67. };
  68. int handle(int);
  69. const Fl_Menu_Item* popup();
  70. const Fl_Menu_Item* popup(int x, int y);
  71. Fl_Menu_Button(int,int,int,int,const char * =0);
  72. DECLARE_CLASS_CHEAP_RTTI_2(Fl_Menu_Button, Fl_Menu_)
  73. };
  74. #endif
  75. //
  76. // End of "$Id: Fl_Menu_Button.H 10513 2015-01-10 22:05:15Z greg.ercolano $".
  77. //