/** @file * @author Edouard DUPIN * @copyright 2011, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ #pragma once #include #include #include #include #include #include #include #include namespace ewol { namespace widget { class Button; using Button = ememory::Ptr; using ButtonWeak = ememory::WeakPtr; /** * a composed button is a button with an inside composed with the specify XML element * ==> this permit to generate standard element simple */ class Button : public ewol::widget::Container2 { public: enum buttonLock{ lockNone, //!< normal status of the button lockWhenPressed, //!< When the state is set in pressed, the status stay in this one lockWhenReleased, //!< When the state is set in not pressed, the status stay in this one lockAccess, //!< all event are trashed == > acctivity of the button is disable }; public: // Event list esignal::Signal<> signalPressed; esignal::Signal<> signalDown; esignal::Signal<> signalUp; esignal::Signal<> signalEnter; esignal::Signal<> signalLeave; esignal::Signal signalValue; public: // propertie list eproperty::Value propertyShape; //!< shaper name property eproperty::Value propertyValue; //!< Current state of the button. eproperty::List propertyLock; //!< Current lock state of the button. eproperty::Value propertyToggleMode; //!< The button is able to toggle. eproperty::Value propertyEnableSingle; //!< When a single subwidget is set display all time it. private: ewol::compositing::Shaper this.shaper; //!< Compositing theme. protected: /** * Constructor * @param _shaperName Shaper file properties */ Button(); void init() ; public: DECLARE_WIDGET_FACTORY(Button, "Button"); /** * Destructor */ ~Button(); private: boolean this.mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). boolean this.buttonPressed; //!< Flag to know if the button is curently pressed. // hover area : Vector2f this.selectableAreaPos; //!< Start position of the events Vector2f this.selectableAreaSize; //!< size of the event positions private: /** * internal system to change the property of the current status * @param _newStatusId new state */ void changeStatusIn(int _newStatusId); /** * update the status with the internal satte of the button ... */ void CheckStatus(); protected: // Derived function void onDraw() ; public: void calculateMinMaxSize() ; void onChangeSize() ; void onRegenerateDisplay() ; boolean onEventInput( ewol::event::Input _event) ; boolean onEventEntry( ewol::event::Entry _event) ; void onDetectPresenceToggleWidget() { propertyToggleMode.set(true); } protected: esignal::Connection this.PCH; //!< Periodic Call Handle to remove it when needed /** * Periodic call to update grapgic display * @param _event Time generic event */ void periodicCall( ewol::event::Time _event); void onLostFocus() ; protected: void onChangePropertyShape(); void onChangePropertyValue(); void onChangePropertyLock(); void onChangePropertyToggleMode(); void onChangePropertyEnableSingle(); }; }; };