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


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:05
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported