/* _______ __ __ __ ______ __ __ _______ __ __
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
*
* Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson
* Copyright (c) 2020 Gwilherm Baudic
* Js_./
* Per Larsson a.k.a finalman _RqZ{a<^_aa
* Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
* _Qhm`] _f "'c 1!5m
* Visit: http://guichan.darkbits.org )Qk
ws?a-?' ._/L #'
* binary forms, with or without )4d[#7r, . ' )d`)[
* modification, are permitted provided _Q-5'5W..j/?' -?!\)cam'
* that the following conditions are met: j<. a J@\
* this list of conditions and the j(]1u
#include "guisan/focuslistener.hpp"
#include "guisan/keylistener.hpp"
#include "guisan/mouseevent.hpp"
#include "guisan/mouselistener.hpp"
#include "guisan/platform.hpp"
#include "guisan/widget.hpp"
#include "guisan/widgets/button.hpp"
namespace gcn
{
/**
* A toggle button, which can stay selected. Think of it as a checkbox,
* but dressed as a regular button. Add an ActionListener to it to know when it
* has been clicked.
*
*/
class GCN_CORE_DECLSPEC ToggleButton : public Button
{
public:
/**
* Constructor.
*/
ToggleButton();
/**
* Constructor.
*
* @param caption the caption of the ToggleButton.
*/
ToggleButton(const std::string& caption);
/**
* Checks if the button is selected.
*
* @return True if the button is selected, false otherwise.
* @see setSelected
*/
[[nodiscard]] bool isSelected() const;
/**
* Sets the button to be selected.
*
* @param selected True if the button should be set as selected.
* @see isSelected
*/
void setSelected(bool selected);
//Inherited from Widget
void draw(Graphics* graphics) override;
// Inherited from MouseListener
void mouseReleased(MouseEvent& mouseEvent) override;
// Inherited from KeyListener
void keyReleased(KeyEvent& keyEvent) override;
protected:
/**
* Toggles the button between being selected and
* not being selected.
*/
virtual void toggleSelected();
/**
* True if the button is selected, false otherwise.
*/
bool mSelected;
};
}
#endif // end GCN_TOGGLEBUTTON_HPP