Fl_Menu_Button.H 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // "$Id: Fl_Menu_Button.H 8864 2011-07-19 04:49:30Z 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. <P>When the user picks an item off the menu, the item's callback is
  42. done with the menu_button as the Fl_Widget* argument. If the
  43. item does not have a callback the menu_button's callback is done
  44. instead.
  45. */
  46. class FL_EXPORT Fl_Menu_Button : public Fl_Menu_ {
  47. protected:
  48. void draw();
  49. public:
  50. /**
  51. \brief indicate what mouse buttons pop up the menu.
  52. Values for type() used to indicate what mouse buttons pop up the menu.
  53. Fl_Menu_Button::POPUP3 is usually what you want.
  54. */
  55. enum popup_buttons {POPUP1 = 1, /**< pops up with the mouse 1st button. */
  56. POPUP2, /**< pops up with the mouse 2nd button. */
  57. POPUP12, /**< pops up with the mouse 1st or 2nd buttons. */
  58. POPUP3, /**< pops up with the mouse 3rd button. */
  59. POPUP13, /**< pops up with the mouse 1st or 3rd buttons. */
  60. POPUP23, /**< pops up with the mouse 2nd or 3rd buttons. */
  61. POPUP123 /**< pops up with any mouse button. */
  62. };
  63. int handle(int);
  64. const Fl_Menu_Item* popup();
  65. const Fl_Menu_Item* popup(int x, int y);
  66. Fl_Menu_Button(int,int,int,int,const char * =0);
  67. DECLARE_CLASS_CHEAP_RTTI_2(Fl_Menu_Button, Fl_Menu_)
  68. };
  69. #endif
  70. //
  71. // End of "$Id: Fl_Menu_Button.H 8864 2011-07-19 04:49:30Z greg.ercolano $".
  72. //