1 /* 2 * Copyright (C) 2012 Emweb bv, Herent, Belgium. 3 * 4 * See the LICENSE file for terms of use. 5 */ 6 7 #include "Wt/WPopupMenu.h" 8 #include "Wt/WPushButton.h" 9 #include "Wt/WSplitButton.h" 10 #include "Wt/WToolBar.h" 11 12 namespace Wt { 13 WSplitButton()14WSplitButton::WSplitButton() 15 { 16 init(WString::Empty); 17 } 18 WSplitButton(const WString & label)19WSplitButton::WSplitButton(const WString& label) 20 { 21 init(label); 22 } 23 init(const WString & label)24void WSplitButton::init(const WString& label) 25 { 26 setImplementation(std::unique_ptr<WToolBar>(impl_ = new WToolBar())); 27 28 impl_->setInline(true); 29 impl_->addButton(std::unique_ptr<WPushButton>(new WPushButton(label))); 30 impl_->addButton(std::unique_ptr<WPushButton>(new WPushButton())); 31 32 dropDownButton()->setStyleClass("dropdown-toggle"); 33 } 34 actionButton()35WPushButton *WSplitButton::actionButton() const 36 { 37 return dynamic_cast<WPushButton *>(impl_->widget(0)); 38 } 39 dropDownButton()40WPushButton *WSplitButton::dropDownButton() const 41 { 42 return dynamic_cast<WPushButton *>(impl_->widget(1)); 43 } 44 setMenu(std::unique_ptr<WPopupMenu> popupMenu)45void WSplitButton::setMenu(std::unique_ptr<WPopupMenu> popupMenu) 46 { 47 dropDownButton()->setMenu(std::move(popupMenu)); 48 } 49 menu()50WPopupMenu *WSplitButton::menu() const 51 { 52 return dropDownButton()->menu(); 53 } 54 55 } 56