PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: TrayIcon.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_TRAYICON_H__ 00024 #define __PLGUI_TRAYICON_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLCore/Base/Event/Event.h> 00032 #include "PLGui/Gui/Resources/Image.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Forward declarations ] 00037 //[-------------------------------------------------------] 00038 namespace PLMath { 00039 class Vector2i; 00040 } 00041 namespace PLGui { 00042 class Gui; 00043 class TrayIconImpl; 00044 } 00045 00046 00047 //[-------------------------------------------------------] 00048 //[ Namespace ] 00049 //[-------------------------------------------------------] 00050 namespace PLGui { 00051 00052 00053 //[-------------------------------------------------------] 00054 //[ Classes ] 00055 //[-------------------------------------------------------] 00056 /** 00057 * @brief 00058 * Tray icon class 00059 * 00060 * @note 00061 * - Implementation of the bridge design pattern, this class is the abstraction 00062 */ 00063 class TrayIcon { 00064 00065 00066 //[-------------------------------------------------------] 00067 //[ Public events ] 00068 //[-------------------------------------------------------] 00069 public: 00070 PLCore::Event<const PLMath::Vector2i&> EventMouseMove; /**< Mouse moves inside the tray icon, mouse position within the widget as parameter */ 00071 PLCore::Event<PLCore::uint32, const PLMath::Vector2i&> EventMouseButtonDown; /**< Mouse button is pressed, mouse button and mouse position within the widget as parameters */ 00072 PLCore::Event<PLCore::uint32, const PLMath::Vector2i&> EventMouseButtonUp; /**< Mouse button is released, mouse button and mouse position within the widget as parameters */ 00073 PLCore::Event<PLCore::uint32, const PLMath::Vector2i&> EventMouseButtonClick; /**< Mouse button has been clicked, mouse button and mouse position within the widget as parameters */ 00074 PLCore::Event<PLCore::uint32, const PLMath::Vector2i&> EventMouseButtonDoubleClick; /**< Mouse button has been double-clicked, mouse button and mouse position within the widget as parameters */ 00075 00076 00077 //[-------------------------------------------------------] 00078 //[ Public functions ] 00079 //[-------------------------------------------------------] 00080 public: 00081 /** 00082 * @brief 00083 * Constructor 00084 * 00085 * @param[in] cGui 00086 * Owner GUI 00087 */ 00088 PLGUI_API TrayIcon(Gui &cGui); 00089 00090 /** 00091 * @brief 00092 * Destructor 00093 */ 00094 PLGUI_API virtual ~TrayIcon(); 00095 00096 /** 00097 * @brief 00098 * Get owner GUI 00099 * 00100 * @return 00101 * Pointer to GUI object 00102 */ 00103 PLGUI_API Gui *GetGui() const; 00104 00105 /** 00106 * @brief 00107 * Get implementation 00108 * 00109 * @return 00110 * Pointer to platform specific implementation 00111 */ 00112 PLGUI_API TrayIconImpl *GetImpl() const; 00113 00114 /** 00115 * @brief 00116 * Get visibility 00117 * 00118 * @return 00119 * 'true' if tray icon is visible, else 'false' 00120 */ 00121 PLGUI_API bool IsVisible() const; 00122 00123 /** 00124 * @brief 00125 * Set visibility 00126 * 00127 * @param[in] bVisible 00128 * 'true' if tray icon is visible, else 'false' 00129 */ 00130 PLGUI_API void SetVisible(bool bVisible); 00131 00132 /** 00133 * @brief 00134 * Get icon 00135 * 00136 * @return 00137 * Icon that is displayed in the tray 00138 */ 00139 PLGUI_API const Image &GetIcon() const; 00140 00141 /** 00142 * @brief 00143 * Set icon 00144 * 00145 * @param[in] cIcon 00146 * Icon that is displayed in the tray 00147 */ 00148 PLGUI_API void SetIcon(const Image &cIcon); 00149 00150 /** 00151 * @brief 00152 * Get tooltip 00153 * 00154 * @return 00155 * Text that is displayed as a tooltip 00156 */ 00157 PLGUI_API PLCore::String GetTooltip() const; 00158 00159 /** 00160 * @brief 00161 * Set tooltip 00162 * 00163 * @param[in] sTooltip 00164 * Text that is displayed as a tooltip 00165 */ 00166 PLGUI_API void SetTooltip(const PLCore::String &sTooltip); 00167 00168 /** 00169 * @brief 00170 * Show a notification text 00171 * 00172 * @param[in] sTitle 00173 * Title 00174 * @param[in] sText 00175 * Text 00176 */ 00177 PLGUI_API void ShowNotification(const PLCore::String &sTitle, const PLCore::String &sText); 00178 00179 00180 //[-------------------------------------------------------] 00181 //[ Public virtual TrayIcon functions ] 00182 //[-------------------------------------------------------] 00183 public: 00184 /** 00185 * @brief 00186 * Called when the mouse is moved within the tray icon 00187 * 00188 * @param[in] vPos 00189 * Mouse position within the tray icon 00190 */ 00191 PLGUI_API virtual void OnMouseMove(const PLMath::Vector2i &vPos); 00192 00193 /** 00194 * @brief 00195 * Called when a mouse button is pressed 00196 * 00197 * @param[in] nButton 00198 * Mouse button that is pressed 00199 * @param[in] vPos 00200 * Mouse position within the tray icon 00201 */ 00202 PLGUI_API virtual void OnMouseButtonDown(PLCore::uint32 nButton, const PLMath::Vector2i &vPos); 00203 00204 /** 00205 * @brief 00206 * Called when a mouse button is released 00207 * 00208 * @param[in] nButton 00209 * Mouse button that is released 00210 * @param[in] vPos 00211 * Mouse position within the tray icon 00212 */ 00213 PLGUI_API virtual void OnMouseButtonUp(PLCore::uint32 nButton, const PLMath::Vector2i &vPos); 00214 00215 /** 00216 * @brief 00217 * Called when a mouse button is clicked 00218 * 00219 * @param[in] nButton 00220 * Mouse button that is clicked 00221 * @param[in] vPos 00222 * Mouse position within the tray icon 00223 */ 00224 PLGUI_API virtual void OnMouseButtonClick(PLCore::uint32 nButton, const PLMath::Vector2i &vPos); 00225 00226 /** 00227 * @brief 00228 * Called when a mouse button is double-clicked 00229 * 00230 * @param[in] nButton 00231 * Mouse button that is double-clicked 00232 * @param[in] vPos 00233 * Mouse position within the tray icon 00234 */ 00235 PLGUI_API virtual void OnMouseButtonDoubleClick(PLCore::uint32 nButton, const PLMath::Vector2i &vPos); 00236 00237 00238 //[-------------------------------------------------------] 00239 //[ Protected data ] 00240 //[-------------------------------------------------------] 00241 protected: 00242 Gui *m_pGui; /**< Pointer to GUI instance */ 00243 TrayIconImpl *m_pImpl; /**< Tray icon implementation */ 00244 bool m_bVisible; /**< Is the tray icon visible? */ 00245 Image m_cIcon; /**< Displayed icon */ 00246 PLCore::String m_sTooltip; /**< Displayed tooltip */ 00247 00248 00249 }; 00250 00251 00252 //[-------------------------------------------------------] 00253 //[ Namespace ] 00254 //[-------------------------------------------------------] 00255 } // PLGui 00256 00257 00258 #endif // __PLGUI_TRAYICON_H__
|