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