PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: WidgetFunctions.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_WIDGETFUNCTIONS_H__ 00024 #define __PLGUI_WIDGETFUNCTIONS_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLGui/PLGui.h" 00032 #include "PLGui/PLGuiDefinitions.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Forward declarations ] 00037 //[-------------------------------------------------------] 00038 namespace PLMath { 00039 class Vector2i; 00040 } 00041 namespace PLGui { 00042 class GuiMessage; 00043 class DataObject; 00044 class Widget; 00045 class Graphics; 00046 } 00047 00048 00049 //[-------------------------------------------------------] 00050 //[ Namespace ] 00051 //[-------------------------------------------------------] 00052 namespace PLGui { 00053 00054 00055 //[-------------------------------------------------------] 00056 //[ Classes ] 00057 //[-------------------------------------------------------] 00058 /** 00059 * @brief 00060 * Widget functions base class 00061 * 00062 * @remarks 00063 * This base class is used for classes, that respond to widget events, such as Widget itself and Modifier 00064 */ 00065 class WidgetFunctions { 00066 00067 00068 //[-------------------------------------------------------] 00069 //[ Public functions ] 00070 //[-------------------------------------------------------] 00071 public: 00072 /** 00073 * @brief 00074 * Constructor 00075 */ 00076 PLGUI_API WidgetFunctions(); 00077 00078 /** 00079 * @brief 00080 * Destructor 00081 */ 00082 PLGUI_API virtual ~WidgetFunctions(); 00083 00084 00085 //[-------------------------------------------------------] 00086 //[ Protected virtual WidgetFunctions functions ] 00087 //[-------------------------------------------------------] 00088 protected: 00089 /** 00090 * @brief 00091 * Process GUI message 00092 * 00093 * @param[in] cMessage 00094 * GUI message 00095 * 00096 * @remarks 00097 * Usually, you should not override this method, but rather use the virtual functions 00098 * that are called after a specific message arrived (e.g. OnShow(), OnClose() etc.). 00099 * If you decide to override this method, make sure to call the base implementation first, 00100 * otherwise the messages will not be processed and no virtual functions or events will 00101 * be called anymore. 00102 */ 00103 PLGUI_API virtual void OnMessage(const GuiMessage &cMessage); 00104 00105 /** 00106 * @brief 00107 * Called when the theme has been changed 00108 * 00109 * @remarks 00110 * This event is caused, when the widget gets a new theme. Use 00111 * this to perform all tasks necessary to adjust to the new theme, 00112 * e.g. resizing certain child widgets or redrawing the widget. 00113 */ 00114 PLGUI_API virtual void OnThemeChanged(); 00115 00116 /** 00117 * @brief 00118 * Called when the widget has been changed 00119 * 00120 * @remarks 00121 * This event is caused, when the widget calls UpdateContent() to 00122 * indicate that the widget has been changed in a way that could 00123 * affect it's size or appearance. This is used to perform an 00124 * AdjustContent() on the parent widget, whenever the size of a 00125 * child widget could have been altered. 00126 */ 00127 PLGUI_API virtual void OnUpdateContent(); 00128 00129 /** 00130 * @brief 00131 * Called when a child widget has been changed 00132 * 00133 * @remarks 00134 * After an UpdateContent()-event has been called on a widget, 00135 * it will cause an UpdateChildWidget()-event on it's parent widget. 00136 * See OnUpdateContent() for further detail on UpdateContent()-events. 00137 */ 00138 PLGUI_API virtual void OnUpdateChildWidget(Widget *pWidget); 00139 00140 /** 00141 * @brief 00142 * Called when a child window has been added 00143 * 00144 * @param[in] pWidget 00145 * Widget 00146 */ 00147 PLGUI_API virtual void OnAddChildWidget(Widget *pWidget); 00148 00149 /** 00150 * @brief 00151 * Called when a child window has been removed 00152 * 00153 * @param[in] pWidget 00154 * Widget 00155 */ 00156 PLGUI_API virtual void OnRemoveChildWidget(Widget *pWidget); 00157 00158 /** 00159 * @brief 00160 * Called when the widget shall be closed 00161 */ 00162 PLGUI_API virtual void OnClose(); 00163 00164 /** 00165 * @brief 00166 * Called after the widget has been created 00167 */ 00168 PLGUI_API virtual void OnCreate(); 00169 00170 /** 00171 * @brief 00172 * Called before the widget is destroyed 00173 */ 00174 PLGUI_API virtual void OnDestroy(); 00175 00176 /** 00177 * @brief 00178 * Called when the widget is shown 00179 */ 00180 PLGUI_API virtual void OnShow(); 00181 00182 /** 00183 * @brief 00184 * Called when the widget gets hidden 00185 */ 00186 PLGUI_API virtual void OnHide(); 00187 00188 /** 00189 * @brief 00190 * Called when the widget is enabled 00191 */ 00192 PLGUI_API virtual void OnEnable(); 00193 00194 /** 00195 * @brief 00196 * Called when the widget gets disabled 00197 */ 00198 PLGUI_API virtual void OnDisable(); 00199 00200 /** 00201 * @brief 00202 * Called when the widget gets the keyboard focus 00203 */ 00204 PLGUI_API virtual void OnGetFocus(); 00205 00206 /** 00207 * @brief 00208 * Called when the widget looses the keyboard focus 00209 */ 00210 PLGUI_API virtual void OnLooseFocus(); 00211 00212 /** 00213 * @brief 00214 * Called when the widget has been activated or deactivated (focus has changed) 00215 * 00216 * @param[in] bActivate 00217 * 'true' if the widget itself or one of it's child widgets had the focus, else 'false' 00218 */ 00219 PLGUI_API virtual void OnActivate(bool bActivate); 00220 00221 /** 00222 * @brief 00223 * Called to draw the widget background 00224 * 00225 * @param[in] cGraphics 00226 * Graphics object used for painting 00227 */ 00228 PLGUI_API virtual void OnDrawBackground(Graphics &cGraphics); 00229 00230 /** 00231 * @brief 00232 * Called to draw the widget 00233 * 00234 * @param[in] cGraphics 00235 * Graphics object used for painting 00236 */ 00237 PLGUI_API virtual void OnDraw(Graphics &cGraphics); 00238 00239 /** 00240 * @brief 00241 * Called when the widget gets moved 00242 * 00243 * @param[in] vPos 00244 * Position 00245 */ 00246 PLGUI_API virtual void OnMove(const PLMath::Vector2i &vPos); 00247 00248 /** 00249 * @brief 00250 * Called when the widget gets resized 00251 * 00252 * @param[in] vSize 00253 * Size 00254 */ 00255 PLGUI_API virtual void OnSize(const PLMath::Vector2i &vSize); 00256 00257 /** 00258 * @brief 00259 * Called when the window state has changed 00260 * 00261 * @param[in] nWindowState 00262 * Window state 00263 */ 00264 PLGUI_API virtual void OnWindowState(EWindowState nWindowState); 00265 00266 /** 00267 * @brief 00268 * Called when fullscreen mode is activated 00269 */ 00270 PLGUI_API virtual void OnEnterFullscreen(); 00271 00272 /** 00273 * @brief 00274 * Called when fullscreen mode is deactivated 00275 */ 00276 PLGUI_API virtual void OnLeaveFullscreen(); 00277 00278 /** 00279 * @brief 00280 * Called when the widget is to calculate it's preferred size 00281 * 00282 * @param[in] vRefSize 00283 * Precalculated reference size, can be (-1, -1) if no reference size is available 00284 * 00285 * @return 00286 * Preferred size 00287 * 00288 * @remarks 00289 * If the widget returns -1 in a component (X/Y), it means that there is 00290 * no preferred size in that direction. A layout will in that case use 00291 * 'as much space as possible', while the FitSize() functions will use 00292 * the current size. 00293 */ 00294 PLGUI_API virtual PLMath::Vector2i OnPreferredSize(const PLMath::Vector2i &vRefSize) const; 00295 00296 /** 00297 * @brief 00298 * Called when the widget content has to be adjusted 00299 */ 00300 PLGUI_API virtual void OnAdjustContent(); 00301 00302 /** 00303 * @brief 00304 * Called when the mouse has entered the widget 00305 */ 00306 PLGUI_API virtual void OnMouseEnter(); 00307 00308 /** 00309 * @brief 00310 * Called when the mouse has left the widget 00311 */ 00312 PLGUI_API virtual void OnMouseLeave(); 00313 00314 /** 00315 * @brief 00316 * Called when the mouse-over state of the widget has changed 00317 * 00318 * @param[in] bMouseOver 00319 * 'true' if the mouse is over the widget or a child widget, else 'false' 00320 */ 00321 PLGUI_API virtual void OnMouseOver(bool bMouseOver); 00322 00323 /** 00324 * @brief 00325 * Called when the mouse is moved within the widget or captured by it 00326 * 00327 * @param[in] vPos 00328 * Mouse position within the widget 00329 */ 00330 PLGUI_API virtual void OnMouseMove(const PLMath::Vector2i &vPos); 00331 00332 /** 00333 * @brief 00334 * Called when the mouse hovers over the widget 00335 */ 00336 PLGUI_API virtual void OnMouseHover(); 00337 00338 /** 00339 * @brief 00340 * Called when the mouse position inside the widget has changed 00341 * 00342 * @param[in] vPos 00343 * Mouse position within the widget 00344 * 00345 * @remarks 00346 * This function is called, when the mouse position inside the widget has changed without 00347 * the user moving the mouse. This is the case e.g. when the widget has been moved while the 00348 * mouse was inside. Usually, you should only need OnMouseMove() to react on mouse movements, 00349 * but when implementing widget movement, you must also react on OnMousePosUpdate() to update 00350 * the new mouse position without doing any action. This is especially important in order to 00351 * let several Widget-Modifiers work together without interfering each other. 00352 */ 00353 PLGUI_API virtual void OnMousePosUpdate(const PLMath::Vector2i &vPos); 00354 00355 /** 00356 * @brief 00357 * Called when a mouse button is pressed 00358 * 00359 * @param[in] nButton 00360 * Mouse button that is pressed 00361 * @param[in] vPos 00362 * Mouse position within the widget 00363 */ 00364 PLGUI_API virtual void OnMouseButtonDown(PLCore::uint32 nButton, const PLMath::Vector2i &vPos); 00365 00366 /** 00367 * @brief 00368 * Called when a mouse button is released 00369 * 00370 * @param[in] nButton 00371 * Mouse button that is released 00372 * @param[in] vPos 00373 * Mouse position within the widget 00374 */ 00375 PLGUI_API virtual void OnMouseButtonUp(PLCore::uint32 nButton, const PLMath::Vector2i &vPos); 00376 00377 /** 00378 * @brief 00379 * Called when a mouse button is clicked 00380 * 00381 * @param[in] nButton 00382 * Mouse button that is clicked 00383 * @param[in] vPos 00384 * Mouse position within the widget 00385 */ 00386 PLGUI_API virtual void OnMouseButtonClick(PLCore::uint32 nButton, const PLMath::Vector2i &vPos); 00387 00388 /** 00389 * @brief 00390 * Called when a mouse button is double-clicked 00391 * 00392 * @param[in] nButton 00393 * Mouse button that is double-clicked 00394 * @param[in] vPos 00395 * Mouse position within the widget 00396 */ 00397 PLGUI_API virtual void OnMouseButtonDoubleClick(PLCore::uint32 nButton, const PLMath::Vector2i &vPos); 00398 00399 /** 00400 * @brief 00401 * Called when the mouse wheel is used 00402 * 00403 * @param[in] nDelta 00404 * Mouse wheel movement 00405 */ 00406 PLGUI_API virtual void OnMouseWheel(int nDelta); 00407 00408 /** 00409 * @brief 00410 * Called when a key was pressed 00411 * 00412 * @param[in] nKey 00413 * Pressed key 00414 * @param[in] nModifiers 00415 * Modifier keys pressed 00416 * 00417 * @note 00418 * - Because of a possible autorepeat the key may be 'pressed' multiple times 00419 * before the 'OnKeyUp'-function is called 00420 */ 00421 PLGUI_API virtual void OnKeyDown(PLCore::uint32 nKey, PLCore::uint32 nModifiers); 00422 00423 /** 00424 * @brief 00425 * Called when a key was released 00426 * 00427 * @param[in] nKey 00428 * Released key 00429 * @param[in] nModifiers 00430 * Modifier keys pressed 00431 */ 00432 PLGUI_API virtual void OnKeyUp(PLCore::uint32 nKey, PLCore::uint32 nModifiers); 00433 00434 /** 00435 * @brief 00436 * Called when a hotkey was pressed 00437 * 00438 * @param[in] nHotkey 00439 * Hotkey ID 00440 */ 00441 PLGUI_API virtual void OnHotkey(PLCore::uint32 nHotkey); 00442 00443 /** 00444 * @brief 00445 * Called when data has been dropped onto the widget 00446 * 00447 * @param[in] cData 00448 * Data 00449 */ 00450 PLGUI_API virtual void OnDrop(const DataObject &cData); 00451 00452 /** 00453 * @brief 00454 * Called when a user defined message has been sent 00455 * 00456 * @param[in] nData 00457 * Message data 00458 * @param[in] pDataPtr 00459 * Data pointer 00460 */ 00461 PLGUI_API virtual void OnUserMessage(PLCore::uint32 nData, void *pDataPtr); 00462 00463 00464 }; 00465 00466 00467 //[-------------------------------------------------------] 00468 //[ Namespace ] 00469 //[-------------------------------------------------------] 00470 } // PLGui 00471 00472 00473 #endif // __PLGUI_WIDGETFUNCTIONS_H__
|