PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: AbstractTooltip.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLGUI_ABSTRACTTOOLTIP_H__ 00024 #define __PLGUI_ABSTRACTTOOLTIP_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLCore/Base/Event/Event.h> 00032 #include "PLGui/Gui/Resources/Timer.h" 00033 #include "PLGui/Widgets/Widget.h" 00034 00035 00036 //[-------------------------------------------------------] 00037 //[ Namespace ] 00038 //[-------------------------------------------------------] 00039 namespace PLGui { 00040 00041 00042 //[-------------------------------------------------------] 00043 //[ Classes ] 00044 //[-------------------------------------------------------] 00045 /** 00046 * @brief 00047 * Base class for tooltip windows 00048 */ 00049 class AbstractTooltip : public Widget { 00050 00051 00052 //[-------------------------------------------------------] 00053 //[ Class definition ] 00054 //[-------------------------------------------------------] 00055 pl_class(PLGUI_RTTI_EXPORT, AbstractTooltip, "PLGui", PLGui::Widget, "Base class for tooltip windows") 00056 // Attributes 00057 pl_attribute(Text, PLCore::String, "", ReadWrite, GetSet, "Tooltip text", "") 00058 pl_attribute(Timeout, PLCore::uint64, 5000, ReadWrite, GetSet, "Time (in ms) after which the tooltip is blended out", "") 00059 // Signals 00060 pl_signal_0(SignalTimeout, "Timeout has been reached", "") 00061 // Slots 00062 pl_slot_0(OnTimer, "Timer callback", "") 00063 pl_class_end 00064 00065 00066 //[-------------------------------------------------------] 00067 //[ Public functions ] 00068 //[-------------------------------------------------------] 00069 public: 00070 /** 00071 * @brief 00072 * Constructor 00073 * 00074 * @param[in] pParent 00075 * Pointer to parent widget 00076 */ 00077 PLGUI_API AbstractTooltip(Widget *pParent = nullptr); 00078 00079 /** 00080 * @brief 00081 * Destructor 00082 */ 00083 PLGUI_API virtual ~AbstractTooltip(); 00084 00085 /** 00086 * @brief 00087 * Get tooltip text 00088 * 00089 * @return 00090 * Tooltip text 00091 */ 00092 PLGUI_API PLCore::String GetText() const; 00093 00094 /** 00095 * @brief 00096 * Set tooltip text 00097 * 00098 * @param[in] sTooltip 00099 * Tooltip text 00100 */ 00101 PLGUI_API void SetText(const PLCore::String &sTooltip); 00102 00103 /** 00104 * @brief 00105 * Get tooltip timeout 00106 * 00107 * @return 00108 * Timeout (in ms) 00109 */ 00110 PLGUI_API PLCore::uint64 GetTimeout() const; 00111 00112 /** 00113 * @brief 00114 * Set tooltip timeout 00115 * 00116 * @param[in] nTimeout 00117 * Timeout (in ms) 00118 */ 00119 PLGUI_API void SetTimeout(PLCore::uint64 nTimeout); 00120 00121 /** 00122 * @brief 00123 * Show tooltip 00124 * 00125 * @param[in] vPos 00126 * Position of tooltip 00127 */ 00128 PLGUI_API void ShowTooltip(const PLMath::Vector2i &vPos); 00129 00130 /** 00131 * @brief 00132 * Blend out tooltip 00133 */ 00134 PLGUI_API void BlendOut(); 00135 00136 00137 //[-------------------------------------------------------] 00138 //[ Protected virtual AbstractTooltip functions ] 00139 //[-------------------------------------------------------] 00140 protected: 00141 /** 00142 * @brief 00143 * Called on display of the tooltip 00144 */ 00145 virtual void OnShowTooltip(); 00146 00147 /** 00148 * @brief 00149 * Called on timeout 00150 */ 00151 virtual void OnTimeout(); 00152 00153 00154 //[-------------------------------------------------------] 00155 //[ Private functions ] 00156 //[-------------------------------------------------------] 00157 private: 00158 /** 00159 * @brief 00160 * Called when the timer has fired 00161 */ 00162 void OnTimer(); 00163 00164 00165 //[-------------------------------------------------------] 00166 //[ Protected data ] 00167 //[-------------------------------------------------------] 00168 protected: 00169 PLCore::String m_sTooltip; /**< Tooltip text */ 00170 PLCore::uint64 m_nTimeout; /**< Timeout (in ms) */ 00171 Timer m_cTimer; /**< Timer */ 00172 00173 00174 }; 00175 00176 00177 //[-------------------------------------------------------] 00178 //[ Namespace ] 00179 //[-------------------------------------------------------] 00180 } // PLGui 00181 00182 00183 #endif // __PLGUI_ABSTRACTTOOLTIP_H__
|