PixelLightAPI  .
GuiMessage.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: GuiMessage.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_GUIMESSAGE_H__
00024 #define __PLGUI_GUIMESSAGE_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/PLCore.h>
00032 #include <PLMath/Vector2i.h>
00033 #include "PLGui/PLGui.h"
00034 
00035 
00036 //[-------------------------------------------------------]
00037 //[ Namespace                                             ]
00038 //[-------------------------------------------------------]
00039 namespace PLGui {
00040 
00041 
00042 //[-------------------------------------------------------]
00043 //[ Forward declarations                                  ]
00044 //[-------------------------------------------------------]
00045 class Widget;
00046 class Graphics;
00047 class DataObject;
00048 class Timer;
00049 
00050 
00051 //[-------------------------------------------------------]
00052 //[ Classes                                               ]
00053 //[-------------------------------------------------------]
00054 /**
00055 *  @brief
00056 *    GUI message/event
00057 */
00058 class GuiMessage {
00059 
00060 
00061     //[-------------------------------------------------------]
00062     //[ Public named constructors                             ]
00063     //[-------------------------------------------------------]
00064     public:
00065         static PLGUI_API GuiMessage OnWakeup();
00066         static PLGUI_API GuiMessage OnExit();
00067         static PLGUI_API GuiMessage OnTimer(Timer *pTimer);
00068         static PLGUI_API GuiMessage OnUserMessage(Widget *pWidget, PLCore::uint32 nData, void *pData);
00069         static PLGUI_API GuiMessage OnInternalMessage(PLCore::uint32 nData, PLCore::uint32 nExtData);
00070         static PLGUI_API GuiMessage OnThemeChanged(Widget *pWidget);
00071         static PLGUI_API GuiMessage OnUpdateContent(Widget *pWidget);
00072         static PLGUI_API GuiMessage OnUpdateChildWidget(Widget *pWidget, Widget *pChildWidget);
00073         static PLGUI_API GuiMessage OnAddChildWidget(Widget *pWidget, Widget *pChildWidget);
00074         static PLGUI_API GuiMessage OnRemoveChildWidget(Widget *pWidget, Widget *pChildWidget);
00075         static PLGUI_API GuiMessage OnClose(Widget *pWidget);
00076         static PLGUI_API GuiMessage OnCreate(Widget *pWidget);
00077         static PLGUI_API GuiMessage OnDestroy(Widget *pWidget);
00078         static PLGUI_API GuiMessage OnShow(Widget *pWidget);
00079         static PLGUI_API GuiMessage OnHide(Widget *pWidget);
00080         static PLGUI_API GuiMessage OnEnable(Widget *pWidget);
00081         static PLGUI_API GuiMessage OnDisable(Widget *pWidget);
00082         static PLGUI_API GuiMessage OnGetFocus(Widget *pWidget);
00083         static PLGUI_API GuiMessage OnLooseFocus(Widget *pWidget);
00084         static PLGUI_API GuiMessage OnActivate(Widget *pWidget, bool bActivate);
00085         static PLGUI_API GuiMessage OnDrawBackground(Widget *pWidget, Graphics *pGraphics);
00086         static PLGUI_API GuiMessage OnDraw(Widget *pWidget, Graphics *pGraphics);
00087         static PLGUI_API GuiMessage OnMove(Widget *pWidget, const PLMath::Vector2i &vPos);
00088         static PLGUI_API GuiMessage OnSize(Widget *pWidget, const PLMath::Vector2i &vSize);
00089         static PLGUI_API GuiMessage OnWindowState(Widget *pWidget, EWindowState nWindowState);
00090         static PLGUI_API GuiMessage OnEnterFullscreen(Widget *pWidget);
00091         static PLGUI_API GuiMessage OnLeaveFullscreen(Widget *pWidget);
00092         static PLGUI_API GuiMessage OnPreferredSize(Widget *pWidget, const PLMath::Vector2i &vSize);
00093         static PLGUI_API GuiMessage OnAdjustContent(Widget *pWidget);
00094         static PLGUI_API GuiMessage OnMouseEnter(Widget *pWidget);
00095         static PLGUI_API GuiMessage OnMouseLeave(Widget *pWidget);
00096         static PLGUI_API GuiMessage OnMouseOver(Widget *pWidget, bool bMouseOver);
00097         static PLGUI_API GuiMessage OnMouseMove(Widget *pWidget, const PLMath::Vector2i &vPos);
00098         static PLGUI_API GuiMessage OnMouseHover(Widget *pWidget);
00099         static PLGUI_API GuiMessage OnMousePosUpdate(Widget *pWidget, const PLMath::Vector2i &vPos);
00100         static PLGUI_API GuiMessage OnMouseButtonDown(Widget *pWidget, EMouseButton nButton, const PLMath::Vector2i &vPos);
00101         static PLGUI_API GuiMessage OnMouseButtonUp(Widget *pWidget, EMouseButton nButton, const PLMath::Vector2i &vPos);
00102         static PLGUI_API GuiMessage OnMouseButtonClick(Widget *pWidget, EMouseButton nButton, const PLMath::Vector2i &vPos);
00103         static PLGUI_API GuiMessage OnMouseButtonDoubleClick(Widget *pWidget, EMouseButton nButton, const PLMath::Vector2i &vPos);
00104         static PLGUI_API GuiMessage OnMouseWheel(Widget *pWidget, int nDelta);
00105         static PLGUI_API GuiMessage OnKeyDown(Widget *pWidget, PLCore::uint32 nKey, PLCore::uint32 nModifiers);
00106         static PLGUI_API GuiMessage OnKeyUp(Widget *pWidget, PLCore::uint32 nKey, PLCore::uint32 nModifiers);
00107         static PLGUI_API GuiMessage OnHotkey(Widget *pWidget, PLCore::uint32 nHotkey);
00108         static PLGUI_API GuiMessage OnDrop(Widget *pWidget, DataObject *pDataObject);
00109 
00110 
00111     //[-------------------------------------------------------]
00112     //[ Public functions                                      ]
00113     //[-------------------------------------------------------]
00114     public:
00115         /**
00116         *  @brief
00117         *    Constructor
00118         *
00119         *  @param[in] pWidget
00120         *    Message target
00121         *  @param[in] nType
00122         *    Message type
00123         */
00124         PLGUI_API GuiMessage(Widget *pWidget = nullptr, EMessageType nType = MessageOnUnknown);
00125 
00126         /**
00127         *  @brief
00128         *    Copy constructor
00129         *
00130         *  @param[in] cOther
00131         *    GUI message
00132         */
00133         PLGUI_API GuiMessage(const GuiMessage &cOther);
00134 
00135         /**
00136         *  @brief
00137         *    Destructor
00138         */
00139         PLGUI_API ~GuiMessage();
00140 
00141         /**
00142         *  @brief
00143         *    Comparison operator
00144         *
00145         *  @param[in] cOther
00146         *    GUI message
00147         *
00148         *  @return
00149         *    'true' if equal, else 'false'
00150         */
00151         PLGUI_API bool operator ==(const GuiMessage &cOther) const;
00152 
00153         /**
00154         *  @brief
00155         *    Assignment operator
00156         *
00157         *  @param[in] cOther
00158         *    GUI message
00159         *
00160         *  @return
00161         *    Reference to this object
00162         */
00163         PLGUI_API GuiMessage &operator =(const GuiMessage &cOther);
00164 
00165         /**
00166         *  @brief
00167         *    Get message representation as string
00168         *
00169         *  @return
00170         *    Message as string
00171         */
00172         PLGUI_API PLCore::String ToString() const;
00173 
00174         /**
00175         *  @brief
00176         *    Get message target
00177         *
00178         *  @return
00179         *    Widget
00180         */
00181         inline Widget *GetWidget() const {
00182             return m_pWidget;
00183         }
00184 
00185         /**
00186         *  @brief
00187         *    Get message type
00188         *
00189         *  @return
00190         *    Message type
00191         */
00192         inline EMessageType GetType() const {
00193             return m_nType;
00194         }
00195 
00196         /**
00197         *  @brief
00198         *    Get message data
00199         *
00200         *  @return
00201         *    Message data
00202         */
00203         inline PLCore::uint32 GetData() const {
00204             return m_nData;
00205         }
00206 
00207         /**
00208         *  @brief
00209         *    Get delta
00210         *
00211         *  @return
00212         *    Delta value
00213         */
00214         inline int GetDelta() const {
00215             return m_nDelta;
00216         }
00217 
00218         /**
00219         *  @brief
00220         *    Get window state
00221         *
00222         *  @return
00223         *    Window state
00224         */
00225         inline EWindowState GetWindowState() const {
00226             return m_nWindowState;
00227         }
00228 
00229         /**
00230         *  @brief
00231         *    Get mouse button
00232         *
00233         *  @return
00234         *    Mouse button
00235         */
00236         inline EMouseButton GetMouseButton() const {
00237             return m_nMouseButton;
00238         }
00239 
00240         /**
00241         *  @brief
00242         *    Get key
00243         *
00244         *  @return
00245         *    Key
00246         */
00247         inline PLCore::uint32 GetKey() const {
00248             return m_nKey;
00249         }
00250 
00251         /**
00252         *  @brief
00253         *    Get boolean state
00254         *
00255         *  @return
00256         *    State
00257         */
00258         inline bool GetState() const {
00259             return m_bState;
00260         }
00261 
00262         /**
00263         *  @brief
00264         *    Get data pointer
00265         *
00266         *  @return
00267         *    Data pointer
00268         */
00269         inline void *GetDataPointer() const {
00270             return m_pDataPtr;
00271         }
00272 
00273         /**
00274         *  @brief
00275         *    Get secondary data
00276         *
00277         *  @return
00278         *    Message data
00279         */
00280         inline PLCore::uint32 GetExtData() const {
00281             return m_nExtData;
00282         }
00283 
00284         /**
00285         *  @brief
00286         *    Get data object
00287         *
00288         *  @return
00289         *    Data pointer
00290         */
00291         inline DataObject *GetDataObject() const {
00292             return m_pDataObject;
00293         }
00294 
00295         /**
00296         *  @brief
00297         *    Get child widget
00298         *
00299         *  @return
00300         *    Widget
00301         */
00302         inline Widget *GetChildWidget() const {
00303             return m_pChildWidget;
00304         }
00305 
00306         /**
00307         *  @brief
00308         *    Get graphics object
00309         *
00310         *  @return
00311         *    Graphics object
00312         */
00313         inline Graphics *GetGraphics() const {
00314             return m_pGraphics;
00315         }
00316 
00317         /**
00318         *  @brief
00319         *    Get timer object
00320         *
00321         *  @return
00322         *    Timer object
00323         */
00324         inline Timer *GetTimer() const {
00325             return m_pTimer;
00326         }
00327 
00328         /**
00329         *  @brief
00330         *    Get modifier keys
00331         *
00332         *  @return
00333         *    Modifiers
00334         */
00335         inline const PLCore::uint32 GetModifiers() const {
00336             return m_nModifiers;
00337         }
00338 
00339         /**
00340         *  @brief
00341         *    Get position or size
00342         *
00343         *  @return
00344         *    Vector
00345         */
00346         inline const PLMath::Vector2i &GetPosSize() const {
00347             return m_vPosSize;
00348         }
00349 
00350 
00351     //[-------------------------------------------------------]
00352     //[ Protected data                                        ]
00353     //[-------------------------------------------------------]
00354     protected:
00355         // Message target
00356         Widget              *m_pWidget;         /**< Widget */
00357 
00358         // Message type
00359         EMessageType         m_nType;           /**< Message type */
00360 
00361         // First message data
00362         union {
00363             PLCore::uint32   m_nData;           /**< Message data */
00364             int              m_nDelta;          /**< Movement delta */
00365             EWindowState     m_nWindowState;    /**< Window state */
00366             EMouseButton     m_nMouseButton;    /**< Mouse button */
00367             PLCore::uint32   m_nKey;            /**< Key code */
00368             bool             m_bState;          /**< Boolean state */
00369         };
00370 
00371         // Second message data
00372         union {
00373             void            *m_pDataPtr;        /**< Message data pointer */
00374             PLCore::uint32   m_nExtData;        /**< Secondary data */
00375             DataObject      *m_pDataObject;     /**< Data object */
00376             Widget          *m_pChildWidget;    /**< Child widget */
00377             Graphics        *m_pGraphics;       /**< Graphics object */
00378             Timer           *m_pTimer;          /**< Timer object */
00379             PLCore::uint32   m_nModifiers;      /**< Key modifiers */
00380         };
00381 
00382         // Position or size data
00383         PLMath::Vector2i     m_vPosSize;        /**< Position or size */
00384 
00385 
00386 };
00387 
00388 
00389 //[-------------------------------------------------------]
00390 //[ Namespace                                             ]
00391 //[-------------------------------------------------------]
00392 } // PLGui
00393 
00394 
00395 #endif // __PLGUI_GUIMESSAGE_H__


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