1 // This may look like C code, but it's really -*- C++ -*-
2 /*
3  * Copyright (C) 2012 Emweb bv, Herent, Belgium.
4  *
5  * See the LICENSE file for terms of use.
6  */
7 #ifndef WT_WSPLITBUTTON_H_
8 #define WT_WSPLITBUTTON_H_
9 
10 #include <vector>
11 
12 #include <Wt/WCompositeWidget.h>
13 #include <Wt/WMenuItem.h>
14 
15 namespace Wt {
16 
17 class WStackedWidget;
18 class WTable;
19 
20 /*! \class WSplitButton Wt/WSplitButton.h Wt/WSplitButton.h
21  *  \brief A split button
22  *
23  * A split button combines a button and a drop down menu. Typically,
24  * the button represents an action, with related alternative actions
25  * accessible from the drop down menu.
26  */
27 class WT_API WSplitButton : public WCompositeWidget
28 {
29 public:
30   /*! \brief Constructor.
31    */
32   WSplitButton();
33 
34   /*! \brief Constructor passing the label.
35    */
36   WSplitButton(const WString& label);
37 
38   /*! \brief Returns the action button.
39    *
40    * This is the button that represents the main action.
41    */
42   WPushButton *actionButton() const;
43 
44   /*! \brief Returns the drop down button.
45    *
46    * This represents the button that represents the drop-down action.
47    */
48   WPushButton *dropDownButton() const;
49 
50   /*! \brief Sets the menu for the drop-down button.
51    */
52   void setMenu(std::unique_ptr<WPopupMenu> menu);
53 
54   /*! \brief Returns the menu for the drop-down button.
55    */
56   WPopupMenu *menu() const;
57 
58 private:
59   WToolBar *impl_;
60 
61   void init(const WString& label);
62 };
63 
64 }
65 
66 #endif // WT_WSPLITBUTTON_H_
67