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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:56
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported